Re: [PATCH] virsh: ensure --maximum flag used only with --config for setvcpus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]