From 01b387beb379c1af6df4bf3c4421e1b24eed9cc1 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 26 Jun 2015 11:17:41 +0300 Subject: [PATCH] Fallback to empty image drive if no physical/virtual drives available. --- blkdev.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/blkdev.cpp b/blkdev.cpp index 9207423c..5a15083d 100644 --- a/blkdev.cpp +++ b/blkdev.cpp @@ -189,6 +189,13 @@ static void install_driver (int flags) } break; } + // use image mode if driver disabled + for (int j = 1; j < NUM_DEVICE_TABLE_ENTRIES; j++) { + if (devicetable[j] == st->device_func && driver_installed[j] < 0) { + st->device_func = devicetable[SCSI_UNIT_IMAGE]; + st->scsiemu = true; + } + } } } @@ -201,7 +208,14 @@ static void install_driver (int flags) struct blkdevstate *st = &state[i]; if (st->device_func == devicetable[j]) { int ok = st->device_func->openbus (0); - driver_installed[j] = 1; + if (!ok && st->device_func != devicetable[SCSI_UNIT_IMAGE]) { + st->device_func = devicetable[SCSI_UNIT_IMAGE]; + st->scsiemu = true; + write_log (_T("Fallback to image mode\n")); + driver_installed[j] = -1; + } else { + driver_installed[j] = 1; + } write_log (_T("%s driver installed, ok=%d\n"), st->device_func->name, ok); break; } -- 2.47.3