[PATCH 10/13] Introduce remoteDomainPinHypervisorFlags and remoteDomainGetHypervisorPinInfo functions in remote driver.

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

 



Introduce 2 APIs to support hypervisor threads in remote driver.
    1) remoteDomainPinHypervisorFlags: call driver api, such as qemudDomainPinHypervisorFlags.
    2) remoteDomainGetHypervisorPinInfo: call driver api, such as qemudDomainGetHypervisorPinInfo.
They are similar to remoteDomainPinVcpuFlags and remoteDomainGetVcpuPinInfo.

Signed-off-by: Tang Chen <tangchen@xxxxxxxxxxxxxx>
---
 src/remote/remote_driver.c   |  102 ++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x |   23 +++++++++-
 src/remote_protocol-structs  |   24 ++++++++++
 3 files changed, 148 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index eac50e6..7fd128b 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1806,6 +1806,106 @@ done:
 }
 
 static int
+remoteDomainPinHypervisorFlags (virDomainPtr dom,
+                                unsigned char *cpumap,
+                                int cpumaplen,
+                                unsigned int flags)
+{
+    int rv = -1;
+    struct private_data *priv = dom->conn->privateData;
+    remote_domain_pin_hypervisor_flags_args args;
+
+    remoteDriverLock(priv);
+
+    if (cpumaplen > REMOTE_CPUMAP_MAX) {
+        remoteError(VIR_ERR_RPC,
+                    _("%s length greater than maximum: %d > %d"),
+                    "cpumap", (int)cpumaplen, REMOTE_CPUMAP_MAX);
+        goto done;
+    }
+
+    make_nonnull_domain(&args.dom, dom);
+    args.vcpu = -1;
+    args.cpumap.cpumap_val = (char *)cpumap;
+    args.cpumap.cpumap_len = cpumaplen;
+    args.flags = flags;
+
+    if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_PIN_HYPERVISOR_FLAGS,
+             (xdrproc_t) xdr_remote_domain_pin_hypervisor_flags_args,
+             (char *) &args,
+             (xdrproc_t) xdr_void, (char *) NULL) == -1) {
+        goto done;
+    }
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+
+static int
+remoteDomainGetHypervisorPinInfo (virDomainPtr domain,
+                                  unsigned char *cpumaps,
+                                  int maplen,
+                                  unsigned int flags)
+{
+    int rv = -1;
+    int i;
+    remote_domain_get_hypervisor_pin_info_args args;
+    remote_domain_get_hypervisor_pin_info_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    /* There is only one cpumap for all hypervisor threads */
+    if (INT_MULTIPLY_OVERFLOW(1, maplen) ||
+        maplen > REMOTE_CPUMAPS_MAX) {
+        remoteError(VIR_ERR_RPC,
+                    _("vCPU map buffer length exceeds maximum: %d > %d"),
+                    maplen, REMOTE_CPUMAPS_MAX);
+        goto done;
+    }
+
+    make_nonnull_domain(&args.dom, domain);
+    args.ncpumaps = 1;
+    args.maplen = maplen;
+    args.flags = flags;
+
+    memset(&ret, 0, sizeof ret);
+
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_HYPERVISOR_PIN_INFO,
+              (xdrproc_t) xdr_remote_domain_get_hypervisor_pin_info_args,
+              (char *) &args,
+              (xdrproc_t) xdr_remote_domain_get_hypervisor_pin_info_ret,
+              (char *) &ret) == -1)
+        goto done;
+
+    if (ret.cpumaps.cpumaps_len > maplen) {
+        remoteError(VIR_ERR_RPC,
+                    _("host reports map buffer length exceeds maximum: %d > %d"),
+                    ret.cpumaps.cpumaps_len, maplen);
+        goto cleanup;
+    }
+
+    memset(cpumaps, 0, maplen);
+
+    for (i = 0; i < ret.cpumaps.cpumaps_len; ++i)
+        cpumaps[i] = ret.cpumaps.cpumaps_val[i];
+
+    rv = ret.num;
+
+cleanup:
+    xdr_free ((xdrproc_t) xdr_remote_domain_get_hypervisor_pin_info_ret,
+              (char *) &ret);
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+static int
 remoteDomainGetVcpus (virDomainPtr domain,
                       virVcpuInfoPtr info,
                       int maxinfo,
@@ -5192,6 +5292,8 @@ static virDriver remote_driver = {
     .domainPinVcpu = remoteDomainPinVcpu, /* 0.3.0 */
     .domainPinVcpuFlags = remoteDomainPinVcpuFlags, /* 0.9.3 */
     .domainGetVcpuPinInfo = remoteDomainGetVcpuPinInfo, /* 0.9.3 */
+    .domainPinHypervisorFlags = remoteDomainPinHypervisorFlags, /* 0.9.13 */
+    .domainGetHypervisorPinInfo = remoteDomainGetHypervisorPinInfo, /* 0.9.13 */
     .domainGetVcpus = remoteDomainGetVcpus, /* 0.3.0 */
     .domainGetMaxVcpus = remoteDomainGetMaxVcpus, /* 0.3.0 */
     .domainGetSecurityLabel = remoteDomainGetSecurityLabel, /* 0.6.1 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 1da9f3e..820553c 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1054,6 +1054,25 @@ struct remote_domain_get_vcpu_pin_info_ret {
     int num;
 };
 
+struct remote_domain_pin_hypervisor_flags_args {
+    remote_nonnull_domain dom;
+    unsigned int vcpu;
+    opaque cpumap<REMOTE_CPUMAP_MAX>; /* (unsigned char *) */
+    unsigned int flags;
+};
+
+struct remote_domain_get_hypervisor_pin_info_args {
+    remote_nonnull_domain dom;
+    int ncpumaps;
+    int maplen;
+    unsigned int flags;
+};
+
+struct remote_domain_get_hypervisor_pin_info_ret {
+    opaque cpumaps<REMOTE_CPUMAPS_MAX>;
+    int num;
+};
+
 struct remote_domain_get_vcpus_args {
     remote_nonnull_domain dom;
     int maxinfo;
@@ -2838,7 +2857,9 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_SNAPSHOT_HAS_METADATA = 272, /* autogen autogen */
     REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 273, /* skipgen skipgen priority:high */
     REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS = 274, /* skipgen skipgen priority:high */
-    REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275 /* skipgen skipgen priority:high */
+    REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275, /* skipgen skipgen priority:high */
+    REMOTE_PROC_DOMAIN_PIN_HYPERVISOR_FLAGS = 276, /* skipgen skipgen */
+    REMOTE_PROC_DOMAIN_GET_HYPERVISOR_PIN_INFO = 277 /* skipgen skipgen */
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index b667527..736160a 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -718,6 +718,28 @@ struct remote_domain_get_vcpu_pin_info_ret {
         } cpumaps;
         int                        num;
 };
+struct remote_domain_pin_hypervisor_flags_args {
+        remote_nonnull_domain      dom;
+        u_int                      vcpu;
+        struct {
+                u_int              cpumap_len;
+                char *             cpumap_val;
+        } cpumap;
+        u_int                      flags;
+};
+struct remote_domain_get_hypervisor_pin_info_args {
+        remote_nonnull_domain      dom;
+        int                        ncpumaps;
+        int                        maplen;
+        u_int                      flags;
+};
+struct remote_domain_get_hypervisor_pin_info_ret {
+        struct {
+                u_int              cpumaps_len;
+                char *             cpumaps_val;
+        } cpumaps;
+        int                        num;
+};
 struct remote_domain_get_vcpus_args {
         remote_nonnull_domain      dom;
         int                        maxinfo;
@@ -2246,4 +2268,6 @@ enum remote_procedure {
         REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 273,
         REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS = 274,
         REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275,
+        REMOTE_PROC_DOMAIN_PIN_HYPERVISOR_FLAGS = 276,
+        REMOTE_PROC_DOMAIN_GET_HYPERVISOR_PIN_INFO = 277,
 };
-- 
1.7.10.2

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