[libvirt] [PATCH] Fix commit 29c1e913e459058c12d02b3f4b767b3dd428a498

Peter Krempa pkrempa at redhat.com
Fri Jun 7 15:18:48 UTC 2013


This patch fixes changes done in commit 29c1e913e459058c12d02b3f4b767b3
that was pushed without implementing review feedback.

The flag introduced by the patch is changed to VIR_DOMAIN_VCPU_GUEST and
documentation makes the difference between regular hotplug and this new
functionality more explicit.

The virsh options that enable the use of the new flag are changed to
"--guest" and the documentation is fixed too.
---
 include/libvirt/libvirt.h.in |  2 +-
 src/libvirt.c                | 18 +++++++++---------
 src/qemu/qemu_driver.c       |  8 ++++----
 tools/virsh-domain.c         | 34 +++++++++++++++++-----------------
 tools/virsh.pod              | 16 ++++++++--------
 5 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index e057be1..574b970 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2120,7 +2120,7 @@ typedef enum {

     /* Additionally, these flags may be bitwise-OR'd in.  */
     VIR_DOMAIN_VCPU_MAXIMUM = (1 << 2), /* Max rather than current count */
-    VIR_DOMAIN_VCPU_AGENT   = (1 << 3), /* Use guest-agent based cpu hotplug */
+    VIR_DOMAIN_VCPU_GUEST   = (1 << 3), /* Modify state of the cpu in the guest */
 } virDomainVcpuFlags;

 int                     virDomainSetVcpus       (virDomainPtr domain,
diff --git a/src/libvirt.c b/src/libvirt.c
index 820519a..620dbdd 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -8907,10 +8907,10 @@ error:
  * current virtual CPU limit, which must be less than or equal to the
  * maximum limit.
  *
- * If @flags includes VIR_DOMAIN_VCPU_AGENT, then a guest agent is used to
- * modify the number of processors used by a domain. This flag can only be used
- * with live guests and is incompatible with VIR_DOMAIN_VCPU_MAXIMUM as the
- * maximum limit can't be changed using the guest agent.
+ * If @flags includes VIR_DOMAIN_VCPU_GUEST, then the state of processors is
+ * modified inside the guest instead of the hypervisor. This flag can only
+ * be used with live guests and is incompatible with VIR_DOMAIN_VCPU_MAXIMUM.
+ * The usage of this flag may require a guest agent configured.
  *
  * Not all hypervisors can support all flag combinations.
  *
@@ -8937,11 +8937,11 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
         goto error;
     }

