提交 d9504941 编写于 作者: M Mike Perez 提交者: Ján Tomko

qemu: Add cmd_per_lun, max_sectors to virtio-scsi

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:

<controller type='scsi' index='0' model='virtio-scsi' cmd_per_lun='50'
max_sectors='512'/>

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: NMike Perez <thingee@gmail.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 fba6bc47
......@@ -2569,11 +2569,32 @@
<p>
An optional sub-element <code>driver</code> can specify the driver
specific options. Currently it only supports attribute <code>queues</code>
(<span class="since">1.0.5</span>, 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:
</p>
<dl>
<dt><code>queues</code></dt>
<dd>
The optional <code>queues</code> attribute specifies the number of
queues for the controller. For best performance, it's recommended to
specify a value matching the number of vCPUs.
<span class="since">Since 1.0.5 (QEMU and KVM only)</span>
</dd>
<dt><code>cmd_per_lun</code></dt>
<dd>
The optional <code>cmd_per_lun</code> attribute specifies the maximum
number of commands that can be queued on devices controlled by the
host.
<span class="since">Since 1.2.7 (QEMU and KVM only)</span>
</dd>
<dt><code>max_sectors</code></dt>
<dd>
The optional <code>max_sectors</code> 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.
<span class="since">Since 1.2.7 (QEMU and KVM only)</span>
</dd>
</dl>
<p>
USB companion controllers have an optional
sub-element <code>&lt;master&gt;</code> to specify the exact
......
......@@ -1735,6 +1735,16 @@
<ref name="unsignedInt"/>
</attribute>
</optional>
<optional>
<attribute name="cmd_per_lun">
<ref name="unsignedInt"/>
</attribute>
</optional>
<optional>
<attribute name="max_sectors">
<ref name="unsignedInt"/>
</attribute>
</optional>
</element>
</optional>
</interleave>
......
......@@ -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, "<driver queues='%u'/>\n", def->queues);
if (def->cmd_per_lun)
virBufferAsprintf(buf, "<driver cmd_per_lun='%u'/>\n", def->cmd_per_lun);
if (def->max_sectors)
virBufferAsprintf(buf, "<driver max_sectors='%u'/>\n", def->max_sectors);
if (virDomainDeviceInfoIsSet(&def->info, flags) &&
virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1;
......
......@@ -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;
......
......@@ -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;
......
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
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>8</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='sdb' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
<controller type='scsi' index='0' model='virtio-scsi'>
<driver cmd_per_lun='50'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<memballoon model='virtio'/>
</devices>
</domain>
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
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>8</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='sdb' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
<controller type='scsi' index='0' model='virtio-scsi'>
<driver max_sectors='512'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<memballoon model='virtio'/>
</devices>
</domain>
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册