Skip to contentSkip to conversation

xen: use new xendevicemodel library

PATCH Superseded Paul Durrant 3 participants 16 messages Mar 2, 2017 – Mar 7, 2017

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover 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.

[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  | 201 ++++++++++++++++++++++++++++++++-----------
 xen-common.c                 |  11 +++
 xen-hvm-stub.c               |   2 +-
 xen-hvm.c                    |  49 ++++++-----
 10 files changed, 208 insertions(+), 86 deletions(-)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

PATCH v2 2/5 xen: rename xen_modified_memory() to xen_hvm_modified_memory()

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

---
Cc: Paolo Bonzini <[email protected]>
Cc: Stefano Stabellini <[email protected]>

---
 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(-)
include/exec/ram_addr.h +2 -2
index 3e79466..8715af6 100644
@@ -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;
         /*
include/hw/xen/xen.h +1 -1
index 09c2ce5..2b1733b 100644
@@ -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);
 
xen-hvm-stub.c +1 -1
index c500325..3ca6c51 100644
@@ -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)
 {
 }
 
xen-hvm.c +1 -1
index dbb8c66..edf4983 100644
@@ -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;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw

PATCH v2 4/5 configure: detect presence of libxendevicemodel

In reply to Paul Durrant

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.

---
Cc: Stefano Stabellini <[email protected]>

---
 configure | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
configure +19 -0
index 8e8f18d..fc1e12b 100755
@@ -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.
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#5 lore raw

PATCH v2 5/5 xen: use libxendevicemodel when available

In reply to Paul Durrant

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.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

v2:
- Add a compat define for xenforeignmemory_close() since this is now used.

---
 include/hw/xen/xen_common.h | 115 +++++++++++++++++++++++++++++++-------------
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
include/hw/xen/xen_common.h +82 -33
index 31cf25f..48444e5 100644
@@ -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 */
@@ -97,6 +145,7 @@ typedef xc_gnttab xengnttab_handle;
     xc_gnttab_map_domain_grant_refs(h, c, d, r, p)
 
 #define xenforeignmemory_open(l, f) xen_xc
+#define xenforeignmemory_close(h)
 
 static inline void *xenforeignmemory_map(xc_interface *h, uint32_t dom,
                                          int prot, size_t pages,
@@ -285,8 +334,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 +351,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 +368,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 +385,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 +399,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 +415,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 +446,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 +461,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 +475,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
xen-common.c +8 -0
index 703e7a5..ae76150 100644
@@ -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();
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH v2 1/5 xen: make use of xen_xc implicit in xen_common.h inlines

In reply to Paul Durrant

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.

---
Cc: Stefano Stabellini <[email protected]>

---
 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(-)
hw/xen/xen_backend.c +0 -2
index 6c21c37..d34c49e 100644
@@ -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;
 
include/hw/xen/xen_backend.h +0 -2
index 4f4799a..30811a1 100644
@@ -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;
include/hw/xen/xen_common.h +47 -43

276 lines not on this page · raw message

xen-common.c +3 -0
index fd2c928..703e7a5 100644
@@ -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;
xen-hvm.c +10 -10
index 5043beb..dbb8c66 100644
@@ -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);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#3 lore raw

PATCH v2 3/5 xen: create wrappers for all other uses of xc_hvm_XXX() functions

In reply to Paul Durrant

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.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>

---
 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(-)
hw/i386/xen/xen_platform.c +1 -1
index 6010f35..1419fc9 100644
@@ -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;
include/hw/xen/xen_common.h +44 -0

50 lines not on this page · raw message

xen-hvm.c +13 -14
index edf4983..4b928cf 100644
@@ -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",
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 5/5
#6 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

In reply to Paul Durrant
Quoted 5 lines · Paul Durrant

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.

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#7 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

In reply to Paul Durrant
Quoted 59 lines · Paul Durrant

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.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

v2:
- Add a compat define for xenforeignmemory_close() since this is now used.

---
 include/hw/xen/xen_common.h | 115 +++++++++++++++++++++++++++++++-------------
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
include/hw/xen/xen_common.h +27 -0
index 31cf25f..48444e5 100644
@@ -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

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 65

Quoted 10 lines
include/hw/xen/xen_common.h +10 -0
+#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

It does build correctly now for Xen < 4.9, however it breaks against xen-unstable:

ERROR: configure test passed without -Werror but failed with -Werror.
This is probably a bug in the configure script. The failing command will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.

and config.log says:

config-temp/qemu-conf.c: In function 'main':
config-temp/qemu-conf.c:32:3: error: implicit declaration of function 'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration] config-temp/qemu-conf.c:32:3: error: nested extern declaration of 'xc_hvm_set_mem_type' [-Werror=nested-externs] config-temp/qemu-conf.c:34:3: error: implicit declaration of function 'xc_hvm_inject_msi' [-Werror=implicit-function-declaration] config-temp/qemu-conf.c:34:3: error: nested extern declaration of 'xc_hvm_inject_msi' [-Werror=nested-externs] config-temp/qemu-conf.c:35:3: error: implicit declaration of function 'xc_hvm_create_ioreq_server' [-Werror=implicit-function-declaration] config-temp/qemu-conf.c:35:3: error: nested extern declaration of 'xc_hvm_create_ioreq_server' [-Werror=nested-externs]

With -DXC_WANT_COMPAT_DEVICEMODEL_API=1:

In file included from /local/qemu-upstream/include/hw/xen/xen_backend.h:4:0,

                   from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In function 'xen_set_mem_type':
/local/qemu-upstream/include/hw/xen/xen_common.h:78:5: error: implicit declaration of function 'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration]

Only another comment (I guess you didn't see in my previous email):
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.

Quoted 218 lines
include/hw/xen/xen_common.h +44 -33
+#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 */
@@ -97,6 +145,7 @@ typedef xc_gnttab xengnttab_handle;
     xc_gnttab_map_domain_grant_refs(h, c, d, r, p)
 
 #define xenforeignmemory_open(l, f) xen_xc
+#define xenforeignmemory_close(h)
 
 static inline void *xenforeignmemory_map(xc_interface *h, uint32_t dom,
                                          int prot, size_t pages,
@@ -285,8 +334,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 +351,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 +368,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 +385,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 +399,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 +415,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 +446,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 +461,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 +475,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
xen-common.c +8 -0
index 703e7a5..ae76150 100644
@@ -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();
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 76 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 02 March 2017 22:50
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>
Subject: Re: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 9 lines · Paul Durrant

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.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Quoted 5 lines

v2:
- Add a compat define for xenforeignmemory_close() since this is now used.

---
 include/hw/xen/xen_common.h | 115

+++++++++++++++++++++++++++++++-------------

Review

Quoted 4 lines
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
(quoted diff) +0 -0

b/include/hw/xen/xen_common.h

Quoted 46 lines

index 31cf25f..48444e5 100644

include/hw/xen/xen_common.h +32 -0
@@ -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 \
Quoted 8 lines

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 65

Quoted 5 lines
include/hw/xen/xen_common.h +5 -0
+    xc_hvm_set_mem_type
+#define xendevicemodel_track_dirty_vram \
+    xc_hvm_track_dirty_vram
+#define xendevicemodel_modified_memory \
+    xc_hvm_modified_memory

It does build correctly now for Xen < 4.9, however it breaks against xen-unstable:

That's weird. I built it against staging just before I posted it. I must have something different in my environment. I'll check again.

Quoted 35 lines

ERROR: configure test passed without -Werror but failed with -Werror.
This is probably a bug in the configure script. The failing command will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.

and config.log says:

config-temp/qemu-conf.c: In function 'main':
config-temp/qemu-conf.c:32:3: error: implicit declaration of function
'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:32:3: error: nested extern declaration of
'xc_hvm_set_mem_type' [-Werror=nested-externs]
config-temp/qemu-conf.c:34:3: error: implicit declaration of function
'xc_hvm_inject_msi' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:34:3: error: nested extern declaration of
'xc_hvm_inject_msi' [-Werror=nested-externs]
config-temp/qemu-conf.c:35:3: error: implicit declaration of function
'xc_hvm_create_ioreq_server' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:35:3: error: nested extern declaration of
'xc_hvm_create_ioreq_server' [-Werror=nested-externs]

With -DXC_WANT_COMPAT_DEVICEMODEL_API=1:

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                   from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In function
'xen_set_mem_type':
/local/qemu-upstream/include/hw/xen/xen_common.h:78:5: error: implicit
declaration of function 'xc_hvm_set_mem_type' [-Werror=implicit-function- declaration]

Quoted 5 lines

Only another comment (I guess you didn't see in my previous email):
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.

Ok. I did miss that. By using macros I was just following previous style (and the args just seemed superfluous since they are more-or-less identical, but I'm happy to use inlines instead.

Paul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

In reply to Stefano Stabellini
Quoted 109 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 02 March 2017 22:50
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>
Subject: Re: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 9 lines · Paul Durrant

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.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Quoted 5 lines

v2:
- Add a compat define for xenforeignmemory_close() since this is now used.

---
 include/hw/xen/xen_common.h | 115

+++++++++++++++++++++++++++++++-------------

Review

Quoted 4 lines
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
(quoted diff) +0 -0

b/include/hw/xen/xen_common.h

Quoted 41 lines

index 31cf25f..48444e5 100644

include/hw/xen/xen_common.h +27 -0
@@ -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

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 65

Quoted 10 lines
include/hw/xen/xen_common.h +10 -0
+#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

It does build correctly now for Xen < 4.9, however it breaks against xen-unstable:

ERROR: configure test passed without -Werror but failed with -Werror.
This is probably a bug in the configure script. The failing command will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.

and config.log says:

config-temp/qemu-conf.c: In function 'main':
config-temp/qemu-conf.c:32:3: error: implicit declaration of function
'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:32:3: error: nested extern declaration of
'xc_hvm_set_mem_type' [-Werror=nested-externs]
config-temp/qemu-conf.c:34:3: error: implicit declaration of function
'xc_hvm_inject_msi' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:34:3: error: nested extern declaration of
'xc_hvm_inject_msi' [-Werror=nested-externs]
config-temp/qemu-conf.c:35:3: error: implicit declaration of function
'xc_hvm_create_ioreq_server' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:35:3: error: nested extern declaration of
'xc_hvm_create_ioreq_server' [-Werror=nested-externs]

With -DXC_WANT_COMPAT_DEVICEMODEL_API=1:

Quoted 9 lines

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                   from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In function
'xen_set_mem_type':
/local/qemu-upstream/include/hw/xen/xen_common.h:78:5: error: implicit
declaration of function 'xc_hvm_set_mem_type' [-Werror=implicit-function- declaration]

Ah... Do you have Anthony's patch?

http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9970e98ace48574701f7e2286fb67090481a3fec

I suspect that may be the problem you're seeing above.

Paul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 119 lines · Paul Durrant
Quoted 109 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 02 March 2017 22:50
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>
Subject: Re: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 9 lines · Paul Durrant

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.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Quoted 5 lines

v2:
- Add a compat define for xenforeignmemory_close() since this is now used.

---
 include/hw/xen/xen_common.h | 115

+++++++++++++++++++++++++++++++-------------

Review

Quoted 4 lines
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
(quoted diff) +0 -0

b/include/hw/xen/xen_common.h

Quoted 41 lines

index 31cf25f..48444e5 100644

include/hw/xen/xen_common.h +27 -0
@@ -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

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 65

Quoted 10 lines
include/hw/xen/xen_common.h +10 -0
+#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

It does build correctly now for Xen < 4.9, however it breaks against xen-unstable:

ERROR: configure test passed without -Werror but failed with -Werror.
This is probably a bug in the configure script. The failing command will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.

and config.log says:

config-temp/qemu-conf.c: In function 'main':
config-temp/qemu-conf.c:32:3: error: implicit declaration of function
'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:32:3: error: nested extern declaration of
'xc_hvm_set_mem_type' [-Werror=nested-externs]
config-temp/qemu-conf.c:34:3: error: implicit declaration of function
'xc_hvm_inject_msi' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:34:3: error: nested extern declaration of
'xc_hvm_inject_msi' [-Werror=nested-externs]
config-temp/qemu-conf.c:35:3: error: implicit declaration of function
'xc_hvm_create_ioreq_server' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:35:3: error: nested extern declaration of
'xc_hvm_create_ioreq_server' [-Werror=nested-externs]

With -DXC_WANT_COMPAT_DEVICEMODEL_API=1:

Quoted 9 lines

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                   from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In function
'xen_set_mem_type':
/local/qemu-upstream/include/hw/xen/xen_common.h:78:5: error: implicit
declaration of function 'xc_hvm_set_mem_type' [-Werror=implicit-function- declaration]

Quoted 5 lines

Ah... Do you have Anthony's patch?

http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9970e98ace48574701f7e2286fb67090481a3fec

I suspect that may be the problem you're seeing above.

Yes, I do have it. I am still having build troubles with v5 too. I am attaching my build test script: feel free to use it to test the build of a single QEMU branch against multiple Xen versions. It requires one Xen repository checked out and built for each Xen version. I have just added the Xen 4.9 tests, so they might be wrong somehow, but the others are known to work.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 120 lines · Stefano Stabellini
Quoted 119 lines · Paul Durrant
Quoted 118 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 02 March 2017 22:50
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>
Subject: Re: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 9 lines · Paul Durrant

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.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Quoted 5 lines

v2:
- Add a compat define for xenforeignmemory_close() since this is now used.

---
 include/hw/xen/xen_common.h | 115

+++++++++++++++++++++++++++++++-------------

Review

Quoted 4 lines
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
(quoted diff) +0 -0

b/include/hw/xen/xen_common.h

Quoted 41 lines

index 31cf25f..48444e5 100644

include/hw/xen/xen_common.h +27 -0
@@ -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

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 65

Quoted 10 lines
include/hw/xen/xen_common.h +10 -0
+#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

It does build correctly now for Xen < 4.9, however it breaks against xen-unstable:

ERROR: configure test passed without -Werror but failed with -Werror.
This is probably a bug in the configure script. The failing command will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.

and config.log says:

config-temp/qemu-conf.c: In function 'main':
config-temp/qemu-conf.c:32:3: error: implicit declaration of function
'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:32:3: error: nested extern declaration of
'xc_hvm_set_mem_type' [-Werror=nested-externs]
config-temp/qemu-conf.c:34:3: error: implicit declaration of function
'xc_hvm_inject_msi' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:34:3: error: nested extern declaration of
'xc_hvm_inject_msi' [-Werror=nested-externs]
config-temp/qemu-conf.c:35:3: error: implicit declaration of function
'xc_hvm_create_ioreq_server' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:35:3: error: nested extern declaration of
'xc_hvm_create_ioreq_server' [-Werror=nested-externs]

With -DXC_WANT_COMPAT_DEVICEMODEL_API=1:

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                   from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In function
'xen_set_mem_type':
/local/qemu-upstream/include/hw/xen/xen_common.h:78:5: error: implicit
declaration of function 'xc_hvm_set_mem_type' [-Werror=implicit-function- declaration]

Quoted 7 lines
Quoted 5 lines

Ah... Do you have Anthony's patch?

http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9970e98ace48574701f7e2286fb67090481a3fec

I suspect that may be the problem you're seeing above.

Yes, I do have it. I am still having build troubles with v5 too. I am

I meant v3

Quoted 5 lines

attaching my build test script: feel free to use it to test the build of a single QEMU branch against multiple Xen versions. It requires one Xen repository checked out and built for each Xen version. I have just added the Xen 4.9 tests, so they might be wrong somehow, but the others are known to work.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#12 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 137 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 03 March 2017 20:43
To: Stefano Stabellini <[email protected]>
Cc: Paul Durrant <[email protected]>; [email protected]; [email protected]; Anthony Perard <[email protected]>
Subject: RE: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 10 lines · Stefano Stabellini
Quoted 9 lines · Paul Durrant
Quoted 9 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 02 March 2017 22:50
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected]; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>
Subject: Re: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Paul Durrant
Quoted 1 line

This patch modifies the wrapper functions in xen_common.h to use

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

new xendevicemodel interface if it is available along with

compatibility

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

code to use the old libxenctrl interface if it is not.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

v2:
- Add a compat define for xenforeignmemory_close() since this is

now

Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 3 lines

used.

---
 include/hw/xen/xen_common.h | 115

+++++++++++++++++++++++++++++++-------------

Review

Quoted 4 lines
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
(quoted diff) +0 -0

b/include/hw/xen/xen_common.h

Quoted 41 lines

index 31cf25f..48444e5 100644

include/hw/xen/xen_common.h +27 -0
@@ -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

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 65

Quoted 10 lines
include/hw/xen/xen_common.h +10 -0
+#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

It does build correctly now for Xen < 4.9, however it breaks against xen-unstable:

ERROR: configure test passed without -Werror but failed with -Werror.
This is probably a bug in the configure script. The failing command will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.

and config.log says:

config-temp/qemu-conf.c: In function 'main':
config-temp/qemu-conf.c:32:3: error: implicit declaration of function
'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:32:3: error: nested extern declaration of
'xc_hvm_set_mem_type' [-Werror=nested-externs]
config-temp/qemu-conf.c:34:3: error: implicit declaration of function
'xc_hvm_inject_msi' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:34:3: error: nested extern declaration of
'xc_hvm_inject_msi' [-Werror=nested-externs]
config-temp/qemu-conf.c:35:3: error: implicit declaration of function
'xc_hvm_create_ioreq_server' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:35:3: error: nested extern declaration of
'xc_hvm_create_ioreq_server' [-Werror=nested-externs]

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

With -DXC_WANT_COMPAT_DEVICEMODEL_API=1:

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                   from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In function
'xen_set_mem_type':
/local/qemu-upstream/include/hw/xen/xen_common.h:78:5: error:

implicit

Quoted 1 line
Quoted 1 line
Quoted 1 line

declaration of function 'xc_hvm_set_mem_type' [-Werror=implicit-

function-

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

declaration]

Ah... Do you have Anthony's patch?

Quoted 15 lines

http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9970e98ace48574701
f7e2286fb67090481a3fec

Quoted 4 lines
Quoted 2 lines

I suspect that may be the problem you're seeing above.

Yes, I do have it. I am still having build troubles with v5 too. I am

I meant v3

Quoted 5 lines

attaching my build test script: feel free to use it to test the build of a single QEMU branch against multiple Xen versions. It requires one Xen repository checked out and built for each Xen version. I have just added the Xen 4.9 tests, so they might be wrong somehow, but the others are known to work.

Your script is lacking Anthony's fix. You need to patch your 4.9 configure clause accordingly. I.e. you need -I$(XEN_ROOT)/tools/libs/devicemodel/include and -L$(XEN_ROOT)/tools/libs/devicemodel in the --extra-cflags.

Paul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 167 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Paul Durrant
Sent: 06 March 2017 09:15
To: 'Stefano Stabellini' <[email protected]>
Cc: Anthony Perard <[email protected]>; xen- [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 5 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 03 March 2017 20:43
To: Stefano Stabellini <[email protected]>
Cc: Paul Durrant <[email protected]>; xen-

[email protected];

Quoted 10 lines

[email protected]; Anthony Perard <[email protected]>
Subject: RE: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 6 lines · Stefano Stabellini
Quoted 5 lines · Paul Durrant
Quoted 5 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 02 March 2017 22:50
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected];

Stefano

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Stabellini <[email protected]>; Anthony Perard <[email protected]>
Subject: Re: [PATCH v2 5/5] xen: use libxendevicemodel when

available

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Paul Durrant
Quoted 1 line

This patch modifies the wrapper functions in xen_common.h to use

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

new xendevicemodel interface if it is available along with

compatibility

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

code to use the old libxenctrl interface if it is not.

Quoted 73 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

v2:
- Add a compat define for xenforeignmemory_close() since this is

now

Quoted 65 lines
Quoted 65 lines
Quoted 65 lines
Quoted 3 lines

used.

---
 include/hw/xen/xen_common.h | 115

+++++++++++++++++++++++++++++++-------------

Review

Quoted 4 lines
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
(quoted diff) +0 -0

b/include/hw/xen/xen_common.h

Quoted 41 lines

index 31cf25f..48444e5 100644

include/hw/xen/xen_common.h +27 -0
@@ -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

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 65

Quoted 10 lines
include/hw/xen/xen_common.h +10 -0
+#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

It does build correctly now for Xen < 4.9, however it breaks against xen-unstable:

ERROR: configure test passed without -Werror but failed with -

Werror.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This is probably a bug in the configure script. The failing command will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.

and config.log says:

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

config-temp/qemu-conf.c: In function 'main':
config-temp/qemu-conf.c:32:3: error: implicit declaration of function
'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:32:3: error: nested extern declaration of
'xc_hvm_set_mem_type' [-Werror=nested-externs]
config-temp/qemu-conf.c:34:3: error: implicit declaration of function
'xc_hvm_inject_msi' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:34:3: error: nested extern declaration of
'xc_hvm_inject_msi' [-Werror=nested-externs]
config-temp/qemu-conf.c:35:3: error: implicit declaration of function
'xc_hvm_create_ioreq_server' [-Werror=implicit-function-

declaration]

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

config-temp/qemu-conf.c:35:3: error: nested extern declaration of
'xc_hvm_create_ioreq_server' [-Werror=nested-externs]

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

With -DXC_WANT_COMPAT_DEVICEMODEL_API=1:

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                   from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In function
'xen_set_mem_type':
/local/qemu-upstream/include/hw/xen/xen_common.h:78:5: error:

Quoted 10 lines

implicit

Quoted 1 line
Quoted 1 line
Quoted 1 line

declaration of function 'xc_hvm_set_mem_type' [-Werror=implicit-

function-

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

declaration]

Ah... Do you have Anthony's patch?

http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9970e98ace48574701

Quoted 13 lines

f7e2286fb67090481a3fec

Quoted 4 lines
Quoted 2 lines

I suspect that may be the problem you're seeing above.

Yes, I do have it. I am still having build troubles with v5 too. I am

I meant v3

Quoted 4 lines

attaching my build test script: feel free to use it to test the build of a single QEMU branch against multiple Xen versions. It requires one Xen repository checked out and built for each Xen version. I have just added the Xen 4.9 tests, so they might be wrong somehow, but the

Quoted 7 lines

others

Quoted 1 line
Quoted 1 line

are known to work.

Your script is lacking Anthony's fix. You need to patch your 4.9 configure clause accordingly. I.e. you need - I$(XEN_ROOT)/tools/libs/devicemodel/include and - L$(XEN_ROOT)/tools/libs/devicemodel in the --extra-cflags.

Sorry, I meant the latter in --extra-ldflags and I notice you do actually have that. It's just the -I that's missing.

Paul

Quoted 2 lines

Paul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#14 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 168 lines · Paul Durrant
Quoted 168 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Paul Durrant
Sent: 06 March 2017 09:15
To: 'Stefano Stabellini' <[email protected]>
Cc: Anthony Perard <[email protected]>; xen- [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 5 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 03 March 2017 20:43
To: Stefano Stabellini <[email protected]>
Cc: Paul Durrant <[email protected]>; xen-

[email protected];

Quoted 10 lines

[email protected]; Anthony Perard <[email protected]>
Subject: RE: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 6 lines · Stefano Stabellini
Quoted 5 lines · Paul Durrant
Quoted 5 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 02 March 2017 22:50
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected];

Stefano

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Stabellini <[email protected]>; Anthony Perard <[email protected]>
Subject: Re: [PATCH v2 5/5] xen: use libxendevicemodel when

available

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Paul Durrant
Quoted 1 line

This patch modifies the wrapper functions in xen_common.h to use

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

new xendevicemodel interface if it is available along with

compatibility

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

code to use the old libxenctrl interface if it is not.

Quoted 73 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

v2:
- Add a compat define for xenforeignmemory_close() since this is

now

Quoted 65 lines
Quoted 65 lines
Quoted 65 lines
Quoted 3 lines

used.

---
 include/hw/xen/xen_common.h | 115

+++++++++++++++++++++++++++++++-------------

Review

Quoted 4 lines
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
(quoted diff) +0 -0

b/include/hw/xen/xen_common.h

Quoted 41 lines

index 31cf25f..48444e5 100644

include/hw/xen/xen_common.h +27 -0
@@ -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

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 65

Quoted 10 lines
include/hw/xen/xen_common.h +10 -0
+#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

It does build correctly now for Xen < 4.9, however it breaks against xen-unstable:

ERROR: configure test passed without -Werror but failed with -

Werror.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This is probably a bug in the configure script. The failing command will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.

and config.log says:

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

config-temp/qemu-conf.c: In function 'main':
config-temp/qemu-conf.c:32:3: error: implicit declaration of function
'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:32:3: error: nested extern declaration of
'xc_hvm_set_mem_type' [-Werror=nested-externs]
config-temp/qemu-conf.c:34:3: error: implicit declaration of function
'xc_hvm_inject_msi' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:34:3: error: nested extern declaration of
'xc_hvm_inject_msi' [-Werror=nested-externs]
config-temp/qemu-conf.c:35:3: error: implicit declaration of function
'xc_hvm_create_ioreq_server' [-Werror=implicit-function-

declaration]

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

config-temp/qemu-conf.c:35:3: error: nested extern declaration of
'xc_hvm_create_ioreq_server' [-Werror=nested-externs]

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

With -DXC_WANT_COMPAT_DEVICEMODEL_API=1:

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                   from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In function
'xen_set_mem_type':
/local/qemu-upstream/include/hw/xen/xen_common.h:78:5: error:

Quoted 10 lines

implicit

Quoted 1 line
Quoted 1 line
Quoted 1 line

declaration of function 'xc_hvm_set_mem_type' [-Werror=implicit-

function-

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

declaration]

Ah... Do you have Anthony's patch?

http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9970e98ace48574701

Quoted 13 lines

f7e2286fb67090481a3fec

Quoted 4 lines
Quoted 2 lines

I suspect that may be the problem you're seeing above.

Yes, I do have it. I am still having build troubles with v5 too. I am

I meant v3

Quoted 4 lines

attaching my build test script: feel free to use it to test the build of a single QEMU branch against multiple Xen versions. It requires one Xen repository checked out and built for each Xen version. I have just added the Xen 4.9 tests, so they might be wrong somehow, but the

others

Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

are known to work.

Your script is lacking Anthony's fix. You need to patch your 4.9 configure clause accordingly. I.e. you need - I$(XEN_ROOT)/tools/libs/devicemodel/include and - L$(XEN_ROOT)/tools/libs/devicemodel in the --extra-cflags.

Sorry, I meant the latter in --extra-ldflags and I notice you do actually have that. It's just the -I that's missing.

Thank you, you are right, that fixes the build against 4.9, but there are problems with all other versions:

[4.3, 4.4]

In file included from /local/qemu-upstream/include/hw/xen/xen_backend.h:4:0,

                 from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h:42:5: error: unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:49:49: error: unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:58:49: error: unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:66:49: error: unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:74:49: error: unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:82:49: error: unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:90:49: error: unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:96:49: error: unknown type name 'ioservid_t'
make: *** [hw/block/xen_disk.o] Error 1

[4.5, 4.6, 4.7, 4.8]

In file included from /local/qemu-upstream/include/hw/xen/xen_backend.h:4:0,

                 from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In function 'xendevicemodel_destroy_ioreq_server':
/local/qemu-upstream/include/hw/xen/xen_common.h:92:5: error: implicit declaration of function 'xc_hvm__destroy_ioreq_server' [-Werror=implicit-function-declaration] /local/qemu-upstream/include/hw/xen/xen_common.h:92:5: error: nested extern declaration of 'xc_hvm__destroy_ioreq_server' [-Werror=nested-externs]
cc1: all warnings being treated as errors

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#15 lore raw

Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 225 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 06 March 2017 19:14
To: Paul Durrant <[email protected]>
Cc: 'Stefano Stabellini' <[email protected]>; Anthony Perard <[email protected]>; [email protected]; qemu- [email protected]
Subject: RE: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 3 lines · Paul Durrant
Quoted 3 lines

-----Original Message-----
From: Qemu-devel [mailto:qemu-devel- [email protected]] On Behalf Of Paul

Durrant

Quoted 5 lines
Quoted 5 lines

Sent: 06 March 2017 09:15
To: 'Stefano Stabellini' <[email protected]>
Cc: Anthony Perard <[email protected]>; xen- [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH v2 5/5] xen: use libxendevicemodel

when

Quoted 9 lines
Quoted 9 lines

available

Quoted 5 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 03 March 2017 20:43
To: Stefano Stabellini <[email protected]>
Cc: Paul Durrant <[email protected]>; xen-

[email protected];

Quoted 1 line

[email protected]; Anthony Perard

<[email protected]>

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Subject: RE: [PATCH v2 5/5] xen: use libxendevicemodel when available

Quoted 6 lines · Stefano Stabellini
Quoted 5 lines · Paul Durrant
Quoted 5 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: 02 March 2017 22:50
To: Paul Durrant <[email protected]>
Cc: [email protected]; [email protected];

Quoted 8 lines
Quoted 8 lines

Stefano

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Stabellini <[email protected]>; Anthony Perard <[email protected]>
Subject: Re: [PATCH v2 5/5] xen: use libxendevicemodel when

available

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Paul Durrant
Quoted 1 line

This patch modifies the wrapper functions in xen_common.h to

use

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

new xendevicemodel interface if it is available along with

compatibility

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

code to use the old libxenctrl interface if it is not.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

v2:
- Add a compat define for xenforeignmemory_close() since this

is

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines

now

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 3 lines

used.

---
 include/hw/xen/xen_common.h | 115

+++++++++++++++++++++++++++++++-------------

Review

Quoted 4 lines
 xen-common.c                |   8 +++
 2 files changed, 90 insertions(+), 33 deletions(-)
(quoted diff) +0 -0

b/include/hw/xen/xen_common.h

Quoted 15 lines

index 31cf25f..48444e5 100644

include/hw/xen/xen_common.h +1 -0
@@ -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.
  */
 
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 38

Quoted 9 lines
include/hw/xen/xen_common.h +9 -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 \

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 42

Quoted 4 lines
include/hw/xen/xen_common.h +4 -0
+    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

\

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 13 lines
include/hw/xen/xen_common.h +13 -0
+    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

include/hw/xen/xen_common.h extern xc_interface *xen_xc; · line 65

Quoted 10 lines
include/hw/xen/xen_common.h +10 -0
+#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

It does build correctly now for Xen < 4.9, however it breaks against xen-unstable:

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ERROR: configure test passed without -Werror but failed with -

Werror.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

This is probably a bug in the configure script. The failing

command

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this

check.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

and config.log says:

config-temp/qemu-conf.c: In function 'main':
config-temp/qemu-conf.c:32:3: error: implicit declaration of

function

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

'xc_hvm_set_mem_type' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:32:3: error: nested extern declaration

of

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

'xc_hvm_set_mem_type' [-Werror=nested-externs]
config-temp/qemu-conf.c:34:3: error: implicit declaration of

function

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

'xc_hvm_inject_msi' [-Werror=implicit-function-declaration]
config-temp/qemu-conf.c:34:3: error: nested extern declaration

of

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

'xc_hvm_inject_msi' [-Werror=nested-externs]
config-temp/qemu-conf.c:35:3: error: implicit declaration of

function

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'xc_hvm_create_ioreq_server' [-Werror=implicit-function-

declaration]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

config-temp/qemu-conf.c:35:3: error: nested extern declaration

of

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

'xc_hvm_create_ioreq_server' [-Werror=nested-externs]

With -DXC_WANT_COMPAT_DEVICEMODEL_API=1:

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                   from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h: In

function

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

'xen_set_mem_type':
/local/qemu-upstream/include/hw/xen/xen_common.h:78:5:

error:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

implicit

Quoted 1 line
Quoted 1 line
Quoted 1 line

declaration of function 'xc_hvm_set_mem_type' [-

Werror=implicit-

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

function-

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

declaration]

Ah... Do you have Anthony's patch?

http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=9970e98ace48574701

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

f7e2286fb67090481a3fec

Quoted 4 lines
Quoted 2 lines

I suspect that may be the problem you're seeing above.

Yes, I do have it. I am still having build troubles with v5 too. I am

I meant v3

Quoted 2 lines

attaching my build test script: feel free to use it to test the build of a single QEMU branch against multiple Xen versions. It requires one

Xen

Quoted 11 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

repository checked out and built for each Xen version. I have just added the Xen 4.9 tests, so they might be wrong somehow, but the

others

Quoted 1 line
Quoted 1 line

are known to work.

Your script is lacking Anthony's fix. You need to patch your 4.9 configure clause accordingly. I.e. you need - I$(XEN_ROOT)/tools/libs/devicemodel/include and - L$(XEN_ROOT)/tools/libs/devicemodel in the --extra-cflags.

Sorry, I meant the latter in --extra-ldflags and I notice you do actually have

that. It's just the -I that's missing.

Thank you, you are right, that fixes the build against 4.9, but there are problems with all other versions:

[4.3, 4.4]

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                 from hw/block/xen_disk.c:27:

/local/qemu-upstream/include/hw/xen/xen_common.h:42:5: error:
unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:49:49: error:
unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:58:49: error:
unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:66:49: error:
unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:74:49: error:

Quoted 9 lines

unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:82:49: error:
unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:90:49: error:
unknown type name 'ioservid_t' /local/qemu-upstream/include/hw/xen/xen_common.h:96:49: error:
unknown type name 'ioservid_t'
make: *** [hw/block/xen_disk.o] Error 1

That's one I'd not considered. I need to cater for an old enough xen where even the old ioreq server API is not available.

Quoted 6 lines

[4.5, 4.6, 4.7, 4.8]

In file included from /local/qemu-
upstream/include/hw/xen/xen_backend.h:4:0,

                 from hw/block/xen_disk.c:27:
Quoted 9 lines

/local/qemu-upstream/include/hw/xen/xen_common.h: In function 'xendevicemodel_destroy_ioreq_server':
/local/qemu-upstream/include/hw/xen/xen_common.h:92:5: error: implicit declaration of function 'xc_hvm__destroy_ioreq_server' [-Werror=implicit- function-declaration] /local/qemu-upstream/include/hw/xen/xen_common.h:92:5: error: nested extern declaration of 'xc_hvm__destroy_ioreq_server' [-Werror=nested- externs]
cc1: all warnings being treated as errors

That's a typo (double _) which I've now found.

V4 coming up.

Thanks,

Paul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel