From nobody Sun Feb 8 17:03:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1487679547994527.97720726673; Tue, 21 Feb 2017 04:19:07 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LCFVha030697; Tue, 21 Feb 2017 07:15:31 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1LCFIcr022611 for ; Tue, 21 Feb 2017 07:15:18 -0500 Received: from antique-work.brq.redhat.com (dhcp129-175.brq.redhat.com [10.34.129.175]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LCF9hM031008 for ; Tue, 21 Feb 2017 07:15:17 -0500 From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 21 Feb 2017 13:15:05 +0100 Message-Id: <5e1c29b2205e824bb5dc314a668191cbec218726.1487678590.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/12] qemu: implement iothread polling X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/qemu/qemu_command.c | 78 ++++++++++++++++++= ++-- src/qemu/qemu_command.h | 5 +- src/qemu/qemu_domain.c | 23 ++++++- src/qemu/qemu_domain.h | 6 ++ src/qemu/qemu_driver.c | 6 +- src/qemu/qemu_process.c | 14 +++- .../qemuxml2argv-iothreads-polling-disabled.args | 23 +++++++ .../qemuxml2argv-iothreads-polling-disabled.xml | 36 ++++++++++ .../qemuxml2argv-iothreads-polling-enabled.args | 23 +++++++ .../qemuxml2argv-iothreads-polling-enabled.xml | 36 ++++++++++ ...emuxml2argv-iothreads-polling-not-supported.xml | 1 + tests/qemuxml2argvtest.c | 8 +++ 12 files changed, 248 insertions(+), 11 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-d= isabled.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-d= isabled.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-e= nabled.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-e= nabled.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-n= ot-supported.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 552fdcf05e..1a189459a4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7277,11 +7277,59 @@ qemuBuildMemCommandLine(virCommandPtr cmd, } =20 =20 +int +qemuBuildIOThreadProps(const virDomainIOThreadIDDef *def, + virQEMUCapsPtr qemuCaps, + virJSONValuePtr *props) +{ + virJSONValuePtr newProps =3D NULL; + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_IOTHREAD_POLLING)) { + switch (def->poll_enabled) { + case VIR_TRISTATE_BOOL_YES: + if (virJSONValueObjectCreate(&newProps, "u:poll-max-ns", + def->poll_max_ns, NULL) < 0) + goto error; + + if (def->poll_grow && + virJSONValueObjectAdd(newProps, "u:poll-grow", + def->poll_grow, NULL) < 0) + goto error; + + if (def->poll_shrink && + virJSONValueObjectAdd(newProps, "u:poll-shrink", + def->poll_shrink, NULL) < 0) + goto error; + break; + case VIR_TRISTATE_BOOL_NO: + if (virJSONValueObjectCreate(&newProps, "u:poll-max-ns", 0, NU= LL) < 0) + goto error; + break; + case VIR_TRISTATE_BOOL_ABSENT: + case VIR_TRISTATE_BOOL_LAST: + break; + } + } + + *props =3D newProps; + return 0; + + error: + virJSONValueFree(newProps); + return -1; +} + + static int qemuBuildIOThreadCommandLine(virCommandPtr cmd, - const virDomainDef *def) + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) { size_t i; + int ret =3D -1; + char *alias =3D NULL; + char *propsCmd =3D NULL; + virJSONValuePtr props =3D NULL; =20 if (def->niothreadids =3D=3D 0) return 0; @@ -7293,11 +7341,31 @@ qemuBuildIOThreadCommandLine(virCommandPtr cmd, */ for (i =3D 0; i < def->niothreadids; i++) { virCommandAddArg(cmd, "-object"); - virCommandAddArgFormat(cmd, "iothread,id=3Diothread%u", - def->iothreadids[i]->iothread_id); + + if (virAsprintf(&alias, "iothread%u", def->iothreadids[i]->iothrea= d_id) < 0) + goto cleanup; + + if (qemuBuildIOThreadProps(def->iothreadids[i], qemuCaps, &props) = < 0) + goto cleanup; + + if (!(propsCmd =3D virQEMUBuildObjectCommandlineFromJSON("iothread= ", + alias, prop= s))) + goto cleanup; + + virCommandAddArg(cmd, propsCmd); + + virJSONValueFree(props); + VIR_FREE(propsCmd); + VIR_FREE(alias); } =20 - return 0; + ret =3D 0; + + cleanup: + virJSONValueFree(props); + VIR_FREE(propsCmd); + VIR_FREE(alias); + return ret; } =20 =20 @@ -9598,7 +9666,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildSmpCommandLine(cmd, def) < 0) goto error; =20 - if (qemuBuildIOThreadCommandLine(cmd, def) < 0) + if (qemuBuildIOThreadCommandLine(cmd, def, qemuCaps) < 0) goto error; =20 if (virDomainNumaGetNodeCount(def->numa) && diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 69fe846139..84e8099bfe 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -202,6 +202,9 @@ char *qemuBuildShmemDevStr(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 - +int qemuBuildIOThreadProps(const virDomainIOThreadIDDef *def, + virQEMUCapsPtr qemuCaps, + virJSONValuePtr *props) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 #endif /* __QEMU_COMMAND_H__*/ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ea4b28288e..009c93a15e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3283,7 +3283,8 @@ virDomainDefParserConfig virQEMUDriverDomainDefParser= Config =3D { =20 .features =3D VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG | VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN | - VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS, + VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS | + VIR_DOMAIN_DEF_FEATURE_IOTHREAD_POLLING, }; =20 =20 @@ -8280,3 +8281,23 @@ qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr driv= er, cleanup: return ret; } + + +void +qemuDomainIOThreadUpdate(virDomainIOThreadIDDefPtr iothread, + qemuMonitorIOThreadInfoPtr iothread_info, + bool supportPolling) +{ + iothread->thread_id =3D iothread_info->thread_id; + + if (supportPolling && iothread->poll_enabled =3D=3D VIR_TRISTATE_BOOL_= ABSENT) { + iothread->poll_max_ns =3D iothread_info->poll_max_ns; + iothread->poll_grow =3D iothread_info->poll_grow; + iothread->poll_shrink =3D iothread_info->poll_shrink; + + if (iothread->poll_max_ns =3D=3D 0) + iothread->poll_enabled =3D VIR_TRISTATE_BOOL_NO; + else + iothread->poll_enabled =3D VIR_TRISTATE_BOOL_YES; + } +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 8ba807c656..900b689411 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -848,4 +848,10 @@ int qemuDomainNamespaceSetupRNG(virQEMUDriverPtr drive= r, int qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainRNGDefPtr rng); + +void qemuDomainIOThreadUpdate(virDomainIOThreadIDDefPtr iothread, + qemuMonitorIOThreadInfoPtr iothread_info, + bool supportPolling) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ff610a7692..9e3691b575 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5581,6 +5581,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, unsigned int orig_niothreads =3D vm->def->niothreadids; unsigned int exp_niothreads =3D vm->def->niothreadids; int new_niothreads =3D 0; + bool supportPolling =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_IOTHR= EAD_POLLING); qemuMonitorIOThreadInfoPtr *new_iothreads =3D NULL; virDomainIOThreadIDDefPtr iothrid; =20 @@ -5599,7 +5600,8 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, * and add the thread_id to the vm->def->iothreadids list. */ if ((new_niothreads =3D qemuMonitorGetIOThreads(priv->mon, - &new_iothreads, false)) = < 0) + &new_iothreads, + supportPolling)) < 0) goto exit_monitor; =20 if (qemuDomainObjExitMonitor(driver, vm) < 0) @@ -5632,7 +5634,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, if (!(iothrid =3D virDomainIOThreadIDAdd(vm->def, iothread_id))) goto cleanup; =20 - iothrid->thread_id =3D new_iothreads[idx]->thread_id; + qemuDomainIOThreadUpdate(iothrid, new_iothreads[idx], supportPolling); =20 if (qemuProcessSetupIOThread(vm, iothrid) < 0) goto cleanup; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9eb4dfd5fa..4f64c0e7d6 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2100,11 +2100,12 @@ qemuProcessDetectIOThreadPIDs(virQEMUDriverPtr driv= er, int niothreads =3D 0; int ret =3D -1; size_t i; + bool supportPolling =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_IOTHR= EAD_POLLING); =20 /* Get the list of IOThreads from qemu */ if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; - niothreads =3D qemuMonitorGetIOThreads(priv->mon, &iothreads, false); + niothreads =3D qemuMonitorGetIOThreads(priv->mon, &iothreads, supportP= olling); if (qemuDomainObjExitMonitor(driver, vm) < 0) goto cleanup; if (niothreads < 0) @@ -2134,7 +2135,7 @@ qemuProcessDetectIOThreadPIDs(virQEMUDriverPtr driver, iothreads[i]->iothread_id); goto cleanup; } - iothrid->thread_id =3D iothreads[i]->thread_id; + qemuDomainIOThreadUpdate(iothrid, iothreads[i], supportPolling); } =20 ret =3D 0; @@ -4571,6 +4572,15 @@ qemuProcessStartValidateIOThreads(virDomainObjPtr vm, return -1; } =20 + for (i =3D 0; i < vm->def->niothreadids; i++) { + if (vm->def->iothreadids[i]->poll_enabled !=3D VIR_TRISTATE_BOOL_A= BSENT && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_IOTHREAD_POLLING)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOThreads polling is not supported for this = QEMU")); + return -1; + } + } + for (i =3D 0; i < vm->def->ncontrollers; i++) { virDomainControllerDefPtr cont =3D vm->def->controllers[i]; =20 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-disabled= .args b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-disabled.args new file mode 100644 index 0000000000..e9b53f0976 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-disabled.args @@ -0,0 +1,23 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-object iothread,id=3Diothread1,poll-max-ns=3D0 \ +-object iothread,id=3Diothread2 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-disabled= .xml b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-disabled.xml new file mode 100644 index 0000000000..f9d769f860 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-disabled.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 2 + 2 + + + + + + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-enabled.= args b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-enabled.args new file mode 100644 index 0000000000..b3495dfe9c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-enabled.args @@ -0,0 +1,23 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-object iothread,id=3Diothread1,poll-max-ns=3D4000 \ +-object iothread,id=3Diothread2 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-enabled.= xml b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-enabled.xml new file mode 100644 index 0000000000..44b6e2e219 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-enabled.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 2 + 2 + + + + + + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-not-supp= orted.xml b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-not-suppo= rted.xml new file mode 120000 index 0000000000..5b40c52a2d --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-polling-not-supported.x= ml @@ -0,0 +1 @@ +qemuxml2argv-iothreads-polling-enabled.xml \ No newline at end of file diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f55b04b057..603e43d295 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1507,6 +1507,14 @@ mymain(void) DO_TEST("iothreads-virtio-scsi-ccw", QEMU_CAPS_OBJECT_IOTHREAD, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI_IOTHREAD, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); + DO_TEST("iothreads-polling-enabled", + QEMU_CAPS_OBJECT_IOTHREAD, + QEMU_CAPS_IOTHREAD_POLLING); + DO_TEST("iothreads-polling-disabled", + QEMU_CAPS_OBJECT_IOTHREAD, + QEMU_CAPS_IOTHREAD_POLLING); + DO_TEST_FAILURE("iothreads-polling-not-supported", + QEMU_CAPS_OBJECT_IOTHREAD); =20 DO_TEST("cpu-topology1", NONE); DO_TEST("cpu-topology2", NONE); --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list