All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
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>,
	Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH V9 03/16] xen: Add a generic layer for xc calls
Date: Wed, 26 Jan 2011 16:49:45 -0600	[thread overview]
Message-ID: <4D40A509.7000909@codemonkey.ws> (raw)
In-Reply-To: <1295965760-31508-4-git-send-email-anthony.perard@citrix.com>

On 01/25/2011 08:29 AM, anthony.perard@citrix.com wrote:
> From: Alexander Graf<agraf@suse.de>
>
> This patch adds a generic layer for xc calls, allowing us to choose between the
> xenner and xen implementations at runtime.
>
> Signed-off-by: Alexander Graf<agraf@suse.de>
> Signed-off-by: Anthony PERARD<anthony.perard@citrix.com>
> ---
>   hw/xen_interfaces.c |  100 +++++++++++++++++++++++++++++++++++++++++++++++++
>   hw/xen_interfaces.h |  104 +++++++++++++++++++++++++++++++++++++++++++++++++++
>   hw/xen_redirect.h   |   56 +++++++++++++++++++++++++++
>   3 files changed, 260 insertions(+), 0 deletions(-)
>   create mode 100644 hw/xen_interfaces.c
>   create mode 100644 hw/xen_interfaces.h
>   create mode 100644 hw/xen_redirect.h
>
> diff --git a/hw/xen_interfaces.c b/hw/xen_interfaces.c
> new file mode 100644
> index 0000000..09f40e0
> --- /dev/null
> +++ b/hw/xen_interfaces.c
> @@ -0,0 +1,100 @@
>    

Needs a copyright.

> +#include<xenctrl.h>
> +#include<xs.h>
> +
> +#include "hw.h"
> +#include "xen.h"
> +#include "xen_interfaces.h"
> +
> +#ifdef CONFIG_XEN
> +
> +static int xc_evtchn_domid(int handle, int domid)
> +{
> +    return -1;
> +}
> +
> +static struct XenEvtOps xc_evtchn_xen = {
> +    .open               = xc_evtchn_open,
> +    .domid              = xc_evtchn_domid,
> +    .close              = xc_evtchn_close,
> +    .fd                 = xc_evtchn_fd,
> +    .notify             = xc_evtchn_notify,
> +    .bind_unbound_port  = xc_evtchn_bind_unbound_port,
> +    .bind_interdomain   = xc_evtchn_bind_interdomain,
> +    .bind_virq          = xc_evtchn_bind_virq,
> +    .unbind             = xc_evtchn_unbind,
> +    .pending            = xc_evtchn_pending,
> +    .unmask             = xc_evtchn_unmask,
> +};
> +
> +static int xs_domid(struct xs_handle *h, int domid)
> +{
> +    return -1;
> +}
> +
> +static struct XenStoreOps xs_xen = {
> +    .daemon_open           = xs_daemon_open,
> +    .domain_open           = xs_domain_open,
> +    .daemon_open_readonly  = xs_daemon_open_readonly,
> +    .domid                 = xs_domid,
> +    .daemon_close          = xs_daemon_close,
> +    .directory             = xs_directory,
> +    .read                  = xs_read,
> +    .write                 = xs_write,
> +    .mkdir                 = xs_mkdir,
> +    .rm                    = xs_rm,
> +    .get_permissions       = xs_get_permissions,
> +    .set_permissions       = xs_set_permissions,
> +    .watch                 = xs_watch,
> +    .fileno                = xs_fileno,
> +    .read_watch            = xs_read_watch,
> +    .unwatch               = xs_unwatch,
> +    .transaction_start     = xs_transaction_start,
> +    .transaction_end       = xs_transaction_end,
> +    .introduce_domain      = xs_introduce_domain,
> +    .resume_domain         = xs_resume_domain,
> +    .release_domain        = xs_release_domain,
> +    .get_domain_path       = xs_get_domain_path,
> +    .is_domain_introduced  = xs_is_domain_introduced,
> +};
> +
> +static struct XenGnttabOps xc_gnttab_xen = {
> +    .open            = xc_gnttab_open,
> +    .close           = xc_gnttab_close,
> +    .map_grant_ref   = xc_gnttab_map_grant_ref,
> +    .map_grant_refs  = xc_gnttab_map_grant_refs,
> +    .munmap          = xc_gnttab_munmap,
> +};
> +
> +struct XenIfOps xc_xen = {
> +    .interface_open                 = xc_interface_open,
> +    .interface_close                = xc_interface_close,
> +    .map_foreign_range              = xc_map_foreign_range,
> +    .map_foreign_pages              = xc_map_foreign_pages,
> +    .map_foreign_bulk               = xc_map_foreign_bulk,
> +};
> +
> +#endif
> +
> +struct XenEvtOps xc_evtchn;
> +struct XenGnttabOps xc_gnttab;
> +struct XenIfOps xc;
> +struct XenStoreOps xs;
> +
> +void xen_interfaces_init(void)
> +{
> +    switch (xen_mode) {
> +#ifdef CONFIG_XEN
> +    case XEN_ATTACH:
> +    case XEN_CREATE:
> +        xc_evtchn = xc_evtchn_xen;
> +        xc_gnttab = xc_gnttab_xen;
> +        xc        = xc_xen;
> +        xs        = xs_xen;
> +        break;
> +#endif
> +    default:
> +        fprintf(stderr, "ERROR: Compiled without %s support, sorry.\n",
> +                xen_mode == XEN_EMULATE ? "xenner" : "Xen");
> +        exit(1);
> +    }
> +}
> diff --git a/hw/xen_interfaces.h b/hw/xen_interfaces.h
> new file mode 100644
> index 0000000..1086850
> --- /dev/null
> +++ b/hw/xen_interfaces.h
> @@ -0,0 +1,104 @@
> +#ifndef QEMU_HW_XEN_INTERFACES_H
> +#define QEMU_HW_XEN_INTERFACES_H 1
> +
> +#include<xenctrl.h>
> +#include<xs.h>
> +
> +/* ------------------------------------------------------------- */
> +/* xen event channel interface                                   */
> +
> +struct XenEvtOps {
> +    int (*open)(void);
> +    int (*domid)(int xce_handle, int domid);
> +    int (*close)(int xce_handle);
> +    int (*fd)(int xce_handle);
> +    int (*notify)(int xce_handle, evtchn_port_t port);
> +    evtchn_port_or_error_t (*bind_unbound_port)(int xce_handle, int domid);
> +    evtchn_port_or_error_t (*bind_interdomain)(int xce_handle, int domid,
> +                                               evtchn_port_t remote_port);
> +    evtchn_port_or_error_t (*bind_virq)(int xce_handle, unsigned int virq);
> +    int (*unbind)(int xce_handle, evtchn_port_t port);
> +    evtchn_port_or_error_t (*pending)(int xce_handle);
> +    int (*unmask)(int xce_handle, evtchn_port_t port);
> +};
> +extern struct XenEvtOps xc_evtchn;
>    

typedef away the struct please.

> +/* ------------------------------------------------------------- */
> +/* xenstore interface                                            */
> +
> +struct xs_handle;
> +struct XenStoreOps {
> +    struct xs_handle *(*daemon_open)(void);
> +    struct xs_handle *(*domain_open)(void);
> +    struct xs_handle *(*daemon_open_readonly)(void);
> +    int (*domid)(struct xs_handle *h, int domid);
> +    void (*daemon_close)(struct xs_handle *);
> +    char **(*directory)(struct xs_handle *h, xs_transaction_t t,
> +                        const char *path, unsigned int *num);
> +    void *(*read)(struct xs_handle *h, xs_transaction_t t,
> +                  const char *path, unsigned int *len);
> +    bool (*write)(struct xs_handle *h, xs_transaction_t t,
> +                  const char *path, const void *data, unsigned int len);
> +    bool (*mkdir)(struct xs_handle *h, xs_transaction_t t,
> +                  const char *path);
> +    bool (*rm)(struct xs_handle *h, xs_transaction_t t,
> +               const char *path);
> +    struct xs_permissions *(*get_permissions)(struct xs_handle *h,
> +                                              xs_transaction_t t,
> +                                              const char *path, unsigned int *num);
> +    bool (*set_permissions)(struct xs_handle *h, xs_transaction_t t,
> +                            const char *path, struct xs_permissions *perms,
> +                            unsigned int num_perms);
> +    bool (*watch)(struct xs_handle *h, const char *path, const char *token);
> +    int (*fileno)(struct xs_handle *h);
> +    char **(*read_watch)(struct xs_handle *h, unsigned int *num);
> +    bool (*unwatch)(struct xs_handle *h, const char *path, const char *token);
> +    xs_transaction_t (*transaction_start)(struct xs_handle *h);
> +    bool (*transaction_end)(struct xs_handle *h, xs_transaction_t t,
> +                            bool abort);
> +    bool (*introduce_domain)(struct xs_handle *h,
> +                             unsigned int domid,
> +                             unsigned long mfn,
> +                             unsigned int eventchn);
> +    bool (*resume_domain)(struct xs_handle *h, unsigned int domid);
> +    bool (*release_domain)(struct xs_handle *h, unsigned int domid);
> +    char *(*get_domain_path)(struct xs_handle *h, unsigned int domid);
> +    bool (*is_domain_introduced)(struct xs_handle *h, unsigned int domid);
> +};
> +extern struct XenStoreOps xs;
> +
> +/* ------------------------------------------------------------- */
> +/* xen grant table interface                                     */
> +
> +struct XenGnttabOps {
> +    int (*open)(void);
> +    int (*close)(int xcg_handle);
> +    void *(*map_grant_ref)(int xcg_handle, uint32_t domid,
> +                          uint32_t ref, int prot);
> +    void *(*map_grant_refs)(int xcg_handle, uint32_t count,
> +                            uint32_t *domids, uint32_t *refs, int prot);
> +    int (*munmap)(int xcg_handle, void *start_address, uint32_t count);
> +};
> +extern struct XenGnttabOps xc_gnttab;
> +
> +/* ------------------------------------------------------------- */
> +/* xen hypercall interface                                       */
> +
> +struct XenIfOps {
> +    int (*interface_open)(void);
> +    int (*interface_close)(int xc_handle);
> +    void *(*map_foreign_range)(int xc_handle, uint32_t dom,
> +                               int size, int prot,
> +                               unsigned long mfn);
> +    void *(*map_foreign_pages)(int xc_handle, uint32_t dom, int prot,
> +                               const xen_pfn_t *arr, int num);
> +    void *(*map_foreign_bulk)(int xc_handle, uint32_t dom, int prot,
> +                              xen_pfn_t *arr, int num);
> +};
> +extern struct XenIfOps xc;
> +
> +/* ------------------------------------------------------------- */
> +
> +void xen_interfaces_init(void);
> +
> +#endif /* QEMU_HW_XEN_INTERFACES_H */
> diff --git a/hw/xen_redirect.h b/hw/xen_redirect.h
> new file mode 100644
> index 0000000..6ddecf3
> --- /dev/null
> +++ b/hw/xen_redirect.h
> @@ -0,0 +1,56 @@
> +#ifndef QEMU_HW_XEN_REDIRECT_H
> +#define QEMU_HW_XEN_REDIRECT_H 1
> +
> +#include "xen_interfaces.h"
> +
> +/* xen event channel interface */
> +#define xc_evtchn_open              xc_evtchn.open
> +#define xc_evtchn_close             xc_evtchn.close
> +#define xc_evtchn_fd                xc_evtchn.fd
> +#define xc_evtchn_notify            xc_evtchn.notify
> +#define xc_evtchn_bind_unbound_port xc_evtchn.bind_unbound_port
> +#define xc_evtchn_bind_interdomain  xc_evtchn.bind_interdomain
> +#define xc_evtchn_bind_virq         xc_evtchn.bind_virq
> +#define xc_evtchn_unbind            xc_evtchn.unbind
> +#define xc_evtchn_pending           xc_evtchn.pending
> +#define xc_evtchn_unmask            xc_evtchn.unmask
> +
> +/* grant table interface */
> +#define xc_gnttab_open              xc_gnttab.open
> +#define xc_gnttab_close             xc_gnttab.close
> +#define xc_gnttab_map_grant_ref     xc_gnttab.map_grant_ref
> +#define xc_gnttab_map_grant_refs    xc_gnttab.map_grant_refs
> +#define xc_gnttab_munmap            xc_gnttab.munmap
> +
> +/* xen hypercall interface */
> +#define xc_interface_open           xc.interface_open
> +#define xc_interface_close          xc.interface_close
> +#define xc_map_foreign_range        xc.map_foreign_range
> +#define xc_map_foreign_pages        xc.map_foreign_pages
> +#define xc_map_foreign_bulk         xc.map_foreign_bulk
> +
> +/* xenstore interface */
> +#define xs_daemon_open              xs.daemon_open
> +#define xs_domain_open              xs.domain_open
> +#define xs_daemon_open_readonly     xs.daemon_open_readonly
> +#define xs_daemon_close             xs.daemon_close
> +#define xs_directory                xs.directory
> +#define xs_read                     xs.read
> +#define xs_write                    xs.write
> +#define xs_mkdir                    xs.mkdir
> +#define xs_rm                       xs.rm
> +#define xs_get_permissions          xs.get_permissions
> +#define xs_set_permissions          xs.set_permissions
> +#define xs_watch                    xs.watch
> +#define xs_fileno                   xs.fileno
> +#define xs_read_watch               xs.read_watch
> +#define xs_unwatch                  xs.unwatch
> +#define xs_transaction_start        xs.transaction_start
> +#define xs_transaction_end          xs.transaction_end
> +#define xs_introduce_domain         xs.introduce_domain
> +#define xs_resume_domain            xs.resume_domain
> +#define xs_release_domain           xs.release_domain
> +#define xs_get_domain_path          xs.get_domain_path
> +#define xs_is_domain_introduced     xs.is_domain_introduced
>    

