From: Ian Campbell Subject: Re: [PATCH 1/2] libxl: open logs with O_APPEND Date: Mon, 28 Nov 2011 13:08:45 +0000 Message-ID: <1322485725.1005.290.camel@zakaz.uk.xensource.com> References: <20179.32337.102834.867932@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20179.32337.102834.867932@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Mon, 2011-11-28 at 12:28 +0000, Ian Jackson wrote: > Logfiles should always be opened for append. > > Signed-off-by: Ian Jackson Both this and the 2/2 patch look sensible to me and are: Acked-by: Ian Campbell > diff -r a9c67c2daf4b tools/libxl/libxl_dm.c > --- a/tools/libxl/libxl_dm.c Mon Nov 28 11:57:23 2011 +0000 > +++ b/tools/libxl/libxl_dm.c Mon Nov 28 12:25:52 2011 +0000 > @@ -830,7 +830,7 @@ int libxl__create_device_model(libxl__gc > libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", path), "%d", !info->xen_platform_pci); > > libxl_create_logfile(ctx, libxl__sprintf(gc, "qemu-dm-%s", info->dom_name), &logfile); > - logfile_w = open(logfile, O_WRONLY|O_CREAT, 0644); > + logfile_w = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644); > free(logfile); > null = open("/dev/null", O_RDONLY); > > diff -r a9c67c2daf4b tools/libxl/xl_cmdimpl.c > --- a/tools/libxl/xl_cmdimpl.c Mon Nov 28 11:57:23 2011 +0000 > +++ b/tools/libxl/xl_cmdimpl.c Mon Nov 28 12:25:52 2011 +0000 > @@ -1597,7 +1597,8 @@ start: > exit(-1); > } > > - CHK_ERRNO(( logfile = open(fullname, O_WRONLY|O_CREAT, 0644) )<0); > + CHK_ERRNO(( logfile = open(fullname, O_WRONLY|O_CREAT|O_APPEND, > + 0644) )<0); fullname here came from libxl_create_logfile so has been rotated such that the file will be empty. I don't think O_APPEND is harmful or wrong given this though. Do we need to arrange for libxl_create_logfile to be called for some of these others though? Ian. > free(fullname); > free(name); > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel