]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Wire up 'replaces' attribute for 'blockdev-mirror'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 17 Mar 2025 16:15:22 +0000 (17:15 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 20 Mar 2025 05:42:43 +0000 (06:42 +0100)
The 'replaces' field controls which node will be replaced by the job.
This can be used to e.g. keep filter nodes in place after the copy
finishes.

This will be used to keep the 'copy-on-read' and 'throttle' layers in
place after a copy.

This patch wires up the monitor and test, but the real callers pass NULL
for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_driver.c
src/qemu/qemu_migration.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h
tests/qemumonitorjsontest.c

index d72805f0c7ecf69f416ae4b4ad6c3510fc818a2d..655521b5b7b7ba4876f640688f1a2f9372e041c3 100644 (file)
@@ -14383,6 +14383,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
     ret = qemuMonitorBlockdevMirror(priv->mon, job->name, true,
                                     qemuDomainDiskGetTopNodename(disk),
                                     qemuBlockStorageSourceGetEffectiveNodename(mirror),
+                                    NULL,
                                     bandwidth,
                                     granularity, buf_size, mirror_shallow,
                                     syncWrites);
index 02ba35dc59604d28965f6218295a02cc7e4cc570..75f5b0fa950ce5e3aa9018be9c7f17750222edb1 100644 (file)
@@ -1213,6 +1213,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virDomainObj *vm,
         mon_ret = qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), diskAlias, true,
                                             qemuDomainDiskGetTopNodename(disk),
                                             qemuBlockStorageSourceGetEffectiveNodename(copysrc),
+                                            NULL,
                                             mirror_speed, 0, 0, mirror_shallow,
                                             syncWrites);
 
index 8d8e73d38d22d52e3c2edf628df446e8376d7b82..a903e4ac7d3b83fea1da5caa316486d2fe1a85d1 100644 (file)
@@ -2784,20 +2784,21 @@ qemuMonitorBlockdevMirror(qemuMonitor *mon,
                           bool persistjob,
                           const char *device,
                           const char *target,
+                          const char *replaces,
                           unsigned long long bandwidth,
                           unsigned int granularity,
                           unsigned long long buf_size,
                           bool shallow,
                           bool syncWrite)
 {
-    VIR_DEBUG("jobname=%s, persistjob=%d, device=%s, target=%s, bandwidth=%lld, "
+    VIR_DEBUG("jobname=%s, persistjob=%d, device=%s, target=%s, replaces=%s, bandwidth=%lld, "
               "granularity=%#x, buf_size=%lld, shallow=%d syncWrite=%d",
-              NULLSTR(jobname), persistjob, device, target, bandwidth, granularity,
-              buf_size, shallow, syncWrite);
+              NULLSTR(jobname), persistjob, device, target, NULLSTR(replaces),
+              bandwidth, granularity, buf_size, shallow, syncWrite);
 
     QEMU_CHECK_MONITOR(mon);
 
-    return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device, target,
+    return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device, target, replaces,
                                          bandwidth, granularity, buf_size, shallow,
                                          syncWrite);
 }
index f7b9263b645edff2a57d359a832d17ea5ecd3fa0..8c3fb5e131178a08aba8f8d6ab3613841a0e008a 100644 (file)
@@ -981,6 +981,7 @@ int qemuMonitorBlockdevMirror(qemuMonitor *mon,
                               bool persistjob,
                               const char *device,
                               const char *target,
+                              const char *replaces,
                               unsigned long long bandwidth,
                               unsigned int granularity,
                               unsigned long long buf_size,
index 9c60807926619b4fe0f24324976bb891429118ab..646d8df24213eefc07a34dc3460b0fab0949a7a3 100644 (file)
@@ -4004,6 +4004,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
                               bool persistjob,
                               const char *device,
                               const char *target,
+                              const char *replaces,
                               unsigned long long speed,
                               unsigned int granularity,
                               unsigned long long buf_size,
@@ -4032,6 +4033,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
                                      "S:job-id", jobname,
                                      "s:device", device,
                                      "s:target", target,
+                                     "S:replaces", replaces,
                                      "Y:speed", speed,
                                      "z:granularity", granularity,
                                      "P:buf-size", buf_size,
index 25e3ae2cbb766acf584a955ebfc2ae501cef2268..77b8bf4a1b589f2f618549e9793792e2f66b519f 100644 (file)
@@ -272,6 +272,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
                               bool persistjob,
                               const char *device,
                               const char *target,
+                              const char *replaces,
                               unsigned long long speed,
                               unsigned int granularity,
                               unsigned long long buf_size,
index f0f6a329c88232115ed5fef48e5a336ab47c3718..afc2e54fd0f824fff634cd745c5687c526e60948 100644 (file)
@@ -1155,7 +1155,7 @@ GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
               "localhost", 12345, 12346, "certsubjectval")
 GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
 GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
-GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", 1024, 1234, 31234, true, true)
+GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", "replacenode", 1024, 1234, 31234, true, true)
 GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", "backingnode", "backingfilename", 1024)
 GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", "topnode", "basenode", "backingfilename", 1024, VIR_TRISTATE_BOOL_YES)
 GEN_TEST_FUNC(qemuMonitorJSONScreendump, "devicename", 1, NULL, "/foo/bar")