RFC Linux based stub-domain
cover RFC Linux based stub-domain
Hi all,
Here is the long overdue patch series to bring support for a Linux based stubdom which will enable to use QEMU upstream as device model in a stubdom.
The first three patches will provide the necessary to build Linux and a disk image for the stubdomain itself. This is created in a separated directory "stubdom-linux". Calling make in this directory will build Linux and the disk. Then a make install will copy the two files to the same directory as the MiniOS use.
The last three patches are the libxl support. There is a field called "stubdomain_version" which is automatically set to the appropriate value, depending on the QEMU version used. It call also be set from VM config file.
So, to start a Linux stubdomain, just set those two variables and it shoud start:device_model_stubdomain_override = 1device_model_version = "qemu-xen"
There is few things that does not have support yet and are on my todo list:
- video output
- save/restore
So for now, we have the network and the console and the disk of the domain.
Regards,
Anthony PERARD (6):
linux-stubdomain: Compile QEMU
linux-stubdomain: Compile Linux
linux-stubdomain: Build a disk image.
libxl: Add "stubdomain_version" to domain_build_info.
libxl: Handle Linux stubdomain specifique QEMU option.
libxl: Build the domain with a Linux based stubdomain.
stubdom-linux/.gitignore | 5 + ...heck-for-xen_initial_domain-in-privcmd_io.patch | 39 + stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch | 36 + stubdom-linux/Makefile | 83 ++ stubdom-linux/extra/initscript | 40 + stubdom-linux/extra/qemu-ifup | 7 + stubdom-linux/mk-ramdisk-common | 178 +++ stubdom-linux/mk-ramdisk-ioemu | 124 ++ stubdom-linux/stubdom-linux-config-64b | 1185 ++++++++++++++++++++ tools/libxl/libxl.c | 25 +- tools/libxl/libxl_create.c | 41 +- tools/libxl/libxl_dm.c | 178 ++- tools/libxl/libxl_internal.c | 22 + tools/libxl/libxl_internal.h | 4 + tools/libxl/libxl_types.idl | 7 + tools/libxl/xl_cmdimpl.c | 14 + 16 files changed, 1944 insertions(+), 44 deletions(-) create mode 100644 stubdom-linux/.gitignore create mode 100644 stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch create mode 100644 stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch create mode 100644 stubdom-linux/Makefile create mode 100644 stubdom-linux/extra/initscript create mode 100644 stubdom-linux/extra/qemu-ifup create mode 100755 stubdom-linux/mk-ramdisk-common create mode 100755 stubdom-linux/mk-ramdisk-ioemu create mode 100644 stubdom-linux/stubdom-linux-config-64b
Signature · 1 line
Anthony PERARD
RFC 1/6 linux-stubdomain: Compile QEMU
This patch add a Makefile which is able to compile QEMU for a stubdomain base on a Linux kernel.
--- stubdom-linux/Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 stubdom-linux/Makefile
stubdom-linux/Makefile new file +49 -0
@@ -0,0 +1,49 @@ +XEN_ROOT = $(CURDIR)/.. + +include $(XEN_ROOT)/Config.mk + +# Qemu tree used +QEMU_TREE=git://xenbits.xen.org/people/aperard/qemu-dm.git +QEMU_BRANCH=origin/stubdom-preview1 + +all: + +qemu-remote: + export GIT=$(GIT); \ + $(XEN_ROOT)/scripts/git-checkout.sh $(QEMU_TREE) $(QEMU_BRANCH) qemu-remote + +qemu-build/Makefile: qemu-remote + 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-fdt \ + --disable-bluez \ + --disable-slirp \ + --disable-nptl \ + --disable-pie \ + --disable-docs \ + --disable-vhost-net \ + --disable-spice \ + --disable-guest-agent \ + --audio-drv-list= \ + --audio-card-list= \ + --disable-smartcard-nss \ + --disable-opengl \ + --enable-stubdom \ + --disable-vnc \ + --enable-trace-backend=stderr \ + --disable-curses \ + --prefix= + +qemu-build/i386-softmmu/qemu-system-i386: qemu-build/Makefile + $(MAKE) -C qemu-build
Signature · 1 line
Anthony PERARD
RFC 2/6 linux-stubdomain: Compile Linux
In reply to Anthony PERARDThis patch add rules to the Makefile to retrieve Linux and build a minimal kernel for the stubdomain.
In order to work as a stubdomain, two patches are applied to the source of Linux.
--- stubdom-linux/.gitignore | 3 + ...heck-for-xen_initial_domain-in-privcmd_io.patch | 39 + stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch | 36 + stubdom-linux/Makefile | 22 +- stubdom-linux/stubdom-linux-config-64b | 1185 ++++++++++++++++++++ 5 files changed, 1284 insertions(+), 1 deletion(-) create mode 100644 stubdom-linux/.gitignore create mode 100644 stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch create mode 100644 stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch create mode 100644 stubdom-linux/stubdom-linux-config-64b
stubdom-linux/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +/linux-*.tar.xz +/linux-*/ +/vmlinuz-stubdom
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +39 -0
@@ -0,0 +1,39 @@ +From 94d3502e70882a78ec3abb22379a79afc1292fb0 Mon Sep 17 00:00:00 2001 +From: Anthony PERARD <[email protected]> +Date: Fri, 1 Jun 2012 15:46:39 +0100 +Subject: [PATCH 1/2] xen: Don't check for xen_initial_domain in + privcmd_ioctl_mmap*. + +This prevent a stubdom from working. + +--- + drivers/xen/privcmd.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c +index ccee0f1..a8d71a3 100644 +--- a/drivers/xen/privcmd.c ++++ b/drivers/xen/privcmd.c +@@ -196,9 +196,6 @@ static long privcmd_ioctl_mmap(void __user *udata) + LIST_HEAD(pagelist); + struct mmap_mfn_state state; + +- if (!xen_initial_domain()) +- return -EPERM; +- + if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd))) + return -EFAULT; + +@@ -286,9 +283,6 @@ static long privcmd_ioctl_mmap_batch(void __user *udata) + LIST_HEAD(pagelist); + struct mmap_batch_state state; + +- if (!xen_initial_domain()) +- return -EPERM; +- + if (copy_from_user(&m, udata, sizeof(m))) + return -EFAULT; + +-- +Anthony PERARD +
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +36 -0
@@ -0,0 +1,36 @@ +From 61cd574f29f41046f1c709cfa9da118156babf83 Mon Sep 17 00:00:00 2001 +From: Anthony PERARD <[email protected]> +Date: Fri, 1 Jun 2012 15:47:01 +0100 +Subject: [PATCH 2/2] fix/remap_area_mfn_pte_fn + +--- + arch/x86/xen/mmu.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c +index 69f5857..999fc82 100644 +--- a/arch/x86/xen/mmu.c ++++ b/arch/x86/xen/mmu.c +@@ -2315,7 +2315,18 @@ static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token, + unsigned long addr, void *data) + { + struct remap_data *rmd = data; +- pte_t pte = pte_mkspecial(pfn_pte(rmd->mfn++, rmd->prot)); ++ ++ /* Use the native_make_pte function because we are sure we don't ++ * have to do any pfn->mfn translations but at the same time we ++ * could in a stubdom so xen_initial_domain() would return false. */ ++ pte_t pte = pte_mkspecial(native_make_pte(((phys_addr_t)(rmd->mfn++) << PAGE_SHIFT) ++ | massage_pgprot(rmd->prot))); ++ pteval_t val = pte_val_ma(pte); ++ ++ if (pat_enabled && !WARN_ON(val & _PAGE_PAT)) { ++ if ((val & (_PAGE_PCD | _PAGE_PWT)) == _PAGE_PWT) ++ val = (val & ~(_PAGE_PCD | _PAGE_PWT)) | _PAGE_PAT; ++ } + + rmd->mmu_update->ptr = virt_to_machine(ptep).maddr; + rmd->mmu_update->val = pte_val_ma(pte); +-- +Anthony PERARD +
stubdom-linux/Makefile +21 -1
@@ -2,11 +2,14 @@ XEN_ROOT = $(CURDIR)/.. include $(XEN_ROOT)/Config.mk +# Linux Kernel version used +LINUX_V=linux-3.4.13 + # Qemu tree used QEMU_TREE=git://xenbits.xen.org/people/aperard/qemu-dm.git QEMU_BRANCH=origin/stubdom-preview1 -all: +all: vmlinuz-stubdom qemu-remote: export GIT=$(GIT); \
@@ -47,3 +50,20 @@ qemu-build/Makefile: qemu-remote qemu-build/i386-softmmu/qemu-system-i386: qemu-build/Makefile $(MAKE) -C qemu-build + +$(LINUX_V).tar.xz: + wget --timestamping ftp://ftp.kernel.org/pub/linux/kernel/v3.x/$(LINUX_V).tar.xz + +$(LINUX_V)/Makefile $(LINUX_V)/.config: $(LINUX_V).tar.xz + rm -rf $(LINUX_V) + tar xf $(LINUX_V).tar.xz + # Temp patches + patch -d $(LINUX_V) -p1 -i ../0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch + patch -d $(LINUX_V) -p1 -i ../0002-fix-remap_area_mfn_pte_fn.patch + cp stubdom-linux-config-64b $(LINUX_V)/.config + +$(LINUX_V)/arch/x86/boot/bzImage: $(LINUX_V)/.config + $(MAKE) -C $(LINUX_V) + +vmlinuz-stubdom: $(LINUX_V)/arch/x86/boot/bzImage + cp -f $^ $@
stubdom-linux/stubdom-linux-config-64b new file +1185 -0
1,185 lines not on this page · raw message
Signature · 1 line
Anthony PERARD
Re: [RFC 2/6] linux-stubdomain: Compile Linux
Quoted 32 lines · Anthony PERARD
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +26
-0@@ -0,0 +1,39 @@ +From 94d3502e70882a78ec3abb22379a79afc1292fb0 Mon Sep 17 00:00:00 2001 +From: Anthony PERARD <[email protected]> +Date: Fri, 1 Jun 2012 15:46:39 +0100 +Subject: [PATCH 1/2] xen: Don't check for xen_initial_domain in + privcmd_ioctl_mmap*. + +This prevent a stubdom from working. + +--- + drivers/xen/privcmd.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c +index ccee0f1..a8d71a3 100644 +--- a/drivers/xen/privcmd.c ++++ b/drivers/xen/privcmd.c +@@ -196,9 +196,6 @@ static long privcmd_ioctl_mmap(void __user *udata) + LIST_HEAD(pagelist); + struct mmap_mfn_state state; + +- if (!xen_initial_domain()) +- return -EPERM; +- + if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd))) + return -EFAULT; +
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch line 36
Quoted 10 lines
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +10
-0+@@ -286,9 +283,6 @@ static long privcmd_ioctl_mmap_batch(void __user *udata) + LIST_HEAD(pagelist); + struct mmap_batch_state state; + +- if (!xen_initial_domain()) +- return -EPERM; +- + if (copy_from_user(&m, udata, sizeof(m))) + return -EFAULT; +
I think you should submit both patches separately for inclusion in the Linux kernel.
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch line 4
Quoted 12 lines
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +2
-0+Anthony PERARD +stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +4
-0@@ -0,0 +1,36 @@ +From 61cd574f29f41046f1c709cfa9da118156babf83 Mon Sep 17 00:00:00 2001 +From: Anthony PERARD <[email protected]> +Date: Fri, 1 Jun 2012 15:47:01 +0100 +Subject: [PATCH 2/2] fix/remap_area_mfn_pte_fn
I think we need a better commit message
Quoted 9 lines
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +9
-0+--- + arch/x86/xen/mmu.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c +index 69f5857..999fc82 100644 +--- a/arch/x86/xen/mmu.c ++++ b/arch/x86/xen/mmu.c +@@ -2315,7 +2315,18 @@ static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch line 24
Quoted 10 lines
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +10
-0+ unsigned long addr, void *data) + { + struct remap_data *rmd = data; +- pte_t pte = pte_mkspecial(pfn_pte(rmd->mfn++, rmd->prot)); ++ ++ /* Use the native_make_pte function because we are sure we don't ++ * have to do any pfn->mfn translations but at the same time we ++ * could in a stubdom so xen_initial_domain() would return false. */ ++ pte_t pte = pte_mkspecial(native_make_pte(((phys_addr_t)(rmd->mfn++) << PAGE_SHIFT) ++ | massage_pgprot(rmd->prot)));
This change is OK. The stubdom part of the comment is a bit confusing and would benefit from a clearer explanation.
Also the indentation is wrong.
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch line 30
Quoted 6 lines
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +6
-0++ pteval_t val = pte_val_ma(pte); ++ ++ if (pat_enabled && !WARN_ON(val & _PAGE_PAT)) { ++ if ((val & (_PAGE_PCD | _PAGE_PWT)) == _PAGE_PWT) ++ val = (val & ~(_PAGE_PCD | _PAGE_PWT)) | _PAGE_PAT; ++ }
Konrad disabled PAT in upstream kernels, see:
commit 8eaffa67b43e99ae581622c5133e20b0f48bcef1
Author: Konrad Rzeszutek Wilk <[email protected]> Date: Fri Feb 10 09:16:27 2012 -0500
xen/pat: Disable PAT support for now.
Re: [RFC 2/6] linux-stubdomain: Compile Linux
Quoted 39 lines · Stefano Stabellini
Quoted 38 lines · Anthony PERARD
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +32
-0@@ -0,0 +1,39 @@ +From 94d3502e70882a78ec3abb22379a79afc1292fb0 Mon Sep 17 00:00:00 2001 +From: Anthony PERARD <[email protected]> +Date: Fri, 1 Jun 2012 15:46:39 +0100 +Subject: [PATCH 1/2] xen: Don't check for xen_initial_domain in + privcmd_ioctl_mmap*. + +This prevent a stubdom from working. + +--- + drivers/xen/privcmd.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c +index ccee0f1..a8d71a3 100644 +--- a/drivers/xen/privcmd.c ++++ b/drivers/xen/privcmd.c +@@ -196,9 +196,6 @@ static long privcmd_ioctl_mmap(void __user *udata) + LIST_HEAD(pagelist); + struct mmap_mfn_state state; + +- if (!xen_initial_domain()) +- return -EPERM; +- + if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd))) + return -EFAULT; + +@@ -286,9 +283,6 @@ static long privcmd_ioctl_mmap_batch(void __user *udata) + LIST_HEAD(pagelist); + struct mmap_batch_state state; + +- if (!xen_initial_domain()) +- return -EPERM;
Quoted 8 lines
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch line 36
Quoted 4 lines
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +4
-0+- + if (copy_from_user(&m, udata, sizeof(m))) + return -EFAULT; +I think you should submit both patches separately for inclusion in the Linux kernel.
Definitely.
Should we remove the check for initial_domain all together and leave this permission to be handle by Xen? Or should we try to find out if the function is called in a stubdom/dom0 ?
Quoted 6 lines
Quoted 6 lines
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +2
-0+Anthony PERARD +stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +0
-1--- /dev/null
Quoted 8 lines
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch line 4
Quoted 6 lines
+++
b/stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patchstubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +4
-0@@ -0,0 +1,36 @@ +From 61cd574f29f41046f1c709cfa9da118156babf83 Mon Sep 17 00:00:00 2001 +From: Anthony PERARD <[email protected]> +Date: Fri, 1 Jun 2012 15:47:01 +0100 +Subject: [PATCH 2/2] fix/remap_area_mfn_pte_fnI think we need a better commit message
Yes, this is definitely not a patch title/comment.
Quoted 14 lines
Quoted 14 lines
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +14
-0+--- + arch/x86/xen/mmu.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c +index 69f5857..999fc82 100644 +--- a/arch/x86/xen/mmu.c ++++ b/arch/x86/xen/mmu.c +@@ -2315,7 +2315,18 @@ static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token, + unsigned long addr, void *data) + { + struct remap_data *rmd = data; +- pte_t pte = pte_mkspecial(pfn_pte(rmd->mfn++, rmd->prot)); ++
Quoted 8 lines
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch line 24
Quoted 5 lines
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +5
-0++ /* Use the native_make_pte function because we are sure we don't ++ * have to do any pfn->mfn translations but at the same time we ++ * could in a stubdom so xen_initial_domain() would return false. */ ++ pte_t pte = pte_mkspecial(native_make_pte(((phys_addr_t)(rmd->mfn++) << PAGE_SHIFT) ++ | massage_pgprot(rmd->prot)));This change is OK. The stubdom part of the comment is a bit confusing and would benefit from a clearer explanation.
OK, I try to clean the explanation.
Quoted 18 lines
Also the indentation is wrong.
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch line 30
Quoted 6 lines
stubdom-linux/0002-fix-remap_area_mfn_pte_fn.patch new file +6
-0++ pteval_t val = pte_val_ma(pte); ++ ++ if (pat_enabled && !WARN_ON(val & _PAGE_PAT)) { ++ if ((val & (_PAGE_PCD | _PAGE_PWT)) == _PAGE_PWT) ++ val = (val & ~(_PAGE_PCD | _PAGE_PWT)) | _PAGE_PAT; ++ }Konrad disabled PAT in upstream kernels, see:
commit
8eaffa67b43e99ae581622c5133e20b0f48bcef1Author: Konrad Rzeszutek Wilk <[email protected]> Date: Fri Feb 10 09:16:27 2012 -0500xen/pat: Disable PAT support for now.
Signature · 1 line
Anthony PERARD
Re: [RFC 2/6] linux-stubdomain: Compile Linux
Quoted 49 lines · Anthony PERARD
Quoted 39 lines · Stefano Stabellini
Quoted 38 lines · Anthony PERARD
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +32
-0@@ -0,0 +1,39 @@ +From 94d3502e70882a78ec3abb22379a79afc1292fb0 Mon Sep 17 00:00:00 2001 +From: Anthony PERARD <[email protected]> +Date: Fri, 1 Jun 2012 15:46:39 +0100 +Subject: [PATCH 1/2] xen: Don't check for xen_initial_domain in + privcmd_ioctl_mmap*. + +This prevent a stubdom from working. + +--- + drivers/xen/privcmd.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c +index ccee0f1..a8d71a3 100644 +--- a/drivers/xen/privcmd.c ++++ b/drivers/xen/privcmd.c +@@ -196,9 +196,6 @@ static long privcmd_ioctl_mmap(void __user *udata) + LIST_HEAD(pagelist); + struct mmap_mfn_state state; + +- if (!xen_initial_domain()) +- return -EPERM; +- + if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd))) + return -EFAULT; + +@@ -286,9 +283,6 @@ static long privcmd_ioctl_mmap_batch(void __user *udata) + LIST_HEAD(pagelist); + struct mmap_batch_state state; + +- if (!xen_initial_domain()) +- return -EPERM;Quoted 8 lines
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch line 36
Quoted 4 lines
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +4
-0+- + if (copy_from_user(&m, udata, sizeof(m))) + return -EFAULT; +I think you should submit both patches separately for inclusion in the Linux kernel.
Quoted 4 lines
Definitely.
Should we remove the check forinitial_domainall together and leave this permission to be handle by Xen? Or should we try to find out if the function is called in a stubdom/dom0 ?
This has already been fixed upstream (Linux 3.8). The check should never have been in the Linux kernel as it is the hypervisor's responsibility to check hypercall permissions, and Xen does this correctly.
Signature · 2 lines
Daniel De Graaf National Security Agency
Re: [RFC 2/6] linux-stubdomain: Compile Linux
In reply to Anthony PERARDQuoted 15 lines · Anthony PERARD, le Mon 22 Apr 2013 14:46:29 +0100, a écrit :
Quoted 6 lines
Quoted 6 lines
+@@ -286,9 +283,6 @@ static long
privcmd_ioctl_mmap_batch(void __user *udata)stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +5
-0+ LIST_HEAD(pagelist); + struct mmap_batch_state state; + +- if (!xen_initial_domain()) +- return -EPERM;Quoted 8 lines
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch line 36
Quoted 4 lines
+-
stubdom-linux/0001-xen-Don-t-check-for-xen_initial_domain-in-privcmd_io.patch new file +3
-0+ if (copy_from_user(&m, udata, sizeof(m))) + return -EFAULT; +I think you should submit both patches separately for inclusion in the Linux kernel.
Quoted 3 lines
Definitely.
Should we remove the check forinitial_domainall together and leave this permission to be handle by Xen?
I would tend to say so. Since it's a matter of hypervisor security, Xen is supposed to check that already anyway, isn't it?
Samuel
RFC 3/6 linux-stubdomain: Build a disk image.
In reply to Anthony PERARDThis patch build a disk image intend to be mounted as rootfs by the stub-domain. It is build using the 'debugfs' tool and make a ext2 fs.
--- stubdom-linux/.gitignore | 2 + stubdom-linux/Makefile | 16 +++- stubdom-linux/extra/initscript | 40 +++++++++ stubdom-linux/extra/qemu-ifup | 7 ++ stubdom-linux/mk-ramdisk-common | 178 ++++++++++++++++++++++++++++++++++++++++ stubdom-linux/mk-ramdisk-ioemu | 124 ++++++++++++++++++++++++++++ 6 files changed, 366 insertions(+), 1 deletion(-) create mode 100644 stubdom-linux/extra/initscript create mode 100644 stubdom-linux/extra/qemu-ifup create mode 100755 stubdom-linux/mk-ramdisk-common create mode 100755 stubdom-linux/mk-ramdisk-ioemu
stubdom-linux/.gitignore +2 -0
@@ -1,3 +1,5 @@ /linux-*.tar.xz /linux-*/ /vmlinuz-stubdom +/initramfs +/stubdom-disk.img
stubdom-linux/Makefile +15 -1
@@ -9,7 +9,13 @@ LINUX_V=linux-3.4.13 QEMU_TREE=git://xenbits.xen.org/people/aperard/qemu-dm.git QEMU_BRANCH=origin/stubdom-preview1 -all: vmlinuz-stubdom +# Stubdom disk content +STUBDOM_DISK_FILE= \ + qemu-build/i386-softmmu/qemu-system-i386 \ + extra/initscript \ + extra/qemu-ifup + +all: stubdom-disk.img vmlinuz-stubdom qemu-remote: export GIT=$(GIT); \
@@ -67,3 +73,11 @@ $(LINUX_V)/arch/x86/boot/bzImage: $(LINUX_V)/.config vmlinuz-stubdom: $(LINUX_V)/arch/x86/boot/bzImage cp -f $^ $@ + +stubdom-disk.img: mk-ramdisk-common mk-ramdisk-ioemu $(STUBDOM_DISK_FILE) + env -u MAKELEVEL -u MAKEFLAGS -u MFLAGS ./mk-ramdisk-ioemu + chmod a-w $@ + +install: stubdom-disk.img vmlinuz-stubdom + cp -f vmlinuz-stubdom $(DESTDIR)/usr/lib/xen/boot/ + cp -f stubdom-disk.img $(DESTDIR)/usr/lib/xen/boot/
stubdom-linux/extra/initscript new file +40 -0
@@ -0,0 +1,40 @@ +#!/bin/busybox sh + +_initscript_panic() { + sleep 10 +} + +trap _initscript_panic 0 + +set -e +set -x +mount -t sysfs /sys /sys +mount -t proc /proc /proc +mount -t xenfs -o nodev /proc/xen /proc/xen + +# TODO: Check if there is network for the vm before doing this +if test -e /sys/class/net/eth0; then + ip link set eth0 address fe:ff:ff:ff:ff:fe + ip addr flush eth0 + ip link set eth0 up + brctl addbr br0 + brctl addif br0 eth0 + ip link set br0 up +else + echo "No network interface named eth0." + ls -l /sys/class/net/ +fi + +# TODO Could probably to xenstore-read `xenstore-read vm`/image/dmargs +# because /local/domain/$domid is probably the root for relative path +domid=$(xenstore-read target) +dom_path="/local/domain/$domid" +vm_path=$(xenstore-read "$dom_path/vm") +dm_args=$(xenstore-read "$vm_path/image/dmargs") + +( sleep 30; free ) & +( sleep 60; free ) & +#( sleep 120; ip addr ) & +( sleep 120; free ) & +free +/bin/qemu $dm_args
stubdom-linux/extra/qemu-ifup new file +7 -0
@@ -0,0 +1,7 @@ +#! /bin/busybox sh + +ip link set "$1" down +ip link set "$1" address fe:ff:ff:ff:ff:fd +ip addr flush "$1" +brctl addif br0 "$1" +ip link set "$1" up
stubdom-linux/mk-ramdisk-common new file +178 -0
178 lines not on this page · raw message
stubdom-linux/mk-ramdisk-ioemu new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
Anthony PERARD
Re: [RFC 3/6] linux-stubdomain: Build a disk image.
Quoted 2 lines · Anthony PERARD
This patch build a disk image intend to be mounted as rootfs by the stub-domain. It is build using the 'debugfs' tool and make a ext2 fs.
You seem to have some vestigial code for building a cpio style initramfs -- what was wrong with that approach? On the face of it that would seem simpler and less "hacky" than the tricks you have to play with debugfs.
[...]
stubdom-linux/extra/initscript line 1
Quoted 7 lines
stubdom-linux/extra/initscript new file +1
-0@@ -0,0 +1,40 @@ +#!/bin/busybox sh
This can become the more normal /bin/sh if you put the appropriate symlink in the initrd?
stubdom-linux/extra/initscript line 5
Quoted 4 lines
stubdom-linux/extra/initscript new file +4
-0+ +_initscript_panic() { + sleep 10 +}
Erm...
Quoted 22 lines
stubdom-linux/extra/initscript new file +22
-0+trap _initscript_panic 0 + +set -e +set -x +mount -t sysfs /sys /sys +mount -t proc /proc /proc +mount -t xenfs -o nodev /proc/xen /proc/xen + +# TODO: Check if there is network for the vm before doing this +if test -e /sys/class/net/eth0; then + ip link set eth0 address fe:ff:ff:ff:ff:fe + ip addr flush eth0 + ip link set eth0 up + brctl addbr br0 + brctl addif br0 eth0 + ip link set br0 up +else + echo "No network interface named eth0." + ls -l /sys/class/net/ +fi + +# TODO Could probably to xenstore-read `xenstore-read vm`/image/dmargs
stubdom-linux/extra/initscript line 38
Quoted 10 lines
stubdom-linux/extra/initscript new file +10
-0+# because /local/domain/$domid is probably the root for relative path +domid=$(xenstore-read target) +dom_path="/local/domain/$domid" +vm_path=$(xenstore-read "$dom_path/vm") +dm_args=$(xenstore-read "$vm_path/image/dmargs") + +( sleep 30; free ) & +( sleep 60; free ) & +#( sleep 120; ip addr ) & +( sleep 120; free ) &
Erm....
Quoted 8 lines
stubdom-linux/extra/initscript new file +2
-0+free +/bin/qemu $dm_argsstubdom-linux/extra/qemu-ifup new file +0
-0
stubdom-linux/extra/qemu-ifup line 7
Quoted 7 lines
stubdom-linux/extra/qemu-ifup new file +7
-0@@ -0,0 +1,7 @@ +#! /bin/busybox sh + +ip link set "$1" down +ip link set "$1" address fe:ff:ff:ff:ff:fd +ip addr flush "$1" +brctl addif br0 "$1" +ip link set "$1" up
I don't think this will work for domains with multiple network devices. e.g. if you want vifX.0 on xenbr0 and vifX.1 on xenbr0 in the dom0 backend this will cause them both to get put on the same bridge inside the stubdom and therefore surface as a single device in dom0.
stubdom-linux/mk-ramdisk-common line 3
Quoted 9 lines
stubdom-linux/mk-ramdisk-common new file +3
-0@@ -0,0 +1,178 @@ +#!/bin/bash +# +# This a simple implementaton of mkinitrd
implementation
Quoted 22 lines
stubdom-linux/mk-ramdisk-common new file +22
-0+ + +# Set the umask. For iscsi, the initrd can contain platintext +# password (chap secret), so only allow read by owner. +umask 022 + +TMPDIR="/tmp" +PROBE="yes" +MNTIMAGE="`pwd`/initramfs/" +IMAGE="./initramfs.cpio" +verbose="" +: ${debug:=false} +case $debug in + true|false) ;; + *) + echo '$debug need to be true or false.' + exit 1 + ;; +esac +$debug && verbose='-v' + +DSO_DEPS=""
stubdom-linux/mk-ramdisk-common line 35
Quoted 10 lines
stubdom-linux/mk-ramdisk-common new file +10
-0+LDSO="" +get_dso_deps() { + bin="$1" ; shift + DSO_DEPS="" + + declare -a FILES + declare -a NAMES + + # this is a hack, but the only better way requires binutils or elfutils + # be installed. i.e., we need readelf to find the interpretter.
binutils will surely be installed while building Xen, won't it?
"interpreter"
stubdom-linux/mk-ramdisk-common line 88
Quoted 11 lines
[...]
stubdom-linux/mk-ramdisk-common new file +9
-0+ case "$FILE" in + /lib*) + TLIBDIR=`echo "$FILE" | sed 's,\(/lib[^/]*\)/.*$,\1,'` + BASE=`basename "$FILE"` + # Prefer nosegneg libs over direct segment accesses on i686. + if [ -f "$TLIBDIR/i686/nosegneg/$BASE" ]; then + FILE="$TLIBDIR/i686/nosegneg/$BASE" + # Otherwise, prefer base libraries rather than their optimized + # variants.
Do we not want optimised e.g. SDL libraries if available, or other libraries related to the provision of things like VNC which are the sorts of instruction hungry stuff that I'd expect to benefit from additional clever instructions...
[...]
stubdom-linux/mk-ramdisk-common
Quoted 6 lines
stubdom-linux/mk-ramdisk-common new file +6
-0+# this cp keep the link to ld-2.11.x.so +if test "`uname -m`" = x86_64; then + cp --no-dereference "/lib/ld-linux-x86-64.so.2" "$MNTIMAGE/lib/ld-linux-x86-64.so.2" +else + cp --no-dereference "/lib/ld-linux.so.2" "$MNTIMAGE/lib/ld-linux.so.2" +fi
Didn't you jump through some hoops earlier to find the actual dynamic interpreter?
Quoted 47 lines
stubdom-linux/mk-ramdisk-common new file +47
-0+try_make_disk=true +if $try_make_disk; then + stubdom_disk=stubdom-disk.img + rm -f $stubdom_disk + dd if=/dev/null of=$stubdom_disk bs=1M seek=40 + mkfs.ext2 -q -F -m0 $stubdom_disk + + cd "$MNTIMAGE" + stubdom_disk="../$stubdom_disk" + new_link(){ + image=$1 + link=$2 + target=`readlink $link` + dir=`dirname $link` + dir=${dir#./} + name_link=$(basename $link) + dir_inode=$(debugfs -R "stat /$dir" $image 2>/dev/null | + sed -nr 's/^Inode: ([[:digit:]]+)[[:space:]].*/\1/p') + test "$dir_inode" || echo 'no dir inode found' + test "$dir_inode" + while true; do + free_inode=$(debugfs -R "find_free_inode $dir_inode 0777" -w $image 2>/dev/null | + sed -nr 's/^Free inode found: ([[:digit:]]+)$/\1/p') + undel_output="$(debugfs -R "undel <$free_inode> /$dir/$name_link" -w $image 2>&1)" + if grep -q "make_link: No free space in the directory" <<<"$undel_output"; then + debugfs -R "expand_dir /$dir" -w $image 2>/dev/null + else + break + fi + done + debugfs -f <( + echo "cd /$dir" + echo "set_inode_field $name_link mode 0120777" + echo "set_inode_field $name_link size ${#target}" + # TODO still need to write the link into blocks + if test ${#target} -lt $((12*4)); then + # write into direct block + blockn=0 + while test "$target"; do + t="${target:0:4}" + target="${target:4}" + #convert a four charactere string into hexa + val=$(printf '0x%02x%02x%02x%02x\n' \'${t:3:1} \'${t:2:1} \'${t:1:1} \'${t:0:1}) + echo "set_inode_field $name_link block[$blockn] $val" + blockn=$((blockn+1)) + done + else
stubdom-linux/mk-ramdisk-common
Quoted 10 lines
stubdom-linux/mk-ramdisk-common new file +10
-0+ # write into a block + echo >&2 ".... write into block not implemented" + fi + ) -w $image >/dev/null 2>/dev/null + } + # TODO Should check for "copy_file: Could not allocate block in ext2 filesystem" + debugfs -f <(find . \ + \( -type d \! -name . -printf 'cd /\nmkdir %h/%f\n' \) \ + -o \( -type f -printf 'cd /%h\nwrite %h/%f %f\n' \) \ + | sed -re 's%^((mkdir|cd) )./%\1/%' ) -w $stubdom_disk >/dev/null
This stuff all seems pretty exciting, but isn't it rather fragile against differences in e2fstools versions etc?
I suppose you must have /usr/sbin and /sbin in your $PATH because none of debugfs, mkfs.ext2 and fsck.ext2 appear in my $PATH...
stubdom-linux/mk-ramdisk-common
Quoted 8 lines
stubdom-linux/mk-ramdisk-common new file +8
-0+ find . -type l | while read line; do + new_link $stubdom_disk "$line" + done + fsck.ext2 -fy $stubdom_disk || true + cd - >/dev/null +else + (cd "$MNTIMAGE"; findall . | cpio -H newc --quiet -o) >| "$IMAGE" || exit 1 + gzip -f "$IMAGE"
This seems like it should be a much simpler option...
Quoted 9 lines
+fi
--
Anthony PERARD_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [RFC 3/6] linux-stubdomain: Build a disk image.
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Anthony PERARD
This patch build a disk image intend to be mounted as rootfs by the stub-domain. It is build using the 'debugfs' tool and make a ext2 fs.
You seem to have some vestigial code for building a cpio style initramfs -- what was wrong with that approach? On the face of it that would seem simpler and less "hacky" than the tricks you have to play with debugfs.
The initramfs were taking more memory for the stub domain, I could not go under 40MB, and now, with the disk, it's 34MB the min that the domain his willing to run with.
Quoted 2 lines
[...]
Review
Quoted 1 line
(quoted diff) +0
-0
b/stubdom-linux/extra/initscript
Quoted 9 lines
stubdom-linux/extra/initscript line 1
Quoted 6 lines
new file mode 100644
index 0000000..122892fstubdom-linux/extra/initscript new file +1
-0@@ -0,0 +1,40 @@ +#!/bin/busybox shThis can become the more normal
/bin/shif you put the appropriate symlink in the initrd?
If I recall correctly, I tryed the symlink, and it was not starting. Maybe a hardlink would works.
Quoted 6 lines
stubdom-linux/extra/initscript line 5
Quoted 4 lines
stubdom-linux/extra/initscript new file +4
-0+ +_initscript_panic() { + sleep 10 +}Erm...
Yes, that debug stuff which can be removed...
Quoted 26 lines
Quoted 26 lines
stubdom-linux/extra/initscript new file +26
-0+trap _initscript_panic 0 + +set -e +set -x +mount -t sysfs /sys /sys +mount -t proc /proc /proc +mount -t xenfs -o nodev /proc/xen /proc/xen + +# TODO: Check if there is network for the vm before doing this +if test -e /sys/class/net/eth0; then + ip link set eth0 address fe:ff:ff:ff:ff:fe + ip addr flush eth0 + ip link set eth0 up + brctl addbr br0 + brctl addif br0 eth0 + ip link set br0 up +else + echo "No network interface named eth0." + ls -l /sys/class/net/ +fi + +# TODO Could probably to xenstore-read `xenstore-read vm`/image/dmargs +# because /local/domain/$domid is probably the root for relative path +domid=$(xenstore-read target) +dom_path="/local/domain/$domid" +vm_path=$(xenstore-read "$dom_path/vm")
Quoted 8 lines
stubdom-linux/extra/initscript line 38
Quoted 6 lines
stubdom-linux/extra/initscript new file +6
-0+dm_args=$(xenstore-read "$vm_path/image/dmargs") + +( sleep 30; free ) & +( sleep 60; free ) & +#( sleep 120; ip addr ) & +( sleep 120; free ) &Erm....
Same.
Quoted 3 lines
Review
Quoted 3 lines
stubdom-linux/extra/initscript new file +2
-0+free +/bin/qemu $dm_args(quoted diff) +0
-0
b/stubdom-linux/extra/qemu-ifup
Quoted 9 lines
Quoted 9 lines
new file mode 100644
index 0000000..d71672bstubdom-linux/extra/qemu-ifup new file +4
-0@@ -0,0 +1,7 @@ +#! /bin/busybox sh + +ip link set "$1" down +ip link set "$1" address fe:ff:ff:ff:ff:fd
Quoted 8 lines
stubdom-linux/extra/qemu-ifup line 7
Quoted 3 lines
stubdom-linux/extra/qemu-ifup new file +3
-0+ip addr flush "$1" +brctl addif br0 "$1" +ip link set "$1" upI don't think this will work for domains with multiple network devices. e.g. if you want vifX.0 on xenbr0 and vifX.1 on xenbr0 in the dom0 backend this will cause them both to get put on the same bridge inside the stubdom and therefore surface as a single device in dom0.
OK, I will look into that.
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/stubdom-linux/mk-ramdisk-common
Quoted 34 lines
stubdom-linux/mk-ramdisk-common line 3
Quoted 8 lines
new file mode 100755
index 0000000..9a4a810stubdom-linux/mk-ramdisk-common new file +3
-0@@ -0,0 +1,178 @@ +#!/bin/bash +# +# This a simple implementaton of mkinitrdimplementation
Quoted 23 lines
stubdom-linux/mk-ramdisk-common new file +23
-0+ + +# Set the umask. For iscsi, the initrd can contain platintext +# password (chap secret), so only allow read by owner. +umask 022 + +TMPDIR="/tmp" +PROBE="yes" +MNTIMAGE="`pwd`/initramfs/" +IMAGE="./initramfs.cpio" +verbose="" +: ${debug:=false} +case $debug in + true|false) ;; + *) + echo '$debug need to be true or false.' + exit 1 + ;; +esac +$debug && verbose='-v' + +DSO_DEPS="" +LDSO=""
Quoted 8 lines
stubdom-linux/mk-ramdisk-common
Quoted 8 lines
stubdom-linux/mk-ramdisk-common new file +8
-0+get_dso_deps() { + bin="$1" ; shift + DSO_DEPS="" + + declare -a FILES + declare -a NAMES + + # this is a hack, but the only better way requires binutils or
elfutils
Quoted 3 lines
stubdom-linux/mk-ramdisk-common line 35
Quoted 1 line
stubdom-linux/mk-ramdisk-common new file +1
-0+ # be installed. i.e., we need readelf to find the interpretter.binutils will surely be installed while building Xen, won't it?
Yes, I will use those for the script.
Quoted 8 lines
"interpreter"
Quoted 7 lines
[...]
stubdom-linux/mk-ramdisk-common new file +5
-0+ case "$FILE" in + /lib*) + TLIBDIR=`echo "$FILE" | sed 's,\(/lib[^/]*\)/.*$,\1,'` + BASE=`basename "$FILE"` + # Prefer nosegneg libs over direct segment accesses
on i686.
Quoted 3 lines
stubdom-linux/mk-ramdisk-common
Quoted 3 lines
stubdom-linux/mk-ramdisk-common new file +3
-0+ if [ -f "$TLIBDIR/i686/nosegneg/$BASE" ]; then + FILE="$TLIBDIR/i686/nosegneg/$BASE" + # Otherwise, prefer base libraries rather than their
optimized
Quoted 11 lines
Quoted 1 line
+ # variants.
Do we not want optimised e.g. SDL libraries if available, or other libraries related to the provision of things like VNC which are the sorts of instruction hungry stuff that I'd expect to benefit from additional clever instructions...
[...]stubdom-linux/mk-ramdisk-common
Quoted 3 lines
stubdom-linux/mk-ramdisk-common new file +3
-0+# this cp keep the link to ld-2.11.x.so +if test "`uname -m`" = x86_64; then + cp --no-dereference "/lib/ld-linux-x86-64.so.2"
"$MNTIMAGE/lib/ld-linux-x86-64.so.2"
Quoted 6 lines
stubdom-linux/mk-ramdisk-common
Quoted 3 lines
stubdom-linux/mk-ramdisk-common new file +3
-0+else + cp --no-dereference "/lib/ld-linux.so.2" "$MNTIMAGE/lib/ld-linux.so.2" +fiDidn't you jump through some hoops earlier to find the actual dynamic interpreter?
The script was not working for this lib.
Quoted 14 lines
Quoted 14 lines
stubdom-linux/mk-ramdisk-common new file +14
-0+try_make_disk=true +if $try_make_disk; then + stubdom_disk=stubdom-disk.img + rm -f $stubdom_disk + dd if=/dev/null of=$stubdom_disk bs=1M seek=40 + mkfs.ext2 -q -F -m0 $stubdom_disk + + cd "$MNTIMAGE" + stubdom_disk="../$stubdom_disk" + new_link(){ + image=$1 + link=$2 + target=`readlink $link` + dir=`dirname $link`
Quoted 8 lines
stubdom-linux/mk-ramdisk-common
Quoted 8 lines
stubdom-linux/mk-ramdisk-common new file +8
-0+ dir=${dir#./} + name_link=$(basename $link) + dir_inode=$(debugfs -R "stat /$dir" $image 2>/dev/null | + sed -nr 's/^Inode: ([[:digit:]]+)[[:space:]].*/\1/p') + test "$dir_inode" || echo 'no dir inode found' + test "$dir_inode" + while true; do + free_inode=$(debugfs -R "find_free_inode $dir_inode 0777" -w
$image 2>/dev/null |
Quoted 2 lines
stubdom-linux/mk-ramdisk-common
Quoted 2 lines
stubdom-linux/mk-ramdisk-common new file +2
-0+ sed -nr 's/^Free inode found: ([[:digit:]]+)$/\1/p') + undel_output="$(debugfs -R "undel <$free_inode>
/$dir/$name_link" -w $image 2>&1)"
Quoted 1 line
Quoted 1 line
+ if grep -q "
make_link: No free space in the directory"
<<<"$undel_output"; then
Quoted 10 lines
Quoted 10 lines
stubdom-linux/mk-ramdisk-common new file +10
-0+ debugfs -R "expand_dir /$dir" -w $image 2>/dev/null + else + break + fi + done + debugfs -f <( + echo "cd /$dir" + echo "set_inode_field $name_link mode 0120777" + echo "set_inode_field $name_link size ${#target}" + # TODO still need to write the link into blocks
Quoted 8 lines
stubdom-linux/mk-ramdisk-common
Quoted 8 lines
stubdom-linux/mk-ramdisk-common new file +8
-0+ if test ${#target} -lt $((12*4)); then + # write into direct block + blockn=0 + while test "$target"; do + t="${target:0:4}" + target="${target:4}" + #convert a four charactere string into hexa + val=$(printf '0x%02x%02x%02x%02x\n' \'${t:3:1}
\'${t:2:1} \'${t:1:1} \'${t:0:1})
Quoted 10 lines
stubdom-linux/mk-ramdisk-common
Quoted 10 lines
stubdom-linux/mk-ramdisk-common new file +10
-0+ echo "set_inode_field $name_link block[$blockn] $val" + blockn=$((blockn+1)) + done + else + # write into a block + echo >&2 ".... write into block not implemented" + fi + ) -w $image >/dev/null 2>/dev/null + } + # TODO Should check for "copy_file: Could not allocate block in
ext2 filesystem"
Quoted 7 lines
stubdom-linux/mk-ramdisk-common
Quoted 4 lines
stubdom-linux/mk-ramdisk-common new file +4
-0+ debugfs -f <(find . \ + \( -type d \! -name . -printf 'cd /\nmkdir %h/%f\n' \) \ + -o \( -type f -printf 'cd /%h\nwrite %h/%f %f\n' \) \ + | sed -re 's%^((mkdir|cd) )./%\1/%' ) -w $stubdom_disk >/dev/nullThis stuff all seems pretty exciting, but isn't it rather fragile against differences in e2fstools versions etc?
Yes, that was the only good enough way to create a disk image as user (not root), with an utility present at least on debian.
Quoted 2 lines
I suppose you must have
/usr/sbinand /sbin in your $PATH because none of debugfs, mkfs.ext2 and fsck.ext2 appear in my $PATH...
Yes, I don't remove {,/usr}/sbin from my PATH.
Quoted 7 lines
stubdom-linux/mk-ramdisk-common
Quoted 7 lines
stubdom-linux/mk-ramdisk-common new file +7
-0+ find . -type l | while read line; do + new_link $stubdom_disk "$line" + done + fsck.ext2 -fy $stubdom_disk || true + cd - >/dev/null +else + (cd "$MNTIMAGE"; findall . | cpio -H newc --quiet -o) >| "$IMAGE"
|| exit 1 >> + gzip -f "$IMAGE"
Quoted 2 lines
This seems like it should be a much simpler option...
Signature · 1 line
Anthony PERARD
Re: [RFC 3/6] linux-stubdomain: Build a disk image.
Quoted 5 lines · Anthony PERARD
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Anthony PERARD
This patch build a disk image intend to be mounted as rootfs by the stub-domain. It is build using the 'debugfs' tool and make a ext2 fs.
Quoted 7 lines
Quoted 3 lines
You seem to have some vestigial code for building a cpio style initramfs -- what was wrong with that approach? On the face of it that would seem simpler and less "hacky" than the tricks you have to play with debugfs.
The initramfs were taking more memory for the stub domain, I could not go under 40MB, and now, with the disk, it's 34MB the min that the domain his willing to run with.
How Odd. Do you know why, it seems they should contain approximately the same amount of data.
Quoted 13 lines
Quoted 2 lines
[...]
Review
Quoted 1 line
(quoted diff) +0
-0b/stubdom-linux/extra/initscript
Quoted 9 lines
stubdom-linux/extra/initscript line 1
Quoted 6 lines
new file mode 100644
index 0000000..122892fstubdom-linux/extra/initscript new file +1
-0@@ -0,0 +1,40 @@ +#!/bin/busybox shThis can become the more normal
/bin/shif you put the appropriate symlink in the initrd?
Quoted 2 lines
If I recall correctly, I tryed the symlink, and it was not starting. Maybe a hardlink would works.
The symlink not working is a bit strange, I wonder what the underlying issue is?
Quoted 5 lines
Quoted 2 lines
This stuff all seems pretty exciting, but isn't it rather fragile against differences in e2fstools versions etc?
Yes, that was the only good enough way to create a disk image as user (not root), with an utility present at least on debian.
What is the status of genext2fs these days?
Quoted 4 lines
Quoted 2 lines
I suppose you must have
/usr/sbinand /sbin in your $PATH because none of debugfs, mkfs.ext2 and fsck.ext2 appear in my $PATH...Yes, I don't remove {,/usr}/sbin from my PATH.
These are not in $PATH for normal users on many (most?) distros (I expect you have probably added them yourself), so this script won't work for some proportion of users.
Ian.
Re: [RFC 3/6] linux-stubdomain: Build a disk image.
Quoted 4 lines · Ian Campbell, le Fri 19 Apr 2013 13:08:21 +0100, a écrit :
Quoted 2 lines
Yes, that was the only good enough way to create a disk image as user (not root), with an utility present at least on debian.
What is the status of genext2fs these days?
Could cpio perhaps be used instead?
Samuel
RFC 4/6 libxl: Add "stubdomain_version" to domain_build_info.
In reply to Anthony PERARDThis enum give the ability to select between the MiniOS based stubdomain and the Linux based stubdomain. It can be written in a VM config file via "stubdomain_version" variable, but will be automatically filled by the appropriate value depending on the device_model_version. To use the stubdomain, it's the same config option "devive_model_stubdomain_override=1" to force the stubdomain.
--- tools/libxl/libxl_create.c | 34 +++++++++++++++++++++++++++++----- tools/libxl/libxl_types.idl | 7 +++++++ tools/libxl/xl_cmdimpl.c | 14 ++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-)
tools/libxl/libxl_create.c +29 -5
@@ -166,12 +166,36 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, }if (b_info->type ==LIBXL_DOMAIN_TYPE_HVM && - b_info->device_model_version != -LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&libxl_defbool_val (b_info->device_model_stubdomain)) { -LIBXL__LOG (CTX ,XTL_ERROR , -"device model stubdomains require \"qemu-xen-traditional\"" ); -return ERROR_INVAL ; +if (!b_info->stubdomain_version) { +switch (b_info->device_model_version) { +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL : + b_info->stubdomain_version =LIBXL_STUBDOMAIN_VERSION_MINIOS ; +break ; +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN : + b_info->stubdomain_version =LIBXL_STUBDOMAIN_VERSION_LINUX ; +break ; +default :abort (); + } + } + +switch (b_info->device_model_version) { +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL : +if (b_info->stubdomain_version !=LIBXL_STUBDOMAIN_VERSION_MINIOS ) { +LIBXL__LOG (CTX ,XTL_ERROR , +"\"qemu-xen-traditional\" require \"minios\" as stubdomain" ); +return ERROR_INVAL ; + } +break ; +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN : +if (b_info->stubdomain_version !=LIBXL_STUBDOMAIN_VERSION_LINUX ) { +LIBXL__LOG (CTX ,XTL_ERROR , +"\"qemu-xen\" require \"linux\" as stubdomain" ); +return ERROR_INVAL ; + } +break ; +default :abort (); + } }if (!b_info->max_vcpus)
tools/libxl/libxl_types.idl +7 -0
@@ -39,6 +39,12 @@ libxl_device_model_version = Enumeration("device_model_version", [ (2, "QEMU_XEN"), # Upstream based qemu-xen device model ]) +# Give the kernel running in the stub-domain +libxl_stubdomain_version = Enumeration("stubdomain_version", [ + (1, "MINIOS"), + (2, "LINUX"), + ]) + libxl_console_type = Enumeration("console_type", [ (1, "SERIAL"), (2, "PV"),
@@ -278,6 +284,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("device_model_version", libxl_device_model_version), ("device_model_stubdomain", libxl_defbool), + ("stubdomain_version", libxl_stubdomain_version), # if you set device_model you must set device_model_version too ("device_model", string), ("device_model_ssidref", uint32),
tools/libxl/xl_cmdimpl.c +14 -0
@@ -1451,8 +1451,22 @@ skip_vfb: } }else if (b_info->device_model)fprintf (stderr,"WARNING: device model override given without specific DM version\n" ); +xlu_cfg_get_defbool (config,"device_model_stubdomain_override" , &b_info->device_model_stubdomain,0 ); +if (!xlu_cfg_get_string (config,"stubdomain_version" , &buf,0 )) { +if (!strcmp (buf,"minios" )) { + b_info->stubdomain_version =LIBXL_STUBDOMAIN_VERSION_MINIOS ; +libxl_defbool_set (&b_info->device_model_stubdomain, true); + }else if (!strcmp (buf,"linux" )) { + b_info->stubdomain_version =LIBXL_STUBDOMAIN_VERSION_LINUX ; +libxl_defbool_set (&b_info->device_model_stubdomain, true); + }else { +fprintf (stderr, +"Unknown stubdomain_version \"%s\" specified\n" , buf); +exit (1 ); + } + }if (!xlu_cfg_get_string (config,"device_model_stubdomain_seclabel" , &buf,0 )) {
Signature · 1 line
Anthony PERARD
Re: [RFC 4/6] libxl: Add "stubdomain_version" to domain_build_info.
Quoted 6 lines · Anthony PERARD
This enum give the ability to select between the MiniOS based stubdomain and the Linux based stubdomain. It can be written in a VM config file via "
stubdomain_version" variable, but will be automatically filled by the appropriate value depending on thedevice_model_version. To use the stubdomain, it's the same config option "devive_model_stubdomain_override=1" to force the stubdomain.
Given that there is no actual choice available (it's minios for qemu-xen-trad and Linux for qemu-xen) at the moment perhaps we should just leave this option out for now and cross this bridge if/when there is a real choice to be made?
If we do want to keep this then I think I'd prefer to see us extend the semantics of device_model_stubdomain_override to be more than a simple boolean, e.g. make it a libxl enum libxl_device_model_stubdomain_type:
0 = "none" => process dm in dom0 1 = "minios" => mini-os based stubdom 2 = "linux" => ... 3 = "foobsd" => ...
etc
Re: [RFC 4/6] libxl: Add "stubdomain_version" to domain_build_info.
Quoted 8 lines · Ian Campbell
Quoted 6 lines · Anthony PERARD
This enum give the ability to select between the MiniOS based stubdomain and the Linux based stubdomain. It can be written in a VM config file via "
stubdomain_version" variable, but will be automatically filled by the appropriate value depending on thedevice_model_version. To use the stubdomain, it's the same config option "devive_model_stubdomain_override=1" to force the stubdomain.
Quoted 4 lines
Given that there is no actual choice available (it's minios for qemu-xen-trad and Linux for qemu-xen) at the moment perhaps we should just leave this option out for now and cross this bridge if/when there is a real choice to be made?
I feel like this will be an easier thing to do for now.
Quoted 7 lines
If we do want to keep this then I think I'd prefer to see us extend the semantics of
device_model_stubdomain_overrideto be more than a simple boolean, e.g. make it a libxl enumlibxl_device_model_stubdomain_type:0 = "none" => process dm in dom0 1 = "minios" => mini-os based stubdom 2 = "linux" => ... 3 = "foobsd" => ...
With this, I don't see how to say: "I want a stubdom for this domain." without having to know which type will be the best (or only) choice. So I go for the no choice for the user, beside stubdom or not.
Signature · 1 line
Anthony PERARD
Re: [RFC 4/6] libxl: Add "stubdomain_version" to domain_build_info.
Quoted 24 lines · Anthony PERARD
Quoted 8 lines · Ian Campbell
Quoted 6 lines · Anthony PERARD
This enum give the ability to select between the MiniOS based stubdomain and the Linux based stubdomain. It can be written in a VM config file via "
stubdomain_version" variable, but will be automatically filled by the appropriate value depending on thedevice_model_version. To use the stubdomain, it's the same config option "devive_model_stubdomain_override=1" to force the stubdomain.Quoted 4 lines
Given that there is no actual choice available (it's minios for qemu-xen-trad and Linux for qemu-xen) at the moment perhaps we should just leave this option out for now and cross this bridge if/when there is a real choice to be made?
I feel like this will be an easier thing to do for now.
Quoted 7 lines
If we do want to keep this then I think I'd prefer to see us extend the semantics of
device_model_stubdomain_overrideto be more than a simple boolean, e.g. make it a libxl enumlibxl_device_model_stubdomain_type:0 = "none" => process dm in dom0 1 = "minios" => mini-os based stubdom 2 = "linux" => ... 3 = "foobsd" => ...
Quoted 1 line
With this, I don't see how to say: "I want a stubdom for this domain."
-1 = "default" ;-)
Quoted 3 lines
without having to know which type will be the best (or only) choice. So I go for the no choice for the user, beside stubdom or not.
RFC 5/6 libxl: Handle Linux stubdomain specifique QEMU option.
In reply to Anthony PERARDThere is few things that are not possible for now in the stubdomain, the QMP socket and graphique output, and few other things that are handled in an other way. This patch try to fix the command line passed to the QEMU in the Linux stubdomain.
--- tools/libxl/libxl_dm.c | 71 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 19 deletions(-)
tools/libxl/libxl_dm.c +52 -19
@@ -19,9 +19,12 @@#include "libxl_internal.h" -static const char *libxl_tapif_script (libxl__gc *gc) +static const char *libxl_tapif_script (libxl__gc *gc, +const libxl_domain_build_info *info) {#ifdef __linux__ +if (info->stubdomain_version ==LIBXL_STUBDOMAIN_VERSION_LINUX ) +return libxl__sprintf (gc,"/etc/qemu-ifup" );return libxl__strdup (gc,"no" );#else return libxl__sprintf (gc,"%s/qemu-ifup" ,libxl__xen_script_dir_path ());
@@ -257,8 +260,8 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc,"tap,vlan=%d,ifname=%s,bridge=%s," "script=%s,downscript=%s" , nics[i].devid, ifname, nics[i].bridge, -libxl_tapif_script (gc), - libxl_tapif_script(gc)), +libxl_tapif_script (gc, b_info), + libxl_tapif_script(gc, b_info)), NULL); ioemu_nics++; }
@@ -372,14 +375,17 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,"-xen-domid" , libxl__sprintf(gc, "%d", guest_domid), NULL); -flexarray_append (dm_args,"-chardev" ); -flexarray_append (dm_args, -libxl__sprintf (gc,"socket,id=libxl-cmd," -"path=%s/qmp-libxl-%d,server,nowait" , -libxl__run_dir_path (), guest_domid)); +/* There is currently no way to access the QMP socket in the stubdom */ +if (!libxl_defbool_val (b_info->device_model_stubdomain)) { +flexarray_append (dm_args,"-chardev" ); +flexarray_append (dm_args, +libxl__sprintf (gc,"socket,id=libxl-cmd," +"path=%s/qmp-libxl-%d,server,nowait" , +libxl__run_dir_path (), guest_domid)); -flexarray_append (dm_args,"-mon" ); -flexarray_append (dm_args,"chardev=libxl-cmd,mode=control" ); +flexarray_append (dm_args,"-mon" ); +flexarray_append (dm_args,"chardev=libxl-cmd,mode=control" ); + }if (b_info->type ==LIBXL_DOMAIN_TYPE_PV ) {flexarray_append (dm_args,"-xen-attach" );
@@ -556,8 +562,8 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,"type=tap,id=net%d,ifname=%s," "script=%s,downscript=%s" , nics[i].devid, ifname, -libxl_tapif_script (gc), - libxl_tapif_script(gc))); +libxl_tapif_script (gc, b_info), + libxl_tapif_script(gc, b_info))); ioemu_nics++; } }
@@ -622,6 +628,10 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc, drive =libxl__sprintf (gc,"if=ide,index=%d,media=cdrom,cache=writeback,id=ide-%i" , disk, dev_number); + else if (b_info->stubdomain_version == LIBXL_STUBDOMAIN_VERSION_LINUX) + drive =libxl__sprintf + (gc,"file=%s,if=ide,index=%d,media=cdrom,cache=writeback,format=%s,id=ide-%i" , +"/dev/xvdc" , disk,"host_cdrom" , dev_number); else drive = libxl__sprintf (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback,id=ide-%i",
@@ -650,9 +660,14 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc, (gc,"file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=writeback" , disks[i].pdev_path, disk, format); else if (disk < 4) - drive =libxl__sprintf - (gc,"file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback" , - disks[i].pdev_path, disk, format); + if (b_info->stubdomain_version == LIBXL_STUBDOMAIN_VERSION_LINUX) + drive =libxl__sprintf + (gc,"file=%s,if=ide,index=%d,media=disk,cache=writeback,format=%s" , +"/dev/xvda" , disk,"host_device" ); + else + drive =libxl__sprintf + (gc,"file=%s,if=ide,index=%d,media=disk,cache=writeback,format=%s" , + disks[i].pdev_path, disk, format); else continue;/* Do not emulate this disk */ }
@@ -733,7 +748,7 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,static int libxl__write_stub_dmargs (libxl__gc *gc,int dm_domid,int guest_domid, -char **args) +char **args,bool linux_stubdom) {libxl_ctx *ctx =libxl__gc_owner (gc);int i;
@@ -761,10 +776,28 @@ static int libxl__write_stub_dmargs(libxl__gc *gc, i =1 ; dmargs[0 ] ='\0' ;while (args[i] !=NULL ) { -if (strcmp (args[i],"-sdl" ) &&strcmp (args[i],"-M" ) &&strcmp (args[i],"xenfv" )) { -strcat (dmargs," " ); -strcat (dmargs, args[i]); +if (!linux_stubdom) { +if (!(strcmp (args[i],"-sdl" ) &&strcmp (args[i],"-M" ) &&strcmp (args[i],"xenfv" ))) { + i++; +continue ; + } + }else { +if (!strcmp (args[i],"-sdl" )) { + i++; +continue ; + } +if (!strcmp (args[i],"-incoming" ) + || !strcmp (args[i],"-vnc" ) + || !strcmp (args[i],"-vga" )) { + i +=2 ; +continue ; + } +if (!strcmp (args[i],"-serial" )) { + args[i+1 ] ="/dev/hvc1" ; + } } +strcat (dmargs," " ); +strcat (dmargs, args[i]); i++; } path =libxl__sprintf (gc,"%s/image/dmargs" , vm_path);
Signature · 1 line
Anthony PERARD
Re: [RFC 5/6] libxl: Handle Linux stubdomain specifique QEMU option.
tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 378
Quoted 10 lines · Anthony PERARD
tools/libxl/libxl_dm.c +1
-5@@ -372,14 +375,17 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,"-xen-domid" , libxl__sprintf(gc, "%d", guest_domid), NULL); -flexarray_append (dm_args,"-chardev" ); -flexarray_append (dm_args, -libxl__sprintf (gc,"socket,id=libxl-cmd," -"path=%s/qmp-libxl-%d,server,nowait" , -libxl__run_dir_path (), guest_domid)); +/* There is currently no way to access the QMP socket in the stubdom */
This rules out a bunch of interesting/useful functionality doesn't it?
Quoted 41 lines
tools/libxl/libxl_dm.c +19
-6+if (!libxl_defbool_val (b_info->device_model_stubdomain)) { +flexarray_append (dm_args,"-chardev" ); +flexarray_append (dm_args, +libxl__sprintf (gc,"socket,id=libxl-cmd," +"path=%s/qmp-libxl-%d,server,nowait" , +libxl__run_dir_path (), guest_domid)); -flexarray_append (dm_args,"-mon" ); -flexarray_append (dm_args,"chardev=libxl-cmd,mode=control" ); +flexarray_append (dm_args,"-mon" ); +flexarray_append (dm_args,"chardev=libxl-cmd,mode=control" ); + }if (b_info->type ==LIBXL_DOMAIN_TYPE_PV ) {flexarray_append (dm_args,"-xen-attach" );@@ -733,7 +748,7 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,static int libxl__write_stub_dmargs (libxl__gc *gc,int dm_domid,int guest_domid, -char **args) +char **args,bool linux_stubdom) {libxl_ctx *ctx =libxl__gc_owner (gc);int i;@@ -761,10 +776,28 @@ static int libxl__write_stub_dmargs(libxl__gc *gc, i =1 ; dmargs[0 ] ='\0' ;while (args[i] !=NULL ) { -if (strcmp (args[i],"-sdl" ) &&strcmp (args[i],"-M" ) &&strcmp (args[i],"xenfv" )) { -strcat (dmargs," " ); -strcat (dmargs, args[i]); +if (!linux_stubdom) { +if (!(strcmp (args[i],"-sdl" ) &&strcmp (args[i],"-M" ) &&strcmp (args[i],"xenfv" ))) { + i++; +continue ; + } + }else { +if (!strcmp (args[i],"-sdl" )) { + i++; +continue ;
tools/libxl/libxl_dm.c static int libxl__write_stub_dmargs(libxl__gc *gc, · line 797
Quoted 10 lines
tools/libxl/libxl_dm.c +10
-0+ } +if (!strcmp (args[i],"-incoming" ) + || !strcmp (args[i],"-vnc" ) + || !strcmp (args[i],"-vga" )) { + i +=2 ; +continue ; + } +if (!strcmp (args[i],"-serial" )) { + args[i+1 ] ="/dev/hvc1" ; + }
Is this all temporary until the various features are supported?
Ian.
Re: [RFC 5/6] libxl: Handle Linux stubdomain specifique QEMU option.
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Anthony PERARD
tools/libxl/libxl_dm.c +0
-0@@ -372,14 +375,17 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,"-xen-domid" , libxl__sprintf(gc, "%d", guest_domid), NULL);
Quoted 8 lines
tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 378
Quoted 6 lines
tools/libxl/libxl_dm.c +1
-5-flexarray_append (dm_args,"-chardev" ); -flexarray_append (dm_args, -libxl__sprintf (gc,"socket,id=libxl-cmd," -"path=%s/qmp-libxl-%d,server,nowait" , -libxl__run_dir_path (), guest_domid)); +/* There is currently no way to access the QMP socket in the stubdom */ This rules out a bunch of interesting/useful functionality doesn't it?
Yes, it does. Anything that it's hotplug (even cd-rom). So I'll have to find a way to the socket from dom0.
Quoted 45 lines
Quoted 45 lines
tools/libxl/libxl_dm.c +23
-6+if (!libxl_defbool_val (b_info->device_model_stubdomain)) { +flexarray_append (dm_args,"-chardev" ); +flexarray_append (dm_args, +libxl__sprintf (gc,"socket,id=libxl-cmd," +"path=%s/qmp-libxl-%d,server,nowait" , +libxl__run_dir_path (), guest_domid)); -flexarray_append (dm_args,"-mon" ); -flexarray_append (dm_args,"chardev=libxl-cmd,mode=control" ); +flexarray_append (dm_args,"-mon" ); +flexarray_append (dm_args,"chardev=libxl-cmd,mode=control" ); + }if (b_info->type ==LIBXL_DOMAIN_TYPE_PV ) {flexarray_append (dm_args,"-xen-attach" );@@ -733,7 +748,7 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,static int libxl__write_stub_dmargs (libxl__gc *gc,int dm_domid,int guest_domid, -char **args) +char **args,bool linux_stubdom) {libxl_ctx *ctx =libxl__gc_owner (gc);int i;@@ -761,10 +776,28 @@ static int libxl__write_stub_dmargs(libxl__gc *gc, i =1 ; dmargs[0 ] ='\0' ;while (args[i] !=NULL ) { -if (strcmp (args[i],"-sdl" ) &&strcmp (args[i],"-M" ) &&strcmp (args[i],"xenfv" )) { -strcat (dmargs," " ); -strcat (dmargs, args[i]); +if (!linux_stubdom) { +if (!(strcmp (args[i],"-sdl" ) &&strcmp (args[i],"-M" ) &&strcmp (args[i],"xenfv" ))) { + i++; +continue ; + } + }else { +if (!strcmp (args[i],"-sdl" )) { + i++; +continue ; + } +if (!strcmp (args[i],"-incoming" ) + || !strcmp (args[i],"-vnc" ) + || !strcmp (args[i],"-vga" )) {
Quoted 8 lines
tools/libxl/libxl_dm.c static int libxl__write_stub_dmargs(libxl__gc *gc, · line 797
Quoted 6 lines
tools/libxl/libxl_dm.c +6
-0+ i +=2 ; +continue ; + } +if (!strcmp (args[i],"-serial" )) { + args[i+1 ] ="/dev/hvc1" ; + }Is this all temporary until the various features are supported?
Yes. Well, a better way to handle that would be to alter the domain build_config were all the options the user wants are present.
Signature · 1 line
Anthony PERARD
RFC 6/6 libxl: Build the domain with a Linux based stubdomain.
In reply to Anthony PERARDThis will build a stubdomain with QEMU upstream.
--- tools/libxl/libxl.c | 25 ++++++++-- tools/libxl/libxl_create.c | 7 ++- tools/libxl/libxl_dm.c | 107 ++++++++++++++++++++++++++++++++++++------- tools/libxl/libxl_internal.c | 22 +++++++++ tools/libxl/libxl_internal.h | 4 ++ 5 files changed, 145 insertions(+), 20 deletions(-)
tools/libxl/libxl.c +22 -3
@@ -1561,8 +1561,17 @@ static int libxl__primary_console_find(libxl_ctx *ctx, uint32_t domid_vm,if (stubdomid) { *domid = stubdomid; - *cons_num =STUBDOM_CONSOLE_SERIAL ; *type =LIBXL_CONSOLE_TYPE_PV ; +switch (libxl__stubdomain_version_running (gc, stubdomid)) { +case LIBXL_STUBDOMAIN_VERSION_MINIOS : + *cons_num =STUBDOM_CONSOLE_SERIAL ; +break ; +case LIBXL_STUBDOMAIN_VERSION_LINUX : + *cons_num =1 ; +break ; +default : +abort (); + } }else {switch (libxl__domain_type (gc, domid_vm)) {case LIBXL_DOMAIN_TYPE_HVM :
@@ -3775,8 +3784,18 @@ int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info,switch (b_info->type) {case LIBXL_DOMAIN_TYPE_HVM : *need_memkb += b_info->shadow_memkb +LIBXL_HVM_EXTRA_MEMORY ; -if (libxl_defbool_val (b_info->device_model_stubdomain)) - *need_memkb +=32 *1024 ; +if (libxl_defbool_val (b_info->device_model_stubdomain)) { +switch (b_info->stubdomain_version) { +case LIBXL_STUBDOMAIN_VERSION_MINIOS : + *need_memkb +=32 *1024 ; +break ; +case LIBXL_STUBDOMAIN_VERSION_LINUX : + *need_memkb +=LIBXL_LINUX_STUBDOM_MEM *1024 ; +break ; +default : +abort (); + } + }break ;case LIBXL_DOMAIN_TYPE_PV : *need_memkb += b_info->shadow_memkb +LIBXL_PV_EXTRA_MEMORY ;
tools/libxl/libxl_create.c +6 -1
@@ -1111,7 +1111,12 @@ static void domcreate_devmodel_started(libxl__egc *egc,if (dcs->dmss.dm.guest_domid) {if (d_config->b_info.device_model_version ==LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN ) { -libxl__qmp_initializations (gc, domid, d_config); +if (!libxl_defbool_val (d_config->b_info.device_model_stubdomain)) { +libxl__qmp_initializations (gc, domid, d_config); + }else { +int stubdom_domid = dcs->dmss.pvqemu.guest_domid; +libxl__qmp_initializations (gc, stubdom_domid, d_config); + } } }
tools/libxl/libxl_dm.c +91 -16
169 lines not on this page · raw message
tools/libxl/libxl_internal.c +22 -0
@@ -347,6 +347,28 @@ int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid)return value; } +int libxl__stubdomain_version_running (libxl__gc *gc,uint32_t domid) +{ +char *path =NULL ; +char *stub_version =NULL ; +libxl_stubdomain_version value; + + path =libxl__xs_libxl_path (gc, domid); + path =libxl__sprintf (gc,"%s/stubdom-version" , path); + stub_version =libxl__xs_read (gc,XBT_NULL , path); +if (!stub_version) { +return LIBXL_STUBDOMAIN_VERSION_MINIOS ; + } + +if (libxl_stubdomain_version_from_string (stub_version, &value) <0 ) { +libxl_ctx *ctx =libxl__gc_owner (gc); +LIBXL__LOG (ctx,LIBXL__LOG_ERROR , +"fatal: %s contain a wrong value (%s)" , path, stub_version); +return -1 ; + } +return value; +} +int libxl__hotplug_settings (libxl__gc *gc,xs_transaction_t t) {int rc =0 ;
tools/libxl/libxl_internal.h +4 -0
@@ -99,6 +99,7 @@#define STUBDOM_CONSOLE_RESTORE 2#define STUBDOM_CONSOLE_SERIAL 3#define STUBDOM_SPECIAL_CONSOLES 3 +#define LIBXL_LINUX_STUBDOM_MEM 34#define TAP_DEVICE_SUFFIX "-emu"#define DISABLE_UDEV_PATH "libxl/disable_udev"
@@ -1564,6 +1565,9 @@ _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s); _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);/* Return the system-wide default device model */ _hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc); +/* Based on /libxl/$domid/stubdom-version xenstore key +* default is minios */ +_hidden int libxl__stubdomain_version_running(libxl__gc *gc, uint32_t domid);/* Check how executes hotplug script currently */ int libxl__hotplug_settings (libxl__gc *gc,xs_transaction_t t);
Signature · 1 line
Anthony PERARD
Quoted 4 lines · Anthony PERARD
Hi all,
Here is the long overdue patch series to bring support for a Linux based stubdom which will enable to use QEMU upstream as device model in a stubdom.
Thanks.
Do you have any performance figures?
What are the overheads for the stub domain (e.g. memory)?
The dependency on various non-mainline git repos and on out of tree patching are a bit concerning, how are we going to address those?
The hardcoded Linux version (currently 3.4.13) is also something of a concern -- what is the intended strategy for managing the kernel used here? Are we planning to periodically update it or something?
Is there any requirement to build as root?
This seems to add a dependency on /bin/busybox from the host, is there a configure check to ensure this is present? Do we rely on the distro to provide this? Which distros has it been tested on? Do we know that distros in general provide a package with /bin/busybox in it?
Ian.
Quoted 9 lines · Ian Campbell
Quoted 4 lines · Anthony PERARD
Hi all,
Here is the long overdue patch series to bring support for a Linux based stubdom which will enable to use QEMU upstream as device model in a stubdom.
Thanks.
Do you have any performance figures?
Yes, I do. I've wrote a presentation for Xen Summit. I will dig them and post them back.
Quoted 1 line
What are the overheads for the stub domain (e.g. memory)?
For memory, about 34MB for the domain, plus something (a process in dom0) to read the stubdom disk image. I can't think of something else.
Quoted 2 lines
The dependency on various non-mainline git repos and on out of tree patching are a bit concerning, how are we going to address those?
The patches for QEMU need to be upstreamed. Then, we could just use the same tree as the non-stubdom qemu-xen, and decide later if it's usefull to build QEMU twice.
For Linux patches, I'm not sure what to do.
- One of them is about checking if a domain have right to call an
hypercall. To be upstream, we would need to check if indeed the hypercall can be called from this domain, or maybe let the hypervisor do this check.
- There other one fix the an address when the function is called from
the stubdom. This one could works in any case.
Quoted 3 lines
The hardcoded Linux version (currently 3.4.13) is also something of a concern -- what is the intended strategy for managing the kernel used here? Are we planning to periodically update it or something?
Well, I've start with this one, but I think that any last release could work, provided the patch are upstream or can be applied.
Quoted 1 line
Is there any requirement to build as root?
No. The only one would be to build a disk image, but I found a way which works on my system without running as root. But this use 'debugfs' to write into a ext2 filesystem.
Quoted 4 lines
This seems to add a dependency on
/bin/busyboxfrom the host, is there a configure check to ensure this is present? Do we rely on the distro to provide this? Which distros has it been tested on? Do we know that distros in general provide a package with/bin/busyboxin it?
Busybox should be a dependency for the build host, which is probably better than compiling it our self. The scripts does not really check for it, yet.
There is another dependency, debugfs, which I'm not sure where we will find it. But I think that I check in debian when I start using it.
Thanks,
Signature · 1 line
Anthony PERARD
Quoted 25 lines · Anthony PERARD
Hi all,
Here is the long overdue patch series to bring support for a Linux based stubdom which will enable to use QEMU upstream as device model in a stubdom.
The first three patches will provide the necessary to build Linux and a disk image for the stubdomain itself. This is created in a separated directory "stubdom-linux". Calling
makein this directory will build Linux and the disk. Then amake installwill copy the two files to the same directory as the MiniOS use.The last three patches are the libxl support. There is a field called "
stubdomain_version" which is automatically set to the appropriate value, depending on the QEMU version used. It call also be set from VM config file.So, to start a Linux stubdomain, just set those two variables and it shoud start:
device_model_stubdomain_override= 1device_model_version= "qemu-xen"There is few things that does not have support yet and are on my todo list:
- video output
- save/restore
So for now, we have the network and the console and the disk of the domain.
Quoted 7 lines
Regards,
Anthony PERARD (6):
linux-stubdomain: Compile QEMU
linux-stubdomain: Compile Linux
linux-stubdomain: Build a disk image.
I think this should be done outside of the Xen build system using one of the existing (embedded) build systems. e.g., Yocto.
David