qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org, xen-devel@lists.xensource.com
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 1/7] xen: groundwork for xen support
Date: Tue, 28 Oct 2008 13:23:36 +0100	[thread overview]
Message-ID: <1225196622-14164-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1225196622-14164-1-git-send-email-kraxel@redhat.com>

- configure script and build system changes.
- wind up new machine type.
- add -xen-* command line options.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 Makefile.target       |    8 ++++
 configure             |   36 +++++++++++++++++
 hw/boards.h           |    3 +
 hw/xen.h              |   20 +++++++++
 hw/xen_machine_pv.c   |  105 +++++++++++++++++++++++++++++++++++++++++++++++++
 target-i386/machine.c |    3 +
 vl.c                  |   29 +++++++++++++
 7 files changed, 204 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen.h
 create mode 100644 hw/xen_machine_pv.c

diff --git a/Makefile.target b/Makefile.target
index f9c0b34..5368f6e 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -629,6 +629,14 @@ ifdef CONFIG_BLUEZ
 LIBS += $(CONFIG_BLUEZ_LIBS)
 endif
 
+# xen backend driver support
+XEN_OBJS := xen_machine_pv.o
+ifeq ($(CONFIG_XEN), yes)
+  OBJS += $(XEN_OBJS)
+  LIBS += $(XEN_LIBS)
+  $(XEN_OBJS) : CFLAGS += -Wall -Wmissing-prototypes -Wstrict-prototypes
+endif
+
 # SCSI layer
 OBJS+= lsi53c895a.o esp.o
 
diff --git a/configure b/configure
index ccc4ae0..b1ab014 100755
--- a/configure
+++ b/configure
@@ -114,6 +114,9 @@ aio="yes"
 nptl="yes"
 mixemu="no"
 bluez="yes"
+signalfd="no"
+eventfd="no"
+xen="yes"
 
 # OS specific
 targetos=`uname -s`
@@ -298,6 +301,8 @@ for opt do
   ;;
   --disable-kqemu) kqemu="no"
   ;;
+  --disable-xen) xen="no"
+  ;;
   --disable-brlapi) brlapi="no"
   ;;
   --disable-bluez) bluez="no"
@@ -441,6 +446,7 @@ echo "                           Available drivers: $audio_possible_drivers"
 echo "  --audio-card-list=LIST   set list of additional emulated audio cards"
 echo "                           Available cards: ac97 adlib cs4231a gus"
 echo "  --enable-mixemu          enable mixer emulation"
+echo "  --disable-xen            disable xen backend driver support"
 echo "  --disable-brlapi         disable BrlAPI"
 echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
 echo "  --disable-curses         disable curses output"
@@ -748,6 +754,22 @@ else
 fi
 
 ##########################################
+# xen probe
+
+if test "$xen" = "yes" ; then
+cat > $TMPC <<EOF
+#include <xenctrl.h>
+#include <xs.h>
+int main(void) { xs_daemon_open; xc_interface_open; }
+EOF
+   if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC -lxenstore -lxenctrl 2> /dev/null ; then
+      :
+   else
+      xen="no"
+   fi
+fi
+
+##########################################
 # SDL probe
 
 sdl_too_old=no
@@ -1026,6 +1048,7 @@ if test -n "$sparc_cpu"; then
     echo "Target Sparc Arch $sparc_cpu"
 fi
 echo "kqemu support     $kqemu"
+echo "xen support       $xen"
 echo "brlapi support    $brlapi"
 echo "Documentation     $build_docs"
 [ ! -z "$uname_release" ] && \
@@ -1296,6 +1319,9 @@ if test "$bluez" = "yes" ; then
   echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak
   echo "#define CONFIG_BLUEZ 1" >> $config_h
 fi
+if test "$xen" = "yes" ; then
+  echo "XEN_LIBS=-lxenstore -lxenctrl" >> $config_mak
+fi
 if test "$aio" = "yes" ; then
   echo "#define CONFIG_AIO 1" >> $config_h
   echo "CONFIG_AIO=yes" >> $config_mak
@@ -1417,6 +1443,11 @@ case "$target_cpu" in
     then
       echo "#define USE_KQEMU 1" >> $config_h
     fi
+    if test "$xen" = "yes" -a "$target_softmmu" = "yes";
+    then
+      echo "CONFIG_XEN=yes" >> $config_mak
+      echo "#define CONFIG_XEN 1" >> $config_h
+    fi
     gcc3minver=`$cc --version 2> /dev/null| fgrep "(GCC) 3." | awk '{ print $3 }' | cut -f2 -d.`
     if test -n "$gcc3minver" && test $gcc3minver -gt 3
     then
@@ -1434,6 +1465,11 @@ case "$target_cpu" in
     then
       echo "#define USE_KQEMU 1" >> $config_h
     fi
