aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_dom.c
diff options
context:
space:
mode:
authorIan Campbell <Ian.Campbell@citrix.com>2012-05-29 10:31:38 +0100
committerIan Campbell <Ian.Campbell@citrix.com>2012-05-29 10:31:38 +0100
commit731a050623bd2a10a4d48176da3a79fb549d8114 (patch)
tree2c715eb78bab736c32aa3f327253a629900461a6 /tools/libxl/libxl_dom.c
parent8d7aec41547d798761dcb308387f276667f9989a (diff)
downloadxen-731a050623bd2a10a4d48176da3a79fb549d8114.tar.gz
xen-731a050623bd2a10a4d48176da3a79fb549d8114.tar.bz2
xen-731a050623bd2a10a4d48176da3a79fb549d8114.zip
libxl: do not overwrite user supplied config when running bootloader
Currently when running the bootloader libxl will update b_info->u.pv.kernel, .ramdisk, .cmdline and .bootloader. This can expose internal details, such as temporary paths in /var/run/xen/bootloader.*/ to the user. This is problematic because it means that the user cannot re-use the struct as is. This does not effect xl in Xen 4.2+ since it always reparses the guest config and reinitialises the build info, however it did cause issues with reboot in 4.1 (reported by Dmitry Morozhnikov) and may cause issues for other users of libxl. Instead make the libxl bootloader infrastructure provide output to its caller which is slurped into the internal libxl__domain_build_state datastructure. If no bootloader is configured then the bootloader instead propagates the user supplied b_info config. In order to simplify this push the error handling for the case where there is no bootdisk down into libxl__bootloader_run. In principal there is no reason why it shouldn't be possible to do a pure netboot guest with a suitable bootloader, but I don't fix that here. This change allow us to make the libxl_file_reference an internal API, and eventually we might be able to get rid of it. Also removes the publix libxl_run_bootloader interface, neither xl nor libvirt use it. I am proposing this for 4.2 due to the API change. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> [ ijc -- reduced log message in libxl__build_pv from INFO to DEBUG ] Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_dom.c')
-rw-r--r--tools/libxl/libxl_dom.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index e42730f846..06dbc926f3 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -240,36 +240,37 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
xc_dom_loginit(ctx->xch);
- dom = xc_dom_allocate(ctx->xch, info->u.pv.cmdline, info->u.pv.features);
+ dom = xc_dom_allocate(ctx->xch, state->pv_cmdline, info->u.pv.features);
if (!dom) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_allocate failed");
return ERROR_FAIL;
}
- if (info->u.pv.kernel.mapped) {
+ LOG(DEBUG, "pv kernel mapped %d path %s\n", state->pv_kernel.mapped, state->pv_kernel.path);
+ if (state->pv_kernel.mapped) {
ret = xc_dom_kernel_mem(dom,
- info->u.pv.kernel.data,
- info->u.pv.kernel.size);
+ state->pv_kernel.data,
+ state->pv_kernel.size);
if ( ret != 0) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_mem failed");
goto out;
}
} else {
- ret = xc_dom_kernel_file(dom, info->u.pv.kernel.path);
+ ret = xc_dom_kernel_file(dom, state->pv_kernel.path);
if ( ret != 0) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_file failed");
goto out;
}
}
- if ( info->u.pv.ramdisk.path && strlen(info->u.pv.ramdisk.path) ) {
- if (info->u.pv.ramdisk.mapped) {
- if ( (ret = xc_dom_ramdisk_mem(dom, info->u.pv.ramdisk.data, info->u.pv.ramdisk.size)) != 0 ) {
+ if ( state->pv_ramdisk.path && strlen(state->pv_ramdisk.path) ) {
+ if (state->pv_ramdisk.mapped) {
+ if ( (ret = xc_dom_ramdisk_mem(dom, state->pv_ramdisk.data, state->pv_ramdisk.size)) != 0 ) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_mem failed");
goto out;
}
} else {
- if ( (ret = xc_dom_ramdisk_file(dom, info->u.pv.ramdisk.path)) != 0 ) {
+ if ( (ret = xc_dom_ramdisk_file(dom, state->pv_ramdisk.path)) != 0 ) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_file failed");
goto out;
}
@@ -314,6 +315,9 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
state->console_mfn = xc_dom_p2m_host(dom, dom->console_pfn);
state->store_mfn = xc_dom_p2m_host(dom, dom->xenstore_pfn);
+ libxl__file_reference_unmap(&state->pv_kernel);
+ libxl__file_reference_unmap(&state->pv_ramdisk);
+
ret = 0;
out:
xc_dom_release(dom);