]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: monitor: Introduce support for blockdev-mirror
authorPeter Krempa <pkrempa@redhat.com>
Tue, 1 Mar 2016 13:55:34 +0000 (14:55 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 23 May 2018 11:18:25 +0000 (13:18 +0200)
drive-mirror allows only file targets. Introduce support for
blockdev-mirror that is able to copy to any BDS described by a node name
in qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index fb9583e4056b19f13d7fbb737b271fcee5712fa6..315bb460b9c1f5a030bd4cbc0b20bf80f498c751 100644 (file)
@@ -3362,6 +3362,28 @@ qemuMonitorDriveMirror(qemuMonitorPtr mon,
 }
 
 
+int
+qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
+                          const char *jobname,
+                          const char *device,
+                          const char *target,
+                          unsigned long long bandwidth,
+                          unsigned int granularity,
+                          unsigned long long buf_size,
+                          unsigned int flags)
+{
+    VIR_DEBUG("jobname=%s, device=%s, target=%s, bandwidth=%lld, "
+              "granularity=%#x, buf_size=%lld, flags=0x%x",
+              NULLSTR(jobname), device, target, bandwidth, granularity,
+              buf_size, flags);
+
+    QEMU_CHECK_MONITOR_JSON(mon);
+
+    return qemuMonitorJSONBlockdevMirror(mon, jobname, device, target, bandwidth,
+                                         granularity, buf_size, flags);
+}
+
+
 /* Use the transaction QMP command to run atomic snapshot commands.  */
 int
 qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions)
index 52ad843029938d4230a94f09a96afbba513c0a12..6acc4edffae88ed475aff34355e943dae30c295a 100644 (file)
@@ -860,6 +860,15 @@ int qemuMonitorDriveMirror(qemuMonitorPtr mon,
                            unsigned long long buf_size,
                            unsigned int flags)
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+int qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
+                              const char *jobname,
+                              const char *device,
+                              const char *target,
+                              unsigned long long bandwidth,
+                              unsigned int granularity,
+                              unsigned long long buf_size,
+                              unsigned int flags)
+    ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
 int qemuMonitorDrivePivot(qemuMonitorPtr mon,
                           const char *device)
     ATTRIBUTE_NONNULL(2);
index 61554a7ebc0ba31f0be61bffc21115fd60b52d1f..2a7abf538e38e787b2556fd1faadee8cb0cadcd5 100644 (file)
@@ -4189,6 +4189,45 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
     return ret;
 }
 
+
+int
+qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
+                              const char *jobname,
+                              const char *device,
+                              const char *target,
+                              unsigned long long speed,
+                              unsigned int granularity,
+                              unsigned long long buf_size,
+                              unsigned int flags)
+{
+    int ret = -1;
+    virJSONValuePtr cmd;
+    virJSONValuePtr reply = NULL;
+    bool shallow = (flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) != 0;
+
+    cmd = qemuMonitorJSONMakeCommand("blockdev-mirror",
+                                     "S:job-id", jobname,
+                                     "s:device", device,
+                                     "s:target", target,
+                                     "Y:speed", speed,
+                                     "z:granularity", granularity,
+                                     "P:buf-size", buf_size,
+                                     "s:sync", shallow ? "top" : "full",
+                                     NULL);
+    if (!cmd)
+        return -1;
+
+    if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
+        goto cleanup;
+    ret = qemuMonitorJSONCheckError(cmd, reply);
+
+ cleanup:
+    virJSONValueFree(cmd);
+    virJSONValueFree(reply);
+    return ret;
+}
+
+
 int
 qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions)
 {
index 22bcc1e8ef4839a893fff00acaa62e42ca6e419f..646cfcc8ac0afc3aee9ac577f788934fc660a19f 100644 (file)
@@ -264,6 +264,15 @@ int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
                                unsigned long long buf_size,
                                unsigned int flags)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon,
+                                  const char *jobname,
+                                  const char *device,
+                                  const char *target,
+                                  unsigned long long speed,
+                                  unsigned int granularity,
+                                  unsigned long long buf_size,
+                                  unsigned int flags)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
 int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon,
                               const char *device)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);