diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 372bdb95d3fc548b3af968845b707c85dd58a86b..4ee6ddf9561ad2a33419918a66af6dab1d400b0f 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 90f3c1ef5c1bf453091a585eeef75dabd2041619..48766567f8a38ac759f303ec2af3fae942b35bfa 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 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. + =item B I I [[I<--config>] [I<--live>] | [I<--current>]]