From nobody Sat Apr 20 11:21:11 2024 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 1541422989952266.49058150733026; Mon, 5 Nov 2018 05:03:09 -0800 (PST) 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 4058085A07; Mon, 5 Nov 2018 13:03:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04B70450D; Mon, 5 Nov 2018 13:03:08 +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 9CBFA4CAA0; Mon, 5 Nov 2018 13:03:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwNV9004269 for ; Mon, 5 Nov 2018 07:58:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 26FA7450D; Mon, 5 Nov 2018 12:58:23 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8AA418522 for ; Mon, 5 Nov 2018 12:58:22 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:05 -0500 Message-Id: <20181105125816.20385-2-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 01/12] qemu: Check for and return IOThread polling values if available 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.26]); Mon, 05 Nov 2018 13:03:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If there are IOThread polling values in the query-iothreads return buffer, then fill them in and set a bool indicating their presence. This will allow for displaying in a domain stats output eventually. Note that the QEMU values are managed a bit differently (as int's stored in int64_t's) than we will manage them (as unsigned long and int values). This is intentional to allow for value validation checking when it comes time to provide the values to QEMU. Signed-off-by: John Ferlan ACKed-by: Michal Privoznik Acked-by: Christian Borntraeger --- src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 48b142a4f4..c2991e2b16 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1116,6 +1116,10 @@ typedef qemuMonitorIOThreadInfo *qemuMonitorIOThread= InfoPtr; struct _qemuMonitorIOThreadInfo { unsigned int iothread_id; int thread_id; + bool poll_valid; + unsigned long long poll_max_ns; + unsigned int poll_grow; + unsigned int poll_shrink; }; int qemuMonitorGetIOThreads(qemuMonitorPtr mon, qemuMonitorIOThreadInfoPtr **iothreads); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3de298c9e2..2e92984b44 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7441,6 +7441,21 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon, "'thread-id' data")); goto cleanup; } + + /* Fetch poll values (since QEMU 2.9 ) if available. QEMU + * stores these values as int64_t's; however, the qapi type + * is an int. The qapi/misc.json also mis-describes the grow + * and shrink values as pure add/remove values. The source + * util/aio-posix.c function aio_poll uses them as a factor + * or divisor in it's calculation. We will fetch and store + * them as defined in our structures. */ + if (virJSONValueObjectGetNumberUlong(child, "poll-max-ns", + &info->poll_max_ns) =3D=3D 0 = && + virJSONValueObjectGetNumberUint(child, "poll-grow", + &info->poll_grow) =3D=3D 0 && + virJSONValueObjectGetNumberUint(child, "poll-shrink", + &info->poll_shrink) =3D=3D 0) + info->poll_valid =3D true; } =20 ret =3D n; --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541422891666411.677580173715; Mon, 5 Nov 2018 05:01:31 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FCDB86663; Mon, 5 Nov 2018 13:01:28 +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 DED5513ABE; Mon, 5 Nov 2018 13:01:27 +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 5008A18005B2; Mon, 5 Nov 2018 13:01:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwNYJ004274 for ; Mon, 5 Nov 2018 07:58:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 93D5C16D40; Mon, 5 Nov 2018 12:58:23 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50DE9450D for ; Mon, 5 Nov 2018 12:58:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:06 -0500 Message-Id: <20181105125816.20385-3-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 02/12] qemu: Split qemuDomainGetIOThreadsLive 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 05 Nov 2018 13:01:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Separate out the fetch of the IOThread monitor call into a separate helper so that a subsequent domain statistics change can fetch the raw IOThread data and parse it as it sees fit. Signed-off-by: John Ferlan Acked-by: Christian Borntraeger --- src/qemu/qemu_driver.c | 48 ++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a52e2495d5..e13633c1e0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5486,39 +5486,52 @@ qemuDomainGetMaxVcpus(virDomainPtr dom) VIR_DOMAIN_VCPU_MAXIMUM)); } =20 + static int -qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainIOThreadInfoPtr **info) +qemuDomainGetIOThreadsMon(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuMonitorIOThreadInfoPtr **iothreads) { qemuDomainObjPrivatePtr priv; - qemuMonitorIOThreadInfoPtr *iothreads =3D NULL; - virDomainIOThreadInfoPtr *info_ret =3D NULL; int niothreads =3D 0; - size_t i; - int ret =3D -1; - - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) - goto cleanup; =20 if (!virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cannot list IOThreads for an inactive domain")); - goto endjob; + return -1; } =20 priv =3D vm->privateData; if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("IOThreads not supported with this binary")); - goto endjob; + return -1; } =20 qemuDomainObjEnterMonitor(driver, vm); - niothreads =3D qemuMonitorGetIOThreads(priv->mon, &iothreads); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; - if (niothreads < 0) + niothreads =3D qemuMonitorGetIOThreads(priv->mon, iothreads); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || niothreads < 0) + return -1; + + return niothreads; +} + + +static int +qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainIOThreadInfoPtr **info) +{ + qemuMonitorIOThreadInfoPtr *iothreads =3D NULL; + virDomainIOThreadInfoPtr *info_ret =3D NULL; + int niothreads =3D 0; + size_t i; + int ret =3D -1; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) + goto cleanup; + + if ((niothreads =3D qemuDomainGetIOThreadsMon(driver, vm, &iothreads))= < 0) goto endjob; =20 /* Nothing to do */ @@ -5548,8 +5561,7 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, virBitmapFree(map); } =20 - *info =3D info_ret; - info_ret =3D NULL; + VIR_STEAL_PTR(*info, info_ret); ret =3D niothreads; =20 endjob: --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541422914460136.770369379646; Mon, 5 Nov 2018 05:01:54 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CB048763B; Mon, 5 Nov 2018 13:01:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1895C5D73F; Mon, 5 Nov 2018 13:01:52 +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 EFB9E4CA95; Mon, 5 Nov 2018 13:01:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwOLm004282 for ; Mon, 5 Nov 2018 07:58:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0C8422657C; Mon, 5 Nov 2018 12:58:24 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC27B18522 for ; Mon, 5 Nov 2018 12:58:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:07 -0500 Message-Id: <20181105125816.20385-4-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 03/12] qemu: Implement the ability to return IOThread stats 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.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 05 Nov 2018 13:01:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Process the IOThreads polling stats if available. Generate the output params record to be returned to the caller with the three values - poll-max-ns, poll-grow, and poll-shrink. Signed-off-by: John Ferlan Acked-by: Christian Borntraeger --- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 38 +++++++++++++++ src/qemu/qemu_driver.c | 81 ++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index fdd2d6b8ea..58fd4bc10c 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2048,6 +2048,7 @@ typedef enum { VIR_DOMAIN_STATS_INTERFACE =3D (1 << 4), /* return domain interfaces i= nfo */ VIR_DOMAIN_STATS_BLOCK =3D (1 << 5), /* return domain block info */ VIR_DOMAIN_STATS_PERF =3D (1 << 6), /* return domain perf event info */ + VIR_DOMAIN_STATS_IOTHREAD =3D (1 << 7), /* return iothread poll info */ } virDomainStatsTypes; =20 typedef enum { diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7690339521..9fda56d660 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11499,6 +11499,44 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * long long. It is produced by the * emulation_faults perf event * + * VIR_DOMAIN_STATS_IOTHREAD: + * Return IOThread statistics if available. IOThread polling is a + * timing mechanism that allows the hypervisor to generate a longer + * period of time in which the guest will perform operations on the + * CPU being used by the IOThread. The higher the value for poll-max-ns + * the longer the guest will keep the CPU. This may affect other host + * threads using the CPU. The poll-grow and poll-shrink values allow + * the hypervisor to generate a mechanism to add or remove polling time + * within the confines of 0 and poll-max-ns. For QEMU, the poll-grow is + * multiplied by the polling interval, while poll-shrink is used as a + * divisor. When not provided, QEMU may double the polling time until + * poll-max-ns is reached. When poll-shrink is 0 (zero) QEMU may reset + * the polling interval to 0 until it finds its "sweet spot". Setting + * poll-grow too large may cause frequent fluctution of the time; howe= ver, + * this can be tempered by a high poll-shrink to reduce the polling + * interval. For example, a poll-grow of 3 will triple the polling time + * which could quickly exceed poll-max-ns; however, a poll-shrink of + * 10 would cut that polling time more gradually. + * + * The typed parameter keys are in this format: + * + * "iothread.cnt" - maximum number of IOThreads in the subsequent list + * as unsigned int. Each IOThread in the list will + * will use it's iothread_id value as the . There + * may be fewer entries than the iothread.cnt + * value if the polling values are not supported. + * "iothread..poll-max-ns" - maximum polling time in ns as an unsi= gned + * long long. A 0 (zero) means polling is + * disabled. + * "iothread..poll-grow" - polling time factor as an unsigned int. + * A 0 (zero) indicates to allow the under= lying + * hypervisor to choose how to grow the + * polling time. + * "iothread..poll-shrink" - polling time divisor as an unsigned i= nt. + * A 0 (zero) indicates to allow the under= lying + * hypervisor to choose how to shrink the + * polling time. + * * Note that entire stats groups or individual stat fields may be missing = from * the output in case they are not supported by the given hypervisor, are = not * applicable for the current state of the guest domain, or their retrieval diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e13633c1e0..b50d805bf1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20437,6 +20437,86 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver, =20 #undef QEMU_ADD_NAME_PARAM =20 +#define QEMU_ADD_IOTHREAD_PARAM_UI(record, maxparams, id, name, value) \ + do { \ + char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \ + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \ + "iothread.%u.%s", id, name); \ + if (virTypedParamsAddUInt(&(record)->params, \ + &(record)->nparams, \ + maxparams, \ + param_name, \ + value) < 0) \ + goto cleanup; \ + } while (0) + +#define QEMU_ADD_IOTHREAD_PARAM_ULL(record, maxparams, id, name, value) \ +do { \ + char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \ + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \ + "iothread.%u.%s", id, name); \ + if (virTypedParamsAddULLong(&(record)->params, \ + &(record)->nparams, \ + maxparams, \ + param_name, \ + value) < 0) \ + goto cleanup; \ +} while (0) + +static int +qemuDomainGetStatsIOThread(virQEMUDriverPtr driver, + virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams, + unsigned int privflags ATTRIBUTE_UNUSED) +{ + size_t i; + qemuMonitorIOThreadInfoPtr *iothreads =3D NULL; + int niothreads; + int ret =3D -1; + + if (!virDomainObjIsActive(dom)) + return 0; + + if ((niothreads =3D qemuDomainGetIOThreadsMon(driver, dom, &iothreads)= ) < 0) + return -1; + + if (niothreads =3D=3D 0) + return 0; + + QEMU_ADD_COUNT_PARAM(record, maxparams, "iothread", niothreads); + + for (i =3D 0; i < niothreads; i++) { + if (iothreads[i]->poll_valid) { + QEMU_ADD_IOTHREAD_PARAM_ULL(record, maxparams, + iothreads[i]->iothread_id, + "poll-max-ns", + iothreads[i]->poll_max_ns); + QEMU_ADD_IOTHREAD_PARAM_UI(record, maxparams, + iothreads[i]->iothread_id, + "poll-grow", + iothreads[i]->poll_grow); + QEMU_ADD_IOTHREAD_PARAM_UI(record, maxparams, + iothreads[i]->iothread_id, + "poll-shrink", + iothreads[i]->poll_shrink); + } + } + + ret =3D 0; + + cleanup: + for (i =3D 0; i < niothreads; i++) + VIR_FREE(iothreads[i]); + VIR_FREE(iothreads); + + return ret; +} + +#undef QEMU_ADD_IOTHREAD_PARAM_UI + +#undef QEMU_ADD_IOTHREAD_PARAM_ULL + #undef QEMU_ADD_COUNT_PARAM =20 static int @@ -20511,6 +20591,7 @@ static struct qemuDomainGetStatsWorker qemuDomainGe= tStatsWorkers[] =3D { { qemuDomainGetStatsInterface, VIR_DOMAIN_STATS_INTERFACE, false }, { qemuDomainGetStatsBlock, VIR_DOMAIN_STATS_BLOCK, true }, { qemuDomainGetStatsPerf, VIR_DOMAIN_STATS_PERF, false }, + { qemuDomainGetStatsIOThread, VIR_DOMAIN_STATS_IOTHREAD, true }, { NULL, 0, false } }; =20 --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541423002795552.4341762373094; Mon, 5 Nov 2018 05:03:22 -0800 (PST) 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 E58D937E60; Mon, 5 Nov 2018 13:03:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76612450D; Mon, 5 Nov 2018 13:03:20 +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 1BCEE4CAA0; Mon, 5 Nov 2018 13:03:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwOeU004294 for ; Mon, 5 Nov 2018 07:58:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 77D772638F; Mon, 5 Nov 2018 12:58:24 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3340C18522 for ; Mon, 5 Nov 2018 12:58:24 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:08 -0500 Message-Id: <20181105125816.20385-5-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 04/12] virsh: Add ability to display IOThread stats 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.29]); Mon, 05 Nov 2018 13:03:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add an --iothread qualifier to domstats and an explanation in the man page. Describe the values in as generic terms as possible allowing each hypervisor to provide a specific algorithm to utilize the values as it sees fit. Signed-off-by: John Ferlan ACKed-by: Michal Privoznik Acked-by: Christian Borntraeger --- tools/virsh-domain-monitor.c | 7 +++++++ tools/virsh.pod | 26 ++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 3a2636377d..5187c1e248 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2066,6 +2066,10 @@ static const vshCmdOptDef opts_domstats[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("report domain perf event statistics"), }, + {.name =3D "iothread", + .type =3D VSH_OT_BOOL, + .help =3D N_("report domain IOThread information"), + }, {.name =3D "list-active", .type =3D VSH_OT_BOOL, .help =3D N_("list only active domains"), @@ -2179,6 +2183,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "perf")) stats |=3D VIR_DOMAIN_STATS_PERF; =20 + if (vshCommandOptBool(cmd, "iothread")) + stats |=3D VIR_DOMAIN_STATS_IOTHREAD; + if (vshCommandOptBool(cmd, "list-active")) flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE; =20 diff --git a/tools/virsh.pod b/tools/virsh.pod index 86c041d575..90f3c1ef5c 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -975,7 +975,8 @@ or unique source names printed by this command. =20 =3Ditem B [I<--raw>] [I<--enforce>] [I<--backing>] [I<--nowait>] [I<--state>] [I<--cpu-total>] [I<--balloon>] [I<--vcpu>] [I<--interface>] -[I<--block>] [I<--perf>] [[I<--list-active>] [I<--list-inactive>] +[I<--block>] [I<--perf>] [I<--iothread>] +[[I<--list-active>] [I<--list-inactive>] [I<--list-persistent>] [I<--list-transient>] [I<--list-running>] [I<--list-paused>] [I<--list-shutoff>] [I<--list-other>]] | [I ...] =20 @@ -993,7 +994,7 @@ behavior use the I<--raw> flag. The individual statistics groups are selectable via specific flags. By default all supported statistics groups are returned. Supported statistics groups flags are: I<--state>, I<--cpu-total>, I<--balloon>, -I<--vcpu>, I<--interface>, I<--block>, I<--perf>. +I<--vcpu>, I<--interface>, I<--block>, I<--perf>, I<--iothread>. =20 Note that - depending on the hypervisor type and version or the domain sta= te - not all of the following statistics may be returned. @@ -1126,6 +1127,27 @@ Information listed includes: VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD event See domblkthreshold. =20 +I<--iothread> returns information about IOThreads on the running guest +if supported by the hypervisor. + +The "poll-max-ns" for each thread is the maximum nanoseconds to allow +each polling interval to occur. A polling interval is a period of time +allowed for a thread to process data before being the guest gives up +its CPU quantum back to the host. A value set too small will not allow +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. The polling interval is +not available for statistical purposes. + + "iothread..poll-max-ns" - maximum polling time in nanoseconds used + by the IOThread. A value of 0 (zero) + indicates polling is disabled. + "iothread..poll-grow" - polling time grow value. A value of 0 (zero) + indicates growth is managed by the hypervisor. + "iothread..poll-shrink" - polling time shrink value. A value of + 0 (zero) indicates shrink is managed by + the hypervisor. + Selecting a specific statistics groups doesn't guarantee that the daemon supports the selected group of stats. Flag I<--enforce> forces the command to fail if the daemon doesn't support the --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541422926512873.8946685147446; Mon, 5 Nov 2018 05:02:06 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8869258E26; Mon, 5 Nov 2018 13:02:03 +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 26B16105707A; Mon, 5 Nov 2018 13:02:03 +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 62EDF180B5B7; Mon, 5 Nov 2018 13:02:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwW7S004321 for ; Mon, 5 Nov 2018 07:58:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id CBC51450D; Mon, 5 Nov 2018 12:58:32 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 841EE26344 for ; Mon, 5 Nov 2018 12:58:24 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:09 -0500 Message-Id: <20181105125816.20385-6-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 05/12] lib: Introduce virDomainSetIOThreadParams 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 05 Nov 2018 13:02:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Create a new API that will allow an adjustment of IOThread polling parameters for the specified IOThread. These parameters will not be saved in the guest XML. Currently the only parameters supported will allow the hypervisor to adjust the parameters used to limit and alter the scope of the polling interval. The polling interval allows the IOThread to spend more or less time processing in the guest. Based on code originally posted by Pavel Hrdina to add virDomainAddIOThreadParams and virDomainModIOThreadParams. Modification of those changes to use virDomainSetIOThreadParams instead and remove concepts related to saving the data in guest XML as well as the way to specifically enable the polling parameters. Signed-off-by: John Ferlan ACKed-by: Michal Privoznik Acked-by: Christian Borntraeger --- include/libvirt/libvirt-domain.h | 44 ++++++++++++++++++++ src/driver-hypervisor.h | 8 ++++ src/libvirt-domain.c | 70 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 21 +++++++++- src/remote_protocol-structs | 10 +++++ 7 files changed, 158 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 58fd4bc10c..bf89d0149f 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1911,6 +1911,50 @@ int virDomainDelIOThread(virDomainP= tr domain, unsigned int iothread_id, unsigned int flags); =20 +/* IOThread set parameters */ + +/** + * VIR_DOMAIN_IOTHREAD_POLL_MAX_NS: + * + * The maximum polling time that can be used by polling algorithm in ns. + * The polling time starts at 0 (zero) and is the time spent by the guest + * to process IOThread data before returning the CPU to the host. The + * polling time will be dynamically modified over time based on the + * poll_grow and poll_shrink parameters provided. A value set too large + * will cause more CPU time to be allocated the guest. A value set too + * small will not provide enough cycles for the guest to process data. + * The polling interval is not available for statistical purposes. + */ +# define VIR_DOMAIN_IOTHREAD_POLL_MAX_NS "poll_max_ns" + +/** + * VIR_DOMAIN_IOTHREAD_POLL_GROW: + * + * This provides a value for the dynamic polling adjustment algorithm to + * use to grow its polling interval up to the poll_max_ns value. A value + * of 0 (zero) allows the hypervisor to choose its own value. The algorithm + * to use for adjustment is hypervisor specific. + */ +# define VIR_DOMAIN_IOTHREAD_POLL_GROW "poll_grow" + +/** + * VIR_DOMAIN_IOTHREAD_POLL_SHRINK: + * + * This provides a value for the dynamic polling adjustment algorithm to + * use to shrink its polling interval when the polling interval exceeds + * the poll_max_ns value. A value of 0 (zero) allows the hypervisor to + * choose its own value. The algorithm to use for adjustment is hypervisor + * specific. + */ +# define VIR_DOMAIN_IOTHREAD_POLL_SHRINK "poll_shrink" + +int virDomainSetIOThreadParams(virDomainPtr domain, + unsigned int iothread_id, + virTypedParameterPtr param= s, + int nparams, + unsigned int flags); + + /** * VIR_USE_CPU: * @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN/OUT) diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index eef31eb1f0..6be3e175ce 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -406,6 +406,13 @@ typedef int unsigned int iothread_id, unsigned int flags); =20 +typedef int +(*virDrvDomainSetIOThreadParams)(virDomainPtr domain, + unsigned int iothread_id, + virTypedParameterPtr params, + int nparams, + unsigned int flags); + typedef int (*virDrvDomainGetSecurityLabel)(virDomainPtr domain, virSecurityLabelPtr seclabel); @@ -1407,6 +1414,7 @@ struct _virHypervisorDriver { virDrvDomainPinIOThread domainPinIOThread; virDrvDomainAddIOThread domainAddIOThread; virDrvDomainDelIOThread domainDelIOThread; + virDrvDomainSetIOThreadParams domainSetIOThreadParams; virDrvDomainGetSecurityLabel domainGetSecurityLabel; virDrvDomainGetSecurityLabelList domainGetSecurityLabelList; virDrvNodeGetSecurityModel nodeGetSecurityModel; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 9fda56d660..5b76458f11 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -7812,6 +7812,76 @@ virDomainDelIOThread(virDomainPtr domain, } =20 =20 +/** + * virDomainSetIOThreadParams: + * @domain: a domain object + * @iothread_id: the specific IOThread ID value to add + * @params: pointer to IOThread parameter objects + * @nparams: number of IOThread parameters + * @flags: bitwise-OR of virDomainModificationImpact and virTypedParameter= Flags + * + * Dynamically set IOThread parameters to the domain. It is left up to + * the underlying virtual hypervisor to determine the valid range for an + * @iothread_id, determining whether the @iothread_id already exists, and + * determining the validity of the provided param values. + * + * See VIR_DOMAIN_IOTHREAD_* for detailed description of accepted IOThread + * parameters. + * + * Since the purpose of this API is to dynamically modify the IOThread + * @flags should only include the VIR_DOMAIN_AFFECT_CURRENT and/or + * VIR_DOMAIN_AFFECT_LIVE virDomainMemoryModFlags. Setting other flags + * may cause errors from the hypervisor. + * + * Note that this call can fail if the underlying virtualization hypervisor + * does not support it or does not support setting the provided values. + * + * This function requires privileged access to the hypervisor. + * + * Returns 0 in case of success, -1 in case of failure. + */ +int +virDomainSetIOThreadParams(virDomainPtr domain, + unsigned int iothread_id, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "iothread_id=3D%u, params=3D%p, nparams=3D%d,= flags=3D0x%x", + iothread_id, params, nparams, flags); + VIR_TYPED_PARAMS_DEBUG(params, nparams); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + virCheckNonNullArgGoto(params, error); + virCheckPositiveArgGoto(nparams, error); + + if (virTypedParameterValidateSet(conn, params, nparams) < 0) + goto error; + + if (conn->driver->domainSetIOThreadParams) { + int ret; + ret =3D conn->driver->domainSetIOThreadParams(domain, iothread_id, + params, nparams, flags= ); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} + + /** * virDomainGetSecurityLabel: * @domain: a domain object diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index d4cdbd8b32..042b4df043 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -809,4 +809,9 @@ LIBVIRT_4.5.0 { virNWFilterBindingGetFilterName; } LIBVIRT_4.4.0; =20 +LIBVIRT_4.10.0 { + global: + virDomainSetIOThreadParams; +} LIBVIRT_4.5.0; + # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 3b43e219e5..dc61391553 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8371,6 +8371,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainPinIOThread =3D remoteDomainPinIOThread, /* 1.2.14 */ .domainAddIOThread =3D remoteDomainAddIOThread, /* 1.2.15 */ .domainDelIOThread =3D remoteDomainDelIOThread, /* 1.2.15 */ + .domainSetIOThreadParams =3D remoteDomainSetIOThreadParams, /* 4.10.0 = */ .domainGetSecurityLabel =3D remoteDomainGetSecurityLabel, /* 0.6.1 */ .domainGetSecurityLabelList =3D remoteDomainGetSecurityLabelList, /* 0= .10.0 */ .nodeGetSecurityModel =3D remoteNodeGetSecurityModel, /* 0.6.1 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 28c8febabd..7630b2ed15 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -256,6 +256,9 @@ const REMOTE_DOMAIN_IP_ADDR_MAX =3D 2048; /* Upper limit on number of guest vcpu information entries */ const REMOTE_DOMAIN_GUEST_VCPU_PARAMS_MAX =3D 64; =20 +/* Upper limit on number of IOThread parameter set entries */ +const REMOTE_DOMAIN_IOTHREAD_PARAMS_MAX =3D 64; + /* Upper limit on number of SEV parameters */ const REMOTE_NODE_SEV_INFO_MAX =3D 64; =20 @@ -1249,6 +1252,13 @@ struct remote_domain_del_iothread_args { unsigned int flags; }; =20 +struct remote_domain_set_iothread_params_args { + remote_nonnull_domain dom; + unsigned int iothread_id; + remote_typed_param params; + unsigned int flags; +}; + struct remote_domain_get_security_label_args { remote_nonnull_domain dom; }; @@ -6312,5 +6322,14 @@ enum remote_procedure { * @acl: connect:search_nwfilter_bindings * @aclfilter: nwfilter_binding:getattr */ - REMOTE_PROC_CONNECT_LIST_ALL_NWFILTER_BINDINGS =3D 401 + REMOTE_PROC_CONNECT_LIST_ALL_NWFILTER_BINDINGS =3D 401, + + /** + * @generate: both + * @acl: domain:write + * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE + * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG + */ + REMOTE_PROC_DOMAIN_SET_IOTHREAD_PARAMS =3D 402 + }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 6343e14638..7c27c63542 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -866,6 +866,15 @@ struct remote_domain_del_iothread_args { u_int iothread_id; u_int flags; }; +struct remote_domain_set_iothread_params_args { + remote_nonnull_domain dom; + u_int iothread_id; + struct { + u_int params_len; + remote_typed_param * params_val; + } params; + u_int flags; +}; struct remote_domain_get_security_label_args { remote_nonnull_domain dom; }; @@ -3368,4 +3377,5 @@ enum remote_procedure { REMOTE_PROC_NWFILTER_BINDING_CREATE_XML =3D 399, REMOTE_PROC_NWFILTER_BINDING_DELETE =3D 400, REMOTE_PROC_CONNECT_LIST_ALL_NWFILTER_BINDINGS =3D 401, + REMOTE_PROC_DOMAIN_SET_IOTHREAD_PARAMS =3D 402, }; --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541423132419509.2902077808966; Mon, 5 Nov 2018 05:05:32 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9195F52748; Mon, 5 Nov 2018 13:05: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 4F7DF17D19; Mon, 5 Nov 2018 13:05: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 C809E180B5B7; Mon, 5 Nov 2018 13:05:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwX0x004326 for ; Mon, 5 Nov 2018 07:58:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4266D450D; Mon, 5 Nov 2018 12:58:33 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3CD726344 for ; Mon, 5 Nov 2018 12:58:32 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:10 -0500 Message-Id: <20181105125816.20385-7-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 06/12] qemu: Add monitor functions to set IOThread params 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 05 Nov 2018 13:05:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add functions to set the IOThreadInfo param data for the live guest. Modify the _qemuMonitorIOThreadInfo to have a flag to indicate when a value was set so that we don't set a value unless it was desired to be set. Based on code originally posted by Pavel Hrdina , but extracted into a separate patch. Note that qapi expects to receive integer parameters rather than unsigned long long or unsigned int's. QEMU does save the value in larger signed 64 bit values eventually. Signed-off-by: John Ferlan Acked-by: Christian Borntraeger --- src/qemu/qemu_monitor.c | 19 +++++++++++++++++++ src/qemu/qemu_monitor.h | 5 +++++ src/qemu/qemu_monitor_json.c | 35 +++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ 4 files changed, 63 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7f7013e115..a65d638ab8 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4135,6 +4135,25 @@ qemuMonitorGetIOThreads(qemuMonitorPtr mon, } =20 =20 +/** + * qemuMonitorSetIOThread: + * @mon: Pointer to the monitor + * @iothreadInfo: filled IOThread info with data + * + * Alter the specified IOThread's IOThreadInfo values. + */ +int +qemuMonitorSetIOThread(qemuMonitorPtr mon, + qemuMonitorIOThreadInfoPtr iothreadInfo) +{ + VIR_DEBUG("iothread=3D%p", iothreadInfo); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONSetIOThread(mon, iothreadInfo); +} + + /** * qemuMonitorGetMemoryDeviceInfo: * @mon: pointer to the monitor diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c2991e2b16..66bfdb0e5c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1120,9 +1120,14 @@ struct _qemuMonitorIOThreadInfo { unsigned long long poll_max_ns; unsigned int poll_grow; unsigned int poll_shrink; + bool set_poll_max_ns; + bool set_poll_grow; + bool set_poll_shrink; }; int qemuMonitorGetIOThreads(qemuMonitorPtr mon, qemuMonitorIOThreadInfoPtr **iothreads); +int qemuMonitorSetIOThread(qemuMonitorPtr mon, + qemuMonitorIOThreadInfoPtr iothreadInfo); =20 typedef struct _qemuMonitorMemoryDeviceInfo qemuMonitorMemoryDeviceInfo; typedef qemuMonitorMemoryDeviceInfo *qemuMonitorMemoryDeviceInfoPtr; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 2e92984b44..5a806f6c0e 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7474,6 +7474,41 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon, } =20 =20 +int +qemuMonitorJSONSetIOThread(qemuMonitorPtr mon, + qemuMonitorIOThreadInfoPtr iothreadInfo) +{ + int ret =3D -1; + char *path =3D NULL; + qemuMonitorJSONObjectProperty prop; + + if (virAsprintf(&path, "/objects/iothread%u", + iothreadInfo->iothread_id) < 0) + goto cleanup; + +#define VIR_IOTHREAD_SET_PROP(propName, propVal) \ + if (iothreadInfo->set_##propVal) { \ + memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); \ + prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_INT; \ + prop.val.iv =3D iothreadInfo->propVal; \ + if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) <= 0) \ + goto cleanup; \ + } + + VIR_IOTHREAD_SET_PROP("poll-max-ns", poll_max_ns); + VIR_IOTHREAD_SET_PROP("poll-grow", poll_grow); + VIR_IOTHREAD_SET_PROP("poll-shrink", poll_shrink); + +#undef VIR_IOTHREAD_SET_PROP + + ret =3D 0; + + cleanup: + VIR_FREE(path); + return ret; +} + + int qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon, virHashTablePtr info) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index da267b15b0..c3abd0ddf0 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -502,6 +502,10 @@ int qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon, qemuMonitorIOThreadInfoPtr **iothreads) ATTRIBUTE_NONNULL(2); =20 +int qemuMonitorJSONSetIOThread(qemuMonitorPtr mon, + qemuMonitorIOThreadInfoPtr iothreadInfo) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon, virHashTablePtr info) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541423145249282.51471667740293; Mon, 5 Nov 2018 05:05:45 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 505E881DE3; Mon, 5 Nov 2018 13:05:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 130B2608E7; Mon, 5 Nov 2018 13:05:43 +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 777123D380; Mon, 5 Nov 2018 13:05:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwXoC004334 for ; Mon, 5 Nov 2018 07:58:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id AA88716D45; Mon, 5 Nov 2018 12:58:33 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69E27450D for ; Mon, 5 Nov 2018 12:58:33 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:11 -0500 Message-Id: <20181105125816.20385-8-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 07/12] qemu: Alter qemuDomainChgIOThread to take enum instead of bool 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 05 Nov 2018 13:05:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We're about to add a new state "modify" and thus the function goes from just Add/Del. Use an enum to manage. Extracted from code originally posted by Pavel Hrdina , but placed into a separate patch. Signed-off-by: John Ferlan ACKed-by: Michal Privoznik Acked-by: Christian Borntraeger --- src/qemu/qemu_driver.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b50d805bf1..6835d3e875 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6018,11 +6018,16 @@ qemuDomainDelIOThreadCheck(virDomainDefPtr def, return 0; } =20 +typedef enum { + VIR_DOMAIN_IOTHREAD_ACTION_ADD, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, +} virDomainIOThreadAction; + static int qemuDomainChgIOThread(virQEMUDriverPtr driver, virDomainObjPtr vm, unsigned int iothread_id, - bool add, + virDomainIOThreadAction action, unsigned int flags) { virQEMUDriverConfigPtr cfg =3D NULL; @@ -6048,18 +6053,24 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, goto endjob; } =20 - if (add) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: if (qemuDomainAddIOThreadCheck(def, iothread_id) < 0) goto endjob; =20 if (qemuDomainHotplugAddIOThread(driver, vm, iothread_id) < 0) goto endjob; - } else { + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: if (qemuDomainDelIOThreadCheck(def, iothread_id) < 0) goto endjob; =20 if (qemuDomainHotplugDelIOThread(driver, vm, iothread_id) < 0) goto endjob; + + break; } =20 if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) @@ -6067,18 +6078,23 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, } =20 if (persistentDef) { - if (add) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: if (qemuDomainAddIOThreadCheck(persistentDef, iothread_id) < 0) goto endjob; =20 if (!virDomainIOThreadIDAdd(persistentDef, iothread_id)) goto endjob; =20 - } else { + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: if (qemuDomainDelIOThreadCheck(persistentDef, iothread_id) < 0) goto endjob; =20 virDomainIOThreadIDDel(persistentDef, iothread_id); + + break; } =20 if (virDomainSaveConfig(cfg->configDir, driver->caps, @@ -6120,7 +6136,8 @@ qemuDomainAddIOThread(virDomainPtr dom, if (virDomainAddIOThreadEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, true, flags); + ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, + VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags); =20 cleanup: virDomainObjEndAPI(&vm); @@ -6152,7 +6169,8 @@ 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_id, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541423156575435.78295625375745; Mon, 5 Nov 2018 05:05:56 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84A4B86671; Mon, 5 Nov 2018 13:05:54 +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 4126165F6A; Mon, 5 Nov 2018 13:05:54 +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 BE63D180B61F; Mon, 5 Nov 2018 13:05:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwYYG004344 for ; Mon, 5 Nov 2018 07:58:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1F2C1450D; Mon, 5 Nov 2018 12:58:34 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id D038518522 for ; Mon, 5 Nov 2018 12:58:33 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:12 -0500 Message-Id: <20181105125816.20385-9-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 08/12] qemu: Alter qemuDomainChgIOThread to take qemuMonitorIOThreadInfo 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 05 Nov 2018 13:05:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rather than passing an iothread_id, let's pass a qemuMonitorIOThreadInfo structure so that a subsequent change to modify the iothread info can just generate and pass one. Signed-off-by: John Ferlan ACKed-by: Michal Privoznik Acked-by: Christian Borntraeger --- src/qemu/qemu_driver.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6835d3e875..4ddca2f765 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6026,7 +6026,7 @@ typedef enum { static int qemuDomainChgIOThread(virQEMUDriverPtr driver, virDomainObjPtr vm, - unsigned int iothread_id, + qemuMonitorIOThreadInfo iothread, virDomainIOThreadAction action, unsigned int flags) { @@ -6055,19 +6055,19 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, =20 switch (action) { case VIR_DOMAIN_IOTHREAD_ACTION_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.iothread= _id) < 0) goto endjob; =20 break; =20 case VIR_DOMAIN_IOTHREAD_ACTION_DEL: - 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 break; @@ -6080,19 +6080,19 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, if (persistentDef) { switch (action) { case VIR_DOMAIN_IOTHREAD_ACTION_ADD: - if (qemuDomainAddIOThreadCheck(persistentDef, iothread_id) < 0) + if (qemuDomainAddIOThreadCheck(persistentDef, iothread.iothrea= d_id) < 0) goto endjob; =20 - if (!virDomainIOThreadIDAdd(persistentDef, iothread_id)) + if (!virDomainIOThreadIDAdd(persistentDef, iothread.iothread_i= d)) goto endjob; =20 break; =20 case VIR_DOMAIN_IOTHREAD_ACTION_DEL: - if (qemuDomainDelIOThreadCheck(persistentDef, iothread_id) < 0) + if (qemuDomainDelIOThreadCheck(persistentDef, iothread.iothrea= d_id) < 0) goto endjob; =20 - virDomainIOThreadIDDel(persistentDef, iothread_id); + virDomainIOThreadIDDel(persistentDef, iothread.iothread_id); =20 break; } @@ -6119,6 +6119,7 @@ qemuDomainAddIOThread(virDomainPtr dom, { virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm =3D NULL; + qemuMonitorIOThreadInfo iothread =3D {0}; int ret =3D -1; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -6136,7 +6137,8 @@ qemuDomainAddIOThread(virDomainPtr dom, if (virDomainAddIOThreadEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, + iothread.iothread_id =3D iothread_id; + ret =3D qemuDomainChgIOThread(driver, vm, iothread, VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags); =20 cleanup: @@ -6152,6 +6154,7 @@ qemuDomainDelIOThread(virDomainPtr dom, { virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm =3D NULL; + qemuMonitorIOThreadInfo iothread =3D {0}; int ret =3D -1; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -6169,7 +6172,8 @@ qemuDomainDelIOThread(virDomainPtr dom, if (virDomainDelIOThreadEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, + iothread.iothread_id =3D iothread_id; + ret =3D qemuDomainChgIOThread(driver, vm, iothread, VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags); =20 cleanup: --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541423017573614.5835625433409; Mon, 5 Nov 2018 05:03:37 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6788C308A972; Mon, 5 Nov 2018 13:03:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 273BD600D7; Mon, 5 Nov 2018 13:03:35 +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 BD8A94CAA0; Mon, 5 Nov 2018 13:03:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwY2V004355 for ; Mon, 5 Nov 2018 07:58:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 88A052638F; Mon, 5 Nov 2018 12:58:34 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44D6D26344 for ; Mon, 5 Nov 2018 12:58:34 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:13 -0500 Message-Id: <20181105125816.20385-10-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 09/12] qemu: Detect whether iothread polling is supported 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 05 Nov 2018 13:03:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add a capability check for IOThread polling (all were added at the same time, so only one check is necessary). Based on code originally posted by Pavel Hrdina with the only changes to include the more recent QEMU releases. Signed-off-by: John Ferlan ACKed-by: Michal Privoznik Acked-by: Christian Borntraeger --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml | 1 + 20 files changed, 21 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2ca5af3297..4fdb0e66a5 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -509,6 +509,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "vfio-pci.display", "blockdev", "vfio-ap", + "iothread.poll-max-ns", ); =20 =20 @@ -1239,6 +1240,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSc= hemaQueries[] =3D { { "nbd-server-start/arg-type/tls-creds", QEMU_CAPS_NBD_TLS }, { "screendump/arg-type/device", QEMU_CAPS_SCREENDUMP_DEVICE }, { "block-commit/arg-type/*top", QEMU_CAPS_ACTIVE_COMMIT }, + { "query-iothreads/ret-type/poll-max-ns", QEMU_CAPS_IOTHREAD_POLLING }, }; =20 typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6bb9a2c8f0..f53288bc81 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -493,6 +493,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_VFIO_PCI_DISPLAY, /* -device vfio-pci.display */ QEMU_CAPS_BLOCKDEV, /* -blockdev and blockdev-add are supported */ QEMU_CAPS_DEVICE_VFIO_AP, /* -device vfio-ap */ + QEMU_CAPS_IOTHREAD_POLLING, /* -object iothread.poll-max-ns */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml b/tests/qem= ucapabilitiesdata/caps_2.10.0.aarch64.xml index b9c4182a66..7061ba8f7e 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml @@ -151,6 +151,7 @@ + 2010000 0 305067 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemuc= apabilitiesdata/caps_2.10.0.ppc64.xml index 66b25601e7..2a48b63efe 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml @@ -150,6 +150,7 @@ + 2010000 0 384412 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.10.0.s390x.xml index e000aac384..c35e014b32 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml @@ -113,6 +113,7 @@ + 2010000 0 306247 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.10.0.x86_64.xml index ebc5e771d9..a8d787f99a 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml @@ -192,6 +192,7 @@ + 2010000 0 364386 diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.11.0.s390x.xml index 4eb8a39d94..6ee53a1f21 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -120,6 +120,7 @@ + 2011000 0 345099 diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.11.0.x86_64.xml index 857a9a9f9a..4ba2a82b60 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml @@ -198,6 +198,7 @@ + 2011000 0 368875 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qem= ucapabilitiesdata/caps_2.12.0.aarch64.xml index 7bf1fab8cb..c7e62d3723 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml @@ -162,6 +162,7 @@ + 2011090 0 344910 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.ppc64.xml index 8b8d8859c1..391c83eaaa 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml @@ -160,6 +160,7 @@ + 2011090 0 425694 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.s390x.xml index 79320d5229..1e09f24c31 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -128,6 +128,7 @@ + 2012000 0 374287 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.12.0.x86_64.xml index fcf94ab720..407c6e63cc 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -203,6 +203,7 @@ + 2011090 0 413556 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_2.9.0.ppc64.xml index f97ebdb9d4..d9ca8f3d2b 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml @@ -142,6 +142,7 @@ + 2009000 0 349056 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.9.0.s390x.xml index 5a4371ab83..a789403ca6 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml @@ -107,6 +107,7 @@ + 2009000 0 267973 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.9.0.x86_64.xml index 7bf31d9fd5..3c26b381da 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -186,6 +186,7 @@ + 2009000 0 340375 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_3.0.0.ppc64.xml index a1e2ae6556..6aad2e0feb 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml @@ -160,6 +160,7 @@ + 2012050 0 444131 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml b/tests/qemu= capabilitiesdata/caps_3.0.0.riscv32.xml index 254a4cf3d8..231213ae3a 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml @@ -100,6 +100,7 @@ + 3000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml b/tests/qemu= capabilitiesdata/caps_3.0.0.riscv64.xml index e7ab79e006..1722876dcc 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml @@ -100,6 +100,7 @@ + 3000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_3.0.0.s390x.xml index 3b5f9818a5..b77e95510f 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml @@ -130,6 +130,7 @@ + 3000000 0 387601 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_3.0.0.x86_64.xml index 7ceea6b738..acfb1d45d2 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml @@ -205,6 +205,7 @@ + 3000000 0 425157 --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541423168799725.9841508400452; Mon, 5 Nov 2018 05:06:08 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE799307DAAC; Mon, 5 Nov 2018 13:06:06 +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 8F9A1608F3; Mon, 5 Nov 2018 13:06:06 +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 26CFD18005B6; Mon, 5 Nov 2018 13:06:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwYwh004362 for ; Mon, 5 Nov 2018 07:58:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE27926E64; Mon, 5 Nov 2018 12:58:34 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC6112657F for ; Mon, 5 Nov 2018 12:58:34 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:14 -0500 Message-Id: <20181105125816.20385-11-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 10/12] 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 05 Nov 2018 13:06:07 +0000 (UTC) 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 Acked-by: Christian Borntraeger --- src/qemu/qemu_driver.c | 201 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4ddca2f765..61b1ce717c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5902,6 +5902,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, @@ -6018,9 +6047,106 @@ 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) +{ + int rc; + + 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 ((rc =3D virTypedParamsGetULLong(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, + &iothread->poll_max_ns)) < 0) + return -1; + if (rc =3D=3D 1) + iothread->set_poll_max_ns =3D true; + + if ((rc =3D virTypedParamsGetUInt(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_GROW, + &iothread->poll_grow)) < 0) + return -1; + if (rc =3D=3D 1) + iothread->set_poll_grow =3D true; + + if ((rc =3D virTypedParamsGetUInt(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_SHRINK, + &iothread->poll_shrink)) < 0) + return -1; + if (rc =3D=3D 1) + iothread->set_poll_shrink =3D true; + + if (iothread->set_poll_max_ns && 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->set_poll_grow && 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->set_poll_shrink && 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; + } + + return 0; +} + + typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, VIR_DOMAIN_IOTHREAD_ACTION_DEL, + VIR_DOMAIN_IOTHREAD_ACTION_MOD, } virDomainIOThreadAction; =20 static int @@ -6071,6 +6197,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) @@ -6094,6 +6234,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 @@ -6181,6 +6329,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; @@ -21964,6 +22164,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.10.0 */ .domainGetSecurityLabel =3D qemuDomainGetSecurityLabel, /* 0.6.1 */ .domainGetSecurityLabelList =3D qemuDomainGetSecurityLabelList, /* 0.1= 0.0 */ .nodeGetSecurityModel =3D qemuNodeGetSecurityModel, /* 0.6.1 */ --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541422940923270.60502860362806; Mon, 5 Nov 2018 05:02:20 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C943307D845; Mon, 5 Nov 2018 13:02:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26783600C5; Mon, 5 Nov 2018 13:02:18 +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 ADC324CAA0; Mon, 5 Nov 2018 13:02:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwZN2004367 for ; Mon, 5 Nov 2018 07:58:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id BADCD450D; Mon, 5 Nov 2018 12:58:35 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78E89194B4 for ; Mon, 5 Nov 2018 12:58:35 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:15 -0500 Message-Id: <20181105125816.20385-12-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 11/12] tools: Add virsh iothreadset command 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 05 Nov 2018 13:02:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add a command to allow for setting various dynamic IOThread polling interval scope (poll-max-ns, poll-grow, and poll-shrink). Describe the values in the virsh.pod in as generic terms as possible. The more specific QEMU algorithm has been divulged in the previous patch. Based heavily on code originally posted by Pavel Hrdina , but altered to only provide one command and to not managed a poll disabled state. Signed-off-by: John Ferlan Acked-by: Christian Borntraeger --- tools/virsh-domain.c | 110 +++++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 21 +++++++++ 2 files changed, 131 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 372bdb95d3..4ee6ddf956 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7734,6 +7734,110 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd) return ret; } =20 + + /* + * "iothreadset" command + */ +static const vshCmdInfo info_iothreadset[] =3D { + {.name =3D "help", + .data =3D N_("modifies an existing IOThread of the guest domain") + }, + {.name =3D "desc", + .data =3D N_("Modifies an existing IOThread of the guest domain.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_iothreadset[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name =3D "id", + .type =3D VSH_OT_INT, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("iothread id of existing IOThread") + }, + {.name =3D "poll-max-ns", + .type =3D VSH_OT_INT, + .help =3D N_("set the maximum IOThread polling time in ns") + }, + {.name =3D "poll-grow", + .type =3D VSH_OT_INT, + .help =3D N_("set the value to increase the IOThread polling time") + }, + {.name =3D "poll-shrink", + .type =3D VSH_OT_INT, + .help =3D N_("set the value for reduction of the IOThread polling tim= e ") + }, + VIRSH_COMMON_OPT_DOMAIN_LIVE, + VIRSH_COMMON_OPT_DOMAIN_CURRENT, + {.name =3D NULL} +}; + +static bool +cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom; + int id =3D 0; + bool ret =3D false; + bool live =3D vshCommandOptBool(cmd, "live"); + unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; + virTypedParameterPtr params =3D NULL; + int nparams =3D 0; + int maxparams =3D 0; + unsigned long long poll_max; + unsigned int poll_val; + int rc; + + if (live) + flags |=3D VIR_DOMAIN_AFFECT_LIVE; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (vshCommandOptInt(ctl, cmd, "id", &id) < 0) + goto cleanup; + if (id <=3D 0) { + vshError(ctl, _("Invalid IOThread id value: '%d'"), id); + goto cleanup; + } + + poll_val =3D 0; + if ((rc =3D vshCommandOptULongLong(ctl, cmd, "poll-max-ns", &poll_max)= ) < 0) + goto cleanup; + if (rc > 0 && virTypedParamsAddULLong(¶ms, &nparams, &maxparams, + VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, + poll_max) < 0) + goto save_error; + +#define VSH_IOTHREAD_SET_UINT_PARAMS(opt, param) \ + poll_val =3D 0; \ + if ((rc =3D vshCommandOptUInt(ctl, cmd, opt, &poll_val)) < 0) \ + goto cleanup; \ + if (rc > 0 && \ + virTypedParamsAddUInt(¶ms, &nparams, &maxparams, \ + param, poll_val) < 0) \ + goto save_error; + + VSH_IOTHREAD_SET_UINT_PARAMS("poll-grow", VIR_DOMAIN_IOTHREAD_POLL_GRO= W) + VSH_IOTHREAD_SET_UINT_PARAMS("poll-shrink", VIR_DOMAIN_IOTHREAD_POLL_S= HRINK) + +#undef VSH_IOTHREAD_SET_UINT_PARAMS + + if (virDomainSetIOThreadParams(dom, id, params, nparams, flags) < 0) + goto cleanup; + + ret =3D true; + + cleanup: + virTypedParamsFree(params, nparams); + virshDomainFree(dom); + return ret; + + save_error: + vshSaveLibvirtError(); + goto cleanup; +} + + /* * "iothreaddel" command */ @@ -14149,6 +14253,12 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_iothreadadd, .flags =3D 0 }, + {.name =3D "iothreadset", + .handler =3D cmdIOThreadSet, + .opts =3D opts_iothreadset, + .info =3D info_iothreadset, + .flags =3D 0 + }, {.name =3D "iothreaddel", .handler =3D cmdIOThreadDel, .opts =3D opts_iothreaddel, diff --git a/tools/virsh.pod b/tools/virsh.pod index 90f3c1ef5c..48766567f8 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1732,6 +1732,27 @@ If I<--config> is specified, affect the next boot of= a persistent guest. If I<--current> is specified or I<--live> and I<--config> are not specifie= d, affect the current guest state. =20 +=3Ditem B I I +[[I<--poll-max-ns> B] [I<--poll-grow> B] +[I<--poll-shrink> B]] +[[I<--config>] [I<--live>] | [I<--current>]] + +Modifies an existing iothread of the domain using the specified +I. The I<--poll-max-ns> provides the maximum polling +interval to be allowed for an IOThread in ns. If a 0 (zero) is provided, +then polling for the IOThread is disabled. The I<--poll-grow> is the +factor by which the current polling time will be adjusted in order to +reach the maximum polling time. If a 0 (zero) is provided, then the +default factor will be used. The I<--poll-shrink> is the quotient +by which the current polling time will be reduced in order to get +below the maximum polling interval. If a 0 (zero) is provided, then +the default quotient will be used. + +If I<--live> is specified, affect a running guest. If the guest is not +running an error is returned. +If I<--current> is specified or I<--live> is not specified, then handle +as if I<--live> was specified. + =3Ditem B I I [[I<--config>] [I<--live>] | [I<--current>]] =20 --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 11:21:11 2024 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 1541422954005297.983383768738; Mon, 5 Nov 2018 05:02:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D9C9C02834E; Mon, 5 Nov 2018 13:02:31 +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 059EA65F4E; Mon, 5 Nov 2018 13:02:31 +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 77FE0180B5B7; Mon, 5 Nov 2018 13:02:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5Cwaok004372 for ; Mon, 5 Nov 2018 07:58:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 39292450D; Mon, 5 Nov 2018 12:58:36 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7591194B4 for ; Mon, 5 Nov 2018 12:58:35 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:16 -0500 Message-Id: <20181105125816.20385-13-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH v2 12/12] docs: Add news article for 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 05 Nov 2018 13:02:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Ferlan Acked-by: Christian Borntraeger --- docs/news.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 9d98c34df2..c7c101fd47 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -35,6 +35,19 @@
+ + + Support changing IOThread polling parameters for a live guest + + + Introduced virDomainSetIOThreadParams which allows dynamically + setting the IOThread polling parameters used by QEMU to manage + the thread polling interval and the algorithm for growth or + shrink of the polling time. The values only affect a running + guest with IOThreads. The guest's IOThread polling values can + be viewed via the domain statistics. + +
--=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list