All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@suse.de>
To: xen-devel@lists.xensource.com
Cc: ack@xensource.com
Subject: [patch 5/6] libxc domain builder rewrite, linux builder
Date: Thu, 25 Jan 2007 17:19:21 +0100	[thread overview]
Message-ID: <20070125161927.319598000@suse.de> (raw)
In-Reply-To: 20070125161916.736076000@suse.de

[-- Attachment #1: tools-domain-builder-linux.diff --]
[-- Type: text/plain, Size: 4797 bytes --]

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

Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
---
 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@suse.de>.
+ *
+ */
+#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

-- 

  parent reply	other threads:[~2007-01-25 16:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-25 16:19 [patch 0/6] domain builder patches Gerd Hoffmann
2007-01-25 16:19 ` [patch 1/6] Generate headers with arch-specific structs Gerd Hoffmann
2007-01-25 16:19 ` [patch 2/6] Add more xc_error_code values Gerd Hoffmann
2007-01-25 16:19 ` [patch 3/6] libxc header fixups Gerd Hoffmann
2007-01-25 16:19 ` [patch 4/6] libxc domain builder rewrite, core bits Gerd Hoffmann
2007-01-25 16:19 ` Gerd Hoffmann [this message]
2007-01-25 16:19 ` [patch 6/6] Support transparant gunzipping in the readnotes utility Gerd Hoffmann
2007-02-13 14:54 ` [patch 0/6] domain builder patches Dietmar Hahn
2007-03-08 21:11 ` Hollis Blanchard
2007-03-13 10:04   ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070125161927.319598000@suse.de \
    --to=kraxel@suse.de \
    --cc=ack@xensource.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.