hw/xen: Rename xen_common.h to xen_native.h

This header is now only for native Xen code, not PV backends that may be
used in Xen emulation. Since the toolstack libraries may depend on the
specific version of Xen headers that they pull in (and will set the
__XEN_TOOLS__ macro to enable internal definitions that they depend on),
the rule is that xen_native.h (and thus the toolstack library headers)
must be included *before* any of the headers in include/hw/xen/interface.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
This commit is contained in:
David Woodhouse 2023-01-02 00:39:13 +00:00
parent a9ae1418b3
commit e2abfe5ec6
17 changed files with 47 additions and 32 deletions

View file

@ -12,6 +12,7 @@
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qemu/module.h" #include "qemu/module.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "hw/xen/xen_native.h"
#include "hw/xen/xen-legacy-backend.h" #include "hw/xen/xen-legacy-backend.h"
#include "hw/xen/xen_pt.h" #include "hw/xen/xen_pt.h"
#include "chardev/char.h" #include "chardev/char.h"

View file

@ -22,6 +22,7 @@
#include "qemu/config-file.h" #include "qemu/config-file.h"
#include "qemu/main-loop.h" #include "qemu/main-loop.h"
#include "qemu/option.h" #include "qemu/option.h"
#include "qemu/iov.h"
#include "fsdev/qemu-fsdev.h" #include "fsdev/qemu-fsdev.h"
#define VERSIONS "1" #define VERSIONS "1"

View file

@ -23,8 +23,9 @@
#include "qemu/main-loop.h" #include "qemu/main-loop.h"
#include "qemu/memalign.h" #include "qemu/memalign.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "hw/xen/xen_common.h" #include "hw/xen/xen.h"
#include "hw/block/xen_blkif.h" #include "hw/block/xen_blkif.h"
#include "hw/xen/interface/io/ring.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "sysemu/iothread.h" #include "sysemu/iothread.h"
#include "xen-block.h" #include "xen-block.h"

View file

@ -19,7 +19,6 @@
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "qom/object_interfaces.h" #include "qom/object_interfaces.h"
#include "hw/xen/xen_common.h"
#include "hw/block/xen_blkif.h" #include "hw/block/xen_blkif.h"
#include "hw/qdev-properties.h" #include "hw/qdev-properties.h"
#include "hw/xen/xen-block.h" #include "hw/xen/xen-block.h"

View file

@ -47,8 +47,6 @@
#include "hw/kvm/clock.h" #include "hw/kvm/clock.h"
#include "hw/sysbus.h" #include "hw/sysbus.h"
#include "hw/i2c/smbus_eeprom.h" #include "hw/i2c/smbus_eeprom.h"
#include "hw/xen/xen-x86.h"
#include "hw/xen/xen.h"
#include "exec/memory.h" #include "exec/memory.h"
#include "hw/acpi/acpi.h" #include "hw/acpi/acpi.h"
#include "hw/acpi/piix4.h" #include "hw/acpi/piix4.h"
@ -60,6 +58,8 @@
#include <xen/hvm/hvm_info_table.h> #include <xen/hvm/hvm_info_table.h>
#include "hw/xen/xen_pt.h" #include "hw/xen/xen_pt.h"
#endif #endif
#include "hw/xen/xen-x86.h"
#include "hw/xen/xen.h"
#include "migration/global_state.h" #include "migration/global_state.h"
#include "migration/misc.h" #include "migration/misc.h"
#include "sysemu/numa.h" #include "sysemu/numa.h"

View file

