[PATCHv5 17/23] blockjob: wire up qemu and RPC for block copy

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

 



Almost trivial; the trick was dealing with the fact that we're
stuck with 'unsigned long bandwidth' due to earlier design
decisions.  Also, prefer the correct flag names (although we
intentionally chose the _SHALLOW and _REUSE_EXT values to be
equal, to allow for loose handling in our code).

* src/remote/remote_protocol.x (remote_domain_block_copy_args):
New struct.
* src/remote/remote_driver.c (remote_driver): Use it.
* src/rpc/gendispatch.pl (name_to_ProcName): Cater to legacy
bandwidth type.
* src/remote_protocol-structs: Regenerate.
* src/qemu/qemu_driver.c (qemuDriver): Wire up driver callback.
(qemuDomainBlockCopy): Use preferred flag names.
---
 src/qemu/qemu_driver.c       |   13 +++++++------
 src/remote/remote_driver.c   |    1 +
 src/remote/remote_protocol.x |   12 +++++++++++-
 src/remote_protocol-structs  |    9 +++++++++
 src/rpc/gendispatch.pl       |    1 +
 5 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f197627..a27f6c2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11938,8 +11938,8 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *path,
     char *origdriver = NULL;

     /* Preliminaries: find the disk we are editing, sanity checks */
-    virCheckFlags(VIR_DOMAIN_BLOCK_REBASE_SHALLOW |
-                  VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT, -1);
+    virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW |
+                  VIR_DOMAIN_BLOCK_COPY_REUSE_EXT, -1);

     qemuDriverLock(driver);
     virUUIDFormat(dom->uuid, uuidstr);
@@ -11992,7 +11992,7 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *path,
     /* XXX this is pessimistic; we could use 'query-block' or even
      * keep track of the backing chain ourselves, rather than assuming
      * that all non-raw source files have a current backing image */
-    if ((flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) &&
+    if ((flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) &&
         STREQ_NULLABLE(format, "raw") &&
         STRNEQ_NULLABLE(disk->driverType, "raw")) {
         qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -12007,14 +12007,14 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *path,
             virReportSystemError(errno, _("unable to stat for disk %s: %s"),
                                  disk->dst, dest);
             goto endjob;
-        } else if (flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT) {
+        } else if (flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT) {
             virReportSystemError(errno,
                                  _("missing destination file for disk %s: %s"),
                                  disk->dst, dest);
             goto endjob;
         }
     } else if (!S_ISBLK(st.st_mode) && st.st_size &&
-               !(flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)) {
+               !(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT)) {
         qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                         _("external destination file for disk %s already "
                           "exists and is not a block device: %s"),
@@ -12022,7 +12022,7 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *path,
         goto endjob;
     }

-    if (!(flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)) {
+    if (!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT)) {
         int fd = qemuOpenFile(driver, dest, O_WRONLY | O_TRUNC | O_CREAT,
                               &need_unlink, NULL);
         if (fd < 0)
@@ -13232,6 +13232,7 @@ static virDriver qemuDriver = {
     .domainBlockJobSetSpeed = qemuDomainBlockJobSetSpeed, /* 0.9.4 */
     .domainBlockPull = qemuDomainBlockPull, /* 0.9.4 */
     .domainBlockRebase = qemuDomainBlockRebase, /* 0.9.10 */
+    .domainBlockCopy = qemuDomainBlockCopy, /* 0.9.12 */
     .isAlive = qemuIsAlive, /* 0.9.8 */
     .nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.8 */
     .domainSetBlockIoTune = qemuDomainSetBlockIoTune, /* 0.9.8 */
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index af46384..b431779 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5095,6 +5095,7 @@ static virDriver remote_driver = {
     .domainBlockJobSetSpeed = remoteDomainBlockJobSetSpeed, /* 0.9.4 */
     .domainBlockPull = remoteDomainBlockPull, /* 0.9.4 */
     .domainBlockRebase = remoteDomainBlockRebase, /* 0.9.10 */
+    .domainBlockCopy = remoteDomainBlockCopy, /* 0.9.12 */
     .setKeepAlive = remoteSetKeepAlive, /* 0.9.8 */
     .isAlive = remoteIsAlive, /* 0.9.8 */
     .nodeSuspendForDuration = remoteNodeSuspendForDuration, /* 0.9.8 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 2d57247..65b4a1d 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1188,6 +1188,14 @@ struct remote_domain_block_rebase_args {
     unsigned hyper bandwidth;
     unsigned int flags;
 };
+struct remote_domain_block_copy_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string path;
+    remote_nonnull_string dest;
+    remote_string format;
+    unsigned hyper bandwidth;
+    unsigned int flags;
+};

 struct remote_domain_set_block_io_tune_args {
     remote_nonnull_domain dom;
@@ -2782,7 +2790,9 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_PM_WAKEUP = 267, /* autogen autogen */
     REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE = 268, /* autogen autogen */
     REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP = 269, /* autogen autogen */
-    REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270 /* autogen autogen */
+    REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270, /* autogen autogen */
+
+    REMOTE_PROC_DOMAIN_BLOCK_COPY = 271 /* autogen autogen */

     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 9b2414f..dd2aa72 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -845,6 +845,14 @@ struct remote_domain_block_rebase_args {
         uint64_t                   bandwidth;
         u_int                      flags;
 };
+struct remote_domain_block_copy_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      path;
+        remote_nonnull_string      dest;
+        remote_string              format;
+        uint64_t                   bandwidth;
+        u_int                      flags;
+};
 struct remote_domain_set_block_io_tune_args {
         remote_nonnull_domain      dom;
         remote_nonnull_string      disk;
@@ -2192,4 +2200,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE = 268,
         REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP = 269,
         REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270,
+        REMOTE_PROC_DOMAIN_BLOCK_COPY = 271,
 };
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index f161ee0..e5e28e0 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -232,6 +232,7 @@ my $long_legacy = {
     NodeGetInfo                 => { ret => { memory => 1 } },
     DomainBlockPull             => { arg => { bandwidth => 1 } },
     DomainBlockRebase           => { arg => { bandwidth => 1 } },
+    DomainBlockCopy             => { arg => { bandwidth => 1 } },
     DomainBlockJobSetSpeed      => { arg => { bandwidth => 1 } },
     DomainMigrateGetMaxSpeed    => { ret => { bandwidth => 1 } },
 };
-- 
1.7.7.6

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