From nobody Sun Feb 8 10:29:55 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 1487679558538744.5826395192812; Tue, 21 Feb 2017 04:19:18 -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 v1LCFfWk030708; Tue, 21 Feb 2017 07:15:41 -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 v1LCFJxf022621 for ; Tue, 21 Feb 2017 07:15:19 -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 v1LCF9hN031008 for ; Tue, 21 Feb 2017 07:15:18 -0500 From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 21 Feb 2017 13:15:06 +0100 Message-Id: <36ca8ca9bc373687c4e3ab6828de6dddf1305d11.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 10/12] qemu: implement virDomainAddIOThreadParams API 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/conf/domain_conf.c | 4 +- src/conf/domain_conf.h | 2 +- src/qemu/qemu_driver.c | 182 +++++++++++++++++++++++++++++++++++++--------= ---- 3 files changed, 140 insertions(+), 48 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4b552a9175..64303a6790 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20348,14 +20348,14 @@ virDomainIOThreadIDFind(const virDomainDef *def, =20 virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def, - unsigned int iothread_id) + virDomainIOThreadIDDef iothread) { virDomainIOThreadIDDefPtr iothrid =3D NULL; =20 if (VIR_ALLOC(iothrid) < 0) goto error; =20 - iothrid->iothread_id =3D iothread_id; + *iothrid =3D iothread; =20 if (VIR_APPEND_ELEMENT_COPY(def->iothreadids, def->niothreadids, iothrid) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8ac1d8a409..5f8c745d8a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2791,7 +2791,7 @@ int virDomainDefAddImplicitDevices(virDomainDefPtr de= f); virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def, unsigned int iothread_id= ); virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def, - unsigned int iothread_id); + virDomainIOThreadIDDef io= thread); void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id); =20 unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9e3691b575..96c8b2b8bc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5571,7 +5571,7 @@ qemuDomainPinIOThread(virDomainPtr dom, static int qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, virDomainObjPtr vm, - unsigned int iothread_id) + virDomainIOThreadIDDef iothread) { qemuDomainObjPrivatePtr priv =3D vm->privateData; char *alias =3D NULL; @@ -5583,14 +5583,18 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr drive= r, int new_niothreads =3D 0; bool supportPolling =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_IOTHR= EAD_POLLING); qemuMonitorIOThreadInfoPtr *new_iothreads =3D NULL; - virDomainIOThreadIDDefPtr iothrid; + virDomainIOThreadIDDefPtr new_iothread =3D NULL; + virJSONValuePtr props =3D NULL; =20 - if (virAsprintf(&alias, "iothread%u", iothread_id) < 0) + if (virAsprintf(&alias, "iothread%u", iothread.iothread_id) < 0) return -1; =20 qemuDomainObjEnterMonitor(driver, vm); =20 - rc =3D qemuMonitorAddObject(priv->mon, "iothread", alias, NULL); + if (qemuBuildIOThreadProps(&iothread, priv->qemuCaps, &props) < 0) + goto cleanup; + + rc =3D qemuMonitorAddObject(priv->mon, "iothread", alias, props); exp_niothreads++; if (rc < 0) goto exit_monitor; @@ -5620,23 +5624,23 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr drive= r, * in the QEMU IOThread list, so we can add it to our iothreadids list */ for (idx =3D 0; idx < new_niothreads; idx++) { - if (new_iothreads[idx]->iothread_id =3D=3D iothread_id) + if (new_iothreads[idx]->iothread_id =3D=3D iothread.iothread_id) break; } =20 if (idx =3D=3D new_niothreads) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot find new IOThread '%u' in QEMU monitor."), - iothread_id); + iothread.iothread_id); goto cleanup; } =20 - if (!(iothrid =3D virDomainIOThreadIDAdd(vm->def, iothread_id))) + if (!(new_iothread =3D virDomainIOThreadIDAdd(vm->def, iothread))) goto cleanup; =20 - qemuDomainIOThreadUpdate(iothrid, new_iothreads[idx], supportPolling); + qemuDomainIOThreadUpdate(new_iothread, new_iothreads[idx], supportPoll= ing); =20 - if (qemuProcessSetupIOThread(vm, iothrid) < 0) + if (qemuProcessSetupIOThread(vm, new_iothread) < 0) goto cleanup; =20 ret =3D 0; @@ -5649,6 +5653,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, } virDomainAuditIOThread(vm, orig_niothreads, new_niothreads, "update", rc =3D=3D 0); + virJSONValueFree(props); VIR_FREE(alias); return ret; =20 @@ -5773,10 +5778,73 @@ qemuDomainDelIOThreadCheck(virDomainDefPtr def, return 0; } =20 + +static int +qemuDomainIOThreadParseParams(virTypedParameterPtr params, + int nparams, + qemuDomainObjPrivatePtr priv, + virDomainIOThreadIDDefPtr iothread) +{ + int poll_enabled; + int rc; + + if (virTypedParamsValidate(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_ENABLED, + VIR_TYPED_PARAM_BOOLEAN, + VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_IOTHREAD_POLL_GROW, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_IOTHREAD_POLL_SHRINK, + VIR_TYPED_PARAM_UINT, + NULL) < 0) + return -1; + + if ((rc =3D virTypedParamsGetBoolean(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_ENABLED, + &poll_enabled)) < 0) + return -1; + + if (rc > 0) { + if (poll_enabled) + iothread->poll_enabled =3D VIR_TRISTATE_BOOL_YES; + else + iothread->poll_enabled =3D VIR_TRISTATE_BOOL_NO; + } + + if (virTypedParamsGetUInt(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, + &iothread->poll_max_ns) < 0) + return -1; + + if (virTypedParamsGetUInt(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_GROW, + &iothread->poll_grow) < 0) + return -1; + + if (virTypedParamsGetUInt(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_SHRINK, + &iothread->poll_shrink) < 0) + return -1; + + if (virDomainIOThreadDefPostParse(iothread) < 0) + return -1; + + if (iothread->poll_enabled !=3D VIR_TRISTATE_BOOL_ABSENT && + !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_IOTHREAD_POLLING)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOThreads polling is not supported for this QEMU= ")); + return -1; + } + + return 0; +} + + static int qemuDomainChgIOThread(virQEMUDriverPtr driver, virDomainObjPtr vm, - unsigned int iothread_id, + virDomainIOThreadIDDef iothread, bool add, unsigned int flags) { @@ -5804,36 +5872,39 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, } =20 if (add) { - if (qemuDomainAddIOThreadCheck(def, iothread_id) < 0) + if (qemuDomainAddIOThreadCheck(def, iothread.iothread_id) < 0) goto endjob; =20 - if (qemuDomainHotplugAddIOThread(driver, vm, iothread_id) < 0) + if (qemuDomainHotplugAddIOThread(driver, vm, iothread) < 0) goto endjob; } else { - if (qemuDomainDelIOThreadCheck(def, iothread_id) < 0) + if (qemuDomainDelIOThreadCheck(def, iothread.iothread_id) < 0) goto endjob; =20 - if (qemuDomainHotplugDelIOThread(driver, vm, iothread_id) < 0) + if (qemuDomainHotplugDelIOThread(driver, vm, + iothread.iothread_id) < 0) goto endjob; } =20 - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, + driver->caps) < 0) goto endjob; } =20 if (persistentDef) { if (add) { - if (qemuDomainAddIOThreadCheck(persistentDef, iothread_id) < 0) + if (qemuDomainAddIOThreadCheck(persistentDef, + iothread.iothread_id) < 0) goto endjob; =20 - if (!virDomainIOThreadIDAdd(persistentDef, iothread_id)) + if (!virDomainIOThreadIDAdd(persistentDef, iothread)) goto endjob; - } else { - if (qemuDomainDelIOThreadCheck(persistentDef, iothread_id) < 0) + if (qemuDomainDelIOThreadCheck(persistentDef, + iothread.iothread_id) < 0) goto endjob; =20 - virDomainIOThreadIDDel(persistentDef, iothread_id); + virDomainIOThreadIDDel(persistentDef, iothread.iothread_id); } =20 if (virDomainSaveConfig(cfg->configDir, driver->caps, @@ -5851,35 +5922,53 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, return ret; } =20 + +static int +qemuDomainAddIOThreadParams(virDomainPtr dom, + unsigned int iothread_id, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm =3D NULL; + virDomainIOThreadIDDef iothread =3D {0}; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (iothread_id =3D=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid value of 0 for iothread_id")); + return -1; + } + iothread.iothread_id =3D iothread_id; + + if (!(vm =3D qemuDomObjFromDomain(dom))) + goto cleanup; + + if (qemuDomainIOThreadParseParams(params, nparams, vm->privateData, + &iothread) < 0) + goto cleanup; + + if (virDomainAddIOThreadParamsEnsureACL(dom->conn, vm->def, flags) < 0) + goto cleanup; + + ret =3D qemuDomainChgIOThread(driver, vm, iothread, true, flags); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static int qemuDomainAddIOThread(virDomainPtr dom, unsigned int iothread_id, unsigned int flags) { - virQEMUDriverPtr driver =3D dom->conn->privateData; - virDomainObjPtr vm =3D NULL; - int ret =3D -1; - - virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | - VIR_DOMAIN_AFFECT_CONFIG, -1); - - if (iothread_id =3D=3D 0) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("invalid value of 0 for iothread_id")); - return -1; - } - - if (!(vm =3D qemuDomObjFromDomain(dom))) - goto cleanup; - - if (virDomainAddIOThreadEnsureACL(dom->conn, vm->def, flags) < 0) - goto cleanup; - - ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, true, flags); - - cleanup: - virDomainObjEndAPI(&vm); - return ret; + return qemuDomainAddIOThreadParams(dom, iothread_id, NULL, 0, flags); } =20 =20 @@ -5890,6 +5979,7 @@ qemuDomainDelIOThread(virDomainPtr dom, { virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm =3D NULL; + virDomainIOThreadIDDef iothread =3D {0}; int ret =3D -1; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -5900,6 +5990,7 @@ qemuDomainDelIOThread(virDomainPtr dom, _("invalid value of 0 for iothread_id")); return -1; } + iothread.iothread_id =3D iothread_id; =20 if (!(vm =3D qemuDomObjFromDomain(dom))) goto cleanup; @@ -5907,7 +5998,7 @@ qemuDomainDelIOThread(virDomainPtr dom, if (virDomainDelIOThreadEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, false, flags); + ret =3D qemuDomainChgIOThread(driver, vm, iothread, false, flags); =20 cleanup: virDomainObjEndAPI(&vm); @@ -20274,6 +20365,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainGetIOThreadInfo =3D qemuDomainGetIOThreadInfo, /* 1.2.14 */ .domainPinIOThread =3D qemuDomainPinIOThread, /* 1.2.14 */ .domainAddIOThread =3D qemuDomainAddIOThread, /* 1.2.15 */ + .domainAddIOThreadParams =3D qemuDomainAddIOThreadParams, /* 3.1.0 */ .domainDelIOThread =3D qemuDomainDelIOThread, /* 1.2.15 */ .domainGetSecurityLabel =3D qemuDomainGetSecurityLabel, /* 0.6.1 */ .domainGetSecurityLabelList =3D qemuDomainGetSecurityLabelList, /* 0.1= 0.0 */ --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list