]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block/nbd: nbd_channel_error() shutdown channel unconditionally
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Thu, 2 Sep 2021 10:38:01 +0000 (13:38 +0300)
committerEric Blake <eblake@redhat.com>
Wed, 29 Sep 2021 18:46:33 +0000 (13:46 -0500)
Don't rely on connection being totally broken in case of -EIO. Safer
and more correct is to just shut down the channel anyway, since we
change the state and plan on reconnecting.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210902103805.25686-2-vsementsov@virtuozzo.com>
[eblake: grammar tweaks]
Signed-off-by: Eric Blake <eblake@redhat.com>
block/nbd.c

index a66b2c282dc3d2e3748eba1cda4da7229880fc06..de59e76378ab66f00b4bb3ad8e7de31e0b76566c 100644 (file)
@@ -129,15 +129,16 @@ static bool nbd_client_connected(BDRVNBDState *s)
 
 static void nbd_channel_error(BDRVNBDState *s, int ret)
 {
+    if (nbd_client_connected(s)) {
+        qio_channel_shutdown(s->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
+    }
+
     if (ret == -EIO) {
         if (nbd_client_connected(s)) {
             s->state = s->reconnect_delay ? NBD_CLIENT_CONNECTING_WAIT :
                                             NBD_CLIENT_CONNECTING_NOWAIT;
         }
     } else {
-        if (nbd_client_connected(s)) {
-            qio_channel_shutdown(s->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
-        }
         s->state = NBD_CLIENT_QUIT;
     }
 }