qemu: Support multiqueue virtio-blk

qemu 2.7.0 introduces multiqueue virtio-blk(commit 2f27059).
This patch introduces a new attribute "queues". An example of
the XML:

<disk type='file' device='disk'>
  <driver name='qemu' type='qcow2' queues='4'/>

The corresponding QEMU command line:

-device virtio-blk-pci,scsi=off,num-queues=4,id=virtio-disk0

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Lin Ma
2017-10-01 01:15:36 +08:00
committed by Ján Tomko
parent c7bdeed559
commit abca72faa4
11 changed files with 138 additions and 1 deletions

View File

@@ -5113,6 +5113,13 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk)
return -1;
}
if (disk->queues && disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("queues attribute in disk driver element is only "
"supported by virtio-blk"));
return -1;
}
return 0;
}
@@ -8776,6 +8783,15 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
}
VIR_FREE(tmp);
if ((tmp = virXMLPropString(cur, "queues")) &&
virStrToLong_uip(tmp, NULL, 10, &def->queues) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("'queues' attribute must be positive number: %s"),
tmp);
goto cleanup;
}
VIR_FREE(tmp);
ret = 0;
cleanup:
@@ -22030,6 +22046,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
if (def->detect_zeroes)
virBufferAsprintf(&driverBuf, " detect_zeroes='%s'", detect_zeroes);
if (def->queues)
virBufferAsprintf(&driverBuf, " queues='%u'", def->queues);
virDomainVirtioOptionsFormat(&driverBuf, def->virtio);

View File

@@ -668,6 +668,7 @@ struct _virDomainDiskDef {
unsigned int iothread; /* unused = 0, > 0 specific thread # */
int detect_zeroes; /* enum virDomainDiskDetectZeroes */
char *domain_name; /* backend domain name */
unsigned int queues;
virDomainVirtioOptionsPtr virtio;
};

View File

@@ -2083,6 +2083,17 @@ qemuBuildDriveDevStr(const virDomainDef *def,
? "on" : "off");
}
if (disk->queues) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("num-queues property isn't supported by this "
"QEMU binary"));
goto error;
}
virBufferAsprintf(&opt, ",num-queues=%u", disk->queues);
}
if (qemuBuildVirtioOptionsStr(&opt, disk->virtio, qemuCaps) < 0)
goto error;

View File

@@ -883,6 +883,9 @@ bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1);
int qemuDomainDefValidateDisk(const virDomainDiskDef *disk,
virQEMUCapsPtr qemuCaps);
int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob);