diff --git a/docs/formatsnapshot.html.in b/docs/formatsnapshot.html.in index d640deb86d..e481284aa8 100644 --- a/docs/formatsnapshot.html.in +++ b/docs/formatsnapshot.html.in @@ -186,6 +186,10 @@ with an attribute type giving the driver type (such as qcow2), of the new file created by the external snapshot of the new file. + + Optionally metadata_cache sub-element can be used + with same semantics as the identically named subelement of the + domain definition disk's driver.
seclabel
diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.rng index e1fb4f7cea..58c370878d 100644 --- a/docs/schemas/domainsnapshot.rng +++ b/docs/schemas/domainsnapshot.rng @@ -212,7 +212,15 @@ - + + + + + + + + + diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 757af681cd..673282be7a 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -190,6 +190,12 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, goto cleanup; } + if (virParseScaledValue("./driver/metadata_cache/max_size", NULL, + ctxt, + &def->src->metadataCacheMaxSize, + 1, ULLONG_MAX, false) < 0) + goto cleanup; + /* validate that the passed path is absolute */ if (virStorageSourceIsRelative(def->src)) { virReportError(VIR_ERR_XML_ERROR, @@ -784,12 +790,27 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, virDomainSnapshotLocationTypeToString(disk->snapshot)); if (disk->src->path || disk->src->format != 0) { + g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) driverChildBuf = VIR_BUFFER_INIT_CHILD(&childBuf); + virBufferAsprintf(&attrBuf, " type='%s'", virStorageTypeToString(disk->src->type)); if (disk->src->format > 0) - virBufferEscapeString(&childBuf, "\n", + virBufferEscapeString(&driverAttrBuf, " type='%s'", virStorageFileFormatTypeToString(disk->src->format)); + if (disk->src->metadataCacheMaxSize > 0) { + g_auto(virBuffer) metadataCacheChildBuf = VIR_BUFFER_INIT_CHILD(&driverChildBuf); + + virBufferAsprintf(&metadataCacheChildBuf, + "%llu\n", + disk->src->metadataCacheMaxSize); + + virXMLFormatElement(&driverChildBuf, "metadata_cache", NULL, &metadataCacheChildBuf); + } + + virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, &driverChildBuf); + if (virDomainDiskSourceFormat(&childBuf, disk->src, "source", 0, false, 0, false, false, xmlopt) < 0) return -1; diff --git a/tests/qemudomainsnapshotxml2xmlin/qcow2-metadata-cache.xml b/tests/qemudomainsnapshotxml2xmlin/qcow2-metadata-cache.xml new file mode 100644 index 0000000000..92440aa0ae --- /dev/null +++ b/tests/qemudomainsnapshotxml2xmlin/qcow2-metadata-cache.xml @@ -0,0 +1,14 @@ + + my snap name + !@#$%^ + + + + + + 1234 + + + + + diff --git a/tests/qemudomainsnapshotxml2xmlout/qcow2-metadata-cache.xml b/tests/qemudomainsnapshotxml2xmlout/qcow2-metadata-cache.xml new file mode 100644 index 0000000000..def2a8ffce --- /dev/null +++ b/tests/qemudomainsnapshotxml2xmlout/qcow2-metadata-cache.xml @@ -0,0 +1,18 @@ + + my snap name + !@#$%^ + 1386166249 + + + + + 1234 + + + + + + + 9d37b878-a7cc-9f9a-b78f-49b3abad25a8 + + diff --git a/tests/qemudomainsnapshotxml2xmltest.c b/tests/qemudomainsnapshotxml2xmltest.c index 4b92967339..2a1fe1f52d 100644 --- a/tests/qemudomainsnapshotxml2xmltest.c +++ b/tests/qemudomainsnapshotxml2xmltest.c @@ -181,6 +181,9 @@ mymain(void) DO_TEST_IN("description_only", NULL); DO_TEST_IN("name_only", NULL); + DO_TEST_INOUT("qcow2-metadata-cache", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", + 1386166249, 0); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;