[PATCH v2 2/2] virsh: introduce flage --direct for save command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Chen Hanxiao <chenhanxiao@xxxxxxxxx>

Base upon patches from Roy Keene <rkeene@xxxxxxxxxxxxxxx>

This patch introduces --direct flag for save command.

We could use this flag to save vm to a PIPE.

We could saving a VM state directly to Ceph RBD images
without having an intermediate file.

How to test:
fifo="$(mktemp -u)"; mkfifo "${fifo}" && virsh save --direct cirros  "${fifo}" &
cat "${fifo}" | rbd --id cinder import - hotsnapshot/test1234 & wait; rm -f "${fifo}"

Signed-off-by: Roy Keene <rkeene@xxxxxxxxxxxxxxx>
Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxx>
---
v2:
  rename VIR_DOMAIN_SAVE_PIPE to VIR_DOMAIN_SAVE_DIRECT

 tools/virsh-domain.c | 6 ++++++
 tools/virsh.pod      | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 3a6fa5c..3ab7457 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4187,6 +4187,10 @@ static const vshCmdOptDef opts_save[] = {
      .type = VSH_OT_BOOL,
      .help = N_("set domain to be paused on restore")
     },
+    {.name = "direct",
+     .type = VSH_OT_BOOL,
+     .help = N_("write the file directly, needed by PIPE/FIFO")
+    },
     {.name = "verbose",
      .type = VSH_OT_BOOL,
      .help = N_("display the progress of save")
@@ -4223,6 +4227,8 @@ doSave(void *opaque)
         flags |= VIR_DOMAIN_SAVE_RUNNING;
     if (vshCommandOptBool(cmd, "paused"))
         flags |= VIR_DOMAIN_SAVE_PAUSED;
+    if (vshCommandOptBool(cmd, "direct"))
+        flags |= VIR_DOMAIN_SAVE_DIRECT;
 
     if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0)
         goto out;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 74c05c9..a2c2cfe 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1898,7 +1898,7 @@ have also reverted all storage volumes back to the same contents as when
 the state file was created.
 
 =item B<save> I<domain> I<state-file> [I<--bypass-cache>] [I<--xml> B<file>]
-[{I<--running> | I<--paused>}] [I<--verbose>]
+[{I<--running> | I<--paused>}] [I<--direct>] [I<--verbose>]
 
 Saves a running domain (RAM, but not disk state) to a state file so that
 it can be restored
@@ -1913,6 +1913,9 @@ with B<domjobabort> command (sent by another virsh instance). Another option
 is to send SIGINT (usually with C<Ctrl-C>) to the virsh process running
 B<save> command. I<--verbose> displays the progress of save.
 
+Usually B<save> command will save the domain's state as a regular file.
+If you want to save it into a PIPE/FIFO, then flag I<--direct> must be set.
+
 This is roughly equivalent to doing a hibernate on a running computer,
 with all the same limitations.  Open network connections may be
 severed upon restore, as TCP timeouts may have expired.
-- 
2.7.4


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux