From: Alexander Graf <agraf@suse.de>
To: Anthony.Perard@citrix.com
Cc: Xen Devel <xen-devel@lists.xensource.com>,
QEMU-devel <qemu-devel@nongnu.org>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [Qemu-devel] [PATCH V6 02/15] xen: Support new libxc calls from xen unstable.
Date: Mon, 15 Nov 2010 11:25:58 +0100 [thread overview]
Message-ID: <B23F6815-FDC5-4756-856C-ABC07ADE9D6A@suse.de> (raw)
In-Reply-To: <1287682587-18642-3-git-send-email-anthony.perard@citrix.com>
On 21.10.2010, at 19:36, Anthony.Perard@citrix.com wrote:
> From: Anthony PERARD <anthony.perard@citrix.com>
>
> Update the libxenctrl calls in Qemu to use the new interface, otherwise
> Qemu wouldn't be able to build against new versions of the library.
>
> We also check libxenctrl version in configure, from Xen 3.3.0 to Xen
> unstable.
>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
> configure | 67 ++++++++++++++++++++++++++++++++++++++++++++++++-
> hw/xen_backend.c | 10 +++---
> hw/xen_backend.h | 2 +-
> hw/xen_common.h | 38 +++++++++++++++++-----------
> hw/xen_disk.c | 12 ++++----
> hw/xen_domainbuild.c | 2 +-
> hw/xen_nic.c | 16 ++++++------
> 7 files changed, 109 insertions(+), 38 deletions(-)
>
> diff --git a/configure b/configure
> index 9ed05de..f6a7073 100755
> --- a/configure
> +++ b/configure
> @@ -284,6 +284,7 @@ vnc_jpeg=""
> vnc_png=""
> vnc_thread="no"
> xen=""
> +xen_ctrl_version=""
> linux_aio=""
> attr=""
> vhost_net=""
> @@ -1135,20 +1136,81 @@ fi
>
> if test "$xen" != "no" ; then
> xen_libs="-lxenstore -lxenctrl -lxenguest"
> +
> + # Xen unstable
> cat > $TMPC <<EOF
> #include <xenctrl.h>
> #include <xs.h>
> -int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
> +#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_interface_open(0, 0, 0);
> + xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
> + xc_gnttab_open(xc);
> + return 0;
> +}
> EOF
> if compile_prog "" "$xen_libs" ; then
> + xen_ctrl_version=410
> xen=yes
> - libs_softmmu="$xen_libs $libs_softmmu"
> +
> + # Xen 4.0.0
> + 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) {
> + xs_daemon_open();
> + xc_interface_open();
> + xc_gnttab_open();
> + xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
> + return 0;
> +}
> +EOF
> + compile_prog "" "$xen_libs"
> + ) ; then
> + xen_ctrl_version=400
> + xen=yes
> +
> + # Xen 3.3.0, 3.4.0
> + elif (
> + cat > $TMPC <<EOF
> +#include <xenctrl.h>
> +#include <xs.h>
> +int main(void) {
> + xs_daemon_open();
> + xc_interface_open();
> + xc_gnttab_open();
> + xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
> + return 0;
> +}
> +EOF
> + compile_prog "" "$xen_libs"
> + ) ; then
> + xen_ctrl_version=330
> + xen=yes
> +
> + # Xen not found or unsupported
> else
> if test "$xen" = "yes" ; then
> feature_not_found "xen"
> fi
> xen=no
> fi
> +
> + if test "$xen" = "yes"; then
> + libs_softmmu="$xen_libs $libs_softmmu"
> + fi
> fi
>
> ##########################################
> @@ -2546,6 +2608,7 @@ if test "$bluez" = "yes" ; then
> fi
> if test "$xen" = "yes" ; then
> echo "CONFIG_XEN=y" >> $config_host_mak
> + echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
> fi
> if test "$io_thread" = "yes" ; then
> echo "CONFIG_IOTHREAD=y" >> $config_host_mak
> diff --git a/hw/xen_backend.c b/hw/xen_backend.c
> index 860b038..3e99751 100644
> --- a/hw/xen_backend.c
> +++ b/hw/xen_backend.c
> @@ -43,7 +43,7 @@
> /* ------------------------------------------------------------- */
>
> /* public */
> -int xen_xc;
> +qemu_xc_interface xen_xc = XC_HANDLER_INITIAL_VALUE;
> struct xs_handle *xenstore = NULL;
> const char *xen_protocol;
>
> @@ -216,7 +216,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
> fcntl(xc_evtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);
>
> if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {
> - xendev->gnttabdev = xc_gnttab_open();
> + xendev->gnttabdev = xc_gnttab_open(xen_xc);
> if (xendev->gnttabdev < 0) {
> xen_be_printf(NULL, 0, "can't open gnttab device\n");
> xc_evtchn_close(xendev->evtchndev);
> @@ -269,7 +269,7 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev)
> if (xendev->evtchndev >= 0)
> xc_evtchn_close(xendev->evtchndev);
> if (xendev->gnttabdev >= 0)
> - xc_gnttab_close(xendev->gnttabdev);
> + xc_gnttab_close(xen_xc, xendev->gnttabdev);
>
> QTAILQ_REMOVE(&xendevs, xendev, next);
> qemu_free(xendev);
> @@ -627,8 +627,8 @@ int xen_be_init(void)
> if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL) < 0)
> goto err;
>
> - xen_xc = xc_interface_open();
> - if (xen_xc == -1) {
> + xen_xc = xc_interface_open(NULL, NULL, 0);
> + if (xen_xc == XC_HANDLER_INITIAL_VALUE) {
> xen_be_printf(NULL, 0, "can't open xen interface\n");
> goto err;
> }
> diff --git a/hw/xen_backend.h b/hw/xen_backend.h
> index 1b428e3..7d84098 100644
> --- a/hw/xen_backend.h
> +++ b/hw/xen_backend.h
> @@ -55,7 +55,7 @@ struct XenDevice {
> /* ------------------------------------------------------------- */
>
> /* variables */
> -extern int xen_xc;
> +extern qemu_xc_interface xen_xc;
> extern struct xs_handle *xenstore;
> extern const char *xen_protocol;
>
> diff --git a/hw/xen_common.h b/hw/xen_common.h
> index 8a55b44..9f75e52 100644
> --- a/hw/xen_common.h
> +++ b/hw/xen_common.h
> @@ -1,6 +1,8 @@
> #ifndef QEMU_HW_XEN_COMMON_H
> #define QEMU_HW_XEN_COMMON_H 1
>
> +#include "config-host.h"
> +
> #include <stddef.h>
> #include <inttypes.h>
>
> @@ -13,22 +15,28 @@
> #include "qemu-queue.h"
>
> /*
> - * tweaks needed to build with different xen versions
> - * 0x00030205 -> 3.1.0
> - * 0x00030207 -> 3.2.0
> - * 0x00030208 -> unstable
> + * We don't support Xen prior to 3.3.0.
> */
> -#include <xen/xen-compat.h>
> -#if __XEN_LATEST_INTERFACE_VERSION__ < 0x00030205
> -# define evtchn_port_or_error_t int
> -#endif
> -#if __XEN_LATEST_INTERFACE_VERSION__ < 0x00030207
> -# define xc_map_foreign_pages xc_map_foreign_batch
> -#endif
> -#if __XEN_LATEST_INTERFACE_VERSION__ < 0x00030208
> -# define xen_mb() mb()
> -# define xen_rmb() rmb()
> -# define xen_wmb() wmb()
> +
> +/* Xen unstable */
> +#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 410
> +typedef int qemu_xc_interface;
> +# define XC_HANDLER_INITIAL_VALUE -1
> +# define xc_fd(xen_xc) xen_xc
> +# define xc_interface_open(l, dl, f) xc_interface_open()
> +# define xc_gnttab_open(xc) xc_gnttab_open()
> +# define xc_gnttab_map_grant_ref(xc, gnt, domid, ref, flags) \
> + xc_gnttab_map_grant_ref(gnt, domid, ref, flags)
> +# define xc_gnttab_map_grant_refs(xc, gnt, count, domids, refs, flags) \
> + xc_gnttab_map_grant_refs(gnt, count, domids, refs, flags)
> +# define xc_gnttab_munmap(xc, gnt, pages, niov) xc_gnttab_munmap(gnt, pages, niov)
> +# define xc_gnttab_close(xc, dev) xc_gnttab_close(dev)
All these defines are very icky. In my patchset I replace all those libxc calls by indirect calls through a struct anyways. Maybe it'd make sense to integrate that part into your series already.
That way you could make this whole compat stuff a lot cleaner. You could use static inline functions to create wrappers to the real calls and just assign those as callbacks in the dispatch struct.
In general, I'd disagree to the preprocessor approach here. If you're not going with the libxc dispatch struct patch, I'd at least like to see all those converted to static inline functions called with different names internally.
Alex
next prev parent reply other threads:[~2010-11-15 10:26 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-21 17:36 [Qemu-devel] [PATCH V6 00/15] xen device model support anthony.perard
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 01/15] xen: Replace some tab-indents with spaces (clean-up) anthony.perard
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 02/15] xen: Support new libxc calls from xen unstable anthony.perard
2010-11-15 10:25 ` Alexander Graf [this message]
2010-11-15 13:57 ` Stefano Stabellini
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 03/15] xen: Add xen_machine_fv anthony.perard
2010-11-15 10:35 ` Alexander Graf
2010-11-15 11:00 ` Kevin Wolf
2010-11-15 13:57 ` Stefano Stabellini
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 04/15] Introduce -accel command option anthony.perard
2010-11-15 10:38 ` Alexander Graf
2010-11-15 10:46 ` Alexander Graf
2010-11-15 12:56 ` Paolo Bonzini
2010-11-15 14:27 ` Anthony PERARD
2010-11-15 14:47 ` Anthony PERARD
2010-11-15 14:51 ` Alexander Graf
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 05/15] xen: Add xen in -accel option anthony.perard
2010-11-15 10:49 ` Alexander Graf
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 06/15] xen: Add the Xen platform pci device anthony.perard
2010-11-15 10:57 ` Alexander Graf
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 07/15] piix_pci: Introduces Xen specific call for irq anthony.perard
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 08/15] xen: add a 8259 Interrupt Controller anthony.perard
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 09/15] xen: Introduce the Xen mapcache anthony.perard
2010-11-15 11:43 ` Alexander Graf
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 10/15] configure: Always use 64bits target physical addresses with xen enabled anthony.perard
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 11/15] Introduce qemu_ram_ptr_unlock anthony.perard
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 12/15] vl.c: Introduce getter for shutdown_requested and reset_requested anthony.perard
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 13/15] xen: Initialize event channels and io rings anthony.perard
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 14/15] xen: Set running state in xenstore anthony.perard
2010-10-21 17:36 ` [Qemu-devel] [PATCH V6 15/15] acpi-piix4: Add Xen hypercall for sleep state anthony.perard
2010-10-26 14:24 ` [Qemu-devel] Re: [PATCH V6 00/15] xen device model support Anthony PERARD
2010-10-26 19:29 ` Blue Swirl
2010-10-26 20:00 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B23F6815-FDC5-4756-856C-ABC07ADE9D6A@suse.de \
--to=agraf@suse.de \
--cc=Anthony.Perard@citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).