[PATCH] qemu_migration: Unregister close callback only if connection still exists

Michal Privoznik posted 1 patch 2 years, 8 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/55b4ccd9410894196dffbf60e645c131c75378da.1626797987.git.mprivozn@redhat.com
src/qemu/qemu_migration.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
[PATCH] qemu_migration: Unregister close callback only if connection still exists
Posted by Michal Privoznik 2 years, 8 months ago
When doing a peer-to-peer migration it may happen that the
connection to the destination disappears. If that happens,
there's no point in trying to unregister the close callback
because the connection is closed already. It results only in
polluting logs with this message:

  error : virNetSocketReadWire:1814 : End of file while reading data: : Input/output error

and the reason for that is unregistering a connection callback
results in RPC (among other things).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1918211
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_migration.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index a4f44b465d..4d651aeb1a 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5214,9 +5214,11 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriver *driver,
 
  cleanup:
     virErrorPreserveLast(&orig_err);
-    qemuDomainObjEnterRemote(vm);
-    virConnectUnregisterCloseCallback(dconn, qemuMigrationSrcConnectionClosed);
-    ignore_value(qemuDomainObjExitRemote(vm, false));
+    if (dconn && virConnectIsAlive(dconn) == 1) {
+        qemuDomainObjEnterRemote(vm);
+        virConnectUnregisterCloseCallback(dconn, qemuMigrationSrcConnectionClosed);
+        ignore_value(qemuDomainObjExitRemote(vm, false));
+    }
     virErrorRestore(&orig_err);
     return ret;
 }
-- 
2.31.1

Re: [PATCH] qemu_migration: Unregister close callback only if connection still exists
Posted by Jiri Denemark 2 years, 8 months ago
On Tue, Jul 20, 2021 at 18:19:54 +0200, Michal Privoznik wrote:
> When doing a peer-to-peer migration it may happen that the
> connection to the destination disappears. If that happens,
> there's no point in trying to unregister the close callback
> because the connection is closed already. It results only in
> polluting logs with this message:
> 
>   error : virNetSocketReadWire:1814 : End of file while reading data: : Input/output error
> 
> and the reason for that is unregistering a connection callback
> results in RPC (among other things).
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1918211
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_migration.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
> index a4f44b465d..4d651aeb1a 100644
> --- a/src/qemu/qemu_migration.c
> +++ b/src/qemu/qemu_migration.c
> @@ -5214,9 +5214,11 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriver *driver,
>  
>   cleanup:
>      virErrorPreserveLast(&orig_err);
> -    qemuDomainObjEnterRemote(vm);
> -    virConnectUnregisterCloseCallback(dconn, qemuMigrationSrcConnectionClosed);
> -    ignore_value(qemuDomainObjExitRemote(vm, false));
> +    if (dconn && virConnectIsAlive(dconn) == 1) {
> +        qemuDomainObjEnterRemote(vm);
> +        virConnectUnregisterCloseCallback(dconn, qemuMigrationSrcConnectionClosed);
> +        ignore_value(qemuDomainObjExitRemote(vm, false));
> +    }
>      virErrorRestore(&orig_err);
>      return ret;
>  }

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>