All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/5] xen: use new xendevicemodel library
@ 2017-02-23 14:53 ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel; +Cc: Paul Durrant

My recent patches to Xen [1] introduced a new library to support
running device models for HVM guests.
This series ports QEMU onto the new library if it is available in the
build environment.

Paul Durrant (5):
  xen: make use of xen_xc implicit in xen_common.h inlines
  xen: rename xen_modified_memory() to xen_hvm_modified_memory()
  xen: create wrappers for all other uses of xc_hvm_XXX() functions
  configure: detect presence of libxendevicemodel
  xen: use libxendevicemodel when available

 configure                    |  19 ++++
 hw/i386/xen/xen_platform.c   |   2 +-
 hw/xen/xen_backend.c         |   2 -
 include/exec/ram_addr.h      |   4 +-
 include/hw/xen/xen.h         |   2 +-
 include/hw/xen/xen_backend.h |   2 -
 include/hw/xen/xen_common.h  | 200 ++++++++++++++++++++++++++++++++-----------
 xen-common.c                 |  11 +++
 xen-hvm-stub.c               |   2 +-
 xen-hvm.c                    |  49 ++++++-----
 10 files changed, 207 insertions(+), 86 deletions(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH 0/5] xen: use new xendevicemodel library
@ 2017-02-23 14:53 ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel; +Cc: Paul Durrant

My recent patches to Xen [1] introduced a new library to support
running device models for HVM guests.
This series ports QEMU onto the new library if it is available in the
build environment.

Paul Durrant (5):
  xen: make use of xen_xc implicit in xen_common.h inlines
  xen: rename xen_modified_memory() to xen_hvm_modified_memory()
  xen: create wrappers for all other uses of xc_hvm_XXX() functions
  configure: detect presence of libxendevicemodel
  xen: use libxendevicemodel when available

 configure                    |  19 ++++
 hw/i386/xen/xen_platform.c   |   2 +-
 hw/xen/xen_backend.c         |   2 -
 include/exec/ram_addr.h      |   4 +-
 include/hw/xen/xen.h         |   2 +-
 include/hw/xen/xen_backend.h |   2 -
 include/hw/xen/xen_common.h  | 200 ++++++++++++++++++++++++++++++++-----------
 xen-common.c                 |  11 +++
 xen-hvm-stub.c               |   2 +-
 xen-hvm.c                    |  49 ++++++-----
 10 files changed, 207 insertions(+), 86 deletions(-)

-- 
2.1.4


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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH 1/5] xen: make use of xen_xc implicit in xen_common.h inlines
  2017-02-23 14:53 ` Paul Durrant
@ 2017-02-23 14:53   ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel; +Cc: Paul Durrant, Stefano Stabellini, Anthony Perard

Doing this will make the transition to using the new libxendevicemodel
interface less intrusive on the callers of these functions, since using
the new library will require a change of handle.

NOTE: The patch also moves the 'externs' for xen_xc and xen_fmem from
      xen_backend.h to xen_common.h, and the declarations from
      xen_backend.c to xen-common.c, which is where they belong.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
---
 hw/xen/xen_backend.c         |  2 -
 include/hw/xen/xen_backend.h |  2 -
 include/hw/xen/xen_common.h  | 90 +++++++++++++++++++++++---------------------
 xen-common.c                 |  3 ++
 xen-hvm.c                    | 20 +++++-----
 5 files changed, 60 insertions(+), 57 deletions(-)

diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
index 6c21c37..d34c49e 100644
--- a/hw/xen/xen_backend.c
+++ b/hw/xen/xen_backend.c
@@ -43,8 +43,6 @@ BusState *xen_sysbus;
 /* ------------------------------------------------------------- */
 
 /* public */
-xc_interface *xen_xc = NULL;
-xenforeignmemory_handle *xen_fmem = NULL;
 struct xs_handle *xenstore = NULL;
 const char *xen_protocol;
 
diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h
index 4f4799a..30811a1 100644
--- a/include/hw/xen/xen_backend.h
+++ b/include/hw/xen/xen_backend.h
@@ -14,8 +14,6 @@
     OBJECT_CHECK(XenDevice, (obj), TYPE_XENBACKEND)
 
 /* variables */
-extern xc_interface *xen_xc;
-extern xenforeignmemory_handle *xen_fmem;
 extern struct xs_handle *xenstore;
 extern const char *xen_protocol;
 extern DeviceState *xen_sysdev;
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index dce76ee..1e08b98 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -20,6 +20,8 @@
 #include "qemu/queue.h"
 #include "hw/xen/trace.h"
 
+extern xc_interface *xen_xc;
+
 /*
  * We don't support Xen prior to 4.2.0.
  */
@@ -73,6 +75,8 @@ static inline void *xenforeignmemory_map(xc_interface *h, uint32_t dom,
 
 #endif
 
+extern xenforeignmemory_handle *xen_fmem;
+
 void destroy_hvm_domain(bool reboot);
 
 /* shutdown/destroy current domain because of an error */
@@ -107,8 +111,7 @@ static inline int xen_get_vmport_regs_pfn(xc_interface *xc, domid_t dom,
 
 #endif
 
-static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
-                                                    domid_t dom,
+static inline int xen_get_default_ioreq_server_info(domid_t dom,
                                                     xen_pfn_t *ioreq_pfn,
                                                     xen_pfn_t *bufioreq_pfn,
                                                     evtchn_port_t
@@ -117,7 +120,7 @@ static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
     unsigned long param;
     int rc;
 
-    rc = xc_get_hvm_param(xc, dom, HVM_PARAM_IOREQ_PFN, &param);
+    rc = xc_get_hvm_param(xen_xc, dom, HVM_PARAM_IOREQ_PFN, &param);
     if (rc < 0) {
         fprintf(stderr, "failed to get HVM_PARAM_IOREQ_PFN\n");
         return -1;
@@ -125,7 +128,7 @@ static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
 
     *ioreq_pfn = param;
 
-    rc = xc_get_hvm_param(xc, dom, HVM_PARAM_BUFIOREQ_PFN, &param);
+    rc = xc_get_hvm_param(xen_xc, dom, HVM_PARAM_BUFIOREQ_PFN, &param);
     if (rc < 0) {
         fprintf(stderr, "failed to get HVM_PARAM_BUFIOREQ_PFN\n");
         return -1;
@@ -133,7 +136,7 @@ static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
 
     *bufioreq_pfn = param;
 
-    rc = xc_get_hvm_param(xc, dom, HVM_PARAM_BUFIOREQ_EVTCHN,
+    rc = xc_get_hvm_param(xen_xc, dom, HVM_PARAM_BUFIOREQ_EVTCHN,
                           &param);
     if (rc < 0) {
         fprintf(stderr, "failed to get HVM_PARAM_BUFIOREQ_EVTCHN\n");
@@ -156,63 +159,64 @@ static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
 
 typedef uint16_t ioservid_t;
 
-static inline void xen_map_memory_section(xc_interface *xc, domid_t dom,
+static inline void xen_map_memory_section(domid_t dom,
                                           ioservid_t ioservid,
                                           MemoryRegionSection *section)
 {
 }
 
-static inline void xen_unmap_memory_section(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_memory_section(domid_t dom,
                                             ioservid_t ioservid,
                                             MemoryRegionSection *section)
 {
 }
 
-static inline void xen_map_io_section(xc_interface *xc, domid_t dom,
+static inline void xen_map_io_section(domid_t dom,
                                       ioservid_t ioservid,
                                       MemoryRegionSection *section)
 {
 }
 
-static inline void xen_unmap_io_section(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_io_section(domid_t dom,
                                         ioservid_t ioservid,
                                         MemoryRegionSection *section)
 {
 }
 
-static inline void xen_map_pcidev(xc_interface *xc, domid_t dom,
+static inline void xen_map_pcidev(domid_t dom,
                                   ioservid_t ioservid,
                                   PCIDevice *pci_dev)
 {
 }
 
-static inline void xen_unmap_pcidev(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_pcidev(domid_t dom,
                                     ioservid_t ioservid,
                                     PCIDevice *pci_dev)
 {
 }
 
-static inline void xen_create_ioreq_server(xc_interface *xc, domid_t dom,
+static inline void xen_create_ioreq_server(domid_t dom,
                                            ioservid_t *ioservid)
 {
 }
 
-static inline void xen_destroy_ioreq_server(xc_interface *xc, domid_t dom,
+static inline void xen_destroy_ioreq_server(domid_t dom,
                                             ioservid_t ioservid)
 {
 }
 
-static inline int xen_get_ioreq_server_info(xc_interface *xc, domid_t dom,
+static inline int xen_get_ioreq_server_info(domid_t dom,
                                             ioservid_t ioservid,
                                             xen_pfn_t *ioreq_pfn,
                                             xen_pfn_t *bufioreq_pfn,
                                             evtchn_port_t *bufioreq_evtchn)
 {
-    return xen_get_default_ioreq_server_info(xc, dom, ioreq_pfn, bufioreq_pfn,
+    return xen_get_default_ioreq_server_info(dom, ioreq_pfn,
+                                             bufioreq_pfn,
                                              bufioreq_evtchn);
 }
 
-static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom,
+static inline int xen_set_ioreq_server_state(domid_t dom,
                                              ioservid_t ioservid,
                                              bool enable)
 {
@@ -224,7 +228,7 @@ static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom,
 
 static bool use_default_ioreq_server;
 
-static inline void xen_map_memory_section(xc_interface *xc, domid_t dom,
+static inline void xen_map_memory_section(domid_t dom,
                                           ioservid_t ioservid,
                                           MemoryRegionSection *section)
 {
@@ -237,11 +241,11 @@ static inline void xen_map_memory_section(xc_interface *xc, domid_t dom,
     }
 
     trace_xen_map_mmio_range(ioservid, start_addr, end_addr);
-    xc_hvm_map_io_range_to_ioreq_server(xc, dom, ioservid, 1,
+    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 1,
                                         start_addr, end_addr);
 }
 
-static inline void xen_unmap_memory_section(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_memory_section(domid_t dom,
                                             ioservid_t ioservid,
                                             MemoryRegionSection *section)
 {
@@ -253,13 +257,12 @@ static inline void xen_unmap_memory_section(xc_interface *xc, domid_t dom,
         return;
     }
 
-
     trace_xen_unmap_mmio_range(ioservid, start_addr, end_addr);
-    xc_hvm_unmap_io_range_from_ioreq_server(xc, dom, ioservid, 1,
-                                            start_addr, end_addr);
+    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
+                                            1, start_addr, end_addr);
 }
 
-static inline void xen_map_io_section(xc_interface *xc, domid_t dom,
+static inline void xen_map_io_section(domid_t dom,
                                       ioservid_t ioservid,
                                       MemoryRegionSection *section)
 {
@@ -271,13 +274,12 @@ static inline void xen_map_io_section(xc_interface *xc, domid_t dom,
         return;
     }
 
-
     trace_xen_map_portio_range(ioservid, start_addr, end_addr);
-    xc_hvm_map_io_range_to_ioreq_server(xc, dom, ioservid, 0,
+    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 0,
                                         start_addr, end_addr);
 }
 
-static inline void xen_unmap_io_section(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_io_section(domid_t dom,
                                         ioservid_t ioservid,
                                         MemoryRegionSection *section)
 {
@@ -290,11 +292,11 @@ static inline void xen_unmap_io_section(xc_interface *xc, domid_t dom,
     }
 
     trace_xen_unmap_portio_range(ioservid, start_addr, end_addr);
-    xc_hvm_unmap_io_range_from_ioreq_server(xc, dom, ioservid, 0,
-                                            start_addr, end_addr);
+    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
+                                            0, start_addr, end_addr);
 }
 
-static inline void xen_map_pcidev(xc_interface *xc, domid_t dom,
+static inline void xen_map_pcidev(domid_t dom,
                                   ioservid_t ioservid,
                                   PCIDevice *pci_dev)
 {
@@ -304,13 +306,13 @@ static inline void xen_map_pcidev(xc_interface *xc, domid_t dom,
 
     trace_xen_map_pcidev(ioservid, pci_bus_num(pci_dev->bus),
                          PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
-    xc_hvm_map_pcidev_to_ioreq_server(xc, dom, ioservid,
-                                      0, pci_bus_num(pci_dev->bus),
+    xc_hvm_map_pcidev_to_ioreq_server(xen_xc, dom, ioservid, 0,
+                                      pci_bus_num(pci_dev->bus),
                                       PCI_SLOT(pci_dev->devfn),
                                       PCI_FUNC(pci_dev->devfn));
 }
 
-static inline void xen_unmap_pcidev(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_pcidev(domid_t dom,
                                     ioservid_t ioservid,
                                     PCIDevice *pci_dev)
 {
@@ -320,16 +322,17 @@ static inline void xen_unmap_pcidev(xc_interface *xc, domid_t dom,
 
     trace_xen_unmap_pcidev(ioservid, pci_bus_num(pci_dev->bus),
                            PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
-    xc_hvm_unmap_pcidev_from_ioreq_server(xc, dom, ioservid,
-                                          0, pci_bus_num(pci_dev->bus),
+    xc_hvm_unmap_pcidev_from_ioreq_server(xen_xc, dom, ioservid, 0,
+                                          pci_bus_num(pci_dev->bus),
                                           PCI_SLOT(pci_dev->devfn),
                                           PCI_FUNC(pci_dev->devfn));
 }
 
-static inline void xen_create_ioreq_server(xc_interface *xc, domid_t dom,
+static inline void xen_create_ioreq_server(domid_t dom,
                                            ioservid_t *ioservid)
 {
-    int rc = xc_hvm_create_ioreq_server(xc, dom, HVM_IOREQSRV_BUFIOREQ_ATOMIC,
+    int rc = xc_hvm_create_ioreq_server(xen_xc, dom,
+                                        HVM_IOREQSRV_BUFIOREQ_ATOMIC,
                                         ioservid);
 
     if (rc == 0) {
@@ -342,7 +345,7 @@ static inline void xen_create_ioreq_server(xc_interface *xc, domid_t dom,
     trace_xen_default_ioreq_server();
 }
 
-static inline void xen_destroy_ioreq_server(xc_interface *xc, domid_t dom,
+static inline void xen_destroy_ioreq_server(domid_t dom,
                                             ioservid_t ioservid)
 {
     if (use_default_ioreq_server) {
@@ -350,27 +353,27 @@ static inline void xen_destroy_ioreq_server(xc_interface *xc, domid_t dom,
     }
 
     trace_xen_ioreq_server_destroy(ioservid);
-    xc_hvm_destroy_ioreq_server(xc, dom, ioservid);
+    xc_hvm_destroy_ioreq_server(xen_xc, dom, ioservid);
 }
 
-static inline int xen_get_ioreq_server_info(xc_interface *xc, domid_t dom,
+static inline int xen_get_ioreq_server_info(domid_t dom,
                                             ioservid_t ioservid,
                                             xen_pfn_t *ioreq_pfn,
                                             xen_pfn_t *bufioreq_pfn,
                                             evtchn_port_t *bufioreq_evtchn)
 {
     if (use_default_ioreq_server) {
-        return xen_get_default_ioreq_server_info(xc, dom, ioreq_pfn,
+        return xen_get_default_ioreq_server_info(dom, ioreq_pfn,
                                                  bufioreq_pfn,
                                                  bufioreq_evtchn);
     }
 
-    return xc_hvm_get_ioreq_server_info(xc, dom, ioservid,
+    return xc_hvm_get_ioreq_server_info(xen_xc, dom, ioservid,
                                         ioreq_pfn, bufioreq_pfn,
                                         bufioreq_evtchn);
 }
 
-static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom,
+static inline int xen_set_ioreq_server_state(domid_t dom,
                                              ioservid_t ioservid,
                                              bool enable)
 {
@@ -379,7 +382,8 @@ static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom,
     }
 
     trace_xen_ioreq_server_state(ioservid, enable);
-    return xc_hvm_set_ioreq_server_state(xc, dom, ioservid, enable);
+    return xc_hvm_set_ioreq_server_state(xen_xc, dom, ioservid,
+                                         enable);
 }
 
 #endif
diff --git a/xen-common.c b/xen-common.c
index fd2c928..703e7a5 100644
--- a/xen-common.c
+++ b/xen-common.c
@@ -25,6 +25,9 @@
     do { } while (0)
 #endif
 
+xc_interface *xen_xc;
+xenforeignmemory_handle *xen_fmem;
+
 static int store_dev_info(int domid, Chardev *cs, const char *string)
 {
     struct xs_handle *xs = NULL;
diff --git a/xen-hvm.c b/xen-hvm.c
index 5043beb..dbb8c66 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -454,10 +454,10 @@ static void xen_set_memory(struct MemoryListener *listener,
         return;
     } else {
         if (add) {
-            xen_map_memory_section(xen_xc, xen_domid, state->ioservid,
+            xen_map_memory_section(xen_domid, state->ioservid,
                                    section);
         } else {
-            xen_unmap_memory_section(xen_xc, xen_domid, state->ioservid,
+            xen_unmap_memory_section(xen_domid, state->ioservid,
                                      section);
         }
     }
@@ -521,7 +521,7 @@ static void xen_io_add(MemoryListener *listener,
 
     memory_region_ref(mr);
 
-    xen_map_io_section(xen_xc, xen_domid, state->ioservid, section);
+    xen_map_io_section(xen_domid, state->ioservid, section);
 }
 
 static void xen_io_del(MemoryListener *listener,
@@ -534,7 +534,7 @@ static void xen_io_del(MemoryListener *listener,
         return;
     }
 
-    xen_unmap_io_section(xen_xc, xen_domid, state->ioservid, section);
+    xen_unmap_io_section(xen_domid, state->ioservid, section);
 
     memory_region_unref(mr);
 }
@@ -547,7 +547,7 @@ static void xen_device_realize(DeviceListener *listener,
     if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
         PCIDevice *pci_dev = PCI_DEVICE(dev);
 
-        xen_map_pcidev(xen_xc, xen_domid, state->ioservid, pci_dev);
+        xen_map_pcidev(xen_domid, state->ioservid, pci_dev);
     }
 }
 
@@ -559,7 +559,7 @@ static void xen_device_unrealize(DeviceListener *listener,
     if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
         PCIDevice *pci_dev = PCI_DEVICE(dev);
 
-        xen_unmap_pcidev(xen_xc, xen_domid, state->ioservid, pci_dev);
+        xen_unmap_pcidev(xen_domid, state->ioservid, pci_dev);
     }
 }
 
@@ -1139,7 +1139,7 @@ static void xen_hvm_change_state_handler(void *opaque, int running,
         xen_main_loop_prepare(state);
     }
 
-    xen_set_ioreq_server_state(xen_xc, xen_domid,
+    xen_set_ioreq_server_state(xen_domid,
                                state->ioservid,
                                (rstate == RUN_STATE_RUNNING));
 }
@@ -1227,7 +1227,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
         goto err;
     }
 
-    xen_create_ioreq_server(xen_xc, xen_domid, &state->ioservid);
+    xen_create_ioreq_server(xen_domid, &state->ioservid);
 
     state->exit.notify = xen_exit_notifier;
     qemu_add_exit_notifier(&state->exit);
@@ -1238,7 +1238,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
     state->wakeup.notify = xen_wakeup_notifier;
     qemu_register_wakeup_notifier(&state->wakeup);
 
-    rc = xen_get_ioreq_server_info(xen_xc, xen_domid, state->ioservid,
+    rc = xen_get_ioreq_server_info(xen_domid, state->ioservid,
                                    &ioreq_pfn, &bufioreq_pfn,
                                    &bufioreq_evtchn);
     if (rc < 0) {
@@ -1288,7 +1288,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
     /* Note: cpus is empty at this point in init */
     state->cpu_by_vcpu_id = g_malloc0(max_cpus * sizeof(CPUState *));
 
-    rc = xen_set_ioreq_server_state(xen_xc, xen_domid, state->ioservid, true);
+    rc = xen_set_ioreq_server_state(xen_domid, state->ioservid, true);
     if (rc < 0) {
         error_report("failed to enable ioreq server info: error %d handle=%p",
                      errno, xen_xc);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 1/5] xen: make use of xen_xc implicit in xen_common.h inlines
@ 2017-02-23 14:53   ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel; +Cc: Anthony Perard, Paul Durrant, Stefano Stabellini

Doing this will make the transition to using the new libxendevicemodel
interface less intrusive on the callers of these functions, since using
the new library will require a change of handle.

NOTE: The patch also moves the 'externs' for xen_xc and xen_fmem from
      xen_backend.h to xen_common.h, and the declarations from
      xen_backend.c to xen-common.c, which is where they belong.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
---
 hw/xen/xen_backend.c         |  2 -
 include/hw/xen/xen_backend.h |  2 -
 include/hw/xen/xen_common.h  | 90 +++++++++++++++++++++++---------------------
 xen-common.c                 |  3 ++
 xen-hvm.c                    | 20 +++++-----
 5 files changed, 60 insertions(+), 57 deletions(-)

diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
index 6c21c37..d34c49e 100644
--- a/hw/xen/xen_backend.c
+++ b/hw/xen/xen_backend.c
@@ -43,8 +43,6 @@ BusState *xen_sysbus;
 /* ------------------------------------------------------------- */
 
 /* public */
-xc_interface *xen_xc = NULL;
-xenforeignmemory_handle *xen_fmem = NULL;
 struct xs_handle *xenstore = NULL;
 const char *xen_protocol;
 
diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h
index 4f4799a..30811a1 100644
--- a/include/hw/xen/xen_backend.h
+++ b/include/hw/xen/xen_backend.h
@@ -14,8 +14,6 @@
     OBJECT_CHECK(XenDevice, (obj), TYPE_XENBACKEND)
 
 /* variables */
-extern xc_interface *xen_xc;
-extern xenforeignmemory_handle *xen_fmem;
 extern struct xs_handle *xenstore;
 extern const char *xen_protocol;
 extern DeviceState *xen_sysdev;
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index dce76ee..1e08b98 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -20,6 +20,8 @@
 #include "qemu/queue.h"
 #include "hw/xen/trace.h"
 
+extern xc_interface *xen_xc;
+
 /*
  * We don't support Xen prior to 4.2.0.
  */
@@ -73,6 +75,8 @@ static inline void *xenforeignmemory_map(xc_interface *h, uint32_t dom,
 
 #endif
 
+extern xenforeignmemory_handle *xen_fmem;
+
 void destroy_hvm_domain(bool reboot);
 
 /* shutdown/destroy current domain because of an error */
@@ -107,8 +111,7 @@ static inline int xen_get_vmport_regs_pfn(xc_interface *xc, domid_t dom,
 
 #endif
 
-static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
-                                                    domid_t dom,
+static inline int xen_get_default_ioreq_server_info(domid_t dom,
                                                     xen_pfn_t *ioreq_pfn,
                                                     xen_pfn_t *bufioreq_pfn,
                                                     evtchn_port_t
@@ -117,7 +120,7 @@ static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
     unsigned long param;
     int rc;
 
-    rc = xc_get_hvm_param(xc, dom, HVM_PARAM_IOREQ_PFN, &param);
+    rc = xc_get_hvm_param(xen_xc, dom, HVM_PARAM_IOREQ_PFN, &param);
     if (rc < 0) {
         fprintf(stderr, "failed to get HVM_PARAM_IOREQ_PFN\n");
         return -1;
@@ -125,7 +128,7 @@ static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
 
     *ioreq_pfn = param;
 
-    rc = xc_get_hvm_param(xc, dom, HVM_PARAM_BUFIOREQ_PFN, &param);
+    rc = xc_get_hvm_param(xen_xc, dom, HVM_PARAM_BUFIOREQ_PFN, &param);
     if (rc < 0) {
         fprintf(stderr, "failed to get HVM_PARAM_BUFIOREQ_PFN\n");
         return -1;
@@ -133,7 +136,7 @@ static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
 
     *bufioreq_pfn = param;
 
-    rc = xc_get_hvm_param(xc, dom, HVM_PARAM_BUFIOREQ_EVTCHN,
+    rc = xc_get_hvm_param(xen_xc, dom, HVM_PARAM_BUFIOREQ_EVTCHN,
                           &param);
     if (rc < 0) {
         fprintf(stderr, "failed to get HVM_PARAM_BUFIOREQ_EVTCHN\n");
@@ -156,63 +159,64 @@ static inline int xen_get_default_ioreq_server_info(xc_interface *xc,
 
 typedef uint16_t ioservid_t;
 
-static inline void xen_map_memory_section(xc_interface *xc, domid_t dom,
+static inline void xen_map_memory_section(domid_t dom,
                                           ioservid_t ioservid,
                                           MemoryRegionSection *section)
 {
 }
 
-static inline void xen_unmap_memory_section(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_memory_section(domid_t dom,
                                             ioservid_t ioservid,
                                             MemoryRegionSection *section)
 {
 }
 
-static inline void xen_map_io_section(xc_interface *xc, domid_t dom,
+static inline void xen_map_io_section(domid_t dom,
                                       ioservid_t ioservid,
                                       MemoryRegionSection *section)
 {
 }
 
-static inline void xen_unmap_io_section(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_io_section(domid_t dom,
                                         ioservid_t ioservid,
                                         MemoryRegionSection *section)
 {
 }
 
-static inline void xen_map_pcidev(xc_interface *xc, domid_t dom,
+static inline void xen_map_pcidev(domid_t dom,
                                   ioservid_t ioservid,
                                   PCIDevice *pci_dev)
 {
 }
 
-static inline void xen_unmap_pcidev(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_pcidev(domid_t dom,
                                     ioservid_t ioservid,
                                     PCIDevice *pci_dev)
 {
 }
 
-static inline void xen_create_ioreq_server(xc_interface *xc, domid_t dom,
+static inline void xen_create_ioreq_server(domid_t dom,
                                            ioservid_t *ioservid)
 {
 }
 
-static inline void xen_destroy_ioreq_server(xc_interface *xc, domid_t dom,
+static inline void xen_destroy_ioreq_server(domid_t dom,
                                             ioservid_t ioservid)
 {
 }
 
-static inline int xen_get_ioreq_server_info(xc_interface *xc, domid_t dom,
+static inline int xen_get_ioreq_server_info(domid_t dom,
                                             ioservid_t ioservid,
                                             xen_pfn_t *ioreq_pfn,
                                             xen_pfn_t *bufioreq_pfn,
                                             evtchn_port_t *bufioreq_evtchn)
 {
-    return xen_get_default_ioreq_server_info(xc, dom, ioreq_pfn, bufioreq_pfn,
+    return xen_get_default_ioreq_server_info(dom, ioreq_pfn,
+                                             bufioreq_pfn,
                                              bufioreq_evtchn);
 }
 
-static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom,
+static inline int xen_set_ioreq_server_state(domid_t dom,
                                              ioservid_t ioservid,
                                              bool enable)
 {
@@ -224,7 +228,7 @@ static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom,
 
 static bool use_default_ioreq_server;
 
-static inline void xen_map_memory_section(xc_interface *xc, domid_t dom,
+static inline void xen_map_memory_section(domid_t dom,
                                           ioservid_t ioservid,
                                           MemoryRegionSection *section)
 {
@@ -237,11 +241,11 @@ static inline void xen_map_memory_section(xc_interface *xc, domid_t dom,
     }
 
     trace_xen_map_mmio_range(ioservid, start_addr, end_addr);
-    xc_hvm_map_io_range_to_ioreq_server(xc, dom, ioservid, 1,
+    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 1,
                                         start_addr, end_addr);
 }
 
-static inline void xen_unmap_memory_section(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_memory_section(domid_t dom,
                                             ioservid_t ioservid,
                                             MemoryRegionSection *section)
 {
@@ -253,13 +257,12 @@ static inline void xen_unmap_memory_section(xc_interface *xc, domid_t dom,
         return;
     }
 
-
     trace_xen_unmap_mmio_range(ioservid, start_addr, end_addr);
-    xc_hvm_unmap_io_range_from_ioreq_server(xc, dom, ioservid, 1,
-                                            start_addr, end_addr);
+    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
+                                            1, start_addr, end_addr);
 }
 
-static inline void xen_map_io_section(xc_interface *xc, domid_t dom,
+static inline void xen_map_io_section(domid_t dom,
                                       ioservid_t ioservid,
                                       MemoryRegionSection *section)
 {
@@ -271,13 +274,12 @@ static inline void xen_map_io_section(xc_interface *xc, domid_t dom,
         return;
     }
 
-
     trace_xen_map_portio_range(ioservid, start_addr, end_addr);
-    xc_hvm_map_io_range_to_ioreq_server(xc, dom, ioservid, 0,
+    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 0,
                                         start_addr, end_addr);
 }
 
-static inline void xen_unmap_io_section(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_io_section(domid_t dom,
                                         ioservid_t ioservid,
                                         MemoryRegionSection *section)
 {
@@ -290,11 +292,11 @@ static inline void xen_unmap_io_section(xc_interface *xc, domid_t dom,
     }
 
     trace_xen_unmap_portio_range(ioservid, start_addr, end_addr);
-    xc_hvm_unmap_io_range_from_ioreq_server(xc, dom, ioservid, 0,
-                                            start_addr, end_addr);
+    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
+                                            0, start_addr, end_addr);
 }
 
-static inline void xen_map_pcidev(xc_interface *xc, domid_t dom,
+static inline void xen_map_pcidev(domid_t dom,
                                   ioservid_t ioservid,
                                   PCIDevice *pci_dev)
 {
@@ -304,13 +306,13 @@ static inline void xen_map_pcidev(xc_interface *xc, domid_t dom,
 
     trace_xen_map_pcidev(ioservid, pci_bus_num(pci_dev->bus),
                          PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
-    xc_hvm_map_pcidev_to_ioreq_server(xc, dom, ioservid,
-                                      0, pci_bus_num(pci_dev->bus),
+    xc_hvm_map_pcidev_to_ioreq_server(xen_xc, dom, ioservid, 0,
+                                      pci_bus_num(pci_dev->bus),
                                       PCI_SLOT(pci_dev->devfn),
                                       PCI_FUNC(pci_dev->devfn));
 }
 
-static inline void xen_unmap_pcidev(xc_interface *xc, domid_t dom,
+static inline void xen_unmap_pcidev(domid_t dom,
                                     ioservid_t ioservid,
                                     PCIDevice *pci_dev)
 {
@@ -320,16 +322,17 @@ static inline void xen_unmap_pcidev(xc_interface *xc, domid_t dom,
 
     trace_xen_unmap_pcidev(ioservid, pci_bus_num(pci_dev->bus),
                            PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
-    xc_hvm_unmap_pcidev_from_ioreq_server(xc, dom, ioservid,
-                                          0, pci_bus_num(pci_dev->bus),
+    xc_hvm_unmap_pcidev_from_ioreq_server(xen_xc, dom, ioservid, 0,
+                                          pci_bus_num(pci_dev->bus),
                                           PCI_SLOT(pci_dev->devfn),
                                           PCI_FUNC(pci_dev->devfn));
 }
 
-static inline void xen_create_ioreq_server(xc_interface *xc, domid_t dom,
+static inline void xen_create_ioreq_server(domid_t dom,
                                            ioservid_t *ioservid)
 {
-    int rc = xc_hvm_create_ioreq_server(xc, dom, HVM_IOREQSRV_BUFIOREQ_ATOMIC,
+    int rc = xc_hvm_create_ioreq_server(xen_xc, dom,
+                                        HVM_IOREQSRV_BUFIOREQ_ATOMIC,
                                         ioservid);
 
     if (rc == 0) {
@@ -342,7 +345,7 @@ static inline void xen_create_ioreq_server(xc_interface *xc, domid_t dom,
     trace_xen_default_ioreq_server();
 }
 
-static inline void xen_destroy_ioreq_server(xc_interface *xc, domid_t dom,
+static inline void xen_destroy_ioreq_server(domid_t dom,
                                             ioservid_t ioservid)
 {
     if (use_default_ioreq_server) {
@@ -350,27 +353,27 @@ static inline void xen_destroy_ioreq_server(xc_interface *xc, domid_t dom,
     }
 
     trace_xen_ioreq_server_destroy(ioservid);
-    xc_hvm_destroy_ioreq_server(xc, dom, ioservid);
+    xc_hvm_destroy_ioreq_server(xen_xc, dom, ioservid);
 }
 
-static inline int xen_get_ioreq_server_info(xc_interface *xc, domid_t dom,
+static inline int xen_get_ioreq_server_info(domid_t dom,
                                             ioservid_t ioservid,
                                             xen_pfn_t *ioreq_pfn,
                                             xen_pfn_t *bufioreq_pfn,
                                             evtchn_port_t *bufioreq_evtchn)
 {
     if (use_default_ioreq_server) {
-        return xen_get_default_ioreq_server_info(xc, dom, ioreq_pfn,
+        return xen_get_default_ioreq_server_info(dom, ioreq_pfn,
                                                  bufioreq_pfn,
                                                  bufioreq_evtchn);
     }
 
-    return xc_hvm_get_ioreq_server_info(xc, dom, ioservid,
+    return xc_hvm_get_ioreq_server_info(xen_xc, dom, ioservid,
                                         ioreq_pfn, bufioreq_pfn,
                                         bufioreq_evtchn);
 }
 
-static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom,
+static inline int xen_set_ioreq_server_state(domid_t dom,
                                              ioservid_t ioservid,
                                              bool enable)
 {
@@ -379,7 +382,8 @@ static inline int xen_set_ioreq_server_state(xc_interface *xc, domid_t dom,
     }
 
     trace_xen_ioreq_server_state(ioservid, enable);
-    return xc_hvm_set_ioreq_server_state(xc, dom, ioservid, enable);
+    return xc_hvm_set_ioreq_server_state(xen_xc, dom, ioservid,
+                                         enable);
 }
 
 #endif
diff --git a/xen-common.c b/xen-common.c
index fd2c928..703e7a5 100644
--- a/xen-common.c
+++ b/xen-common.c
@@ -25,6 +25,9 @@
     do { } while (0)
 #endif
 
+xc_interface *xen_xc;
+xenforeignmemory_handle *xen_fmem;
+
 static int store_dev_info(int domid, Chardev *cs, const char *string)
 {
     struct xs_handle *xs = NULL;
diff --git a/xen-hvm.c b/xen-hvm.c
index 5043beb..dbb8c66 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -454,10 +454,10 @@ static void xen_set_memory(struct MemoryListener *listener,
         return;
     } else {
         if (add) {
-            xen_map_memory_section(xen_xc, xen_domid, state->ioservid,
+            xen_map_memory_section(xen_domid, state->ioservid,
                                    section);
         } else {
-            xen_unmap_memory_section(xen_xc, xen_domid, state->ioservid,
+            xen_unmap_memory_section(xen_domid, state->ioservid,
                                      section);
         }
     }
@@ -521,7 +521,7 @@ static void xen_io_add(MemoryListener *listener,
 
     memory_region_ref(mr);
 
-    xen_map_io_section(xen_xc, xen_domid, state->ioservid, section);
+    xen_map_io_section(xen_domid, state->ioservid, section);
 }
 
 static void xen_io_del(MemoryListener *listener,
@@ -534,7 +534,7 @@ static void xen_io_del(MemoryListener *listener,
         return;
     }
 
-    xen_unmap_io_section(xen_xc, xen_domid, state->ioservid, section);
+    xen_unmap_io_section(xen_domid, state->ioservid, section);
 
     memory_region_unref(mr);
 }
@@ -547,7 +547,7 @@ static void xen_device_realize(DeviceListener *listener,
     if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
         PCIDevice *pci_dev = PCI_DEVICE(dev);
 
-        xen_map_pcidev(xen_xc, xen_domid, state->ioservid, pci_dev);
+        xen_map_pcidev(xen_domid, state->ioservid, pci_dev);
     }
 }
 
@@ -559,7 +559,7 @@ static void xen_device_unrealize(DeviceListener *listener,
     if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
         PCIDevice *pci_dev = PCI_DEVICE(dev);
 
-        xen_unmap_pcidev(xen_xc, xen_domid, state->ioservid, pci_dev);
+        xen_unmap_pcidev(xen_domid, state->ioservid, pci_dev);
     }
 }
 
@@ -1139,7 +1139,7 @@ static void xen_hvm_change_state_handler(void *opaque, int running,
         xen_main_loop_prepare(state);
     }
 
-    xen_set_ioreq_server_state(xen_xc, xen_domid,
+    xen_set_ioreq_server_state(xen_domid,
                                state->ioservid,
                                (rstate == RUN_STATE_RUNNING));
 }
@@ -1227,7 +1227,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
         goto err;
     }
 
-    xen_create_ioreq_server(xen_xc, xen_domid, &state->ioservid);
+    xen_create_ioreq_server(xen_domid, &state->ioservid);
 
     state->exit.notify = xen_exit_notifier;
     qemu_add_exit_notifier(&state->exit);
@@ -1238,7 +1238,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
     state->wakeup.notify = xen_wakeup_notifier;
     qemu_register_wakeup_notifier(&state->wakeup);
 
-    rc = xen_get_ioreq_server_info(xen_xc, xen_domid, state->ioservid,
+    rc = xen_get_ioreq_server_info(xen_domid, state->ioservid,
                                    &ioreq_pfn, &bufioreq_pfn,
                                    &bufioreq_evtchn);
     if (rc < 0) {
@@ -1288,7 +1288,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
     /* Note: cpus is empty at this point in init */
     state->cpu_by_vcpu_id = g_malloc0(max_cpus * sizeof(CPUState *));
 
-    rc = xen_set_ioreq_server_state(xen_xc, xen_domid, state->ioservid, true);
+    rc = xen_set_ioreq_server_state(xen_domid, state->ioservid, true);
     if (rc < 0) {
         error_report("failed to enable ioreq server info: error %d handle=%p",
                      errno, xen_xc);
-- 
2.1.4


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

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH 2/5] xen: rename xen_modified_memory() to xen_hvm_modified_memory()
  2017-02-23 14:53 ` Paul Durrant
