return niothreads >= 0;
}
+/*
+ * "iothreadpin" command
+ */
+static const vshCmdInfo info_iothreadpin[] = {
+ {.name = "help",
+ .data = N_("control domain IOThread affinity")
+ },
+ {.name = "desc",
+ .data = N_("Pin domain IOThreads to host physical CPUs.")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_iothreadpin[] = {
+ {.name = "domain",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("domain name, id or uuid")
+ },
+ {.name = "iothread",
+ .type = VSH_OT_INT,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("IOThread ID number")
+ },
+ {.name = "cpulist",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("host cpu number(s) to set")
+ },
+ {.name = "config",
+ .type = VSH_OT_BOOL,
+ .help = N_("affect next boot")
+ },
+ {.name = "live",
+ .type = VSH_OT_BOOL,
+ .help = N_("affect running domain")
+ },
+ {.name = "current",
+ .type = VSH_OT_BOOL,
+ .help = N_("affect current domain")
+ },
+ {.name = NULL}
+};
+
+static bool
+cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd)
+{
+ virDomainPtr dom;
+ const char *cpulist = NULL;
+ bool config = vshCommandOptBool(cmd, "config");
+ bool live = vshCommandOptBool(cmd, "live");
+ bool current = vshCommandOptBool(cmd, "current");
+ unsigned int iothread_id = 0;
+ int maxcpu;
+ bool ret = false;
+ unsigned char *cpumap = NULL;
+ size_t cpumaplen;
+ unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
+
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
+ if (config)
+ flags |= VIR_DOMAIN_AFFECT_CONFIG;
+ if (live)
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
+
+ if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+
+ if (vshCommandOptUInt(cmd, "iothread", &iothread_id) < 0) {
+ vshError(ctl, "%s", _("iothreadpin: Invalid IOThread number."));
+ goto cleanup;
+ }
+
+ if (vshCommandOptString(cmd, "cpulist", &cpulist) < 0) {
+ vshError(ctl, "%s", _("iothreadpin: invalid cpulist."));
+ goto cleanup;
+ }
+
+ if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
+ goto cleanup;
+ cpumaplen = VIR_CPU_MAPLEN(maxcpu);
+
+ /* Pin mode: pinning specified vcpu to specified physical cpus*/
+ if (!(cpumap = vshParseCPUList(ctl, cpulist, maxcpu, cpumaplen)))
+ goto cleanup;
+
+ if (virDomainPinIOThread(dom, iothread_id,
+ cpumap, cpumaplen, flags) != 0)
+ goto cleanup;
+
+ ret = true;
+
+ cleanup:
+ VIR_FREE(cpumap);
+ virDomainFree(dom);
+ return ret;
+}
+
/*
* "cpu-compare" command
*/
.info = info_iothreads,
.flags = 0
},
+ {.name = "iothreadpin",
+ .handler = cmdIOThreadPin,
+ .opts = opts_iothreadpin,
+ .info = info_iothreadpin,
+ .flags = 0
+ },
{.name = "send-key",
.handler = cmdSendKey,
.opts = opts_send_key,
If I<--current> is specified or I<--live> and I<--config> are not specified,
then get the IOThread data based on the current guest state.
+=item B<iothreadpin> I<domain> I<iothread> I<cpulist>
+[[I<--live>] [I<--config>] | [I<--current>]]
+
+Change the pinning of a domain IOThread to host physical CPUs. In order
+to retrieve a list of all IOThreads, use B<iothreadsinfo>. To pin an
+I<iothread> specify the I<cpulist> desired for the IOThread ID as listed
+in the B<iothreadsinfo> output.
+
+I<cpulist> is a list of physical CPU numbers. Its syntax is a comma
+separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can
+also be allowed. The '-' denotes the range and the '^' denotes exclusive.
+If you want to reset iothreadpin setting, that is, to pin an I<iothread>
+to all physical cpus, simply specify 'r' as a I<cpulist>.
+
+If I<--live> is specified, affect a running guest. If the guest is not running,
+an error is returned.
+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.
+Both I<--live> and I<--config> flags may be given if I<cpulist> is present,
+but I<--current> is exclusive.
+If no flag is specified, behavior is different depending on hypervisor.
+
+B<Note>: The expression is sequentially evaluated, so "0-15,^8" is
+identical to "9-14,0-7,15" but not identical to "^8,0-15".
+
=item B<managedsave> I<domain> [I<--bypass-cache>]
[{I<--running> | I<--paused>}] [I<--verbose>]