qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Anthony PERARD <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: [Xen-devel] Re: [Qemu-devel] [PATCH V10 03/15] xen: Support new libxc calls from xen unstable.
Date: Fri, 25 Feb 2011 08:11:11 -0600	[thread overview]
Message-ID: <4D67B87F.4020108@codemonkey.ws> (raw)
In-Reply-To: <AANLkTinwodD_K30UXEUvb-54q7QxUUqLCHHTX9Rtyghx@mail.gmail.com>

On 02/25/2011 08:06 AM, Anthony PERARD wrote:
> On Thu, Feb 24, 2011 at 17:29, Anthony Liguori<anthony@codemonkey.ws>  wrote:
>    
>> On 02/02/2011 08:49 AM, anthony.perard@citrix.com wrote:
>>      
>>> From: Anthony PERARD<anthony.perard@citrix.com>
>>>
>>> This patch adds a generic layer for xc calls, allowing us to choose
>>> between the
>>> xenner and xen implementations at runtime.
>>>
>>> It also 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 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>
>>> Acked-by: Alexander Graf<agraf@suse.de>
>>> ---
>>>   Makefile.target      |    3 +
>>>   configure            |   62 +++++++++++++++-
>>>   hw/xen_backend.c     |   74 ++++++++++---------
>>>   hw/xen_backend.h     |    7 +-
>>>   hw/xen_common.h      |   38 ++++++----
>>>   hw/xen_console.c     |   10 +-
>>>   hw/xen_devconfig.c   |   10 +-
>>>   hw/xen_disk.c        |   28 ++++---
>>>   hw/xen_domainbuild.c |   29 ++++----
>>>   hw/xen_interfaces.c  |  191
>>> ++++++++++++++++++++++++++++++++++++++++++++++++
>>>   hw/xen_interfaces.h  |  198
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++
>>>   hw/xen_nic.c         |   36 +++++-----
>>>   hw/xenfb.c           |   14 ++--
>>>   13 files changed, 584 insertions(+), 116 deletions(-)
>>>   create mode 100644 hw/xen_interfaces.c
>>>   create mode 100644 hw/xen_interfaces.h
>>>
>>> diff --git a/Makefile.target b/Makefile.target
>>> index db29e96..d09719f 100644
>>> --- a/Makefile.target
>>> +++ b/Makefile.target
>>> @@ -205,6 +205,9 @@ QEMU_CFLAGS += $(VNC_SASL_CFLAGS)
>>>   QEMU_CFLAGS += $(VNC_JPEG_CFLAGS)
>>>   QEMU_CFLAGS += $(VNC_PNG_CFLAGS)
>>>
>>> +# xen support
>>> +obj-$(CONFIG_XEN) += xen_interfaces.o
>>> +
>>>   # xen backend driver support
>>>   obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o
>>>   obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o
>>> diff --git a/configure b/configure
>>> index 5a9121d..fde9bad 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -126,6 +126,7 @@ vnc_jpeg=""
>>>   vnc_png=""
>>>   vnc_thread="no"
>>>   xen=""
>>> +xen_ctrl_version=""
>>>   linux_aio=""
>>>   attr=""
>>>   vhost_net=""
>>> @@ -1144,13 +1145,71 @@ 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 = xc_interface_open(0, 0, 0);
>>> +  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
>>> +  xc_gnttab_open(NULL, 0);
>>> +  return 0;
>>> +}
>>>   EOF
>>>     if compile_prog "" "$xen_libs" ; then
>>> +    xen_ctrl_version=410
>>> +    xen=yes
>>> +
>>> +  # 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"
>>> @@ -3009,6 +3068,7 @@ case "$target_arch2" in
>>>       if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
>>>         echo "CONFIG_XEN=y">>    $config_target_mak
>>>         echo "LIBS+=$xen_libs">>    $config_target_mak
>>> +      echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version">>
>>>   $config_target_mak
>>>       fi
>>>   esac
>>>   case "$target_arch2" in
>>> diff --git a/hw/xen_backend.c b/hw/xen_backend.c
>>> index 860b038..cf081e1 100644
>>> --- a/hw/xen_backend.c
>>> +++ b/hw/xen_backend.c
>>> @@ -43,7 +43,8 @@
>>>   /* ------------------------------------------------------------- */
>>>
>>>   /* public */
>>> -int xen_xc;
>>> +XenXC xen_xc = XC_HANDLER_INITIAL_VALUE;
>>> +XenGnttab xen_xcg = XC_HANDLER_INITIAL_VALUE;
>>>   struct xs_handle *xenstore = NULL;
>>>   const char *xen_protocol;
>>>
>>> @@ -58,7 +59,7 @@ int xenstore_write_str(const char *base, const char
>>> *node, const char *val)
>>>       char abspath[XEN_BUFSIZE];
>>>
>>>       snprintf(abspath, sizeof(abspath), "%s/%s", base, node);
>>> -    if (!xs_write(xenstore, 0, abspath, val, strlen(val)))
>>> +    if (!xs_ops.write(xenstore, 0, abspath, val, strlen(val)))
>>>           return -1;
>>>       return 0;
>>>   }
>>> @@ -70,7 +71,7 @@ char *xenstore_read_str(const char *base, const char
>>> *node)
>>>       char *str, *ret = NULL;
>>>
>>>       snprintf(abspath, sizeof(abspath), "%s/%s", base, node);
>>> -    str = xs_read(xenstore, 0, abspath,&len);
>>> +    str = xs_ops.read(xenstore, 0, abspath,&len);
>>>
>>>        
>> I think I gave this feedback before but I'd really like to see static
>> inlines here.
>>
>> It's very likely that you'll either want to have tracing or some commands
>> can have a NULL function pointer in which case having a central location to
>> do this is very useful.
>>
>> Plus, it's more natural to read code that's making a function call instead
>> of going through a function pointer in a structure redirection.
>>
>> Can probably do this with just a sed over the current patch.
>>      
>
> Is it good to have a .h with functions like that? :
>
> static inline XenXC qemu_xc_interface_open(xentoollog_logger *logger,
>                              xentoollog_logger *dombuild_logger,
>                              unsigned open_flags)
> {
> #if CONFIG_XEN_CTRL_INTERFACE_VERSION<  410
>      return xc_interface_open();
> #else
>      return xc_interface_open(logger, dombuild_logger, open_flags);
> #endif
> }
>
>
> So there will have no more structure redirection.
>    