static inline please.

Regards,

Anthony Liguori

> +#endif /* QEMU_HW_XEN_REDIRECT_H */
>    

  reply	other threads:[~2011-01-26 22:51 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25 14:29 [Qemu-devel] [PATCH V9 00/16] Xen device model support anthony.perard
2011-01-25 14:29 ` anthony.perard
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 01/16] xen: Replace some tab-indents with spaces (clean-up) anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 02/16] xen: Make xen build only on x86 target anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 03/16] xen: Add a generic layer for xc calls anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26 22:49   ` Anthony Liguori [this message]
2011-01-28 15:09     ` [Xen-devel] Re: [Qemu-devel] " Anthony PERARD
2011-01-28 15:09       ` Anthony PERARD
2011-01-28 15:12       ` [Xen-devel] " Alexander Graf
2011-01-28 15:12         ` Alexander Graf
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 04/16] xen: Support new libxc calls from xen unstable anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26 22:53   ` [Qemu-devel] " Anthony Liguori
2011-01-27 12:03     ` Stefano Stabellini
2011-01-27 12:03       ` Stefano Stabellini
2011-01-27 12:16       ` [Xen-devel] " Keir Fraser
2011-01-27 12:16         ` Keir Fraser
2011-01-27 12:21         ` [Xen-devel] " Stefano Stabellini
2011-01-27 12:21           ` Stefano Stabellini
2011-01-27 17:24     ` Anthony PERARD
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 05/16] xen: Add xen_machine_fv anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26 22:56   ` [Qemu-devel] " Anthony Liguori
2011-01-27 12:04     ` Stefano Stabellini
2011-01-27 12:04       ` Stefano Stabellini
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 06/16] xen: Add initialisation of Xen anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26 22:57   ` [Qemu-devel] " Anthony Liguori
2011-01-26 22:57     ` Anthony Liguori
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 07/16] xen: Add the Xen platform pci device anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26 23:01   ` [Qemu-devel] " Anthony Liguori
2011-01-26 23:01     ` Anthony Liguori
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 08/16] piix_pci: Introduces Xen specific call for irq anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 09/16] xen: add a 8259 Interrupt Controller anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26 23:04   ` [Qemu-devel] " Anthony Liguori
2011-01-26 23:04     ` Anthony Liguori
2011-01-27 17:19     ` [Qemu-devel] " Anthony PERARD
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 10/16] xen: Introduce the Xen mapcache anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26 23:07   ` [Qemu-devel] " Anthony Liguori
2011-01-27 12:04     ` Stefano Stabellini
2011-01-27 12:04       ` Stefano Stabellini
2011-01-31 16:30     ` Stefano Stabellini
2011-01-31 16:30       ` Stefano Stabellini
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 11/16] configure: Always use 64bits target physical addresses with xen enabled anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 12/16] Introduce qemu_ram_ptr_unlock anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26 23:10   ` [Qemu-devel] " Anthony Liguori
2011-01-26 23:10     ` Anthony Liguori
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 13/16] vl.c: Introduce getter for shutdown_requested and reset_requested anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 14/16] xen: Initialize event channels and io rings anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 15/16] xen: Set running state in xenstore anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26 23:12   ` [Qemu-devel] " Anthony Liguori
2011-01-25 14:29 ` [Qemu-devel] [PATCH V9 16/16] acpi-piix4: Add Xen hypercall for sleep state anthony.perard
2011-01-25 14:29   ` anthony.perard
2011-01-26  2:49   ` [Qemu-devel] " Isaku Yamahata
2011-01-26 13:47     ` Anthony PERARD
2011-01-26 14:36     ` [Qemu-devel] Re: [PATCH V9 16/16] xen: Add Xen hypercall for sleep state in the cmos_s3 callback anthony.perard
2011-01-26 14:36       ` anthony.perard
2011-01-26 23:14       ` [Qemu-devel] " Anthony Liguori
2011-01-26 23:11   ` [Qemu-devel] [PATCH V9 16/16] acpi-piix4: Add Xen hypercall for sleep state Anthony Liguori
2011-01-26 23:11     ` Anthony Liguori
2011-01-25 14:41 ` [Qemu-devel] Re: [PATCH V9 00/16] Xen device model support Anthony PERARD
2011-01-25 14:41   ` Anthony PERARD

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=4D40A509.7000909@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.