From nobody Mon Sep 16 19:21:10 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 --- 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