From d950494129513558a303387e26a2bab057012c5e Mon Sep 17 00:00:00 2001 From: Mike Perez Date: Thu, 22 May 2014 11:22:52 -0700 Subject: [PATCH] qemu: Add cmd_per_lun, max_sectors to virtio-scsi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This introduces two new attributes "cmd_per_lun" and "max_sectors" same with the names QEMU uses for virtio-scsi. An example of the XML: The corresponding QEMU command line: -device virtio-scsi-pci,id=scsi0,cmd_per_lun=50,max_sectors=512, bus=pci.0,addr=0x3 Signed-off-by: Mike Perez Signed-off-by: Ján Tomko --- docs/formatdomain.html.in | 29 ++++++++++++++++--- docs/schemas/domaincommon.rng | 10 +++++++ src/conf/domain_conf.c | 27 +++++++++++++++-- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_command.c | 27 +++++++++++++---- ...xml2argv-disk-virtio-scsi-cmd_per_lun.args | 9 ++++++ ...uxml2argv-disk-virtio-scsi-cmd_per_lun.xml | 29 +++++++++++++++++++ ...xml2argv-disk-virtio-scsi-max_sectors.args | 9 ++++++ ...uxml2argv-disk-virtio-scsi-max_sectors.xml | 29 +++++++++++++++++++ tests/qemuxml2argvtest.c | 6 ++++ tests/qemuxml2xmltest.c | 2 ++ 11 files changed, 168 insertions(+), 11 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3075e16f21..dce75078fd 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2569,11 +2569,32 @@

An optional sub-element driver can specify the driver - specific options. Currently it only supports attribute queues - (1.0.5, QEMU and KVM only), which specifies the - number of queues for the controller. For best performance, it's recommended - to specify a value matching the number of vCPUs. + specific options:

+
+
queues
+
+ The optional queues attribute specifies the number of + queues for the controller. For best performance, it's recommended to + specify a value matching the number of vCPUs. + Since 1.0.5 (QEMU and KVM only) +
+
cmd_per_lun
+
+ The optional cmd_per_lun attribute specifies the maximum + number of commands that can be queued on devices controlled by the + host. + Since 1.2.7 (QEMU and KVM only) +
+
max_sectors
+
+ The optional max_sectors attribute specifies the maximum + amount of data in bytes that will be transferred to or from the device + in a single command. The transfer length is measured in sectors, where + a sector is 512 bytes. + Since 1.2.7 (QEMU and KVM only) +
+

