mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-17 06:03:52 +03:00
qemu: monitor: Add support for 'write-blocking' copy mode for blockdev-mirror
Forces the data to be written synchronously to both the original and the mirrored images which ensures that the job will reach synchronized phase. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
701c8c2467
commit
7d773a77ff
@ -15149,7 +15149,8 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
ret = qemuMonitorBlockdevMirror(priv->mon, job->name, true,
|
ret = qemuMonitorBlockdevMirror(priv->mon, job->name, true,
|
||||||
qemuDomainDiskGetTopNodename(disk),
|
qemuDomainDiskGetTopNodename(disk),
|
||||||
mirror->nodeformat, bandwidth,
|
mirror->nodeformat, bandwidth,
|
||||||
granularity, buf_size, mirror_shallow);
|
granularity, buf_size, mirror_shallow,
|
||||||
|
false);
|
||||||
} else {
|
} else {
|
||||||
/* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specified
|
/* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specified
|
||||||
* by the user */
|
* by the user */
|
||||||
|
@ -959,7 +959,8 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriver *driver,
|
|||||||
if (mon_ret == 0)
|
if (mon_ret == 0)
|
||||||
mon_ret = qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), jobname, persistjob,
|
mon_ret = qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), jobname, persistjob,
|
||||||
sourcename, copysrc->nodeformat,
|
sourcename, copysrc->nodeformat,
|
||||||
mirror_speed, 0, 0, mirror_shallow);
|
mirror_speed, 0, 0, mirror_shallow,
|
||||||
|
false);
|
||||||
|
|
||||||
if (mon_ret != 0)
|
if (mon_ret != 0)
|
||||||
qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), data);
|
qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), data);
|
||||||
|
@ -3058,17 +3058,19 @@ qemuMonitorBlockdevMirror(qemuMonitor *mon,
|
|||||||
unsigned long long bandwidth,
|
unsigned long long bandwidth,
|
||||||
unsigned int granularity,
|
unsigned int granularity,
|
||||||
unsigned long long buf_size,
|
unsigned long long buf_size,
|
||||||
bool shallow)
|
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, bandwidth=%lld, "
|
||||||
"granularity=%#x, buf_size=%lld, shallow=%d",
|
"granularity=%#x, buf_size=%lld, shallow=%d syncWrite=%d",
|
||||||
NULLSTR(jobname), persistjob, device, target, bandwidth, granularity,
|
NULLSTR(jobname), persistjob, device, target, bandwidth, granularity,
|
||||||
buf_size, shallow);
|
buf_size, shallow, syncWrite);
|
||||||
|
|
||||||
QEMU_CHECK_MONITOR(mon);
|
QEMU_CHECK_MONITOR(mon);
|
||||||
|
|
||||||
return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device, target,
|
return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device, target,
|
||||||
bandwidth, granularity, buf_size, shallow);
|
bandwidth, granularity, buf_size, shallow,
|
||||||
|
syncWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1079,7 +1079,8 @@ int qemuMonitorBlockdevMirror(qemuMonitor *mon,
|
|||||||
unsigned long long bandwidth,
|
unsigned long long bandwidth,
|
||||||
unsigned int granularity,
|
unsigned int granularity,
|
||||||
unsigned long long buf_size,
|
unsigned long long buf_size,
|
||||||
bool shallow)
|
bool shallow,
|
||||||
|
bool syncWrite)
|
||||||
ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
|
ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
|
||||||
int qemuMonitorDrivePivot(qemuMonitor *mon,
|
int qemuMonitorDrivePivot(qemuMonitor *mon,
|
||||||
const char *jobname)
|
const char *jobname)
|
||||||
|
@ -4305,17 +4305,22 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
|
|||||||
unsigned long long speed,
|
unsigned long long speed,
|
||||||
unsigned int granularity,
|
unsigned int granularity,
|
||||||
unsigned long long buf_size,
|
unsigned long long buf_size,
|
||||||
bool shallow)
|
bool shallow,
|
||||||
|
bool syncWrite)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) cmd = NULL;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
g_autoptr(virJSONValue) reply = NULL;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT;
|
virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT;
|
||||||
virTristateBool autodismiss = VIR_TRISTATE_BOOL_ABSENT;
|
virTristateBool autodismiss = VIR_TRISTATE_BOOL_ABSENT;
|
||||||
const char *syncmode = "full";
|
const char *syncmode = "full";
|
||||||
|
const char *copymode = NULL;
|
||||||
|
|
||||||
if (shallow)
|
if (shallow)
|
||||||
syncmode = "top";
|
syncmode = "top";
|
||||||
|
|
||||||
|
if (syncWrite)
|
||||||
|
copymode = "write-blocking";
|
||||||
|
|
||||||
if (persistjob) {
|
if (persistjob) {
|
||||||
autofinalize = VIR_TRISTATE_BOOL_YES;
|
autofinalize = VIR_TRISTATE_BOOL_YES;
|
||||||
autodismiss = VIR_TRISTATE_BOOL_NO;
|
autodismiss = VIR_TRISTATE_BOOL_NO;
|
||||||
@ -4329,6 +4334,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
|
|||||||
"z:granularity", granularity,
|
"z:granularity", granularity,
|
||||||
"P:buf-size", buf_size,
|
"P:buf-size", buf_size,
|
||||||
"s:sync", syncmode,
|
"s:sync", syncmode,
|
||||||
|
"S:copy-mode", copymode,
|
||||||
"T:auto-finalize", autofinalize,
|
"T:auto-finalize", autofinalize,
|
||||||
"T:auto-dismiss", autodismiss,
|
"T:auto-dismiss", autodismiss,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -266,7 +266,8 @@ int qemuMonitorJSONBlockdevMirror(qemuMonitor *mon,
|
|||||||
unsigned long long speed,
|
unsigned long long speed,
|
||||||
unsigned int granularity,
|
unsigned int granularity,
|
||||||
unsigned long long buf_size,
|
unsigned long long buf_size,
|
||||||
bool shallow)
|
bool shallow,
|
||||||
|
bool syncWrite)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
|
||||||
int qemuMonitorJSONDrivePivot(qemuMonitor *mon,
|
int qemuMonitorJSONDrivePivot(qemuMonitor *mon,
|
||||||
const char *jobname)
|
const char *jobname)
|
||||||
|
@ -1175,7 +1175,7 @@ GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
|
|||||||
GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
|
GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
|
GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", 1024, 1234, 31234, true, true)
|
GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", 1024, 1234, 31234, true, true)
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", 1024, 1234, 31234, true)
|
GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", 1024, 1234, 31234, true, true)
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/bar1", "backingnode", "backingfilename", 1024)
|
GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/bar1", "backingnode", "backingfilename", 1024)
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", true, "/foo/bar1", "topnode", "/foo/bar2", "basenode", "backingfilename", 1024)
|
GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", true, "/foo/bar1", "topnode", "/foo/bar2", "basenode", "backingfilename", 1024)
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb")
|
GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user