It would be better to have two versions of the header, one that 
implemented the < 410 functions and one that implemented the newer 
functions.

If you're just using the new signature for everything, you could even 
just #define in the later header.

Regards,

Anthony Liguori

> Regards,
>
>    

  reply	other threads:[~2011-02-25 14:11 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-02 14:49 [Qemu-devel] [PATCH V10 00/15] Xen device model support anthony.perard
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 01/15] xen: Replace some tab-indents with spaces (clean-up) anthony.perard
2011-02-24 16:06   ` Anthony Liguori
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 02/15] xen: Make xen build only on x86 target anthony.perard
2011-02-24 16:11   ` Anthony Liguori
2011-02-24 16:25     ` [Xen-devel] " Anthony PERARD
2011-02-24 17:27       ` Anthony Liguori
2011-02-24 17:46         ` Jan Kiszka
2011-02-24 17:59           ` Anthony Liguori
2011-03-11  6:20             ` Alexander Graf
2011-03-11 11:15               ` Stefano Stabellini
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 03/15] xen: Support new libxc calls from xen unstable anthony.perard
2011-02-24 17:29   ` Anthony Liguori
2011-02-25 14:06     ` [Xen-devel] " Anthony PERARD
2011-02-25 14:11       ` Anthony Liguori [this message]
2011-02-25 16:01         ` Anthony PERARD
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 04/15] xen: Add initialisation of Xen anthony.perard
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 05/15] xen: Add xenfv machine anthony.perard
2011-02-24 17:31   ` Anthony Liguori
2011-02-25 13:55     ` Anthony PERARD
2011-02-25 14:09       ` Anthony Liguori
2011-02-25 14:28         ` [Xen-devel] " Anthony PERARD
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 06/15] xen: Add the Xen platform pci device anthony.perard
2011-02-24 17:33   ` Anthony Liguori
2011-02-24 17:36     ` Paolo Bonzini
2011-02-25  9:58       ` [Xen-devel] " Ian Campbell
2011-02-25 10:54         ` Paolo Bonzini
2011-02-25 14:18           ` [Xen-devel] " Anthony PERARD
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 07/15] piix_pci: Introduces Xen specific call for irq anthony.perard
2011-02-24 17:34   ` Anthony Liguori
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 08/15] xen: Introduce Xen Interrupt Controller anthony.perard
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 09/15] xen: Introduce the Xen mapcache anthony.perard
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 10/15] configure: Always use 64bits target physical addresses with xen enabled anthony.perard
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 11/15] Introduce qemu_put_ram_ptr anthony.perard
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 12/15] vl.c: Introduce getter for shutdown_requested and reset_requested anthony.perard
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 13/15] xen: Initialize event channels and io rings anthony.perard
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 14/15] xen: Set running state in xenstore anthony.perard
2011-02-02 14:49 ` [Qemu-devel] [PATCH V10 15/15] xen: Add Xen hypercall for sleep state in the cmos_s3 callback anthony.perard
2011-02-24 17:38 ` [Qemu-devel] [PATCH V10 00/15] Xen device model support 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=4D67B87F.4020108@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --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).