[Libvir] [RFC] 3/3 Driver functions for linux container support

2008-02-20 Thread Dave Leskovec
This patch contains the new files lxc_driver.c and lxc_driver.h Index: src/lxc_driver.c === RCS file: src/lxc_driver.c diff -N src/lxc_driver.c --- /dev/null1 Jan 1970 00:00:00 - +++ src/lxc_driver.c19 Feb 2008 18:54:30

[Libvir] [RFC] 2/3 Config functions for managing linux containers

2008-02-20 Thread Dave Leskovec
This patch contains the new files lxc_conf.c and lxc_conf.h Index: src/lxc_conf.c === RCS file: src/lxc_conf.c diff -N src/lxc_conf.c --- /dev/null1 Jan 1970 00:00:00 - +++ src/lxc_conf.c20 Feb 2008 23:02:14 - @@ -0,0

[Libvir] [RFC] 1/3 Base linux container support

2008-02-20 Thread Dave Leskovec
This patch contains the base linux container support * new switch --with-lxc to enable support (off by default) * Add new source files to Makefile.am * Add define for lxc in driver.h * Add call to lxcRegister() in libvirt.c * Add define for errors from lxc in virterror.h * Add case for errors fro

[Libvir] [RFC] 0/3 Add Linux Container support to libvirt

2008-02-20 Thread Dave Leskovec
The following set of patches add the first batch of linux container support to libvirt. The work is not complete but I wanted to start getting some of this out for comments. This set of patches supports the following: * new switch --with-lxc to enable linux container support (off by default)

Re: [Libvir] [PATCH] Rewrite openvzSetUUID.

