[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [RFC 1/7] linux-stubdomain: Compile QEMU



On Tue, 3 Feb 2015, Eric Shelton wrote:
> This patch adds a Makefile which downloads, patches, and compiles
> upstream QEMU for a stubdomain based on a linux kernel.
> 
> Signed-off-by: Eric Shelton <eshelton@xxxxxxxxx>
> ---
>  stubdom-linux/.gitignore            |  3 ++
>  stubdom-linux/Makefile              | 55 
> +++++++++++++++++++++++++++++++++++++
>  stubdom-linux/qemu-configure.patch  | 47 +++++++++++++++++++++++++++++++
>  stubdom-linux/qemu-xen-common.patch | 12 ++++++++
>  stubdom-linux/qemu-xen-h.patch      | 18 ++++++++++++
>  stubdom-linux/qemu-xen-hvm.patch    | 36 ++++++++++++++++++++++++
>  6 files changed, 171 insertions(+)
>  create mode 100644 stubdom-linux/.gitignore
>  create mode 100644 stubdom-linux/Makefile
>  create mode 100644 stubdom-linux/qemu-configure.patch
>  create mode 100644 stubdom-linux/qemu-xen-common.patch
>  create mode 100644 stubdom-linux/qemu-xen-h.patch
>  create mode 100644 stubdom-linux/qemu-xen-hvm.patch
> 
> diff --git a/stubdom-linux/.gitignore b/stubdom-linux/.gitignore
> new file mode 100644
> index 0000000..1b5ec08
> --- /dev/null
> +++ b/stubdom-linux/.gitignore
> @@ -0,0 +1,3 @@
> +/qemu-build/
> +/qemu-remote
> +/qemu-remote-remote/
> diff --git a/stubdom-linux/Makefile b/stubdom-linux/Makefile
> new file mode 100644
> index 0000000..4e84a61
> --- /dev/null
> +++ b/stubdom-linux/Makefile
> @@ -0,0 +1,55 @@
> +XEN_ROOT = $(CURDIR)/..
> +
> +-include $(XEN_ROOT)/config/Tools.mk
> +include $(XEN_ROOT)/Config.mk
> +
> +# Qemu tree used
> +QEMU_TREE=git://xenbits.xen.org/qemu-upstream-4.5-testing.git
> +QEMU_BRANCH=qemu-xen-4.5.0
> +
> +all:
> +
> +qemu-build/Makefile:
> +     export GIT=$(GIT); \
> +     $(XEN_ROOT)/scripts/git-checkout.sh $(QEMU_TREE) $(QEMU_BRANCH) 
> qemu-remote
> +     cd qemu-remote && patch -p1 < ../qemu-configure.patch
> +     cd qemu-remote && patch -p1 < ../qemu-xen-common.patch
> +     cd qemu-remote && patch -p1 < ../qemu-xen-h.patch
> +     cd qemu-remote && patch -p1 < ../qemu-xen-hvm.patch

Before having patches, I would like to try to get them upstream in QEMU.
If we really cannot do that, then I would still prefer to commit any
required workarounds to the qemu-xen rather than having them here as
patches.


> +     mkdir -p qemu-build
> +     cd qemu-build && ../qemu-remote/configure \
> +             --target-list=i386-softmmu \
> +             --enable-xen \
> +             --extra-cflags="-I$(XEN_ROOT)/tools/include \
> +                     -I$(XEN_ROOT)/tools/libxc \
> +                     -I$(XEN_ROOT)/tools/xenstore \
> +                     -I$(XEN_ROOT)/tools/xenstore/compat \
> +                     -DDEBUG_XEN" \
> +             --extra-ldflags="-L$(XEN_ROOT)/tools/libxc 
> -L$(XEN_ROOT)/tools/xenstore" \
> +             --disable-werror \
> +             --disable-sdl \
> +             --disable-kvm \
> +             --disable-gtk \
> +             --disable-fdt \
> +             --disable-bluez \
> +             --disable-libusb \
> +             --disable-slirp \
> +             --disable-pie \
> +             --disable-docs \
> +             --disable-vhost-net \
> +             --disable-spice \
> +             --disable-guest-agent \
> +             --audio-drv-list= \
> +             --disable-smartcard-nss \
> +             --enable-stubdom \
> +             --disable-vnc \
> +             --disable-spice \
> +             --enable-trace-backend=stderr \
> +             --disable-curses \
> +             --python=$(PYTHON) \
> +             --prefix=
> +
> +.PHONY:qemu-build
> +qemu-build: qemu-build/Makefile
> +qemu-build/i386-softmmu/qemu-system-i386: qemu-build
> +     $(MAKE) -C qemu-build
> diff --git a/stubdom-linux/qemu-configure.patch 
> b/stubdom-linux/qemu-configure.patch
> new file mode 100644
> index 0000000..b93132d
> --- /dev/null
> +++ b/stubdom-linux/qemu-configure.patch
> @@ -0,0 +1,47 @@
> +--- a/configure      2015-01-21 23:48:23.763333326 -0500
> ++++ b/configure      2015-01-21 23:52:30.326666664 -0500
> +@@ -300,6 +300,7 @@
> + libusb=""
> + usb_redir=""
> + glx=""
> ++stubdom="no"
> + zlib="yes"
> + lzo="no"
> + snappy="no"
> +@@ -1021,6 +1022,8 @@
> +   ;;
> +   --enable-usb-redir) usb_redir="yes"
> +   ;;
> ++  --enable-stubdom) stubdom="yes"
> ++  ;;
> +   --disable-zlib-test) zlib="no"
> +   ;;
> +   --enable-lzo) lzo="yes"
> +@@ -1329,6 +1332,7 @@
> +   --enable-usb-redir       enable usb network redirection support
> +   --enable-lzo             enable the support of lzo compression library
> +   --enable-snappy          enable the support of snappy compression library
> ++  --enable-stubdom         enable building the ioemu-stubdom
> +   --disable-guest-agent    disable building of the QEMU Guest Agent
> +   --enable-guest-agent     enable building of the QEMU Guest Agent
> +   --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
> +@@ -4122,6 +4126,7 @@
> +     echo "Target Sparc Arch $sparc_cpu"
> + fi
> + echo "xen support       $xen"
> ++echo "stubdom support   $stubdom"
> + echo "brlapi support    $brlapi"
> + echo "bluez  support    $bluez"
> + echo "Documentation     $docs"
> +@@ -4553,6 +4558,11 @@
> +   echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
> + fi
> + 
> ++# stubdom support
> ++if test "$stubdom" = "yes"; then
> ++  echo "CONFIG_STUBDOM=y" >> $config_host_mak
> ++fi
> ++
> + echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
> + if test "$coroutine_pool" = "yes" ; then
> +   echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
> diff --git a/stubdom-linux/qemu-xen-common.patch 
> b/stubdom-linux/qemu-xen-common.patch
> new file mode 100644
> index 0000000..b473e36
> --- /dev/null
> +++ b/stubdom-linux/qemu-xen-common.patch
> @@ -0,0 +1,12 @@
> +--- a/xen-common.c   2015-01-25 20:42:36.329999998 -0500
> ++++ b/xen-common.c   2015-01-25 20:43:20.346666663 -0500
> +@@ -92,7 +92,8 @@
> +         exit(1);
> +     }
> + 
> +-    snprintf(path, sizeof (path), "device-model/%u/state", xen_domid);
> ++    snprintf(path, sizeof (path),
> ++             "/local/domain/0/device-model/%u/state", xen_domid);

