[libvirt] [PATCH]lxc: goto cleanup if lxcContainerBuildInitCmd returns NULL
Chen Hanxiao
chenhanxiao at cn.fujitsu.com
Mon Sep 30 09:26:28 UTC 2013
> -----Original Message-----
> From: Daniel P. Berrange [mailto:berrange at redhat.com]
> Sent: Monday, September 30, 2013 4:51 PM
> To: Chen Hanxiao
> Cc: libvir-list at redhat.com
> Subject: Re: [libvirt] [PATCH]lxc: goto cleanup if lxcContainerBuildInitCmd
> returns NULL
>
> On Mon, Sep 30, 2013 at 04:20:14PM +0800, Chen Hanxiao wrote:
> > From: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
> >
> > We should goto cleanup directly
> > if lxcContainerBuildInitCmd returns NULL,
> > which would avoid lots of unnecessary works.
> >
> > Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
> > ---
> > src/lxc/lxc_container.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> > index 3fdf397..f03f236 100644
> > --- a/src/lxc/lxc_container.c
> > +++ b/src/lxc/lxc_container.c
> > @@ -1820,7 +1820,10 @@ static int lxcContainerChild(void *data)
> > if ((hasReboot = lxcContainerHasReboot()) < 0)
> > goto cleanup;
> >
> > - cmd = lxcContainerBuildInitCmd(vmDef);
> > + if (!(cmd = lxcContainerBuildInitCmd(vmDef))) {
> > + VIR_DEBUG("Failed to build init cmd for container");
> > + goto cleanup;
> > + }
> > virCommandWriteArgLog(cmd, 1);
>
> This is not required - the virCommand APIs are designed to handle
> NULL for cmd - they do delayed error reporting.
>
Thanks, I see.
I just don't want lxcContainerChild to have finished all preparation
and then find nothing to do due to an OOM occurred :)
>
> Daniel
> --
> |: http://berrange.com -o-
> http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org -o-
> http://virt-manager.org :|
> |: http://autobuild.org -o-
> http://search.cpan.org/~danberr/ :|
> |: http://entangle-photo.org -o-
> http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list