render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
d76c62
From 100ae962cd0f4dbfd5270bc2d61f05ec1c524c0a Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <100ae962cd0f4dbfd5270bc2d61f05ec1c524c0a@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Tue, 4 Feb 2020 15:07:40 +0100
d76c62
Subject: [PATCH] conf: backup: Allow configuration of names exported via NBD
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
If users wish to use different name for exported disks or bitmaps
d76c62
the new fields allow to do so. Additionally they also document the
d76c62
current settings.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
d76c62
Reviewed-by: Eric Blake <eblake@redhat.com>
d76c62
(cherry picked from commit 12ccd8d4db12d71a270d903701a8edb83d41f127)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1207659
d76c62
Message-Id: <8043f75d8d4b4ae7e7ae3671d71407f733e6a3cf.1580824112.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 docs/formatbackup.html.in                             |  9 +++++++++
d76c62
 docs/schemas/domainbackup.rng                         |  8 ++++++++
d76c62
 src/conf/backup_conf.c                                | 10 ++++++++++
d76c62
 src/conf/backup_conf.h                                |  2 ++
d76c62
 tests/domainbackupxml2xmlin/backup-pull-seclabel.xml  |  2 +-
d76c62
 tests/domainbackupxml2xmlout/backup-pull-seclabel.xml |  2 +-
d76c62
 6 files changed, 31 insertions(+), 2 deletions(-)
d76c62
d76c62
diff --git a/docs/formatbackup.html.in b/docs/formatbackup.html.in
d76c62
index 1c690901c7..543d913072 100644
d76c62
--- a/docs/formatbackup.html.in
d76c62
+++ b/docs/formatbackup.html.in
d76c62
@@ -85,6 +85,15 @@
d76c62
               
Setting this attribute to yes(default) specifies
d76c62
                 that the disk should take part in the backup and using
d76c62
                 no excludes the disk from the backup.
d76c62
+              
exportname
d76c62
+              
Allows modification of the NBD export name for the given disk.
d76c62
+                By default equal to disk target.
d76c62
+                Valid only for pull mode backups.
d76c62
+              
exportbitmap
d76c62
+              
Allows modification of the name of the bitmap describing dirty
d76c62
+                blocks for an incremental backup exported via NBD export name
d76c62
+                for the given disk.
d76c62
+                Valid only for pull mode backups.
d76c62
               
type
d76c62
               
A mandatory attribute to describe the type of the
d76c62
                 disk, except when backup='no' is
d76c62
diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng
d76c62
index c1e4d80302..395ea841f9 100644
d76c62
--- a/docs/schemas/domainbackup.rng
d76c62
+++ b/docs/schemas/domainbackup.rng
d76c62
@@ -165,6 +165,14 @@
d76c62
             <attribute name='name'>
d76c62
               <ref name='diskTarget'/>
d76c62
             </attribute>
d76c62
+            <optional>
d76c62
+              <attribute name='exportname'>
d76c62
+                <text/>
d76c62
+              </attribute>
d76c62
+              <attribute name='exportbitmap'>
d76c62
+                <text/>
d76c62
+              </attribute>
d76c62
+            </optional>
d76c62
             <choice>
d76c62
               <group>
d76c62
                 <attribute name='backup'>
d76c62
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
d76c62
index 61dc8cd4b2..b370b686f1 100644
d76c62
--- a/src/conf/backup_conf.c
d76c62
+++ b/src/conf/backup_conf.c
d76c62
@@ -71,6 +71,8 @@ virDomainBackupDefFree(virDomainBackupDefPtr def)
d76c62
         virDomainBackupDiskDefPtr disk = def->disks + i;
d76c62
 
d76c62
         g_free(disk->name);
d76c62
+        g_free(disk->exportname);
d76c62
+        g_free(disk->exportbitmap);
d76c62
         virObjectUnref(disk->store);
d76c62
     }
d76c62
 
d76c62
@@ -124,6 +126,11 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
d76c62
     if (def->backup == VIR_TRISTATE_BOOL_NO)
d76c62
         return 0;
d76c62
 
d76c62
+    if (!push) {
d76c62
+        def->exportname = virXMLPropString(node, "exportname");
d76c62
+        def->exportbitmap = virXMLPropString(node, "exportbitmap");
d76c62
+    }
d76c62
+
d76c62
     if (internal) {
d76c62
         if (!(state = virXMLPropString(node, "state")) ||
d76c62
             (tmp = virDomainBackupDiskStateTypeFromString(state)) < 0) {
d76c62
@@ -333,6 +340,9 @@ virDomainBackupDiskDefFormat(virBufferPtr buf,
d76c62
     if (disk->backup == VIR_TRISTATE_BOOL_YES) {
d76c62
         virBufferAsprintf(&attrBuf, " type='%s'", virStorageTypeToString(disk->store->type));
d76c62
 
d76c62
+        virBufferEscapeString(&attrBuf, " exportname='%s'", disk->exportname);
d76c62
+        virBufferEscapeString(&attrBuf, " exportbitmap='%s'", disk->exportbitmap);
d76c62
+
d76c62
         if (disk->store->format > 0)
d76c62
             virBufferEscapeString(&childBuf, "<driver type='%s'/>\n",
d76c62
                                   virStorageFileFormatTypeToString(disk->store->format));
d76c62
diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h
d76c62
index 7cf44245d4..672fd52ee7 100644
d76c62
--- a/src/conf/backup_conf.h
d76c62
+++ b/src/conf/backup_conf.h
d76c62
@@ -51,6 +51,8 @@ typedef virDomainBackupDiskDef *virDomainBackupDiskDefPtr;
d76c62
 struct _virDomainBackupDiskDef {
d76c62
     char *name;     /* name matching the 
d76c62
     virTristateBool backup; /* whether backup is requested */
d76c62
+    char *exportname; /* name of the NBD export for pull mode backup */
d76c62
+    char *exportbitmap; /* name of the bitmap exposed in NBD for pull mode backup */
d76c62
 
d76c62
     /* details of target for push-mode, or of the scratch file for pull-mode */
d76c62
     virStorageSourcePtr store;
d76c62
diff --git a/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml b/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml
d76c62
index a00d8758bb..4e6e602c19 100644
d76c62
--- a/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml
d76c62
+++ b/tests/domainbackupxml2xmlin/backup-pull-seclabel.xml
d76c62
@@ -2,7 +2,7 @@
d76c62
   <incremental>1525889631</incremental>
d76c62
   <server transport='tcp' name='localhost' port='10809'/>
d76c62
   <disks>
d76c62
-    <disk name='vda' type='file'>
d76c62
+    <disk name='vda' type='file' exportname='test-vda' exportbitmap='blah'>
d76c62
       <driver type='qcow2'/>
d76c62
       <scratch file='/path/to/file'>
d76c62
         <seclabel model='dac' relabel='no'/>
d76c62
diff --git a/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml b/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
d76c62
index c631c9b979..450f007d3a 100644
d76c62
--- a/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
d76c62
+++ b/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
d76c62
@@ -2,7 +2,7 @@
d76c62
   <incremental>1525889631</incremental>
d76c62
   <server transport='tcp' name='localhost' port='10809'/>
d76c62
   <disks>
d76c62
-    <disk name='vda' backup='yes' type='file'>
d76c62
+    <disk name='vda' backup='yes' type='file' exportname='test-vda' exportbitmap='blah'>
d76c62
       <driver type='qcow2'/>
d76c62
       <scratch file='/path/to/file'>
d76c62
         <seclabel model='dac' relabel='no'/>
d76c62
-- 
d76c62
2.25.0
d76c62