From: Wei Liu Subject: Re: [PATCH] tools: xl: handle unspecified extra= when dealing with root= Date: Mon, 9 Mar 2015 13:00:27 +0000 Message-ID: <20150309130027.GS18491@zion.uk.xensource.com> References: <1425905336-12055-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1425905336-12055-1-git-send-email-ian.campbell@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Chunyan Liu , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Mon, Mar 09, 2015 at 12:48:56PM +0000, Ian Campbell wrote: > If the cfg file includes root= but not extra= (nor cmdline=, which > supercedes both) then the command line will end up with an extra > "(null)" on it (at least with glibc's implementation of asprintf). > > Signed-off-by: Ian Campbell > Cc: Chunyan Liu Acked-by: Wei Liu > --- > tools/libxl/xl_cmdimpl.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 96fbe63..2c32a96 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -817,9 +817,11 @@ static char *parse_cmdline(XLU_Config *config) > fprintf(stderr, "Warning: ignoring root= and extra= " > "in favour of cmdline=\n"); > } else { > - if (root) { > + if (root && extra) { > if (asprintf(&cmdline, "root=%s %s", root, extra) == -1) > cmdline = NULL; > + } else if (root) { > + cmdline = strdup(root); > } else if (extra) { > cmdline = strdup(extra); > } > -- > 1.7.10.4