WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [patch 5/6] libxc domain builder rewrite, linux builder

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [patch 5/6] libxc domain builder rewrite, linux builder
From: Gerd Hoffmann <kraxel@xxxxxxx>
Date: Thu, 25 Jan 2007 17:19:21 +0100
Cc: ack@xxxxxxxxxxxxx
Delivery-date: Fri, 26 Jan 2007 01:55:13 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20070125161916.736076000@xxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-14
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(-)

Index: build-32-release304-12901/tools/libxc/xc_dom_compat_linux.c
===================================================================
--- /dev/null
+++ 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 <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;
+}
Index: build-32-release304-12901/tools/libxc/Makefile
===================================================================
--- build-32-release304-12901.orig/tools/libxc/Makefile
+++ 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

-- 

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