[PATCH] Support Xen domctl v8

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

 



xen-unstable c/s 23874:651aed73b39c added another member to
xen_domctl_getdomaininfo struct and bumped domctl version to 8.
Add a corresponding domctl v8 struct in xen hypervisor sub-driver
and detect domctl v8 during initialization.
---
 src/xen/xen_hypervisor.c |  129 +++++++++++++++++++++++++++++++++------------
 1 files changed, 94 insertions(+), 35 deletions(-)

diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 941686f..ee3a59c 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -243,12 +243,30 @@ struct xen_v2d7_getdomaininfo {
 };
 typedef struct xen_v2d7_getdomaininfo xen_v2d7_getdomaininfo;
 
+struct xen_v2d8_getdomaininfo {
+    domid_t  domain;	/* the domain number */
+    uint32_t flags;	/* flags, see before */
+    uint64_t tot_pages ALIGN_64;	/* total number of pages used */
+    uint64_t max_pages ALIGN_64;	/* maximum number of pages allowed */
+    uint64_t shr_pages ALIGN_64;    /* number of shared pages */
+    uint64_t paged_pages ALIGN_64;    /* number of paged pages */
+    uint64_t shared_info_frame ALIGN_64; /* MFN of shared_info struct */
+    uint64_t cpu_time ALIGN_64;  /* CPU time used */
+    uint32_t nr_online_vcpus;  /* Number of VCPUs currently online. */
+    uint32_t max_vcpu_id; /* Maximum VCPUID in use by this domain. */
+    uint32_t ssidref;
+    xen_domain_handle_t handle;
+    uint32_t cpupool;
+};
+typedef struct xen_v2d8_getdomaininfo xen_v2d8_getdomaininfo;
+
 union xen_getdomaininfo {
     struct xen_v0_getdomaininfo v0;
     struct xen_v2_getdomaininfo v2;
     struct xen_v2d5_getdomaininfo v2d5;
     struct xen_v2d6_getdomaininfo v2d6;
     struct xen_v2d7_getdomaininfo v2d7;
+    struct xen_v2d8_getdomaininfo v2d8;
 };
 typedef union xen_getdomaininfo xen_getdomaininfo;
 
@@ -258,6 +276,7 @@ union xen_getdomaininfolist {
     struct xen_v2d5_getdomaininfo *v2d5;
     struct xen_v2d6_getdomaininfo *v2d6;
     struct xen_v2d7_getdomaininfo *v2d7;
+    struct xen_v2d8_getdomaininfo *v2d8;
 };
 typedef union xen_getdomaininfolist xen_getdomaininfolist;
 
