From: Keir Fraser Date: Fri, 4 Dec 2009 07:09:44 +0000 (+0000) Subject: libxenlight: avoid writing empty values to xenstore X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12961 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=91064f9e07648d000118586573fbba8c9a5bdee3;p=xen.git libxenlight: avoid writing empty values to xenstore Prevent segmentation fault caused by empty values in key-value pairs for the /vm/ subdirectory when restoring a pv domain. Signed-off-by: Andres Lagar-Cavilla --- diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index b101acb48b..54e7b72f41 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -229,6 +229,7 @@ int libxl_domain_restore(struct libxl_ctx *ctx, libxl_domain_build_info *info, libxl_device_model_info *dm_info) { char **vments = NULL, **localents = NULL; + int i; build_pre(ctx, domid, info, state); restore_common(ctx, domid, info, state, fd); @@ -240,14 +241,19 @@ int libxl_domain_restore(struct libxl_ctx *ctx, libxl_domain_build_info *info, vments[3] = "hvm"; } else { vments = libxl_calloc(ctx, 9, sizeof(char *)); - vments[0] = "image/ostype"; - vments[1] = "linux"; - vments[2] = "image/kernel"; - vments[3] = (char*) info->kernel; - vments[4] = "image/ramdisk"; - vments[5] = (char*) info->u.pv.ramdisk; - vments[6] = "image/cmdline"; - vments[7] = (char*) info->u.pv.cmdline; + i = 0; + vments[i++] = "image/ostype"; + vments[i++] = "linux"; + vments[i++] = "image/kernel"; + vments[i++] = (char*) info->kernel; + if (info->u.pv.ramdisk) { + vments[i++] = "image/ramdisk"; + vments[i++] = (char*) info->u.pv.ramdisk; + } + if (info->u.pv.cmdline) { + vments[i++] = "image/cmdline"; + vments[i++] = (char*) info->u.pv.cmdline; + } } build_post(ctx, domid, info, state, vments, localents); if (info->hvm)