[PATCH 8/8] conf: backup: Format index of 'store'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 docs/formatbackup.rst                          | 4 ++++
 src/conf/backup_conf.c                         | 8 +++++++-
 tests/qemustatusxml2xmldata/backup-pull-in.xml | 2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

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, "<driver type='%s'/>\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 @@
       <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>
-- 
2.28.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux