For compatibility reasons virDomainSetVcpus needs to add vcpus as non
hotpluggable which means that the users whill not be able to unplug it
after the VM has started. Add a flag that will allow to tell the API
that the unpluggable vcpus are okay.
---
 include/libvirt/libvirt-domain.h | 1 +
 tools/virsh-domain.c             | 7 +++++++
 tools/virsh.pod                  | 7 ++++++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index f1c35d9..385b846 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1707,6 +1707,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_GUEST   = (1 << 3), /* Modify state of the cpu in the 
guest */
+    VIR_DOMAIN_VCPU_HOTPLUGGABLE = (1 << 4), /* Make vcpus added 
hot(un)pluggable */
 } virDomainVcpuFlags;

 int                     virDomainSetVcpus       (virDomainPtr domain,
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 3829b17..2ce0a06 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6722,6 +6722,10 @@ static const vshCmdOptDef opts_setvcpus[] = {
      .type = VSH_OT_BOOL,
      .help = N_("modify cpu state in the guest")
     },
+    {.name = "hotpluggable",
+     .type = VSH_OT_BOOL,
+     .help = N_("make added vcpus hot(un)pluggable")
+    },
     {.name = NULL}
 };

@@ -6736,6 +6740,7 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
     bool live = vshCommandOptBool(cmd, "live");
     bool current = vshCommandOptBool(cmd, "current");
     bool guest = vshCommandOptBool(cmd, "guest");
+    bool hotpluggable = vshCommandOptBool(cmd, "hotpluggable");
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;

     VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
@@ -6752,6 +6757,8 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_DOMAIN_VCPU_GUEST;
     if (maximum)
         flags |= VIR_DOMAIN_VCPU_MAXIMUM;
+    if (hotpluggable)
+        flags |= VIR_DOMAIN_VCPU_HOTPLUGGABLE;

     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 49abda9..cbb237a 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2316,7 +2316,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<--guest>]
+[I<--live>] | [I<--current>]] [I<--guest>] [I<--hotpluggable>]

 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
@@ -2348,6 +2348,11 @@ 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.

+To allow adding vcpus to persistent definitions that can be later hotunplugged
+after the domain is booted it is necessary to specify the I<--hotpluggable>
+flag. Vcpus added to live domains supporting vcpu unplug are automatically
+marked as hotpluggable.
+
 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
 used with the I<--config> flag, and not with the I<--live> or the I<--current>
-- 
2.10.0

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

Reply via email to