diff --git a/docs/formatbackup.rst b/docs/formatbackup.rst index 1b9e6ebb22..c378ad9d9a 100644 --- a/docs/formatbackup.rst +++ b/docs/formatbackup.rst @@ -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 diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 11d419ce2b..90ffcc51d1 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -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, "\n", virStorageFileFormatTypeToString(disk->store->format)); diff --git a/tests/qemustatusxml2xmldata/backup-pull-in.xml b/tests/qemustatusxml2xmldata/backup-pull-in.xml index faaed67e38..bb322f94d3 100644 --- a/tests/qemustatusxml2xmldata/backup-pull-in.xml +++ b/tests/qemustatusxml2xmldata/backup-pull-in.xml @@ -256,7 +256,7 @@ 12345 - +