mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +00:00
setvcpus: add "--current" option to "virsh setvcpus"
This patch adds the --current option to "virsh setvcpus" command. Currently "virsh setvcpus" command supports "--live" and "--config" , but "--current" option. From view of consistency, it's reasonable to support "--current" option too. When --current is specified, it affects a "current" domain. Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
This commit is contained in:
parent
c147b93739
commit
3807d552c7
@ -3257,6 +3257,7 @@ static const vshCmdOptDef opts_setvcpus[] = {
|
|||||||
{"maximum", VSH_OT_BOOL, 0, N_("set maximum limit on next boot")},
|
{"maximum", VSH_OT_BOOL, 0, N_("set maximum limit on next boot")},
|
||||||
{"config", VSH_OT_BOOL, 0, N_("affect next boot")},
|
{"config", VSH_OT_BOOL, 0, N_("affect next boot")},
|
||||||
{"live", VSH_OT_BOOL, 0, N_("affect running domain")},
|
{"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}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3269,9 +3270,24 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
|
|||||||
int maximum = vshCommandOptBool(cmd, "maximum");
|
int maximum = vshCommandOptBool(cmd, "maximum");
|
||||||
int config = vshCommandOptBool(cmd, "config");
|
int config = vshCommandOptBool(cmd, "config");
|
||||||
int live = vshCommandOptBool(cmd, "live");
|
int live = vshCommandOptBool(cmd, "live");
|
||||||
int flags = ((maximum ? VIR_DOMAIN_VCPU_MAXIMUM : 0) |
|
int current = vshCommandOptBool(cmd, "current");
|
||||||
(config ? VIR_DOMAIN_AFFECT_CONFIG : 0) |
|
int flags = 0;
|
||||||
(live ? VIR_DOMAIN_AFFECT_LIVE : 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 && !maximum)
|
||||||
|
flags = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!vshConnectionUsability(ctl, ctl->conn))
|
if (!vshConnectionUsability(ctl, ctl->conn))
|
||||||
return false;
|
return false;
|
||||||
@ -3284,7 +3300,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!flags) {
|
if (flags == -1) {
|
||||||
if (virDomainSetVcpus(dom, count) != 0) {
|
if (virDomainSetVcpus(dom, count) != 0) {
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
@ -3294,6 +3310,8 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (maximum) {
|
if (maximum) {
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG, "--maximum flag was given\n");
|
vshDebug(ctl, VSH_ERR_DEBUG, "--maximum flag was given\n");
|
||||||
|
|
||||||
|
flags |= VIR_DOMAIN_VCPU_MAXIMUM;
|
||||||
|
|
||||||
/* If neither the --config nor --live flags were given, OR
|
/* If neither the --config nor --live flags were given, OR
|
||||||
if just the --live flag was given, we need to error out
|
if just the --live flag was given, we need to error out
|
||||||
warning the user that the --maximum flag can only be used
|
warning the user that the --maximum flag can only be used
|
||||||
|
@ -740,7 +740,7 @@ exclusive. If no flag is specified, behavior is different depending
|
|||||||
on hypervisor.
|
on hypervisor.
|
||||||
|
|
||||||
=item B<setvcpus> I<domain-id> I<count> optional I<--maximum> I<--config>
|
=item B<setvcpus> I<domain-id> I<count> optional I<--maximum> I<--config>
|
||||||
I<--live>
|
I<--live> I<--current>
|
||||||
|
|
||||||
Change the number of virtual CPUs active in a guest domain. By default,
|
Change the number of virtual CPUs active in a guest domain. By default,
|
||||||
this command works on active guest domains. To change the settings for an
|
this command works on active guest domains. To change the settings for an
|
||||||
@ -758,7 +758,9 @@ If I<--live> is specified, the guest domain must be active, and the change
|
|||||||
takes place immediately. Both the I<--config> and I<--live> flags may be
|
takes place immediately. Both the I<--config> and I<--live> flags may be
|
||||||
specified together if supported by the hypervisor.
|
specified together if supported by the hypervisor.
|
||||||
|
|
||||||
When neither the I<--config> nor I<--live> flags are given, the I<--live>
|
If I<--current> is specified, affect the current guest state.
|
||||||
|
|
||||||
|
When no flags are given, the I<--live>
|
||||||
flag is assumed and the guest domain must be active. In this situation it
|
flag is assumed and the guest domain must be active. In this situation it
|
||||||
is up to the hypervisor whether the I<--config> flag is also assumed, and
|
is up to the hypervisor whether the I<--config> flag is also assumed, and
|
||||||
therefore whether the XML configuration is adjusted to make the change
|
therefore whether the XML configuration is adjusted to make the change
|
||||||
|
Loading…
Reference in New Issue
Block a user