]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: backup: Format index of 'store'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 7 Dec 2020 11:38:50 +0000 (12:38 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 8 Dec 2020 14:12:34 +0000 (15:12 +0100)
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>
docs/formatbackup.rst
src/conf/backup_conf.c
tests/qemustatusxml2xmldata/backup-pull-in.xml

index 1b9e6ebb226026456d0c7943ac8ad2da27f6c0c1..c378ad9d9a199dffcabd29256a20280e0ddbcfd6 100644 (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
index 11d419ce2bdc5d1e0a37bbbaaf26f30e4108a3f9..90ffcc51d14a6203707da380e736fc051ca34481 100644 (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));
index faaed67e385da85357250b9d97631a1cd9900964..bb322f94d323999b29dd5a56e3da2af474ea2879 100644 (file)
       <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>