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 05/13] xen: groundwork for xen support
Date: Thu, 21 Aug 2008 18:27:26 +0200 [thread overview]
Message-ID: <1219336054-15919-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1219336054-15919-1-git-send-email-kraxel@redhat.com>
- configure script and build system changes.
- wind up new machine type.
- add -domid command line option.
- allow xenpv machines run without disk and kernel specified
by adding a nodisk_ok field to QEMUMachine.
- detect xen being present.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
Makefile.target | 8 +++
configure | 27 +++++++++
hw/boards.h | 3 +
hw/xen.h | 18 ++++++
hw/xen_machine_pv.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++
target-i386/machine.c | 3 +
vl.c | 15 +++++
7 files changed, 220 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 42162c3..13ee854 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -515,6 +515,14 @@ CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
LIBS += $(CONFIG_VNC_TLS_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 74ce443..14689d2 100755
--- a/configure
+++ b/configure
@@ -109,6 +109,7 @@ curses="yes"
aio="yes"
nptl="yes"
mixemu="no"
+xen="no"
# OS specific
targetos=`uname -s`
@@ -204,6 +205,7 @@ linux="yes"
linux_user="yes"
if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
kqemu="yes"
+ xen="yes"
audio_possible_drivers="$audio_possible_drivers fmod"
fi
;;
@@ -287,6 +289,8 @@ for opt do
;;
--disable-kqemu) kqemu="no"
;;
+ --disable-xen) xen="no"
+ ;;
--disable-brlapi) brlapi="no"
;;
--enable-profiler) profiler="yes"
@@ -425,6 +429,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"
@@ -686,6 +691,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
@@ -946,6 +967,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" ] && \
@@ -1203,6 +1225,11 @@ if test "$brlapi" = "yes" ; then
echo "#define CONFIG_BRLAPI 1" >> $config_h
echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
fi
+if test "$xen" = "yes" ; then
+ echo "CONFIG_XEN=yes" >> $config_mak
+ echo "#define CONFIG_XEN 1" >> $config_h
+ echo "XEN_LIBS=-lxenstore -lxenctrl" >> $config_mak
+fi
if test "$aio" = "yes" ; then
echo "#define CONFIG_AIO 1" >> $config_h
fi
diff --git a/hw/boards.h b/hw/boards.h
index e6dd198..9af9939 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -30,6 +30,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..a772aad
--- /dev/null
+++ b/hw/xen.h
@@ -0,0 +1,18 @@
+#ifndef QEMU_XEN_H
+#define QEMU_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 */
+extern int xen_domid;
+extern int xen_present;
+extern int xen_emulate;
+extern int xen_domainbuild;
+
+int xen_detect(void);
+
+#endif /* QEMU_XEN_H */
diff --git a/hw/xen_machine_pv.c b/hw/xen_machine_pv.c
new file mode 100644
index 0000000..05f0e67
--- /dev/null
+++ b/hw/xen_machine_pv.c
@@ -0,0 +1,146 @@
+/*
+ * 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 <xenctrl.h>
+
+/* -------------------------------------------------------------------- */
+/* variables */
+
+int xen_domid;
+int xen_present = -1;
+int xen_emulate;
+int xen_domainbuild;
+
+/* -------------------------------------------------------------------- */
+/* initialization code */
+
+/*
+ * Figure the environment we are running in.
+ * Returns true when xen is present, false otherwise.
+ * Also checks whenever the domain specified via -domid
+ * exists (so we can attach) or whenever it must be created.
+ */
+int xen_detect(void)
+{
+ struct xc_dominfo info;
+ int xc, rc;
+
+ if (xen_present != -1)
+ goto out;
+
+ /* running on xen? (priviledged domain) */
+ xen_present = 0;
+ xc = xc_interface_open();
+ if (-1 == xc)
+ goto out;
+ xen_present = 1;
+
+ /* does the domain exist? Or should we create one? */
+ rc = xc_domain_getinfo(xc, xen_domid, 1, &info);
+ if ((1 != rc) || (info.domid != xen_domid))
+ xen_domainbuild = 1;
+ close(xc);
+
+out:
+ return xen_present;
+}
+
+static int xen_init(void)
+{
+ if (!xen_domid) {
+ fprintf(stderr, "%s: no domid specified\n", __FUNCTION__);
+ return -1;
+ }
+
+ if (!xen_detect()) {
+ fprintf(stderr, "%s: emulating Xen\n", __FUNCTION__);
+ xen_emulate = 1;
+ }
+
+ 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;
+
+ if (xen_emulate) {
+ fprintf(stderr, "xen pv emulation not implemented yet\n");
+ goto err;
+ }
+ if (xen_domainbuild) {
+ fprintf(stderr, "xen pv domain creation not implemented yet\n");
+ 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,
+};
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 91dbd55..98ece17 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 3211507..ff94c6f 100644
--- a/vl.c
+++ b/vl.c
@@ -29,6 +29,7 @@
#include "hw/audiodev.h"
#include "hw/isa.h"
#include "hw/baum.h"
+#include "hw/xen.h"
#include "net.h"
#include "console.h"
#include "sysemu.h"
@@ -7780,6 +7781,9 @@ 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
+ "-domid specify xen guest domain id\n"
+#endif
"\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n"
@@ -7885,6 +7889,9 @@ enum {
QEMU_OPTION_startdate,
QEMU_OPTION_tb_size,
QEMU_OPTION_icount,
+#ifdef CONFIG_XEN
+ QEMU_OPTION_domid,
+#endif
};
typedef struct QEMUOption {
@@ -7973,6 +7980,9 @@ const QEMUOption qemu_options[] = {
#ifdef CONFIG_CURSES
{ "curses", 0, QEMU_OPTION_curses },
#endif
+#ifdef CONFIG_XEN
+ { "domid", HAS_ARG, QEMU_OPTION_domid },
+#endif
/* temporary options */
{ "usb", 0, QEMU_OPTION_usb },
@@ -8847,6 +8857,11 @@ int main(int argc, char **argv)
icount_time_shift = strtol(optarg, NULL, 0);
}
break;
+#ifdef CONFIG_XEN
+ case QEMU_OPTION_domid:
+ xen_domid = atoi(optarg);
+ break;
+#endif
}
}
}
--
1.5.5.1
next prev parent reply other threads:[~2008-08-21 16:28 UTC|newest]
Thread overview: 117+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-21 16:27 [Qemu-devel] [PATCH 00/13] merge some xen bits into qemu Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 01/13] Handle terminating signals Gerd Hoffmann
2008-08-21 20:11 ` Anthony Liguori
[not found] ` <m2n.s.1KWGbo-001Nr9@chiark.greenend.org.uk>
2008-08-26 10:44 ` Ian Jackson
2008-08-26 12:16 ` Gerd Hoffmann
2008-08-26 12:36 ` Ian Jackson
2008-08-26 12:58 ` Gerd Hoffmann
2008-08-26 17:55 ` Jamie Lokier
2008-08-26 13:17 ` Anthony Liguori
2008-08-26 13:38 ` [Xen-devel] " Ian Jackson
2008-08-26 14:52 ` Avi Kivity
2008-08-26 17:49 ` Jamie Lokier
2008-08-26 15:04 ` Anthony Liguori
2008-08-26 15:08 ` Ian Jackson
2008-08-26 15:20 ` Anthony Liguori
2008-08-26 15:28 ` Ian Jackson
2008-08-26 15:36 ` Anthony Liguori
2008-08-26 17:47 ` Jamie Lokier
2008-08-26 18:03 ` Jamie Lokier
2008-08-26 18:50 ` Anthony Liguori
2008-08-27 9:46 ` Ian Jackson
2008-08-27 16:27 ` Jamie Lokier
2008-08-27 16:35 ` Ian Jackson
2008-08-27 17:55 ` Anthony Liguori
2008-08-27 18:41 ` Jamie Lokier
2008-08-28 9:34 ` Ian Jackson
2008-09-07 2:41 ` Anthony Liguori
2008-08-26 15:36 ` Samuel Thibault
2008-08-26 15:21 ` Anthony Liguori
[not found] ` <m2n.s.1KXzwZ-002RA9@chiark.greenend.org.uk>
2008-08-26 15:23 ` Ian Jackson
2008-08-26 15:29 ` Avi Kivity
[not found] ` <m2n.s.1KY0XT-002RJM@chiark.greenend.org.uk>
2008-08-26 15:38 ` Ian Jackson
2008-08-26 16:12 ` Avi Kivity
2008-08-26 16:14 ` Julian Seward
2008-08-26 16:39 ` Anthony Liguori
2008-08-27 8:05 ` Avi Kivity
2008-08-27 8:49 ` Alan Cox
2008-08-27 9:10 ` Avi Kivity
2008-08-27 9:16 ` Keir Fraser
2008-08-27 9:12 ` Gleb Natapov
[not found] ` <m2n.s.1KXz4u-002Qvq@chiark.greenend.org.uk>
2008-08-26 14:55 ` Ian Jackson
2008-08-21 16:27 ` [Qemu-devel] [PATCH 02/13] add DisplayState->idle Gerd Hoffmann
2008-08-21 16:33 ` [Qemu-devel] " Samuel Thibault
2008-08-21 20:12 ` [Qemu-devel] " Anthony Liguori
2008-08-21 16:27 ` [Qemu-devel] [PATCH 03/13] add container_of() macro to osdep.h Gerd Hoffmann
2008-08-21 20:12 ` Anthony Liguori
2008-08-21 16:27 ` [Qemu-devel] [PATCH 04/13] move GUI_REFRESH_INTERVAL define from vl.c to console.h Gerd Hoffmann
2008-08-21 20:12 ` Anthony Liguori
2008-08-21 16:27 ` Gerd Hoffmann [this message]
2008-08-21 20:18 ` [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support Anthony Liguori
2008-08-21 16:27 ` [Qemu-devel] [PATCH 06/13] xen: backend driver core Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 07/13] xen: add console backend driver Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 08/13] xen: add framebuffer " Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 09/13] xen: add block device " Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 10/13] xen: add net " Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 11/13] xen: blk & nic configuration via cmd line Gerd Hoffmann
2008-08-21 16:27 ` [Qemu-devel] [PATCH 12/13] set vnc password from xenstore Gerd Hoffmann
2008-08-21 20:14 ` Anthony Liguori
2008-08-21 20:19 ` [Xen-devel] " Daniel P. Berrange
2008-08-21 20:22 ` Anthony Liguori
2008-08-21 20:26 ` Daniel P. Berrange
2008-08-21 21:34 ` Gerd Hoffmann
2008-08-21 21:48 ` Daniel P. Berrange
2008-08-21 22:36 ` Anthony Liguori
2008-08-24 9:03 ` Avi Kivity
2008-08-22 7:04 ` Gerd Hoffmann
2008-08-22 19:11 ` Jamie Lokier
2008-08-22 19:01 ` Jamie Lokier
2008-08-21 22:34 ` Anthony Liguori
2008-08-22 8:27 ` Gerd Hoffmann
2008-08-24 8:57 ` Avi Kivity
2008-08-24 9:59 ` Jamie Lokier
2008-08-24 10:07 ` Avi Kivity
2008-08-24 12:48 ` Jamie Lokier
2008-08-21 20:59 ` Jamie Lokier
2008-08-21 21:29 ` Gerd Hoffmann
2008-08-26 10:13 ` Ian Jackson
2008-08-21 20:17 ` [Qemu-devel] Re: [Xen-devel] " Daniel P. Berrange
2008-08-21 21:25 ` Gerd Hoffmann
[not found] ` <m2n.s.1KWHfl-001Ntw@chiark.greenend.org.uk>
2008-08-26 10:47 ` Ian Jackson
2008-08-21 16:27 ` [Qemu-devel] [PATCH 13/13] xen: pv domain builder Gerd Hoffmann
[not found] ` <m2n.s.1KWDD7-002TB9@chiark.greenend.org.uk>
2008-08-26 10:31 ` [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support Ian Jackson
2008-08-26 12:34 ` Gerd Hoffmann
2008-08-26 12:57 ` [Xen-devel] " Daniel P. Berrange
2008-08-26 13:20 ` Gerd Hoffmann
2008-08-26 13:23 ` Daniel P. Berrange
2008-08-26 13:33 ` Ian Jackson
2008-08-26 14:14 ` Daniel P. Berrange
2008-08-26 14:31 ` Gerd Hoffmann
2008-08-26 14:40 ` Daniel P. Berrange
2008-08-26 14:49 ` Gerd Hoffmann
2008-08-26 14:53 ` Daniel P. Berrange
2008-08-26 19:24 ` Gerd Hoffmann
2008-08-26 14:53 ` Ian Jackson
2008-08-27 8:51 ` Gerd Hoffmann
2008-08-27 9:53 ` Ian Jackson
2008-08-27 9:56 ` Daniel P. Berrange
2008-08-27 10:00 ` Ian Jackson
2008-08-27 10:23 ` Daniel P. Berrange
2008-08-27 10:37 ` Gerd Hoffmann
2008-08-27 10:44 ` Daniel P. Berrange
2008-08-27 11:01 ` Gerd Hoffmann
[not found] ` <m2n.s.1KXzR5-002R2A@chiark.greenend.org.uk>
2008-08-26 15:05 ` Ian Jackson
2008-08-26 15:09 ` Daniel P. Berrange
2008-08-26 13:24 ` Ian Jackson
2008-08-26 13:50 ` Daniel P. Berrange
[not found] ` <m2n.s.1KWDfC-002TCd@chiark.greenend.org.uk>
[not found] ` <m2n.s.1KWDGv-002TBJ@chiark.greenend.org.uk>
[not found] ` <m2n.s.1KWDEt-002TBA@chiark.greenend.org.uk>
2008-08-26 10:42 ` [Qemu-devel] [PATCH 13/13] xen: pv domain builder Ian Jackson
2008-08-26 10:50 ` [Xen-devel] " Samuel Thibault
2008-08-26 13:43 ` Ian Jackson
2008-08-26 21:00 ` Markus Armbruster
2008-08-26 12:55 ` Gerd Hoffmann
2008-08-26 13:14 ` Ian Jackson
2008-08-26 13:53 ` Gerd Hoffmann
2008-08-26 14:19 ` Ian Jackson
2008-08-26 20:00 ` [Xen-devel] " Gerd Hoffmann
2008-08-27 9:48 ` Ian Jackson
2008-08-26 13:56 ` 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=1219336054-15919-6-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).