]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lib: Add API for specific vCPU hot(un)plug
authorPeter Krempa <pkrempa@redhat.com>
Tue, 21 Jun 2016 08:44:51 +0000 (10:44 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 21 Feb 2017 14:06:59 +0000 (15:06 +0100)
Similarly to domainSetGuestVcpus this commit adds API which allows to
modify state of individual vcpus rather than just setting the count.

This allows to enable CPUs in specific guest NUMA nodes to achieve any
necessary configuration.

include/libvirt/libvirt-domain.h
src/driver-hypervisor.h
src/libvirt-domain.c
src/libvirt_public.syms
src/remote/remote_driver.c
src/remote/remote_protocol.x
src/remote_protocol-structs

index e303140a23311d445f6ba18c9fe344c9e8fdc95c..c0f715d66a6970210835fe7d449e84f153222fd8 100644 (file)
@@ -4528,4 +4528,9 @@ int virDomainSetGuestVcpus(virDomainPtr domain,
                            int state,
                            unsigned int flags);
 
+int virDomainSetVcpu(virDomainPtr domain,
+                     const char *vcpumap,
+                     int state,
+                     unsigned int flags);
+
 #endif /* __VIR_LIBVIRT_DOMAIN_H__ */
index 51af73200bf074d25f5a5eaead8583a4ca559499..b81420aefeff65b95eda1e23b6a661199d4c6fb5 100644 (file)
@@ -1251,6 +1251,12 @@ typedef int
                              int state,
                              unsigned int flags);
 
+typedef int
+(*virDrvDomainSetVcpu)(virDomainPtr domain,
+                       const char *cpumap,
+                       int state,
+                       unsigned int flags);
+
 typedef struct _virHypervisorDriver virHypervisorDriver;
 typedef virHypervisorDriver *virHypervisorDriverPtr;
 
@@ -1489,6 +1495,7 @@ struct _virHypervisorDriver {
     virDrvDomainMigrateStartPostCopy domainMigrateStartPostCopy;
     virDrvDomainGetGuestVcpus domainGetGuestVcpus;
     virDrvDomainSetGuestVcpus domainSetGuestVcpus;
+    virDrvDomainSetVcpu domainSetVcpu;
 };
 
 
index 5b3e842058067a5bd17f8ed8045e61526edcf8bb..619a9fccb2ca7ed8708730b3e64f151adaaa07b2 100644 (file)
@@ -11749,3 +11749,51 @@ virDomainSetGuestVcpus(virDomainPtr domain,
     virDispatchError(domain->conn);
     return -1;
 }
+
+
+/**
+ * virDomainSetVcpu:
+ * @domain: pointer to domain object
+ * @vcpumap: text representation of a bitmap of vcpus to set
+ * @state: 0 to disable/1 to enable cpus described by @vcpumap
+ * @flags: bitwise-OR of virDomainModificationImpact
+ *
+ * Enables/disables individual vcpus described by @vcpumap in the hypervisor.
+ *
+ * Various hypervisor implementations may limit to operate on just 1
+ * hotpluggable entity (which may contain multiple vCPUs on certain platforms).
+ *
+ * Note that OSes and hypervisors may require vCPU 0 to stay online.
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int
+virDomainSetVcpu(virDomainPtr domain,
+                 const char *vcpumap,
+                 int state,
+                 unsigned int flags)
+{
+    VIR_DOMAIN_DEBUG(domain, "vcpumap='%s' state=%i flags=%x",
+                     NULLSTR(vcpumap), state, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    virCheckReadOnlyGoto(domain->conn->flags, error);
+
+    virCheckNonNullArgGoto(vcpumap, error);
+
+    if (domain->conn->driver->domainSetVcpu) {
+        int ret;
+        ret = domain->conn->driver->domainSetVcpu(domain, vcpumap, state, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return -1;
+}
index 62885ac415af4607080dc4fa5f66c875efb2f75f..04ef58021bc149bf10b841b0b55e425dde0c8675 100644 (file)
@@ -753,4 +753,9 @@ LIBVIRT_3.0.0 {
         virConnectSecretEventDeregisterAny;
 } LIBVIRT_2.2.0;
 
+LIBVIRT_3.1.0 {
+    global:
+        virDomainSetVcpu;
+} LIBVIRT_3.0.0;
+
 # .... define new API here using predicted next version number ....
index a3f7d9b0ba2a502b7745022f1599884a77c5430b..0c8bfeed16d4c5ff46abaafded1314ae13e4b65b 100644 (file)
@@ -8402,6 +8402,7 @@ static virHypervisorDriver hypervisor_driver = {
     .domainMigrateStartPostCopy = remoteDomainMigrateStartPostCopy, /* 1.3.3 */
     .domainGetGuestVcpus = remoteDomainGetGuestVcpus, /* 2.0.0 */
     .domainSetGuestVcpus = remoteDomainSetGuestVcpus, /* 2.0.0 */
+    .domainSetVcpu = remoteDomainSetVcpu, /* 3.1.0 */
 };
 
 static virNetworkDriver network_driver = {
index cd0a14cc69c8d06154a61ca555f58bccf67783c4..abe63af0703f1cbdbf4cad2abbb8e598aac9707a 100644 (file)
@@ -3353,6 +3353,13 @@ struct remote_domain_set_guest_vcpus_args {
     unsigned int flags;
 };
 
+struct remote_domain_set_vcpu_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string cpumap;
+    int state;
+    unsigned int flags;
+};
+
 
 struct remote_domain_event_callback_metadata_change_msg {
     int callbackID;
@@ -6018,6 +6025,13 @@ enum remote_procedure {
      * @generate: both
      * @acl: none
      */
-    REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED = 383
+    REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED = 383,
 
+    /**
+     * @generate: both
+     * @acl: domain:write
+     * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE
+     * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG
+     */
+    REMOTE_PROC_DOMAIN_SET_VCPU = 384
 };
index 0360600cfb1f260d7137eeddffe8f177943ccdb1..e1e53d21b2657a768317242dc5ae1ef57676ddae 100644 (file)
@@ -2800,6 +2800,12 @@ struct remote_domain_set_guest_vcpus_args {
         int                        state;
         u_int                      flags;
 };
+struct remote_domain_set_vcpu_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      cpumap;
+        int                        state;
+        u_int                      flags;
+};
 struct remote_domain_event_callback_metadata_change_msg {
         int                        callbackID;
         remote_nonnull_domain      dom;
@@ -3210,4 +3216,5 @@ enum remote_procedure {
         REMOTE_PROC_CONNECT_SECRET_EVENT_DEREGISTER_ANY = 381,
         REMOTE_PROC_SECRET_EVENT_LIFECYCLE = 382,
         REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED = 383,
+        REMOTE_PROC_DOMAIN_SET_VCPU = 384,
 };