1 /*
2 * Xen domain builder -- compatibility code.
3 *
4 * Replacements for xc_linux_build & friends,
5 * as example code and to make the new builder
6 * usable as drop-in replacement.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation;
11 * version 2.1 of the License.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; If not, see <http://www.gnu.org/licenses/>.
20 *
21 * written 2006 by Gerd Hoffmann <kraxel@suse.de>.
22 *
23 */
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <inttypes.h>
29 #include <zlib.h>
30
31 #include "xenctrl.h"
32 #include "xg_private.h"
33 #include "xc_dom.h"
34
35 /* ------------------------------------------------------------------------ */
36
xc_linux_build(xc_interface * xch,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)37 int xc_linux_build(xc_interface *xch, uint32_t domid,
38 unsigned int mem_mb,
39 const char *image_name,
40 const char *initrd_name,
41 const char *cmdline,
42 const char *features,
43 unsigned long flags,
44 unsigned int store_evtchn,
45 unsigned long *store_mfn,
46 unsigned int console_evtchn,
47 unsigned long *console_mfn)
48 {
49 struct xc_dom_image *dom;
50 int rc;
51
52 xc_dom_loginit(xch);
53 dom = xc_dom_allocate(xch, cmdline, features);
54 if (dom == NULL)
55 return -1;
56 if ( (rc = xc_dom_kernel_file(dom, image_name)) != 0 )
57 goto out;
58 if ( initrd_name && strlen(initrd_name) &&
59 ((rc = xc_dom_module_file(dom, initrd_name, NULL)) != 0) )
60 goto out;
61
62 dom->flags |= flags;
63 dom->console_evtchn = console_evtchn;
64 dom->xenstore_evtchn = store_evtchn;
65
66 if ( (rc = xc_dom_boot_xen_init(dom, xch, domid)) != 0 )
67 goto out;
68 if ( (rc = xc_dom_parse_image(dom)) != 0 )
69 goto out;
70 if ( (rc = xc_dom_mem_init(dom, mem_mb)) != 0 )
71 goto out;
72 if ( (rc = xc_dom_boot_mem_init(dom)) != 0 )
73 goto out;
74 if ( (rc = xc_dom_build_image(dom)) != 0 )
75 goto out;
76 if ( (rc = xc_dom_boot_image(dom)) != 0 )
77 goto out;
78 if ( (rc = xc_dom_gnttab_init(dom)) != 0)
79 goto out;
80
81 *console_mfn = xc_dom_p2m(dom, dom->console_pfn);
82 *store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
83
84 out:
85 xc_dom_release(dom);
86 return rc;
87 }
88
89 /*
90 * Local variables:
91 * mode: C
92 * c-file-style: "BSD"
93 * c-basic-offset: 4
94 * tab-width: 4
95 * indent-tabs-mode: nil
96 * End:
97 */
98