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

[Xen-devel] [PATCH 3/8] libxc: allow xc_get/set_hvm_param() to get/set 64-bit values



HVMOP_get_param and HVMOP_set_param take a uint32_t for the parameter
index and a uint64_t for the value.  So, make the corresponding libxc
function take the same types.

Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx>
---
 tools/libxc/xc_cpuid_x86.c          |   11 +++++------
 tools/libxc/xc_domain.c             |    4 ++--
 tools/libxc/xc_domain_save.c        |   33 +++++++++++----------------------
 tools/libxc/xc_resume.c             |    2 +-
 tools/libxc/xenctrl.h               |    4 ++--
 tools/libxl/libxl.c                 |    2 +-
 tools/libxl/libxl_dom.c             |   10 +++++++---
 tools/python/xen/lowlevel/xc/xc.c   |    4 ++--
 tools/tests/xen-access/xen-access.c |    5 +++--
 9 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index 4772ca7..0541bc6 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -276,13 +276,12 @@ static void xc_cpuid_hvm_policy(
 {
     DECLARE_DOMCTL;
     char brand[13];
-    unsigned long nestedhvm;
-    unsigned long pae;
+    uint64_t val;
     int is_pae, is_nestedhvm;
     uint64_t xfeature_mask;
 
-    xc_get_hvm_param(xch, domid, HVM_PARAM_PAE_ENABLED, &pae);
-    is_pae = !!pae;
+    xc_get_hvm_param(xch, domid, HVM_PARAM_PAE_ENABLED, &val);
+    is_pae = !!val;
 
     /* Detecting Xen's atitude towards XSAVE */
     memset(&domctl, 0, sizeof(domctl));
@@ -291,8 +290,8 @@ static void xc_cpuid_hvm_policy(
     do_domctl(xch, &domctl);
     xfeature_mask = domctl.u.vcpuextstate.xfeature_mask;
 
-    xc_get_hvm_param(xch, domid, HVM_PARAM_NESTEDHVM, &nestedhvm);
-    is_nestedhvm = !!nestedhvm;
+    xc_get_hvm_param(xch, domid, HVM_PARAM_NESTEDHVM, &val);
+    is_nestedhvm = !!val;
 
     switch ( input[0] )
     {
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 369c3f3..39786fd 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -1242,7 +1242,7 @@ int xc_domain_send_trigger(xc_interface *xch,
     return do_domctl(xch, &domctl);
 }
 
-int xc_set_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned 
long value)
+int xc_set_hvm_param(xc_interface *handle, domid_t dom, uint32_t param, 
uint64_t value)
 {
     DECLARE_HYPERCALL;
     DECLARE_HYPERCALL_BUFFER(xen_hvm_param_t, arg);
@@ -1263,7 +1263,7 @@ int xc_set_hvm_param(xc_interface *handle, domid_t dom, 
int param, unsigned long
     return rc;
 }
 
-int xc_get_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned 
long *value)
+int xc_get_hvm_param(xc_interface *handle, domid_t dom, uint32_t param, 
uint64_t *value)
 {
     DECLARE_HYPERCALL;
     DECLARE_HYPERCALL_BUFFER(xen_hvm_param_t, arg);
diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c
index 71f9b59..5c6c517 100644
--- a/tools/libxc/xc_domain_save.c
+++ b/tools/libxc/xc_domain_save.c
@@ -1645,8 +1645,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t 
dom, uint32_t max_iter
 
         chunk.id = XC_SAVE_ID_HVM_IDENT_PT;
         chunk.data = 0;
-        xc_get_hvm_param(xch, dom, HVM_PARAM_IDENT_PT,
-                         (unsigned long *)&chunk.data);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_IDENT_PT, &chunk.data);
 
         if ( (chunk.data != 0) &&
              wrexact(io_fd, &chunk, sizeof(chunk)) )
@@ -1657,8 +1656,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t 
dom, uint32_t max_iter
 
         chunk.id = XC_SAVE_ID_HVM_PAGING_RING_PFN;
         chunk.data = 0;
-        xc_get_hvm_param(xch, dom, HVM_PARAM_PAGING_RING_PFN,
-                         (unsigned long *)&chunk.data);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_PAGING_RING_PFN, &chunk.data);
 
         if ( (chunk.data != 0) &&
              wrexact(io_fd, &chunk, sizeof(chunk)) )
@@ -1669,8 +1667,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t 
dom, uint32_t max_iter
 
         chunk.id = XC_SAVE_ID_HVM_ACCESS_RING_PFN;
         chunk.data = 0;
-        xc_get_hvm_param(xch, dom, HVM_PARAM_ACCESS_RING_PFN,
-                         (unsigned long *)&chunk.data);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_ACCESS_RING_PFN, &chunk.data);
 
         if ( (chunk.data != 0) &&
              wrexact(io_fd, &chunk, sizeof(chunk)) )
@@ -1681,8 +1678,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t 
dom, uint32_t max_iter
 
         chunk.id = XC_SAVE_ID_HVM_SHARING_RING_PFN;
         chunk.data = 0;
-        xc_get_hvm_param(xch, dom, HVM_PARAM_SHARING_RING_PFN,
-                         (unsigned long *)&chunk.data);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_SHARING_RING_PFN, &chunk.data);
 
         if ( (chunk.data != 0) &&
              wrexact(io_fd, &chunk, sizeof(chunk)) )