2008-02-20 Thread Jim Meyering
I wrote: ... > diff --git a/src/openvz_conf.c b/src/openvz_conf.c ... > + FILE *fp = fopen(conf_file, "a"); > + if (fp == NULL) > + return -1; ... > + /* Record failure if fseek, fprintf or fclose fails, > +and be careful always to close the stream. */ > + if (fseek(f

Re: [Libvir] [PATCH] Use virErrorMsg in qemudReportError

2008-02-20 Thread Daniel P. Berrange
On Wed, Feb 20, 2008 at 12:28:23PM -0500, Cole Robinson wrote: > Currently the qemu driver doesn't use virErrorMsg when raising error > messages. This causes some errors to appear as "libvir: QEMU error: " > if a custom string wasn't raised, which isn't all that useful. The > patch below fixes this

Re: [Libvir] [PATCH] Rewrite openvzSetUUID.

2008-02-20 Thread Jim Meyering
Jim Paris <[EMAIL PROTECTED]> wrote: > Jim Meyering wrote: >> +/* Record failure if any of these fails, >> + and be careful always to close the stream. */ >> +if ((fseek(fp, 0, SEEK_END) < 0) >> ++ (fprintf(fp, "\n#UUID: %s\n", uuidstr) < 0); >> ++ (fclose(fp) == EOF

[Libvir] RFC: Updated async job public API

2008-02-20 Thread Daniel P. Berrange
A little over a month ago I proposed an API extension for enabling long operations to be done as asynchronous background jobs. http://www.redhat.com/archives/libvir-list/2008-January/msg00040.html While the proof of concept definitely worked, having played around & thought about it a little more

Re: [Libvir] [PATCH] Rewrite openvzSetUUID.

2008-02-20 Thread Jim Paris
Jim Meyering wrote: > + /* Record failure if any of these fails, > +and be careful always to close the stream. */ > + if ((fseek(fp, 0, SEEK_END) < 0) > + + (fprintf(fp, "\n#UUID: %s\n", uuidstr) < 0); > + + (fclose(fp) == EOF)) > + ret = -1; I don't think

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Paris
Jim Meyering wrote: > It *could* perform that test, but I think it is slightly more > maintainable (no duplication of that potentially nontrivial expression) > and just as correct to check only "ret < 0". Not having the duplicated expression is certainly good, if it's correct to do so (and it seem

Re: [Libvir] PATCH: 1/16: public API

2008-02-20 Thread Jim Meyering
"Daniel P. Berrange" <[EMAIL PROTECTED]> wrote: > All committed. Congratulations! :-) -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Re: [Libvir] PATCH: 1/16: public API

2008-02-20 Thread Richard W.M. Jones
On Wed, Feb 20, 2008 at 04:39:31PM +, Daniel P. Berrange wrote: > On Wed, Feb 20, 2008 at 04:10:30PM +, Daniel P. Berrange wrote: > > On Wed, Feb 20, 2008 at 02:52:54AM -0500, Daniel Veillard wrote: > > > So let's push this ! > > > > All committed. Now to find out what I broke :-) It pa

[Libvir] [PATCH] Rewrite openvzSetUUID.

2008-02-20 Thread Jim Meyering
There were several unchecked syscalls in this function, along with the at-least-theoretical risk of a file descriptor leak, so I rewrote this function to avoid all that, using a stream rather than a bare file descriptor. Subject: [PATCH] Rewrite openvzSetUUID. * src/openvz_conf.c (

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Meyering
Jim Paris <[EMAIL PROTECTED]> wrote: > Jim Meyering wrote: ... Hi Jim, >> -retry: >> -ret = write(pollInfos[nr].fd, (char *) req, req->len); >> +ret = safewrite(pollInfos[nr].fd, (char *) req, req->len); >> if (ret < 0) { > > Should this check (ret == req->len) instead? safewrite()

[Libvir] [PATCH] Use virErrorMsg in qemudReportError

2008-02-20 Thread Cole Robinson
Currently the qemu driver doesn't use virErrorMsg when raising error messages. This causes some errors to appear as "libvir: QEMU error: " if a custom string wasn't raised, which isn't all that useful. The patch below fixes this. Thanks, Cole diff --git a/src/qemu_conf.c b/src/qemu_conf.c index e

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Paris
Hi Jim, comments inline Jim Meyering wrote: > diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c > index d96d3db..a22ba6c 100644 > --- a/proxy/libvirt_proxy.c > +++ b/proxy/libvirt_proxy.c > @@ -2,7 +2,7 @@ > * proxy_svr.c: root suid proxy server for Xen access to APIs with no > *

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Meyering
Mark McLoughlin <[EMAIL PROTECTED]> wrote: > On Wed, 2008-02-20 at 16:42 +0100, Jim Meyering wrote: > >> If I do as you suggest and move the safewrite definition into util.h, >> and make it static inline, then both problems go away. > > Make sure to try and build this with gcc-4.3.0 - remembe

Re: [Libvir] PATCH: 1/16: public API

2008-02-20 Thread Daniel P. Berrange
On Wed, Feb 20, 2008 at 04:10:30PM +, Daniel P. Berrange wrote: > On Wed, Feb 20, 2008 at 02:52:54AM -0500, Daniel Veillard wrote: > > On Wed, Feb 20, 2008 at 04:00:39AM +, Daniel P. Berrange wrote: > > > On Tue, Feb 12, 2008 at 04:30:07AM +, Daniel P. Berrange wrote: > > > > This defin

Re: [Libvir] [PATCH] Avoid "make syntax-check" failure.

2008-02-20 Thread Daniel Veillard
On Wed, Feb 20, 2008 at 04:56:21PM +0100, Jim Meyering wrote: > There were a few trailing blanks in a generated Makefile.am file. > This patch fixes the python script not to emit the offending spaces: > > Avoid "make syntax-check" failure. > * docs/examples/index.py: Don't emit trailin

[Libvir] Re: take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Daniel Veillard
On Wed, Feb 20, 2008 at 04:42:12PM +0100, Jim Meyering wrote: > Daniel Veillard <[EMAIL PROTECTED]> wrote: > > maybe for case outside of the library adding a copy of safewrite > > in virsh.c would be a good way to do this while keeping the code > > consistent. The duplication of that small functi

Re: [Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Mark McLoughlin
On Wed, 2008-02-20 at 16:42 +0100, Jim Meyering wrote: > If I do as you suggest and move the safewrite definition into util.h, > and make it static inline, then both problems go away. Make sure to try and build this with gcc-4.3.0 - remember that we un-inlined xstrtol() because of: int

Re: [Libvir] PATCH: 1/16: public API

2008-02-20 Thread Daniel P. Berrange
On Wed, Feb 20, 2008 at 02:52:54AM -0500, Daniel Veillard wrote: > On Wed, Feb 20, 2008 at 04:00:39AM +, Daniel P. Berrange wrote: > > On Tue, Feb 12, 2008 at 04:30:07AM +, Daniel P. Berrange wrote: > > > This defines the public API for the storage pool and volume support. > > > The naming

[Libvir] [PATCH] Avoid "make syntax-check" failure.

2008-02-20 Thread Jim Meyering
There were a few trailing blanks in a generated Makefile.am file. This patch fixes the python script not to emit the offending spaces: Avoid "make syntax-check" failure. * docs/examples/index.py: Don't emit trailing blanks. * docs/examples/Makefile.am: Regenerate. Signed-o

[Libvir] take 2 [Re: write(2) may write less than the total requested

2008-02-20 Thread Jim Meyering
Daniel Veillard <[EMAIL PROTECTED]> wrote: > On Wed, Feb 20, 2008 at 02:53:49PM +0100, Jim Meyering wrote: >> Use safewrite in place of write, in many cases. >> And add "make syntax-check" rules to ensure no new uses sneak in. >> >> There are many uses of write like this: >> >> if (write (fd,

Re: [Libvir] [PATCH] write(2) may write less than the total requested

2008-02-20 Thread Daniel Veillard
On Wed, Feb 20, 2008 at 02:53:49PM +0100, Jim Meyering wrote: > Use safewrite in place of write, in many cases. > And add "make syntax-check" rules to ensure no new uses sneak in. > > There are many uses of write like this: > > if (write (fd, xml, towrite) != towrite) > return -1; >

Re: [Libvir] [PATCH] Handle failed openvzLocateConfDir.

2008-02-20 Thread Daniel Veillard
On Wed, Feb 20, 2008 at 03:23:52PM +0100, Jim Meyering wrote: > Jim Meyering <[EMAIL PROTECTED]> wrote: > ... > >> +if (conf_dir != NULL) > >> +return -1 > > > > Whoa. > > Chris Lalance pointed out another obvious flaw. > > I meant to add *this*: > > > >> +if (conf_dir == NULL) > >>

Re: [Libvir] [PATCH] Handle failed openvzLocateConfDir.

2008-02-20 Thread Daniel Veillard
On Wed, Feb 20, 2008 at 02:56:06PM +0100, Jim Meyering wrote: > While looking at misuses of write, I found problems in src/openvz_conf.c > Here's the first fix: > > Handle failed openvzLocateConfDir. > * src/openvz_conf.c (openvzLocateConfDir, openvzGetVPSUUID): > (openvzSetUUID)

Re: [Libvir] [PATCH] Handle failed openvzLocateConfDir.

2008-02-20 Thread Jim Meyering
Jim Meyering <[EMAIL PROTECTED]> wrote: ... >> +if (conf_dir != NULL) >> +return -1 > > Whoa. > Chris Lalance pointed out another obvious flaw. > I meant to add *this*: > >> +if (conf_dir == NULL) >> +return -1 > > Will repost shortly. > Thanks, Chris! Here's the corrected

Re: [Libvir] [PATCH] Handle failed openvzLocateConfDir.

2008-02-20 Thread Jim Meyering
Jim Meyering <[EMAIL PROTECTED]> wrote: > While looking at misuses of write, I found problems in src/openvz_conf.c > Here's the first fix: > > Handle failed openvzLocateConfDir. > * src/openvz_conf.c (openvzLocateConfDir, openvzGetVPSUUID): > (openvzSetUUID): Don't dereference NUL

Re: [Libvir] [PATCH] Handle failed openvzLocateConfDir.

2008-02-20 Thread Jim Meyering
Jim Meyering <[EMAIL PROTECTED]> wrote: > While looking at misuses of write, I found problems in src/openvz_conf.c > Here's the first fix: > > Handle failed openvzLocateConfDir. > * src/openvz_conf.c (openvzLocateConfDir, openvzGetVPSUUID): > (openvzSetUUID): Don't dereference NU

[Libvir] [PATCH] Handle failed openvzLocateConfDir.

2008-02-20 Thread Jim Meyering
While looking at misuses of write, I found problems in src/openvz_conf.c Here's the first fix: Handle failed openvzLocateConfDir. * src/openvz_conf.c (openvzLocateConfDir, openvzGetVPSUUID): (openvzSetUUID): Don't dereference NULL upon failure. Signed-off-by: Jim Meyering

[Libvir] [PATCH] write(2) may write less than the total requested

2008-02-20 Thread Jim Meyering
Use safewrite in place of write, in many cases. And add "make syntax-check" rules to ensure no new uses sneak in. There are many uses of write like this: if (write (fd, xml, towrite) != towrite) return -1; The problem is that the syscall can succeed, yet write less than the requested