Even if this counts as a workaround, I think it could go upstream in
QEMU.


> +     if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {
> +         fprintf(stderr, "error recording dm state\n");
> +         exit(1);
> diff --git a/stubdom-linux/qemu-xen-h.patch b/stubdom-linux/qemu-xen-h.patch
> new file mode 100644
> index 0000000..262b1d1
> --- /dev/null
> +++ b/stubdom-linux/qemu-xen-h.patch
> @@ -0,0 +1,18 @@
> +--- a/include/hw/xen/xen.h   2015-01-21 23:54:36.856666662 -0500
> ++++ b/include/hw/xen/xen.h   2015-01-21 23:55:39.356666667 -0500
> +@@ -28,6 +28,15 @@
> +     return xen_allowed;
> + }
> + 
> ++static inline int xen_stubdom_enable(void)
> ++{
> ++#ifdef CONFIG_STUBDOM
> ++    return 1;
> ++#else
> ++    return 0;
> ++#endif
> ++}

As the STUBDOM related changes are small, I think we could avoid to
introduce this config option altogether.

Maybe we could figure out that we are running as stubdom with a runtime
option, like a command line argument, something on xenstore or even our
own domain id.


> + int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
> + void xen_piix3_set_irq(void *opaque, int irq_num, int level);
> + void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int 
> len);
> diff --git a/stubdom-linux/qemu-xen-hvm.patch 
> b/stubdom-linux/qemu-xen-hvm.patch
> new file mode 100644
> index 0000000..ac6a53f
> --- /dev/null
> +++ b/stubdom-linux/qemu-xen-hvm.patch
> @@ -0,0 +1,36 @@
> +--- a/xen-hvm.c      2015-01-21 22:32:42.999999995 -0500
> ++++ b/xen-hvm.c      2015-01-21 22:35:17.633333330 -0500
> +@@ -1008,6 +1008,10 @@
> +     state->wakeup.notify = xen_wakeup_notifier;
> +     qemu_register_wakeup_notifier(&state->wakeup);
> + 
> ++    if (xen_stubdom_enable()) {
> ++        xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_DM_DOMAIN, 
> DOMID_SELF);
> ++    }
> ++
> +     xc_get_hvm_param(xen_xc, xen_domid, HVM_PARAM_IOREQ_PFN, &ioreq_pfn);
> +     DPRINTF("shared page at pfn %lx\n", ioreq_pfn);
> +     state->shared_page = xc_map_foreign_range(xen_xc, xen_domid, 
> XC_PAGE_SIZE,
> +@@ -1063,6 +1067,7 @@
> +     memory_listener_register(&state->memory_listener, 
> &address_space_memory);
> +     state->log_for_dirtybit = NULL;
> + 
> ++#ifndef CONFIG_STUBDOM
> +     /* Initialize backend core & drivers */
> +     if (xen_be_init() != 0) {
> +         fprintf(stderr, "%s: xen backend core setup failed\n", 
> __FUNCTION__);
> +@@ -1071,6 +1076,14 @@
> +     xen_be_register("console", &xen_console_ops);
> +     xen_be_register("vkbd", &xen_kbdmouse_ops);
> +     xen_be_register("qdisk", &xen_blkdev_ops);
> ++#else
> ++    xenstore = xs_daemon_open();
> ++    if (!xenstore) {
> ++        xen_be_printf(NULL, 0, "can't connect to xenstored\n");
> ++        return -1;
> ++    }
> ++#endif
> ++
> +     xen_read_physmap(state);
> + 
> +     return 0;
> -- 
> 1.8.5.5
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.