@@ -295,179 +314,211 @@ typedef struct xen_v2s5_availheap  xen_v2s5_availheap;
 #define XEN_GETDOMAININFOLIST_ALLOC(domlist, size)                      \
     (hv_versions.hypervisor < 2 ?                                       \
      (VIR_ALLOC_N(domlist.v0, (size)) == 0) :                           \
-     (hv_versions.dom_interface >= 7 ?                                  \
+     (hv_versions.dom_interface >= 8 ?                                  \
+      (VIR_ALLOC_N(domlist.v2d8, (size)) == 0) :                        \
+     (hv_versions.dom_interface == 7 ?                                  \
       (VIR_ALLOC_N(domlist.v2d7, (size)) == 0) :                        \
      (hv_versions.dom_interface == 6 ?                                  \
       (VIR_ALLOC_N(domlist.v2d6, (size)) == 0) :                        \
      (hv_versions.dom_interface == 5 ?                                  \
       (VIR_ALLOC_N(domlist.v2d5, (size)) == 0) :                        \
-      (VIR_ALLOC_N(domlist.v2, (size)) == 0)))))
+      (VIR_ALLOC_N(domlist.v2, (size)) == 0))))))
 
 #define XEN_GETDOMAININFOLIST_FREE(domlist)            \
     (hv_versions.hypervisor < 2 ?                      \
      VIR_FREE(domlist.v0) :                            \
-     (hv_versions.dom_interface >= 7 ?                 \
+     (hv_versions.dom_interface >= 8 ?                 \
+      VIR_FREE(domlist.v2d8) :                         \
+     (hv_versions.dom_interface == 7 ?                 \
       VIR_FREE(domlist.v2d7) :                         \
      (hv_versions.dom_interface == 6 ?                 \
       VIR_FREE(domlist.v2d6) :                         \
      (hv_versions.dom_interface == 5 ?                 \
       VIR_FREE(domlist.v2d5) :                         \
-      VIR_FREE(domlist.v2)))))
+      VIR_FREE(domlist.v2))))))
 
 #define XEN_GETDOMAININFOLIST_CLEAR(domlist, size)            \
     (hv_versions.hypervisor < 2 ?                             \
      memset(domlist.v0, 0, sizeof(*domlist.v0) * size) :      \
-     (hv_versions.dom_interface >= 7 ?                        \
+     (hv_versions.dom_interface >= 8 ?                        \
+      memset(domlist.v2d8, 0, sizeof(*domlist.v2d8) * size) : \
+     (hv_versions.dom_interface == 7 ?                        \
       memset(domlist.v2d7, 0, sizeof(*domlist.v2d7) * size) : \
      (hv_versions.dom_interface == 6 ?                        \
       memset(domlist.v2d6, 0, sizeof(*domlist.v2d6) * size) : \
      (hv_versions.dom_interface == 5 ?                        \
       memset(domlist.v2d5, 0, sizeof(*domlist.v2d5) * size) : \
-      memset(domlist.v2, 0, sizeof(*domlist.v2) * size)))))
+      memset(domlist.v2, 0, sizeof(*domlist.v2) * size))))))
 
 #define XEN_GETDOMAININFOLIST_DOMAIN(domlist, n)    \
     (hv_versions.hypervisor < 2 ?                   \
      domlist.v0[n].domain :                         \
-     (hv_versions.dom_interface >= 7 ?              \
+     (hv_versions.dom_interface >= 8 ?              \
+      domlist.v2d8[n].domain :                      \
+     (hv_versions.dom_interface == 7 ?              \
       domlist.v2d7[n].domain :                      \
      (hv_versions.dom_interface == 6 ?              \
       domlist.v2d6[n].domain :                      \
      (hv_versions.dom_interface == 5 ?              \
       domlist.v2d5[n].domain :                      \
-      domlist.v2[n].domain))))
+      domlist.v2[n].domain)))))
 
 #define XEN_GETDOMAININFOLIST_UUID(domlist, n)      \
     (hv_versions.hypervisor < 2 ?                   \
      domlist.v0[n].handle :                         \
-     (hv_versions.dom_interface >= 7 ?              \
+     (hv_versions.dom_interface >= 8 ?              \
+      domlist.v2d8[n].handle :                      \
+     (hv_versions.dom_interface == 7 ?              \
       domlist.v2d7[n].handle :                      \
      (hv_versions.dom_interface == 6 ?              \
       domlist.v2d6[n].handle :                      \
      (hv_versions.dom_interface == 5 ?              \
       domlist.v2d5[n].handle :                      \
-      domlist.v2[n].handle))))
+      domlist.v2[n].handle)))))
 
 #define XEN_GETDOMAININFOLIST_DATA(domlist)        \
     (hv_versions.hypervisor < 2 ?                  \
      (void*)(domlist->v0) :                        \
-     (hv_versions.dom_interface >= 7 ?             \
+     (hv_versions.dom_interface >= 8 ?             \
+      (void*)(domlist->v2d8) :                     \
+     (hv_versions.dom_interface == 7 ?             \
       (void*)(domlist->v2d7) :                     \
      (hv_versions.dom_interface == 6 ?             \
       (void*)(domlist->v2d6) :                     \
      (hv_versions.dom_interface == 5 ?             \
       (void*)(domlist->v2d5) :                     \
-      (void*)(domlist->v2)))))
+      (void*)(domlist->v2))))))
 
 #define XEN_GETDOMAININFO_SIZE                     \
     (hv_versions.hypervisor < 2 ?                  \
      sizeof(xen_v0_getdomaininfo) :                \
-     (hv_versions.dom_interface >= 7 ?             \
+     (hv_versions.dom_interface >= 8 ?             \
+      sizeof(xen_v2d8_getdomaininfo) :             \
+     (hv_versions.dom_interface == 7 ?             \
       sizeof(xen_v2d7_getdomaininfo) :             \
      (hv_versions.dom_interface == 6 ?             \
       sizeof(xen_v2d6_getdomaininfo) :             \
      (hv_versions.dom_interface == 5 ?             \
       sizeof(xen_v2d5_getdomaininfo) :             \
-      sizeof(xen_v2_getdomaininfo)))))
+      sizeof(xen_v2_getdomaininfo))))))
 
 #define XEN_GETDOMAININFO_CLEAR(dominfo)                           \
     (hv_versions.hypervisor < 2 ?                                  \
      memset(&(dominfo.v0), 0, sizeof(xen_v0_getdomaininfo)) :      \
-     (hv_versions.dom_interface >= 7 ?                             \
+     (hv_versions.dom_interface >= 8 ?                             \
+      memset(&(dominfo.v2d8), 0, sizeof(xen_v2d8_getdomaininfo)) : \
+     (hv_versions.dom_interface == 7 ?                             \
       memset(&(dominfo.v2d7), 0, sizeof(xen_v2d7_getdomaininfo)) : \
      (hv_versions.dom_interface == 6 ?                             \
       memset(&(dominfo.v2d6), 0, sizeof(xen_v2d6_getdomaininfo)) : \
      (hv_versions.dom_interface == 5 ?                             \
       memset(&(dominfo.v2d5), 0, sizeof(xen_v2d5_getdomaininfo)) : \
-      memset(&(dominfo.v2), 0, sizeof(xen_v2_getdomaininfo))))))
+      memset(&(dominfo.v2), 0, sizeof(xen_v2_getdomaininfo)))))))
 
 #define XEN_GETDOMAININFO_DOMAIN(dominfo)       \
     (hv_versions.hypervisor < 2 ?               \
      dominfo.v0.domain :                        \
-     (hv_versions.dom_interface >= 7 ?          \
+     (hv_versions.dom_interface >= 8 ?          \
+      dominfo.v2d8.domain :                     \
+     (hv_versions.dom_interface == 7 ?          \
       dominfo.v2d7.domain :                     \
      (hv_versions.dom_interface == 6 ?          \
       dominfo.v2d6.domain :                     \
      (hv_versions.dom_interface == 5 ?          \
       dominfo.v2d5.domain :                     \
-      dominfo.v2.domain))))
+      dominfo.v2.domain)))))
 
 #define XEN_GETDOMAININFO_CPUTIME(dominfo)      \
     (hv_versions.hypervisor < 2 ?               \
      dominfo.v0.cpu_time :                      \
-     (hv_versions.dom_interface >= 7 ?          \
+     (hv_versions.dom_interface >= 8 ?          \
+      dominfo.v2d8.cpu_time :                   \
+     (hv_versions.dom_interface == 7 ?          \
       dominfo.v2d7.cpu_time :                   \
      (hv_versions.dom_interface == 6 ?          \
       dominfo.v2d6.cpu_time :                   \
      (hv_versions.dom_interface == 5 ?          \
       dominfo.v2d5.cpu_time :                   \
-      dominfo.v2.cpu_time))))
+      dominfo.v2.cpu_time)))))
 
 
 #define XEN_GETDOMAININFO_CPUCOUNT(dominfo)     \
     (hv_versions.hypervisor < 2 ?               \
      dominfo.v0.nr_online_vcpus :               \
-     (hv_versions.dom_interface >= 7 ?          \
+     (hv_versions.dom_interface >= 8 ?          \
+      dominfo.v2d8.nr_online_vcpus :            \
+     (hv_versions.dom_interface == 7 ?          \
       dominfo.v2d7.nr_online_vcpus :            \
      (hv_versions.dom_interface == 6 ?          \
       dominfo.v2d6.nr_online_vcpus :            \
      (hv_versions.dom_interface == 5 ?          \
       dominfo.v2d5.nr_online_vcpus :            \
-      dominfo.v2.nr_online_vcpus))))
+      dominfo.v2.nr_online_vcpus)))))
 
