[libvirt PATCH 3/6] qemu: block: blockpull param 'top' support in virsh proper

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

 



A new command-line option --top was added to virsh's blockpull command.
Similar to how --base is handled, in presence of --top the operation is
implemented internally as a rebase.  To that end, a corresponding new 'top'
parameter was added to virDomainBlockRebase().

Signed-off-by: Pavel Mores <pmores@xxxxxxxxxx>
---
 include/libvirt/libvirt-domain.h |  4 ++--
 src/libvirt-domain.c             |  5 +++--
 tools/virsh-domain.c             | 14 +++++++++++---
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index b440818ec2..069d7f98ec 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -2560,8 +2560,8 @@ typedef enum {
 } virDomainBlockRebaseFlags;
 
 int virDomainBlockRebase(virDomainPtr dom, const char *disk,
-                         const char *base, unsigned long bandwidth,
-                         unsigned int flags);
+                         const char *base, const char *top,
+                         unsigned long bandwidth, unsigned int flags);
 
 /**
  * virDomainBlockCopyFlags:
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 65813b68cc..1f9d1b5b84 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -10150,6 +10150,7 @@ virDomainBlockPull(virDomainPtr dom, const char *disk,
  * @disk: path to the block device, or device shorthand
  * @base: path to backing file to keep, or device shorthand,
  *        or NULL for no backing file
+ * @top: path to top file, or device shorthand, or NULL for no top
  * @bandwidth: (optional) specify bandwidth limit; flags determine the unit
  * @flags: bitwise-OR of virDomainBlockRebaseFlags
  *
@@ -10257,8 +10258,8 @@ virDomainBlockPull(virDomainPtr dom, const char *disk,
  */
 int
 virDomainBlockRebase(virDomainPtr dom, const char *disk,
-                     const char *base, unsigned long bandwidth,
-                     unsigned int flags)
+                     const char *base, const char *top,
+                     unsigned long bandwidth, unsigned int flags)
 {
     virConnectPtr conn;
 
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 9d0f7d68d2..47ccdd1b94 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2436,7 +2436,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
         if (bytes)
             flags |= VIR_DOMAIN_BLOCK_REBASE_BANDWIDTH_BYTES;
 
-        if (virDomainBlockRebase(dom, path, dest, bandwidth, flags) < 0)
+        if (virDomainBlockRebase(dom, path, dest, NULL, bandwidth, flags) < 0)
             goto cleanup;
     }
 
@@ -2765,6 +2765,10 @@ static const vshCmdOptDef opts_blockpull[] = {
      .type = VSH_OT_STRING,
      .help = N_("path of backing file in chain for a partial pull")
     },
+    {.name = "top",
+     .type = VSH_OT_STRING,
+     .help = N_("path of top backing file in chain for a partial pull")
+    },
     {.name = "wait",
      .type = VSH_OT_BOOL,
      .help = N_("wait for job to finish")
@@ -2804,6 +2808,7 @@ cmdBlockpull(vshControl *ctl, const vshCmd *cmd)
     int timeout = 0;
     const char *path = NULL;
     const char *base = NULL;
+    const char *top = NULL;
     unsigned long bandwidth = 0;
     unsigned int flags = 0;
     virshBlockJobWaitDataPtr bjWait = NULL;
@@ -2817,6 +2822,9 @@ cmdBlockpull(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
         return false;
 
+    if (vshCommandOptStringReq(ctl, cmd, "top", &top) < 0)
+        return false;
+
     if (vshBlockJobOptionBandwidth(ctl, cmd, bytes, &bandwidth) < 0)
         return false;
 
@@ -2834,11 +2842,11 @@ cmdBlockpull(vshControl *ctl, const vshCmd *cmd)
                                          verbose, timeout, async)))
         goto cleanup;
 
-    if (base || flags) {
+    if (base || top || flags) {
         if (bytes)
             flags |= VIR_DOMAIN_BLOCK_REBASE_BANDWIDTH_BYTES;
 
-        if (virDomainBlockRebase(dom, path, base, bandwidth, flags) < 0)
+        if (virDomainBlockRebase(dom, path, base, top, bandwidth, flags) < 0)
             goto cleanup;
     } else {
         if (bytes)
-- 
2.24.1





[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