@ 2017-02-23 14:53   ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel
  Cc: Paul Durrant, Paolo Bonzini, Stefano Stabellini, Anthony Perard

This patch is a purely cosmetic change that avoids a name collision in
a subsequent patch.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
---
 include/exec/ram_addr.h | 4 ++--
 include/hw/xen/xen.h    | 2 +-
 xen-hvm-stub.c          | 2 +-
 xen-hvm.c               | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 3e79466..8715af6 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -259,7 +259,7 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
 
     rcu_read_unlock();
 
-    xen_modified_memory(start, length);
+    xen_hvm_modified_memory(start, length);
 }
 
 #if !defined(_WIN32)
@@ -313,7 +313,7 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
 
         rcu_read_unlock();
 
-        xen_modified_memory(start, pages << TARGET_PAGE_BITS);
+        xen_hvm_modified_memory(start, pages << TARGET_PAGE_BITS);
     } else {
         uint8_t clients = tcg_enabled() ? DIRTY_CLIENTS_ALL : DIRTY_CLIENTS_NOCODE;
         /*
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index 09c2ce5..2b1733b 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -43,7 +43,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory);
 
 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
                    struct MemoryRegion *mr, Error **errp);
-void xen_modified_memory(ram_addr_t start, ram_addr_t length);
+void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length);
 
 void xen_register_framebuffer(struct MemoryRegion *mr);
 
diff --git a/xen-hvm-stub.c b/xen-hvm-stub.c
index c500325..3ca6c51 100644
--- a/xen-hvm-stub.c
+++ b/xen-hvm-stub.c
@@ -50,7 +50,7 @@ void xen_register_framebuffer(MemoryRegion *mr)
 {
 }
 
-void xen_modified_memory(ram_addr_t start, ram_addr_t length)
+void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
 {
 }
 
diff --git a/xen-hvm.c b/xen-hvm.c
index dbb8c66..edf4983 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -1391,7 +1391,7 @@ void xen_shutdown_fatal_error(const char *fmt, ...)
     qemu_system_shutdown_request();
 }
 
-void xen_modified_memory(ram_addr_t start, ram_addr_t length)
+void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
 {
     if (unlikely(xen_in_migration)) {
         int rc;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 2/5] xen: rename xen_modified_memory() to xen_hvm_modified_memory()
@ 2017-02-23 14:53   ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel
  Cc: Anthony Perard, Paolo Bonzini, Paul Durrant, Stefano Stabellini

This patch is a purely cosmetic change that avoids a name collision in
a subsequent patch.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
---
 include/exec/ram_addr.h | 4 ++--
 include/hw/xen/xen.h    | 2 +-
 xen-hvm-stub.c          | 2 +-
 xen-hvm.c               | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 3e79466..8715af6 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -259,7 +259,7 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
 
     rcu_read_unlock();
 
-    xen_modified_memory(start, length);
+    xen_hvm_modified_memory(start, length);
 }
 
 #if !defined(_WIN32)
@@ -313,7 +313,7 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
 
         rcu_read_unlock();
 
-        xen_modified_memory(start, pages << TARGET_PAGE_BITS);
+        xen_hvm_modified_memory(start, pages << TARGET_PAGE_BITS);
     } else {
         uint8_t clients = tcg_enabled() ? DIRTY_CLIENTS_ALL : DIRTY_CLIENTS_NOCODE;
         /*
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index 09c2ce5..2b1733b 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -43,7 +43,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory);
 
 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
                    struct MemoryRegion *mr, Error **errp);
-void xen_modified_memory(ram_addr_t start, ram_addr_t length);
+void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length);
 
 void xen_register_framebuffer(struct MemoryRegion *mr);
 
diff --git a/xen-hvm-stub.c b/xen-hvm-stub.c
index c500325..3ca6c51 100644
--- a/xen-hvm-stub.c
+++ b/xen-hvm-stub.c
@@ -50,7 +50,7 @@ void xen_register_framebuffer(MemoryRegion *mr)
 {
 }
 
-void xen_modified_memory(ram_addr_t start, ram_addr_t length)
+void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
 {
 }
 
diff --git a/xen-hvm.c b/xen-hvm.c
index dbb8c66..edf4983 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -1391,7 +1391,7 @@ void xen_shutdown_fatal_error(const char *fmt, ...)
     qemu_system_shutdown_request();
 }
 
-void xen_modified_memory(ram_addr_t start, ram_addr_t length)
+void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
 {
     if (unlikely(xen_in_migration)) {
         int rc;
-- 
2.1.4


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

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions
  2017-02-23 14:53 ` Paul Durrant
                   ` (3 preceding siblings ...)
  (?)
@ 2017-02-23 14:53 ` Paul Durrant
  2017-03-01 16:13     ` Anthony PERARD
  -1 siblings, 1 reply; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel
  Cc: Paul Durrant, Stefano Stabellini, Anthony Perard, Paolo Bonzini,
	Richard Henderson, Eduardo Habkost, Michael S. Tsirkin

This patch creates inline wrapper functions in xen_common.h for all open
coded calls to xc_hvm_XXX() functions outside of xen_common.h so that use
of xen_xc can be made implicit. This again is in preparation for the move
to using libxendevicemodel.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
---
 hw/i386/xen/xen_platform.c  |  2 +-
 include/hw/xen/xen_common.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 xen-hvm.c                   | 27 +++++++++++++--------------
 3 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 6010f35..1419fc9 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -195,7 +195,7 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t v
     case 0: /* Platform flags */ {
         hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ?
             HVMMEM_ram_ro : HVMMEM_ram_rw;
-        if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type, 0xc0, 0x40)) {
+        if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
             DPRINTF("unable to change ro/rw state of ROM memory area!\n");
         } else {
             s->flags = val & PFFLAG_ROM_LOCK;
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 1e08b98..31cf25f 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
  * We don't support Xen prior to 4.2.0.
  */
 
+static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
+                                   uint64_t first_pfn, uint32_t nr)
+{
+    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
+}
+
+static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
+                                         uint8_t bus, uint8_t device,
+                                         uint8_t intx, unsigned int level)
+{
+    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
+                                     intx, level);
+}
+
+static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
+                                         uint8_t irq)
+{
+    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
+}
+
+static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
+                                 uint32_t msi_data)
+{
+    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
+}
+
+static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
+                                        unsigned int level)
+{
+    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
+}
+
+static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
+                                       uint32_t nr, unsigned long *bitmap)
+{
+    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
+}
+
+static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
+                                      uint32_t nr)
+{
+    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
+}
+
 /* Xen 4.2 through 4.6 */
 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471
 
diff --git a/xen-hvm.c b/xen-hvm.c
index edf4983..4b928cf 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -125,8 +125,8 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
 
 void xen_piix3_set_irq(void *opaque, int irq_num, int level)
 {
-    xc_hvm_set_pci_intx_level(xen_xc, xen_domid, 0, 0, irq_num >> 2,
-                              irq_num & 3, level);
+    xen_set_pci_intx_level(xen_domid, 0, 0, irq_num >> 2,
+                           irq_num & 3, level);
 }
 
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
@@ -141,7 +141,7 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
         }
         v &= 0xf;
         if (((address + i) >= 0x60) && ((address + i) <= 0x63)) {
-            xc_hvm_set_pci_link_route(xen_xc, xen_domid, address + i - 0x60, v);
+            xen_set_pci_link_route(xen_domid, address + i - 0x60, v);
         }
     }
 }
@@ -156,7 +156,7 @@ int xen_is_pirq_msi(uint32_t msi_data)
 
 void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
 {
-    xc_hvm_inject_msi(xen_xc, xen_domid, addr, data);
+    xen_inject_msi(xen_domid, addr, data);
 }
 
 static void xen_suspend_notifier(Notifier *notifier, void *data)
@@ -168,7 +168,7 @@ static void xen_suspend_notifier(Notifier *notifier, void *data)
 
 static void xen_set_irq(void *opaque, int irq, int level)
 {
-    xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level);
+    xen_set_isa_irq_level(xen_domid, irq, level);
 }
 
 qemu_irq *xen_interrupt_controller_init(void)