-#define XEN_GETDOMAININFO_MAXCPUID(dominfo)  \
+#define XEN_GETDOMAININFO_MAXCPUID(dominfo)     \
     (hv_versions.hypervisor < 2 ?               \
      dominfo.v0.max_vcpu_id :                   \
-     (hv_versions.dom_interface >= 7 ?          \
+     (hv_versions.dom_interface >= 8 ?          \
+      dominfo.v2d8.max_vcpu_id :                \
+     (hv_versions.dom_interface == 7 ?          \
       dominfo.v2d7.max_vcpu_id :                \
      (hv_versions.dom_interface == 6 ?          \
       dominfo.v2d6.max_vcpu_id :                \
      (hv_versions.dom_interface == 5 ?          \
       dominfo.v2d5.max_vcpu_id :                \
-      dominfo.v2.max_vcpu_id))))
+      dominfo.v2.max_vcpu_id)))))
 
 #define XEN_GETDOMAININFO_FLAGS(dominfo)        \
     (hv_versions.hypervisor < 2 ?               \
      dominfo.v0.flags :                         \
-     (hv_versions.dom_interface >= 7 ?          \
+     (hv_versions.dom_interface >= 8 ?          \
+      dominfo.v2d8.flags :                      \
+     (hv_versions.dom_interface == 7 ?          \
       dominfo.v2d7.flags :                      \
      (hv_versions.dom_interface == 6 ?          \
       dominfo.v2d6.flags :                      \
      (hv_versions.dom_interface == 5 ?          \
       dominfo.v2d5.flags :                      \
-      dominfo.v2.flags))))
+      dominfo.v2.flags)))))
 
 #define XEN_GETDOMAININFO_TOT_PAGES(dominfo)    \
     (hv_versions.hypervisor < 2 ?               \
      dominfo.v0.tot_pages :                     \
-     (hv_versions.dom_interface >= 7 ?          \
+     (hv_versions.dom_interface >= 8 ?          \
+      dominfo.v2d8.tot_pages :                  \
+     (hv_versions.dom_interface == 7 ?          \
       dominfo.v2d7.tot_pages :                  \
      (hv_versions.dom_interface == 6 ?          \
       dominfo.v2d6.tot_pages :                  \
      (hv_versions.dom_interface == 5 ?          \
       dominfo.v2d5.tot_pages :                  \
-      dominfo.v2.tot_pages))))
+      dominfo.v2.tot_pages)))))
 
 #define XEN_GETDOMAININFO_MAX_PAGES(dominfo)    \
     (hv_versions.hypervisor < 2 ?               \
      dominfo.v0.max_pages :                     \
-     (hv_versions.dom_interface >= 7 ?          \
+     (hv_versions.dom_interface >= 8 ?          \
+      dominfo.v2d8.max_pages :                  \
+     (hv_versions.dom_interface == 7 ?          \
       dominfo.v2d7.max_pages :                  \
      (hv_versions.dom_interface == 6 ?          \
       dominfo.v2d6.max_pages :                  \
      (hv_versions.dom_interface == 5 ?          \
       dominfo.v2d5.max_pages :                  \
-      dominfo.v2.max_pages))))
+      dominfo.v2.max_pages)))))
 
 #define XEN_GETDOMAININFO_UUID(dominfo)         \
     (hv_versions.hypervisor < 2 ?               \
      dominfo.v0.handle :                        \
-     (hv_versions.dom_interface >= 7 ?          \
+     (hv_versions.dom_interface >= 8 ?          \
+      dominfo.v2d8.handle :                     \
+     (hv_versions.dom_interface == 7 ?          \
       dominfo.v2d7.handle :                     \
      (hv_versions.dom_interface == 6 ?          \
       dominfo.v2d6.handle :                     \
      (hv_versions.dom_interface == 5 ?          \
       dominfo.v2d5.handle :                     \
-      dominfo.v2.handle))))
+      dominfo.v2.handle)))))
 
 
 static int
@@ -2142,12 +2193,20 @@ xenHypervisorInit(struct xenHypervisorVersions *override_versions)
     /* Xen 4.1
      * sysctl version 8 -> xen-unstable c/s 21118:28e5409e3fb3
      * domctl version 7 -> xen-unstable c/s 21212:de94884a669c
+     * domctl version 8 -> xen-unstable c/s 23874:651aed73b39c
      */
     hv_versions.sys_interface = 8; /* XEN_SYSCTL_INTERFACE_VERSION */
     if (virXen_getdomaininfo(fd, 0, &info) == 1) {
         hv_versions.dom_interface = 7; /* XEN_DOMCTL_INTERFACE_VERSION */
-        VIR_DEBUG("Using hypervisor call v2, sys ver8 dom ver7\n");
-        goto done;
+        if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+            VIR_DEBUG("Using hypervisor call v2, sys ver8 dom ver7");
+            goto done;
+        }
+        hv_versions.dom_interface = 8; /* XEN_DOMCTL_INTERFACE_VERSION */
+        if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+            VIR_DEBUG("Using hypervisor call v2, sys ver8 dom ver8");
+            goto done;
+        }
     }
 
     hv_versions.hypervisor = 1;
-- 
1.7.7

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