]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: add --image-format option to the save command
authorPavel Hrdina <phrdina@redhat.com>
Thu, 20 Mar 2025 22:34:44 +0000 (23:34 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 21 Mar 2025 09:56:19 +0000 (10:56 +0100)
Option --parallel-channels would require changing configuration file to
be used so introduce this option as well to make it convenient for
users.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
docs/manpages/virsh.rst
tools/virsh-domain.c

index 65ec03cf2020dec7bda8862e2cc9d526f49350e3..35ae6af547a89398f6b49c8c755c51a93a1758e4 100644 (file)
@@ -4179,6 +4179,7 @@ save
 ::
 
    save domain state-file [--bypass-cache] [--xml file]
+      [--image-format format]
       [--parallel-channels channels]
       [{--running | --paused}] [--verbose]
 
@@ -4213,6 +4214,10 @@ based on the state the domain was in when the save was done; passing
 either the *--running* or *--paused* flag will allow overriding which
 state the ``restore`` should use.
 
+*--image-format* option can change the default image format used to
+save data into file. For more details consult the qemu.conf configuration
+file.
+
 *--parallel-channels* option can specify number of parallel IO channels
 to be used when saving memory to file. Using parallel IO channels requires
 the use of ``sparse`` image save format. Parallel save may significantly
index 98f0e60ed41690df81494ec2ff81438757d19ab6..ceff6789d8c67c1661ea13e7fadc94bbfa766d66 100644 (file)
@@ -4534,6 +4534,10 @@ static const vshCmdOptDef opts_save[] = {
      .type = VSH_OT_INT,
      .help = N_("number of IO channels to use for parallel save")
     },
+    {.name = "image-format",
+     .type = VSH_OT_STRING,
+     .help = N_("format of the save image file")
+    },
     {.name = "xml",
      .type = VSH_OT_STRING,
      .unwanted_positional = true,
@@ -4570,6 +4574,7 @@ doSave(void *opaque)
     int nchannels = 0;
     unsigned int flags = 0;
     const char *xmlfile = NULL;
+    const char *format = NULL;
     g_autofree char *xml = NULL;
     int rc;
 #ifndef WIN32
@@ -4598,6 +4603,13 @@ doSave(void *opaque)
                              VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS, nchannels) < 0)
         goto out;
 
+    if (vshCommandOptString(ctl, cmd, "image-format", &format) < 0)
+        goto out;
+    if (format &&
+        virTypedParamsAddString(&params, &nparams, &maxparams,
+                                VIR_DOMAIN_SAVE_PARAM_IMAGE_FORMAT, format) < 0)
+        goto out;
+
     if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0)
         goto out;