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

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



From: Chen Hanxiao <chenhanxiao gmail com>

Base upon patches from Roy Keene <rkeene knightpoint com>

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

Signed-off-by: Roy Keene <rkeene knightpoint com>
Signed-off-by: Chen Hanxiao <chenhanxiao gmail com>
---
v2-resend:
  rebase on upstream

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 93587e8..88492e0 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 0e434c0..25cfce3 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1896,7 +1896,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
@@ -1911,6 +1911,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



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