Blob Blame History Raw
From 100ae962cd0f4dbfd5270bc2d61f05ec1c524c0a Mon Sep 17 00:00:00 2001
Message-Id: <100ae962cd0f4dbfd5270bc2d61f05ec1c524c0a@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 4 Feb 2020 15:07:40 +0100
Subject: [PATCH] conf: backup: Allow configuration of names exported via NBD
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If users wish to use different name for exported disks or bitmaps
the new fields allow to do so. Additionally they also document the
current settings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 12ccd8d4db12d71a270d903701a8edb83d41f127)

https://bugzilla.redhat.com/show_bug.cgi?id=1207659
Message-Id: <8043f75d8d4b4ae7e7ae3671d71407f733e6a3cf.1580824112.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 docs/formatbackup.html.in                             |  9 +++++++++
 docs/schemas/domainbackup.rng                         |  8 ++++++++
 src/conf/backup_conf.c                                | 10 ++++++++++
 src/conf/backup_conf.h                                |  2 ++
 tests/domainbackupxml2xmlin/backup-pull-seclabel.xml  |  2 +-
 tests/domainbackupxml2xmlout/backup-pull-seclabel.xml |  2 +-
 6 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/docs/formatbackup.html.in b/docs/formatbackup.html.in
index 1c690901c7..543d913072 100644
--- a/docs/formatbackup.html.in
+++ b/docs/formatbackup.html.in
@@ -85,6 +85,15 @@
               <dd>Setting this attribute to <code>yes</code>(default) specifies
                 that the disk should take part in the backup and using
                 <code>no</code> excludes the disk from the backup.</dd>
+              <dt><code>exportname</code></dt>
+              <dd>Allows modification of the NBD export name for the given disk.
+                By default equal to disk target.
+                Valid only for pull mode backups.</dd>
+              <dt><code>exportbitmap</code></dt>
+              <dd>Allows modification of the name of the bitmap describing dirty
+                blocks for an incremental backup exported via NBD export name
+                for the given disk.
+                Valid only for pull mode backups.</dd>
               <dt><code>type</code></dt>
               <dd>A mandatory attribute to describe the type of the
                 disk, except when <code>backup='no'</code> is
diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng
index c1e4d80302..395ea841f9 100644
--- a/docs/schemas/domainbackup.rng
+++ b/docs/schemas/domainbackup.rng
@@ -165,6 +165,14 @@
             <attribute name='name'>
               <ref name='diskTarget'/>
             </attribute>
+            <optional>
+              <attribute name='exportname'>
+                <text/>
+              </attribute>
+              <attribute name='exportbitmap'>
+                <text/>
+              </attribute>
+            </optional>
             <choice>
               <group>
                 <attribute name='backup'>
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
index 61dc8cd4b2..b370b686f1 100644
--- a/src/conf/backup_conf.c
+++ b/src/conf/backup_conf.c
@@ -71,6 +71,8 @@ virDomainBackupDefFree(virDomainBackupDefPtr def)
         virDomainBackupDiskDefPtr disk = def->disks + i;
 
         g_free(disk->name);
+        g_free(disk->exportname);
+        g_free(disk->exportbitmap);
         virObjectUnref(disk->store);
     }
 
@@ -124,6 +126,11 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
     if (def->backup == VIR_TRISTATE_BOOL_NO)
         return 0;
 
+    if (!push) {
+        def->exportname = virXMLPropString(node, "exportname");
+        def->exportbitmap = virXMLPropString(node, "exportbitmap");
+    }
+
     if (internal) {
         if (!(state = virXMLPropString(node, "state")) ||
             (tmp = virDomainBackupDiskStateTypeFromString(state)) < 0) {
@@ -333,6 +340,9 @@ virDomainBackupDiskDefFormat(virBufferPtr buf,
     if (disk->backup == VIR_TRISTATE_BOOL_YES) {
         virBufferAsprintf(&attrBuf, " type='%s'", virStorageTypeToString(disk->store->type));
 
+        virBufferEscapeString(&attrBuf, " exportname='%s'", disk->exportname);
+        virBufferEscapeString(&attrBuf, " exportbitmap='%s'", disk->exportbitmap);
+
         if (disk->store->format > 0)
             virBufferEscapeString(&childBuf, "<driver type='%s'/>\n",
                                   virStorageFileFormatTypeToString(disk->store->format));
diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h
index 7cf44245d4..672fd52ee7 100644
--- a/src/conf/backup_conf.h
+++ b/src/conf/backup_conf.h
@@ -51,6 +51,8 @@ typedef virDomainBackupDiskDef *virDomainBackupDiskDefPtr;
 struct _virDomainBackupDiskDef {
     char *name;     /* name matching the <target dev='...' of the domain */
     virTristateBool backup; /* whether backup is requested */
+    char *exportname; /* name of the NBD export for pull mode backup */
+    char *exportbitmap; /* name of the bitmap exposed in NBD for pull mode backup */
 
     /* details of target for push-mode, or of the scratch file for pull-mode */
     virStorageSourcePtr store;
diff --git a/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml b/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml
index a00d8758bb..4e6e602c19 100644
--- a/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml
+++ b/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml
@@ -2,7 +2,7 @@
   <incremental>1525889631</incremental>
   <server transport='tcp' name='localhost' port='10809'/>
   <disks>
-    <disk name='vda' type='file'>
+    <disk name='vda' type='file' exportname='test-vda' exportbitmap='blah'>
       <driver type='qcow2'/>
       <scratch file='/path/to/file'>
         <seclabel model='dac' relabel='no'/>
diff --git a/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml b/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
index c631c9b979..450f007d3a 100644
--- a/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
+++ b/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
@@ -2,7 +2,7 @@
   <incremental>1525889631</incremental>
   <server transport='tcp' name='localhost' port='10809'/>
   <disks>
-    <disk name='vda' backup='yes' type='file'>
+    <disk name='vda' backup='yes' type='file' exportname='test-vda' exportbitmap='blah'>
       <driver type='qcow2'/>
       <scratch file='/path/to/file'>
         <seclabel model='dac' relabel='no'/>
-- 
2.25.0