+    if test "$xen" = "yes" -a "$target_softmmu" = "yes"
+    then
+      echo "CONFIG_XEN=yes" >> $config_mak
+      echo "#define CONFIG_XEN 1" >> $config_h
+    fi
   ;;
   alpha)
     echo "TARGET_ARCH=alpha" >> $config_mak
diff --git a/hw/boards.h b/hw/boards.h
index d30c0fc..9bcfdae 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -32,6 +32,9 @@ extern QEMUMachine bareetraxfs_machine;
 extern QEMUMachine pc_machine;
 extern QEMUMachine isapc_machine;
 
+/* xen_machine.c */
+extern QEMUMachine xenpv_machine;
+
 /* ppc.c */
 extern QEMUMachine prep_machine;
 extern QEMUMachine core99_machine;
diff --git a/hw/xen.h b/hw/xen.h
new file mode 100644
index 0000000..4bcc0f1
--- /dev/null
+++ b/hw/xen.h
@@ -0,0 +1,20 @@
+#ifndef QEMU_HW_XEN_H
+#define QEMU_HW_XEN_H 1
+/*
+ * public xen header
+ *   stuff needed outside xen-*.c, i.e. interfaces to qemu.
+ *   must not depend on any xen headers being present in
+ *   /usr/include/xen, so it can be included unconditionally.
+ */
+
+/* xen-machine.c */
+enum xen_mode {
+    XEN_EMULATE = 0,  // xen emulation, using xenner (default)
+    XEN_CREATE,       // create xen domain
+    XEN_ATTACH        // attach to xen domain created by xend
+};
+
+extern int xen_domid;
+extern enum xen_mode xen_mode;
+
+#endif /* QEMU_HW_XEN_H */
diff --git a/hw/xen_machine_pv.c b/hw/xen_machine_pv.c
new file mode 100644
index 0000000..9daab75
--- /dev/null
+++ b/hw/xen_machine_pv.c
@@ -0,0 +1,105 @@
+/*
+ * QEMU Xen PV Machine
+ *
+ * Copyright (c) 2007,08 Red Hat
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "hw.h"
+#include "boards.h"
+
+#include "xen.h"
+#include <xenctrl.h>
+
+/* -------------------------------------------------------------------- */
+/* variables                                                            */
+
+int xen_domid;
+enum xen_mode xen_mode = XEN_EMULATE;
+
+/* -------------------------------------------------------------------- */
+/* initialization code                                                  */
+
+static int xen_init(void)
+{
+    if (!xen_domid) {
+	fprintf(stderr, "%s: no domid specified\n", __FUNCTION__);
+	return -1;
+    }
+
+    if (xen_mode == XEN_EMULATE) {
+        fprintf(stderr, "%s: emulating Xen\n", __FUNCTION__);
+    }
+
+    return 0;
+}
+
+static int xen_init_pv(DisplayState *ds)
+{
+    int rc;
+
+    rc = xen_init();
+    if (rc < 0)
+        return rc;
+
+    return 0;
+}
+
+/* -------------------------------------------------------------------- */
+/* paravirtualized xen machine                                          */
+
+static void xenpv_init(ram_addr_t ram_size, int vga_ram_size,
+		       const char *boot_device, DisplayState *ds,
+		       const char *kernel_filename,
+		       const char *kernel_cmdline,
+		       const char *initrd_filename,
+		       const char *cpu_model)
+{
+    CPUState *env;
+    int rc;
+
+    rc = xen_init_pv(ds);
+    if (-1 == rc)
+        goto err;
+
+    /* create dummy cpu, halted */
+    if (cpu_model == NULL) {
+#ifdef TARGET_X86_64
+        cpu_model = "qemu64";
+#else
+        cpu_model = "qemu32";
+#endif
+    }
+    env = cpu_init(cpu_model);
+    env->halted = 1;
+
+    return;
+
+err:
+    exit(1);
+}
+
+QEMUMachine xenpv_machine = {
+    .name = "xenpv",
+    .desc = "paravirtualized Xen machine",
+    .init = xenpv_init,
+    .nodisk_ok = 1,
+    .max_cpus = 1,
+};
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 9d440fb..be10cfb 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -9,6 +9,9 @@ void register_machines(void)
 {
     qemu_register_machine(&pc_machine);
     qemu_register_machine(&isapc_machine);
+#ifdef CONFIG_XEN
+    qemu_register_machine(&xenpv_machine);
+#endif
 }
 
 static void cpu_put_seg(QEMUFile *f, SegmentCache *dt)
diff --git a/vl.c b/vl.c
index 0ca7151..0d275bf 100644
--- a/vl.c
+++ b/vl.c
@@ -30,6 +30,7 @@
 #include "hw/isa.h"
 #include "hw/baum.h"
 #include "hw/bt.h"
+#include "hw/xen.h"
 #include "net.h"
 #include "console.h"
 #include "sysemu.h"
@@ -8282,6 +8283,13 @@ static void help(int exitcode)
            "-startdate      select initial date of the clock\n"
            "-icount [N|auto]\n"
            "                Enable virtual instruction counter with 2^N clock ticks per instruction\n"
