]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: backup: Enable full backup support
authorPeter Krempa <pkrempa@redhat.com>
Thu, 18 Mar 2021 14:11:55 +0000 (15:11 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 19 Mar 2021 15:41:39 +0000 (16:41 +0100)
qemuBackupBegin can take a full backup of the disks (excluding any
operations with bitmaps) without the need to wait for the
blockdev-reopen support in qemu.

Add a check that no checkpoint creation is required and the disk backup
mode isn't VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_INCREMENTAL.

Call to virDomainBackupAlignDisks is moved earlier as it initializes the
disk backup mode if not present in user config.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_backup.c
src/qemu/qemu_domain.c

index f91d632715b8eb4d983a635102f2272c64c8b95b..d89122f225253786dd721862bbd0693021d56618 100644 (file)
@@ -788,12 +788,33 @@ qemuBackupBegin(virDomainObjPtr vm,
         goto endjob;
     }
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_INCREMENTAL_BACKUP)) {
+    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_BACKUP)) {
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
-                       _("incremental backup is not supported yet"));
+                       _("backup is not supported with this QEMU"));
         goto endjob;
     }
 
+    if (virDomainBackupAlignDisks(def, vm->def, suffix) < 0)
+        goto endjob;
+
+    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_INCREMENTAL_BACKUP)) {
+        size_t i;
+
+        if (chkdef) {
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                           _("creating checkpoint for incremental backup is not supported yet"));
+            goto endjob;
+        }
+
+        for (i = 0; i < def->ndisks; i++) {
+            if (def->disks[i].backupmode == VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_INCREMENTAL) {
+                virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                               _("incremental backup is not supported yet"));
+                goto endjob;
+            }
+        }
+    }
+
     if (priv->backup) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("another backup job is already running"));
@@ -806,9 +827,6 @@ qemuBackupBegin(virDomainObjPtr vm,
     if (qemuBackupBeginPrepareTLS(vm, cfg, def, &tlsProps, &tlsSecretProps) < 0)
         goto endjob;
 
-    if (virDomainBackupAlignDisks(def, vm->def, suffix) < 0)
-        goto endjob;
-
     actions = virJSONValueNewArray();
 
     /* The 'chk' checkpoint must be rolled back if the transaction command
index ed2a1481d472d3c22271bd4640434b53db79a917..5c98f8ff1aae2e42060adea2dc35bcd3f63280b9 100644 (file)
@@ -2322,9 +2322,6 @@ qemuDomainObjPrivateXMLFormatBackups(virBufferPtr buf,
     g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
     g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
 
-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_INCREMENTAL_BACKUP))
-        return 0;
-
     if (priv->backup &&
         virDomainBackupDefFormat(&childBuf, priv->backup, true) < 0)
         return -1;