-    if (flags & VIR_DOMAIN_VCPU_AGENT &&
+    if (flags & VIR_DOMAIN_VCPU_GUEST &&
         flags & VIR_DOMAIN_VCPU_MAXIMUM) {
         virReportInvalidArg(flags,
                             _("flags 'VIR_DOMAIN_VCPU_MAXIMUM' and "
-                              "'VIR_DOMAIN_VCPU_AGENT' in '%s' are mutually "
+                              "'VIR_DOMAIN_VCPU_GUEST' in '%s' are mutually "
                               "exclusive"), __FUNCTION__);
         goto error;
     }
@@ -8991,9 +8991,9 @@ error:
  * virtual CPU limit is queried.  Otherwise, this call queries the
  * current virtual CPU count.
  *
- * If @flags includes VIR_DOMAIN_VCPU_AGENT, then a guest agent is used to
- * modify the number of processors used by a domain. This flag is only usable on
- * live domains.
+ * If @flags includes VIR_DOMAIN_VCPU_GUEST, then the state of the processors
+ * is modified in the guest instead of the hypervisor. This flag is only usable
+ * on live domains. Guest agent may be needed for this flag to be available.
  *
  * Returns the number of vCPUs in case of success, -1 in case of failure.
  */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e5f6988..1b5b04f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3792,7 +3792,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG |
                   VIR_DOMAIN_VCPU_MAXIMUM |
-                  VIR_DOMAIN_VCPU_AGENT, -1);
+                  VIR_DOMAIN_VCPU_GUEST, -1);

     if (!nvcpus || (unsigned short) nvcpus != nvcpus) {
         virReportError(VIR_ERR_INVALID_ARG,
@@ -3834,7 +3834,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
         goto endjob;
     }

-    if (flags & VIR_DOMAIN_VCPU_AGENT) {
+    if (flags & VIR_DOMAIN_VCPU_GUEST) {
         if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
             virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                            _("chainging of maximum vCPU count isn't supported "
@@ -4518,7 +4518,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG |
                   VIR_DOMAIN_VCPU_MAXIMUM |
-                  VIR_DOMAIN_VCPU_AGENT, -1);
+                  VIR_DOMAIN_VCPU_GUEST, -1);

     if (!(vm = qemuDomObjFromDomain(dom)))
         return -1;
@@ -4535,7 +4535,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
     if (flags & VIR_DOMAIN_AFFECT_LIVE)
         def = vm->def;

-    if (flags & VIR_DOMAIN_VCPU_AGENT) {
+    if (flags & VIR_DOMAIN_VCPU_GUEST) {
         if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
             virReportError(VIR_ERR_INVALID_ARG, "%s",
                            _("vCPU count provided by the guest agent can only be "
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0616487..955e882 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5161,9 +5161,9 @@ static const vshCmdOptDef opts_vcpucount[] = {
      .type = VSH_OT_BOOL,
      .help = N_("get value according to current domain state")
     },
-    {.name = "agent",
+    {.name = "guest",
      .type = VSH_OT_BOOL,
-     .help = N_("use guest agent based hotplug")
+     .help = N_("retrieve vcpu count from the guest instead of the hypervisor")
     },
     {.name = NULL}
 };
@@ -5207,8 +5207,8 @@ vshCPUCountCollect(vshControl *ctl,
            last_error->code == VIR_ERR_INVALID_ARG))
          goto cleanup;

-     if (flags & VIR_DOMAIN_VCPU_AGENT) {
-         vshError(ctl, "%s", _("Failed to retrieve vCPU count via guest agent"));
+     if (flags & VIR_DOMAIN_VCPU_GUEST) {
+         vshError(ctl, "%s", _("Failed to retrieve vCPU count from the guest"));
          goto cleanup;
      }

@@ -5267,8 +5267,8 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
     bool config = vshCommandOptBool(cmd, "config");
     bool live = vshCommandOptBool(cmd, "live");
     bool current = vshCommandOptBool(cmd, "current");
-    bool agent = vshCommandOptBool(cmd, "agent");
-    bool all = maximum + active + current + config + live + agent == 0;
+    bool guest = vshCommandOptBool(cmd, "guest");
+    bool all = maximum + active + current + config + live + guest == 0;
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;

     /* Backwards compatibility: prior to 0.9.4,
@@ -5283,7 +5283,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
     VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
     VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
     VSH_EXCLUSIVE_OPTIONS_VAR(active, maximum);
-    VSH_EXCLUSIVE_OPTIONS_VAR(agent, config);
+    VSH_EXCLUSIVE_OPTIONS_VAR(guest, config);

     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -5291,8 +5291,8 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_DOMAIN_AFFECT_CONFIG;
     if (maximum)
         flags |= VIR_DOMAIN_VCPU_MAXIMUM;
-    if (agent)
-        flags |= VIR_DOMAIN_VCPU_AGENT;
+    if (guest)
+        flags |= VIR_DOMAIN_VCPU_GUEST;

     if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
         return false;
@@ -5762,10 +5762,6 @@ static const vshCmdOptDef opts_emulatorpin[] = {
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
     },
-    {.name = "agent",
-     .type = VSH_OT_BOOL,
-     .help = N_("use guest agent based hotplug")
-    },
     {.name = NULL}
 };

@@ -5889,6 +5885,10 @@ static const vshCmdOptDef opts_setvcpus[] = {
      .type = VSH_OT_BOOL,
      .help = N_("affect current domain")
     },
+    {.name = "guest",
+     .type = VSH_OT_BOOL,
+     .help = N_("modify cpu state in the guest")
+    },
     {.name = NULL}
 };

@@ -5902,19 +5902,19 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
     bool config = vshCommandOptBool(cmd, "config");
     bool live = vshCommandOptBool(cmd, "live");
     bool current = vshCommandOptBool(cmd, "current");
-    bool agent = vshCommandOptBool(cmd, "agent");
+    bool guest = vshCommandOptBool(cmd, "guest");
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;

     VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
     VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
-    VSH_EXCLUSIVE_OPTIONS_VAR(agent, config);
+    VSH_EXCLUSIVE_OPTIONS_VAR(guest, config);

     if (config)
         flags |= VIR_DOMAIN_AFFECT_CONFIG;
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
-    if (agent)
-        flags |= VIR_DOMAIN_VCPU_AGENT;
+    if (guest)
+        flags |= VIR_DOMAIN_VCPU_GUEST;
     /* none of the options were specified */
     if (!current && flags == 0)
         flags = -1;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index d537653..405b4d2 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1585,7 +1585,7 @@ exclusive. If no flag is specified, behavior is different depending
 on hypervisor.

 =item B<setvcpus> I<domain> I<count> [I<--maximum>] [[I<--config>]
-[I<--live>] | [I<--current>]] [I<--agent>]
+[I<--live>] | [I<--current>]] [I<--guest>]

 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
@@ -1611,9 +1611,9 @@ 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
 persistent.

-If I<--agent> is specified, then guest agent commands are used to retrieve the
-count of available vCPUs from the perspective of the guest. This flag is usable
-only for live domains.
+If I<--guest> is specified, then the count of cpus is modified in the guest
+instead of the hypervisor. This flag is usable only for live domains
+and may require guest agent to be configured in the guest.

 The I<--maximum> flag controls the maximum number of virtual cpus that can
 be hot-plugged the next time the domain is booted.  As such, it must only be
@@ -1741,7 +1741,7 @@ NOTE: For an inactive domain, the domain name or UUID must be used as the
 I<domain>.

 =item B<vcpucount> I<domain>  [{I<--maximum> | I<--active>}
-{I<--config> | I<--live> | I<--current>}] [I<--agent>]
+{I<--config> | I<--live> | I<--current>}] [I<--guest>]

 Print information about the virtual cpu counts of the given
 I<domain>.  If no flags are specified, all possible counts are
@@ -1759,9 +1759,9 @@ lists current values, and I<--current> queries according to the current
 state of the domain (corresponding to I<--live> if running, or
 I<--config> if inactive); these three flags are mutually exclusive.

-If I<--agent> is specified, then guest agent commands are used to retrieve the
-count of available vCPUs from the perspective of the guest. This flag is usable
-only for live domains.
+If I<--guest> is specified, then the count of cpus is reported from
+the perspective of the guest. This flag is usable only for live domains
+and may require guest agent to be configured in the guest.

 =item B<vcpuinfo> I<domain>

-- 
1.8.2.1




More information about the libvir-list mailing list