usb-bot is SCSI HBA which support only one SCSI target with ID 0.
we can create one or more SCSI devices connected to it with -device
as its luns. For usb-bot the limit is 15 luns.
The difference from other SCSI controllers is that usb-bot needs
usb-bus support. That means usb-bot is required to be attached to a
existing USB controller.
libvirt xml example:
<devices>
...
<controller type='usb' index='0'>
</controller>
<controller type='scsi' index='0' model='usb-bot'>
<address type='usb' bus='0' port='1'/>
</controller>
...
</devices>
QEMU commandline should be:
-device piix3-usb-uhci,id=usb \
-device usb-bot,id=scsi0,bus=usb.0,port=1
---
docs/formatdomain.html.in | 4 ++--
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 52 +++++++++++++++++++++++++++++++++++++++++--
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 16 +++++++++++++
src/vmx/vmx.c | 3 ++-
6 files changed, 72 insertions(+), 5 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index cce179d..274acf4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2413,8 +2413,8 @@
control how many devices can be connected through the
controller. A "scsi" controller has an optional
attribute <code>model</code>, which is one of "auto",
"buslogic",
- "ibmvscsi", "lsilogic", "lsisas1068",
"lsisas1078", "virtio-scsi" or
- "vmpvscsi". A "usb" controller has an optional attribute
+ "ibmvscsi", "lsilogic", "lsisas1068",
"lsisas1078", "virtio-scsi",
+ "vmpvscsi" or "usb-bot". A "usb" controller has an
optional attribute
<code>model</code>, which is one of "piix3-uhci",
"piix4-uhci", "ehci",
"ich9-ehci1", "ich9-uhci1", "ich9-uhci2",
"ich9-uhci3", "vt82c686b-uhci",
"pci-ohci" or "nec-xhci". Additionally,
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 6978dc7..d748d68 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1509,6 +1509,7 @@
<value>ibmvscsi</value>
<value>virtio-scsi</value>
<value>lsisas1078</value>
+ <value>usb-bot</value>
</choice>
</attribute>
</optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f8fbf79..545c157 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -324,7 +324,8 @@ VIR_ENUM_IMPL(virDomainControllerModelSCSI,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAS
"vmpvscsi",
"ibmvscsi",
"virtio-scsi",
- "lsisas1078");
+ "lsisas1078",
+ "usb-bot");
VIR_ENUM_IMPL(virDomainControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST,
"piix3-uhci",
@@ -5736,6 +5737,17 @@ virDomainControllerDefParseXML(xmlNodePtr node,
goto error;
switch (def->type) {
+ case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
+ if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT) {
+ if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("usb-bot mode of scsi controller requires "
+ "address of type 'usb'"));
+ goto error;
+ }
+ }
+ break;
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: {
char *ports = virXMLPropString(node, "ports");
if (ports) {
@@ -5826,7 +5838,8 @@ virDomainControllerDefParseXML(xmlNodePtr node,
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 &&
- def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Controllers must use the 'pci' address
type"));
goto error;
@@ -13778,6 +13791,38 @@ virDomainDefMaybeAddSmartcardController(virDomainDefPtr def)
return 0;
}
+static int
+virDomainDefMaybeAddUSBcontroller(virDomainDefPtr def)
+{
+ size_t i;
+ int maxController = -1;
+
+ for (i = 0; i < def->ncontrollers; i++) {
+ virDomainControllerDefPtr cont = def->controllers[i];
+
+ if (cont->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+ continue;
+
+ if (cont->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT)
+ continue;
+
+ if ((int)cont->info.addr.usb.bus > maxController)
+ maxController = cont->info.addr.usb.bus;
+ }
+
+ if (maxController == -1)
+ return 0;
+
+ for (i = 0; i <= maxController; i++) {
+ if (virDomainDefMaybeAddController(def,
+ VIR_DOMAIN_CONTROLLER_TYPE_USB,
+ i, -1) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
/*
* Based on the declared <address/> info for any devices,
* add necessary drive controllers which are not already present
@@ -13816,6 +13861,9 @@ virDomainDefAddImplicitControllers(virDomainDefPtr def)
if (virDomainDefMaybeAddHostdevSCSIcontroller(def) < 0)
return -1;
+ if (virDomainDefMaybeAddUSBcontroller(def) < 0)
+ return -1;
+
return 0;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 56739b7..3e69f84 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -787,6 +787,7 @@ enum virDomainControllerModelSCSI {
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
+ VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f8fccea..5f08a72 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -684,6 +684,14 @@ qemuSetScsiControllerModel(virDomainDefPtr def,
return -1;
}
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT:
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_BOT)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("This QEMU doesn't support "
+ "usb-bot scsi controller"));
+ return -1;
+ }
+ break;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
/*TODO: need checking work here if necessary */
break;
@@ -2692,6 +2700,11 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
def->controllers[i]->idx == 0)
continue;
+ /* SCSI controller model 'usb-bot' needs address of USB type */
+ if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI
&&
+ def->controllers[i]->model ==
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT)
+ continue;
+
if (def->controllers[i]->info.type ==
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO)
continue;
if (def->controllers[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
@@ -4614,6 +4627,9 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC:
virBufferAddLit(&buf, "lsi");
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT:
+ virBufferAddLit(&buf, "usb-bot");
+ break;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
virBufferAddLit(&buf, "spapr-vscsi");
break;
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 11e8a62..35be3ba 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -514,7 +514,8 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI,
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
"pvscsi",
"UNUSED ibmvscsi",
"UNUSED virtio-scsi",
- "UNUSED lsisas1078");
+ "UNUSED lsisas1078",
+ "UNUSED usb-scsi");
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
--
1.8.3.1