Blame SOURCES/kvm-virtio-blk-Fix-rollback-path-in-virtio_blk_data_plan.patch

a83cc2
From b8febd2f080de1f12e68cc233c68c7a39835a3c4 Mon Sep 17 00:00:00 2001
a83cc2
From: Greg Kurz <groug@kaod.org>
a83cc2
Date: Wed, 26 May 2021 09:03:51 -0400
a83cc2
Subject: [PATCH 11/15] virtio-blk: Fix rollback path in
a83cc2
 virtio_blk_data_plane_start()
a83cc2
a83cc2
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
RH-MergeRequest: 5: Synchronize RHEL-AV 8.5 release 18 to RHEL 9 Beta
a83cc2
RH-Commit: [8/12] 73d05400a537ce1847605dca58aff99e0a905919 (mrezanin/centos-src-qemu-kvm)
a83cc2
RH-Bugzilla: 1957194
a83cc2
RH-Acked-by: Danilo Cesar Lemes de Paula <ddepaula@redhat.com>
a83cc2
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
a83cc2
RH-Acked-by: Greg Kurz <gkurz@redhat.com>
a83cc2
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
a83cc2
a83cc2
When dataplane multiqueue support was added in QEMU 2.7, the path
a83cc2
that would rollback guest notifiers assignment in case of error
a83cc2
simply got dropped.
a83cc2
a83cc2
Later on, when Error was added to blk_set_aio_context() in QEMU 4.1,
a83cc2
another error path was introduced, but it ommits to rollback both
a83cc2
host and guest notifiers.
a83cc2
a83cc2
It seems cleaner to fix the rollback path in one go. The patch is
a83cc2
simple enough that it can be adjusted if backported to a pre-4.1
a83cc2
QEMU.
a83cc2
a83cc2
Fixes: 51b04ac5c6a6 ("virtio-blk: dataplane multiqueue support")
a83cc2
Cc: stefanha@redhat.com
a83cc2
Fixes: 97896a4887a0 ("block: Add Error to blk_set_aio_context()")
a83cc2
Cc: kwolf@redhat.com
a83cc2
Signed-off-by: Greg Kurz <groug@kaod.org>
a83cc2
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
a83cc2
Message-Id: <20210407143501.244343-2-groug@kaod.org>
a83cc2
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
a83cc2
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
a83cc2
(cherry picked from commit 570fe439e5d1b8626cf344c6bc97d90cfcaf0c79)
a83cc2
Signed-off-by: Greg Kurz <gkurz@redhat.com>
a83cc2
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
a83cc2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
---
a83cc2
 hw/block/dataplane/virtio-blk.c | 11 +++++++++--
a83cc2
 1 file changed, 9 insertions(+), 2 deletions(-)
a83cc2
a83cc2
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
a83cc2
index e9050c8987..d7b5c95d26 100644
a83cc2
--- a/hw/block/dataplane/virtio-blk.c
a83cc2
+++ b/hw/block/dataplane/virtio-blk.c
a83cc2
@@ -207,7 +207,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
a83cc2
                 virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
a83cc2
                 virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
a83cc2
             }
a83cc2
-            goto fail_guest_notifiers;
a83cc2
+            goto fail_host_notifiers;
a83cc2
         }
a83cc2
     }
a83cc2
 
a83cc2
@@ -221,7 +221,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
a83cc2
     aio_context_release(old_context);
a83cc2
     if (r < 0) {
a83cc2
         error_report_err(local_err);
a83cc2
-        goto fail_guest_notifiers;
a83cc2
+        goto fail_aio_context;
a83cc2
     }
a83cc2
 
a83cc2
     /* Process queued requests before the ones in vring */
a83cc2
@@ -245,6 +245,13 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
a83cc2
     aio_context_release(s->ctx);
a83cc2
     return 0;
a83cc2
 
a83cc2
+  fail_aio_context:
a83cc2
+    for (i = 0; i < nvqs; i++) {
a83cc2
+        virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
a83cc2
+        virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
a83cc2
+    }
a83cc2
+  fail_host_notifiers:
a83cc2
+    k->set_guest_notifiers(qbus->parent, nvqs, false);
a83cc2
   fail_guest_notifiers:
a83cc2
     /*
a83cc2
      * If we failed to set up the guest notifiers queued requests will be
a83cc2
-- 
a83cc2
2.27.0
a83cc2