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 @@
-
+