@@ -481,10 +481,10 @@ static void xen_set_memory(struct MemoryListener *listener,
                                section->mr, section->offset_within_region);
         } else {
             mem_type = HVMMEM_ram_ro;
-            if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type,
-                                    start_addr >> TARGET_PAGE_BITS,
-                                    size >> TARGET_PAGE_BITS)) {
-                DPRINTF("xc_hvm_set_mem_type error, addr: "TARGET_FMT_plx"\n",
+            if (xen_set_mem_type(xen_domid, mem_type,
+                                 start_addr >> TARGET_PAGE_BITS,
+                                 size >> TARGET_PAGE_BITS)) {
+                DPRINTF("xen_set_mem_type error, addr: "TARGET_FMT_plx"\n",
                         start_addr);
             }
         }
@@ -586,9 +586,8 @@ static void xen_sync_dirty_bitmap(XenIOState *state,
         return;
     }
 
-    rc = xc_hvm_track_dirty_vram(xen_xc, xen_domid,
-                                 start_addr >> TARGET_PAGE_BITS, npages,
-                                 bitmap);
+    rc = xen_track_dirty_vram(xen_domid, start_addr >> TARGET_PAGE_BITS,
+                              npages, bitmap);
     if (rc < 0) {
 #ifndef ENODATA
 #define ENODATA  ENOENT
@@ -634,7 +633,7 @@ static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *section,
     if (old & ~new & (1 << DIRTY_MEMORY_VGA)) {
         state->log_for_dirtybit = NULL;
         /* Disable dirty bit tracking */
-        xc_hvm_track_dirty_vram(xen_xc, xen_domid, 0, 0, NULL);
+        xen_track_dirty_vram(xen_domid, 0, 0, NULL);
     }
 }
 
@@ -1403,7 +1402,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
         start_pfn = start >> TARGET_PAGE_BITS;
         nb_pages = ((start + length + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS)
             - start_pfn;
-        rc = xc_hvm_modified_memory(xen_xc, xen_domid, start_pfn, nb_pages);
+        rc = xen_modified_memory(xen_domid, start_pfn, nb_pages);
         if (rc) {
             fprintf(stderr,
                     "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n",
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions
  2017-02-23 14:53 ` Paul Durrant
                   ` (2 preceding siblings ...)
  (?)
@ 2017-02-23 14:53 ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel
  Cc: Stefano Stabellini, Eduardo Habkost, Michael S. Tsirkin,
	Paul Durrant, Anthony Perard, Paolo Bonzini, Richard Henderson

This patch creates inline wrapper functions in xen_common.h for all open
coded calls to xc_hvm_XXX() functions outside of xen_common.h so that use
of xen_xc can be made implicit. This again is in preparation for the move
to using libxendevicemodel.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
---
 hw/i386/xen/xen_platform.c  |  2 +-
 include/hw/xen/xen_common.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 xen-hvm.c                   | 27 +++++++++++++--------------
 3 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 6010f35..1419fc9 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -195,7 +195,7 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t v
     case 0: /* Platform flags */ {
         hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ?
             HVMMEM_ram_ro : HVMMEM_ram_rw;
-        if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type, 0xc0, 0x40)) {
+        if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
             DPRINTF("unable to change ro/rw state of ROM memory area!\n");
         } else {
             s->flags = val & PFFLAG_ROM_LOCK;
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 1e08b98..31cf25f 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
  * We don't support Xen prior to 4.2.0.
  */
 
+static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
+                                   uint64_t first_pfn, uint32_t nr)
+{
+    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
+}
+
+static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
+                                         uint8_t bus, uint8_t device,
+                                         uint8_t intx, unsigned int level)
+{
+    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
+                                     intx, level);
+}
+
+static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
+                                         uint8_t irq)
+{
+    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
+}
+
+static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
+                                 uint32_t msi_data)
+{
+    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
+}
+
+static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
+                                        unsigned int level)
+{
+    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
+}
+
+static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
+                                       uint32_t nr, unsigned long *bitmap)
+{
+    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
+}
+
+static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
+                                      uint32_t nr)
+{
+    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
+}
+
 /* Xen 4.2 through 4.6 */
 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471
 
diff --git a/xen-hvm.c b/xen-hvm.c
index edf4983..4b928cf 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -125,8 +125,8 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
 
 void xen_piix3_set_irq(void *opaque, int irq_num, int level)
 {
-    xc_hvm_set_pci_intx_level(xen_xc, xen_domid, 0, 0, irq_num >> 2,
-                              irq_num & 3, level);
+    xen_set_pci_intx_level(xen_domid, 0, 0, irq_num >> 2,
+                           irq_num & 3, level);
 }
 
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
@@ -141,7 +141,7 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
         }
         v &= 0xf;
         if (((address + i) >= 0x60) && ((address + i) <= 0x63)) {
-            xc_hvm_set_pci_link_route(xen_xc, xen_domid, address + i - 0x60, v);
+            xen_set_pci_link_route(xen_domid, address + i - 0x60, v);
         }
     }
 }
@@ -156,7 +156,7 @@ int xen_is_pirq_msi(uint32_t msi_data)
 
 void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
 {
-    xc_hvm_inject_msi(xen_xc, xen_domid, addr, data);
+    xen_inject_msi(xen_domid, addr, data);
 }
 
 static void xen_suspend_notifier(Notifier *notifier, void *data)
@@ -168,7 +168,7 @@ static void xen_suspend_notifier(Notifier *notifier, void *data)
 
 static void xen_set_irq(void *opaque, int irq, int level)
 {
-    xc_hvm_set_isa_irq_level(xen_xc, xen_domid, irq, level);
+    xen_set_isa_irq_level(xen_domid, irq, level);
 }
 
 qemu_irq *xen_interrupt_controller_init(void)
@@ -481,10 +481,10 @@ static void xen_set_memory(struct MemoryListener *listener,
                                section->mr, section->offset_within_region);
         } else {
             mem_type = HVMMEM_ram_ro;
-            if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type,
-                                    start_addr >> TARGET_PAGE_BITS,
-                                    size >> TARGET_PAGE_BITS)) {
-                DPRINTF("xc_hvm_set_mem_type error, addr: "TARGET_FMT_plx"\n",
+            if (xen_set_mem_type(xen_domid, mem_type,
+                                 start_addr >> TARGET_PAGE_BITS,
+                                 size >> TARGET_PAGE_BITS)) {
+                DPRINTF("xen_set_mem_type error, addr: "TARGET_FMT_plx"\n",
                         start_addr);
             }
         }
@@ -586,9 +586,8 @@ static void xen_sync_dirty_bitmap(XenIOState *state,
         return;
     }
 
-    rc = xc_hvm_track_dirty_vram(xen_xc, xen_domid,
-                                 start_addr >> TARGET_PAGE_BITS, npages,
-                                 bitmap);
+    rc = xen_track_dirty_vram(xen_domid, start_addr >> TARGET_PAGE_BITS,
+                              npages, bitmap);
     if (rc < 0) {
 #ifndef ENODATA
 #define ENODATA  ENOENT
@@ -634,7 +633,7 @@ static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *section,
     if (old & ~new & (1 << DIRTY_MEMORY_VGA)) {
         state->log_for_dirtybit = NULL;
         /* Disable dirty bit tracking */
-        xc_hvm_track_dirty_vram(xen_xc, xen_domid, 0, 0, NULL);
+        xen_track_dirty_vram(xen_domid, 0, 0, NULL);
     }
 }
 
@@ -1403,7 +1402,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
         start_pfn = start >> TARGET_PAGE_BITS;
         nb_pages = ((start + length + TARGET_PAGE_SIZE - 1) >> TARGET_PAGE_BITS)
             - start_pfn;
-        rc = xc_hvm_modified_memory(xen_xc, xen_domid, start_pfn, nb_pages);
+        rc = xen_modified_memory(xen_domid, start_pfn, nb_pages);
         if (rc) {
             fprintf(stderr,
                     "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n",
-- 
2.1.4


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

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH 4/5] configure: detect presence of libxendevicemodel
  2017-02-23 14:53 ` Paul Durrant
@ 2017-02-23 14:53   ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel; +Cc: Paul Durrant, Stefano Stabellini, Anthony Perard

This patch adds code in configure to set CONFIG_XEN_CTRL_INTERFACE_VERSION
to a new value of 490 if libxendevicemodel is present in the build
environment.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
---
 configure | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/configure b/configure
index 8e8f18d..fc1e12b 100755
--- a/configure
+++ b/configure
@@ -1980,6 +1980,25 @@ EOF
   # Xen unstable
   elif
       cat > $TMPC <<EOF &&
+#undef XC_WANT_COMPAT_DEVICEMODEL_API
+#define __XEN_TOOLS__
+#include <xendevicemodel.h>
+int main(void) {
+  xendevicemodel_handle *xd;
+
+  xd = xendevicemodel_open(0, 0);
+  xendevicemodel_close(xd);
+
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs $xen_stable_libs -lxendevicemodel"
+    then
+    xen_stable_libs="$xen_stable_libs -lxendevicemodel"
+    xen_ctrl_version=490
+    xen=yes
+  elif
+      cat > $TMPC <<EOF &&
 /*
  * If we have stable libs the we don't want the libxc compat
  * layers, regardless of what CFLAGS we may have been given.
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 4/5] configure: detect presence of libxendevicemodel
@ 2017-02-23 14:53   ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel; +Cc: Anthony Perard, Paul Durrant, Stefano Stabellini

This patch adds code in configure to set CONFIG_XEN_CTRL_INTERFACE_VERSION
to a new value of 490 if libxendevicemodel is present in the build
environment.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
---
 configure | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/configure b/configure
index 8e8f18d..fc1e12b 100755
--- a/configure
+++ b/configure
@@ -1980,6 +1980,25 @@ EOF
   # Xen unstable
   elif
       cat > $TMPC <<EOF &&
+#undef XC_WANT_COMPAT_DEVICEMODEL_API
+#define __XEN_TOOLS__
+#include <xendevicemodel.h>
+int main(void) {
+  xendevicemodel_handle *xd;
+
+  xd = xendevicemodel_open(0, 0);
+  xendevicemodel_close(xd);
+
+  return 0;
+}
+EOF
+      compile_prog "" "$xen_libs $xen_stable_libs -lxendevicemodel"
+    then
+    xen_stable_libs="$xen_stable_libs -lxendevicemodel"
+    xen_ctrl_version=490
+    xen=yes
+  elif
+      cat > $TMPC <<EOF &&
 /*
  * If we have stable libs the we don't want the libxc compat
  * layers, regardless of what CFLAGS we may have been given.
-- 
2.1.4


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

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH 5/5] xen: use libxendevicemodel when available
  2017-02-23 14:53 ` Paul Durrant
@ 2017-02-23 14:53   ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel; +Cc: Paul Durrant, Stefano Stabellini, Anthony Perard

This patch modifies the wrapper functions in xen_common.h to use the
new xendevicemodel interface if it is available along with compatibility
code to use the old libxenctrl interface if it is not.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
---
 include/hw/xen/xen_common.h | 114 +++++++++++++++++++++++++++++++-------------
 xen-common.c                |   8 ++++
 2 files changed, 89 insertions(+), 33 deletions(-)

diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 31cf25f..2c2a61b 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -9,6 +9,7 @@
 #undef XC_WANT_COMPAT_EVTCHN_API
 #undef XC_WANT_COMPAT_GNTTAB_API
 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
+#undef XC_WANT_COMPAT_DEVICEMODEL_API
 
 #include <xenctrl.h>
 #include <xenstore.h>
@@ -26,48 +27,95 @@ extern xc_interface *xen_xc;
  * We don't support Xen prior to 4.2.0.
  */
 
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 490
+
+typedef xc_interface xendevicemodel_handle;
+
+#define xendevicemodel_open(l, f) xen_xc
+
+#define xendevicemodel_map_io_range_to_ioreq_server \
+    xc_hvm_map_io_range_to_ioreq_server
+#define xendevicemodel_unmap_io_range_from_ioreq_server \
+    xc_hvm_unmap_io_range_from_ioreq_server
+#define xendevicemodel_map_pcidev_to_ioreq_server \
+    xc_hvm_map_pcidev_to_ioreq_server
+#define xendevicemodel_unmap_pcidev_from_ioreq_server \
+    xc_hvm_unmap_pcidev_from_ioreq_server
+#define xendevicemodel_create_ioreq_server \
+    xc_hvm_create_ioreq_server
+#define xendevicemodel_destroy_ioreq_server \
+    xc_hvm_destroy_ioreq_server
+#define xendevicemodel_get_ioreq_server_info \
+    xc_hvm_get_ioreq_server_info
+#define xendevicemodel_set_ioreq_server_state \
+    xc_hvm_set_ioreq_server_state
+#define xendevicemodel_set_pci_intx_level \
+    xc_hvm_set_pci_intx_level
+#define xendevicemodel_set_pci_link_route \
+    xc_hvm_set_pci_link_route
+#define xendevicemodel_set_isa_irq_level \
+    xc_hvm_set_isa_irq_level
+#define xendevicemodel_inject_msi \
+    xc_hvm_inject_msi
+#define xendevicemodel_set_mem_type \
+    xc_hvm_set_mem_type
+#define xendevicemodel_track_dirty_vram \
+    xc_hvm_track_dirty_vram
+#define xendevicemodel_modified_memory \
+    xc_hvm_modified_memory
+
+#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 490 */
+
+#include <xendevicemodel.h>
+
+#endif
+
+extern xendevicemodel_handle *xen_dmod;
+
 static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
                                    uint64_t first_pfn, uint32_t nr)
 {
-    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
+    return xendevicemodel_set_mem_type(xen_dmod, domid, type, first_pfn,
+                                       nr);
 }
 
 static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
                                          uint8_t bus, uint8_t device,
                                          uint8_t intx, unsigned int level)
 {
-    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
-                                     intx, level);
+    return xendevicemodel_set_pci_intx_level(xen_dmod, domid, segment, bus,
+                                             device, intx, level);
 }
 
 static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
                                          uint8_t irq)
 {
-    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
+    return xendevicemodel_set_pci_link_route(xen_dmod, domid, link, irq);
 }
 
 static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
                                  uint32_t msi_data)
 {
-    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
+    return xendevicemodel_inject_msi(xen_dmod, domid, msi_addr, msi_data);
 }
 
 static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
                                         unsigned int level)
 {
-    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
+    return xendevicemodel_set_isa_irq_level(xen_dmod, domid, irq, level);
 }
 
 static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
                                        uint32_t nr, unsigned long *bitmap)
 {
-    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
+    return xendevicemodel_track_dirty_vram(xen_dmod, domid, first_pfn, nr,
+                                           bitmap);
 }
 
 static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
                                       uint32_t nr)
 {
-    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
+    return xendevicemodel_modified_memory(xen_dmod, domid, first_pfn, nr);
 }
 
 /* Xen 4.2 through 4.6 */
@@ -285,8 +333,8 @@ static inline void xen_map_memory_section(domid_t dom,
     }
 
     trace_xen_map_mmio_range(ioservid, start_addr, end_addr);
-    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 1,
-                                        start_addr, end_addr);
+    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom, ioservid, 1,
+                                                start_addr, end_addr);
 }
 
 static inline void xen_unmap_memory_section(domid_t dom,
@@ -302,8 +350,8 @@ static inline void xen_unmap_memory_section(domid_t dom,
     }
 
     trace_xen_unmap_mmio_range(ioservid, start_addr, end_addr);
-    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
-                                            1, start_addr, end_addr);
+    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod, dom, ioservid,
+                                                    1, start_addr, end_addr);
 }
 
 static inline void xen_map_io_section(domid_t dom,
@@ -319,8 +367,8 @@ static inline void xen_map_io_section(domid_t dom,
     }
 
     trace_xen_map_portio_range(ioservid, start_addr, end_addr);
-    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 0,
-                                        start_addr, end_addr);
+    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom, ioservid, 0,
+                                                start_addr, end_addr);
 }
 
 static inline void xen_unmap_io_section(domid_t dom,
@@ -336,8 +384,8 @@ static inline void xen_unmap_io_section(domid_t dom,
     }
 
     trace_xen_unmap_portio_range(ioservid, start_addr, end_addr);
-    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
-                                            0, start_addr, end_addr);
+    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod, dom, ioservid,
+                                                    0, start_addr, end_addr);
 }
 
 static inline void xen_map_pcidev(domid_t dom,
@@ -350,10 +398,10 @@ static inline void xen_map_pcidev(domid_t dom,
 
     trace_xen_map_pcidev(ioservid, pci_bus_num(pci_dev->bus),
                          PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
-    xc_hvm_map_pcidev_to_ioreq_server(xen_xc, dom, ioservid, 0,
-                                      pci_bus_num(pci_dev->bus),
-                                      PCI_SLOT(pci_dev->devfn),
-                                      PCI_FUNC(pci_dev->devfn));
+    xendevicemodel_map_pcidev_to_ioreq_server(xen_dmod, dom, ioservid, 0,
+                                              pci_bus_num(pci_dev->bus),
+                                              PCI_SLOT(pci_dev->devfn),
+                                              PCI_FUNC(pci_dev->devfn));
 }
 
 static inline void xen_unmap_pcidev(domid_t dom,
@@ -366,18 +414,18 @@ static inline void xen_unmap_pcidev(domid_t dom,
 
     trace_xen_unmap_pcidev(ioservid, pci_bus_num(pci_dev->bus),
                            PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
-    xc_hvm_unmap_pcidev_from_ioreq_server(xen_xc, dom, ioservid, 0,
-                                          pci_bus_num(pci_dev->bus),
-                                          PCI_SLOT(pci_dev->devfn),
-                                          PCI_FUNC(pci_dev->devfn));
+    xendevicemodel_unmap_pcidev_from_ioreq_server(xen_dmod, dom, ioservid, 0,
+                                                  pci_bus_num(pci_dev->bus),
+                                                  PCI_SLOT(pci_dev->devfn),
+                                                  PCI_FUNC(pci_dev->devfn));
 }
 
 static inline void xen_create_ioreq_server(domid_t dom,
                                            ioservid_t *ioservid)
 {
-    int rc = xc_hvm_create_ioreq_server(xen_xc, dom,
-                                        HVM_IOREQSRV_BUFIOREQ_ATOMIC,
-                                        ioservid);
+    int rc = xendevicemodel_create_ioreq_server(xen_dmod, dom,
+                                                HVM_IOREQSRV_BUFIOREQ_ATOMIC,
+                                                ioservid);
 
     if (rc == 0) {
         trace_xen_ioreq_server_create(*ioservid);
@@ -397,7 +445,7 @@ static inline void xen_destroy_ioreq_server(domid_t dom,
     }
 
     trace_xen_ioreq_server_destroy(ioservid);
-    xc_hvm_destroy_ioreq_server(xen_xc, dom, ioservid);
+    xendevicemodel_destroy_ioreq_server(xen_dmod, dom, ioservid);
 }
 
 static inline int xen_get_ioreq_server_info(domid_t dom,
@@ -412,9 +460,9 @@ static inline int xen_get_ioreq_server_info(domid_t dom,
                                                  bufioreq_evtchn);
     }
 
-    return xc_hvm_get_ioreq_server_info(xen_xc, dom, ioservid,
-                                        ioreq_pfn, bufioreq_pfn,
-                                        bufioreq_evtchn);
+    return xendevicemodel_get_ioreq_server_info(xen_dmod, dom, ioservid,
+                                                ioreq_pfn, bufioreq_pfn,
+                                                bufioreq_evtchn);
 }
 
 static inline int xen_set_ioreq_server_state(domid_t dom,
@@ -426,8 +474,8 @@ static inline int xen_set_ioreq_server_state(domid_t dom,
     }
 
     trace_xen_ioreq_server_state(ioservid, enable);
-    return xc_hvm_set_ioreq_server_state(xen_xc, dom, ioservid,
-                                         enable);
+    return xendevicemodel_set_ioreq_server_state(xen_dmod, dom, ioservid,
+                                                 enable);
 }
 
 #endif
diff --git a/xen-common.c b/xen-common.c
index 703e7a5..ae76150 100644
--- a/xen-common.c
+++ b/xen-common.c
@@ -27,6 +27,7 @@
 
 xc_interface *xen_xc;
 xenforeignmemory_handle *xen_fmem;
+xendevicemodel_handle *xen_dmod;
 
 static int store_dev_info(int domid, Chardev *cs, const char *string)
 {
@@ -128,6 +129,13 @@ static int xen_init(MachineState *ms)
         xc_interface_close(xen_xc);
         return -1;
     }
+    xen_dmod = xendevicemodel_open(0, 0);
+    if (xen_dmod == NULL) {
+        xen_pv_printf(NULL, 0, "can't open xen devicemodel interface\n");
+        xenforeignmemory_close(xen_fmem);
+        xc_interface_close(xen_xc);
+        return -1;
+    }
     qemu_add_vm_change_state_handler(xen_change_state_handler, NULL);
 
     global_state_set_optional();
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 5/5] xen: use libxendevicemodel when available
@ 2017-02-23 14:53   ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:53 UTC (permalink / raw)
  To: xen-devel, qemu-devel; +Cc: Anthony Perard, Paul Durrant, Stefano Stabellini

This patch modifies the wrapper functions in xen_common.h to use the
new xendevicemodel interface if it is available along with compatibility
code to use the old libxenctrl interface if it is not.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
---
 include/hw/xen/xen_common.h | 114 +++++++++++++++++++++++++++++++-------------
 xen-common.c                |   8 ++++
 2 files changed, 89 insertions(+), 33 deletions(-)

diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 31cf25f..2c2a61b 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -9,6 +9,7 @@
 #undef XC_WANT_COMPAT_EVTCHN_API
 #undef XC_WANT_COMPAT_GNTTAB_API
 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
+#undef XC_WANT_COMPAT_DEVICEMODEL_API
 
 #include <xenctrl.h>
 #include <xenstore.h>
@@ -26,48 +27,95 @@ extern xc_interface *xen_xc;
  * We don't support Xen prior to 4.2.0.
  */
 
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 490
+
+typedef xc_interface xendevicemodel_handle;
+
+#define xendevicemodel_open(l, f) xen_xc
+
+#define xendevicemodel_map_io_range_to_ioreq_server \
+    xc_hvm_map_io_range_to_ioreq_server
+#define xendevicemodel_unmap_io_range_from_ioreq_server \
+    xc_hvm_unmap_io_range_from_ioreq_server
+#define xendevicemodel_map_pcidev_to_ioreq_server \
+    xc_hvm_map_pcidev_to_ioreq_server
+#define xendevicemodel_unmap_pcidev_from_ioreq_server \
+    xc_hvm_unmap_pcidev_from_ioreq_server
+#define xendevicemodel_create_ioreq_server \
+    xc_hvm_create_ioreq_server
+#define xendevicemodel_destroy_ioreq_server \
+    xc_hvm_destroy_ioreq_server
+#define xendevicemodel_get_ioreq_server_info \
+    xc_hvm_get_ioreq_server_info
+#define xendevicemodel_set_ioreq_server_state \
+    xc_hvm_set_ioreq_server_state
+#define xendevicemodel_set_pci_intx_level \
+    xc_hvm_set_pci_intx_level
+#define xendevicemodel_set_pci_link_route \
+    xc_hvm_set_pci_link_route
+#define xendevicemodel_set_isa_irq_level \
+    xc_hvm_set_isa_irq_level
+#define xendevicemodel_inject_msi \
+    xc_hvm_inject_msi
+#define xendevicemodel_set_mem_type \
+    xc_hvm_set_mem_type
+#define xendevicemodel_track_dirty_vram \
+    xc_hvm_track_dirty_vram
+#define xendevicemodel_modified_memory \
+    xc_hvm_modified_memory
+
+#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 490 */
+
+#include <xendevicemodel.h>
+
+#endif
+
+extern xendevicemodel_handle *xen_dmod;
+
 static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
                                    uint64_t first_pfn, uint32_t nr)
 {
-    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
+    return xendevicemodel_set_mem_type(xen_dmod, domid, type, first_pfn,
+                                       nr);
 }
 
 static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
                                          uint8_t bus, uint8_t device,
                                          uint8_t intx, unsigned int level)
 {
-    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
-                                     intx, level);
+    return xendevicemodel_set_pci_intx_level(xen_dmod, domid, segment, bus,
+                                             device, intx, level);
 }
 
 static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
                                          uint8_t irq)
 {
-    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
+    return xendevicemodel_set_pci_link_route(xen_dmod, domid, link, irq);
 }
 
 static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
                                  uint32_t msi_data)
 {
-    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
+    return xendevicemodel_inject_msi(xen_dmod, domid, msi_addr, msi_data);
 }
 
 static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
                                         unsigned int level)
 {
-    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
+    return xendevicemodel_set_isa_irq_level(xen_dmod, domid, irq, level);
 }
 
 static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
                                        uint32_t nr, unsigned long *bitmap)
 {
-    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
+    return xendevicemodel_track_dirty_vram(xen_dmod, domid, first_pfn, nr,
+                                           bitmap);
 }
 
 static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
                                       uint32_t nr)
 {
-    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
+    return xendevicemodel_modified_memory(xen_dmod, domid, first_pfn, nr);
 }
 
 /* Xen 4.2 through 4.6 */
@@ -285,8 +333,8 @@ static inline void xen_map_memory_section(domid_t dom,
     }
 
     trace_xen_map_mmio_range(ioservid, start_addr, end_addr);
-    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 1,
-                                        start_addr, end_addr);
+    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom, ioservid, 1,
+                                                start_addr, end_addr);
 }
 
 static inline void xen_unmap_memory_section(domid_t dom,
@@ -302,8 +350,8 @@ static inline void xen_unmap_memory_section(domid_t dom,
     }
 
     trace_xen_unmap_mmio_range(ioservid, start_addr, end_addr);
-    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
-                                            1, start_addr, end_addr);
+    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod, dom, ioservid,
+                                                    1, start_addr, end_addr);
 }
 
 static inline void xen_map_io_section(domid_t dom,
@@ -319,8 +367,8 @@ static inline void xen_map_io_section(domid_t dom,
     }
 
     trace_xen_map_portio_range(ioservid, start_addr, end_addr);
-    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 0,
-                                        start_addr, end_addr);
+    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom, ioservid, 0,
+                                                start_addr, end_addr);
 }
 
 static inline void xen_unmap_io_section(domid_t dom,
@@ -336,8 +384,8 @@ static inline void xen_unmap_io_section(domid_t dom,
     }
 
     trace_xen_unmap_portio_range(ioservid, start_addr, end_addr);
-    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
-                                            0, start_addr, end_addr);
+    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod, dom, ioservid,
+                                                    0, start_addr, end_addr);
 }
 
 static inline void xen_map_pcidev(domid_t dom,
@@ -350,10 +398,10 @@ static inline void xen_map_pcidev(domid_t dom,
 
     trace_xen_map_pcidev(ioservid, pci_bus_num(pci_dev->bus),
                          PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
-    xc_hvm_map_pcidev_to_ioreq_server(xen_xc, dom, ioservid, 0,
-                                      pci_bus_num(pci_dev->bus),
-                                      PCI_SLOT(pci_dev->devfn),
-                                      PCI_FUNC(pci_dev->devfn));
+    xendevicemodel_map_pcidev_to_ioreq_server(xen_dmod, dom, ioservid, 0,
+                                              pci_bus_num(pci_dev->bus),
+                                              PCI_SLOT(pci_dev->devfn),
+                                              PCI_FUNC(pci_dev->devfn));
 }
 
 static inline void xen_unmap_pcidev(domid_t dom,
@@ -366,18 +414,18 @@ static inline void xen_unmap_pcidev(domid_t dom,
 
     trace_xen_unmap_pcidev(ioservid, pci_bus_num(pci_dev->bus),
                            PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
-    xc_hvm_unmap_pcidev_from_ioreq_server(xen_xc, dom, ioservid, 0,
-                                          pci_bus_num(pci_dev->bus),
-                                          PCI_SLOT(pci_dev->devfn),
-                                          PCI_FUNC(pci_dev->devfn));
+    xendevicemodel_unmap_pcidev_from_ioreq_server(xen_dmod, dom, ioservid, 0,
+                                                  pci_bus_num(pci_dev->bus),
+                                                  PCI_SLOT(pci_dev->devfn),
+                                                  PCI_FUNC(pci_dev->devfn));
 }
 
 static inline void xen_create_ioreq_server(domid_t dom,
                                            ioservid_t *ioservid)
 {
-    int rc = xc_hvm_create_ioreq_server(xen_xc, dom,
-                                        HVM_IOREQSRV_BUFIOREQ_ATOMIC,
-                                        ioservid);
+    int rc = xendevicemodel_create_ioreq_server(xen_dmod, dom,
+                                                HVM_IOREQSRV_BUFIOREQ_ATOMIC,
+                                                ioservid);
 
     if (rc == 0) {
         trace_xen_ioreq_server_create(*ioservid);
@@ -397,7 +445,7 @@ static inline void xen_destroy_ioreq_server(domid_t dom,
     }
 
     trace_xen_ioreq_server_destroy(ioservid);
-    xc_hvm_destroy_ioreq_server(xen_xc, dom, ioservid);
+    xendevicemodel_destroy_ioreq_server(xen_dmod, dom, ioservid);
 }
 
 static inline int xen_get_ioreq_server_info(domid_t dom,
@@ -412,9 +460,9 @@ static inline int xen_get_ioreq_server_info(domid_t dom,
                                                  bufioreq_evtchn);
     }
 
-    return xc_hvm_get_ioreq_server_info(xen_xc, dom, ioservid,
-                                        ioreq_pfn, bufioreq_pfn,
-                                        bufioreq_evtchn);
+    return xendevicemodel_get_ioreq_server_info(xen_dmod, dom, ioservid,
+                                                ioreq_pfn, bufioreq_pfn,
+                                                bufioreq_evtchn);
 }
 
 static inline int xen_set_ioreq_server_state(domid_t dom,
@@ -426,8 +474,8 @@ static inline int xen_set_ioreq_server_state(domid_t dom,
     }
 
     trace_xen_ioreq_server_state(ioservid, enable);
-    return xc_hvm_set_ioreq_server_state(xen_xc, dom, ioservid,
-                                         enable);
+    return xendevicemodel_set_ioreq_server_state(xen_dmod, dom, ioservid,
+                                                 enable);
 }
 
 #endif
diff --git a/xen-common.c b/xen-common.c
index 703e7a5..ae76150 100644
--- a/xen-common.c
+++ b/xen-common.c
@@ -27,6 +27,7 @@
 
 xc_interface *xen_xc;
 xenforeignmemory_handle *xen_fmem;
+xendevicemodel_handle *xen_dmod;
 
 static int store_dev_info(int domid, Chardev *cs, const char *string)
 {
@@ -128,6 +129,13 @@ static int xen_init(MachineState *ms)
         xc_interface_close(xen_xc);
         return -1;
     }
+    xen_dmod = xendevicemodel_open(0, 0);
+    if (xen_dmod == NULL) {
+        xen_pv_printf(NULL, 0, "can't open xen devicemodel interface\n");
+        xenforeignmemory_close(xen_fmem);
+        xc_interface_close(xen_xc);
+        return -1;
+    }
     qemu_add_vm_change_state_handler(xen_change_state_handler, NULL);
 
     global_state_set_optional();
-- 
2.1.4


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

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 0/5] xen: use new xendevicemodel library
  2017-02-23 14:53 ` Paul Durrant
@ 2017-02-23 14:55   ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:55 UTC (permalink / raw)
  To: Paul Durrant, xen-devel, qemu-devel

> -----Original Message-----
> From: Paul Durrant [mailto:paul.durrant@citrix.com]
> Sent: 23 February 2017 14:54
> To: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org
> Cc: Paul Durrant <Paul.Durrant@citrix.com>
> Subject: [PATCH 0/5] xen: use new xendevicemodel library
> 
> My recent patches to Xen [1] introduced a new library to support
> running device models for HVM guests.
> This series ports QEMU onto the new library if it is available in the
> build environment.
> 

Apologies for the missing reference...

[1] Patches starting with http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=b108240265deea37601f1a605910069a837da841

> Paul Durrant (5):
>   xen: make use of xen_xc implicit in xen_common.h inlines
>   xen: rename xen_modified_memory() to xen_hvm_modified_memory()
>   xen: create wrappers for all other uses of xc_hvm_XXX() functions
>   configure: detect presence of libxendevicemodel
>   xen: use libxendevicemodel when available
> 
>  configure                    |  19 ++++
>  hw/i386/xen/xen_platform.c   |   2 +-
>  hw/xen/xen_backend.c         |   2 -
>  include/exec/ram_addr.h      |   4 +-
>  include/hw/xen/xen.h         |   2 +-
>  include/hw/xen/xen_backend.h |   2 -
>  include/hw/xen/xen_common.h  | 200
> ++++++++++++++++++++++++++++++++-----------
>  xen-common.c                 |  11 +++
>  xen-hvm-stub.c               |   2 +-
>  xen-hvm.c                    |  49 ++++++-----
>  10 files changed, 207 insertions(+), 86 deletions(-)
> 
> --
> 2.1.4

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 0/5] xen: use new xendevicemodel library
@ 2017-02-23 14:55   ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-02-23 14:55 UTC (permalink / raw)
  To: Paul Durrant, xen-devel, qemu-devel

> -----Original Message-----
> From: Paul Durrant [mailto:paul.durrant@citrix.com]
> Sent: 23 February 2017 14:54
> To: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org
> Cc: Paul Durrant <Paul.Durrant@citrix.com>
> Subject: [PATCH 0/5] xen: use new xendevicemodel library
> 
> My recent patches to Xen [1] introduced a new library to support
> running device models for HVM guests.
> This series ports QEMU onto the new library if it is available in the
> build environment.
> 

Apologies for the missing reference...

[1] Patches starting with http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=b108240265deea37601f1a605910069a837da841

> Paul Durrant (5):
>   xen: make use of xen_xc implicit in xen_common.h inlines
>   xen: rename xen_modified_memory() to xen_hvm_modified_memory()
>   xen: create wrappers for all other uses of xc_hvm_XXX() functions
>   configure: detect presence of libxendevicemodel
>   xen: use libxendevicemodel when available
> 
>  configure                    |  19 ++++
>  hw/i386/xen/xen_platform.c   |   2 +-
>  hw/xen/xen_backend.c         |   2 -
>  include/exec/ram_addr.h      |   4 +-
>  include/hw/xen/xen.h         |   2 +-
>  include/hw/xen/xen_backend.h |   2 -
>  include/hw/xen/xen_common.h  | 200
> ++++++++++++++++++++++++++++++++-----------
>  xen-common.c                 |  11 +++
>  xen-hvm-stub.c               |   2 +-
>  xen-hvm.c                    |  49 ++++++-----
>  10 files changed, 207 insertions(+), 86 deletions(-)
> 
> --
> 2.1.4


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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 1/5] xen: make use of xen_xc implicit in xen_common.h inlines
  2017-02-23 14:53   ` Paul Durrant
@ 2017-03-01 15:19     ` Anthony PERARD
  -1 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-01 15:19 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, qemu-devel, Stefano Stabellini

On Thu, Feb 23, 2017 at 02:53:51PM +0000, Paul Durrant wrote:
> Doing this will make the transition to using the new libxendevicemodel
> interface less intrusive on the callers of these functions, since using
> the new library will require a change of handle.
> 
> NOTE: The patch also moves the 'externs' for xen_xc and xen_fmem from
>       xen_backend.h to xen_common.h, and the declarations from
>       xen_backend.c to xen-common.c, which is where they belong.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

-- 
Anthony PERARD

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 1/5] xen: make use of xen_xc implicit in xen_common.h inlines
@ 2017-03-01 15:19     ` Anthony PERARD
  0 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-01 15:19 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, Stefano Stabellini, qemu-devel

On Thu, Feb 23, 2017 at 02:53:51PM +0000, Paul Durrant wrote:
> Doing this will make the transition to using the new libxendevicemodel
> interface less intrusive on the callers of these functions, since using
> the new library will require a change of handle.
> 
> NOTE: The patch also moves the 'externs' for xen_xc and xen_fmem from
>       xen_backend.h to xen_common.h, and the declarations from
>       xen_backend.c to xen-common.c, which is where they belong.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

-- 
Anthony PERARD

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 2/5] xen: rename xen_modified_memory() to xen_hvm_modified_memory()
  2017-02-23 14:53   ` Paul Durrant
@ 2017-03-01 15:24     ` Anthony PERARD
  -1 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-01 15:24 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, qemu-devel, Paolo Bonzini, Stefano Stabellini

On Thu, Feb 23, 2017 at 02:53:52PM +0000, Paul Durrant wrote:
> This patch is a purely cosmetic change that avoids a name collision in
> a subsequent patch.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

-- 
Anthony PERARD

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 2/5] xen: rename xen_modified_memory() to xen_hvm_modified_memory()
@ 2017-03-01 15:24     ` Anthony PERARD
  0 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-01 15:24 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, Stefano Stabellini, qemu-devel, Paolo Bonzini

On Thu, Feb 23, 2017 at 02:53:52PM +0000, Paul Durrant wrote:
> This patch is a purely cosmetic change that avoids a name collision in
> a subsequent patch.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

-- 
Anthony PERARD

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions
  2017-02-23 14:53 ` [Qemu-devel] " Paul Durrant
@ 2017-03-01 16:13     ` Anthony PERARD
  0 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-01 16:13 UTC (permalink / raw)
  To: Paul Durrant
  Cc: xen-devel, qemu-devel, Stefano Stabellini, Paolo Bonzini,
	Richard Henderson, Eduardo Habkost, Michael S. Tsirkin

On Thu, Feb 23, 2017 at 02:53:53PM +0000, Paul Durrant wrote:
> This patch creates inline wrapper functions in xen_common.h for all open
> coded calls to xc_hvm_XXX() functions outside of xen_common.h so that use
> of xen_xc can be made implicit. This again is in preparation for the move
> to using libxendevicemodel.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> ---
> diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
> index 1e08b98..31cf25f 100644
> --- a/include/hw/xen/xen_common.h
> +++ b/include/hw/xen/xen_common.h
> @@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
>   * We don't support Xen prior to 4.2.0.
>   */
>  
> +static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
> +                                   uint64_t first_pfn, uint32_t nr)
> +{

I don't know if it matters from where the functions are called, but
here, xc_hvm_set_mem_type takes a "uint64_t nr" (and not uint32_t).

> +    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
> +}
> +
> +static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
> +                                         uint8_t bus, uint8_t device,
> +                                         uint8_t intx, unsigned int level)
> +{
> +    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
> +                                     intx, level);
> +}
> +
> +static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
> +                                         uint8_t irq)
> +{
> +    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
> +}
> +
> +static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
> +                                 uint32_t msi_data)
> +{
> +    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
> +}
> +
> +static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
> +                                        unsigned int level)
> +{
> +    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
> +}
> +
> +static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
> +                                       uint32_t nr, unsigned long *bitmap)
> +{

Same here.

> +    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
> +}
> +
> +static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
> +                                      uint32_t nr)
> +{

And here.

> +    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
> +}
> +
>  /* Xen 4.2 through 4.6 */
>  #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471
>  

The rest looks good.

-- 
Anthony PERARD

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions
@ 2017-03-01 16:13     ` Anthony PERARD
  0 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-01 16:13 UTC (permalink / raw)
  To: Paul Durrant
  Cc: Stefano Stabellini, Eduardo Habkost, Michael S. Tsirkin,
	qemu-devel, Paolo Bonzini, xen-devel, Richard Henderson

On Thu, Feb 23, 2017 at 02:53:53PM +0000, Paul Durrant wrote:
> This patch creates inline wrapper functions in xen_common.h for all open
> coded calls to xc_hvm_XXX() functions outside of xen_common.h so that use
> of xen_xc can be made implicit. This again is in preparation for the move
> to using libxendevicemodel.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> ---
> diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
> index 1e08b98..31cf25f 100644
> --- a/include/hw/xen/xen_common.h
> +++ b/include/hw/xen/xen_common.h
> @@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
>   * We don't support Xen prior to 4.2.0.
>   */
>  
> +static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
> +                                   uint64_t first_pfn, uint32_t nr)
> +{

I don't know if it matters from where the functions are called, but
here, xc_hvm_set_mem_type takes a "uint64_t nr" (and not uint32_t).

> +    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
> +}
> +
> +static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
> +                                         uint8_t bus, uint8_t device,
> +                                         uint8_t intx, unsigned int level)
> +{
> +    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
> +                                     intx, level);
> +}
> +
> +static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
> +                                         uint8_t irq)
> +{
> +    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
> +}
> +
> +static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
> +                                 uint32_t msi_data)
> +{
> +    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
> +}
> +
> +static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
> +                                        unsigned int level)
> +{
> +    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
> +}
> +
> +static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
> +                                       uint32_t nr, unsigned long *bitmap)
> +{

Same here.

> +    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
> +}
> +
> +static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
> +                                      uint32_t nr)
> +{

And here.

> +    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
> +}
> +
>  /* Xen 4.2 through 4.6 */
>  #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471
>  

The rest looks good.

-- 
Anthony PERARD

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions
  2017-03-01 16:13     ` Anthony PERARD
@ 2017-03-01 16:16       ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-01 16:16 UTC (permalink / raw)
  To: Anthony Perard
  Cc: xen-devel, qemu-devel, Stefano Stabellini, Paolo Bonzini,
	Richard Henderson, Eduardo Habkost, Michael S. Tsirkin

> -----Original Message-----
> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> Sent: 01 March 2017 16:14
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> Stabellini <sstabellini@kernel.org>; Paolo Bonzini <pbonzini@redhat.com>;
> Richard Henderson <rth@twiddle.net>; Eduardo Habkost
> <ehabkost@redhat.com>; Michael S. Tsirkin <mst@redhat.com>
> Subject: Re: [PATCH 3/5] xen: create wrappers for all other uses of
> xc_hvm_XXX() functions
> 
> On Thu, Feb 23, 2017 at 02:53:53PM +0000, Paul Durrant wrote:
> > This patch creates inline wrapper functions in xen_common.h for all open
> > coded calls to xc_hvm_XXX() functions outside of xen_common.h so that
> use
> > of xen_xc can be made implicit. This again is in preparation for the move
> > to using libxendevicemodel.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > ---
> > diff --git a/include/hw/xen/xen_common.h
> b/include/hw/xen/xen_common.h
> > index 1e08b98..31cf25f 100644
> > --- a/include/hw/xen/xen_common.h
> > +++ b/include/hw/xen/xen_common.h
> > @@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
> >   * We don't support Xen prior to 4.2.0.
> >   */
> >
> > +static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t
> type,
> > +                                   uint64_t first_pfn, uint32_t nr)
> > +{
> 
> I don't know if it matters from where the functions are called, but
> here, xc_hvm_set_mem_type takes a "uint64_t nr" (and not uint32_t).

Yes, the old APIs were wrong and discarded the upper 32 bits, so limiting here is correct. Moving to the new API fixes the issue.

> 
> > +    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
> > +}
> > +
> > +static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
> > +                                         uint8_t bus, uint8_t device,
> > +                                         uint8_t intx, unsigned int level)
> > +{
> > +    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus,
> device,
> > +                                     intx, level);
> > +}
> > +
> > +static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
> > +                                         uint8_t irq)
> > +{
> > +    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
> > +}
> > +
> > +static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
> > +                                 uint32_t msi_data)
> > +{
> > +    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
> > +}
> > +
> > +static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
> > +                                        unsigned int level)
> > +{
> > +    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
> > +}
> > +
> > +static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
> > +                                       uint32_t nr, unsigned long *bitmap)
> > +{
> 
> Same here.
> 
> > +    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
> > +}
> > +
> > +static inline int xen_modified_memory(domid_t domid, uint64_t
> first_pfn,
> > +                                      uint32_t nr)
> > +{
> 
> And here.
> 
> > +    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
> > +}
> > +
> >  /* Xen 4.2 through 4.6 */
> >  #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471
> >
> 
> The rest looks good.

Thanks,

  Paul

> 
> --
> Anthony PERARD

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions
@ 2017-03-01 16:16       ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-01 16:16 UTC (permalink / raw)
  To: Anthony Perard
  Cc: Stefano Stabellini, Eduardo Habkost, Michael S. Tsirkin,
	qemu-devel, Paolo Bonzini, xen-devel, Richard Henderson

> -----Original Message-----
> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> Sent: 01 March 2017 16:14
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> Stabellini <sstabellini@kernel.org>; Paolo Bonzini <pbonzini@redhat.com>;
> Richard Henderson <rth@twiddle.net>; Eduardo Habkost
> <ehabkost@redhat.com>; Michael S. Tsirkin <mst@redhat.com>
> Subject: Re: [PATCH 3/5] xen: create wrappers for all other uses of
> xc_hvm_XXX() functions
> 
> On Thu, Feb 23, 2017 at 02:53:53PM +0000, Paul Durrant wrote:
> > This patch creates inline wrapper functions in xen_common.h for all open
> > coded calls to xc_hvm_XXX() functions outside of xen_common.h so that
> use
> > of xen_xc can be made implicit. This again is in preparation for the move
> > to using libxendevicemodel.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > ---
> > diff --git a/include/hw/xen/xen_common.h
> b/include/hw/xen/xen_common.h
> > index 1e08b98..31cf25f 100644
> > --- a/include/hw/xen/xen_common.h
> > +++ b/include/hw/xen/xen_common.h
> > @@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
> >   * We don't support Xen prior to 4.2.0.
> >   */
> >
> > +static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t
> type,
> > +                                   uint64_t first_pfn, uint32_t nr)
> > +{
> 
> I don't know if it matters from where the functions are called, but
> here, xc_hvm_set_mem_type takes a "uint64_t nr" (and not uint32_t).

Yes, the old APIs were wrong and discarded the upper 32 bits, so limiting here is correct. Moving to the new API fixes the issue.

> 
> > +    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
> > +}
> > +
> > +static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
> > +                                         uint8_t bus, uint8_t device,
> > +                                         uint8_t intx, unsigned int level)
> > +{
> > +    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus,
> device,
> > +                                     intx, level);
> > +}
> > +
> > +static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
> > +                                         uint8_t irq)
> > +{
> > +    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
> > +}
> > +
> > +static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
> > +                                 uint32_t msi_data)
> > +{
> > +    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
> > +}
> > +
> > +static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
> > +                                        unsigned int level)
> > +{
> > +    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
> > +}
> > +
> > +static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
> > +                                       uint32_t nr, unsigned long *bitmap)
> > +{
> 
> Same here.
> 
> > +    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
> > +}
> > +
> > +static inline int xen_modified_memory(domid_t domid, uint64_t
> first_pfn,
> > +                                      uint32_t nr)
> > +{
> 
> And here.
> 
> > +    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
> > +}
> > +
> >  /* Xen 4.2 through 4.6 */
> >  #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 471
> >
> 
> The rest looks good.

Thanks,

  Paul

> 
> --
> Anthony PERARD

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] configure: detect presence of libxendevicemodel
  2017-02-23 14:53   ` Paul Durrant
@ 2017-03-01 17:17     ` Anthony PERARD
  -1 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-01 17:17 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, qemu-devel, Stefano Stabellini

On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> This patch adds code in configure to set CONFIG_XEN_CTRL_INTERFACE_VERSION
> to a new value of 490 if libxendevicemodel is present in the build
> environment.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> ---
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> ---
>  configure | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/configure b/configure
> index 8e8f18d..fc1e12b 100755
> --- a/configure
> +++ b/configure
> @@ -1980,6 +1980,25 @@ EOF
>    # Xen unstable
>    elif
>        cat > $TMPC <<EOF &&
> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> +#define __XEN_TOOLS__

Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
xen.git?

Also it seems to be the only time this define is used in your patch
series.

> +#include <xendevicemodel.h>
> +int main(void) {
> +  xendevicemodel_handle *xd;
> +
> +  xd = xendevicemodel_open(0, 0);
> +  xendevicemodel_close(xd);
> +
> +  return 0;
> +}
> +EOF
> +      compile_prog "" "$xen_libs $xen_stable_libs -lxendevicemodel"
> +    then
> +    xen_stable_libs="$xen_stable_libs -lxendevicemodel"
> +    xen_ctrl_version=490
> +    xen=yes
> +  elif
> +      cat > $TMPC <<EOF &&
>  /*
>   * If we have stable libs the we don't want the libxc compat
>   * layers, regardless of what CFLAGS we may have been given.
> -- 
> 2.1.4
> 

-- 
Anthony PERARD

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
@ 2017-03-01 17:17     ` Anthony PERARD
  0 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-01 17:17 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, Stefano Stabellini, qemu-devel

On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> This patch adds code in configure to set CONFIG_XEN_CTRL_INTERFACE_VERSION
> to a new value of 490 if libxendevicemodel is present in the build
> environment.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> ---
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> ---
>  configure | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/configure b/configure
> index 8e8f18d..fc1e12b 100755
> --- a/configure
> +++ b/configure
> @@ -1980,6 +1980,25 @@ EOF
>    # Xen unstable
>    elif
>        cat > $TMPC <<EOF &&
> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> +#define __XEN_TOOLS__

Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
xen.git?

Also it seems to be the only time this define is used in your patch
series.

> +#include <xendevicemodel.h>
> +int main(void) {
> +  xendevicemodel_handle *xd;
> +
> +  xd = xendevicemodel_open(0, 0);
> +  xendevicemodel_close(xd);
> +
> +  return 0;
> +}
> +EOF
> +      compile_prog "" "$xen_libs $xen_stable_libs -lxendevicemodel"
> +    then
> +    xen_stable_libs="$xen_stable_libs -lxendevicemodel"
> +    xen_ctrl_version=490
> +    xen=yes
> +  elif
> +      cat > $TMPC <<EOF &&
>  /*
>   * If we have stable libs the we don't want the libxc compat
>   * layers, regardless of what CFLAGS we may have been given.
> -- 
> 2.1.4
> 

-- 
Anthony PERARD

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 5/5] xen: use libxendevicemodel when available
  2017-02-23 14:53   ` Paul Durrant
@ 2017-03-02  2:05     ` Stefano Stabellini
  -1 siblings, 0 replies; 42+ messages in thread
From: Stefano Stabellini @ 2017-03-02  2:05 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, qemu-devel, Stefano Stabellini, Anthony Perard

On Thu, 23 Feb 2017, Paul Durrant wrote:
> This patch modifies the wrapper functions in xen_common.h to use the
> new xendevicemodel interface if it is available along with compatibility
> code to use the old libxenctrl interface if it is not.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

Hi Paul,

Sorry for the late reply, I am flooded with patches over here. Aside
from Anthony's comments, the other patches of this series look good to
me.

The Xen side patches are not in, are they? Do you have a Xen git branch
with them so that I can test this patch properly?

This patch breaks the build against Xen >= 4.3, with:

/local/qemu-upstream/xen-common.c: In function 'xen_init':
/local/qemu-upstream/xen-common.c:135:9: error: implicit declaration of function 'xenforeignmemory_close' [-Werror=implicit-function-declaration]
/local/qemu-upstream/xen-common.c:135:9: error: nested extern declaration of 'xenforeignmemory_close' [-Werror=nested-externs]
cc1: all warnings being treated as errors


> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> ---
>  include/hw/xen/xen_common.h | 114 +++++++++++++++++++++++++++++++-------------
>  xen-common.c                |   8 ++++
>  2 files changed, 89 insertions(+), 33 deletions(-)
> 
> diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
> index 31cf25f..2c2a61b 100644
> --- a/include/hw/xen/xen_common.h
> +++ b/include/hw/xen/xen_common.h
> @@ -9,6 +9,7 @@
>  #undef XC_WANT_COMPAT_EVTCHN_API
>  #undef XC_WANT_COMPAT_GNTTAB_API
>  #undef XC_WANT_COMPAT_MAP_FOREIGN_API
> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
>  
>  #include <xenctrl.h>
>  #include <xenstore.h>
> @@ -26,48 +27,95 @@ extern xc_interface *xen_xc;
>   * We don't support Xen prior to 4.2.0.
>   */
>  
> +#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 490
> +
> +typedef xc_interface xendevicemodel_handle;
> +
> +#define xendevicemodel_open(l, f) xen_xc
> +
> +#define xendevicemodel_map_io_range_to_ioreq_server \

Could you please use static inline functions for compatibility rather
than macros? That way we are going to have some more compile time
checks. Or at least macros with parameters.


