[PATCH 2/2] virsh: introduce flage --pipe 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 --pipe flag for save command.

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 --pipe cirros  "${fifo}" &
# cat "${fifo}" | rbd --id cinder import - rbd/test1234 & wait; rm -f "${fifo}"

Cc: Roy Keene <rkeene@xxxxxxxxxxxxxxx>
Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxx>
---
 tools/virsh-domain.c | 6 ++++++
 tools/virsh.pod      | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index e359bfc..6ac3edf 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4170,6 +4170,10 @@ static const vshCmdOptDef opts_save[] = {
      .type = VSH_OT_BOOL,
      .help = N_("set domain to be paused on restore")
     },
+    {.name = "pipe",
+     .type = VSH_OT_BOOL,
+     .help = N_("the file being saved to is a pipe")
+    },
     {.name = "verbose",
      .type = VSH_OT_BOOL,
      .help = N_("display the progress of save")
@@ -4206,6 +4210,8 @@ doSave(void *opaque)
         flags |= VIR_DOMAIN_SAVE_RUNNING;
     if (vshCommandOptBool(cmd, "paused"))
         flags |= VIR_DOMAIN_SAVE_PAUSED;
+    if (vshCommandOptBool(cmd, "pipe"))
+        flags |= VIR_DOMAIN_SAVE_PIPE;
 
     if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0)
         goto out;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 247d235..8419db8 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1893,7 +1893,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<--pipe>] [I<--verbose>]
 
 Saves a running domain (RAM, but not disk state) to a state file so that
 it can be restored
@@ -1908,6 +1908,10 @@ 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.
+Flag I<--pipe> could let B<save> dumps domain's state to a PIPE.
+Try to write a PIPE without I<--pipe> would error out.
+
 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