Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Aug 2021 18:29:13 GMT
From:      Gordon Tetlow <gordon@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f66e34809906 - releng/13.0 - Fix virtio_blk(4) failing to attach on some hypervisors.
Message-ID:  <202108241829.17OITDkh023827@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/13.0 has been updated by gordon:

URL: https://cgit.FreeBSD.org/src/commit/?id=f66e34809906a3222446e1407bd9add84dd6f10c

commit f66e34809906a3222446e1407bd9add84dd6f10c
Author:     Gordon Tetlow <gordon@FreeBSD.org>
AuthorDate: 2021-08-24 16:31:52 +0000
Commit:     Gordon Tetlow <gordon@FreeBSD.org>
CommitDate: 2021-08-24 16:36:55 +0000

    Fix virtio_blk(4) failing to attach on some hypervisors.
    
    Approved by:    so
    Security:       EN-21:23.virtio_blk
---
 sys/dev/virtio/block/virtio_blk.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c
index 50642fb0b009..8a5558f4571d 100644
--- a/sys/dev/virtio/block/virtio_blk.c
+++ b/sys/dev/virtio/block/virtio_blk.c
@@ -126,6 +126,7 @@ static int	vtblk_detach(device_t);
 static int	vtblk_suspend(device_t);
 static int	vtblk_resume(device_t);
 static int	vtblk_shutdown(device_t);
+static int	vtblk_attach_completed(device_t);
 static int	vtblk_config_change(device_t);
 
 static int	vtblk_open(struct disk *);
@@ -255,6 +256,7 @@ static device_method_t vtblk_methods[] = {
 	DEVMETHOD(device_shutdown,	vtblk_shutdown),
 
 	/* VirtIO methods. */
+	DEVMETHOD(virtio_attach_completed, vtblk_attach_completed),
 	DEVMETHOD(virtio_config_change,	vtblk_config_change),
 
 	DEVMETHOD_END
@@ -378,8 +380,6 @@ vtblk_attach(device_t dev)
 		goto fail;
 	}
 
-	vtblk_create_disk(sc);
-
 	virtqueue_enable_intr(sc->vtblk_vq);
 
 fail:
@@ -461,6 +461,22 @@ vtblk_shutdown(device_t dev)
 	return (0);
 }
 
+static int
+vtblk_attach_completed(device_t dev)
+{
+	struct vtblk_softc *sc;
+
+	sc = device_get_softc(dev);
+
+	/*
+	 * Create disk after attach as VIRTIO_BLK_T_GET_ID can only be
+	 * processed after the device acknowledged
+	 * VIRTIO_CONFIG_STATUS_DRIVER_OK.
+	 */
+	vtblk_create_disk(sc);
+	return (0);
+}
+
 static int
 vtblk_config_change(device_t dev)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108241829.17OITDkh023827>