Make sure the description is populated before registering a drive. --- src/usb-msc.c | 5 ++--- src/virtio-blk.c | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/usb-msc.c b/src/usb-msc.c index 080efdc..48635d9 100644 --- a/src/usb-msc.c +++ b/src/usb-msc.c @@ -235,6 +235,8 @@ usb_msc_init(struct usb_pipe *pipe , strtcpy(rev, data.rev, sizeof(rev)) , pdt, removable); udrive_g->drive.removable = removable; + snprintf(desc, MAXDESCSIZE, "USB Drive %s %s %s", vendor, product, rev); + udrive_g->drive.desc = desc;
if (pdt == USB_MSC_TYPE_CDROM) ret = setup_drive_cdrom(&dop); @@ -243,9 +245,6 @@ usb_msc_init(struct usb_pipe *pipe if (ret) goto fail;
- snprintf(desc, MAXDESCSIZE, "USB Drive %s %s %s", vendor, product, rev); - udrive_g->drive.desc = desc; - return 0; fail: dprintf(1, "Unable to configure USB MSC device.\n"); diff --git a/src/virtio-blk.c b/src/virtio-blk.c index 7a25826..9c9ed83 100644 --- a/src/virtio-blk.c +++ b/src/virtio-blk.c @@ -151,15 +151,13 @@ init_virtio_blk(u16 bdf) vdrive_g->drive.pchs.cylinders = cfg.cylinders; vdrive_g->drive.pchs.heads = cfg.heads; vdrive_g->drive.pchs.spt = cfg.sectors; - - setup_translation(&vdrive_g->drive); - add_bcv_internal(&vdrive_g->drive); - snprintf(desc, MAXDESCSIZE, "Virtio disk PCI:%x:%x", pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); - vdrive_g->drive.desc = desc;
+ setup_translation(&vdrive_g->drive); + add_bcv_internal(&vdrive_g->drive); + vp_set_status(ioaddr, VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK); return;