1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-04-01 20:05:19 +00:00

qemu: monitor: Wire up 'replaces' attribute for 'blockdev-mirror'

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>
This commit is contained in:
Peter Krempa 2025-03-17 17:15:22 +01:00
parent 6ccf67f5a7
commit ca429f102c
7 changed files with 12 additions and 5 deletions

View 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);

View 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);

View 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);
}

View 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,

View 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,

View 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,

View 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")