+#ifdef CONFIG_XEN
+           "-xen-domid id   specify xen guest domain id\n"
+           "-xen-create     create domain using xen hypercalls, bypassing xend\n"
+           "                warning: should not be used when xend is in use\n"
+           "-xen-attach     attach to existing xen domain\n"
+           "                xend will use this when starting qemu\n"
+#endif
            "\n"
            "During emulation, the following keys are useful:\n"
            "ctrl-alt-f      toggle full screen\n"
@@ -8387,6 +8395,11 @@ enum {
     QEMU_OPTION_icount,
     QEMU_OPTION_uuid,
     QEMU_OPTION_incoming,
+#ifdef CONFIG_XEN
+    QEMU_OPTION_xen_domid,
+    QEMU_OPTION_xen_create,
+    QEMU_OPTION_xen_attach,
+#endif
 };
 
 typedef struct QEMUOption {
@@ -8476,6 +8489,11 @@ static const QEMUOption qemu_options[] = {
     { "curses", 0, QEMU_OPTION_curses },
 #endif
     { "uuid", HAS_ARG, QEMU_OPTION_uuid },
+#ifdef CONFIG_XEN
+    { "xen-domid", HAS_ARG, QEMU_OPTION_xen_domid },
+    { "xen-create", 0, QEMU_OPTION_xen_create },
+    { "xen-attach", 0, QEMU_OPTION_xen_attach },
+#endif
 
     /* temporary options */
     { "usb", 0, QEMU_OPTION_usb },
@@ -9403,6 +9421,17 @@ int main(int argc, char **argv)
             case QEMU_OPTION_incoming:
                 incoming = optarg;
                 break;
+#ifdef CONFIG_XEN
+            case QEMU_OPTION_xen_domid:
+                xen_domid = atoi(optarg);
+                break;
+            case QEMU_OPTION_xen_create:
+                xen_mode = XEN_CREATE;
+                break;
+            case QEMU_OPTION_xen_attach:
+                xen_mode = XEN_ATTACH;
+                break;
+#endif
             }
         }
     }
-- 
1.5.6.5

  reply	other threads:[~2008-10-28 12:23 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-28 12:23 [Qemu-devel] [PATCH 0/7] merge some xen bits into qemu Gerd Hoffmann
2008-10-28 12:23 ` Gerd Hoffmann [this message]
2008-10-28 12:23 ` [Qemu-devel] [PATCH 2/7] xen: backend driver core Gerd Hoffmann
2008-10-28 12:23 ` [Qemu-devel] [PATCH 3/7] xen: add console backend driver Gerd Hoffmann
2008-10-28 17:16   ` Blue Swirl
2008-10-29 10:53     ` Gerd Hoffmann
2008-10-28 12:23 ` [Qemu-devel] [PATCH 4/7] xen: add framebuffer " Gerd Hoffmann
2008-10-28 12:23 ` [Qemu-devel] [PATCH 5/7] xen: add block device " Gerd Hoffmann
2008-10-28 12:23 ` [Qemu-devel] [PATCH 6/7] xen: add net " Gerd Hoffmann
2008-10-28 12:23 ` [Qemu-devel] [PATCH 7/7] xen: blk & nic configuration via cmd line Gerd Hoffmann
2008-10-28 14:34 ` [Qemu-devel] Re: [Xen-devel] [PATCH 0/7] merge some xen bits into qemu Ian Jackson
2008-10-28 15:11   ` Anthony Liguori
2008-10-28 18:31     ` Ian Jackson
2008-10-28 18:32       ` Ian Jackson
2008-10-28 21:15       ` Gerd Hoffmann
2008-10-30 12:07         ` Ian Jackson
2008-10-30 14:04           ` Gerd Hoffmann
2008-10-28 15:53   ` Gerd Hoffmann
2008-10-28 16:43   ` Markus Armbruster
2008-10-29  0:04 ` Samuel Thibault
2008-10-29  9:08   ` Gerd Hoffmann
  -- strict thread matches above, loose matches on Subject: below --
2008-08-04 15:50 [Qemu-devel] " Gerd Hoffmann
2008-08-04 15:50 ` [Qemu-devel] [PATCH 1/7] xen: groundwork for xen support Gerd Hoffmann
2008-08-04 16:34   ` Blue Swirl
2008-08-04 18:01     ` Gerd Hoffmann
2008-08-04 17:35   ` Anthony Liguori
2008-08-04 18:04     ` Gerd Hoffmann
2008-07-28 13:17 [Qemu-devel] [PATCH 0/7] merge some xen bits into qemu Gerd Hoffmann
2008-07-28 13:17 ` [Qemu-devel] [PATCH 1/7] xen: groundwork for xen support Gerd Hoffmann
2008-07-28 14:04   ` Anthony Liguori
2008-07-28 14:52     ` Gerd Hoffmann

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=1225196622-14164-2-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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).