Commit e37630ca4f5142a6830654d9801b473600417d5c
1 parent
b194f610
xen: groundwork for xen support (Gerd Hoffmann)
- configure script and build system changes. - wind up new machine type. - add -xen-* command line options. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7219 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
8 changed files
with
150 additions
and
0 deletions
Makefile.target
... | ... | @@ -560,6 +560,13 @@ ifdef CONFIG_BLUEZ |
560 | 560 | LIBS += $(CONFIG_BLUEZ_LIBS) |
561 | 561 | endif |
562 | 562 | |
563 | +# xen backend driver support | |
564 | +XEN_OBJS := xen_machine_pv.o | |
565 | +ifeq ($(CONFIG_XEN), yes) | |
566 | + OBJS += $(XEN_OBJS) | |
567 | + LIBS += $(XEN_LIBS) | |
568 | +endif | |
569 | + | |
563 | 570 | # SCSI layer |
564 | 571 | OBJS+= lsi53c895a.o esp.o |
565 | 572 | ... | ... |
configure
... | ... | @@ -191,6 +191,7 @@ aix="no" |
191 | 191 | blobs="yes" |
192 | 192 | fdt="yes" |
193 | 193 | sdl_x11="no" |
194 | +xen="yes" | |
194 | 195 | pkgversion="" |
195 | 196 | |
196 | 197 | # OS specific |
... | ... | @@ -421,6 +422,8 @@ for opt do |
421 | 422 | ;; |
422 | 423 | --disable-kqemu) kqemu="no" |
423 | 424 | ;; |
425 | + --disable-xen) xen="no" | |
426 | + ;; | |
424 | 427 | --disable-brlapi) brlapi="no" |
425 | 428 | ;; |
426 | 429 | --disable-bluez) bluez="no" |
... | ... | @@ -586,6 +589,7 @@ echo " Available drivers: $audio_possible_drivers" |
586 | 589 | echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]" |
587 | 590 | echo " Available cards: $audio_possible_cards" |
588 | 591 | echo " --enable-mixemu enable mixer emulation" |
592 | +echo " --disable-xen disable xen backend driver support" | |
589 | 593 | echo " --disable-brlapi disable BrlAPI" |
590 | 594 | echo " --disable-vnc-tls disable TLS encryption for VNC server" |
591 | 595 | echo " --disable-vnc-sasl disable SASL encryption for VNC server" |
... | ... | @@ -802,6 +806,22 @@ else |
802 | 806 | fi |
803 | 807 | |
804 | 808 | ########################################## |
809 | +# xen probe | |
810 | + | |
811 | +if test "$xen" = "yes" ; then | |
812 | +cat > $TMPC <<EOF | |
813 | +#include <xenctrl.h> | |
814 | +#include <xs.h> | |
815 | +int main(void) { xs_daemon_open; xc_interface_open; } | |
816 | +EOF | |
817 | + if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC -lxenstore -lxenctrl 2> /dev/null ; then | |
818 | + : | |
819 | + else | |
820 | + xen="no" | |
821 | + fi | |
822 | +fi | |
823 | + | |
824 | +########################################## | |
805 | 825 | # SDL probe |
806 | 826 | |
807 | 827 | sdl_too_old=no |
... | ... | @@ -1296,6 +1316,7 @@ if test -n "$sparc_cpu"; then |
1296 | 1316 | echo "Target Sparc Arch $sparc_cpu" |
1297 | 1317 | fi |
1298 | 1318 | echo "kqemu support $kqemu" |
1319 | +echo "xen support $xen" | |
1299 | 1320 | echo "brlapi support $brlapi" |
1300 | 1321 | echo "Documentation $build_docs" |
1301 | 1322 | [ ! -z "$uname_release" ] && \ |
... | ... | @@ -1612,6 +1633,9 @@ if test "$bluez" = "yes" ; then |
1612 | 1633 | echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak |
1613 | 1634 | echo "#define CONFIG_BLUEZ 1" >> $config_h |
1614 | 1635 | fi |
1636 | +if test "$xen" = "yes" ; then | |
1637 | + echo "XEN_LIBS=-lxenstore -lxenctrl" >> $config_mak | |
1638 | +fi | |
1615 | 1639 | if test "$aio" = "yes" ; then |
1616 | 1640 | echo "#define CONFIG_AIO 1" >> $config_h |
1617 | 1641 | echo "CONFIG_AIO=yes" >> $config_mak |
... | ... | @@ -1777,6 +1801,11 @@ case "$target_cpu" in |
1777 | 1801 | echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak |
1778 | 1802 | echo "#define CONFIG_KVM 1" >> $config_h |
1779 | 1803 | fi |
1804 | + if test "$xen" = "yes" -a "$target_softmmu" = "yes"; | |
1805 | + then | |
1806 | + echo "CONFIG_XEN=yes" >> $config_mak | |
1807 | + echo "#define CONFIG_XEN 1" >> $config_h | |
1808 | + fi | |
1780 | 1809 | ;; |
1781 | 1810 | x86_64) |
1782 | 1811 | echo "TARGET_ARCH=x86_64" >> $config_mak |
... | ... | @@ -1793,6 +1822,11 @@ case "$target_cpu" in |
1793 | 1822 | echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak |
1794 | 1823 | echo "#define CONFIG_KVM 1" >> $config_h |
1795 | 1824 | fi |
1825 | + if test "$xen" = "yes" -a "$target_softmmu" = "yes" | |
1826 | + then | |
1827 | + echo "CONFIG_XEN=yes" >> $config_mak | |
1828 | + echo "#define CONFIG_XEN 1" >> $config_h | |
1829 | + fi | |
1796 | 1830 | ;; |
1797 | 1831 | alpha) |
1798 | 1832 | echo "TARGET_ARCH=alpha" >> $config_mak | ... | ... |
hw/boards.h
... | ... | @@ -32,6 +32,9 @@ extern QEMUMachine axisdev88_machine; |
32 | 32 | extern QEMUMachine pc_machine; |
33 | 33 | extern QEMUMachine isapc_machine; |
34 | 34 | |
35 | +/* xen_machine.c */ | |
36 | +extern QEMUMachine xenpv_machine; | |
37 | + | |
35 | 38 | /* ppc.c */ |
36 | 39 | extern QEMUMachine prep_machine; |
37 | 40 | extern QEMUMachine core99_machine; | ... | ... |
hw/xen.h
0 โ 100644
1 | +#ifndef QEMU_HW_XEN_H | |
2 | +#define QEMU_HW_XEN_H 1 | |
3 | +/* | |
4 | + * public xen header | |
5 | + * stuff needed outside xen-*.c, i.e. interfaces to qemu. | |
6 | + * must not depend on any xen headers being present in | |
7 | + * /usr/include/xen, so it can be included unconditionally. | |
8 | + */ | |
9 | + | |
10 | +/* xen-machine.c */ | |
11 | +enum xen_mode { | |
12 | + XEN_EMULATE = 0, // xen emulation, using xenner (default) | |
13 | + XEN_CREATE, // create xen domain | |
14 | + XEN_ATTACH // attach to xen domain created by xend | |
15 | +}; | |
16 | + | |
17 | +extern uint32_t xen_domid; | |
18 | +extern enum xen_mode xen_mode; | |
19 | + | |
20 | +#endif /* QEMU_HW_XEN_H */ | ... | ... |
hw/xen_machine_pv.c
0 โ 100644
1 | +/* | |
2 | + * QEMU Xen PV Machine | |
3 | + * | |
4 | + * Copyright (c) 2007 Red Hat | |
5 | + * | |
6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | + * of this software and associated documentation files (the "Software"), to deal | |
8 | + * in the Software without restriction, including without limitation the rights | |
9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | + * copies of the Software, and to permit persons to whom the Software is | |
11 | + * furnished to do so, subject to the following conditions: | |
12 | + * | |
13 | + * The above copyright notice and this permission notice shall be included in | |
14 | + * all copies or substantial portions of the Software. | |
15 | + * | |
16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | + * THE SOFTWARE. | |
23 | + */ | |
24 | + | |
25 | +#include "hw.h" | |
26 | +#include "pc.h" | |
27 | +#include "sysemu.h" | |
28 | +#include "boards.h" | |
29 | +#include "xen.h" | |
30 | + | |
31 | +uint32_t xen_domid; | |
32 | +enum xen_mode xen_mode = XEN_EMULATE; | |
33 | + | |
34 | +static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size, | |
35 | + const char *boot_device, | |
36 | + const char *kernel_filename, | |
37 | + const char *kernel_cmdline, | |
38 | + const char *initrd_filename, | |
39 | + const char *cpu_model) | |
40 | +{ | |
41 | + CPUState *env; | |
42 | + | |
43 | + /* Initialize a dummy CPU */ | |
44 | + if (cpu_model == NULL) { | |
45 | +#ifdef TARGET_X86_64 | |
46 | + cpu_model = "qemu64"; | |
47 | +#else | |
48 | + cpu_model = "qemu32"; | |
49 | +#endif | |
50 | + } | |
51 | + env = cpu_init(cpu_model); | |
52 | + env->halted = 1; | |
53 | +} | |
54 | + | |
55 | +QEMUMachine xenpv_machine = { | |
56 | + .name = "xenpv", | |
57 | + .desc = "Xen Para-virtualized PC", | |
58 | + .init = xen_init_pv, | |
59 | + .max_cpus = 1, | |
60 | +}; | ... | ... |
qemu-options.hx
... | ... | @@ -1348,6 +1348,17 @@ Enable KVM full virtualization support. This option is only available |
1348 | 1348 | if KVM support is enabled when compiling. |
1349 | 1349 | ETEXI |
1350 | 1350 | |
1351 | +#ifdef CONFIG_XEN | |
1352 | +DEF("xen-domid", HAS_ARG, QEMU_OPTION_xen_domid, | |
1353 | + "-xen-domid id specify xen guest domain id\n") | |
1354 | +DEF("xen-create", 0, QEMU_OPTION_xen_create, | |
1355 | + "-xen-create create domain using xen hypercalls, bypassing xend\n" | |
1356 | + " warning: should not be used when xend is in use\n") | |
1357 | +DEF("xen-attach", 0, QEMU_OPTION_xen_attach, | |
1358 | + "-xen-attach attach to existing xen domain\n" | |
1359 | + " xend will use this when starting qemu\n") | |
1360 | +#endif | |
1361 | + | |
1351 | 1362 | DEF("no-reboot", 0, QEMU_OPTION_no_reboot, \ |
1352 | 1363 | "-no-reboot exit instead of rebooting\n") |
1353 | 1364 | STEXI | ... | ... |
target-i386/machine.c
... | ... | @@ -9,6 +9,9 @@ void register_machines(void) |
9 | 9 | { |
10 | 10 | qemu_register_machine(&pc_machine); |
11 | 11 | qemu_register_machine(&isapc_machine); |
12 | +#ifdef CONFIG_XEN | |
13 | + qemu_register_machine(&xenpv_machine); | |
14 | +#endif | |
12 | 15 | } |
13 | 16 | |
14 | 17 | static void cpu_put_seg(QEMUFile *f, SegmentCache *dt) | ... | ... |
vl.c
... | ... | @@ -139,6 +139,7 @@ int main(int argc, char **argv) |
139 | 139 | #include "hw/baum.h" |
140 | 140 | #include "hw/bt.h" |
141 | 141 | #include "hw/smbios.h" |
142 | +#include "hw/xen.h" | |
142 | 143 | #include "bt-host.h" |
143 | 144 | #include "net.h" |
144 | 145 | #include "monitor.h" |
... | ... | @@ -5046,6 +5047,17 @@ int main(int argc, char **argv, char **envp) |
5046 | 5047 | run_as = optarg; |
5047 | 5048 | break; |
5048 | 5049 | #endif |
5050 | +#ifdef CONFIG_XEN | |
5051 | + case QEMU_OPTION_xen_domid: | |
5052 | + xen_domid = atoi(optarg); | |
5053 | + break; | |
5054 | + case QEMU_OPTION_xen_create: | |
5055 | + xen_mode = XEN_CREATE; | |
5056 | + break; | |
5057 | + case QEMU_OPTION_xen_attach: | |
5058 | + xen_mode = XEN_ATTACH; | |
5059 | + break; | |
5060 | +#endif | |
5049 | 5061 | } |
5050 | 5062 | } |
5051 | 5063 | } | ... | ... |