@@ -1693,8 +1689,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t 
dom, uint32_t max_iter
 
         chunk.id = XC_SAVE_ID_HVM_VM86_TSS;
         chunk.data = 0;
-        xc_get_hvm_param(xch, dom, HVM_PARAM_VM86_TSS,
-                         (unsigned long *)&chunk.data);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_VM86_TSS, &chunk.data);
 
         if ( (chunk.data != 0) &&
              wrexact(io_fd, &chunk, sizeof(chunk)) )
@@ -1705,8 +1700,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t 
dom, uint32_t max_iter
 
         chunk.id = XC_SAVE_ID_HVM_CONSOLE_PFN;
         chunk.data = 0;
-        xc_get_hvm_param(xch, dom, HVM_PARAM_CONSOLE_PFN,
-                         (unsigned long *)&chunk.data);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_CONSOLE_PFN, &chunk.data);
 
         if ( (chunk.data != 0) &&
              wrexact(io_fd, &chunk, sizeof(chunk)) )
@@ -1717,8 +1711,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t 
dom, uint32_t max_iter
 
         chunk.id = XC_SAVE_ID_HVM_ACPI_IOPORTS_LOCATION;
         chunk.data = 0;
-        xc_get_hvm_param(xch, dom, HVM_PARAM_ACPI_IOPORTS_LOCATION,
-                         (unsigned long *)&chunk.data);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_ACPI_IOPORTS_LOCATION, 
&chunk.data);
 
         if ((chunk.data != 0) && wrexact(io_fd, &chunk, sizeof(chunk)))
         {
@@ -1728,8 +1721,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t 
dom, uint32_t max_iter
 
         chunk.id = XC_SAVE_ID_HVM_VIRIDIAN;
         chunk.data = 0;
-        xc_get_hvm_param(xch, dom, HVM_PARAM_VIRIDIAN,
-                         (unsigned long *)&chunk.data);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_VIRIDIAN, &chunk.data);
 
         if ( (chunk.data != 0) &&
              wrexact(io_fd, &chunk, sizeof(chunk)) )
