[libvirt] [PATCH 3/3] qemu: Add multiqueue support for vhost-user-scsi/blk
The format like this: Signed-off-by: Li Feng --- src/conf/device_conf.h | 5 + src/conf/domain_conf.c | 14 ++ src/qemu/qemu_command.c | 7 +++ tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/vhost-user-blk.xml| 1 + 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index d0854925e3..c3c722edd3 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -179,6 +179,11 @@ struct _virDomainDeviceInfo { * cases we might want to prevent that from happening by * locking the isolation group */ bool isolationGroupLocked; + +/* vhost-user-scsi/blk/nvme support multiqueue, parse the queue + * num from xml. + */ +unsigned int num_queues; }; void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fd53fab271..eeed88e41e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7483,10 +7483,12 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, xmlNodePtr alias = NULL; xmlNodePtr boot = NULL; xmlNodePtr rom = NULL; +xmlNodePtr queue = NULL; int ret = -1; VIR_AUTOFREE(char *) romenabled = NULL; VIR_AUTOFREE(char *) rombar = NULL; VIR_AUTOFREE(char *) aliasStr = NULL; +VIR_AUTOFREE(char *) queueStr = NULL; virDomainDeviceInfoClear(info); @@ -7510,6 +7512,9 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, (flags & VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) && virXMLNodeNameEqual(cur, "rom")) { rom = cur; +} else if (queue == NULL && + virXMLNodeNameEqual(cur, "queue")) { +queue = cur; } } cur = cur->next; @@ -7563,6 +7568,15 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, virDomainDeviceAddressParseXML(address, info) < 0) goto cleanup; +if (queue) { +queueStr = virXMLPropString(queue, "num"); +if (virStrToLong_uip(queueStr, NULL, 10, >num_queues) < 0) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Cannot parse 'num' attribute '%s'"), queueStr); + +goto cleanup; +} +} ret = 0; cleanup: diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 336ca3f729..7a3c695ac1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10737,6 +10737,13 @@ qemuBuildVhostUserChrDeviceStr(char **deviceStr, virBufferAsprintf(, "%s,chardev=char%s,id=%s", device_type, vhostuser->info.alias, vhostuser->info.alias); +if (vhostuser->info.num_queues > 0) { +if ((virDomainChrDeviceType)vhostuser->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_SCSI) { +virBufferAsprintf(, ",num_queues=%d", vhostuser->info.num_queues); +} else if ((virDomainChrDeviceType)vhostuser->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_BLK) { +virBufferAsprintf(, ",num-queues=%d", vhostuser->info.num_queues); +} +} if (qemuBuildDeviceAddressStr(, def, >info, qemuCaps) < 0) return -1; diff --git a/tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args index 4c67be1863..ea99f5949d 100644 --- a/tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args @@ -31,7 +31,7 @@ file=/tmp/lib/domain--1-test/master-key.aes \ -chardev socket,id=charvhost-user-blk-disk0,path=/tmp/vhost-blk.sock,\ reconnect=1 \ -device vhost-user-blk-pci,chardev=charvhost-user-blk-disk0,\ -id=vhost-user-blk-disk0 \ +id=vhost-user-blk-disk0,num-queues=4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/vhost-user-blk.xml b/tests/qemuxml2argvdata/vhost-user-blk.xml index c9ff7650cb..276fea14b5 100644 --- a/tests/qemuxml2argvdata/vhost-user-blk.xml +++ b/tests/qemuxml2argvdata/vhost-user-blk.xml @@ -32,6 +32,7 @@ + -- 2.11.0 -- The SmartX email address is only for business purpose. Any sent message that is not related to the business is not authorized or permitted by SmartX. 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] vhost-user-scsi/blk: add xml validation check
Add vhost-user-scsi/blk xml schema to validate the correctness when editing the xml for the new chardev. Signed-off-by: Li Feng --- docs/schemas/domaincommon.rng | 48 +++ 1 file changed, 48 insertions(+) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 40eb4a2d75..63c629d117 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4375,6 +4375,52 @@ + + + + + +unix + + + + + + + + + + + + + + + + + + + + + + +unix + + + + + + + + + + + + + + + + + @@ -4973,6 +5019,8 @@ + + -- 2.11.0 -- The SmartX email address is only for business purpose. Any sent message that is not related to the business is not authorized or permitted by SmartX. 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/3] Add vhost-user-scsi/blk support
The latest qemu has support the vhost-user-scsi and vhost-user-blk backend for better performance. This patch let the libvirt could manage the vhost-user disks. Usage in xml like this: Li Feng (3): qemu: Add vhost-user-scsi/blk support vhost-user-scsi/blk: add xml validation check qemu: Add multiqueue support for vhost-user-scsi/blk docs/schemas/domaincommon.rng | 48 ++ src/conf/device_conf.h | 5 + src/conf/domain_conf.c | 93 +- src/conf/domain_conf.h | 9 ++ src/qemu/qemu_alias.c | 16 src/qemu/qemu_command.c| 105 + src/qemu/qemu_domain.c | 2 + .../vhost-user-blk.x86_64-latest.args | 37 tests/qemuxml2argvdata/vhost-user-blk.xml | 38 .../vhost-user-scsi.x86_64-latest.args | 37 tests/qemuxml2argvdata/vhost-user-scsi.xml | 37 tests/qemuxml2argvtest.c | 3 + 12 files changed, 429 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-user-blk.xml create mode 100644 tests/qemuxml2argvdata/vhost-user-scsi.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-user-scsi.xml -- 2.11.0 -- The SmartX email address is only for business purpose. Any sent message that is not related to the business is not authorized or permitted by SmartX. 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/3] qemu: Add vhost-user-scsi/blk support
Vhost-user-scsi and vhost-user-blk is supported in Qemu, this patch add support in libvirt. Hotplug is also support here. Usage like this: Signed-off-by: Li Feng --- src/conf/domain_conf.c | 79 - src/conf/domain_conf.h | 9 ++ src/qemu/qemu_alias.c | 16 src/qemu/qemu_command.c| 98 ++ src/qemu/qemu_domain.c | 2 + .../vhost-user-blk.x86_64-latest.args | 37 tests/qemuxml2argvdata/vhost-user-blk.xml | 37 .../vhost-user-scsi.x86_64-latest.args | 37 tests/qemuxml2argvdata/vhost-user-scsi.xml | 37 tests/qemuxml2argvtest.c | 3 + 10 files changed, 354 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/vhost-user-blk.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-user-blk.xml create mode 100644 tests/qemuxml2argvdata/vhost-user-scsi.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/vhost-user-scsi.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5d090876f8..fd53fab271 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -619,6 +619,8 @@ VIR_ENUM_IMPL(virDomainChrDevice, "serial", "console", "channel", + "vhost-user-scsi-pci", + "vhost-user-blk-pci", ); VIR_ENUM_IMPL(virDomainChr, @@ -4182,6 +4184,16 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, if ((rc = cb(def, , >channels[i]->info, opaque)) != 0) return rc; } +for (i = 0; i < def->n_vhost_user_blk; i++) { +device.data.chr = def->vhost_user_blk[i]; +if ((rc = cb(def, , >vhost_user_blk[i]->info, opaque)) != 0) +return rc; +} +for (i = 0; i < def->n_vhost_user_scsi; i++) { +device.data.chr = def->vhost_user_scsi[i]; +if ((rc = cb(def, , >vhost_user_scsi[i]->info, opaque)) != 0) +return rc; +} for (i = 0; i < def->nconsoles; i++) { bool all = iteratorFlags & DOMAIN_DEVICE_ITERATE_ALL_CONSOLES; @@ -12284,6 +12296,8 @@ virDomainChrDefaultTargetType(int devtype) case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE; +case VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_SCSI: +case VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_BLK: case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: /* No target type yet*/ @@ -12315,6 +12329,8 @@ virDomainChrTargetTypeFromString(int devtype, ret = virDomainChrSerialTargetTypeFromString(targetType); break; +case VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_SCSI: +case VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_BLK: case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: /* No target type yet*/ @@ -12339,6 +12355,8 @@ virDomainChrTargetModelFromString(int devtype, ret = virDomainChrSerialTargetModelTypeFromString(targetModel); break; +case VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_SCSI: +case VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_BLK: case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: @@ -16410,7 +16428,9 @@ virDomainDeviceDefParse(const char *xmlStr, if (virXMLNodeNameEqual(node, "channel") || virXMLNodeNameEqual(node, "console") || virXMLNodeNameEqual(node, "parallel") || -virXMLNodeNameEqual(node, "serial")) { +virXMLNodeNameEqual(node, "serial") || +virXMLNodeNameEqual(node, "vhost-user-blk-pci") || +virXMLNodeNameEqual(node, "vhost-user-scsi-pci")) { dev->type = VIR_DOMAIN_DEVICE_CHR; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -17486,6 +17506,11 @@ virDomainChrEquals(virDomainChrDefPtr src, ATTRIBUTE_FALLTHROUGH; +case VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_SCSI: +case VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_BLK: +return STREQ_NULLABLE(src->source->data.nix.path, +tgt->source->data.nix.path); + case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: return src->target.port == tgt->target.port; @@ -17545,6 +17570,14 @@ virDomainChrGetDomainPtrsInternal(virDomainDefPtr vmdef, *arrPtr = >channels; *cntPtr = >nchannels; return 0; +case VIR_DOMAIN_CHR_DEVICE_TYPE_VHOST_USER_BLK: +*arrPtr = >vhost_user_blk; +*cntPtr = &g
[libvirt] Add support for vhost-user-scsi-pci/vhost-user-blk-pci
Hi Guys, And I want to add the vhost-user-scsi-pci/vhost-user-blk-pci support for libvirt. The usage in qemu like this: Vhost-SCSI -chardev socket,id=char0,path=/var/tmp/vhost.0 -device vhost-user-scsi-pci,id=scsi0,chardev=char0 Vhost-BLK -chardev socket,id=char1,path=/var/tmp/vhost.1 -device vhost-user-blk-pci,id=blk0,chardev=char1 What type should I add for libvirt. Type1: Type2: Could anyone give some suggestions? Thanks, Feng Li -- The SmartX email address is only for business purpose. Any sent message that is not related to the business is not authorized or permitted by SmartX. 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list