]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
vcpupin: introduce a new libvirt API (virDomainPinVcpuFlags)
authorTaku Izumi <izumi.taku@jp.fujitsu.com>
Mon, 13 Jun 2011 15:35:54 +0000 (23:35 +0800)
committerDaniel Veillard <veillard@redhat.com>
Mon, 13 Jun 2011 15:35:54 +0000 (23:35 +0800)
This patch introduces a new libvirt API virDomainPinVcpuFlags,
a direct extension from the existing virDomainPinVcpu

include/libvirt/libvirt.h.in
src/driver.h
src/libvirt.c
src/libvirt_public.syms

index df213f15cd4258fb96b63e731418064cf3d185f2..a38ba810f272b1074e7eb14580d6e88c4ddab275 100644 (file)
@@ -1049,6 +1049,11 @@ int                     virDomainPinVcpu        (virDomainPtr domain,
                                                  unsigned int vcpu,
                                                  unsigned char *cpumap,
                                                  int maplen);
+int                     virDomainPinVcpuFlags   (virDomainPtr domain,
+                                                 unsigned int vcpu,
+                                                 unsigned char *cpumap,
+                                                 int maplen,
+                                                 unsigned int flags);
 
 /**
  * VIR_USE_CPU:
index 5df798a0c66b07c05a8305296661565c9018228c..b92d7b8ca1a60a05e89562c66abd27a785003026 100644 (file)
@@ -229,6 +229,12 @@ typedef int
                                          unsigned int vcpu,
                                          unsigned char *cpumap,
                                          int maplen);
+typedef int
+        (*virDrvDomainPinVcpuFlags)     (virDomainPtr domain,
+                                         unsigned int vcpu,
+                                         unsigned char *cpumap,
+                                         int maplen,
+                                         unsigned int flags);
 typedef int
         (*virDrvDomainGetVcpus)                (virDomainPtr domain,
                                          virVcpuInfoPtr info,
@@ -671,6 +677,7 @@ struct _virDriver {
     virDrvDomainSetVcpusFlags          domainSetVcpusFlags;
     virDrvDomainGetVcpusFlags          domainGetVcpusFlags;
     virDrvDomainPinVcpu                domainPinVcpu;
+    virDrvDomainPinVcpuFlags    domainPinVcpuFlags;
     virDrvDomainGetVcpus               domainGetVcpus;
     virDrvDomainGetMaxVcpus            domainGetMaxVcpus;
     virDrvDomainGetSecurityLabel     domainGetSecurityLabel;
index 997d4a258e1de3a0bf051c1a557279c7c872d27b..fc5903fe3b2067c4389a44482db8ea04e6fedd76 100644 (file)
@@ -6708,6 +6708,82 @@ error:
     return -1;
 }
 
+/**
+ * virDomainPinVcpuFlags:
+ * @domain: pointer to domain object, or NULL for Domain0
+ * @vcpu: virtual CPU number
+ * @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN)
+ *      Each bit set to 1 means that corresponding CPU is usable.
+ *      Bytes are stored in little-endian order: CPU0-7, 8-15...
+ *      In each byte, lowest CPU number is least significant bit.
+ * @maplen: number of bytes in cpumap, from 1 up to size of CPU map in
+ *      underlying virtualization system (Xen...).
+ *      If maplen < size, missing bytes are set to zero.
+ *      If maplen > size, failure code is returned.
+ * @flags: bitwise-OR of virDomainModificationImpac
+ *
+ * Dynamically change the real CPUs which can be allocated to a virtual CPU.
+ * This function requires privileged access to the hypervisor.
+ *
+ * @flags may include VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG.
+ * Both flags may be set.
+ * If VIR_DOMAIN_AFFECT_LIVE is set, the change affects a running domain
+ * and may fail if domain is not alive.
+ * If VIR_DOMAIN_AFFECT_CONFIG is set, the change affects persistent state,
+ * and will fail for transient domains. If neither flag is specified (that is,
+ * @flags is VIR_DOMAIN_AFFECT_CURRENT), then an inactive domain modifies
+ * persistent setup, while an active domain is hypervisor-dependent on whether
+ * just live or both live and persistent state is changed.
+ * Not all hypervisors can support all flag combinations.
+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ *
+ */
+int
+virDomainPinVcpuFlags(virDomainPtr domain, unsigned int vcpu,
+                      unsigned char *cpumap, int maplen, unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "vcpu=%u, cpumap=%p, maplen=%d, flags=%u",
+                     vcpu, cpumap, maplen, flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+
+    if (domain->conn->flags & VIR_CONNECT_RO) {
+        virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    if ((vcpu > 32000) || (cpumap == NULL) || (maplen < 1)) {
+        virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+        goto error;
+    }
+
+    conn = domain->conn;
+
+    if (conn->driver->domainPinVcpuFlags) {
+        int ret;
+        ret = conn->driver->domainPinVcpuFlags (domain, vcpu, cpumap, maplen, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(domain->conn);
+    return -1;
+
+}
+
 /**
  * virDomainGetVcpus:
  * @domain: pointer to domain object, or NULL for Domain0
index 4d4299a3f3d0be416af816c8e8c70d6f35a10ea0..ff58e9d58cf48312bf0e41faac7a4c2b5d40b9d9 100644 (file)
@@ -450,4 +450,9 @@ LIBVIRT_0.9.2 {
         virInterfaceChangeRollback;
 } LIBVIRT_0.9.0;
 
+LIBVIRT_0.9.3 {
+    global:
+         virDomainPinVcpuFlags;
+} LIBVIRT_0.9.2;
+
 # .... define new API here using predicted next version number ....