Populate drive_g->desc prior to calling add_bcv_internal().
authorKevin O'Connor <kevin@koconnor.net>
Sun, 26 Dec 2010 22:22:28 +0000 (17:22 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 26 Dec 2010 22:22:28 +0000 (17:22 -0500)
Make sure the description is populated before registering a drive.

src/usb-msc.c
src/virtio-blk.c

index 080efdc12c1702e2af7b88a4a8d50ba3d3155cfe..48635d9696f17b4ea47207cc3d623d77d296fec2 100644 (file)
@@ -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");
index 7a2582635760cd81dc7a1da76c89040f47b85e30..9c9ed83b956e06fdd6e03f25580494cafe615b0a 100644 (file)
@@ -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;