mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-21 21:25:25 +00:00
conf: snapshot: Add support for <metadata_cache>
Similarly to the domain config code it may be beneficial to control the cache size of images introduced as snapshots into the backing chain. Wire up handling of the 'metadata_cache' element. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
154df5840d
commit
06380cb587
@ -186,6 +186,10 @@
|
||||
with an attribute <code>type</code> giving the driver type (such
|
||||
as qcow2), of the new file created by the external
|
||||
snapshot of the new file.
|
||||
|
||||
Optionally <code>metadata_cache</code> sub-element can be used
|
||||
with same semantics as the identically named subelement of the
|
||||
domain definition disk's driver.
|
||||
</dd>
|
||||
<dt><code>seclabel</code></dt>
|
||||
</dl>
|
||||
|
@ -212,7 +212,15 @@
|
||||
<ref name="storageFormatBacking"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
<empty/>
|
||||
<optional>
|
||||
<element name="metadata_cache">
|
||||
<optional>
|
||||
<element name="max_size">
|
||||
<ref name="scaledInteger"/>
|
||||
</element>
|
||||
</optional>
|
||||
</element>
|
||||
</optional>
|
||||
</element>
|
||||
</optional>
|
||||
</define>
|
||||
|
@ -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, "<driver type='%s'/>\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,
|
||||
"<max_size unit='bytes'>%llu</max_size>\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;
|
||||
|
14
tests/qemudomainsnapshotxml2xmlin/qcow2-metadata-cache.xml
Normal file
14
tests/qemudomainsnapshotxml2xmlin/qcow2-metadata-cache.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<domainsnapshot>
|
||||
<name>my snap name</name>
|
||||
<description>!@#$%^</description>
|
||||
<disks>
|
||||
<disk name='hdd' snapshot='external'>
|
||||
<source file='/path/to/new'/>
|
||||
<driver type='qcow2'>
|
||||
<metadata_cache>
|
||||
<max_size unit='bytes'>1234</max_size>
|
||||
</metadata_cache>
|
||||
</driver>
|
||||
</disk>
|
||||
</disks>
|
||||
</domainsnapshot>
|
18
tests/qemudomainsnapshotxml2xmlout/qcow2-metadata-cache.xml
Normal file
18
tests/qemudomainsnapshotxml2xmlout/qcow2-metadata-cache.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<domainsnapshot>
|
||||
<name>my snap name</name>
|
||||
<description>!@#$%^</description>
|
||||
<creationTime>1386166249</creationTime>
|
||||
<disks>
|
||||
<disk name='hdd' snapshot='external' type='file'>
|
||||
<driver type='qcow2'>
|
||||
<metadata_cache>
|
||||
<max_size unit='bytes'>1234</max_size>
|
||||
</metadata_cache>
|
||||
</driver>
|
||||
<source file='/path/to/new'/>
|
||||
</disk>
|
||||
</disks>
|
||||
<domain>
|
||||
<uuid>9d37b878-a7cc-9f9a-b78f-49b3abad25a8</uuid>
|
||||
</domain>
|
||||
</domainsnapshot>
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user