tools/save: Drop unused parameters from xc_domain_save()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 3 Jan 2020 18:31:46 +0000 (18:31 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 7 Jan 2020 12:26:45 +0000 (12:26 +0000)
XCFLAGS_CHECKPOINT_COMPRESS has been unused since c/s b15bc4345 (2015),
XCFLAGS_HVM since c/s 9e8672f1c (2013), and XCFLAGS_STDVGA since c/s
087d43326 (2007).  Drop the constants, and code which sets them.

The separate hvm parameter (appeared in c/s d11bec8a1, 2007 and ultimately
redundant with XCFLAGS_HVM), is used for sanity checking and debug printing,
then discarded and replaced with Xen's idea of whether the domain is PV or
HVM.

Rearrange the logic in xc_domain_save() to ask Xen sightly earlier, and use a
consistent idea of 'hvm' throughout.  Removing this parameter removes the
final user of libxl's dss->hvm, so drop that field as well.

Update the doxygen comment to be accurate.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <Ian.Jackson@citrix.com>
tools/libxc/include/xenguest.h
tools/libxc/xc_nomigrate.c
tools/libxc/xc_sr_save.c
tools/libxl/libxl_dom_save.c
tools/libxl/libxl_internal.h
tools/libxl/libxl_save_callout.c
tools/libxl/libxl_save_helper.c

index fdb03e32dae192eaf4f71c4921fd21de2578a4c9..1c358a05776b8b056e354f1afa84654454430c33 100644 (file)
@@ -26,9 +26,6 @@
 
 #define XCFLAGS_LIVE      (1 << 0)
 #define XCFLAGS_DEBUG     (1 << 1)
-#define XCFLAGS_HVM       (1 << 2)
-#define XCFLAGS_STDVGA    (1 << 3)
-#define XCFLAGS_CHECKPOINT_COMPRESS    (1 << 4)
 
 #define X86_64_B_SIZE   64 
 #define X86_32_B_SIZE   32
@@ -124,16 +121,18 @@ typedef enum {
 /**
  * This function will save a running domain.
  *
- * @parm xch a handle to an open hypervisor interface
- * @parm fd the file descriptor to save a domain to
- * @parm dom the id of the domain
+ * @param xch a handle to an open hypervisor interface
+ * @param io_fd the file descriptor to save a domain to
+ * @param dom the id of the domain
+ * @param flags XCFLAGS_xxx
  * @param stream_type XC_MIG_STREAM_NONE if the far end of the stream
  *        doesn't use checkpointing
+ * @param recv_fd Only used for XC_MIG_STREAM_COLO.  Contains backchannel from
+ *        the destination side.
  * @return 0 on success, -1 on failure
  */
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,
-                   uint32_t flags /* XCFLAGS_xxx */,
-                   struct save_callbacks* callbacks, int hvm,
+                   uint32_t flags, struct save_callbacks *callbacks,
                    xc_migration_stream_t stream_type, int recv_fd);
 
 /* callbacks provided by xc_domain_restore */
index c4dca88eb058c94231f3e572471064c9bd7ab9b9..5a1d7e46f93890511661e78b49ce10e8519bee6a 100644 (file)
@@ -21,7 +21,7 @@
 #include <xenguest.h>
 
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t flags,
-                   struct save_callbacks* callbacks, int hvm,
+                   struct save_callbacks *callbacks,
                    xc_migration_stream_t stream_type, int recv_fd)
 {
     errno = ENOSYS;
index 5a40e588e0a5b759ffa416848fd78b93f20af85e..6f61f85ee05003a4b69ade1797068092b6beadbc 100644 (file)
@@ -967,7 +967,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
 
 int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,
                    uint32_t flags, struct save_callbacks* callbacks,
-                   int hvm, xc_migration_stream_t stream_type, int recv_fd)
+                   xc_migration_stream_t stream_type, int recv_fd)
 {
     struct xc_sr_context ctx =
         {
@@ -982,32 +982,33 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,
     ctx.save.checkpointed = stream_type;
     ctx.save.recv_fd = recv_fd;
 
+    if ( xc_domain_getinfo(xch, dom, 1, &ctx.dominfo) != 1 )
+    {
+        PERROR("Failed to get domain info");
+        return -1;
+    }
+
+    if ( ctx.dominfo.domid != dom )
+    {
+        ERROR("Domain %u does not exist", dom);
+        return -1;
+    }
+
     /* If altering migration_stream update this assert too. */
     assert(stream_type == XC_MIG_STREAM_NONE ||
            stream_type == XC_MIG_STREAM_REMUS ||
            stream_type == XC_MIG_STREAM_COLO);
 
     /* Sanity checks for callbacks. */
-    if ( hvm )
+    if ( ctx.dominfo.hvm )
         assert(callbacks->switch_qemu_logdirty);
     if ( ctx.save.checkpointed )
         assert(callbacks->checkpoint && callbacks->postcopy);
     if ( ctx.save.checkpointed == XC_MIG_STREAM_COLO )
         assert(callbacks->wait_checkpoint);
 
-    DPRINTF("fd %d, dom %u, flags %u, hvm %d", io_fd, dom, flags, hvm);
-
-    if ( xc_domain_getinfo(xch, dom, 1, &ctx.dominfo) != 1 )
-    {
-        PERROR("Failed to get domain info");
-        return -1;
-    }
-
-    if ( ctx.dominfo.domid != dom )
-    {
-        ERROR("Domain %u does not exist", dom);
-        return -1;
-    }
+    DPRINTF("fd %d, dom %u, flags %u, hvm %d",
+            io_fd, dom, flags, ctx.dominfo.hvm);
 
     ctx.domid = dom;
 
index 65610e6055a7cb5c63af22fb448221e623c439d0..32e3cb5a1310348ff4a4c89b9a4d7ce2a1b2d692 100644 (file)
@@ -408,22 +408,8 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
     rc = libxl__domain_suspend_init(egc, dsps, type);
     if (rc) goto out;
 
-    switch (type) {
-    case LIBXL_DOMAIN_TYPE_PVH:
-    case LIBXL_DOMAIN_TYPE_HVM: {
-        dss->hvm = 1;
-        break;
-    }
-    case LIBXL_DOMAIN_TYPE_PV:
-        dss->hvm = 0;
-        break;
-    default:
-        abort();
-    }
-
     dss->xcflags = (live ? XCFLAGS_LIVE : 0)
-          | (debug ? XCFLAGS_DEBUG : 0)
-          | (dss->hvm ? XCFLAGS_HVM : 0);
+          | (debug ? XCFLAGS_DEBUG : 0);
 
     /* Disallow saving a guest with vNUMA configured because migration
      * stream does not preserve node information.
@@ -440,11 +426,6 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
         goto out;
     }
 
-    if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_REMUS) {
-        if (libxl_defbool_val(r_info->compression))
-            dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS;
-    }
-
     if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_NONE)
         callbacks->suspend = libxl__domain_suspend_callback;
 
index a99f3627e4df84c15a1f30ba067d0b9247cefb91..ba8c9b41ab9d3923598d0c0f855e5a48cf0b2958 100644 (file)
@@ -3591,7 +3591,6 @@ struct libxl__domain_save_state {
     const libxl_domain_remus_info *remus;
     /* private */
     int rc;
-    int hvm;
     int xcflags;
     libxl__domain_suspend_state dsps;
     union {
index caa139681318ad429fcc44eaea9bd248d220b06c..0b11495f9bf044ebc391d5805d913e9c7fa29f67 100644 (file)
@@ -87,7 +87,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
         libxl__srm_callout_enumcallbacks_save(&shs->callbacks.save.a);
 
     const unsigned long argnums[] = {
-        dss->domid, dss->xcflags, dss->hvm, cbflags,
+        dss->domid, dss->xcflags, cbflags,
         dss->checkpointed_stream,
     };
 
index cdad40be4f5332c6d4899a26ba0a894c7440f0d4..0f52930c45524c11f1cf8f7633eec304bae5eeb6 100644 (file)
@@ -252,7 +252,6 @@ int main(int argc, char **argv)
         recv_fd =                           atoi(NEXTARG);
         uint32_t dom =                      strtoul(NEXTARG,0,10);
         uint32_t flags =                    strtoul(NEXTARG,0,10);
-        int hvm =                           atoi(NEXTARG);
         unsigned cbflags =                  strtoul(NEXTARG,0,10);
         xc_migration_stream_t stream_type = strtoul(NEXTARG,0,10);
         assert(!*++argv);
@@ -263,7 +262,7 @@ int main(int argc, char **argv)
         setup_signals(save_signal_handler);
 
         r = xc_domain_save(xch, io_fd, dom, flags, &helper_save_callbacks,
-                           hvm, stream_type, recv_fd);
+                           stream_type, recv_fd);
         complete(r);
 
     } else if (!strcmp(mode,"--restore-domain")) {