render / rpms / libvirt

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