@ -18,7 +18,7 @@
#include "hw/irq.h" #include "hw/irq.h"
#include "hw/hw.h" #include "hw/hw.h"
#include "hw/i386/apic-msidef.h" #include "hw/i386/apic-msidef.h"
#include "hw/xen/xen_common.h" #include "hw/xen/xen_native.h"
#include "hw/xen/xen-legacy-backend.h" #include "hw/xen/xen-legacy-backend.h"
#include "hw/xen/xen-bus.h" #include "hw/xen/xen-bus.h"
#include "hw/xen/xen-x86.h" #include "hw/xen/xen-x86.h"
@ -52,10 +52,11 @@ static bool xen_in_migration;
/* Compatibility with older version */ /* Compatibility with older version */
/* This allows QEMU to build on a system that has Xen 4.5 or earlier /*
* installed. This here (not in hw/xen/xen_common.h) because xen/hvm/ioreq.h * This allows QEMU to build on a system that has Xen 4.5 or earlier installed.
* needs to be included before this block and hw/xen/xen_common.h needs to * This is here (not in hw/xen/xen_native.h) because xen/hvm/ioreq.h needs to
* be included before xen/hvm/ioreq.h * be included before this block and hw/xen/xen_native.h needs to be included
* before xen/hvm/ioreq.h
*/ */
#ifndef IOREQ_TYPE_VMWARE_PORT #ifndef IOREQ_TYPE_VMWARE_PORT
#define IOREQ_TYPE_VMWARE_PORT 3 #define IOREQ_TYPE_VMWARE_PORT 3

View file

@ -14,7 +14,7 @@
#include <sys/resource.h> #include <sys/resource.h>
#include "hw/xen/xen-legacy-backend.h" #include "hw/xen/xen_native.h"
#include "qemu/bitmap.h" #include "qemu/bitmap.h"
#include "sysemu/runstate.h" #include "sysemu/runstate.h"

View file

@ -28,7 +28,6 @@
#include "hw/ide/pci.h" #include "hw/ide/pci.h"
#include "hw/pci/pci.h" #include "hw/pci/pci.h"
#include "migration/vmstate.h" #include "migration/vmstate.h"
#include "hw/xen/xen.h"
#include "net/net.h" #include "net/net.h"
#include "trace.h" #include "trace.h"
#include "sysemu/xen.h" #include "sysemu/xen.h"
@ -38,10 +37,12 @@
#include "qom/object.h" #include "qom/object.h"
#ifdef CONFIG_XEN #ifdef CONFIG_XEN
#include "hw/xen/xen_common.h" #include "hw/xen/xen_native.h"
#include "hw/xen/xen-legacy-backend.h"
#endif #endif
/* The rule is that xen_native.h must come first */
#include "hw/xen/xen.h"
//#define DEBUG_PLATFORM //#define DEBUG_PLATFORM
#ifdef DEBUG_PLATFORM #ifdef DEBUG_PLATFORM

View file

@ -1,6 +1,6 @@
# See docs/devel/tracing.rst for syntax documentation. # See docs/devel/tracing.rst for syntax documentation.
# ../../include/hw/xen/xen_common.h # ../../include/hw/xen/xen_native.h
xen_default_ioreq_server(void) "" xen_default_ioreq_server(void) ""
xen_ioreq_server_create(uint32_t id) "id: %u" xen_ioreq_server_create(uint32_t id) "id: %u"
xen_ioreq_server_destroy(uint32_t id) "id: %u" xen_ioreq_server_destroy(uint32_t id) "id: %u"

View file