> +    xc_hvm_map_io_range_to_ioreq_server
> +#define xendevicemodel_unmap_io_range_from_ioreq_server \
> +    xc_hvm_unmap_io_range_from_ioreq_server
> +#define xendevicemodel_map_pcidev_to_ioreq_server \
> +    xc_hvm_map_pcidev_to_ioreq_server
> +#define xendevicemodel_unmap_pcidev_from_ioreq_server \
> +    xc_hvm_unmap_pcidev_from_ioreq_server
> +#define xendevicemodel_create_ioreq_server \
> +    xc_hvm_create_ioreq_server
> +#define xendevicemodel_destroy_ioreq_server \
> +    xc_hvm_destroy_ioreq_server
> +#define xendevicemodel_get_ioreq_server_info \
> +    xc_hvm_get_ioreq_server_info
> +#define xendevicemodel_set_ioreq_server_state \
> +    xc_hvm_set_ioreq_server_state
> +#define xendevicemodel_set_pci_intx_level \
> +    xc_hvm_set_pci_intx_level
> +#define xendevicemodel_set_pci_link_route \
> +    xc_hvm_set_pci_link_route
> +#define xendevicemodel_set_isa_irq_level \
> +    xc_hvm_set_isa_irq_level
> +#define xendevicemodel_inject_msi \
> +    xc_hvm_inject_msi
> +#define xendevicemodel_set_mem_type \
> +    xc_hvm_set_mem_type
> +#define xendevicemodel_track_dirty_vram \
> +    xc_hvm_track_dirty_vram
> +#define xendevicemodel_modified_memory \
> +    xc_hvm_modified_memory
> +
> +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 490 */
> +
> +#include <xendevicemodel.h>
> +
> +#endif
> +
> +extern xendevicemodel_handle *xen_dmod;
> +
>  static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
>                                     uint64_t first_pfn, uint32_t nr)
>  {
> -    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
> +    return xendevicemodel_set_mem_type(xen_dmod, domid, type, first_pfn,
> +                                       nr);
>  }
>  
>  static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
>                                           uint8_t bus, uint8_t device,
>                                           uint8_t intx, unsigned int level)
>  {
> -    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
> -                                     intx, level);
> +    return xendevicemodel_set_pci_intx_level(xen_dmod, domid, segment, bus,
> +                                             device, intx, level);
>  }
>  
>  static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
>                                           uint8_t irq)
>  {
> -    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
> +    return xendevicemodel_set_pci_link_route(xen_dmod, domid, link, irq);
>  }
>  
>  static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
>                                   uint32_t msi_data)
>  {
> -    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
> +    return xendevicemodel_inject_msi(xen_dmod, domid, msi_addr, msi_data);
>  }
>  
>  static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
>                                          unsigned int level)
>  {
> -    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
> +    return xendevicemodel_set_isa_irq_level(xen_dmod, domid, irq, level);
>  }
>  
>  static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
>                                         uint32_t nr, unsigned long *bitmap)
>  {
> -    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
> +    return xendevicemodel_track_dirty_vram(xen_dmod, domid, first_pfn, nr,
> +                                           bitmap);
>  }
>  
>  static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
>                                        uint32_t nr)
>  {
> -    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
> +    return xendevicemodel_modified_memory(xen_dmod, domid, first_pfn, nr);
>  }
>  
>  /* Xen 4.2 through 4.6 */
> @@ -285,8 +333,8 @@ static inline void xen_map_memory_section(domid_t dom,
>      }
>  
>      trace_xen_map_mmio_range(ioservid, start_addr, end_addr);
> -    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 1,
> -                                        start_addr, end_addr);
> +    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom, ioservid, 1,
> +                                                start_addr, end_addr);
>  }
>  
>  static inline void xen_unmap_memory_section(domid_t dom,
> @@ -302,8 +350,8 @@ static inline void xen_unmap_memory_section(domid_t dom,
>      }
>  
>      trace_xen_unmap_mmio_range(ioservid, start_addr, end_addr);
> -    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
> -                                            1, start_addr, end_addr);
> +    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod, dom, ioservid,
> +                                                    1, start_addr, end_addr);
>  }
>  
>  static inline void xen_map_io_section(domid_t dom,
> @@ -319,8 +367,8 @@ static inline void xen_map_io_section(domid_t dom,
>      }
>  
>      trace_xen_map_portio_range(ioservid, start_addr, end_addr);
> -    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 0,
> -                                        start_addr, end_addr);
> +    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom, ioservid, 0,
> +                                                start_addr, end_addr);
>  }
>  
>  static inline void xen_unmap_io_section(domid_t dom,
> @@ -336,8 +384,8 @@ static inline void xen_unmap_io_section(domid_t dom,
>      }
>  
>      trace_xen_unmap_portio_range(ioservid, start_addr, end_addr);
> -    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
> -                                            0, start_addr, end_addr);
> +    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod, dom, ioservid,
> +                                                    0, start_addr, end_addr);
>  }
>  
>  static inline void xen_map_pcidev(domid_t dom,
> @@ -350,10 +398,10 @@ static inline void xen_map_pcidev(domid_t dom,
>  
>      trace_xen_map_pcidev(ioservid, pci_bus_num(pci_dev->bus),
>                           PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
> -    xc_hvm_map_pcidev_to_ioreq_server(xen_xc, dom, ioservid, 0,
> -                                      pci_bus_num(pci_dev->bus),
> -                                      PCI_SLOT(pci_dev->devfn),
> -                                      PCI_FUNC(pci_dev->devfn));
> +    xendevicemodel_map_pcidev_to_ioreq_server(xen_dmod, dom, ioservid, 0,
> +                                              pci_bus_num(pci_dev->bus),
> +                                              PCI_SLOT(pci_dev->devfn),
> +                                              PCI_FUNC(pci_dev->devfn));
>  }
>  
>  static inline void xen_unmap_pcidev(domid_t dom,
> @@ -366,18 +414,18 @@ static inline void xen_unmap_pcidev(domid_t dom,
>  
>      trace_xen_unmap_pcidev(ioservid, pci_bus_num(pci_dev->bus),
>                             PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
> -    xc_hvm_unmap_pcidev_from_ioreq_server(xen_xc, dom, ioservid, 0,
> -                                          pci_bus_num(pci_dev->bus),
> -                                          PCI_SLOT(pci_dev->devfn),
> -                                          PCI_FUNC(pci_dev->devfn));
> +    xendevicemodel_unmap_pcidev_from_ioreq_server(xen_dmod, dom, ioservid, 0,
> +                                                  pci_bus_num(pci_dev->bus),
> +                                                  PCI_SLOT(pci_dev->devfn),
> +                                                  PCI_FUNC(pci_dev->devfn));
>  }
>  
>  static inline void xen_create_ioreq_server(domid_t dom,
>                                             ioservid_t *ioservid)
>  {
> -    int rc = xc_hvm_create_ioreq_server(xen_xc, dom,
> -                                        HVM_IOREQSRV_BUFIOREQ_ATOMIC,
> -                                        ioservid);
> +    int rc = xendevicemodel_create_ioreq_server(xen_dmod, dom,
> +                                                HVM_IOREQSRV_BUFIOREQ_ATOMIC,
> +                                                ioservid);
>  
>      if (rc == 0) {
>          trace_xen_ioreq_server_create(*ioservid);
> @@ -397,7 +445,7 @@ static inline void xen_destroy_ioreq_server(domid_t dom,
>      }
>  
>      trace_xen_ioreq_server_destroy(ioservid);
> -    xc_hvm_destroy_ioreq_server(xen_xc, dom, ioservid);
> +    xendevicemodel_destroy_ioreq_server(xen_dmod, dom, ioservid);
>  }
>  
>  static inline int xen_get_ioreq_server_info(domid_t dom,
> @@ -412,9 +460,9 @@ static inline int xen_get_ioreq_server_info(domid_t dom,
>                                                   bufioreq_evtchn);
>      }
>  
> -    return xc_hvm_get_ioreq_server_info(xen_xc, dom, ioservid,
> -                                        ioreq_pfn, bufioreq_pfn,
> -                                        bufioreq_evtchn);
> +    return xendevicemodel_get_ioreq_server_info(xen_dmod, dom, ioservid,
> +                                                ioreq_pfn, bufioreq_pfn,
> +                                                bufioreq_evtchn);
>  }
>  
>  static inline int xen_set_ioreq_server_state(domid_t dom,
> @@ -426,8 +474,8 @@ static inline int xen_set_ioreq_server_state(domid_t dom,
>      }
>  
>      trace_xen_ioreq_server_state(ioservid, enable);
> -    return xc_hvm_set_ioreq_server_state(xen_xc, dom, ioservid,
> -                                         enable);
> +    return xendevicemodel_set_ioreq_server_state(xen_dmod, dom, ioservid,
> +                                                 enable);
>  }
>  
>  #endif
> diff --git a/xen-common.c b/xen-common.c
> index 703e7a5..ae76150 100644
> --- a/xen-common.c
> +++ b/xen-common.c
> @@ -27,6 +27,7 @@
>  
>  xc_interface *xen_xc;
>  xenforeignmemory_handle *xen_fmem;
> +xendevicemodel_handle *xen_dmod;
>  
>  static int store_dev_info(int domid, Chardev *cs, const char *string)
>  {
> @@ -128,6 +129,13 @@ static int xen_init(MachineState *ms)
>          xc_interface_close(xen_xc);
>          return -1;
>      }
> +    xen_dmod = xendevicemodel_open(0, 0);
> +    if (xen_dmod == NULL) {
> +        xen_pv_printf(NULL, 0, "can't open xen devicemodel interface\n");
> +        xenforeignmemory_close(xen_fmem);
> +        xc_interface_close(xen_xc);
> +        return -1;
> +    }
>      qemu_add_vm_change_state_handler(xen_change_state_handler, NULL);
>  
>      global_state_set_optional();
> -- 
> 2.1.4
> 

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 5/5] xen: use libxendevicemodel when available
@ 2017-03-02  2:05     ` Stefano Stabellini
  0 siblings, 0 replies; 42+ messages in thread
From: Stefano Stabellini @ 2017-03-02  2:05 UTC (permalink / raw)
  To: Paul Durrant; +Cc: Anthony Perard, xen-devel, Stefano Stabellini, qemu-devel

On Thu, 23 Feb 2017, Paul Durrant wrote:
> This patch modifies the wrapper functions in xen_common.h to use the
> new xendevicemodel interface if it is available along with compatibility
> code to use the old libxenctrl interface if it is not.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

Hi Paul,

Sorry for the late reply, I am flooded with patches over here. Aside
from Anthony's comments, the other patches of this series look good to
me.

The Xen side patches are not in, are they? Do you have a Xen git branch
with them so that I can test this patch properly?

This patch breaks the build against Xen >= 4.3, with:

/local/qemu-upstream/xen-common.c: In function 'xen_init':
/local/qemu-upstream/xen-common.c:135:9: error: implicit declaration of function 'xenforeignmemory_close' [-Werror=implicit-function-declaration]
/local/qemu-upstream/xen-common.c:135:9: error: nested extern declaration of 'xenforeignmemory_close' [-Werror=nested-externs]
cc1: all warnings being treated as errors


> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> ---
>  include/hw/xen/xen_common.h | 114 +++++++++++++++++++++++++++++++-------------
>  xen-common.c                |   8 ++++
>  2 files changed, 89 insertions(+), 33 deletions(-)
> 
> diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
> index 31cf25f..2c2a61b 100644
> --- a/include/hw/xen/xen_common.h
> +++ b/include/hw/xen/xen_common.h
> @@ -9,6 +9,7 @@
>  #undef XC_WANT_COMPAT_EVTCHN_API
>  #undef XC_WANT_COMPAT_GNTTAB_API
>  #undef XC_WANT_COMPAT_MAP_FOREIGN_API
> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
>  
>  #include <xenctrl.h>
>  #include <xenstore.h>
> @@ -26,48 +27,95 @@ extern xc_interface *xen_xc;
>   * We don't support Xen prior to 4.2.0.
>   */
>  
> +#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 490
> +
> +typedef xc_interface xendevicemodel_handle;
> +
> +#define xendevicemodel_open(l, f) xen_xc
> +
> +#define xendevicemodel_map_io_range_to_ioreq_server \

Could you please use static inline functions for compatibility rather
than macros? That way we are going to have some more compile time
checks. Or at least macros with parameters.


> +    xc_hvm_map_io_range_to_ioreq_server
> +#define xendevicemodel_unmap_io_range_from_ioreq_server \
> +    xc_hvm_unmap_io_range_from_ioreq_server
> +#define xendevicemodel_map_pcidev_to_ioreq_server \
> +    xc_hvm_map_pcidev_to_ioreq_server
> +#define xendevicemodel_unmap_pcidev_from_ioreq_server \
> +    xc_hvm_unmap_pcidev_from_ioreq_server
> +#define xendevicemodel_create_ioreq_server \
> +    xc_hvm_create_ioreq_server
> +#define xendevicemodel_destroy_ioreq_server \
> +    xc_hvm_destroy_ioreq_server
> +#define xendevicemodel_get_ioreq_server_info \
> +    xc_hvm_get_ioreq_server_info
> +#define xendevicemodel_set_ioreq_server_state \
> +    xc_hvm_set_ioreq_server_state
> +#define xendevicemodel_set_pci_intx_level \
> +    xc_hvm_set_pci_intx_level
> +#define xendevicemodel_set_pci_link_route \
> +    xc_hvm_set_pci_link_route
> +#define xendevicemodel_set_isa_irq_level \
> +    xc_hvm_set_isa_irq_level
> +#define xendevicemodel_inject_msi \
> +    xc_hvm_inject_msi
> +#define xendevicemodel_set_mem_type \
> +    xc_hvm_set_mem_type
> +#define xendevicemodel_track_dirty_vram \
> +    xc_hvm_track_dirty_vram
> +#define xendevicemodel_modified_memory \
> +    xc_hvm_modified_memory
> +
> +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 490 */
> +
> +#include <xendevicemodel.h>
> +
> +#endif
> +
> +extern xendevicemodel_handle *xen_dmod;
> +
>  static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t type,
>                                     uint64_t first_pfn, uint32_t nr)
>  {
> -    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
> +    return xendevicemodel_set_mem_type(xen_dmod, domid, type, first_pfn,
> +                                       nr);
>  }
>  
>  static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
>                                           uint8_t bus, uint8_t device,
>                                           uint8_t intx, unsigned int level)
>  {
> -    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus, device,
> -                                     intx, level);
> +    return xendevicemodel_set_pci_intx_level(xen_dmod, domid, segment, bus,
> +                                             device, intx, level);
>  }
>  
>  static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
>                                           uint8_t irq)
>  {
> -    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
> +    return xendevicemodel_set_pci_link_route(xen_dmod, domid, link, irq);
>  }
>  
>  static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
>                                   uint32_t msi_data)
>  {
> -    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
> +    return xendevicemodel_inject_msi(xen_dmod, domid, msi_addr, msi_data);
>  }
>  
>  static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
>                                          unsigned int level)
>  {
> -    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
> +    return xendevicemodel_set_isa_irq_level(xen_dmod, domid, irq, level);
>  }
>  
>  static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
>                                         uint32_t nr, unsigned long *bitmap)
>  {
> -    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
> +    return xendevicemodel_track_dirty_vram(xen_dmod, domid, first_pfn, nr,
> +                                           bitmap);
>  }
>  
>  static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
>                                        uint32_t nr)
>  {
> -    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
> +    return xendevicemodel_modified_memory(xen_dmod, domid, first_pfn, nr);
>  }
>  
>  /* Xen 4.2 through 4.6 */
> @@ -285,8 +333,8 @@ static inline void xen_map_memory_section(domid_t dom,
>      }
>  
>      trace_xen_map_mmio_range(ioservid, start_addr, end_addr);
> -    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 1,
> -                                        start_addr, end_addr);
> +    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom, ioservid, 1,
> +                                                start_addr, end_addr);
>  }
>  
>  static inline void xen_unmap_memory_section(domid_t dom,
> @@ -302,8 +350,8 @@ static inline void xen_unmap_memory_section(domid_t dom,
>      }
>  
>      trace_xen_unmap_mmio_range(ioservid, start_addr, end_addr);
> -    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
> -                                            1, start_addr, end_addr);
> +    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod, dom, ioservid,
> +                                                    1, start_addr, end_addr);
>  }
>  
>  static inline void xen_map_io_section(domid_t dom,
> @@ -319,8 +367,8 @@ static inline void xen_map_io_section(domid_t dom,
>      }
>  
>      trace_xen_map_portio_range(ioservid, start_addr, end_addr);
> -    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 0,
> -                                        start_addr, end_addr);
> +    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom, ioservid, 0,
> +                                                start_addr, end_addr);
>  }
>  
>  static inline void xen_unmap_io_section(domid_t dom,
> @@ -336,8 +384,8 @@ static inline void xen_unmap_io_section(domid_t dom,
>      }
>  
>      trace_xen_unmap_portio_range(ioservid, start_addr, end_addr);
> -    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
> -                                            0, start_addr, end_addr);
> +    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod, dom, ioservid,
> +                                                    0, start_addr, end_addr);
>  }
>  
>  static inline void xen_map_pcidev(domid_t dom,
> @@ -350,10 +398,10 @@ static inline void xen_map_pcidev(domid_t dom,
>  
>      trace_xen_map_pcidev(ioservid, pci_bus_num(pci_dev->bus),
>                           PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
> -    xc_hvm_map_pcidev_to_ioreq_server(xen_xc, dom, ioservid, 0,
> -                                      pci_bus_num(pci_dev->bus),
> -                                      PCI_SLOT(pci_dev->devfn),
> -                                      PCI_FUNC(pci_dev->devfn));
> +    xendevicemodel_map_pcidev_to_ioreq_server(xen_dmod, dom, ioservid, 0,
> +                                              pci_bus_num(pci_dev->bus),
> +                                              PCI_SLOT(pci_dev->devfn),
> +                                              PCI_FUNC(pci_dev->devfn));
>  }
>  
>  static inline void xen_unmap_pcidev(domid_t dom,
> @@ -366,18 +414,18 @@ static inline void xen_unmap_pcidev(domid_t dom,
>  
>      trace_xen_unmap_pcidev(ioservid, pci_bus_num(pci_dev->bus),
>                             PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
> -    xc_hvm_unmap_pcidev_from_ioreq_server(xen_xc, dom, ioservid, 0,
> -                                          pci_bus_num(pci_dev->bus),
> -                                          PCI_SLOT(pci_dev->devfn),
> -                                          PCI_FUNC(pci_dev->devfn));
> +    xendevicemodel_unmap_pcidev_from_ioreq_server(xen_dmod, dom, ioservid, 0,
> +                                                  pci_bus_num(pci_dev->bus),
> +                                                  PCI_SLOT(pci_dev->devfn),
> +                                                  PCI_FUNC(pci_dev->devfn));
>  }
>  
>  static inline void xen_create_ioreq_server(domid_t dom,
>                                             ioservid_t *ioservid)
>  {
> -    int rc = xc_hvm_create_ioreq_server(xen_xc, dom,
> -                                        HVM_IOREQSRV_BUFIOREQ_ATOMIC,
> -                                        ioservid);
> +    int rc = xendevicemodel_create_ioreq_server(xen_dmod, dom,
> +                                                HVM_IOREQSRV_BUFIOREQ_ATOMIC,
> +                                                ioservid);
>  
>      if (rc == 0) {
>          trace_xen_ioreq_server_create(*ioservid);
> @@ -397,7 +445,7 @@ static inline void xen_destroy_ioreq_server(domid_t dom,
>      }
>  
>      trace_xen_ioreq_server_destroy(ioservid);
> -    xc_hvm_destroy_ioreq_server(xen_xc, dom, ioservid);
> +    xendevicemodel_destroy_ioreq_server(xen_dmod, dom, ioservid);
>  }
>  
>  static inline int xen_get_ioreq_server_info(domid_t dom,
> @@ -412,9 +460,9 @@ static inline int xen_get_ioreq_server_info(domid_t dom,
>                                                   bufioreq_evtchn);
>      }
>  
> -    return xc_hvm_get_ioreq_server_info(xen_xc, dom, ioservid,
> -                                        ioreq_pfn, bufioreq_pfn,
> -                                        bufioreq_evtchn);
> +    return xendevicemodel_get_ioreq_server_info(xen_dmod, dom, ioservid,
> +                                                ioreq_pfn, bufioreq_pfn,
> +                                                bufioreq_evtchn);
>  }
>  
>  static inline int xen_set_ioreq_server_state(domid_t dom,
> @@ -426,8 +474,8 @@ static inline int xen_set_ioreq_server_state(domid_t dom,
>      }
>  
>      trace_xen_ioreq_server_state(ioservid, enable);
> -    return xc_hvm_set_ioreq_server_state(xen_xc, dom, ioservid,
> -                                         enable);
> +    return xendevicemodel_set_ioreq_server_state(xen_dmod, dom, ioservid,
> +                                                 enable);
>  }
>  
>  #endif
> diff --git a/xen-common.c b/xen-common.c
> index 703e7a5..ae76150 100644
> --- a/xen-common.c
> +++ b/xen-common.c
> @@ -27,6 +27,7 @@
>  
>  xc_interface *xen_xc;
>  xenforeignmemory_handle *xen_fmem;
> +xendevicemodel_handle *xen_dmod;
>  
>  static int store_dev_info(int domid, Chardev *cs, const char *string)
>  {
> @@ -128,6 +129,13 @@ static int xen_init(MachineState *ms)
>          xc_interface_close(xen_xc);
>          return -1;
>      }
> +    xen_dmod = xendevicemodel_open(0, 0);
> +    if (xen_dmod == NULL) {
> +        xen_pv_printf(NULL, 0, "can't open xen devicemodel interface\n");
> +        xenforeignmemory_close(xen_fmem);
> +        xc_interface_close(xen_xc);
> +        return -1;
> +    }
>      qemu_add_vm_change_state_handler(xen_change_state_handler, NULL);
>  
>      global_state_set_optional();
> -- 
> 2.1.4
> 

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 5/5] xen: use libxendevicemodel when available
  2017-03-02  2:05     ` Stefano Stabellini
@ 2017-03-02  8:58       ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-02  8:58 UTC (permalink / raw)
  To: 'Stefano Stabellini'; +Cc: xen-devel, qemu-devel, Anthony Perard

> -----Original Message-----
> From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> Sent: 02 March 2017 02:06
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> Stabellini <sstabellini@kernel.org>; Anthony Perard
> <anthony.perard@citrix.com>
> Subject: Re: [PATCH 5/5] xen: use libxendevicemodel when available
> 
> On Thu, 23 Feb 2017, Paul Durrant wrote:
> > This patch modifies the wrapper functions in xen_common.h to use the
> > new xendevicemodel interface if it is available along with compatibility
> > code to use the old libxenctrl interface if it is not.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> 
> Hi Paul,
> 
> Sorry for the late reply, I am flooded with patches over here. Aside
> from Anthony's comments, the other patches of this series look good to
> me.
> 

Good :-) I will reply to Anthony's recent comment shortly.

> The Xen side patches are not in, are they? Do you have a Xen git branch
> with them so that I can test this patch properly?

Yes, they are in staging but not yet in master.

> 
> This patch breaks the build against Xen >= 4.3, with:
> 
> /local/qemu-upstream/xen-common.c: In function 'xen_init':
> /local/qemu-upstream/xen-common.c:135:9: error: implicit declaration of
> function 'xenforeignmemory_close' [-Werror=implicit-function-declaration]
> /local/qemu-upstream/xen-common.c:135:9: error: nested extern
> declaration of 'xenforeignmemory_close' [-Werror=nested-externs]
> cc1: all warnings being treated as errors

I must have missed that compat define. Thanks for spotting that. I'll re-check and send v2.

Cheers,

  Paul

> 
> 
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > ---
> >  include/hw/xen/xen_common.h | 114
> +++++++++++++++++++++++++++++++-------------
> >  xen-common.c                |   8 ++++
> >  2 files changed, 89 insertions(+), 33 deletions(-)
> >
> > diff --git a/include/hw/xen/xen_common.h
> b/include/hw/xen/xen_common.h
> > index 31cf25f..2c2a61b 100644
> > --- a/include/hw/xen/xen_common.h
> > +++ b/include/hw/xen/xen_common.h
> > @@ -9,6 +9,7 @@
> >  #undef XC_WANT_COMPAT_EVTCHN_API
> >  #undef XC_WANT_COMPAT_GNTTAB_API
> >  #undef XC_WANT_COMPAT_MAP_FOREIGN_API
> > +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> >
> >  #include <xenctrl.h>
> >  #include <xenstore.h>
> > @@ -26,48 +27,95 @@ extern xc_interface *xen_xc;
> >   * We don't support Xen prior to 4.2.0.
> >   */
> >
> > +#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 490
> > +
> > +typedef xc_interface xendevicemodel_handle;
> > +
> > +#define xendevicemodel_open(l, f) xen_xc
> > +
> > +#define xendevicemodel_map_io_range_to_ioreq_server \
> 
> Could you please use static inline functions for compatibility rather
> than macros? That way we are going to have some more compile time
> checks. Or at least macros with parameters.
> 
> 
> > +    xc_hvm_map_io_range_to_ioreq_server
> > +#define xendevicemodel_unmap_io_range_from_ioreq_server \
> > +    xc_hvm_unmap_io_range_from_ioreq_server
> > +#define xendevicemodel_map_pcidev_to_ioreq_server \
> > +    xc_hvm_map_pcidev_to_ioreq_server
> > +#define xendevicemodel_unmap_pcidev_from_ioreq_server \
> > +    xc_hvm_unmap_pcidev_from_ioreq_server
> > +#define xendevicemodel_create_ioreq_server \
> > +    xc_hvm_create_ioreq_server
> > +#define xendevicemodel_destroy_ioreq_server \
> > +    xc_hvm_destroy_ioreq_server
> > +#define xendevicemodel_get_ioreq_server_info \
> > +    xc_hvm_get_ioreq_server_info
> > +#define xendevicemodel_set_ioreq_server_state \
> > +    xc_hvm_set_ioreq_server_state
> > +#define xendevicemodel_set_pci_intx_level \
> > +    xc_hvm_set_pci_intx_level
> > +#define xendevicemodel_set_pci_link_route \
> > +    xc_hvm_set_pci_link_route
> > +#define xendevicemodel_set_isa_irq_level \
> > +    xc_hvm_set_isa_irq_level
> > +#define xendevicemodel_inject_msi \
> > +    xc_hvm_inject_msi
> > +#define xendevicemodel_set_mem_type \
> > +    xc_hvm_set_mem_type
> > +#define xendevicemodel_track_dirty_vram \
> > +    xc_hvm_track_dirty_vram
> > +#define xendevicemodel_modified_memory \
> > +    xc_hvm_modified_memory
> > +
> > +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 490 */
> > +
> > +#include <xendevicemodel.h>
> > +
> > +#endif
> > +
> > +extern xendevicemodel_handle *xen_dmod;
> > +
> >  static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t
> type,
> >                                     uint64_t first_pfn, uint32_t nr)
> >  {
> > -    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
> > +    return xendevicemodel_set_mem_type(xen_dmod, domid, type,
> first_pfn,
> > +                                       nr);
> >  }
> >
> >  static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
> >                                           uint8_t bus, uint8_t device,
> >                                           uint8_t intx, unsigned int level)
> >  {
> > -    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus,
> device,
> > -                                     intx, level);
> > +    return xendevicemodel_set_pci_intx_level(xen_dmod, domid,
> segment, bus,
> > +                                             device, intx, level);
> >  }
> >
> >  static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
> >                                           uint8_t irq)
> >  {
> > -    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
> > +    return xendevicemodel_set_pci_link_route(xen_dmod, domid, link,
> irq);
> >  }
> >
> >  static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
> >                                   uint32_t msi_data)
> >  {
> > -    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
> > +    return xendevicemodel_inject_msi(xen_dmod, domid, msi_addr,
> msi_data);
> >  }
> >
> >  static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
> >                                          unsigned int level)
> >  {
> > -    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
> > +    return xendevicemodel_set_isa_irq_level(xen_dmod, domid, irq,
> level);
> >  }
> >
> >  static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
> >                                         uint32_t nr, unsigned long *bitmap)
> >  {
> > -    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
> > +    return xendevicemodel_track_dirty_vram(xen_dmod, domid, first_pfn,
> nr,
> > +                                           bitmap);
> >  }
> >
> >  static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
> >                                        uint32_t nr)
> >  {
> > -    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
> > +    return xendevicemodel_modified_memory(xen_dmod, domid,
> first_pfn, nr);
> >  }
> >
> >  /* Xen 4.2 through 4.6 */
> > @@ -285,8 +333,8 @@ static inline void
> xen_map_memory_section(domid_t dom,
> >      }
> >
> >      trace_xen_map_mmio_range(ioservid, start_addr, end_addr);
> > -    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 1,
> > -                                        start_addr, end_addr);
> > +    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom,
> ioservid, 1,
> > +                                                start_addr, end_addr);
> >  }
> >
> >  static inline void xen_unmap_memory_section(domid_t dom,
> > @@ -302,8 +350,8 @@ static inline void
> xen_unmap_memory_section(domid_t dom,
> >      }
> >
> >      trace_xen_unmap_mmio_range(ioservid, start_addr, end_addr);
> > -    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
> > -                                            1, start_addr, end_addr);
> > +    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod,
> dom, ioservid,
> > +                                                    1, start_addr, end_addr);
> >  }
> >
> >  static inline void xen_map_io_section(domid_t dom,
> > @@ -319,8 +367,8 @@ static inline void xen_map_io_section(domid_t
> dom,
> >      }
> >
> >      trace_xen_map_portio_range(ioservid, start_addr, end_addr);
> > -    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 0,
> > -                                        start_addr, end_addr);
> > +    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom,
> ioservid, 0,
> > +                                                start_addr, end_addr);
> >  }
> >
> >  static inline void xen_unmap_io_section(domid_t dom,
> > @@ -336,8 +384,8 @@ static inline void xen_unmap_io_section(domid_t
> dom,
> >      }
> >
> >      trace_xen_unmap_portio_range(ioservid, start_addr, end_addr);
> > -    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
> > -                                            0, start_addr, end_addr);
> > +    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod,
> dom, ioservid,
> > +                                                    0, start_addr, end_addr);
> >  }
> >
> >  static inline void xen_map_pcidev(domid_t dom,
> > @@ -350,10 +398,10 @@ static inline void xen_map_pcidev(domid_t dom,
> >
> >      trace_xen_map_pcidev(ioservid, pci_bus_num(pci_dev->bus),
> >                           PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
> > -    xc_hvm_map_pcidev_to_ioreq_server(xen_xc, dom, ioservid, 0,
> > -                                      pci_bus_num(pci_dev->bus),
> > -                                      PCI_SLOT(pci_dev->devfn),
> > -                                      PCI_FUNC(pci_dev->devfn));
> > +    xendevicemodel_map_pcidev_to_ioreq_server(xen_dmod, dom,
> ioservid, 0,
> > +                                              pci_bus_num(pci_dev->bus),
> > +                                              PCI_SLOT(pci_dev->devfn),
> > +                                              PCI_FUNC(pci_dev->devfn));
> >  }
> >
> >  static inline void xen_unmap_pcidev(domid_t dom,
> > @@ -366,18 +414,18 @@ static inline void xen_unmap_pcidev(domid_t
> dom,
> >
> >      trace_xen_unmap_pcidev(ioservid, pci_bus_num(pci_dev->bus),
> >                             PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
> > -    xc_hvm_unmap_pcidev_from_ioreq_server(xen_xc, dom, ioservid, 0,
> > -                                          pci_bus_num(pci_dev->bus),
> > -                                          PCI_SLOT(pci_dev->devfn),
> > -                                          PCI_FUNC(pci_dev->devfn));
> > +    xendevicemodel_unmap_pcidev_from_ioreq_server(xen_dmod, dom,
> ioservid, 0,
> > +                                                  pci_bus_num(pci_dev->bus),
> > +                                                  PCI_SLOT(pci_dev->devfn),
> > +                                                  PCI_FUNC(pci_dev->devfn));
> >  }
> >
> >  static inline void xen_create_ioreq_server(domid_t dom,
> >                                             ioservid_t *ioservid)
> >  {
> > -    int rc = xc_hvm_create_ioreq_server(xen_xc, dom,
> > -                                        HVM_IOREQSRV_BUFIOREQ_ATOMIC,
> > -                                        ioservid);
> > +    int rc = xendevicemodel_create_ioreq_server(xen_dmod, dom,
> > +                                                HVM_IOREQSRV_BUFIOREQ_ATOMIC,
> > +                                                ioservid);
> >
> >      if (rc == 0) {
> >          trace_xen_ioreq_server_create(*ioservid);
> > @@ -397,7 +445,7 @@ static inline void
> xen_destroy_ioreq_server(domid_t dom,
> >      }
> >
> >      trace_xen_ioreq_server_destroy(ioservid);
> > -    xc_hvm_destroy_ioreq_server(xen_xc, dom, ioservid);
> > +    xendevicemodel_destroy_ioreq_server(xen_dmod, dom, ioservid);
> >  }
> >
> >  static inline int xen_get_ioreq_server_info(domid_t dom,
> > @@ -412,9 +460,9 @@ static inline int xen_get_ioreq_server_info(domid_t
> dom,
> >                                                   bufioreq_evtchn);
> >      }
> >
> > -    return xc_hvm_get_ioreq_server_info(xen_xc, dom, ioservid,
> > -                                        ioreq_pfn, bufioreq_pfn,
> > -                                        bufioreq_evtchn);
> > +    return xendevicemodel_get_ioreq_server_info(xen_dmod, dom,
> ioservid,
> > +                                                ioreq_pfn, bufioreq_pfn,
> > +                                                bufioreq_evtchn);
> >  }
> >
> >  static inline int xen_set_ioreq_server_state(domid_t dom,
> > @@ -426,8 +474,8 @@ static inline int
> xen_set_ioreq_server_state(domid_t dom,
> >      }
> >
> >      trace_xen_ioreq_server_state(ioservid, enable);
> > -    return xc_hvm_set_ioreq_server_state(xen_xc, dom, ioservid,
> > -                                         enable);
> > +    return xendevicemodel_set_ioreq_server_state(xen_dmod, dom,
> ioservid,
> > +                                                 enable);
> >  }
> >
> >  #endif
> > diff --git a/xen-common.c b/xen-common.c
> > index 703e7a5..ae76150 100644
> > --- a/xen-common.c
> > +++ b/xen-common.c
> > @@ -27,6 +27,7 @@
> >
> >  xc_interface *xen_xc;
> >  xenforeignmemory_handle *xen_fmem;
> > +xendevicemodel_handle *xen_dmod;
> >
> >  static int store_dev_info(int domid, Chardev *cs, const char *string)
> >  {
> > @@ -128,6 +129,13 @@ static int xen_init(MachineState *ms)
> >          xc_interface_close(xen_xc);
> >          return -1;
> >      }
> > +    xen_dmod = xendevicemodel_open(0, 0);
> > +    if (xen_dmod == NULL) {
> > +        xen_pv_printf(NULL, 0, "can't open xen devicemodel interface\n");
> > +        xenforeignmemory_close(xen_fmem);
> > +        xc_interface_close(xen_xc);
> > +        return -1;
> > +    }
> >      qemu_add_vm_change_state_handler(xen_change_state_handler,
> NULL);
> >
> >      global_state_set_optional();
> > --
> > 2.1.4
> >

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 5/5] xen: use libxendevicemodel when available
@ 2017-03-02  8:58       ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-02  8:58 UTC (permalink / raw)
  To: 'Stefano Stabellini'; +Cc: Anthony Perard, xen-devel, qemu-devel

> -----Original Message-----
> From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> Sent: 02 March 2017 02:06
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> Stabellini <sstabellini@kernel.org>; Anthony Perard
> <anthony.perard@citrix.com>
> Subject: Re: [PATCH 5/5] xen: use libxendevicemodel when available
> 
> On Thu, 23 Feb 2017, Paul Durrant wrote:
> > This patch modifies the wrapper functions in xen_common.h to use the
> > new xendevicemodel interface if it is available along with compatibility
> > code to use the old libxenctrl interface if it is not.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> 
> Hi Paul,
> 
> Sorry for the late reply, I am flooded with patches over here. Aside
> from Anthony's comments, the other patches of this series look good to
> me.
> 

Good :-) I will reply to Anthony's recent comment shortly.

> The Xen side patches are not in, are they? Do you have a Xen git branch
> with them so that I can test this patch properly?

Yes, they are in staging but not yet in master.

> 
> This patch breaks the build against Xen >= 4.3, with:
> 
> /local/qemu-upstream/xen-common.c: In function 'xen_init':
> /local/qemu-upstream/xen-common.c:135:9: error: implicit declaration of
> function 'xenforeignmemory_close' [-Werror=implicit-function-declaration]
> /local/qemu-upstream/xen-common.c:135:9: error: nested extern
> declaration of 'xenforeignmemory_close' [-Werror=nested-externs]
> cc1: all warnings being treated as errors

I must have missed that compat define. Thanks for spotting that. I'll re-check and send v2.

Cheers,

  Paul

> 
> 
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > ---
> >  include/hw/xen/xen_common.h | 114
> +++++++++++++++++++++++++++++++-------------
> >  xen-common.c                |   8 ++++
> >  2 files changed, 89 insertions(+), 33 deletions(-)
> >
> > diff --git a/include/hw/xen/xen_common.h
> b/include/hw/xen/xen_common.h
> > index 31cf25f..2c2a61b 100644
> > --- a/include/hw/xen/xen_common.h
> > +++ b/include/hw/xen/xen_common.h
> > @@ -9,6 +9,7 @@
> >  #undef XC_WANT_COMPAT_EVTCHN_API
> >  #undef XC_WANT_COMPAT_GNTTAB_API
> >  #undef XC_WANT_COMPAT_MAP_FOREIGN_API
> > +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> >
> >  #include <xenctrl.h>
> >  #include <xenstore.h>
> > @@ -26,48 +27,95 @@ extern xc_interface *xen_xc;
> >   * We don't support Xen prior to 4.2.0.
> >   */
> >
> > +#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 490
> > +
> > +typedef xc_interface xendevicemodel_handle;
> > +
> > +#define xendevicemodel_open(l, f) xen_xc
> > +
> > +#define xendevicemodel_map_io_range_to_ioreq_server \
> 
> Could you please use static inline functions for compatibility rather
> than macros? That way we are going to have some more compile time
> checks. Or at least macros with parameters.
> 
> 
> > +    xc_hvm_map_io_range_to_ioreq_server
> > +#define xendevicemodel_unmap_io_range_from_ioreq_server \
> > +    xc_hvm_unmap_io_range_from_ioreq_server
> > +#define xendevicemodel_map_pcidev_to_ioreq_server \
> > +    xc_hvm_map_pcidev_to_ioreq_server
> > +#define xendevicemodel_unmap_pcidev_from_ioreq_server \
> > +    xc_hvm_unmap_pcidev_from_ioreq_server
> > +#define xendevicemodel_create_ioreq_server \
> > +    xc_hvm_create_ioreq_server
> > +#define xendevicemodel_destroy_ioreq_server \
> > +    xc_hvm_destroy_ioreq_server
> > +#define xendevicemodel_get_ioreq_server_info \
> > +    xc_hvm_get_ioreq_server_info
> > +#define xendevicemodel_set_ioreq_server_state \
> > +    xc_hvm_set_ioreq_server_state
> > +#define xendevicemodel_set_pci_intx_level \
> > +    xc_hvm_set_pci_intx_level
> > +#define xendevicemodel_set_pci_link_route \
> > +    xc_hvm_set_pci_link_route
> > +#define xendevicemodel_set_isa_irq_level \
> > +    xc_hvm_set_isa_irq_level
> > +#define xendevicemodel_inject_msi \
> > +    xc_hvm_inject_msi
> > +#define xendevicemodel_set_mem_type \
> > +    xc_hvm_set_mem_type
> > +#define xendevicemodel_track_dirty_vram \
> > +    xc_hvm_track_dirty_vram
> > +#define xendevicemodel_modified_memory \
> > +    xc_hvm_modified_memory
> > +
> > +#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 490 */
> > +
> > +#include <xendevicemodel.h>
> > +
> > +#endif
> > +
> > +extern xendevicemodel_handle *xen_dmod;
> > +
> >  static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t
> type,
> >                                     uint64_t first_pfn, uint32_t nr)
> >  {
> > -    return xc_hvm_set_mem_type(xen_xc, domid, type, first_pfn, nr);
> > +    return xendevicemodel_set_mem_type(xen_dmod, domid, type,
> first_pfn,
> > +                                       nr);
> >  }
> >
> >  static inline int xen_set_pci_intx_level(domid_t domid, uint16_t segment,
> >                                           uint8_t bus, uint8_t device,
> >                                           uint8_t intx, unsigned int level)
> >  {
> > -    return xc_hvm_set_pci_intx_level(xen_xc, domid, segment, bus,
> device,
> > -                                     intx, level);
> > +    return xendevicemodel_set_pci_intx_level(xen_dmod, domid,
> segment, bus,
> > +                                             device, intx, level);
> >  }
> >
> >  static inline int xen_set_pci_link_route(domid_t domid, uint8_t link,
> >                                           uint8_t irq)
> >  {
> > -    return xc_hvm_set_pci_link_route(xen_xc, domid, link, irq);
> > +    return xendevicemodel_set_pci_link_route(xen_dmod, domid, link,
> irq);
> >  }
> >
> >  static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr,
> >                                   uint32_t msi_data)
> >  {
> > -    return xc_hvm_inject_msi(xen_xc, domid, msi_addr, msi_data);
> > +    return xendevicemodel_inject_msi(xen_dmod, domid, msi_addr,
> msi_data);
> >  }
> >
> >  static inline int xen_set_isa_irq_level(domid_t domid, uint8_t irq,
> >                                          unsigned int level)
> >  {
> > -    return xc_hvm_set_isa_irq_level(xen_xc, domid, irq, level);
> > +    return xendevicemodel_set_isa_irq_level(xen_dmod, domid, irq,
> level);
> >  }
> >
> >  static inline int xen_track_dirty_vram(domid_t domid, uint64_t first_pfn,
> >                                         uint32_t nr, unsigned long *bitmap)
> >  {
> > -    return xc_hvm_track_dirty_vram(xen_xc, domid, first_pfn, nr, bitmap);
> > +    return xendevicemodel_track_dirty_vram(xen_dmod, domid, first_pfn,
> nr,
> > +                                           bitmap);
> >  }
> >
> >  static inline int xen_modified_memory(domid_t domid, uint64_t first_pfn,
> >                                        uint32_t nr)
> >  {
> > -    return xc_hvm_modified_memory(xen_xc, domid, first_pfn, nr);
> > +    return xendevicemodel_modified_memory(xen_dmod, domid,
> first_pfn, nr);
> >  }
> >
> >  /* Xen 4.2 through 4.6 */
> > @@ -285,8 +333,8 @@ static inline void
> xen_map_memory_section(domid_t dom,
> >      }
> >
> >      trace_xen_map_mmio_range(ioservid, start_addr, end_addr);
> > -    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 1,
> > -                                        start_addr, end_addr);
> > +    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom,
> ioservid, 1,
> > +                                                start_addr, end_addr);
> >  }
> >
> >  static inline void xen_unmap_memory_section(domid_t dom,
> > @@ -302,8 +350,8 @@ static inline void
> xen_unmap_memory_section(domid_t dom,
> >      }
> >
> >      trace_xen_unmap_mmio_range(ioservid, start_addr, end_addr);
> > -    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
> > -                                            1, start_addr, end_addr);
> > +    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod,
> dom, ioservid,
> > +                                                    1, start_addr, end_addr);
> >  }
> >
> >  static inline void xen_map_io_section(domid_t dom,
> > @@ -319,8 +367,8 @@ static inline void xen_map_io_section(domid_t
> dom,
> >      }
> >
> >      trace_xen_map_portio_range(ioservid, start_addr, end_addr);
> > -    xc_hvm_map_io_range_to_ioreq_server(xen_xc, dom, ioservid, 0,
> > -                                        start_addr, end_addr);
> > +    xendevicemodel_map_io_range_to_ioreq_server(xen_dmod, dom,
> ioservid, 0,
> > +                                                start_addr, end_addr);
> >  }
> >
> >  static inline void xen_unmap_io_section(domid_t dom,
> > @@ -336,8 +384,8 @@ static inline void xen_unmap_io_section(domid_t
> dom,
> >      }
> >
> >      trace_xen_unmap_portio_range(ioservid, start_addr, end_addr);
> > -    xc_hvm_unmap_io_range_from_ioreq_server(xen_xc, dom, ioservid,
> > -                                            0, start_addr, end_addr);
> > +    xendevicemodel_unmap_io_range_from_ioreq_server(xen_dmod,
> dom, ioservid,
> > +                                                    0, start_addr, end_addr);
> >  }
> >
> >  static inline void xen_map_pcidev(domid_t dom,
> > @@ -350,10 +398,10 @@ static inline void xen_map_pcidev(domid_t dom,
> >
> >      trace_xen_map_pcidev(ioservid, pci_bus_num(pci_dev->bus),
> >                           PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
> > -    xc_hvm_map_pcidev_to_ioreq_server(xen_xc, dom, ioservid, 0,
> > -                                      pci_bus_num(pci_dev->bus),
> > -                                      PCI_SLOT(pci_dev->devfn),
> > -                                      PCI_FUNC(pci_dev->devfn));
> > +    xendevicemodel_map_pcidev_to_ioreq_server(xen_dmod, dom,
> ioservid, 0,
> > +                                              pci_bus_num(pci_dev->bus),
> > +                                              PCI_SLOT(pci_dev->devfn),
> > +                                              PCI_FUNC(pci_dev->devfn));
> >  }
> >
> >  static inline void xen_unmap_pcidev(domid_t dom,
> > @@ -366,18 +414,18 @@ static inline void xen_unmap_pcidev(domid_t
> dom,
> >
> >      trace_xen_unmap_pcidev(ioservid, pci_bus_num(pci_dev->bus),
> >                             PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn));
> > -    xc_hvm_unmap_pcidev_from_ioreq_server(xen_xc, dom, ioservid, 0,
> > -                                          pci_bus_num(pci_dev->bus),
> > -                                          PCI_SLOT(pci_dev->devfn),
> > -                                          PCI_FUNC(pci_dev->devfn));
> > +    xendevicemodel_unmap_pcidev_from_ioreq_server(xen_dmod, dom,
> ioservid, 0,
> > +                                                  pci_bus_num(pci_dev->bus),
> > +                                                  PCI_SLOT(pci_dev->devfn),
> > +                                                  PCI_FUNC(pci_dev->devfn));
> >  }
> >
> >  static inline void xen_create_ioreq_server(domid_t dom,
> >                                             ioservid_t *ioservid)
> >  {
> > -    int rc = xc_hvm_create_ioreq_server(xen_xc, dom,
> > -                                        HVM_IOREQSRV_BUFIOREQ_ATOMIC,
> > -                                        ioservid);
> > +    int rc = xendevicemodel_create_ioreq_server(xen_dmod, dom,
> > +                                                HVM_IOREQSRV_BUFIOREQ_ATOMIC,
> > +                                                ioservid);
> >
> >      if (rc == 0) {
> >          trace_xen_ioreq_server_create(*ioservid);
> > @@ -397,7 +445,7 @@ static inline void
> xen_destroy_ioreq_server(domid_t dom,
> >      }
> >
> >      trace_xen_ioreq_server_destroy(ioservid);
> > -    xc_hvm_destroy_ioreq_server(xen_xc, dom, ioservid);
> > +    xendevicemodel_destroy_ioreq_server(xen_dmod, dom, ioservid);
> >  }
> >
> >  static inline int xen_get_ioreq_server_info(domid_t dom,
> > @@ -412,9 +460,9 @@ static inline int xen_get_ioreq_server_info(domid_t
> dom,
> >                                                   bufioreq_evtchn);
> >      }
> >
> > -    return xc_hvm_get_ioreq_server_info(xen_xc, dom, ioservid,
> > -                                        ioreq_pfn, bufioreq_pfn,
> > -                                        bufioreq_evtchn);
> > +    return xendevicemodel_get_ioreq_server_info(xen_dmod, dom,
> ioservid,
> > +                                                ioreq_pfn, bufioreq_pfn,
> > +                                                bufioreq_evtchn);
> >  }
> >
> >  static inline int xen_set_ioreq_server_state(domid_t dom,
> > @@ -426,8 +474,8 @@ static inline int
> xen_set_ioreq_server_state(domid_t dom,
> >      }
> >
> >      trace_xen_ioreq_server_state(ioservid, enable);
> > -    return xc_hvm_set_ioreq_server_state(xen_xc, dom, ioservid,
> > -                                         enable);
> > +    return xendevicemodel_set_ioreq_server_state(xen_dmod, dom,
> ioservid,
> > +                                                 enable);
> >  }
> >
> >  #endif
> > diff --git a/xen-common.c b/xen-common.c
> > index 703e7a5..ae76150 100644
> > --- a/xen-common.c
> > +++ b/xen-common.c
> > @@ -27,6 +27,7 @@
> >
> >  xc_interface *xen_xc;
> >  xenforeignmemory_handle *xen_fmem;
> > +xendevicemodel_handle *xen_dmod;
> >
> >  static int store_dev_info(int domid, Chardev *cs, const char *string)
> >  {
> > @@ -128,6 +129,13 @@ static int xen_init(MachineState *ms)
> >          xc_interface_close(xen_xc);
> >          return -1;
> >      }
> > +    xen_dmod = xendevicemodel_open(0, 0);
> > +    if (xen_dmod == NULL) {
> > +        xen_pv_printf(NULL, 0, "can't open xen devicemodel interface\n");
> > +        xenforeignmemory_close(xen_fmem);
> > +        xc_interface_close(xen_xc);
> > +        return -1;
> > +    }
> >      qemu_add_vm_change_state_handler(xen_change_state_handler,
> NULL);
> >
> >      global_state_set_optional();
> > --
> > 2.1.4
> >

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] configure: detect presence of libxendevicemodel
  2017-03-01 17:17     ` Anthony PERARD
@ 2017-03-02  9:06       ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-02  9:06 UTC (permalink / raw)
  To: Anthony Perard; +Cc: xen-devel, qemu-devel, Stefano Stabellini

> -----Original Message-----
> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> Sent: 01 March 2017 17:18
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> Stabellini <sstabellini@kernel.org>
> Subject: Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
> 
> On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> > This patch adds code in configure to set
> CONFIG_XEN_CTRL_INTERFACE_VERSION
> > to a new value of 490 if libxendevicemodel is present in the build
> > environment.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > ---
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > ---
> >  configure | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >
> > diff --git a/configure b/configure
> > index 8e8f18d..fc1e12b 100755
> > --- a/configure
> > +++ b/configure
> > @@ -1980,6 +1980,25 @@ EOF
> >    # Xen unstable
> >    elif
> >        cat > $TMPC <<EOF &&
> > +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> > +#define __XEN_TOOLS__
> 
> Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
> xen.git?
> 
> Also it seems to be the only time this define is used in your patch
> series.
>
No. QEMU falls under the definition of 'tools' as far as Xen goes and the hypercalls and xendevicemodel API are protected by that. The reason you don't see it elsewhere is that xenctrl.h defines it. (See http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenctrl.h;hb=HEAD#l27).
I think that's a little underhand so I thought I'd make the new code in configure more transparent. I can change it to just include xenctrl.h before xendevicemodel.h if you'd prefer.

  Paul

> > +#include <xendevicemodel.h>
> > +int main(void) {
> > +  xendevicemodel_handle *xd;
> > +
> > +  xd = xendevicemodel_open(0, 0);
> > +  xendevicemodel_close(xd);
> > +
> > +  return 0;
> > +}
> > +EOF
> > +      compile_prog "" "$xen_libs $xen_stable_libs -lxendevicemodel"
> > +    then
> > +    xen_stable_libs="$xen_stable_libs -lxendevicemodel"
> > +    xen_ctrl_version=490
> > +    xen=yes
> > +  elif
> > +      cat > $TMPC <<EOF &&
> >  /*
> >   * If we have stable libs the we don't want the libxc compat
> >   * layers, regardless of what CFLAGS we may have been given.
> > --
> > 2.1.4
> >
> 
> --
> Anthony PERARD

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
@ 2017-03-02  9:06       ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-02  9:06 UTC (permalink / raw)
  To: Anthony Perard; +Cc: xen-devel, Stefano Stabellini, qemu-devel

> -----Original Message-----
> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> Sent: 01 March 2017 17:18
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> Stabellini <sstabellini@kernel.org>
> Subject: Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
> 
> On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> > This patch adds code in configure to set
> CONFIG_XEN_CTRL_INTERFACE_VERSION
> > to a new value of 490 if libxendevicemodel is present in the build
> > environment.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > ---
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > ---
> >  configure | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >
> > diff --git a/configure b/configure
> > index 8e8f18d..fc1e12b 100755
> > --- a/configure
> > +++ b/configure
> > @@ -1980,6 +1980,25 @@ EOF
> >    # Xen unstable
> >    elif
> >        cat > $TMPC <<EOF &&
> > +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> > +#define __XEN_TOOLS__
> 
> Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
> xen.git?
> 
> Also it seems to be the only time this define is used in your patch
> series.
>
No. QEMU falls under the definition of 'tools' as far as Xen goes and the hypercalls and xendevicemodel API are protected by that. The reason you don't see it elsewhere is that xenctrl.h defines it. (See http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenctrl.h;hb=HEAD#l27).
I think that's a little underhand so I thought I'd make the new code in configure more transparent. I can change it to just include xenctrl.h before xendevicemodel.h if you'd prefer.

  Paul

> > +#include <xendevicemodel.h>
> > +int main(void) {
> > +  xendevicemodel_handle *xd;
> > +
> > +  xd = xendevicemodel_open(0, 0);
> > +  xendevicemodel_close(xd);
> > +
> > +  return 0;
> > +}
> > +EOF
> > +      compile_prog "" "$xen_libs $xen_stable_libs -lxendevicemodel"
> > +    then
> > +    xen_stable_libs="$xen_stable_libs -lxendevicemodel"
> > +    xen_ctrl_version=490
> > +    xen=yes
> > +  elif
> > +      cat > $TMPC <<EOF &&
> >  /*
> >   * If we have stable libs the we don't want the libxc compat
> >   * layers, regardless of what CFLAGS we may have been given.
> > --
> > 2.1.4
> >
> 
> --
> Anthony PERARD

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions
  2017-03-01 16:16       ` Paul Durrant
@ 2017-03-02 10:44         ` Anthony PERARD
  -1 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-02 10:44 UTC (permalink / raw)
  To: Paul Durrant
  Cc: xen-devel, qemu-devel, Stefano Stabellini, Paolo Bonzini,
	Richard Henderson, Eduardo Habkost, Michael S. Tsirkin

On Wed, Mar 01, 2017 at 04:16:32PM +0000, Paul Durrant wrote:
> > -----Original Message-----
> > From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> > Sent: 01 March 2017 16:14
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> > Stabellini <sstabellini@kernel.org>; Paolo Bonzini <pbonzini@redhat.com>;
> > Richard Henderson <rth@twiddle.net>; Eduardo Habkost
> > <ehabkost@redhat.com>; Michael S. Tsirkin <mst@redhat.com>
> > Subject: Re: [PATCH 3/5] xen: create wrappers for all other uses of
> > xc_hvm_XXX() functions
> > 
> > On Thu, Feb 23, 2017 at 02:53:53PM +0000, Paul Durrant wrote:
> > > This patch creates inline wrapper functions in xen_common.h for all open
> > > coded calls to xc_hvm_XXX() functions outside of xen_common.h so that
> > use
> > > of xen_xc can be made implicit. This again is in preparation for the move
> > > to using libxendevicemodel.
> > >
> > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > ---
> > > diff --git a/include/hw/xen/xen_common.h
> > b/include/hw/xen/xen_common.h
> > > index 1e08b98..31cf25f 100644
> > > --- a/include/hw/xen/xen_common.h
> > > +++ b/include/hw/xen/xen_common.h
> > > @@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
> > >   * We don't support Xen prior to 4.2.0.
> > >   */
> > >
> > > +static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t
> > type,
> > > +                                   uint64_t first_pfn, uint32_t nr)
> > > +{
> > 
> > I don't know if it matters from where the functions are called, but
> > here, xc_hvm_set_mem_type takes a "uint64_t nr" (and not uint32_t).
> 
> Yes, the old APIs were wrong and discarded the upper 32 bits, so limiting here is correct. Moving to the new API fixes the issue.

OK, thanks.

In that case:
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

-- 
Anthony PERARD

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions
@ 2017-03-02 10:44         ` Anthony PERARD
  0 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-02 10:44 UTC (permalink / raw)
  To: Paul Durrant
  Cc: Stefano Stabellini, Eduardo Habkost, Michael S. Tsirkin,
	qemu-devel, Paolo Bonzini, xen-devel, Richard Henderson

On Wed, Mar 01, 2017 at 04:16:32PM +0000, Paul Durrant wrote:
> > -----Original Message-----
> > From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> > Sent: 01 March 2017 16:14
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> > Stabellini <sstabellini@kernel.org>; Paolo Bonzini <pbonzini@redhat.com>;
> > Richard Henderson <rth@twiddle.net>; Eduardo Habkost
> > <ehabkost@redhat.com>; Michael S. Tsirkin <mst@redhat.com>
> > Subject: Re: [PATCH 3/5] xen: create wrappers for all other uses of
> > xc_hvm_XXX() functions
> > 
> > On Thu, Feb 23, 2017 at 02:53:53PM +0000, Paul Durrant wrote:
> > > This patch creates inline wrapper functions in xen_common.h for all open
> > > coded calls to xc_hvm_XXX() functions outside of xen_common.h so that
> > use
> > > of xen_xc can be made implicit. This again is in preparation for the move
> > > to using libxendevicemodel.
> > >
> > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > ---
> > > diff --git a/include/hw/xen/xen_common.h
> > b/include/hw/xen/xen_common.h
> > > index 1e08b98..31cf25f 100644
> > > --- a/include/hw/xen/xen_common.h
> > > +++ b/include/hw/xen/xen_common.h
> > > @@ -26,6 +26,50 @@ extern xc_interface *xen_xc;
> > >   * We don't support Xen prior to 4.2.0.
> > >   */
> > >
> > > +static inline int xen_set_mem_type(domid_t domid, hvmmem_type_t
> > type,
> > > +                                   uint64_t first_pfn, uint32_t nr)
> > > +{
> > 
> > I don't know if it matters from where the functions are called, but
> > here, xc_hvm_set_mem_type takes a "uint64_t nr" (and not uint32_t).
> 
> Yes, the old APIs were wrong and discarded the upper 32 bits, so limiting here is correct. Moving to the new API fixes the issue.

OK, thanks.

In that case:
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

-- 
Anthony PERARD

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] configure: detect presence of libxendevicemodel
  2017-03-02  9:06       ` Paul Durrant
@ 2017-03-02 10:54         ` Anthony PERARD
  -1 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-02 10:54 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, qemu-devel, Stefano Stabellini

On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
> > -----Original Message-----
> > From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> > Sent: 01 March 2017 17:18
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> > Stabellini <sstabellini@kernel.org>
> > Subject: Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
> > 
> > On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> > > This patch adds code in configure to set
> > CONFIG_XEN_CTRL_INTERFACE_VERSION
> > > to a new value of 490 if libxendevicemodel is present in the build
> > > environment.
> > >
> > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > ---
> > > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > > Cc: Anthony Perard <anthony.perard@citrix.com>
> > > ---
> > >  configure | 19 +++++++++++++++++++
> > >  1 file changed, 19 insertions(+)
> > >
> > > diff --git a/configure b/configure
> > > index 8e8f18d..fc1e12b 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -1980,6 +1980,25 @@ EOF
> > >    # Xen unstable
> > >    elif
> > >        cat > $TMPC <<EOF &&
> > > +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> > > +#define __XEN_TOOLS__
> > 
> > Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
> > xen.git?
> > 
> > Also it seems to be the only time this define is used in your patch
> > series.
> >
> No. QEMU falls under the definition of 'tools' as far as Xen goes and the hypercalls and xendevicemodel API are protected by that. The reason you don't see it elsewhere is that xenctrl.h defines it. (See http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenctrl.h;hb=HEAD#l27).
> I think that's a little underhand so I thought I'd make the new code in configure more transparent. I can change it to just include xenctrl.h before xendevicemodel.h if you'd prefer.

I guess that is fine with __XEN_TOOLS__.
You can add my
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

-- 
Anthony PERARD

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
@ 2017-03-02 10:54         ` Anthony PERARD
  0 siblings, 0 replies; 42+ messages in thread
From: Anthony PERARD @ 2017-03-02 10:54 UTC (permalink / raw)
  To: Paul Durrant; +Cc: xen-devel, Stefano Stabellini, qemu-devel

On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
> > -----Original Message-----
> > From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> > Sent: 01 March 2017 17:18
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> > Stabellini <sstabellini@kernel.org>
> > Subject: Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
> > 
> > On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> > > This patch adds code in configure to set
> > CONFIG_XEN_CTRL_INTERFACE_VERSION
> > > to a new value of 490 if libxendevicemodel is present in the build
> > > environment.
> > >
> > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > ---
> > > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > > Cc: Anthony Perard <anthony.perard@citrix.com>
> > > ---
> > >  configure | 19 +++++++++++++++++++
> > >  1 file changed, 19 insertions(+)
> > >
> > > diff --git a/configure b/configure
> > > index 8e8f18d..fc1e12b 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -1980,6 +1980,25 @@ EOF
> > >    # Xen unstable
> > >    elif
> > >        cat > $TMPC <<EOF &&
> > > +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> > > +#define __XEN_TOOLS__
> > 
> > Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
> > xen.git?
> > 
> > Also it seems to be the only time this define is used in your patch
> > series.
> >
> No. QEMU falls under the definition of 'tools' as far as Xen goes and the hypercalls and xendevicemodel API are protected by that. The reason you don't see it elsewhere is that xenctrl.h defines it. (See http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenctrl.h;hb=HEAD#l27).
> I think that's a little underhand so I thought I'd make the new code in configure more transparent. I can change it to just include xenctrl.h before xendevicemodel.h if you'd prefer.

I guess that is fine with __XEN_TOOLS__.
You can add my
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

-- 
Anthony PERARD

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] configure: detect presence of libxendevicemodel
  2017-03-02 10:54         ` Anthony PERARD
@ 2017-03-02 10:55           ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-02 10:55 UTC (permalink / raw)
  To: Anthony Perard; +Cc: xen-devel, qemu-devel, Stefano Stabellini

> -----Original Message-----
> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> Sent: 02 March 2017 10:55
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> Stabellini <sstabellini@kernel.org>
> Subject: Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
> 
> On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
> > > -----Original Message-----
> > > From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> > > Sent: 01 March 2017 17:18
> > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> > > Stabellini <sstabellini@kernel.org>
> > > Subject: Re: [PATCH 4/5] configure: detect presence of
> libxendevicemodel
> > >
> > > On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> > > > This patch adds code in configure to set
> > > CONFIG_XEN_CTRL_INTERFACE_VERSION
> > > > to a new value of 490 if libxendevicemodel is present in the build
> > > > environment.
> > > >
> > > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > > ---
> > > > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > > > Cc: Anthony Perard <anthony.perard@citrix.com>
> > > > ---
> > > >  configure | 19 +++++++++++++++++++
> > > >  1 file changed, 19 insertions(+)
> > > >
> > > > diff --git a/configure b/configure
> > > > index 8e8f18d..fc1e12b 100755
> > > > --- a/configure
> > > > +++ b/configure
> > > > @@ -1980,6 +1980,25 @@ EOF
> > > >    # Xen unstable
> > > >    elif
> > > >        cat > $TMPC <<EOF &&
> > > > +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> > > > +#define __XEN_TOOLS__
> > >
> > > Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
> > > xen.git?
> > >
> > > Also it seems to be the only time this define is used in your patch
> > > series.
> > >
> > No. QEMU falls under the definition of 'tools' as far as Xen goes and the
> hypercalls and xendevicemodel API are protected by that. The reason you
> don't see it elsewhere is that xenctrl.h defines it. (See
> http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenc
> trl.h;hb=HEAD#l27).
> > I think that's a little underhand so I thought I'd make the new code in
> configure more transparent. I can change it to just include xenctrl.h before
> xendevicemodel.h if you'd prefer.
> 
> I guess that is fine with __XEN_TOOLS__.
> You can add my
> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

Cool. Thanks,

  Paul

> 
> --
> Anthony PERARD

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
@ 2017-03-02 10:55           ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-02 10:55 UTC (permalink / raw)
  To: Anthony Perard; +Cc: xen-devel, Stefano Stabellini, qemu-devel

> -----Original Message-----
> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> Sent: 02 March 2017 10:55
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> Stabellini <sstabellini@kernel.org>
> Subject: Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
> 
> On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
> > > -----Original Message-----
> > > From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> > > Sent: 01 March 2017 17:18
> > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> > > Stabellini <sstabellini@kernel.org>
> > > Subject: Re: [PATCH 4/5] configure: detect presence of
> libxendevicemodel
> > >
> > > On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> > > > This patch adds code in configure to set
> > > CONFIG_XEN_CTRL_INTERFACE_VERSION
> > > > to a new value of 490 if libxendevicemodel is present in the build
> > > > environment.
> > > >
> > > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > > ---
> > > > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > > > Cc: Anthony Perard <anthony.perard@citrix.com>
> > > > ---
> > > >  configure | 19 +++++++++++++++++++
> > > >  1 file changed, 19 insertions(+)
> > > >
> > > > diff --git a/configure b/configure
> > > > index 8e8f18d..fc1e12b 100755
> > > > --- a/configure
> > > > +++ b/configure
> > > > @@ -1980,6 +1980,25 @@ EOF
> > > >    # Xen unstable
> > > >    elif
> > > >        cat > $TMPC <<EOF &&
> > > > +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> > > > +#define __XEN_TOOLS__
> > >
> > > Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
> > > xen.git?
> > >
> > > Also it seems to be the only time this define is used in your patch
> > > series.
> > >
> > No. QEMU falls under the definition of 'tools' as far as Xen goes and the
> hypercalls and xendevicemodel API are protected by that. The reason you
> don't see it elsewhere is that xenctrl.h defines it. (See
> http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenc
> trl.h;hb=HEAD#l27).
> > I think that's a little underhand so I thought I'd make the new code in
> configure more transparent. I can change it to just include xenctrl.h before
> xendevicemodel.h if you'd prefer.
> 
> I guess that is fine with __XEN_TOOLS__.
> You can add my
> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

Cool. Thanks,

  Paul

> 
> --
> Anthony PERARD

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [Xen-devel] [PATCH 4/5] configure: detect presence of libxendevicemodel
  2017-03-02 10:54         ` Anthony PERARD
@ 2017-03-02 11:01           ` Juergen Gross
  -1 siblings, 0 replies; 42+ messages in thread
From: Juergen Gross @ 2017-03-02 11:01 UTC (permalink / raw)
  To: Anthony PERARD, Paul Durrant; +Cc: xen-devel, Stefano Stabellini, qemu-devel

On 02/03/17 11:54, Anthony PERARD wrote:
> On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
>>> -----Original Message-----
>>> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
>>> Sent: 01 March 2017 17:18
>>> To: Paul Durrant <Paul.Durrant@citrix.com>
>>> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
>>> Stabellini <sstabellini@kernel.org>
>>> Subject: Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
>>>
>>> On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
>>>> This patch adds code in configure to set
>>> CONFIG_XEN_CTRL_INTERFACE_VERSION
>>>> to a new value of 490 if libxendevicemodel is present in the build
>>>> environment.
>>>>
>>>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
>>>> ---
>>>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>>>> Cc: Anthony Perard <anthony.perard@citrix.com>
>>>> ---
>>>>  configure | 19 +++++++++++++++++++
>>>>  1 file changed, 19 insertions(+)
>>>>
>>>> diff --git a/configure b/configure
>>>> index 8e8f18d..fc1e12b 100755
>>>> --- a/configure
>>>> +++ b/configure
>>>> @@ -1980,6 +1980,25 @@ EOF
>>>>    # Xen unstable
>>>>    elif
>>>>        cat > $TMPC <<EOF &&
>>>> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
>>>> +#define __XEN_TOOLS__
>>>
>>> Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
>>> xen.git?
>>>
>>> Also it seems to be the only time this define is used in your patch
>>> series.
>>>
>> No. QEMU falls under the definition of 'tools' as far as Xen goes and the hypercalls and xendevicemodel API are protected by that. The reason you don't see it elsewhere is that xenctrl.h defines it. (See http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenctrl.h;hb=HEAD#l27).
>> I think that's a little underhand so I thought I'd make the new code in configure more transparent. I can change it to just include xenctrl.h before xendevicemodel.h if you'd prefer.
> 
> I guess that is fine with __XEN_TOOLS__.
> You can add my
> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
> 

Sorry for jumping in only now:

Wouldn't it be better to base qemu's configure modification for support
of Xen 4.9 (and newer) on my just posted series introducing pkg-config?

I'm just about to expand this series to all of Xen's libraries and I
already have a qemu patch at hand supporting this new scheme.


Juergen

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
@ 2017-03-02 11:01           ` Juergen Gross
  0 siblings, 0 replies; 42+ messages in thread
From: Juergen Gross @ 2017-03-02 11:01 UTC (permalink / raw)
  To: Anthony PERARD, Paul Durrant; +Cc: xen-devel, Stefano Stabellini, qemu-devel

On 02/03/17 11:54, Anthony PERARD wrote:
> On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
>>> -----Original Message-----
>>> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
>>> Sent: 01 March 2017 17:18
>>> To: Paul Durrant <Paul.Durrant@citrix.com>
>>> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
>>> Stabellini <sstabellini@kernel.org>
>>> Subject: Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
>>>
>>> On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
>>>> This patch adds code in configure to set
>>> CONFIG_XEN_CTRL_INTERFACE_VERSION
>>>> to a new value of 490 if libxendevicemodel is present in the build
>>>> environment.
>>>>
>>>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
>>>> ---
>>>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>>>> Cc: Anthony Perard <anthony.perard@citrix.com>
>>>> ---
>>>>  configure | 19 +++++++++++++++++++
>>>>  1 file changed, 19 insertions(+)
>>>>
>>>> diff --git a/configure b/configure
>>>> index 8e8f18d..fc1e12b 100755
>>>> --- a/configure
>>>> +++ b/configure
>>>> @@ -1980,6 +1980,25 @@ EOF
>>>>    # Xen unstable
>>>>    elif
>>>>        cat > $TMPC <<EOF &&
>>>> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
>>>> +#define __XEN_TOOLS__
>>>
>>> Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
>>> xen.git?
>>>
>>> Also it seems to be the only time this define is used in your patch
>>> series.
>>>
>> No. QEMU falls under the definition of 'tools' as far as Xen goes and the hypercalls and xendevicemodel API are protected by that. The reason you don't see it elsewhere is that xenctrl.h defines it. (See http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenctrl.h;hb=HEAD#l27).
>> I think that's a little underhand so I thought I'd make the new code in configure more transparent. I can change it to just include xenctrl.h before xendevicemodel.h if you'd prefer.
> 
> I guess that is fine with __XEN_TOOLS__.
> You can add my
> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
> 

Sorry for jumping in only now:

Wouldn't it be better to base qemu's configure modification for support
of Xen 4.9 (and newer) on my just posted series introducing pkg-config?

I'm just about to expand this series to all of Xen's libraries and I
already have a qemu patch at hand supporting this new scheme.


Juergen

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

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [Xen-devel] [PATCH 4/5] configure: detect presence of libxendevicemodel
  2017-03-02 11:01           ` Juergen Gross
@ 2017-03-02 11:06             ` Paul Durrant
  -1 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-02 11:06 UTC (permalink / raw)
  To: 'Juergen Gross', Anthony Perard
  Cc: xen-devel, Stefano Stabellini, qemu-devel

> -----Original Message-----
> From: Juergen Gross [mailto:jgross@suse.com]
> Sent: 02 March 2017 11:01
> To: Anthony Perard <anthony.perard@citrix.com>; Paul Durrant
> <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; Stefano Stabellini
> <sstabellini@kernel.org>; qemu-devel@nongnu.org
> Subject: Re: [Xen-devel] [PATCH 4/5] configure: detect presence of
> libxendevicemodel
> 
> On 02/03/17 11:54, Anthony PERARD wrote:
> > On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
> >>> -----Original Message-----
> >>> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> >>> Sent: 01 March 2017 17:18
> >>> To: Paul Durrant <Paul.Durrant@citrix.com>
> >>> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> >>> Stabellini <sstabellini@kernel.org>
> >>> Subject: Re: [PATCH 4/5] configure: detect presence of
> libxendevicemodel
> >>>
> >>> On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> >>>> This patch adds code in configure to set
> >>> CONFIG_XEN_CTRL_INTERFACE_VERSION
> >>>> to a new value of 490 if libxendevicemodel is present in the build
> >>>> environment.
> >>>>
> >>>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> >>>> ---
> >>>> Cc: Stefano Stabellini <sstabellini@kernel.org>
> >>>> Cc: Anthony Perard <anthony.perard@citrix.com>
> >>>> ---
> >>>>  configure | 19 +++++++++++++++++++
> >>>>  1 file changed, 19 insertions(+)
> >>>>
> >>>> diff --git a/configure b/configure
> >>>> index 8e8f18d..fc1e12b 100755
> >>>> --- a/configure
> >>>> +++ b/configure
> >>>> @@ -1980,6 +1980,25 @@ EOF
> >>>>    # Xen unstable
> >>>>    elif
> >>>>        cat > $TMPC <<EOF &&
> >>>> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> >>>> +#define __XEN_TOOLS__
> >>>
> >>> Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
> >>> xen.git?
> >>>
> >>> Also it seems to be the only time this define is used in your patch
> >>> series.
> >>>
> >> No. QEMU falls under the definition of 'tools' as far as Xen goes and the
> hypercalls and xendevicemodel API are protected by that. The reason you
> don't see it elsewhere is that xenctrl.h defines it. (See
> http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenc
> trl.h;hb=HEAD#l27).
> >> I think that's a little underhand so I thought I'd make the new code in
> configure more transparent. I can change it to just include xenctrl.h before
> xendevicemodel.h if you'd prefer.
> >
> > I guess that is fine with __XEN_TOOLS__.
> > You can add my
> > Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
> >
> 
> Sorry for jumping in only now:
> 
> Wouldn't it be better to base qemu's configure modification for support
> of Xen 4.9 (and newer) on my just posted series introducing pkg-config?
> 
> I'm just about to expand this series to all of Xen's libraries and I
> already have a qemu patch at hand supporting this new scheme.

Ok, but I'm at v2 and I was literally just about to post. I guess it will also be pretty trivial to change configure after this change has been applied.

  Paul

> 
> 
> Juergen

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
@ 2017-03-02 11:06             ` Paul Durrant
  0 siblings, 0 replies; 42+ messages in thread
From: Paul Durrant @ 2017-03-02 11:06 UTC (permalink / raw)
  To: 'Juergen Gross', Anthony Perard
  Cc: xen-devel, Stefano Stabellini, qemu-devel

> -----Original Message-----
> From: Juergen Gross [mailto:jgross@suse.com]
> Sent: 02 March 2017 11:01
> To: Anthony Perard <anthony.perard@citrix.com>; Paul Durrant
> <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; Stefano Stabellini
> <sstabellini@kernel.org>; qemu-devel@nongnu.org
> Subject: Re: [Xen-devel] [PATCH 4/5] configure: detect presence of
> libxendevicemodel
> 
> On 02/03/17 11:54, Anthony PERARD wrote:
> > On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
> >>> -----Original Message-----
> >>> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> >>> Sent: 01 March 2017 17:18
> >>> To: Paul Durrant <Paul.Durrant@citrix.com>
> >>> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
> >>> Stabellini <sstabellini@kernel.org>
> >>> Subject: Re: [PATCH 4/5] configure: detect presence of
> libxendevicemodel
> >>>
> >>> On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
> >>>> This patch adds code in configure to set
> >>> CONFIG_XEN_CTRL_INTERFACE_VERSION
> >>>> to a new value of 490 if libxendevicemodel is present in the build
> >>>> environment.
> >>>>
> >>>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> >>>> ---
> >>>> Cc: Stefano Stabellini <sstabellini@kernel.org>
> >>>> Cc: Anthony Perard <anthony.perard@citrix.com>
> >>>> ---
> >>>>  configure | 19 +++++++++++++++++++
> >>>>  1 file changed, 19 insertions(+)
> >>>>
> >>>> diff --git a/configure b/configure
> >>>> index 8e8f18d..fc1e12b 100755
> >>>> --- a/configure
> >>>> +++ b/configure
> >>>> @@ -1980,6 +1980,25 @@ EOF
> >>>>    # Xen unstable
> >>>>    elif
> >>>>        cat > $TMPC <<EOF &&
> >>>> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
> >>>> +#define __XEN_TOOLS__
> >>>
> >>> Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
> >>> xen.git?
> >>>
> >>> Also it seems to be the only time this define is used in your patch
> >>> series.
> >>>
> >> No. QEMU falls under the definition of 'tools' as far as Xen goes and the
> hypercalls and xendevicemodel API are protected by that. The reason you
> don't see it elsewhere is that xenctrl.h defines it. (See
> http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenc
> trl.h;hb=HEAD#l27).
> >> I think that's a little underhand so I thought I'd make the new code in
> configure more transparent. I can change it to just include xenctrl.h before
> xendevicemodel.h if you'd prefer.
> >
> > I guess that is fine with __XEN_TOOLS__.
> > You can add my
> > Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
> >
> 
> Sorry for jumping in only now:
> 
> Wouldn't it be better to base qemu's configure modification for support
> of Xen 4.9 (and newer) on my just posted series introducing pkg-config?
> 
> I'm just about to expand this series to all of Xen's libraries and I
> already have a qemu patch at hand supporting this new scheme.

Ok, but I'm at v2 and I was literally just about to post. I guess it will also be pretty trivial to change configure after this change has been applied.

  Paul

> 
> 
> Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [Xen-devel] [PATCH 4/5] configure: detect presence of libxendevicemodel
  2017-03-02 11:06             ` Paul Durrant
@ 2017-03-02 11:26               ` Juergen Gross
  -1 siblings, 0 replies; 42+ messages in thread
From: Juergen Gross @ 2017-03-02 11:26 UTC (permalink / raw)
  To: Paul Durrant, Anthony Perard; +Cc: xen-devel, Stefano Stabellini, qemu-devel

On 02/03/17 12:06, Paul Durrant wrote:
>> -----Original Message-----
>> From: Juergen Gross [mailto:jgross@suse.com]
>> Sent: 02 March 2017 11:01
>> To: Anthony Perard <anthony.perard@citrix.com>; Paul Durrant
>> <Paul.Durrant@citrix.com>
>> Cc: xen-devel@lists.xenproject.org; Stefano Stabellini
>> <sstabellini@kernel.org>; qemu-devel@nongnu.org
>> Subject: Re: [Xen-devel] [PATCH 4/5] configure: detect presence of
>> libxendevicemodel
>>
>> On 02/03/17 11:54, Anthony PERARD wrote:
>>> On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
>>>>> -----Original Message-----
>>>>> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
>>>>> Sent: 01 March 2017 17:18
>>>>> To: Paul Durrant <Paul.Durrant@citrix.com>
>>>>> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
>>>>> Stabellini <sstabellini@kernel.org>
>>>>> Subject: Re: [PATCH 4/5] configure: detect presence of
>> libxendevicemodel
>>>>>
>>>>> On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
>>>>>> This patch adds code in configure to set
>>>>> CONFIG_XEN_CTRL_INTERFACE_VERSION
>>>>>> to a new value of 490 if libxendevicemodel is present in the build
>>>>>> environment.
>>>>>>
>>>>>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
>>>>>> ---
>>>>>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>>>>>> Cc: Anthony Perard <anthony.perard@citrix.com>
>>>>>> ---
>>>>>>  configure | 19 +++++++++++++++++++
>>>>>>  1 file changed, 19 insertions(+)
>>>>>>
>>>>>> diff --git a/configure b/configure
>>>>>> index 8e8f18d..fc1e12b 100755
>>>>>> --- a/configure
>>>>>> +++ b/configure
>>>>>> @@ -1980,6 +1980,25 @@ EOF
>>>>>>    # Xen unstable
>>>>>>    elif
>>>>>>        cat > $TMPC <<EOF &&
>>>>>> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
>>>>>> +#define __XEN_TOOLS__
>>>>>
>>>>> Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
>>>>> xen.git?
>>>>>
>>>>> Also it seems to be the only time this define is used in your patch
>>>>> series.
>>>>>
>>>> No. QEMU falls under the definition of 'tools' as far as Xen goes and the
>> hypercalls and xendevicemodel API are protected by that. The reason you
>> don't see it elsewhere is that xenctrl.h defines it. (See
>> http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenc
>> trl.h;hb=HEAD#l27).
>>>> I think that's a little underhand so I thought I'd make the new code in
>> configure more transparent. I can change it to just include xenctrl.h before
>> xendevicemodel.h if you'd prefer.
>>>
>>> I guess that is fine with __XEN_TOOLS__.
>>> You can add my
>>> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
>>>
>>
>> Sorry for jumping in only now:
>>
>> Wouldn't it be better to base qemu's configure modification for support
>> of Xen 4.9 (and newer) on my just posted series introducing pkg-config?
>>
>> I'm just about to expand this series to all of Xen's libraries and I
>> already have a qemu patch at hand supporting this new scheme.
> 
> Ok, but I'm at v2 and I was literally just about to post. I guess it will also be pretty trivial to change configure after this change has been applied.

Sure, this will work.

Its your decision. :-)


