virtio-scsi: skip initializing non-bootable devices

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>
This commit is contained in:
Gerd Hoffmann 2020-01-14 10:04:06 +01:00
parent 8d4252254a
commit d6bdb85eb0
1 changed files with 10 additions and 1 deletions

View 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;