diff options
author | Emmanuel Ackaouy <ack@xensource.com> | 2007-01-25 22:16:52 +0000 |
---|---|---|
committer | Emmanuel Ackaouy <ack@xensource.com> | 2007-01-25 22:16:52 +0000 |
commit | 2be4a20325eaff61f1a14fe43de84a88fdf248f5 (patch) | |
tree | bf62a28a913a9284fcc3601f0f2ce88911e7023e /tools/libxc/xc_dom_compat_linux.c | |
parent | b4feb14b3dd705b59ce7a2d66fe0879d54e408e8 (diff) | |
download | xen-2be4a20325eaff61f1a14fe43de84a88fdf248f5.tar.gz xen-2be4a20325eaff61f1a14fe43de84a88fdf248f5.tar.bz2 xen-2be4a20325eaff61f1a14fe43de84a88fdf248f5.zip |
libxc domain builder rewrite, linux builder
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(-)
Diffstat (limited to 'tools/libxc/xc_dom_compat_linux.c')
-rw-r--r-- | tools/libxc/xc_dom_compat_linux.c | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/tools/libxc/xc_dom_compat_linux.c b/tools/libxc/xc_dom_compat_linux.c new file mode 100644 index 0000000000..c387cb88fe --- /dev/null +++ b/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; +} |