Skip to contentSkip to conversation

domain builder patches

PATCH In review Gerd Hoffmann 3 participants 10 messages Jan 25, 2007 – Mar 13, 2007 Kbuild

lore
Share & tools
lore
#0 lore raw

cover domain builder patches

This patchset contains the domain builder rewrite. Main feature beside some general code cleanup is support for 32-on-64, i.e. it is possible to create non-native domains amd thus mix 32pae and 64bit domains on the same machine. The patches come with individual descriptions. The patchset depends on the libelf patches posted earlier this week.

cheers,
Gerd

#1 lore raw

PATCH 1/6 Generate headers with arch-specific structs.

This patch adds a script to generate headers with arch-specific structs which can be included on any architecture. Can be used to deal with structs of "foreign" architectures, needed for 32-on-64 support for example.

---
 Makefile                                  |   11 +-
 tools/Rules.mk                            |    2 
 xen/Makefile                              |    4 
 xen/include/public/foreign/Makefile       |   37 +++++++
 xen/include/public/foreign/mkchecker.py   |   58 +++++++++++
 xen/include/public/foreign/mkheader.py    |  153 ++++++++++++++++++++++++++++++
 xen/include/public/foreign/reference.size |   17 +++
 xen/include/public/foreign/structs.py     |   52 ++++++++++
 8 files changed, 331 insertions(+), 3 deletions(-)
xen/include/public/foreign/Makefile new file +37 -0
Index: build-32-unstable-13553/xen/include/public/foreign/Makefile
===================================================================
@@ -0,0 +1,37 @@
+XEN_ROOT := ../../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+architectures := x86_32 x86_64 ia64
+headers := $(patsubst %, %.h, $(architectures))
+scripts := $(wildcard *.py)
+
+.PHONY: all clean check-headers
+all: $(headers) check-headers
+
+clean:
+	rm -f $(headers)
+	rm -f checker checker.c $(XEN_TARGET_ARCH).size
+	rm -f *.pyc *.o *~
+
+check-headers: checker
+ifeq ($(CROSS_COMPILE),)
+	./checker > $(XEN_TARGET_ARCH).size
+	diff -u reference.size $(XEN_TARGET_ARCH).size
+else
+	@echo "cross build: skipping check"
+endif
+
+x86_32.h: ../arch-x86/xen-x86_32.h ../arch-x86/xen.h ../xen.h $(scripts)
+	python mkheader.py $* $@ $(filter %.h,$^)
+
+x86_64.h: ../arch-x86/xen-x86_64.h ../arch-x86/xen.h ../xen.h $(scripts)
+	python mkheader.py $* $@ $(filter %.h,$^)
+
+ia64.h: ../arch-ia64.h ../xen.h $(scripts)
+	python mkheader.py $* $@ $(filter %.h,$^)
+
+checker: checker.c $(headers)
+	$(HOSTCC) $(CFLAGS) -o $@ $<
+
+checker.c: $(scripts)
+	python mkchecker.py $(XEN_TARGET_ARCH) $@ $(architectures)
xen/include/public/foreign/mkheader.py new file +153 -0

153 lines not on this page · raw message

xen/include/public/foreign/structs.py new file +52 -0

52 lines not on this page · raw message

xen/include/public/foreign/reference.size new file +17 -0
Index: build-32-unstable-13553/xen/include/public/foreign/reference.size
===================================================================
@@ -0,0 +1,17 @@
+
+structs              |  x86_32  x86_64    ia64
+
+start_info           |    1104    1152    1152
+trap_info            |       8      16       -
+pt_fpreg             |       -       -      16
+cpu_user_regs        |      68     200     496
+xen_ia64_boot_param  |       -       -      96
+ia64_tr_entry        |       -       -      32
+vcpu_extra_regs      |       -       -     536
+vcpu_guest_context   |    2800    5168    1056
+arch_vcpu_info       |      24      16       0
+vcpu_time_info       |      32      32      32
+vcpu_info            |      64      64      48
+arch_shared_info     |     268     280     272
+shared_info          |    2584    3368    4384
+
xen/Makefile +4 -0
Index: build-32-unstable-13553/xen/Makefile
===================================================================
@@ -35,10 +35,13 @@ _install: $(TARGET).gz
 		$(INSTALL_DIR) $(DESTDIR)/usr/include/xen/hvm
 	[ -d $(DESTDIR)/usr/include/xen/io ] || \
 		$(INSTALL_DIR) $(DESTDIR)/usr/include/xen/io
