From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andres Lagar-Cavilla Subject: [PATCH 04/14]: libxenlight, avoid writing empty values to xenstore Date: Mon, 30 Nov 2009 14:11:41 -0500 Message-ID: <4B1418ED.70306@lagarcavilla.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030700000502010905050507" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------030700000502010905050507 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Prevent segmentation fault caused by empty values in key-value pairs for the /vm/ subdirectory when creating a pv domain. Signed-off-by: Andres Lagar-Cavilla --------------030700000502010905050507 Content-Type: text/x-patch; name="04_avoid_segfault_empty_vm_values.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="04_avoid_segfault_empty_vm_values.patch" # HG changeset patch # User Andres Lagar-Cavilla # Date 1259166041 18000 # Node ID ef6525f1ea939e2e283929428c1c78e53b90a819 # Parent aba8d2df7e42c185f77a17e47b491385a65383f1 Prevent segmentation fault caused by empty values in key-value pairs for the /vm/ subdirectory when creating a pv domain. Signed-off-by: Andres Lagar-Cavilla diff -r aba8d2df7e42 -r ef6525f1ea93 libxl.c --- a/libxl.c +++ b/libxl.c @@ -191,6 +191,7 @@ retry_transaction: int libxl_domain_build(struct libxl_ctx *ctx, libxl_domain_build_info *info, uint32_t domid, libxl_domain_build_state *state) { char **vments = NULL, **localents = NULL; + int i; build_pre(ctx, domid, info, state); if (info->hvm) { @@ -203,14 +204,19 @@ int libxl_domain_build(struct libxl_ctx } else { build_pv(ctx, domid, info, state); 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); return 0; --------------030700000502010905050507 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------030700000502010905050507--