[PATCHv2 31/33] lib: Introduce flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE

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

 



Introduce flag for the block rebase API to allow the rebase operation to
leave the chain relatively addressed. Also adds a virsh switch to enable
this behavior.
---
 include/libvirt/libvirt.h.in |  2 ++
 tools/virsh-domain.c         | 22 +++++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 2df7fc8..a4fe175 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2571,6 +2571,8 @@ typedef enum {
                                                    file for a copy */
     VIR_DOMAIN_BLOCK_REBASE_COPY_RAW  = 1 << 2, /* Make destination file raw */
     VIR_DOMAIN_BLOCK_REBASE_COPY      = 1 << 3, /* Start a copy job */
+    VIR_DOMAIN_BLOCK_REBASE_RELATIVE  = 1 << 4, /* Keep backing chain relative
+                                                   if possible */
 } virDomainBlockRebaseFlags;

 int           virDomainBlockRebase(virDomainPtr dom, const char *disk,
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 5c3a142..74473a8 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1479,10 +1479,14 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
     case VSH_CMD_BLOCK_JOB_PULL:
         if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
             goto cleanup;
-        if (base)
-            ret = virDomainBlockRebase(dom, path, base, bandwidth, 0);
-        else
+        if (base) {
+          if (vshCommandOptBool(cmd, "keep-relative"))
+              flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;
+
+            ret = virDomainBlockRebase(dom, path, base, bandwidth, flags);
+        } else {
             ret = virDomainBlockPull(dom, path, bandwidth, 0);
+        }
         break;
     case VSH_CMD_BLOCK_JOB_COMMIT:
         if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0 ||
@@ -2071,6 +2075,11 @@ static const vshCmdOptDef opts_block_pull[] = {
      .type = VSH_OT_BOOL,
      .help = N_("with --wait, don't wait for cancel to finish")
     },
+    {.name = "keep-relative",
+     .type = VSH_OT_BOOL,
+     .help = N_("keep the backing chain relative if it was relatively "
+                "referenced if it was before")
+    },
     {.name = NULL}
 };

@@ -2091,6 +2100,13 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
     bool quit = false;
     int abort_flags = 0;

+    if (vshCommandOptBool(cmd, "keep-relative") &&
+        !vshCommandOptBool(cmd, "base")) {
+        vshError(ctl, "%s", _("--keep-relative is supported only with partial "
+                              "pull operations with --base specified"));
+        return false;
+    }
+
     if (blocking) {
         if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
             return false;
-- 
1.9.3

--
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]