aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi/scsi-bus.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-02-15 13:18:54 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-02-21 13:17:45 +0100
commitfb8b660e1718aaa77cccbda67af5727bb4a6250f (patch)
tree0a0ac20d15f1ec4836cfc91142a5a07841958021 /hw/scsi/scsi-bus.c
parent8f2d75e81d5eb2715be653010258ce9d57549de7 (diff)
downloadqemu-fb8b660e1718aaa77cccbda67af5727bb4a6250f.zip
qemu-fb8b660e1718aaa77cccbda67af5727bb4a6250f.tar.gz
qemu-fb8b660e1718aaa77cccbda67af5727bb4a6250f.tar.bz2
hw/scsi: Concentrate -drive if=scsi auto-create in one place
The logic to create frontends for -drive if=scsi is in SCSI HBAs. For all other interface types, it's in machine initialization code. A few machine types create the SCSI HBAs necessary for that. That's also not done for other interface types. I'm going to deprecate these SCSI eccentricities. In preparation for that, create the frontends in main() instead of the SCSI HBAs, by calling new function scsi_legacy_handle_cmdline() there. Note that not all SCSI HBAs create frontends. Take care not to change that. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1487161136-9018-2-git-send-email-armbru@redhat.com> Acked-By: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/scsi/scsi-bus.c')
-rw-r--r--hw/scsi/scsi-bus.c45
1 files changed, 38 insertions, 7 deletions
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 5940cb1..b9111ee 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -261,12 +261,11 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
return SCSI_DEVICE(dev);
}
-void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp)
+void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
{
Location loc;
DriveInfo *dinfo;
int unit;
- Error *err = NULL;
loc_push_none(&loc);
for (unit = 0; unit <= bus->info->max_target; unit++) {
@@ -276,15 +275,47 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp)
}
qemu_opts_loc_restore(dinfo->opts);
scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo),
- unit, false, -1, NULL, &err);
- if (err != NULL) {
- error_propagate(errp, err);
- break;
- }
+ unit, false, -1, NULL, &error_fatal);
}
loc_pop(&loc);
}
+static bool is_scsi_hba_with_legacy_magic(Object *obj)
+{
+ static const char *magic[] = {
+ "am53c974", "dc390", "esp", "lsi53c810", "lsi53c895a",
+ "megasas", "megasas-gen2", "mptsas1068", "spapr-vscsi",
+ "virtio-scsi-device",
+ NULL
+ };
+ const char *typename = object_get_typename(obj);
+ int i;
+
+ for (i = 0; magic[i]; i++)
+ if (!strcmp(typename, magic[i])) {
+ return true;
+ }
+
+ return false;
+}
+
+static int scsi_legacy_handle_cmdline_cb(Object *obj, void *opaque)
+{
+ SCSIBus *bus = (SCSIBus *)object_dynamic_cast(obj, TYPE_SCSI_BUS);
+
+ if (bus && is_scsi_hba_with_legacy_magic(OBJECT(bus->qbus.parent))) {
+ scsi_bus_legacy_handle_cmdline(bus);
+ }
+
+ return 0;
+}
+
+void scsi_legacy_handle_cmdline(void)
+{
+ object_child_foreach_recursive(object_get_root(),
+ scsi_legacy_handle_cmdline_cb, NULL);
+}
+
static int32_t scsi_invalid_field(SCSIRequest *req, uint8_t *buf)
{
scsi_req_build_sense(req, SENSE_CODE(INVALID_FIELD));