Juergen

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 4/5] configure: detect presence of libxendevicemodel
@ 2017-03-02 11:26               ` Juergen Gross
  0 siblings, 0 replies; 42+ messages in thread
From: Juergen Gross @ 2017-03-02 11:26 UTC (permalink / raw)
  To: Paul Durrant, Anthony Perard; +Cc: xen-devel, Stefano Stabellini, qemu-devel

On 02/03/17 12:06, Paul Durrant wrote:
>> -----Original Message-----
>> From: Juergen Gross [mailto:jgross@suse.com]
>> Sent: 02 March 2017 11:01
>> To: Anthony Perard <anthony.perard@citrix.com>; Paul Durrant
>> <Paul.Durrant@citrix.com>
>> Cc: xen-devel@lists.xenproject.org; Stefano Stabellini
>> <sstabellini@kernel.org>; qemu-devel@nongnu.org
>> Subject: Re: [Xen-devel] [PATCH 4/5] configure: detect presence of
>> libxendevicemodel
>>
>> On 02/03/17 11:54, Anthony PERARD wrote:
>>> On Thu, Mar 02, 2017 at 09:06:43AM +0000, Paul Durrant wrote:
>>>>> -----Original Message-----
>>>>> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
>>>>> Sent: 01 March 2017 17:18
>>>>> To: Paul Durrant <Paul.Durrant@citrix.com>
>>>>> Cc: xen-devel@lists.xenproject.org; qemu-devel@nongnu.org; Stefano
>>>>> Stabellini <sstabellini@kernel.org>
>>>>> Subject: Re: [PATCH 4/5] configure: detect presence of
>> libxendevicemodel
>>>>>
>>>>> On Thu, Feb 23, 2017 at 02:53:54PM +0000, Paul Durrant wrote:
>>>>>> This patch adds code in configure to set
>>>>> CONFIG_XEN_CTRL_INTERFACE_VERSION
>>>>>> to a new value of 490 if libxendevicemodel is present in the build
>>>>>> environment.
>>>>>>
>>>>>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
>>>>>> ---
>>>>>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>>>>>> Cc: Anthony Perard <anthony.perard@citrix.com>
>>>>>> ---
>>>>>>  configure | 19 +++++++++++++++++++
>>>>>>  1 file changed, 19 insertions(+)
>>>>>>
>>>>>> diff --git a/configure b/configure
>>>>>> index 8e8f18d..fc1e12b 100755
>>>>>> --- a/configure
>>>>>> +++ b/configure
>>>>>> @@ -1980,6 +1980,25 @@ EOF
>>>>>>    # Xen unstable
>>>>>>    elif
>>>>>>        cat > $TMPC <<EOF &&
>>>>>> +#undef XC_WANT_COMPAT_DEVICEMODEL_API
>>>>>> +#define __XEN_TOOLS__
>>>>>
>>>>> Isn't __XEN_TOOLS__ supposed to be reserved for some to tools inside
>>>>> xen.git?
>>>>>
>>>>> Also it seems to be the only time this define is used in your patch
>>>>> series.
>>>>>
>>>> No. QEMU falls under the definition of 'tools' as far as Xen goes and the
>> hypercalls and xendevicemodel API are protected by that. The reason you
>> don't see it elsewhere is that xenctrl.h defines it. (See
>> http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxc/include/xenc
>> trl.h;hb=HEAD#l27).
>>>> I think that's a little underhand so I thought I'd make the new code in
>> configure more transparent. I can change it to just include xenctrl.h before
>> xendevicemodel.h if you'd prefer.
>>>
>>> I guess that is fine with __XEN_TOOLS__.
>>> You can add my
>>> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
>>>
>>
>> Sorry for jumping in only now:
>>
>> Wouldn't it be better to base qemu's configure modification for support
>> of Xen 4.9 (and newer) on my just posted series introducing pkg-config?
>>
>> I'm just about to expand this series to all of Xen's libraries and I
>> already have a qemu patch at hand supporting this new scheme.
> 
> Ok, but I'm at v2 and I was literally just about to post. I guess it will also be pretty trivial to change configure after this change has been applied.

Sure, this will work.

Its your decision. :-)


Juergen


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

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2017-03-02 11:26 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23 14:53 [Qemu-devel] [PATCH 0/5] xen: use new xendevicemodel library Paul Durrant
2017-02-23 14:53 ` Paul Durrant
2017-02-23 14:53 ` [Qemu-devel] [PATCH 1/5] xen: make use of xen_xc implicit in xen_common.h inlines Paul Durrant
2017-02-23 14:53   ` Paul Durrant
2017-03-01 15:19   ` [Qemu-devel] " Anthony PERARD
2017-03-01 15:19     ` Anthony PERARD
2017-02-23 14:53 ` [Qemu-devel] [PATCH 2/5] xen: rename xen_modified_memory() to xen_hvm_modified_memory() Paul Durrant
2017-02-23 14:53   ` Paul Durrant
2017-03-01 15:24   ` [Qemu-devel] " Anthony PERARD
2017-03-01 15:24     ` Anthony PERARD
2017-02-23 14:53 ` [PATCH 3/5] xen: create wrappers for all other uses of xc_hvm_XXX() functions Paul Durrant
2017-02-23 14:53 ` [Qemu-devel] " Paul Durrant
2017-03-01 16:13   ` Anthony PERARD
2017-03-01 16:13     ` Anthony PERARD
2017-03-01 16:16     ` [Qemu-devel] " Paul Durrant
2017-03-01 16:16       ` Paul Durrant
2017-03-02 10:44       ` [Qemu-devel] " Anthony PERARD
2017-03-02 10:44         ` Anthony PERARD
2017-02-23 14:53 ` [Qemu-devel] [PATCH 4/5] configure: detect presence of libxendevicemodel Paul Durrant
2017-02-23 14:53   ` Paul Durrant
2017-03-01 17:17   ` [Qemu-devel] " Anthony PERARD
2017-03-01 17:17     ` Anthony PERARD
2017-03-02  9:06     ` [Qemu-devel] " Paul Durrant
2017-03-02  9:06       ` Paul Durrant
2017-03-02 10:54       ` [Qemu-devel] " Anthony PERARD
2017-03-02 10:54         ` Anthony PERARD
2017-03-02 10:55         ` [Qemu-devel] " Paul Durrant
2017-03-02 10:55           ` Paul Durrant
2017-03-02 11:01         ` [Qemu-devel] [Xen-devel] " Juergen Gross
2017-03-02 11:01           ` Juergen Gross
2017-03-02 11:06           ` [Qemu-devel] [Xen-devel] " Paul Durrant
2017-03-02 11:06             ` Paul Durrant
2017-03-02 11:26             ` [Qemu-devel] [Xen-devel] " Juergen Gross
2017-03-02 11:26               ` Juergen Gross
2017-02-23 14:53 ` [Qemu-devel] [PATCH 5/5] xen: use libxendevicemodel when available Paul Durrant
2017-02-23 14:53   ` Paul Durrant
2017-03-02  2:05   ` [Qemu-devel] " Stefano Stabellini
2017-03-02  2:05     ` Stefano Stabellini
2017-03-02  8:58     ` [Qemu-devel] " Paul Durrant
2017-03-02  8:58       ` Paul Durrant
2017-02-23 14:55 ` [Qemu-devel] [PATCH 0/5] xen: use new xendevicemodel library Paul Durrant
2017-02-23 14:55   ` Paul Durrant

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.