[PATCH 1/4] vcpupin: inroduce a new libvir API (virDomainPinVcpuFlags)

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

 



This patch introduces a new libvirt API (virDomainPinVcpuFlags)

Signed-off-by: Taku Izumi <izumi.taku@xxxxxxxxxxxxxx>
---
 include/libvirt/libvirt.h.in |    5 +++
 src/driver.h                 |    7 ++++
 src/libvirt.c                |   70 +++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |    1
 src/lxc/lxc_driver.c         |    1
 src/openvz/openvz_driver.c   |    1
 src/phyp/phyp_driver.c       |    1
 src/qemu/qemu_driver.c       |    1
 src/remote/remote_driver.c   |    1
 src/test/test_driver.c       |    1
 src/uml/uml_driver.c         |    1
 src/vbox/vbox_tmpl.c         |    1
 src/vmware/vmware_driver.c   |    1
 src/xen/xen_driver.c         |    1
 src/xenapi/xenapi_driver.c   |    1
 15 files changed, 94 insertions(+)

Index: libvirt/include/libvirt/libvirt.h.in
===================================================================
--- libvirt.orig/include/libvirt/libvirt.h.in
+++ libvirt/include/libvirt/libvirt.h.in
@@ -1036,6 +1036,11 @@ int                     virDomainPinVcpu
                                                  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: libvirt/src/driver.h
===================================================================
--- libvirt.orig/src/driver.h
+++ libvirt/src/driver.h
@@ -220,6 +220,12 @@ typedef int
                                          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,
                                          int maxinfo,
@@ -570,6 +576,7 @@ struct _virDriver {
     virDrvDomainSetVcpusFlags		domainSetVcpusFlags;
     virDrvDomainGetVcpusFlags		domainGetVcpusFlags;
     virDrvDomainPinVcpu		domainPinVcpu;
+    virDrvDomainPinVcpuFlags    domainPinVcpuFlags;
     virDrvDomainGetVcpus		domainGetVcpus;
     virDrvDomainGetMaxVcpus		domainGetMaxVcpus;
     virDrvDomainGetSecurityLabel     domainGetSecurityLabel;
Index: libvirt/src/libvirt.c
===================================================================
--- libvirt.orig/src/libvirt.c
+++ libvirt/src/libvirt.c
@@ -5495,6 +5495,76 @@ error:
 }

 /**
+ * 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 correspoinding 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: an OR'ed set of virDomainVcpuFlags
+ *
+ * Dynamically change the real CPUs which can be allocated to a virtual CPU.
+ * This function requires privileged access to the hypervisor.
+ *
+ * @flags must include VIR_DOMAIN_VCPU_LIVE to affect a running domain
+ * (which may fail if domain is not active), or VIR_DOMAIN_MEM_CONFIG to
+ * affect the next boot via the XML description of the domain.
+ * Both flags may be set.
+ *
+ * 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
  * @info: pointer to an array of virVcpuInfo structures (OUT)
Index: libvirt/src/libvirt_public.syms
===================================================================
--- libvirt.orig/src/libvirt_public.syms
+++ libvirt/src/libvirt_public.syms
@@ -434,6 +434,7 @@ LIBVIRT_0.9.0 {
         virEventRunDefaultImpl;
         virStorageVolDownload;
         virStorageVolUpload;
+        virDomainPinVcpuFlags;
 } LIBVIRT_0.8.8;

 # .... define new API here using predicted next version number ....
Index: libvirt/src/lxc/lxc_driver.c
===================================================================
--- libvirt.orig/src/lxc/lxc_driver.c
+++ libvirt/src/lxc/lxc_driver.c
@@ -2837,6 +2837,7 @@ static virDriver lxcDriver = {
     NULL, /* domainSetVcpusFlags */
     NULL, /* domainGetVcpusFlags */
     NULL, /* domainPinVcpu */
+    NULL, /* domainPinVcpuFlags */
     NULL, /* domainGetVcpus */
     NULL, /* domainGetMaxVcpus */
     NULL, /* domainGetSecurityLabel */