+	[ -d $(DESTDIR)/usr/include/xen/foreign ] || \
+		$(INSTALL_DIR) $(DESTDIR)/usr/include/xen/foreign
 	$(INSTALL_DATA) include/public/*.h $(DESTDIR)/usr/include/xen
 	$(INSTALL_DATA) include/public/arch-x86/*.h $(DESTDIR)/usr/include/xen/arch-x86
 	$(INSTALL_DATA) include/public/hvm/*.h $(DESTDIR)/usr/include/xen/hvm
 	$(INSTALL_DATA) include/public/io/*.h $(DESTDIR)/usr/include/xen/io
+	$(INSTALL_DATA) include/public/foreign/*.h $(DESTDIR)/usr/include/xen/foreign
 	$(INSTALL_DATA) include/public/COPYING $(DESTDIR)/usr/include/xen
 
 .PHONY: _debug
@@ -48,6 +51,7 @@ _debug:
 .PHONY: _clean
 _clean: delete-unfresh-files
 	$(MAKE) -C tools clean
+	$(MAKE) -C include/public/foreign clean
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C include clean
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C common clean
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C drivers clean
xen/include/public/foreign/mkchecker.py new file +58 -0

58 lines not on this page · raw message

tools/Rules.mk +2 -0
Index: build-32-unstable-13553/tools/Rules.mk
===================================================================
@@ -52,5 +52,7 @@ mk-symlinks-xen:
 	( cd xen/io && ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . )
 	mkdir -p xen/arch-x86
 	( cd xen/arch-x86 && ln -sf ../../$(XEN_ROOT)/xen/include/public/arch-x86/*.h . )
+	mkdir -p xen/foreign
+	( cd xen/foreign && ln -sf ../../$(XEN_ROOT)/xen/include/public/foreign/*.h . )
 
 mk-symlinks: mk-symlinks-xen mk-symlinks-$(XEN_OS)
Makefile +8 -3
Index: build-32-unstable-13553/Makefile
===================================================================
@@ -22,7 +22,7 @@ endif
 install: install-xen install-kernels install-tools install-docs
 
 .PHONY: build
-build: kernels
+build: kernels build-headers
 	$(MAKE) -C xen build
 	$(MAKE) -C tools build
 	$(MAKE) -C docs build
@@ -59,11 +59,11 @@ prep-kernels:
 	for i in $(XKERNELS) ; do $(MAKE) $$i-prep || exit 1; done
 
 .PHONY: install-xen
-install-xen:
+install-xen: build-headers
 	$(MAKE) -C xen install
 
 .PHONY: install-tools
-install-tools:
+install-tools: build-headers
 	$(MAKE) -C tools install
 
 .PHONY: install-kernels
@@ -82,6 +82,11 @@ dev-docs:
 .PHONY: kbuild
 kbuild: kernels
 
+# generate header files
+.PHONY: build-headers
+build-headers:
+	$(MAKE) -C xen/include/public/foreign
+
 # Delete the kernel build trees entirely
 .PHONY: kdelete
 kdelete:
#2 lore raw

PATCH 2/6 Add more xc_error_code values.

In reply to Gerd Hoffmann

XC_INVALID_PARAM
such as asking for features unsupported by either xen or guest kernel.
XC_OUT_OF_MEMORY
no comment ;)

---
 tools/libxc/xc_private.c |    4 ++++
 tools/libxc/xenctrl.h    |    2 ++
 2 files changed, 6 insertions(+)
tools/libxc/xenctrl.h +2 -0
Index: build-32-unstable-12809/tools/libxc/xenctrl.h
===================================================================
@@ -691,6 +691,8 @@ typedef enum {
   XC_ERROR_NONE = 0,
   XC_INTERNAL_ERROR = 1,
   XC_INVALID_KERNEL = 2,
+  XC_INVALID_PARAM = 3,
+  XC_OUT_OF_MEMORY = 4,
 } xc_error_code;
 
 #define XC_MAX_ERROR_MSG_LEN 1024
tools/libxc/xc_private.c +4 -0
Index: build-32-unstable-12809/tools/libxc/xc_private.c
===================================================================
@@ -45,6 +45,10 @@ const char *xc_error_code_to_desc(int co
         return "Internal error";
     case XC_INVALID_KERNEL:
         return "Invalid kernel";
+    case XC_INVALID_PARAM:
+        return "Invalid configuration";
+    case XC_OUT_OF_MEMORY:
+        return "Out of memory";
     }
 
     return "Unknown error code";
#3 lore raw

PATCH 3/6 libxc header fixups.

In reply to Gerd Hoffmann

Make some arch-specific #defines for page table handling available unconditionally, add a suffix to avoid name clashes.

The versions without suffix are defined depending on the architecture like they used to, so code using them continues to work.

---
 tools/libxc/xg_private.h |  114 +++++++++++++++++++++++++++--------------------
 1 file changed, 67 insertions(+), 47 deletions(-)
tools/libxc/xg_private.h +67 -47
Index: build-32-unstable-11822/tools/libxc/xg_private.h
===================================================================
@@ -46,37 +46,41 @@ unsigned long csum_page (void * page);
 #define _PAGE_PSE       0x080
 #define _PAGE_GLOBAL    0x100
 
-#define L1_PAGETABLE_SHIFT_PAE   12
-#define L2_PAGETABLE_SHIFT_PAE   21
-#define L3_PAGETABLE_SHIFT_PAE   30
-
-#define L2_PAGETABLE_SHIFT_I386  22
-
-#if defined(__i386__)
-#define L1_PAGETABLE_SHIFT       12
-#define L2_PAGETABLE_SHIFT       22
-#elif defined(__x86_64__)
-#define L1_PAGETABLE_SHIFT       12
-#define L2_PAGETABLE_SHIFT       21
-#define L3_PAGETABLE_SHIFT       30
-#define L4_PAGETABLE_SHIFT       39
-#endif
+#define L1_PAGETABLE_SHIFT_I386       12
+#define L2_PAGETABLE_SHIFT_I386       22
+#define L1_PAGETABLE_ENTRIES_I386   1024
+#define L2_PAGETABLE_ENTRIES_I386   1024
 
-#define L1_PAGETABLE_ENTRIES_PAE  512
-#define L2_PAGETABLE_ENTRIES_PAE  512
-#define L3_PAGETABLE_ENTRIES_PAE    4
+#define L1_PAGETABLE_SHIFT_PAE        12
+#define L2_PAGETABLE_SHIFT_PAE        21
+#define L3_PAGETABLE_SHIFT_PAE        30
+#define L1_PAGETABLE_ENTRIES_PAE     512
+#define L2_PAGETABLE_ENTRIES_PAE     512
+#define L3_PAGETABLE_ENTRIES_PAE       4
 
-#define L1_PAGETABLE_ENTRIES_I386 1024
-#define L2_PAGETABLE_ENTRIES_I386 1024
+#define L1_PAGETABLE_SHIFT_X86_64     12
+#define L2_PAGETABLE_SHIFT_X86_64     21
+#define L3_PAGETABLE_SHIFT_X86_64     30
+#define L4_PAGETABLE_SHIFT_X86_64     39
+#define L1_PAGETABLE_ENTRIES_X86_64  512
+#define L2_PAGETABLE_ENTRIES_X86_64  512
+#define L3_PAGETABLE_ENTRIES_X86_64  512
+#define L4_PAGETABLE_ENTRIES_X86_64  512
 
 #if defined(__i386__)
-#define L1_PAGETABLE_ENTRIES   1024
-#define L2_PAGETABLE_ENTRIES   1024
+#define L1_PAGETABLE_SHIFT     L1_PAGETABLE_SHIFT_I386
+#define L2_PAGETABLE_SHIFT     L2_PAGETABLE_SHIFT_I386
+#define L1_PAGETABLE_ENTRIES   L1_PAGETABLE_ENTRIES_I386
+#define L2_PAGETABLE_ENTRIES   L2_PAGETABLE_ENTRIES_I386
 #elif defined(__x86_64__)
-#define L1_PAGETABLE_ENTRIES    512
-#define L2_PAGETABLE_ENTRIES    512
-#define L3_PAGETABLE_ENTRIES    512
-#define L4_PAGETABLE_ENTRIES    512
+#define L1_PAGETABLE_SHIFT     L1_PAGETABLE_SHIFT_X86_64
+#define L2_PAGETABLE_SHIFT     L2_PAGETABLE_SHIFT_X86_64
+#define L3_PAGETABLE_SHIFT     L3_PAGETABLE_SHIFT_X86_64
+#define L4_PAGETABLE_SHIFT     L4_PAGETABLE_SHIFT_X86_64
+#define L1_PAGETABLE_ENTRIES   L1_PAGETABLE_ENTRIES_X86_64
+#define L2_PAGETABLE_ENTRIES   L2_PAGETABLE_ENTRIES_X86_64
+#define L3_PAGETABLE_ENTRIES   L3_PAGETABLE_ENTRIES_X86_64
+#define L4_PAGETABLE_ENTRIES   L4_PAGETABLE_ENTRIES_X86_64
 #endif
 
 typedef uint32_t l1_pgentry_32_t;
@@ -84,13 +88,23 @@ typedef uint32_t l2_pgentry_32_t;
 typedef uint64_t l1_pgentry_64_t;
 typedef uint64_t l2_pgentry_64_t;
 typedef uint64_t l3_pgentry_64_t;
-typedef unsigned long l1_pgentry_t;
-typedef unsigned long l2_pgentry_t;
-#if defined(__x86_64__)
-typedef unsigned long l3_pgentry_t;
-typedef unsigned long l4_pgentry_t;
+typedef uint64_t l4_pgentry_64_t;
+
+#if defined(__i386__)
+typedef l1_pgentry_32_t l1_pgentry_t;
+typedef l2_pgentry_32_t l2_pgentry_t;
+#elif defined(__x86_64__)
+typedef l1_pgentry_64_t l1_pgentry_t;
+typedef l2_pgentry_64_t l2_pgentry_t;
+typedef l3_pgentry_64_t l3_pgentry_t;
+typedef l4_pgentry_64_t l4_pgentry_t;
 #endif
 
+#define l1_table_offset_i386(_a) \
+  (((_a) >> L1_PAGETABLE_SHIFT_I386) & (L1_PAGETABLE_ENTRIES_I386 - 1))
+#define l2_table_offset_i386(_a) \
+  (((_a) >> L2_PAGETABLE_SHIFT_I386) & (L2_PAGETABLE_ENTRIES_I386 - 1))
+
 #define l1_table_offset_pae(_a) \
   (((_a) >> L1_PAGETABLE_SHIFT_PAE) & (L1_PAGETABLE_ENTRIES_PAE - 1))
 #define l2_table_offset_pae(_a) \
@@ -98,27 +112,33 @@ typedef unsigned long l4_pgentry_t;
 #define l3_table_offset_pae(_a) \
   (((_a) >> L3_PAGETABLE_SHIFT_PAE) & (L3_PAGETABLE_ENTRIES_PAE - 1))
 
-#define l1_table_offset_i386(_a) \
-  (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES_I386 - 1))
-#define l2_table_offset_i386(_a) \
-  (((_a) >> L2_PAGETABLE_SHIFT_I386) & (L2_PAGETABLE_ENTRIES_I386 - 1))
+#define l1_table_offset_x86_64(_a) \
+  (((_a) >> L1_PAGETABLE_SHIFT_X86_64) & (L1_PAGETABLE_ENTRIES_X86_64 - 1))
+#define l2_table_offset_x86_64(_a) \
+  (((_a) >> L2_PAGETABLE_SHIFT_X86_64) & (L2_PAGETABLE_ENTRIES_X86_64 - 1))
+#define l3_table_offset_x86_64(_a) \
+  (((_a) >> L3_PAGETABLE_SHIFT_X86_64) & (L3_PAGETABLE_ENTRIES_X86_64 - 1))
+#define l4_table_offset_x86_64(_a) \
+  (((_a) >> L4_PAGETABLE_SHIFT_X86_64) & (L4_PAGETABLE_ENTRIES_X86_64 - 1))
 
 #if defined(__i386__)
-#define l1_table_offset(_a) \
-          (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
-#define l2_table_offset(_a) \
-          ((_a) >> L2_PAGETABLE_SHIFT)
+#define l1_table_offset(_a) l1_table_offset_i386(_a)
+#define l2_table_offset(_a) l2_table_offset_i386(_a)
 #elif defined(__x86_64__)
-#define l1_table_offset(_a) \
-  (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
-#define l2_table_offset(_a) \
-  (((_a) >> L2_PAGETABLE_SHIFT) & (L2_PAGETABLE_ENTRIES - 1))
-#define l3_table_offset(_a) \
-  (((_a) >> L3_PAGETABLE_SHIFT) & (L3_PAGETABLE_ENTRIES - 1))
-#define l4_table_offset(_a) \
-  (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
+#define l1_table_offset(_a) l1_table_offset_x86_64(_a)
+#define l2_table_offset(_a) l2_table_offset_x86_64(_a)
+#define l3_table_offset(_a) l3_table_offset_x86_64(_a)
+#define l4_table_offset(_a) l4_table_offset_x86_64(_a)
 #endif
 
+#define PAGE_SHIFT_X86          12
+#define PAGE_SIZE_X86           (1UL << PAGE_SHIFT_X86)
+#define PAGE_MASK_X86           (~(PAGE_SIZE_X86-1))
+
+#define PAGE_SHIFT_IA64         14
+#define PAGE_SIZE_IA64          (1UL << PAGE_SHIFT_IA64)
+#define PAGE_MASK_IA64          (~(PAGE_SIZE_IA64-1))
+
 struct domain_setup_info
 {
     uint64_t v_start;
#4 lore raw

PATCH 4/6 libxc domain builder rewrite, core bits.

In reply to Gerd Hoffmann
---
 tools/libxc/Makefile           |   14 
 tools/libxc/xc_dom.h           |  261 +++++++++++++
 tools/libxc/xc_dom_binloader.c |  294 +++++++++++++++
 tools/libxc/xc_dom_boot.c      |  515 +++++++++++++++++++++++++++
 tools/libxc/xc_dom_core.c      |  773 +++++++++++++++++++++++++++++++++++++++++
 tools/libxc/xc_dom_elfloader.c |  283 +++++++++++++++
 tools/libxc/xc_dom_ia64.c      |  118 ++++++
 tools/libxc/xc_dom_powerpc64.c |  100 +++++
 tools/libxc/xc_dom_x86.c       |  559 +++++++++++++++++++++++++++++
 9 files changed, 2917 insertions(+)
tools/libxc/Makefile +14 -0
Index: build-32-unstable-13568/tools/libxc/Makefile
===================================================================
@@ -45,6 +45,20 @@ $(LIBELF_SRCS) libelf-private.h:
 # add libelf bits to libxc
 GUEST_SRCS-y += $(LIBELF_SRCS)
 
+# new domain builder
+GUEST_SRCS-y += xc_dom_core.c xc_dom_boot.c
+GUEST_SRCS-y += xc_dom_elfloader.c
+GUEST_SRCS-y += xc_dom_binloader.c
+
+ifeq ($(CONFIG_POWERPC),y)
+# big endian boxes
+GUEST_SRCS-y += xc_dom_powerpc64.c
+else
+# little endian boxes
+GUEST_SRCS-y += xc_dom_x86.c
+GUEST_SRCS-y += xc_dom_ia64.c
+endif
+
 -include $(XEN_TARGET_ARCH)/Makefile
 
 CFLAGS   += -Werror -Wmissing-prototypes
tools/libxc/xc_dom.h new file +261 -0

261 lines not on this page · raw message

tools/libxc/xc_dom_boot.c new file +515 -0

515 lines not on this page · raw message

tools/libxc/xc_dom_core.c new file +773 -0

773 lines not on this page · raw message

tools/libxc/xc_dom_ia64.c new file +118 -0

118 lines not on this page · raw message

tools/libxc/xc_dom_x86.c new file +559 -0

559 lines not on this page · raw message

tools/libxc/xc_dom_powerpc64.c new file +100 -0

100 lines not on this page · raw message

tools/libxc/xc_dom_elfloader.c new file +283 -0

283 lines not on this page · raw message

tools/libxc/xc_dom_binloader.c new file +294 -0

294 lines not on this page · raw message

#5 lore raw

PATCH 5/6 libxc domain builder rewrite, linux builder

In reply to Gerd Hoffmann

use new domain builder for the linux (aka generic elf) loader.

---
 tools/libxc/Makefile              |    7 +-
 tools/libxc/xc_dom_compat_linux.c |  124 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+), 2 deletions(-)
tools/libxc/xc_dom_compat_linux.c new file +124 -0
Index: build-32-release304-12901/tools/libxc/xc_dom_compat_linux.c
===================================================================
@@ -0,0 +1,124 @@
+/*
+ * Xen domain builder -- compatibility code.
+ *
+ * Replacements for xc_linux_build & friends,
+ * as example code and to make the new builder
+ * usable as drop-in replacement.
+ *
+ * This code is licenced under the GPL.
+ * written 2006 by Gerd Hoffmann <[email protected]>.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <zlib.h>
+
+#include "xenctrl.h"
+#include "xg_private.h"
+#include "xc_dom.h"
+
+/* ------------------------------------------------------------------------ */
+
+static int xc_linux_build_internal(struct xc_dom_image *dom,
+				   int xc_handle, uint32_t domid,
+				   unsigned int mem_mb,
+				   unsigned long flags,
+				   unsigned int store_evtchn,
+				   unsigned long *store_mfn,
+				   unsigned int console_evtchn,
+				   unsigned long *console_mfn)
+{
+    int rc;
+
+    if (0 != (rc = xc_dom_boot_xen_init(dom, xc_handle, domid)))
+	goto out;
+    if (0 != (rc = xc_dom_parse_image(dom)))
+	goto out;
+    if (0 != (rc = xc_dom_mem_init(dom, mem_mb)))
+	goto out;
+    if (0 != (rc = xc_dom_boot_mem_init(dom)))
+	goto out;
+    if (0 != (rc = xc_dom_build_image(dom)))
+	goto out;
+
+    dom->flags = flags;
+    dom->console_evtchn = console_evtchn;
+    dom->xenstore_evtchn = store_evtchn;
+    rc = xc_dom_boot_image(dom);
+    if (0 != rc)
+	goto out;
+
+    *console_mfn = xc_dom_p2m_host(dom, dom->console_pfn);
+    *store_mfn = xc_dom_p2m_host(dom, dom->xenstore_pfn);
+
+  out:
+    return rc;
+}
+
+int xc_linux_build_mem(int xc_handle, uint32_t domid,
+		       unsigned int mem_mb,
+		       const char *image_buffer,
+		       unsigned long image_size,
+		       const char *initrd,
+		       unsigned long initrd_len,
+		       const char *cmdline,
+		       const char *features,
+		       unsigned long flags,
+		       unsigned int store_evtchn,
+		       unsigned long *store_mfn,
+		       unsigned int console_evtchn, unsigned long *console_mfn)
+{
+    struct xc_dom_image *dom;
+    int rc;
+
+    xc_dom_loginit();
+    dom = xc_dom_allocate(cmdline, features);
+    if (0 != (rc = xc_dom_kernel_mem(dom, image_buffer, image_size)))
+	goto out;
+    if (initrd)
+	if (0 != (rc = xc_dom_ramdisk_mem(dom, initrd, initrd_len)))
+	    goto out;
+
+    rc = xc_linux_build_internal(dom, xc_handle, domid,
+				 mem_mb, flags,
+				 store_evtchn, store_mfn,
+				 console_evtchn, console_mfn);
+
+  out:
+    xc_dom_release(dom);
+    return rc;
+}
+
+int xc_linux_build(int xc_handle, uint32_t domid,
+		   unsigned int mem_mb,
+		   const char *image_name,
+		   const char *initrd_name,
+		   const char *cmdline,
+		   const char *features,
+		   unsigned long flags,
+		   unsigned int store_evtchn,
+		   unsigned long *store_mfn,
+		   unsigned int console_evtchn, unsigned long *console_mfn)
+{
+    struct xc_dom_image *dom;
+    int rc;
+
+    xc_dom_loginit();
+    dom = xc_dom_allocate(cmdline, features);
+    if (0 != (rc = xc_dom_kernel_file(dom, image_name)))
+	goto out;
+    if (initrd_name && strlen(initrd_name))
+	if (0 != (rc = xc_dom_ramdisk_file(dom, initrd_name)))
+	    goto out;
+
+    rc = xc_linux_build_internal(dom, xc_handle, domid,
+				 mem_mb, flags,
+				 store_evtchn, store_mfn,
+				 console_evtchn, console_mfn);
+
+  out:
+    xc_dom_release(dom);
+    return rc;
+}
tools/libxc/Makefile +5 -2
Index: build-32-release304-12901/tools/libxc/Makefile
===================================================================
@@ -24,8 +24,8 @@ GUEST_SRCS-y :=
 GUEST_SRCS-y += xc_load_bin.c
 GUEST_SRCS-y += xc_load_elf.c
 GUEST_SRCS-y += xg_private.c
-GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c
-GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c
+#GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c
+#GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c
 GUEST_SRCS-$(CONFIG_MIGRATE) += xc_linux_restore.c xc_linux_save.c
 GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c
 
@@ -58,6 +58,9 @@ GUEST_SRCS-y += xc_dom_x86.c
 GUEST_SRCS-y += xc_dom_ia64.c
 endif
 
+GUEST_SRCS-$(CONFIG_X86)     += xc_dom_compat_linux.c
+GUEST_SRCS-$(CONFIG_IA64)    += xc_dom_compat_linux.c
+
 -include $(XEN_TARGET_ARCH)/Makefile
 
 CFLAGS   += -Werror -Wmissing-prototypes
#6 lore raw

PATCH 6/6 Support transparant gunzipping in the readnotes utility.

In reply to Gerd Hoffmann
---
 tools/xcutils/readnotes.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
tools/xcutils/readnotes.c +12 -2
Index: build-32-unstable-12621/tools/xcutils/readnotes.c
===================================================================
@@ -11,6 +11,7 @@
 #include <sys/mman.h>
 
 #include <xg_private.h>
+#include <xc_dom.h> /* gunzip bits */
 
 #include <xen/libelf.h>
 
@@ -33,8 +34,8 @@ static void print_numeric_note(const cha
 int main(int argc, char **argv)
 {
 	const char *f;
-	int fd,h,size,count;
-	void *image;
+	int fd,h,size,usize,count;
+	void *image,*tmp;
 	struct stat st;
 	struct elf_binary elf;
 	const elf_shdr *shdr;
@@ -68,6 +69,15 @@ int main(int argc, char **argv)
 	}
 	size = st.st_size;
 
+	usize = xc_dom_check_gzip(image, st.st_size);
+	if (usize)
+	{
+		tmp = malloc(size);
+		xc_dom_do_gunzip(image, st.st_size, tmp, size);
+		image = tmp;
+		size = usize;
+	}
+
 	if (0 != elf_init(&elf, image, size))
 	{
 		fprintf(stderr, "File %s is not an ELF image\n", f);
#7 lore raw
In reply to Gerd Hoffmann

Hi Gerd,

Am Donnerstag, 25. Januar 2007 17:19 schrieb Gerd Hoffmann:

Quoted 8 lines

This patchset contains the domain builder rewrite. Main feature beside some general code cleanup is support for 32-on-64, i.e. it is possible to create non-native domains amd thus mix 32pae and 64bit domains on the same machine. The patches come with individual descriptions. The patchset depends on the libelf patches posted earlier this week.

cheers,
Gerd

I tried out the new domain builder on xen-ia64 with my ported mini-os in big endian mode and the only change I had to do was to define a second struct xc_dom_arch with the new guest type in xc_dom_ia64.c:

static struct xc_dom_arch xc_dom_arch_ia64_be = {
    .guest_type = "xen-3.0-ia64be",
    .page_shift = PAGE_SHIFT_IA64,
    .alloc_magic_pages = alloc_magic_pages,
    .start_info = start_info_ia64,
    .shared_info = shared_info_ia64,
    .vcpu = vcpu_ia64,
};

With some small patches in the ia64-hypervisor the image got loaded and startet. Good work ;-).
Thanks.

Dietmar.

#8 lore raw
In reply to Gerd Hoffmann
Quoted 5 lines · Gerd Hoffmann

This patchset contains the domain builder rewrite. Main feature beside some general code cleanup is support for 32-on-64, i.e. it is possible to create non-native domains amd thus mix 32pae and 64bit domains on the same machine. The patches come with individual descriptions. The patchset depends on the libelf patches posted earlier this week.

How can I return an error message from the architecture part of the domain builder that will be displayed by xm create?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#9 lore raw
Quoted 2 lines · Hollis Blanchard

How can I return an error message from the architecture part of the domain builder that will be displayed by xm create?

xc_dom_panic() takes an error code and a message to be printed. It's also logged with source file and line number in /var/log/xen/domain-builder-ng.log.

xc_dom_printf() can be used to log (debug) messages to the same file.

HTH,
Gerd