USB companion controllers have an optional sub-element <master> to specify the exact diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 33d0308cf9..7be028d160 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1735,6 +1735,16 @@ + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fa64dc1707..f7fe64b4b9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6104,6 +6104,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, char *idx = NULL; char *model = NULL; char *queues = NULL; + char *cmd_per_lun = NULL; + char *max_sectors = NULL; xmlNodePtr saved = ctxt->node; int rc; @@ -6147,6 +6149,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "driver")) queues = virXMLPropString(cur, "queues"); + cmd_per_lun = virXMLPropString(cur, "cmd_per_lun"); + max_sectors = virXMLPropString(cur, "max_sectors"); } cur = cur->next; } @@ -6157,6 +6161,17 @@ virDomainControllerDefParseXML(xmlNodePtr node, goto error; } + if (cmd_per_lun && virStrToLong_ui(cmd_per_lun, NULL, 10, &def->cmd_per_lun) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Malformed 'cmd_per_lun' value '%s'"), cmd_per_lun); + goto error; + } + + if (max_sectors && virStrToLong_ui(max_sectors, NULL, 10, &def->max_sectors) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Malformed 'max_sectors' value %s'"), max_sectors); + } + if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) goto error; @@ -6264,6 +6279,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, VIR_FREE(idx); VIR_FREE(model); VIR_FREE(queues); + VIR_FREE(cmd_per_lun); + VIR_FREE(max_sectors); return def; @@ -15362,13 +15379,19 @@ virDomainControllerDefFormat(virBufferPtr buf, break; } - if (def->queues || virDomainDeviceInfoIsSet(&def->info, flags) || - pcihole64) { + if (def->queues || def->cmd_per_lun || def->max_sectors || + virDomainDeviceInfoIsSet(&def->info, flags) || pcihole64) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); if (def->queues) virBufferAsprintf(buf, "\n", def->queues); + if (def->cmd_per_lun) + virBufferAsprintf(buf, "\n", def->cmd_per_lun); + + if (def->max_sectors) + virBufferAsprintf(buf, "\n", def->max_sectors); + if (virDomainDeviceInfoIsSet(&def->info, flags) && virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) return -1; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1122eb26c8..a00e30a586 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -719,6 +719,8 @@ struct _virDomainControllerDef { unsigned int idx; int model; /* -1 == undef */ unsigned int queues; + unsigned int cmd_per_lun; + unsigned int max_sectors; union { virDomainVirtioSerialOpts vioserial; virDomainPCIControllerOpts pciopts; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 48291760bf..472438220c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4099,12 +4099,23 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef, virBuffer buf = VIR_BUFFER_INITIALIZER; int model; - if (def->queues && - !(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI && + if (!(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI && def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'queues' is only supported by virtio-scsi controller")); - return NULL; + if (def->queues) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'queues' is only supported by virtio-scsi controller")); + return NULL; + } + if (def->cmd_per_lun) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'cmd_per_lun' is only supported by virtio-scsi controller")); + return NULL; + } + if (def->max_sectors) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'max_sectors' is only supported by virtio-scsi controller")); + return NULL; + } } switch (def->type) { @@ -4232,6 +4243,12 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef, if (def->queues) virBufferAsprintf(&buf, ",num_queues=%u", def->queues); + if (def->cmd_per_lun) + virBufferAsprintf(&buf, ",cmd_per_lun=%u", def->cmd_per_lun); + + if (def->max_sectors) + virBufferAsprintf(&buf, ",max_sectors=%u", def->max_sectors); + if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info, qemuCaps) < 0) goto error; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args new file mode 100644 index 0000000000..2c757905b2 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args @@ -0,0 +1,9 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M pc -m 214 -smp 8 -nographic -nodefconfig -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device virtio-scsi-pci,id=scsi0,cmd_per_lun=50,bus=pci.0,addr=0x3 \ +-usb \ +-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \ +-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\ +drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.xml new file mode 100644 index 0000000000..615a7f5ba8 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-cmd_per_lun.xml @@ -0,0 +1,29 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 8 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +

+ + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.args new file mode 100644 index 0000000000..895f379926 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.args @@ -0,0 +1,9 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M pc -m 214 -smp 8 -nographic -nodefconfig -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device virtio-scsi-pci,id=scsi0,max_sectors=512,bus=pci.0,addr=0x3 \ +-usb \ +-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \ +-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\ +drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.xml new file mode 100644 index 0000000000..cd7d4a7deb --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-max_sectors.xml @@ -0,0 +1,29 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 8 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 4ff13281d5..bbc0fb7a9b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -809,6 +809,12 @@ mymain(void) DO_TEST("disk-virtio-scsi-num_queues", QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); + DO_TEST("disk-virtio-scsi-cmd_per_lun", + QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_VIRTIO_SCSI); + DO_TEST("disk-virtio-scsi-max_sectors", + QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_VIRTIO_SCSI); DO_TEST("disk-scsi-megasas", QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_MEGASAS); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 43cd02224e..26e3cadda0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -223,6 +223,8 @@ mymain(void) DO_TEST("disk-scsi-vscsi"); DO_TEST("disk-scsi-virtio-scsi"); DO_TEST("disk-virtio-scsi-num_queues"); + DO_TEST("disk-virtio-scsi-cmd_per_lun"); + DO_TEST("disk-virtio-scsi-max_sectors"); DO_TEST("disk-scsi-megasas"); DO_TEST_DIFFERENT("disk-mirror-old"); DO_TEST_FULL("disk-mirror", false, WHEN_ACTIVE); -- GitLab