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

[Xen-changelog] [xen-unstable] libxc domain builder rewrite, linux builder



# HG changeset patch
# User Emmanuel Ackaouy <ack@xxxxxxxxxxxxx>
# Date 1169763412 0
# Node ID d42878949f63a3614b22c388cb82862b7d3c264e
# Parent  fd50500eee7ce4477b9e80413f1a2ea0dfe661c8
libxc domain builder rewrite, linux builder

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

Signed-off-by: Gerd Hoffmann <kraxel@xxxxxxx>
---
 tools/libxc/Makefile              |    7 +-
 tools/libxc/xc_dom_compat_linux.c |  124 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+), 2 deletions(-)

diff -r fd50500eee7c -r d42878949f63 tools/libxc/Makefile
--- a/tools/libxc/Makefile      Thu Jan 25 22:16:52 2007 +0000
+++ b/tools/libxc/Makefile      Thu Jan 25 22:16:52 2007 +0000
@@ -25,8 +25,8 @@ GUEST_SRCS-y += xc_load_bin.c
 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 xc_hvm_restore.c xc_hvm_save.c
 
@@ -58,6 +58,9 @@ GUEST_SRCS-y += xc_dom_x86.c
 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
 
diff -r fd50500eee7c -r d42878949f63 tools/libxc/xc_dom_compat_linux.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxc/xc_dom_compat_linux.c Thu Jan 25 22:16:52 2007 +0000
@@ -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 <kraxel@xxxxxxx>.
+ *
+ */
+#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;
+}

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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