1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

conf: backup: Format index of 'store'

Similarly to other disk-related stuff, the index is useful when you want
to refer to the image in APIs such as virDomainSetBlockThreshold.

For internal use we also need to parse it inside of the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-12-07 12:38:50 +01:00
parent 40242b7452
commit e3922af17c
3 changed files with 12 additions and 2 deletions

View File

@ -95,6 +95,10 @@ were supplied). The following child elements and attributes are supported:
Similar to a disk declaration for a domain, the choice of type controls
what additional sub-elements are needed to describe the destination.
``index``
Output only. The value can be used to refer to the scratch or output
file of the backup in APIs such as ``virDomainSetBlockThreshold``.
``target``
Valid only for push mode backups, this is the primary sub-element that
describes the file name of the backup destination, similar to the

View File

@ -105,6 +105,7 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
VIR_XPATH_NODE_AUTORESTORE(ctxt)
g_autofree char *type = NULL;
g_autofree char *format = NULL;
g_autofree char *idx = NULL;
g_autofree char *backup = NULL;
g_autofree char *state = NULL;
g_autofree char *backupmode = NULL;
@ -171,8 +172,10 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
type = virXMLPropString(node, "type");
format = virXPathString("string(./driver/@type)", ctxt);
if (internal)
idx = virXMLPropString(node, "index");
if (!(def->store = virDomainStorageSourceParseBase(type, format, NULL)))
if (!(def->store = virDomainStorageSourceParseBase(type, format, idx)))
return -1;
if (def->store->type != VIR_STORAGE_TYPE_FILE &&
@ -386,6 +389,9 @@ virDomainBackupDiskDefFormat(virBufferPtr buf,
virBufferEscapeString(&attrBuf, " exportname='%s'", disk->exportname);
virBufferEscapeString(&attrBuf, " exportbitmap='%s'", disk->exportbitmap);
if (disk->store->id != 0)
virBufferAsprintf(&attrBuf, " index='%u'", disk->store->id);
if (disk->store->format > 0)
virBufferEscapeString(&childBuf, "<driver type='%s'/>\n",
virStorageFileFormatTypeToString(disk->store->format));

View File

@ -256,7 +256,7 @@
<incremental>12345</incremental>
<server transport='tcp' tls='yes' name='localhost' port='10809'/>
<disks>
<disk name='vda' backup='yes' state='running' type='file'>
<disk name='vda' backup='yes' state='running' type='file' index='123'>
<scratch file='/path/to/file/'/>
</disk>
</disks>