ia64/xen-unstable

changeset 13640:d42878949f63

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(-)
author Emmanuel Ackaouy <ack@xensource.com>
date Thu Jan 25 22:16:52 2007 +0000 (2007-01-25)
parents fd50500eee7c
children 9d1d9877131d
files tools/libxc/Makefile tools/libxc/xc_dom_compat_linux.c
line diff
     1.1 --- a/tools/libxc/Makefile	Thu Jan 25 22:16:52 2007 +0000
     1.2 +++ b/tools/libxc/Makefile	Thu Jan 25 22:16:52 2007 +0000
     1.3 @@ -25,8 +25,8 @@ GUEST_SRCS-y :=
     1.4  GUEST_SRCS-y += xc_load_bin.c
     1.5  GUEST_SRCS-y += xc_load_elf.c
     1.6  GUEST_SRCS-y += xg_private.c
     1.7 -GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c
     1.8 -GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c
     1.9 +#GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c
    1.10 +#GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c
    1.11  GUEST_SRCS-$(CONFIG_MIGRATE) += xc_linux_restore.c xc_linux_save.c
    1.12  GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c xc_hvm_restore.c xc_hvm_save.c
    1.13  
    1.14 @@ -59,6 +59,9 @@ GUEST_SRCS-y += xc_dom_x86.c
    1.15  GUEST_SRCS-y += xc_dom_ia64.c
    1.16  endif
    1.17  
    1.18 +GUEST_SRCS-$(CONFIG_X86)     += xc_dom_compat_linux.c
    1.19 +GUEST_SRCS-$(CONFIG_IA64)    += xc_dom_compat_linux.c
    1.20 +
    1.21  -include $(XEN_TARGET_ARCH)/Makefile
    1.22  
    1.23  CFLAGS   += -Werror -Wmissing-prototypes
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/libxc/xc_dom_compat_linux.c	Thu Jan 25 22:16:52 2007 +0000
     2.3 @@ -0,0 +1,124 @@
     2.4 +/*
     2.5 + * Xen domain builder -- compatibility code.
     2.6 + *
     2.7 + * Replacements for xc_linux_build & friends,
     2.8 + * as example code and to make the new builder
     2.9 + * usable as drop-in replacement.
    2.10 + *
    2.11 + * This code is licenced under the GPL.
    2.12 + * written 2006 by Gerd Hoffmann <kraxel@suse.de>.
    2.13 + *
    2.14 + */
    2.15 +#include <stdio.h>
    2.16 +#include <stdlib.h>
    2.17 +#include <string.h>
    2.18 +#include <inttypes.h>
    2.19 +#include <zlib.h>
    2.20 +
    2.21 +#include "xenctrl.h"
    2.22 +#include "xg_private.h"
    2.23 +#include "xc_dom.h"
    2.24 +
    2.25 +/* ------------------------------------------------------------------------ */
    2.26 +
    2.27 +static int xc_linux_build_internal(struct xc_dom_image *dom,
    2.28 +				   int xc_handle, uint32_t domid,
    2.29 +				   unsigned int mem_mb,
    2.30 +				   unsigned long flags,
    2.31 +				   unsigned int store_evtchn,
    2.32 +				   unsigned long *store_mfn,
    2.33 +				   unsigned int console_evtchn,
    2.34 +				   unsigned long *console_mfn)
    2.35 +{
    2.36 +    int rc;
    2.37 +
    2.38 +    if (0 != (rc = xc_dom_boot_xen_init(dom, xc_handle, domid)))
    2.39 +	goto out;
    2.40 +    if (0 != (rc = xc_dom_parse_image(dom)))
    2.41 +	goto out;
    2.42 +    if (0 != (rc = xc_dom_mem_init(dom, mem_mb)))
    2.43 +	goto out;
    2.44 +    if (0 != (rc = xc_dom_boot_mem_init(dom)))
    2.45 +	goto out;
    2.46 +    if (0 != (rc = xc_dom_build_image(dom)))
    2.47 +	goto out;
    2.48 +
    2.49 +    dom->flags = flags;
    2.50 +    dom->console_evtchn = console_evtchn;
    2.51 +    dom->xenstore_evtchn = store_evtchn;
    2.52 +    rc = xc_dom_boot_image(dom);
    2.53 +    if (0 != rc)
    2.54 +	goto out;
    2.55 +
    2.56 +    *console_mfn = xc_dom_p2m_host(dom, dom->console_pfn);
    2.57 +    *store_mfn = xc_dom_p2m_host(dom, dom->xenstore_pfn);
    2.58 +
    2.59 +  out:
    2.60 +    return rc;
    2.61 +}
    2.62 +
    2.63 +int xc_linux_build_mem(int xc_handle, uint32_t domid,
    2.64 +		       unsigned int mem_mb,
    2.65 +		       const char *image_buffer,
    2.66 +		       unsigned long image_size,
    2.67 +		       const char *initrd,
    2.68 +		       unsigned long initrd_len,
    2.69 +		       const char *cmdline,
    2.70 +		       const char *features,
    2.71 +		       unsigned long flags,
    2.72 +		       unsigned int store_evtchn,
    2.73 +		       unsigned long *store_mfn,
    2.74 +		       unsigned int console_evtchn, unsigned long *console_mfn)
    2.75 +{
    2.76 +    struct xc_dom_image *dom;
    2.77 +    int rc;
    2.78 +
    2.79 +    xc_dom_loginit();
    2.80 +    dom = xc_dom_allocate(cmdline, features);
    2.81 +    if (0 != (rc = xc_dom_kernel_mem(dom, image_buffer, image_size)))
    2.82 +	goto out;
    2.83 +    if (initrd)
    2.84 +	if (0 != (rc = xc_dom_ramdisk_mem(dom, initrd, initrd_len)))
    2.85 +	    goto out;
    2.86 +
    2.87 +    rc = xc_linux_build_internal(dom, xc_handle, domid,
    2.88 +				 mem_mb, flags,
    2.89 +				 store_evtchn, store_mfn,
    2.90 +				 console_evtchn, console_mfn);
    2.91 +
    2.92 +  out:
    2.93 +    xc_dom_release(dom);
    2.94 +    return rc;
    2.95 +}
    2.96 +
    2.97 +int xc_linux_build(int xc_handle, uint32_t domid,
    2.98 +		   unsigned int mem_mb,
    2.99 +		   const char *image_name,
   2.100 +		   const char *initrd_name,
   2.101 +		   const char *cmdline,
   2.102 +		   const char *features,
   2.103 +		   unsigned long flags,
   2.104 +		   unsigned int store_evtchn,
   2.105 +		   unsigned long *store_mfn,
   2.106 +		   unsigned int console_evtchn, unsigned long *console_mfn)
   2.107 +{
   2.108 +    struct xc_dom_image *dom;
   2.109 +    int rc;
   2.110 +
   2.111 +    xc_dom_loginit();
   2.112 +    dom = xc_dom_allocate(cmdline, features);
   2.113 +    if (0 != (rc = xc_dom_kernel_file(dom, image_name)))
   2.114 +	goto out;
   2.115 +    if (initrd_name && strlen(initrd_name))
   2.116 +	if (0 != (rc = xc_dom_ramdisk_file(dom, initrd_name)))
   2.117 +	    goto out;
   2.118 +
   2.119 +    rc = xc_linux_build_internal(dom, xc_handle, domid,
   2.120 +				 mem_mb, flags,
   2.121 +				 store_evtchn, store_mfn,
   2.122 +				 console_evtchn, console_mfn);
   2.123 +
   2.124 +  out:
   2.125 +    xc_dom_release(dom);
   2.126 +    return rc;
   2.127 +}