[xen master] libxl: add libxl_domain_suspend_only to simply suspend a domain, without saving it

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen master] libxl: add libxl_domain_suspend_only to simply suspend a domain, without saving it

patchbot
commit 9ee6308d5b9d227eba08b7a19fa660e7614e3d32
Author:     Marek Marczykowski-Górecki <[hidden email]>
AuthorDate: Wed Apr 4 19:01:12 2018 +0200
Commit:     Wei Liu <[hidden email]>
CommitDate: Fri Apr 6 09:05:25 2018 +0100

    libxl: add libxl_domain_suspend_only to simply suspend a domain, without saving it
   
    Similar functionality to libxl_domain_suspend(), but do not save domains
    state to any file. Only suspend the domain and keep it in suspended
    shutdown state (do not destroy it). Such domain can be later woken up
    with libxl_domain_resume. The main reason for this functionality is to
    suspend the host while some domains are running, potentially holding PCI
    devices. This will give a chance to a driver in such a domain to
    properly suspend the device.
   
    Signed-off-by: Marek Marczykowski-Górecki <[hidden email]>
    Signed-off-by: Marcus of Wetware Labs <[hidden email]>
    Acked-by: Wei Liu <[hidden email]>
---
 tools/libxl/libxl.h        | 16 ++++++++++++++++
 tools/libxl/libxl_domain.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index eea57cac62..a09d069358 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -839,6 +839,14 @@ typedef struct libxl__ctx libxl_ctx;
 #endif
 
 /*
+ * LIBXL_HAVE_DOMAIN_SUSPEND_ONLY
+ *
+ * If this is defined, function libxl_domains_suspend_only() is available.
+ */
+
+#define LIBXL_HAVE_DOMAIN_SUSPEND_ONLY 1
+
+/*
  * LIBXL_HAVE_DEVICE_PCI_SEIZE
  *
  * If this is defined, then the libxl_device_pci struct will contain
@@ -1484,6 +1492,14 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd,
 #define LIBXL_SUSPEND_DEBUG 1
 #define LIBXL_SUSPEND_LIVE 2
 
+/*
+ * Only suspend domain, do not save its state to file, do not destroy it.
+ * Suspended domain can be resumed with libxl_domain_resume()
+ */
+int libxl_domain_suspend_only(libxl_ctx *ctx, uint32_t domid,
+                         const libxl_asyncop_how *ao_how)
+                         LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* @param suspend_cancel [from xenctrl.h:xc_domain_resume( @param fast )]
  *   If this parameter is true, use co-operative resume. The guest
  *   must support this.
diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
index 13b1c73d40..533bcdf240 100644
--- a/tools/libxl/libxl_domain.c
+++ b/tools/libxl/libxl_domain.c
@@ -523,6 +523,40 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags,
     return AO_CREATE_FAIL(rc);
 }
 
+static void domain_suspend_empty_cb(libxl__egc *egc,
+                              libxl__domain_suspend_state *dss, int rc)
+{
+    STATE_AO_GC(dss->ao);
+    libxl__ao_complete(egc,ao,rc);
+}
+
+int libxl_domain_suspend_only(libxl_ctx *ctx, uint32_t domid,
+                              const libxl_asyncop_how *ao_how)
+{
+    AO_CREATE(ctx, domid, ao_how);
+    libxl__domain_suspend_state *dsps;
+    int rc;
+
+    libxl_domain_type type = libxl__domain_type(gc, domid);
+    if (type == LIBXL_DOMAIN_TYPE_INVALID) {
+        rc = ERROR_FAIL;
+        goto out_err;
+    }
+
+    GCNEW(dsps);
+    dsps->ao = ao;
+    dsps->domid = domid;
+    dsps->type = type;
+    rc = libxl__domain_suspend_init(egc, dsps, type);
+    if (rc < 0) goto out_err;
+    dsps->callback_common_done = domain_suspend_empty_cb;
+    libxl__domain_suspend(egc, dsps);
+    return AO_INPROGRESS;
+
+ out_err:
+    return AO_CREATE_FAIL(rc);
+}
+
 int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid)
 {
     int ret;
--
generated by git-patchbot for /home/xen/git/xen.git#master


_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog