提交 9a3404ed 编写于 作者: T Taku Izumi 提交者: Daniel Veillard

vcpupin: add the new option to "virsh vcpupin" command

This patch adds the new option (--live, --config and --current) to
"virsh vcpupin" command. The behavior of above aption is the same as
that of "virsh setmem", "virsh setvcpus", and whatnot.
When the --config option is specified, the command affects a persistent
domain, while --live option is specified, it affects a running (live) domain.
The --current option cannot be used with --config or --live at the same
time, and when --current is specified, it affects a "current" domain.
上级 b01e9936
...@@ -2929,6 +2929,9 @@ static const vshCmdOptDef opts_vcpupin[] = { ...@@ -2929,6 +2929,9 @@ static const vshCmdOptDef opts_vcpupin[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")}, {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"vcpu", VSH_OT_INT, VSH_OFLAG_REQ, N_("vcpu number")}, {"vcpu", VSH_OT_INT, VSH_OFLAG_REQ, N_("vcpu number")},
{"cpulist", VSH_OT_DATA, VSH_OFLAG_REQ, N_("host cpu number(s) (comma separated)")}, {"cpulist", VSH_OT_DATA, VSH_OFLAG_REQ, N_("host cpu number(s) (comma separated)")},
{"config", VSH_OT_BOOL, 0, N_("affect next boot")},
{"live", VSH_OT_BOOL, 0, N_("affect running domain")},
{"current", VSH_OT_BOOL, 0, N_("affect current domain")},
{NULL, 0, 0, NULL} {NULL, 0, 0, NULL}
}; };
...@@ -2945,6 +2948,26 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd) ...@@ -2945,6 +2948,26 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
int cpumaplen; int cpumaplen;
int i; int i;
enum { expect_num, expect_num_or_comma } state; enum { expect_num, expect_num_or_comma } state;
int config = vshCommandOptBool(cmd, "config");
int live = vshCommandOptBool(cmd, "live");
int current = vshCommandOptBool(cmd, "current");
int flags = 0;
if (current) {
if (live || config) {
vshError(ctl, "%s", _("--current must be specified exclusively"));
return false;
}
flags = VIR_DOMAIN_AFFECT_CURRENT;
} else {
if (config)
flags |= VIR_DOMAIN_AFFECT_CONFIG;
if (live)
flags |= VIR_DOMAIN_AFFECT_LIVE;
/* neither option is specified */
if (!live && !config)
flags = -1;
}
if (!vshConnectionUsability(ctl, ctl->conn)) if (!vshConnectionUsability(ctl, ctl->conn))
return false; return false;
...@@ -3041,8 +3064,14 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd) ...@@ -3041,8 +3064,14 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
cpulist++; cpulist++;
} while (cpulist); } while (cpulist);
if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0) { if (flags == -1) {
ret = false; if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0) {
ret = false;
}
} else {
if (virDomainPinVcpuFlags(dom, vcpu, cpumap, cpumaplen, flags) != 0) {
ret = false;
}
} }
VIR_FREE(cpumap); VIR_FREE(cpumap);
......
...@@ -790,10 +790,16 @@ values; these two flags cannot both be specified. ...@@ -790,10 +790,16 @@ values; these two flags cannot both be specified.
Returns basic information about the domain virtual CPUs, like the number of Returns basic information about the domain virtual CPUs, like the number of
vCPUs, the running time, the affinity to physical processors. vCPUs, the running time, the affinity to physical processors.
=item B<vcpupin> I<domain-id> I<vcpu> I<cpulist> =item B<vcpupin> I<domain-id> I<vcpu> I<cpulist> optional I<--live> I<--config>
I<--current>
Pin domain VCPUs to host physical CPUs. The I<vcpu> number must be provided Pin domain VCPUs to host physical CPUs. The I<vcpu> number must be provided
and I<cpulist> is a comma separated list of physical CPU numbers. and I<cpulist> is a comma separated list of physical CPU numbers.
If I<--live> is specified, affect a running guest.
If I<--config> is specified, affect the next boot of a persistent guest.
If I<--current> is specified, affect the current guest state.
Both I<--live> and I<--config> flags may be given, but I<--current> is exclusive.
If no flag is specified, behavior is different depending on hypervisor.
=item B<vncdisplay> I<domain-id> =item B<vncdisplay> I<domain-id>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册