Stefano Stabellini
2012-Apr-17 18:12 UTC
[PATCH BUILD FIX 0/2] build xc_hvm_inject_msi on Xen < 4.2
Hi all, this small patch series fixes the build breakage introduced by f1dbf015dfb0aa7f66f710a1f1bc58b662951de2 with Xen < 4.2. The problem is that xc_hvm_inject_msi is only defined from Xen 4.2 onwards so we need to provide a compatibility function for older Xen versions. Stefano Stabellini (2): xen,configure: detect Xen 4.2 xen: add a dummy xc_hvm_inject_msi for Xen < 4.2 configure | 25 +++++++++++++++++++++++++ hw/pc.c | 2 +- hw/xen.h | 10 ++++++++++ hw/xen_common.h | 15 +++++++++++++++ xen-all.c | 2 +- 5 files changed, 52 insertions(+), 2 deletions(-) git://xenbits.xen.org/people/sstabellini/qemu-dm.git build_fix Cheers, Stefano
Stefano Stabellini
2012-Apr-17 18:13 UTC
[PATCH BUILD FIX 1/2] xen,configure: detect Xen 4.2
Xen 4.2 is the first to support xc_hvm_inject_msi: use it to determine if we are running on it. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com> --- configure | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/configure b/configure index 1d94acd..38f45f3 100755 --- a/configure +++ b/configure @@ -1398,6 +1398,31 @@ int main(void) { xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); xc_gnttab_open(NULL, 0); xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); + xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); + return 0; +} +EOF + compile_prog "" "$xen_libs" + ) ; then + xen_ctrl_version=420 + xen=yes + + elif ( + cat > $TMPC <<EOF +#include <xenctrl.h> +#include <xs.h> +#include <stdint.h> +#include <xen/hvm/hvm_info_table.h> +#if !defined(HVM_MAX_VCPUS) +# error HVM_MAX_VCPUS not defined +#endif +int main(void) { + xc_interface *xc; + xs_daemon_open(); + xc = xc_interface_open(0, 0, 0); + xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); + xc_gnttab_open(NULL, 0); + xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); return 0; } EOF -- 1.7.2.5
Stefano Stabellini
2012-Apr-17 18:13 UTC
[PATCH BUILD FIX 2/2] xen: add a dummy xc_hvm_inject_msi for Xen < 4.2
xc_hvm_inject_msi is only available on Xen >= 4.2: add a dummy compatibility function for Xen < 4.2. Also enable msi support only on Xen >= 4.2. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com> --- hw/pc.c | 2 +- hw/xen.h | 10 ++++++++++ hw/xen_common.h | 15 +++++++++++++++ xen-all.c | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 1f5aacb..4d34a33 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -916,7 +916,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id) msi_supported = true; } - if (xen_enabled()) { + if (xen_msi_support()) { msi_supported = true; } diff --git a/hw/xen.h b/hw/xen.h index e5926b7..3ae4cd0 100644 --- a/hw/xen.h +++ b/hw/xen.h @@ -57,4 +57,14 @@ void xen_register_framebuffer(struct MemoryRegion *mr); # define HVM_MAX_VCPUS 32 #endif +static inline int xen_msi_support(void) +{ +#if defined(CONFIG_XEN_CTRL_INTERFACE_VERSION) \ + && CONFIG_XEN_CTRL_INTERFACE_VERSION >= 420 + return xen_enabled(); +#else + return 0; +#endif +} + #endif /* QEMU_HW_XEN_H */ diff --git a/hw/xen_common.h b/hw/xen_common.h index 0409ac7..7043c14 100644 --- a/hw/xen_common.h +++ b/hw/xen_common.h @@ -133,6 +133,21 @@ static inline int xc_fd(xc_interface *xen_xc) } #endif +/* Xen before 4.2 */ +#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 420 +static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom, + uint64_t addr, uint32_t data) +{ + return -ENOSYS; +} +#else +static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom, + uint64_t addr, uint32_t data) +{ + return xc_hvm_inject_msi(xen_xc, dom, addr, data); +} +#endif + void destroy_hvm_domain(void); #endif /* QEMU_HW_XEN_COMMON_H */ diff --git a/xen-all.c b/xen-all.c index a08eec0..bdf9c0f 100644 --- a/xen-all.c +++ b/xen-all.c @@ -129,7 +129,7 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) void xen_hvm_inject_msi(uint64_t addr, uint32_t data) { - xc_hvm_inject_msi(xen_xc, xen_domid, addr, data); + xen_xc_hvm_inject_msi(xen_xc, xen_domid, addr, data); } static void xen_suspend_notifier(Notifier *notifier, void *data) -- 1.7.2.5