[libvirt] [PATCH] virsh: ensure --maximum flag used only with --config for setvcpus
Eric Blake
eblake at redhat.com
Thu Jan 13 18:00:33 UTC 2011
On 01/13/2011 10:42 AM, Justin Clift wrote:
> ---
> tools/virsh.c | 21 +++++++++++++++++++++
> 1 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 018e363..f14144d 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -2765,11 +2765,32 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
> ret = FALSE;
> }
> } else {
> + /* If the --maximum flag was given, we need to ensure only the
> + --config flag is in effect as well */
> + if (VIR_DOMAIN_VCPU_MAXIMUM & flags) {
> + vshDebug(ctl, 5, "--maximum flag was given\n");
> +
> + /* If neither the --config nor --live flags were given, OR
> + if just the --live flag was given, we need to error out
> + warning the user that the --maximum flag can only be used
> + with the --config flag */
> + if ((VIR_DOMAIN_VCPU_LIVE & flags) |
> + (VIR_DOMAIN_VCPU_MAXIMUM == flags)) {
Idiomatically, I would use || instead of | (although the result is the
same in this case).
Also, rather than checking flags, you can check the bool variables that
fed flags. I'm squashing this in, then pushing.
diff --git i/tools/virsh.c w/tools/virsh.c
index 4c3d965..4f103ae 100644
--- i/tools/virsh.c
+++ w/tools/virsh.c
@@ -1,7 +1,7 @@
/*
* virsh.c: a shell to exercise the libvirt API
*
- * Copyright (C) 2005, 2007-2010 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2011 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -2767,15 +2767,14 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
} else {
/* If the --maximum flag was given, we need to ensure only the
--config flag is in effect as well */
- if (VIR_DOMAIN_VCPU_MAXIMUM & flags) {
+ if (maximum) {
vshDebug(ctl, 5, "--maximum flag was given\n");
/* If neither the --config nor --live flags were given, OR
if just the --live flag was given, we need to error out
warning the user that the --maximum flag can only be used
with the --config flag */
- if ((VIR_DOMAIN_VCPU_LIVE & flags) |
- (VIR_DOMAIN_VCPU_MAXIMUM == flags)) {
+ if (live || !config) {
/* Warn the user about the invalid flag combination */
vshError(ctl, _("--maximum must be used with --config
only"));
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110113/c17e1ce6/attachment-0001.sig>
More information about the libvir-list
mailing list