Index: libvirt/src/openvz/openvz_driver.c
===================================================================
--- libvirt.orig/src/openvz/openvz_driver.c
+++ libvirt/src/openvz/openvz_driver.c
@@ -1585,6 +1585,7 @@ static virDriver openvzDriver = {
     openvzDomainSetVcpusFlags, /* domainSetVcpusFlags */
     openvzDomainGetVcpusFlags, /* domainGetVcpusFlags */
     NULL, /* domainPinVcpu */
+    NULL, /* domainPinVcpuFlags */
     NULL, /* domainGetVcpus */
     openvzDomainGetMaxVcpus, /* domainGetMaxVcpus */
     NULL, /* domainGetSecurityLabel */
Index: libvirt/src/phyp/phyp_driver.c
===================================================================
--- libvirt.orig/src/phyp/phyp_driver.c
+++ libvirt/src/phyp/phyp_driver.c
@@ -3986,6 +3986,7 @@ static virDriver phypDriver = {
     phypDomainSetVcpusFlags,    /* domainSetVcpusFlags */
     phypDomainGetVcpusFlags,    /* domainGetVcpusFlags */
     NULL,                       /* domainPinVcpu */
+    NULL,                       /* domainPinVcpuFlags */
     NULL,                       /* domainGetVcpus */
     phypGetLparCPUMAX,          /* domainGetMaxVcpus */
     NULL,                       /* domainGetSecurityLabel */
Index: libvirt/src/qemu/qemu_driver.c
===================================================================
--- libvirt.orig/src/qemu/qemu_driver.c
+++ libvirt/src/qemu/qemu_driver.c
@@ -6854,6 +6854,7 @@ static virDriver qemuDriver = {
     qemudDomainSetVcpusFlags, /* domainSetVcpusFlags */
     qemudDomainGetVcpusFlags, /* domainGetVcpusFlags */
     qemudDomainPinVcpu, /* domainPinVcpu */
+    NULL, /* domainPinVcpuFlags */
     qemudDomainGetVcpus, /* domainGetVcpus */
     qemudDomainGetMaxVcpus, /* domainGetMaxVcpus */
     qemudDomainGetSecurityLabel, /* domainGetSecurityLabel */
Index: libvirt/src/remote/remote_driver.c
===================================================================
--- libvirt.orig/src/remote/remote_driver.c
+++ libvirt/src/remote/remote_driver.c
@@ -11227,6 +11227,7 @@ static virDriver remote_driver = {
     remoteDomainSetVcpusFlags, /* domainSetVcpusFlags */
     remoteDomainGetVcpusFlags, /* domainGetVcpusFlags */
     remoteDomainPinVcpu, /* domainPinVcpu */
+    NULL, /* domainPinVcpuFlags */
     remoteDomainGetVcpus, /* domainGetVcpus */
     remoteDomainGetMaxVcpus, /* domainGetMaxVcpus */
     remoteDomainGetSecurityLabel, /* domainGetSecurityLabel */
Index: libvirt/src/test/test_driver.c
===================================================================
--- libvirt.orig/src/test/test_driver.c
+++ libvirt/src/test/test_driver.c
@@ -5378,6 +5378,7 @@ static virDriver testDriver = {
     testDomainSetVcpusFlags, /* domainSetVcpusFlags */
     testDomainGetVcpusFlags, /* domainGetVcpusFlags */
     testDomainPinVcpu, /* domainPinVcpu */
+    NULL, /* domainPinVcpuFlags */
     testDomainGetVcpus, /* domainGetVcpus */
     testDomainGetMaxVcpus, /* domainGetMaxVcpus */
     NULL, /* domainGetSecurityLabel */
Index: libvirt/src/uml/uml_driver.c
===================================================================
--- libvirt.orig/src/uml/uml_driver.c
+++ libvirt/src/uml/uml_driver.c
@@ -2180,6 +2180,7 @@ static virDriver umlDriver = {
     NULL, /* domainSetVcpusFlags */
     NULL, /* domainGetVcpusFlags */
     NULL, /* domainPinVcpu */
+    NULL, /* domainPinVcpuFlags */
     NULL, /* domainGetVcpus */
     NULL, /* domainGetMaxVcpus */
     NULL, /* domainGetSecurityLabel */
Index: libvirt/src/vbox/vbox_tmpl.c
===================================================================
--- libvirt.orig/src/vbox/vbox_tmpl.c
+++ libvirt/src/vbox/vbox_tmpl.c
@@ -8568,6 +8568,7 @@ virDriver NAME(Driver) = {
     vboxDomainSetVcpusFlags, /* domainSetVcpusFlags */
     vboxDomainGetVcpusFlags, /* domainGetVcpusFlags */
     NULL, /* domainPinVcpu */
+    NULL, /* domainPinVcpuFlags */
     NULL, /* domainGetVcpus */
     vboxDomainGetMaxVcpus, /* domainGetMaxVcpus */
     NULL, /* domainGetSecurityLabel */
Index: libvirt/src/vmware/vmware_driver.c
===================================================================
--- libvirt.orig/src/vmware/vmware_driver.c
+++ libvirt/src/vmware/vmware_driver.c
@@ -938,6 +938,7 @@ static virDriver vmwareDriver = {
     NULL,                       /* domainSetVcpusFlags */
     NULL,                       /* domainGetVcpusFlags */
     NULL,                       /* domainPinVcpu */
+    NULL,                       /* domainPinVcpuFlags */
     NULL,                       /* domainGetVcpus */
     NULL,                       /* domainGetMaxVcpus */
     NULL,                       /* domainGetSecurityLabel */
Index: libvirt/src/xen/xen_driver.c
===================================================================
--- libvirt.orig/src/xen/xen_driver.c
+++ libvirt/src/xen/xen_driver.c
@@ -2072,6 +2072,7 @@ static virDriver xenUnifiedDriver = {
     xenUnifiedDomainSetVcpusFlags, /* domainSetVcpusFlags */
     xenUnifiedDomainGetVcpusFlags, /* domainGetVcpusFlags */
     xenUnifiedDomainPinVcpu, /* domainPinVcpu */
+    NULL, /* domainPinVcpuFlags */
     xenUnifiedDomainGetVcpus, /* domainGetVcpus */
     xenUnifiedDomainGetMaxVcpus, /* domainGetMaxVcpus */
     NULL, /* domainGetSecurityLabel */
Index: libvirt/src/xenapi/xenapi_driver.c
===================================================================
--- libvirt.orig/src/xenapi/xenapi_driver.c
+++ libvirt/src/xenapi/xenapi_driver.c
@@ -1816,6 +1816,7 @@ static virDriver xenapiDriver = {
     xenapiDomainSetVcpusFlags, /* domainSetVcpusFlags */
     xenapiDomainGetVcpusFlags, /* domainGetVcpusFlags */
     xenapiDomainPinVcpu, /* domainPinVcpu */
+    NULL, /* domainPinVcpuFlags */
     xenapiDomainGetVcpus, /* domainGetVcpus */
     xenapiDomainGetMaxVcpus, /* domainGetMaxVcpus */
     NULL, /* domainGetSecurityLabel */


--
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]