Sample command line for pvscsi-based disk is: -drive file=image.raw,if=none,cache=off,id=pvscsi1 \ -device pvscsi,id=pvscsi -device scsi-disk,drive=pvscsi1,bus=pvscsi.0 \
Signed-off-by: Dmitry Fleytman <dmi...@daynix.com> Signed-off-by: Yan Vugenfirer <y...@daynix.com> --- Makefile.objs | 1 + blockdev.c | 12 ++++++++---- blockdev.h | 10 +++++++++- default-configs/pci.mak | 1 + hw/pc.c | 5 +++++ hw/pci-hotplug.c | 7 ++++++- hw/pci.h | 1 + hw/scsi-bus.c | 14 ++++++++++++-- hw/scsi.h | 1 + 9 files changed, 44 insertions(+), 8 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index 226b01d..bf0a351 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -304,6 +304,7 @@ hw-obj-$(CONFIG_AHCI) += ide/ich.o # SCSI layer hw-obj-$(CONFIG_LSI_SCSI_PCI) += lsi53c895a.o +hw-obj-$(CONFIG_PVSCSI_SCSI_PCI) += pvscsi.o hw-obj-$(CONFIG_ESP) += esp.o hw-obj-y += dma-helpers.o sysbus.o isa-bus.o diff --git a/blockdev.c b/blockdev.c index 1a500b8..41e8efd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -32,6 +32,7 @@ static const char *const if_name[IF_COUNT] = { [IF_SD] = "sd", [IF_VIRTIO] = "virtio", [IF_XEN] = "xen", + [IF_PVSCSI] = "pvscsi", }; static const int if_max_devs[IF_COUNT] = { @@ -433,7 +434,8 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) on_write_error = BLOCK_ERR_STOP_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { - if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { + if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && + type != IF_PVSCSI && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } @@ -446,7 +448,8 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { - if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { + if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && + type != IF_PVSCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } @@ -516,7 +519,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) } else { /* no id supplied -> create one */ dinfo->id = g_malloc0(32); - if (type == IF_IDE || type == IF_SCSI) + if (type == IF_IDE || type == IF_SCSI || type == IF_PVSCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; if (max_devs) snprintf(dinfo->id, 32, "%s%i%s%i", @@ -545,6 +548,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) case IF_IDE: case IF_SCSI: case IF_XEN: + case IF_PVSCSI: case IF_NONE: switch(media) { case MEDIA_DISK: @@ -596,7 +600,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && - type != IF_NONE && type != IF_PFLASH) { + type != IF_PVSCSI && type != IF_NONE && type != IF_PFLASH) { error_report("readonly not supported by this bus type"); goto err; } diff --git a/blockdev.h b/blockdev.h index 1813c53..7c531aa 100644 --- a/blockdev.h +++ b/blockdev.h @@ -24,7 +24,15 @@ void blockdev_auto_del(BlockDriverState *bs); typedef enum { IF_DEFAULT = -1, /* for use with drive_add() only */ IF_NONE, - IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, + IF_IDE, + IF_SCSI, + IF_FLOPPY, + IF_PFLASH, + IF_MTD, + IF_SD, + IF_VIRTIO, + IF_XEN, + IF_PVSCSI, IF_COUNT } BlockInterfaceType; diff --git a/default-configs/pci.mak b/default-configs/pci.mak index 21e4ccf..c203bf8 100644 --- a/default-configs/pci.mak +++ b/default-configs/pci.mak @@ -11,6 +11,7 @@ CONFIG_EEPRO100_PCI=y CONFIG_PCNET_PCI=y CONFIG_PCNET_COMMON=y CONFIG_LSI_SCSI_PCI=y +CONFIG_PVSCSI_SCSI_PCI=y CONFIG_RTL8139_PCI=y CONFIG_E1000_PCI=y CONFIG_IDE_CORE=y diff --git a/hw/pc.c b/hw/pc.c index 83a1b5b..2140a25 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1175,4 +1175,9 @@ void pc_pci_device_init(PCIBus *pci_bus) for (bus = 0; bus <= max_bus; bus++) { pci_create_simple(pci_bus, -1, "lsi53c895a"); } + + max_bus = drive_get_max_bus(IF_PVSCSI); + for (bus = 0; bus <= max_bus; bus++) { + pci_create_simple(pci_bus, -1, "pvscsi"); + } } diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 5c6307f..672b2d7 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -114,6 +114,7 @@ int pci_drive_hot_add(Monitor *mon, const QDict *qdict, switch (type) { case IF_SCSI: + case IF_PVSCSI: if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) { goto err; } @@ -153,6 +154,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, type = IF_SCSI; else if (!strcmp(buf, "virtio")) { type = IF_VIRTIO; + } else if (!strcmp(buf, "pvscsi")) { + type = IF_PVSCSI; } else { monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf); return NULL; @@ -186,7 +189,9 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, switch (type) { case IF_SCSI: - dev = pci_create(bus, devfn, "lsi53c895a"); + case IF_PVSCSI: + dev = pci_create(bus, devfn, (type == IF_SCSI) ? "lsi53c895a" + : "pvscsi"); if (qdev_init(&dev->qdev) < 0) dev = NULL; if (dev && dinfo) { diff --git a/hw/pci.h b/hw/pci.h index 4f19fdb..21df859 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -60,6 +60,7 @@ #define PCI_DEVICE_ID_VMWARE_NET 0x0720 #define PCI_DEVICE_ID_VMWARE_SCSI 0x0730 #define PCI_DEVICE_ID_VMWARE_IDE 0x1729 +#define PCI_DEVICE_ID_VMWARE_PVSCSI 0x07C0 /* Intel (0x8086) */ #define PCI_DEVICE_ID_INTEL_82551IT 0x1209 diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 2cb5a18..8baabb5 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -215,7 +215,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv, return SCSI_DEVICE(dev); } -int scsi_bus_legacy_handle_cmdline(SCSIBus *bus) +static int _scsi_bus_legacy_handle_cmdline(SCSIBus *bus, BlockInterfaceType t) { Location loc; DriveInfo *dinfo; @@ -223,7 +223,7 @@ int scsi_bus_legacy_handle_cmdline(SCSIBus *bus) loc_push_none(&loc); for (unit = 0; unit <= bus->info->max_target; unit++) { - dinfo = drive_get(IF_SCSI, bus->busnr, unit); + dinfo = drive_get(t, bus->busnr, unit); if (dinfo == NULL) { continue; } @@ -237,6 +237,16 @@ int scsi_bus_legacy_handle_cmdline(SCSIBus *bus) return res; } +int scsi_bus_legacy_handle_cmdline(SCSIBus *bus) +{ + return _scsi_bus_legacy_handle_cmdline(bus, IF_SCSI); +} + +int pvscsi_bus_legacy_handle_cmdline(SCSIBus *bus) +{ + return _scsi_bus_legacy_handle_cmdline(bus, IF_PVSCSI); +} + /* SCSIReqOps implementation for invalid commands. */ static int32_t scsi_invalid_command(SCSIRequest *req, uint8_t *buf) diff --git a/hw/scsi.h b/hw/scsi.h index 2eb66f7..ad7f6ef 100644 --- a/hw/scsi.h +++ b/hw/scsi.h @@ -154,6 +154,7 @@ static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d) SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv, int unit, bool removable, int bootindex); int scsi_bus_legacy_handle_cmdline(SCSIBus *bus); +int pvscsi_bus_legacy_handle_cmdline(SCSIBus *bus); /* * Predefined sense codes -- 1.7.7.6