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 <phrdina@xxxxxxxxxx>, but altered to only provide one command and to not managed a poll disabled state. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- 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; } + + /* + * "iothreadset" command + */ +static const vshCmdInfo info_iothreadset[] = { + {.name = "help", + .data = N_("modifies an existing IOThread of the guest domain") + }, + {.name = "desc", + .data = N_("Modifies an existing IOThread of the guest domain.") + }, + {.name = NULL} +}; + +static const vshCmdOptDef opts_iothreadset[] = { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name = "id", + .type = VSH_OT_INT, + .flags = VSH_OFLAG_REQ, + .help = N_("iothread id of existing IOThread") + }, + {.name = "poll-max-ns", + .type = VSH_OT_INT, + .help = N_("set the maximum IOThread polling time in ns") + }, + {.name = "poll-grow", + .type = VSH_OT_INT, + .help = N_("set the value to increase the IOThread polling time") + }, + {.name = "poll-shrink", + .type = VSH_OT_INT, + .help = N_("set the value for reduction of the IOThread polling time ") + }, + VIRSH_COMMON_OPT_DOMAIN_LIVE, + VIRSH_COMMON_OPT_DOMAIN_CURRENT, + {.name = NULL} +}; + +static bool +cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom; + int id = 0; + bool ret = false; + bool live = vshCommandOptBool(cmd, "live"); + unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; + virTypedParameterPtr params = NULL; + int nparams = 0; + int maxparams = 0; + unsigned long long poll_max; + unsigned int poll_val; + int rc; + + if (live) + flags |= VIR_DOMAIN_AFFECT_LIVE; + + if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (vshCommandOptInt(ctl, cmd, "id", &id) < 0) + goto cleanup; + if (id <= 0) { + vshError(ctl, _("Invalid IOThread id value: '%d'"), id); + goto cleanup; + } + + poll_val = 0; + if ((rc = 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 = 0; \ + if ((rc = 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_GROW) + VSH_IOTHREAD_SET_UINT_PARAMS("poll-shrink", VIR_DOMAIN_IOTHREAD_POLL_SHRINK) + +#undef VSH_IOTHREAD_SET_UINT_PARAMS + + if (virDomainSetIOThreadParams(dom, id, params, nparams, flags) < 0) + goto cleanup; + + ret = true; + + cleanup: + virTypedParamsFree(params, nparams); + virshDomainFree(dom); + return ret; + + save_error: + vshSaveLibvirtError(); + goto cleanup; +} + + /* * "iothreaddel" command */ @@ -14149,6 +14253,12 @@ const vshCmdDef domManagementCmds[] = { .info = info_iothreadadd, .flags = 0 }, + {.name = "iothreadset", + .handler = cmdIOThreadSet, + .opts = opts_iothreadset, + .info = info_iothreadset, + .flags = 0 + }, {.name = "iothreaddel", .handler = cmdIOThreadDel, .opts = 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 specified, affect the current guest state. +=item B<iothreadset> I<domain> I<iothread_id> +[[I<--poll-max-ns> B<ns>] [I<--poll-grow> B<factor>] +[I<--poll-shrink> B<divisor>]] +[[I<--config>] [I<--live>] | [I<--current>]] + +Modifies an existing iothread of the domain using the specified +I<iothread_id>. 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. + =item B<iothreaddel> I<domain> I<iothread_id> [[I<--config>] [I<--live>] | [I<--current>]] -- 2.17.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list