From: Peter Krempa Date: Thu, 14 Jan 2021 12:57:52 +0000 (+0100) Subject: conf: disk: Parse and format also for X-Git-Tag: v7.0.0~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=964650ed2a3e36a1e12d720ff5d9caa5a1552ebe;p=thirdparty%2Flibvirt.git conf: disk: Parse and format also for Commit 154df5840d added support for as property of a . Since the same parser is used to parse the XML used with virDomainBlockCopy it starts the copy job with the appropriate cache configured, but the doesn't show this configuration nor it's preserved if libvirtd is restarted during the mirror. Add parsing, formatting and tests for for a . Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 349fc28c2a..01b7187637 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8784,6 +8784,12 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, return -1; } + if (virParseScaledValue("./format/metadata_cache/max_size", NULL, + ctxt, + &def->mirror->metadataCacheMaxSize, + 1, ULLONG_MAX, false) < 0) + return -1; + return 0; } @@ -24283,6 +24289,8 @@ virDomainDiskDefFormatMirror(virBufferPtr buf, { g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) formatAttrBuf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) formatChildBuf = VIR_BUFFER_INIT_CHILD(&childBuf); const char *formatStr = NULL; /* For now, mirroring is currently output-only: we only output it @@ -24311,7 +24319,19 @@ virDomainDiskDefFormatMirror(virBufferPtr buf, virBufferEscapeString(&attrBuf, " ready='%s'", virDomainDiskMirrorStateTypeToString(disk->mirrorState)); - virBufferEscapeString(&childBuf, "\n", formatStr); + virBufferEscapeString(&formatAttrBuf, " type='%s'", formatStr); + if (disk->mirror->metadataCacheMaxSize > 0) { + g_auto(virBuffer) metadataCacheChildBuf = VIR_BUFFER_INIT_CHILD(&formatChildBuf); + + virBufferAsprintf(&metadataCacheChildBuf, + "%llu\n", + disk->mirror->metadataCacheMaxSize); + + virXMLFormatElement(&formatChildBuf, "metadata_cache", NULL, &metadataCacheChildBuf); + } + + virXMLFormatElement(&childBuf, "format", &formatAttrBuf, &formatChildBuf); + if (virDomainDiskSourceFormat(&childBuf, disk->mirror, "source", 0, true, flags, false, false, xmlopt) < 0) return -1; diff --git a/tests/qemuxml2argvdata/disk-mirror.xml b/tests/qemuxml2argvdata/disk-mirror.xml index 2d61fe29c3..73886e99f4 100644 --- a/tests/qemuxml2argvdata/disk-mirror.xml +++ b/tests/qemuxml2argvdata/disk-mirror.xml @@ -54,6 +54,20 @@ + + + + + + + 1234 + + + + + + + diff --git a/tests/qemuxml2xmloutdata/disk-mirror-active.xml b/tests/qemuxml2xmloutdata/disk-mirror-active.xml index 17fb061d49..0e2669398c 100644 --- a/tests/qemuxml2xmloutdata/disk-mirror-active.xml +++ b/tests/qemuxml2xmloutdata/disk-mirror-active.xml @@ -61,6 +61,22 @@
+ + + + + + + + 1234 + + + + + + +
+
@@ -71,7 +87,7 @@ -
+
diff --git a/tests/qemuxml2xmloutdata/disk-mirror-inactive.xml b/tests/qemuxml2xmloutdata/disk-mirror-inactive.xml index 157ffcf6b2..6c7f92c1cc 100644 --- a/tests/qemuxml2xmloutdata/disk-mirror-inactive.xml +++ b/tests/qemuxml2xmloutdata/disk-mirror-inactive.xml @@ -43,6 +43,13 @@
+ + + + + +
+
@@ -53,7 +60,7 @@ -
+