From nobody Tue May 13 11:10:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1538917291933638.7754522801305; Sun, 7 Oct 2018 06:01:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54C8380F6B; Sun, 7 Oct 2018 13:01:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 197722E057; Sun, 7 Oct 2018 13:01:30 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A9EB718005B9; Sun, 7 Oct 2018 13:01:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w97D0Ynb010067 for ; Sun, 7 Oct 2018 09:00:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF1592010D97; Sun, 7 Oct 2018 13:00:34 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-15.phx2.redhat.com [10.3.116.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E5DB2010D60 for ; Sun, 7 Oct 2018 13:00:34 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Sun, 7 Oct 2018 09:00:23 -0400 Message-Id: <20181007130024.1750-11-jferlan@redhat.com> In-Reply-To: <20181007130024.1750-1-jferlan@redhat.com> References: <20181007130024.1750-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/11] qemu: Introduce qemuDomainSetIOThreadParams 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 07 Oct 2018 13:01:30 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1545732 Implement the QEMU driver mechanism in order to set the polling parameters for an IOThread within the bounds specified by the QEMU qapi parameter passing. Based heavily on patches originally posted by Pavel Hrdina , but modified to only handle alterations for a running guest. For the most part the API names changed, the typed parameters removed the poll enabled value, and the capabilities check was moved to just before the live attempt to set. Since changes are only supported for a running guest, no guest XML alterations were kept. Signed-off-by: John Ferlan --- src/qemu/qemu_driver.c | 202 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c87a0db86d..be668b3217 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5899,6 +5899,35 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver, goto cleanup; } =20 + +static int +qemuDomainHotplugModIOThread(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuMonitorIOThreadInfo iothread) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + int rc; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_IOTHREAD_POLLING)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOThreads polling is not supported for this QEMU= ")); + return -1; + } + + qemuDomainObjEnterMonitor(driver, vm); + + rc =3D qemuMonitorSetIOThread(priv->mon, &iothread); + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return -1; + + if (rc < 0) + return -1; + + return 0; +} + + static int qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -6015,9 +6044,107 @@ qemuDomainDelIOThreadCheck(virDomainDefPtr def, return 0; } =20 + +/** + * @params: Pointer to params list + * @nparams: Number of params to be parsed + * @iothread: Buffer to store the values + * + * The following is a description of each value parsed: + * + * - "poll-max-ns" for each IOThread is the maximum time in nanoseconds + * to allow each polling interval to occur. A polling interval is a + * period of time allowed for a thread to process data before it returns + * the CPU quantum back to the host. A value set too small will not all= ow + * the IOThread to run long enough on a CPU to process data. A value set + * too high will consume too much CPU time per IOThread failing to allow + * other threads running on the CPU to get time. A value of 0 (zero) wi= ll + * disable the polling. + * + * - "poll-grow" - factor to grow the current polling time when deemed + * necessary. If a 0 (zero) value is provided, QEMU currently doubles + * its polling interval unless the current value is greater than the + * poll-max-ns. + * + * - "poll-shrink" - divisor to reduced the current polling time when deem= ed + * necessary. If a 0 (zero) value is provided, QEMU resets the polling + * interval to 0 (zero) allowing the poll-grow to manipulate the time. + * + * QEMU keeps track of the polling time elapsed and may grow or shrink the + * its polling interval based upon its heuristic algorithm. It is possible + * that calculations determine that it has found a "sweet spot" and no + * ajustments are made. The polling time value is not available. + * + * Returns 0 on success, -1 on failure with error set. + */ +static int +qemuDomainIOThreadParseParams(virTypedParameterPtr params, + int nparams, + qemuMonitorIOThreadInfoPtr iothread) +{ + if (virTypedParamsValidate(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_IOTHREAD_POLL_GROW, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_IOTHREAD_POLL_SHRINK, + VIR_TYPED_PARAM_UINT, + NULL) < 0) + return -1; + + if (virTypedParamsGetULLong(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 (iothread->poll_max_ns > INT_MAX) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("poll-max-ns (%llu) must be less than or equal to= %d"), + iothread->poll_max_ns, INT_MAX); + return -1; + } + + if (iothread->poll_grow > INT_MAX) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("poll-grow (%u) must be less than or equal to %d"= ), + iothread->poll_grow, INT_MAX); + return -1; + } + + if (iothread->poll_shrink > INT_MAX) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("poll-shrink (%u) must be less than or equal to %= d"), + iothread->poll_shrink, INT_MAX); + return -1; + } + + if ((iothread->poll_grow > 0 || iothread->poll_shrink > 0) && + iothread->poll_max_ns =3D=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("poll-grow or poll-shrink is set for iothread id " + "'%u' but poll-max-ns is not set"), + iothread->iothread_id); + return -1; + } + + return 0; +} + + typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, VIR_DOMAIN_IOTHREAD_ACTION_DEL, + VIR_DOMAIN_IOTHREAD_ACTION_MOD, } virDomainIOThreadAction; =20 static int @@ -6068,6 +6195,20 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, goto endjob; =20 break; + + case VIR_DOMAIN_IOTHREAD_ACTION_MOD: + if (!(virDomainIOThreadIDFind(def, iothread.iothread_id))) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot find IOThread '%u' in iothreadids= "), + iothread.iothread_id); + goto endjob; + } + + if (qemuDomainHotplugModIOThread(driver, vm, iothread) < 0) + goto endjob; + + break; + } =20 if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) @@ -6091,6 +6232,14 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, =20 virDomainIOThreadIDDel(persistentDef, iothread.iothread_id); =20 + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_MOD: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("configuring persistent polling values is " + "not supported")); + goto endjob; + break; } =20 @@ -6178,6 +6327,58 @@ qemuDomainDelIOThread(virDomainPtr dom, return ret; } =20 + +/** + * @dom: Domain to set IOThread params + * @iothread_id: IOThread 'id' that will be modified + * @params: List of parameters to change + * @nparams: Number of parameters in the list + * @flags: Flags for the set (only supports live alteration) + * + * Alter the specified @iothread_id with the values provided. + * + * Returs 0 on success, -1 on failure + */ +static int +qemuDomainSetIOThreadParams(virDomainPtr dom, + unsigned int iothread_id, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm =3D NULL; + qemuMonitorIOThreadInfo iothread =3D {0}; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE, -1); + + if (iothread_id =3D=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid value of 0 for iothread_id")); + goto cleanup; + } + + iothread.iothread_id =3D iothread_id; + + if (!(vm =3D qemuDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainSetIOThreadParamsEnsureACL(dom->conn, vm->def, flags) < 0) + goto cleanup; + + if (qemuDomainIOThreadParseParams(params, nparams, &iothread) < 0) + goto cleanup; + + ret =3D qemuDomainChgIOThread(driver, vm, iothread, + VIR_DOMAIN_IOTHREAD_ACTION_MOD, flags); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static int qemuDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPt= r seclabel) { virQEMUDriverPtr driver =3D dom->conn->privateData; @@ -21955,6 +22156,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainPinIOThread =3D qemuDomainPinIOThread, /* 1.2.14 */ .domainAddIOThread =3D qemuDomainAddIOThread, /* 1.2.15 */ .domainDelIOThread =3D qemuDomainDelIOThread, /* 1.2.15 */ + .domainSetIOThreadParams =3D qemuDomainSetIOThreadParams, /* 4.9.0 */ .domainGetSecurityLabel =3D qemuDomainGetSecurityLabel, /* 0.6.1 */ .domainGetSecurityLabelList =3D qemuDomainGetSecurityLabelList, /* 0.1= 0.0 */ .nodeGetSecurityModel =3D qemuNodeGetSecurityModel, /* 0.6.1 */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list