]> xenbits.xensource.com Git - osstest/seabios.git/commitdiff
virtio-scsi: skip initializing non-bootable devices
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 14 Jan 2020 09:04:06 +0000 (10:04 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 14 Jan 2020 09:18:02 +0000 (10:18 +0100)
Check each disk attached to a virtio-scsi device whenever
it is bootable and skip initialization in case it isn't.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
src/hw/virtio-scsi.c

index a27bdc1cfbb75939271c9b3eac684a276224cb01..a5332848b8c8bf88a9a478b3f8511a66930dc98a 100644 (file)
@@ -111,8 +111,18 @@ virtio_scsi_init_lun(struct virtio_lun_s *vlun, struct pci_device *pci,
 static int
 virtio_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv)
 {
+    u8 skip_nonbootable = is_bootprio_strict();
     struct virtio_lun_s *tmpl_vlun =
         container_of(tmpl_drv, struct virtio_lun_s, drive);
+    int prio = bootprio_find_scsi_device(tmpl_vlun->pci, tmpl_vlun->target, tmpl_vlun->lun);
+
+    if (skip_nonbootable && prio < 0) {
+        dprintf(1, "skipping init of a non-bootable virtio-scsi dev at %pP,"
+                " target %d, lun %d\n",
+                tmpl_vlun->pci, tmpl_vlun->target, tmpl_vlun->lun);
+        return -1;
+    }
+
     struct virtio_lun_s *vlun = malloc_low(sizeof(*vlun));
     if (!vlun) {
         warn_noalloc();
@@ -123,7 +133,6 @@ virtio_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv)
 
     boot_lchs_find_scsi_device(vlun->pci, vlun->target, vlun->lun,
                                &(vlun->drive.lchs));
-    int prio = bootprio_find_scsi_device(vlun->pci, vlun->target, vlun->lun);
     int ret = scsi_drive_setup(&vlun->drive, "virtio-scsi", prio);
     if (ret)
         goto fail;