@ -13,8 +13,8 @@
#include "qemu/uuid.h" #include "qemu/uuid.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "hw/xen/xen_native.h"
#include "hw/xen/xen_backend_ops.h" #include "hw/xen/xen_backend_ops.h"
#include "hw/xen/xen_common.h"
/* /*
* If we have new enough libxenctrl then we do not want/need these compat * If we have new enough libxenctrl then we do not want/need these compat

View file

@ -60,9 +60,9 @@
#include "hw/pci/pci_bus.h" #include "hw/pci/pci_bus.h"
#include "hw/qdev-properties.h" #include "hw/qdev-properties.h"
#include "hw/qdev-properties-system.h" #include "hw/qdev-properties-system.h"
#include "xen_pt.h"
#include "hw/xen/xen.h" #include "hw/xen/xen.h"
#include "hw/xen/xen-legacy-backend.h" #include "hw/xen/xen-legacy-backend.h"
#include "xen_pt.h"
#include "qemu/range.h" #include "qemu/range.h"
static bool has_igd_gfx_passthru; static bool has_igd_gfx_passthru;

View file

@ -1,7 +1,7 @@
#ifndef XEN_PT_H #ifndef XEN_PT_H
#define XEN_PT_H #define XEN_PT_H
#include "hw/xen/xen_common.h" #include "hw/xen/xen_native.h"
#include "xen-host-pci-device.h" #include "xen-host-pci-device.h"
#include "qom/object.h" #include "qom/object.h"

View file

@ -15,8 +15,8 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qemu/timer.h" #include "qemu/timer.h"
#include "hw/xen/xen-legacy-backend.h"
#include "xen_pt.h" #include "xen_pt.h"
#include "hw/xen/xen-legacy-backend.h"
#define XEN_PT_MERGE_VALUE(value, data, val_mask) \ #define XEN_PT_MERGE_VALUE(value, data, val_mask) \
(((value) & (val_mask)) | ((data) & ~(val_mask))) (((value) & (val_mask)) | ((data) & ~(val_mask)))

View file

@ -11,9 +11,9 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "hw/xen/xen-legacy-backend.h"
#include "xen_pt.h"
#include "hw/i386/apic-msidef.h" #include "hw/i386/apic-msidef.h"
#include "xen_pt.h"
#include "hw/xen/xen-legacy-backend.h"
#define XEN_PT_AUTO_ASSIGN -1 #define XEN_PT_AUTO_ASSIGN -1

View file

@ -8,15 +8,21 @@
#define QEMU_HW_XEN_H #define QEMU_HW_XEN_H
/* /*
* As a temporary measure while the headers are being untangled, define * C files using Xen toolstack libraries will have included those headers
* __XEN_TOOLS__ here before any Xen headers are included. Otherwise, if * already via xen_native.h, and having __XEM_TOOLS__ defined will have
* the Xen toolstack library headers are later included, they will find * automatically set __XEN_INTERFACE_VERSION__ to the latest supported
* some of the "internal" definitions missing and the build will fail. In * by the *system* Xen headers which were transitively included.
* later commits, we'll end up with a rule that the native libraries have *
* to be included first, which will ensure that the libraries get the * C files which are part of the internal emulation, and which did not
* version of Xen libraries that they expect. * include xen_native.h, may need this defined so that the Xen headers
* imported to include/hw/xen/interface/ will expose the appropriate API
* version.
*
* This is why there's a rule that xen_native.h must be included first.
*/ */
#define __XEN_TOOLS__ 1 #ifndef __XEN_INTERFACE_VERSION__
#define __XEN_INTERFACE_VERSION__ 0x00040e00
#endif
#include "exec/cpu-common.h" #include "exec/cpu-common.h"

View file

@ -1,5 +1,9 @@
#ifndef QEMU_HW_XEN_COMMON_H #ifndef QEMU_HW_XEN_NATIVE_H
#define QEMU_HW_XEN_COMMON_H #define QEMU_HW_XEN_NATIVE_H
#ifdef __XEN_INTERFACE_VERSION__
#error In Xen native files, include xen_native.h before other Xen headers
#endif
/* /*
* If we have new enough libxenctrl then we do not want/need these compat * If we have new enough libxenctrl then we do not want/need these compat
@ -622,4 +626,4 @@ static inline int xen_set_ioreq_server_state(domid_t dom,
#endif #endif
#endif /* QEMU_HW_XEN_COMMON_H */ #endif /* QEMU_HW_XEN_NATIVE_H */

View file

@ -1,8 +1,9 @@
#ifndef QEMU_HW_XEN_PVDEV_H #ifndef QEMU_HW_XEN_PVDEV_H
#define QEMU_HW_XEN_PVDEV_H #define QEMU_HW_XEN_PVDEV_H
#include "hw/qdev-core.h"
#include "hw/xen/xen_backend_ops.h" #include "hw/xen/xen_backend_ops.h"
#include "hw/xen/xen_common.h"
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
#define XEN_BUFSIZE 1024 #define XEN_BUFSIZE 1024