]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: backup: Don't attempt to stop the NBD server twice
authorPeter Krempa <pkrempa@redhat.com>
Wed, 19 Nov 2025 08:11:18 +0000 (09:11 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 24 Nov 2025 15:40:24 +0000 (16:40 +0100)
When notifying the backup code about termination of the block job which
is part of a backup operation the code attempts to terminate the NBD
server. This is done for every blockjob so could cause us to attempt to
terminate the NBD server multiple times which doesn't cause problems but
generates spurious errors.

Add a flag that the NBD server was stopped and do it just once. Don't
bother storing the flag in the status XML as it's just for the shutdown
phase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/backup_conf.h
src/qemu/qemu_backup.c

index 9c3532a5462e45cc5695e2df014fd140d8d1fbba..f90a4dcaee1cbc084cd311cc451568cdb6089db0 100644 (file)
@@ -99,6 +99,10 @@ struct _virDomainBackupDef {
     char *errmsg; /* error message of failed sub-blockjob */
 
     unsigned int apiFlags; /* original flags used when starting the job */
+
+    bool nbdStopped; /* The NBD server for a pull-mode backup was stopped. This
+                        flag is deliberately not stored in the status XML as
+                        it's related only to termination of the backup. */
 };
 
 typedef enum {
index 3b4fe54854655bf687a645daeb95d82d728428ae..9832c186a89335ab1c27fe51a8ab4468fed2908f 100644 (file)
@@ -1006,14 +1006,17 @@ qemuBackupNotifyBlockjobEnd(virDomainObj *vm,
         return;
 
     if (backup->type == VIR_DOMAIN_BACKUP_TYPE_PULL) {
-        if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
-            return;
-        ignore_value(qemuMonitorNBDServerStop(priv->mon));
-        if (backup->tlsAlias)
-            ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsAlias, false));
-        if (backup->tlsSecretAlias)
-            ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsSecretAlias, false));
-        qemuDomainObjExitMonitor(vm);
+        if (!backup->nbdStopped) {
+            if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
+                return;
+            ignore_value(qemuMonitorNBDServerStop(priv->mon));
+            if (backup->tlsAlias)
+                ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsAlias, false));
+            if (backup->tlsSecretAlias)
+                ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsSecretAlias, false));
+            qemuDomainObjExitMonitor(vm);
+            backup->nbdStopped = true;
+        }
 
         /* update the final statistics with the current job's data */
         backup->pull_tmp_used += cur;