@@ -1803,12 +1795,9 @@ int xc_domain_save(xc_interface *xch, int io_fd, 
uint32_t dom, uint32_t max_iter
 
         /* Save magic-page locations. */
         memset(magic_pfns, 0, sizeof(magic_pfns));
-        xc_get_hvm_param(xch, dom, HVM_PARAM_IOREQ_PFN,
-                         (unsigned long *)&magic_pfns[0]);
-        xc_get_hvm_param(xch, dom, HVM_PARAM_BUFIOREQ_PFN,
-                         (unsigned long *)&magic_pfns[1]);
-        xc_get_hvm_param(xch, dom, HVM_PARAM_STORE_PFN,
-                         (unsigned long *)&magic_pfns[2]);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_IOREQ_PFN, &magic_pfns[0]);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_BUFIOREQ_PFN, &magic_pfns[1]);
+        xc_get_hvm_param(xch, dom, HVM_PARAM_STORE_PFN, &magic_pfns[2]);
         if ( wrexact(io_fd, magic_pfns, sizeof(magic_pfns)) )
         {
             PERROR("Error when writing to state file (7)");
diff --git a/tools/libxc/xc_resume.c b/tools/libxc/xc_resume.c
index e423814..226b5e9 100644
--- a/tools/libxc/xc_resume.c
+++ b/tools/libxc/xc_resume.c
@@ -51,7 +51,7 @@ static int modify_returncode(xc_interface *xch, uint32_t 
domid)
     if ( info.hvm )
     {
         /* HVM guests without PV drivers have no return code to modify. */
-        unsigned long irq = 0;
+        uint64_t irq = 0;
         xc_get_hvm_param(xch, domid, HVM_PARAM_CALLBACK_IRQ, &irq);
         if ( !irq )
             return 0;
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index 02129f7..fff9be1 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -1784,8 +1784,8 @@ const xc_error *xc_get_last_error(xc_interface *handle);
 void xc_clear_last_error(xc_interface *xch);
 
 
-int xc_set_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned 
long value);
-int xc_get_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned 
long *value);
+int xc_set_hvm_param(xc_interface *handle, domid_t dom, uint32_t param, 
uint64_t value);
+int xc_get_hvm_param(xc_interface *handle, domid_t dom, uint32_t param, 
uint64_t *value);
 
 /* HVM guest pass-through */
 int xc_assign_device(xc_interface *xch,
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 900b8d4..808c44e 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -872,7 +872,7 @@ int libxl__domain_pvcontrol_available(libxl__gc *gc, 
uint32_t domid)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
 
-    unsigned long pvdriver = 0;
+    uint64_t pvdriver = 0;
     int ret;
 
     libxl_domain_type domtype = libxl__domain_type(gc, domid);
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 661999c..b8cc40c 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -490,6 +490,7 @@ static int hvm_build_set_params(xc_interface *handle, 
uint32_t domid,
 {
     struct hvm_info_table *va_hvm;
     uint8_t *va_map, sum;
+    uint64_t str_mfn, cons_mfn;
     int i;
 
     va_map = xc_map_foreign_range(handle, domid,
@@ -508,11 +509,14 @@ static int hvm_build_set_params(xc_interface *handle, 
uint32_t domid,
     va_hvm->checksum -= sum;
     munmap(va_map, XC_PAGE_SIZE);
 
-    xc_get_hvm_param(handle, domid, HVM_PARAM_STORE_PFN, store_mfn);
-    xc_get_hvm_param(handle, domid, HVM_PARAM_CONSOLE_PFN, console_mfn);
+    xc_get_hvm_param(handle, domid, HVM_PARAM_STORE_PFN, &str_mfn);
+    xc_get_hvm_param(handle, domid, HVM_PARAM_CONSOLE_PFN, &cons_mfn);
     xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN, store_evtchn);
     xc_set_hvm_param(handle, domid, HVM_PARAM_CONSOLE_EVTCHN, console_evtchn);
 
+    *store_mfn = str_mfn;
+    *console_mfn = cons_mfn;
+
     xc_dom_gnttab_hvm_seed(handle, domid, *console_mfn, *store_mfn, 
console_domid, store_domid);
     return 0;
 }
@@ -1070,7 +1074,7 @@ static void domain_suspend_callback_common(libxl__egc 
*egc,
                                            libxl__domain_suspend_state *dss)
 {
     STATE_AO_GC(dss->ao);
-    unsigned long hvm_s_state = 0, hvm_pvdrv = 0;
+    uint64_t hvm_s_state = 0, hvm_pvdrv = 0;
     int ret, rc;
 
     /* Convenience aliases */
diff --git a/tools/python/xen/lowlevel/xc/xc.c 
b/tools/python/xen/lowlevel/xc/xc.c
index cb34446..43ac133 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -550,7 +550,7 @@ static PyObject *pyxc_get_hvm_param(XcObject *self,
 {
     uint32_t dom;
     int param;
-    unsigned long value;
+    uint64_t value;
 
     static char *kwd_list[] = { "domid", "param", NULL }; 
     if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
@@ -560,7 +560,7 @@ static PyObject *pyxc_get_hvm_param(XcObject *self,
     if ( xc_get_hvm_param(self->xc_handle, dom, param, &value) != 0 )
         return pyxc_error_to_exception(self->xc_handle);
 
-    return PyLong_FromUnsignedLong(value);
+    return PyLong_FromUnsignedLongLong(value);
 
 }
 
diff --git a/tools/tests/xen-access/xen-access.c 
b/tools/tests/xen-access/xen-access.c
index 0a84bd5..d493f21 100644
--- a/tools/tests/xen-access/xen-access.c
+++ b/tools/tests/xen-access/xen-access.c
@@ -223,6 +223,7 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t 
domain_id)
     xenaccess_t *xenaccess = 0;
     xc_interface *xch;
     int rc;
+    uint64_t val;
     unsigned long ring_pfn, mmap_pfn;
 
     xch = xc_interface_open(NULL, NULL, 0);
@@ -247,8 +248,8 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t 
domain_id)
 
     /* Map the ring page */
     xc_get_hvm_param(xch, xenaccess->mem_event.domain_id, 
-                        HVM_PARAM_ACCESS_RING_PFN, &ring_pfn);
-    mmap_pfn = ring_pfn;
+                        HVM_PARAM_ACCESS_RING_PFN, &val);
+    mmap_pfn = ring_pfn = val;
     xenaccess->mem_event.ring_page = 
         xc_map_foreign_batch(xch, xenaccess->mem_event.domain_id, 
                                 PROT_READ | PROT_WRITE, &mmap_pfn, 1);
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.