Re: [libvirt] [PATCH] fix MinGW compilation(200808)

2008-08-06 Thread Jim Meyering
Daniel P. Berrange [EMAIL PROTECTED] wrote:
 On Tue, Aug 05, 2008 at 01:52:58PM +0200, Jim Meyering wrote:
 Atsushi SAKAI [EMAIL PROTECTED] wrote:
 ...
  network_conf.c:290: warning: implicit declaration of function `inet_aton'
  network_conf.c:290: warning: nested extern declaration of `inet_aton'

 We can/should use inet_pton instead.  Then, not only do we use what seems
 to be the preferred interface, but there is a gnulib module by the same
 name that can come into play if it too is missing.

 Even better would be to use  getaddrinfo() with AI_NUMERIC, since we
 already require getaddrinfo() to work on Windows for the remote driver

Dan,

If you don't object, I'll go for the simpler interface (and smaller
change).  However I've just noticed that that will require an adjustment
of the gnulib license for the inet_pton module.  But that shouldn't be
a problem, since the code in question is glibc-derived.

Here's the required patch, excluding the bit that will
add the new file(s) from gnulib, once the license has
been adjusted.

diff --git a/bootstrap b/bootstrap
index bc1c352..70b9a05 100755
--- a/bootstrap
+++ b/bootstrap
@@ -69,6 +69,7 @@ c-ctype
 getaddrinfo
 getpass
 gettext
+inet_pton
 mktempd
 physmem
 poll
diff --git a/src/network_conf.c b/src/network_conf.c
index 10c9dca..8c8a366 100644
--- a/src/network_conf.c
+++ b/src/network_conf.c
@@ -286,13 +286,13 @@ virNetworkDefParseXML(virConnectPtr conn,
 char *netaddr;
 xmlNodePtr dhcp;

-if (!inet_aton(def-ipAddress, inaddress)) {
+if (inet_pton(AF_INET, def-ipAddress, inaddress) = 0) {
 virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR,
   _(cannot parse IP address '%s'),
   def-ipAddress);
 goto error;
 }
-if (!inet_aton(def-netmask, innetmask)) {
+if (!inet_pton(AF_INET, def-netmask, innetmask) = 0) {
 virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR,
   _(cannot parse netmask '%s'),
   def-netmask);

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] fix MinGW compilation(200808)

2008-08-06 Thread Jim Meyering
Jim Meyering [EMAIL PROTECTED] wrote:

 Daniel P. Berrange [EMAIL PROTECTED] wrote:
 On Tue, Aug 05, 2008 at 01:52:58PM +0200, Jim Meyering wrote:
 Atsushi SAKAI [EMAIL PROTECTED] wrote:
 ...
  network_conf.c:290: warning: implicit declaration of function `inet_aton'
  network_conf.c:290: warning: nested extern declaration of `inet_aton'

 We can/should use inet_pton instead.  Then, not only do we use what seems
 to be the preferred interface, but there is a gnulib module by the same
 name that can come into play if it too is missing.

 Even better would be to use  getaddrinfo() with AI_NUMERIC, since we
 already require getaddrinfo() to work on Windows for the remote driver

 Dan,

 If you don't object, I'll go for the simpler interface (and smaller
 change).  However I've just noticed that that will require an adjustment
 of the gnulib license for the inet_pton module.  But that shouldn't be
 a problem, since the code in question is glibc-derived.

 Here's the required patch, excluding the bit that will
 add the new file(s) from gnulib, once the license has
 been adjusted.
...
 -if (!inet_aton(def-netmask, innetmask)) {
 +if (!inet_pton(AF_INET, def-netmask, innetmask) = 0) {

Whoops.  I forgot to remove one of the !.
Here's the correct patch:

diff --git a/bootstrap b/bootstrap
index bc1c352..70b9a05 100755
--- a/bootstrap
+++ b/bootstrap
@@ -69,6 +69,7 @@ c-ctype
 getaddrinfo
 getpass
 gettext
+inet_pton
 mktempd
 physmem
 poll
diff --git a/src/network_conf.c b/src/network_conf.c
index 10c9dca..f70c73d 100644
--- a/src/network_conf.c
+++ b/src/network_conf.c
@@ -286,13 +286,13 @@ virNetworkDefParseXML(virConnectPtr conn,
 char *netaddr;
 xmlNodePtr dhcp;

-if (!inet_aton(def-ipAddress, inaddress)) {
+if (inet_pton(AF_INET, def-ipAddress, inaddress) = 0) {
 virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR,
   _(cannot parse IP address '%s'),
   def-ipAddress);
 goto error;
 }
-if (!inet_aton(def-netmask, innetmask)) {
+if (inet_pton(AF_INET, def-netmask, innetmask) = 0) {
 virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR,
   _(cannot parse netmask '%s'),
   def-netmask);

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 7/7: Allow replacing root filesystem

2008-08-06 Thread Jim Meyering
Daniel P. Berrange [EMAIL PROTECTED] wrote:
...
 -static int lxcContainerSetStdio(int control, const char *ttyPath)
 +static int lxcContainerSetStdio(int control, int ttyfd)
  {

Hi Dan,

Not a big deal, but since ttyfd is now an input to this function,
it'd be less surprising if the caller were to close it.
Probably not worth changing...

  int rc = -1;
 -int ttyfd;
  int open_max, i;

  if (setsid()  0) {
  lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
   _(setsid failed: %s), strerror(errno));
 -goto error_out;
 -}
 -
 -ttyfd = open(ttyPath, O_RDWR|O_NOCTTY);
 -if (ttyfd  0) {
 -lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
 - _(open(%s) failed: %s), ttyPath, strerror(errno));
 -goto error_out;
 +goto cleanup;
  }

  if (ioctl(ttyfd, TIOCSCTTY, NULL)  0) {
 @@ -159,8 +161,6 @@

  cleanup:
  close(ttyfd);
 -
 -error_out:
  return rc;
  }

 @@ -223,6 +223,7 @@
  return 0;
  }

 +
  /**
   * lxcEnableInterfaces:
   * @vm: Pointer to vm structure
 @@ -252,6 +253,20 @@
  return rc;
  }
...

 +if (root) {
 +char *oldroot;
 +struct mntent *mntent;
 +char **mounts = NULL;
 +int nmounts = 0;
 +FILE *procmnt;

This can be const:

 +struct {
 +int maj;
 +int min;
 +const char *path;
 +} devs[] = {
 +{ 1, 3, /dev/null },
 +{ 1, 5, /dev/zero },
 +{ 1, 7, /dev/full },
 +{ 5, 1, /dev/console },

Might be good to add /dev/random and /dev/urandom.
I recently had trouble on a system where udev malfunctioned,
and some /dev/{u,}random-requiring libs/services failed in unusual ways.

Also, how about adding permission bits to the table, so that
console doesn't end up being mode 0777:

  struct {
int maj;
int min;
mode_t mode,
const char *path;
  } const devs[] = {
{ 1, 3, 0666, /dev/null },
{ 1, 5, 0666, /dev/zero },
{ 1, 7, 0666, /dev/full },
{ 5, 1, 0600, /dev/console },
{ 1, 8, 0666, /dev/random },
{ 1, 9, 0666, /dev/urandom },
  };

 +if (virFileMakePath(/dev/pts)  0 ||
 +mount(/.oldroot/dev/pts, /dev/pts, NULL,
 +  MS_MOVE, NULL)  0) {
 +lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
 + _(failed to move /dev/pts into container: %s),
 + strerror(errno));
 +return -1;
 +}
 +
 +/* Populate /dev/ with a few important bits */
 +umask(0);

In principle, it's better never to change umask.  Otherwise, when
multi-threaded, that temporarily-cleared umask could hose a file-creation
operation in another thread -- and it'd be a race, so probably hard to
reproduce.

 +for (i = 0 ; i  ARRAY_CARDINALITY(devs) ; i++) {
 +dev_t dev = makedev(devs[i].maj, devs[i].min);
 +if (mknod(devs[i].path,
 +  0777 | S_IFCHR,

Dropping the umask, you might do s/0777/0/ here, and then
call chmod to set each mode to devs[i].mode

 +  dev)  0) {
 +lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
 + _(failed to make device %s: %s),
 + devs[i].path, strerror(errno));

Returning here would leave umask set to 0.
Another reason not to change it in the first place.

 +return -1;
 +}
 +}
 +umask(0700);

When you do change umask, be sure to restore to the previous value.

 +/* Pull in rest of container's mounts */
 +for (tmp = vmDef-fss; tmp; tmp = tmp-next) {
 +char *src;
 +if (STREQ(tmp-dst, /))
 +continue;
 +// XXX fix
 +if (tmp-type != VIR_DOMAIN_FS_TYPE_MOUNT)
 +continue;
 +
 +if (asprintf(src, /.oldroot/%s, tmp-src)  0)
 +return -1;
 +
 +if (virFileMakePath(tmp-dst)  0 ||
 +mount(src, tmp-dst, NULL, MS_BIND, NULL)  0) {
 +lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
 + _(failed to mount %s at %s for container: %s),
 + tmp-src, tmp-dst, strerror(errno));

Call VIR_FREE(src) here to avoid a leak.

 +return -1;
 +}
 +VIR_FREE(src);
 +}
 +
 +if (!(procmnt = setmntent(/proc/mounts, r))) {
 +lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
 + _(failed to read /proc/mounts: %s),
 + strerror(errno));
 +return -1;
 +}
 +while ((mntent = getmntent(procmnt)) != NULL) {
 +if (!STRPREFIX(mntent-mnt_dir, /.oldroot))
 +continue;
 +if (VIR_REALLOC_N(mounts, nmounts+1)  0)

Call endmntent(procmnt) here, to
avoid a potential file descriptor leak.

 

Re: [libvirt] [PATCH] fix MinGW compilation(200808)

2008-08-06 Thread Daniel P. Berrange
On Wed, Aug 06, 2008 at 09:10:04AM +0200, Jim Meyering wrote:
 Daniel P. Berrange [EMAIL PROTECTED] wrote:
  On Tue, Aug 05, 2008 at 01:52:58PM +0200, Jim Meyering wrote:
  Atsushi SAKAI [EMAIL PROTECTED] wrote:
  ...
   network_conf.c:290: warning: implicit declaration of function `inet_aton'
   network_conf.c:290: warning: nested extern declaration of `inet_aton'
 
  We can/should use inet_pton instead.  Then, not only do we use what seems
  to be the preferred interface, but there is a gnulib module by the same
  name that can come into play if it too is missing.
 
  Even better would be to use  getaddrinfo() with AI_NUMERIC, since we
  already require getaddrinfo() to work on Windows for the remote driver
 
 Dan,
 
 If you don't object, I'll go for the simpler interface (and smaller
 change).  However I've just noticed that that will require an adjustment
 of the gnulib license for the inet_pton module.  But that shouldn't be
 a problem, since the code in question is glibc-derived.

Yep, fine by me.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 0/7: Re-factor LXC driver

2008-08-06 Thread Daniel P. Berrange
On Tue, Aug 05, 2008 at 02:17:27PM -0700, Dan Smith wrote:
 DB This is a long overdue followup to my previous set of patches to
 DB make the LXC driver use the new domain XML apis.
 
 Have you been able to test this with NET_NS support enabled yet?
 
 I am hitting the same issue I was before.  On starting an LXC domain
 with a network interface, the daemon finishes the action and reports
 a good status to virsh.  The domain fails to start, with the following
 in the per-domain log file:
 
   DEBUG: lxc_container.c: lxcContainerStart (clone() returned, 8082)
   libvir: Linux Container error : internal error read of fd 6 failed: 
 Input/output error 
   DEBUG: veth.c: vethDelete (veth: veth2)
 
 However, now, the daemon crashes well after leaving the LXC driver's
 domain startup process.  From the timing, I'd guess it's in some event
 (or SIGCHLD) handler, but I can't reproduce it in gdb to get more
 information.

That's not good. There should be no SIGCHLD's anywhere now - the container
double-forks into the background. Its probably some error in the cleanup
path - valgrind may help if gdb fails.

 This looks to be identical in root cause to what I was seeing with the
 previous set of patches, and was unable to figure out why file
 descriptor 6 was getting prematurely closed.  I'll get started on
 debugging it again tomorrow, but it might be good if you can reproduce
 it as well :)

I've unfortunately still not got a  kernel build with all the neccessary
NET_NS bits added on. If you can capture an strace it can probably 
help me diagnose the problem

   strace -f -ff -o net.log -s 3 -p `pid of libvirtd`

IIRC, you said removing the bit of code which closed all open file descriptor
would make it work again ?  If you can grab an strace with that change in 
too I can compare and figure out where we're going wrong.


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] fix MinGW compilation(200808)

2008-08-06 Thread Jim Meyering
Daniel P. Berrange [EMAIL PROTECTED] wrote:
 On Wed, Aug 06, 2008 at 09:10:04AM +0200, Jim Meyering wrote:
 Daniel P. Berrange [EMAIL PROTECTED] wrote:
  On Tue, Aug 05, 2008 at 01:52:58PM +0200, Jim Meyering wrote:
  Atsushi SAKAI [EMAIL PROTECTED] wrote:
  ...
   network_conf.c:290: warning: implicit declaration of function 
   `inet_aton'
   network_conf.c:290: warning: nested extern declaration of `inet_aton'
 
  We can/should use inet_pton instead.  Then, not only do we use what seems
  to be the preferred interface, but there is a gnulib module by the same
  name that can come into play if it too is missing.
 
  Even better would be to use  getaddrinfo() with AI_NUMERIC, since we
  already require getaddrinfo() to work on Windows for the remote driver

 Dan,

 If you don't object, I'll go for the simpler interface (and smaller
 change).  However I've just noticed that that will require an adjustment
 of the gnulib license for the inet_pton module.  But that shouldn't be
 a problem, since the code in question is glibc-derived.

 Yep, fine by me.

Ok.  Here's the complete patch, including the new file from gnulib.
I've verified that a freshly-cloned directory passes

  ./autogen  make  make check

Ha!  But it failed make syntax-check due to the
use of ctype's tolower in inet_pton.c.
I'm fixing that in gnulib now, since it can/should be c_tolower.
Here's the fix prior to the s/tolower/c_tolower/ inet_pton.c change
(it also does s/ctype/c-ctype/).  I'll wait until gnulib
is fixed before committing here.

From 45a33378a90fac3058360ba92ff0afca3e03df73 Mon Sep 17 00:00:00 2001
From: Jim Meyering [EMAIL PROTECTED]
Date: Wed, 6 Aug 2008 11:36:14 +0200
Subject: [PATCH] work around MinGW build failure due to its lack of inet_aton

Use inet_pton instead; pull in gnulib's module by the same name.
* src/network_conf.c (virNetworkDefParseXML): Use inet_pton,
rather than inet_aton.
* bootstrap (modules): Add inet_pton.
* gnulib/lib/inet_pton.c: New file, from gnulib.
---
 ChangeLog  |9 ++
 bootstrap  |1 +
 gnulib/lib/inet_pton.c |  257 
 src/network_conf.c |4 +-
 4 files changed, 269 insertions(+), 2 deletions(-)
 create mode 100644 gnulib/lib/inet_pton.c

diff --git a/ChangeLog b/ChangeLog
index 133bde6..d066751 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-08-06  Jim Meyering  [EMAIL PROTECTED]
+
+   work around MinGW build failure due to its lack of inet_aton
+   Use inet_pton instead; pull in gnulib's module by the same name.
+   * src/network_conf.c (virNetworkDefParseXML): Use inet_pton,
+   rather than inet_aton.
+   * bootstrap (modules): Add inet_pton.
+   * gnulib/lib/inet_pton.c: New file, from gnulib.
+
 Tue Aug  5 10:43:42 CEST 2008 Jim Meyering  [EMAIL PROTECTED]

make distclean: remove generated source files
diff --git a/bootstrap b/bootstrap
index bc1c352..70b9a05 100755
--- a/bootstrap
+++ b/bootstrap
@@ -69,6 +69,7 @@ c-ctype
 getaddrinfo
 getpass
 gettext
+inet_pton
 mktempd
 physmem
 poll
diff --git a/gnulib/lib/inet_pton.c b/gnulib/lib/inet_pton.c
new file mode 100644
index 000..3e92631
--- /dev/null
+++ b/gnulib/lib/inet_pton.c
@@ -0,0 +1,257 @@
+/* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form
+
+   Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see http://www.gnu.org/licenses/.  */
+
+/*
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include config.h
+
+/* Specification.  */
+#include arpa/inet.h
+

[libvirt] incorrect data in online documentation (I think)

2008-08-06 Thread matthew chan
Hi

The online documentation mentions that the XML memory node units are
in byte, but from the example code I have observed, it seems more likely
to be in kilobytes.

Could someone verify + change if necessary please?

Thanks,
Matt

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH]: Fix sexpr generation again

2008-08-06 Thread Chris Lalancette
DanB pointed out that my sexpr xend_internal patch from yesterday broke one of
the regression tests.  The problem is that the xenDaemonFormatSxpr{Disk,Net}
functions are shared between domain creation time and attaching disk time.
Unfortunately, though, Xend expects something different during these two times.
 During domain creation time, it wants the (device in front of the sexpr,
while during attach time it does not.  To remedy this situation, I added a flag
to these two functions to differentiate between these two modes.  With this
patch in place, all of the regression tests pass.

Signed-off-by: Chris Lalancette [EMAIL PROTECTED]
Index: src/xend_internal.c
===
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.208
diff -u -r1.208 xend_internal.c
--- a/src/xend_internal.c	5 Aug 2008 16:45:07 -	1.208
+++ b/src/xend_internal.c	6 Aug 2008 10:18:21 -
@@ -91,13 +91,15 @@
 virDomainDiskDefPtr def,
 virBufferPtr buf,
 int hvm,
-int xendConfigVersion);
+int xendConfigVersion,
+int isAttach);
 static int
 xenDaemonFormatSxprNet(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainNetDefPtr def,
virBufferPtr buf,
int hvm,
-   int xendConfigVersion);
+   int xendConfigVersion,
+   int isAttach);
 static int
 virDomainXMLDevID(virDomainPtr domain,
   virDomainDeviceDefPtr dev,
@@ -3898,7 +3900,7 @@
 dev-data.disk,
 buf,
 STREQ(def-os.type, hvm) ? 1 : 0,
-priv-xendConfigVersion)  0)
+priv-xendConfigVersion, 1)  0)
 goto cleanup;
 break;
 
@@ -3907,7 +3909,7 @@
dev-data.net,
buf,
STREQ(def-os.type, hvm) ? 1 : 0,
-   priv-xendConfigVersion)  0)
+   priv-xendConfigVersion, 1)  0)
 goto cleanup;
 break;
 
@@ -5017,7 +5019,8 @@
 virDomainDiskDefPtr def,
 virBufferPtr buf,
 int hvm,
-int xendConfigVersion)
+int xendConfigVersion,
+int isAttach)
 {
 /* Xend (all versions) put the floppy device config
  * under the hvm (image (os)) block
@@ -5032,6 +5035,9 @@
 xendConfigVersion == 1)
 return 0;
 
+if (!isAttach)
+virBufferAddLit(buf, (device );
+
 /* Normally disks are in a (device (vbd ...)) block
  * but blktap disks ended up in a differently named
  * (device (tap )) block */
@@ -5085,6 +5091,9 @@
 else
 virBufferAddLit(buf, (mode 'w'));
 
+if (!isAttach)
+virBufferAddLit(buf, ));
+
 virBufferAddLit(buf, ));
 
 return 0;
@@ -5109,7 +5118,8 @@
virDomainNetDefPtr def,
virBufferPtr buf,
int hvm,
-   int xendConfigVersion)
+   int xendConfigVersion,
+   int isAttach)
 {
 if (def-type != VIR_DOMAIN_NET_TYPE_BRIDGE 
 def-type != VIR_DOMAIN_NET_TYPE_NETWORK 
@@ -5119,6 +5129,9 @@
 return -1;
 }
 
+if (!isAttach)
+virBufferAddLit(buf, (device );
+
 virBufferAddLit(buf, (vif );
 
 virBufferVSprintf(buf,
@@ -5179,6 +5192,9 @@
 if ((hvm)  (xendConfigVersion  4))
 virBufferAddLit(buf, (type ioemu));
 
+if (!isAttach)
+virBufferAddLit(buf, ));
+
 virBufferAddLit(buf, ));
 
 return 0;
@@ -5439,14 +5455,14 @@
 
 disk = def-disks;
 while (disk) {
-if (xenDaemonFormatSxprDisk(conn, disk, buf, hvm, xendConfigVersion)  0)
+if (xenDaemonFormatSxprDisk(conn, disk, buf, hvm, xendConfigVersion, 0)  0)
 goto error;
 disk = disk-next;
 }
 
 net = def-nets;
 while (net) {
-if (xenDaemonFormatSxprNet(conn, net, buf, hvm, xendConfigVersion)  0)
+if (xenDaemonFormatSxprNet(conn, net, buf, hvm, xendConfigVersion, 0)  0)
 goto error;
 net = net-next;
 }
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH]: Fix sexpr generation again

2008-08-06 Thread Daniel P. Berrange
On Wed, Aug 06, 2008 at 12:20:50PM +0200, Chris Lalancette wrote:
 DanB pointed out that my sexpr xend_internal patch from yesterday broke one of
 the regression tests.  The problem is that the xenDaemonFormatSxpr{Disk,Net}
 functions are shared between domain creation time and attaching disk time.
 Unfortunately, though, Xend expects something different during these two 
 times.
  During domain creation time, it wants the (device in front of the sexpr,
 while during attach time it does not.  To remedy this situation, I added a 
 flag
 to these two functions to differentiate between these two modes.  With this
 patch in place, all of the regression tests pass.
 
 Signed-off-by: Chris Lalancette [EMAIL PROTECTED]

ACK, thanks for fixing this up.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH]: Fix sexpr generation again

2008-08-06 Thread Daniel Veillard
On Wed, Aug 06, 2008 at 12:20:50PM +0200, Chris Lalancette wrote:
 DanB pointed out that my sexpr xend_internal patch from yesterday broke one of
 the regression tests.  The problem is that the xenDaemonFormatSxpr{Disk,Net}
 functions are shared between domain creation time and attaching disk time.
 Unfortunately, though, Xend expects something different during these two 
 times.
  During domain creation time, it wants the (device in front of the sexpr,
 while during attach time it does not.  To remedy this situation, I added a 
 flag
 to these two functions to differentiate between these two modes.  With this
 patch in place, all of the regression tests pass.

  Looks fine to me, +1

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] fix MinGW compilation(200808)

2008-08-06 Thread Daniel Veillard
On Wed, Aug 06, 2008 at 11:52:20AM +0200, Jim Meyering wrote:
 Daniel P. Berrange [EMAIL PROTECTED] wrote:
  If you don't object, I'll go for the simpler interface (and smaller
  change).  However I've just noticed that that will require an adjustment
  of the gnulib license for the inet_pton module.  But that shouldn't be
  a problem, since the code in question is glibc-derived.
 
  Yep, fine by me.
 
 Ok.  Here's the complete patch, including the new file from gnulib.
 I've verified that a freshly-cloned directory passes
 
   ./autogen  make  make check
 
 Ha!  But it failed make syntax-check due to the
 use of ctype's tolower in inet_pton.c.
 I'm fixing that in gnulib now, since it can/should be c_tolower.
 Here's the fix prior to the s/tolower/c_tolower/ inet_pton.c change
 (it also does s/ctype/c-ctype/).  I'll wait until gnulib
 is fixed before committing here.

  +1 fine by me

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] incorrect data in online documentation (I think)

2008-08-06 Thread Daniel Veillard
On Tue, Aug 05, 2008 at 06:43:04PM -0400, matthew chan wrote:
 Hi
 
 The online documentation mentions that the XML memory node units are
 in byte, but from the example code I have observed, it seems more likely
 to be in kilobytes.
 
 Could someone verify + change if necessary please?

  Hum, right, taht's a mistake, I'm updating this, thanks for the heads up !

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Memory corruption with CVS tip + python

2008-08-06 Thread Chris Lalancette
All,
FYI, I'm running into some memory corruption when using CVS tip and trying
to use an older virt-install command.  I won't have time to debug this today, so
I thought I would mention it on-list in case someone else wants to take a crack
at it.

My system is an AMD system running RHEL-5.2 x86_64 bits, so it has
python-virtinst-0.300.2-8.el5 installed.

Basically, I did this:

# cvs co libvirt
# cd libvirt
# ./autogen.sh
# make dist

From here, I took the resulting .tar.gz, and dumped it into
/usr/src/redhat/SOURCES, and then took the SPEC file from the Fedora 9 sources.
 I had to modify the very top of it (since RHEL-5 rpmbuild didn't like the
macros for whatever reason), but if I read the logic right, I put these flags at
the top:

%define with_polkit 0
%define with_proxy yes
%define with_qemu 0

Then I built and installed a libvirt and libvirt-python RPM with this.  Finally,
I restarted libvirtd, and then tried to run the following command:

[EMAIL PROTECTED] libvirt]# virt-install -n test -f 
/var/lib/xen/images/test.img -s 10
-r 768 -v -c /var/lib/xen/images/boot.iso -d --vnc
Wed, 06 Aug 2008 07:59:10 DEBUGDistroInstaller location is a local
file/path: /var/lib/xen/images/boot.iso


Starting install...
Segmentation fault
[EMAIL PROTECTED] libvirt]#

It happens every time, so it should be fairly easy to track down.

Chris Lalancette

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 6/7: Persist live domain config across restarts

2008-08-06 Thread Jim Meyering
Daniel P. Berrange [EMAIL PROTECTED] wrote:
 Internally the drivers track the current live configuration, and the new
 inactive config for running domains. When the libvirtd process is restarted
 though, this data is lost for any active LXC domains. This patch makes the
 LXC driver persist the live config to /var/run/libvirt/lxc/NAME.xml so it
 can be tracked across restarts

 It required a small change to the domain XML APis to make the autostart
 symlink processing optional when deleting a config file
...

Looks fine to me.
ACK

 diff -r cf1cf3a1d4d6 src/lxc_driver.c
 --- a/src/lxc_driver.cTue Aug 05 16:50:51 2008 +0100
 +++ b/src/lxc_driver.cTue Aug 05 16:50:59 2008 +0100
...
 @@ -960,6 +973,8 @@

  vm = lxc_driver-domains;
  while (vm) {
 +char *config = NULL;
 +virDomainDefPtr tmp;

The initialization of config looks unnecessary.

The only other change I'd make would be to move both declarations down
to first use.  Then the context-challenged reader doesn't have to wonder
what, if anything, happens to those variables between declaration and
first use.

  int rc;
  if ((vm-monitor = lxcMonitorClient(NULL, lxc_driver, vm))  0) {
  vm = vm-next;
 @@ -972,6 +987,18 @@
  vm-monitor = -1;
  vm = vm-next;
  continue;
 +}
 +

   char *config;

 +if (asprintf(config, %s/%s.xml,
 + lxc_driver-stateDir, vm-def-name)  0)
 +continue;
 +
 +/* Try and load the live config */
 +tmp = virDomainDefParseFile(NULL, lxc_driver-caps, config);

   virDomainDefPtr tmp = virDomainDefParseFile(NULL, lxc_driver-caps,
   config);

 +VIR_FREE(config);
 +if (tmp) {
 +vm-newDef = vm-def;
 +vm-def = tmp;
  }

  if (vm-pid != 0) {

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] fix failing make syntax-check

2008-08-06 Thread Jim Meyering
make syntax-check just started failing.
This fixes it:

  fix failing make syntax-check
  * src/stats_linux.c: Don't include c-ctype.h no longer used.

---
 ChangeLog |3 +++
 src/stats_linux.c |1 -
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c23799c..ea6f1da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 Tue Aug  6 13:30:44 CEST 2008 Jim Meyering  [EMAIL PROTECTED]

+   fix failing make syntax-check
+   * src/stats_linux.c: Don't include c-ctype.h no longer used.
+
work around MinGW build failure due to its lack of inet_aton
Use inet_pton instead; pull in gnulib's module by the same name.
* src/network_conf.c (virNetworkDefParseXML): Use inet_pton,
diff --git a/src/stats_linux.c b/src/stats_linux.c
index 897251b..3f7dd52 100644
--- a/src/stats_linux.c
+++ b/src/stats_linux.c
@@ -19,7 +19,6 @@
 #include string.h
 #include unistd.h
 #include regex.h
-#include c-ctype.h

 #ifdef WITH_XEN
 #include xs.h
--
1.6.0.rc1.92.g189f7

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] fix failing make syntax-check

2008-08-06 Thread Daniel Veillard
On Wed, Aug 06, 2008 at 02:26:52PM +0200, Jim Meyering wrote:
 make syntax-check just started failing.

  strange it works for me on CVS head

 This fixes it:
 
   fix failing make syntax-check
   * src/stats_linux.c: Don't include c-ctype.h no longer used.

+1 sure

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] fix failing make syntax-check

2008-08-06 Thread Jim Meyering
Daniel Veillard [EMAIL PROTECTED] wrote:
 On Wed, Aug 06, 2008 at 02:26:52PM +0200, Jim Meyering wrote:
 make syntax-check just started failing.

   strange it works for me on CVS head

It was so small/obvious, that after waiting half an hour,
I went ahead and committed it.

If you add back the #include c-ctype.h line,
make syntax-check should fail.

 This fixes it:

   fix failing make syntax-check
   * src/stats_linux.c: Don't include c-ctype.h no longer used.

 +1 sure

Thanks for the review.

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] static ip address

2008-08-06 Thread Olivier Deckmyn



Le 4 août 08 à 12:46, Olivier Deckmyn [EMAIL PROTECTED] a  
écrit :




On Mon, Aug 4, 2008 at 9:12 AM, [EMAIL PROTECTED] wrote:
 Patch on qemu_conf.c doesn't apply to 0.4.4 released version.

 Any reason why this feature wasn't commited ?

Just that I didn't have the time to follow it through properly, and  
then

settled for just using static IP assignments.



Could someone please commit this patch ? (if l knew how to do it - i  
would do it myself :()


Thx




Reading this ML since only a few hours, it appears that it would  
save quite a lot of people :)


Cheers,

Olivier.

--
Mads Chr. Olesen
[EMAIL PROTECTED]


--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 0/7: Re-factor LXC driver

2008-08-06 Thread Daniel P. Berrange
On Wed, Aug 06, 2008 at 10:41:42AM +0100, Daniel P. Berrange wrote:
 On Tue, Aug 05, 2008 at 02:17:27PM -0700, Dan Smith wrote:
  DB This is a long overdue followup to my previous set of patches to
  DB make the LXC driver use the new domain XML apis.
  
  Have you been able to test this with NET_NS support enabled yet?
  
  I am hitting the same issue I was before.  On starting an LXC domain
  with a network interface, the daemon finishes the action and reports
  a good status to virsh.  The domain fails to start, with the following
  in the per-domain log file:
  
DEBUG: lxc_container.c: lxcContainerStart (clone() returned, 8082)
libvir: Linux Container error : internal error read of fd 6 failed: 
  Input/output error 
DEBUG: veth.c: vethDelete (veth: veth2)
  
  However, now, the daemon crashes well after leaving the LXC driver's
  domain startup process.  From the timing, I'd guess it's in some event
  (or SIGCHLD) handler, but I can't reproduce it in gdb to get more
  information.
 
 That's not good. There should be no SIGCHLD's anywhere now - the container
 double-forks into the background. Its probably some error in the cleanup
 path - valgrind may help if gdb fails.
 
  This looks to be identical in root cause to what I was seeing with the
  previous set of patches, and was unable to figure out why file
  descriptor 6 was getting prematurely closed.  I'll get started on
  debugging it again tomorrow, but it might be good if you can reproduce
  it as well :)
 
 I've unfortunately still not got a  kernel build with all the neccessary
 NET_NS bits added on. 

Turns out this wasn't needed. Simply commenting out use of the CLONE_NETNS
flag and using a currently 2.6.26 kernel is sufficient to expose the container
failing to start, and the libvirtd daemon crashing. So I'll track these down
and fix it

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 5/7: Remove paths from virDomainObjPtr

2008-08-06 Thread Jim Meyering
Daniel P. Berrange [EMAIL PROTECTED] wrote:
...

ACK, modulo two questions:

 diff -r a204a9425afd src/domain_conf.c
  int virDomainDeleteConfig(virConnectPtr conn,
 -   virDomainObjPtr dom)
 +  const char *configDir,
 +  const char *autostartDir,
 +  virDomainObjPtr dom)
  {
 -if (!dom-configFile || !dom-autostartLink) {
 -virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
 -  _(no config file for %s), dom-def-name);
 -return -1;
 +char *configFile = NULL, *autostartLink = NULL;
 +int ret = -1;
 +
 +if (asprintf(configFile, %s/%s,

Shouldn't that be %s/%s.xml, as used in at least two
other places where configFile is defined?
This deserves a tiny helper function, so that the
dom-configFile mapping happens in just one place.

 + configDir, dom-def-name)  0) {
 +configFile = NULL;
...

  #endif /* ! PROXY */
...
 diff -r a204a9425afd src/qemu_driver.c
...
  static int qemudDomainSetAutostart(virDomainPtr dom,
 -int autostart) {
 +   int autostart) {
  struct qemud_driver *driver = (struct qemud_driver 
 *)dom-conn-privateData;
  virDomainObjPtr vm = virDomainFindByUUID(driver-domains, dom-uuid);
 +char *configFile = NULL, *autostartLink = NULL;
 +int ret = -1;

  if (!vm) {
  qemudReportError(dom-conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
   %s, _(no domain with matching uuid));
 +return -1;
 +}
 +
 +if (!vm-persistent) {
 +qemudReportError(dom-conn, dom, NULL, VIR_ERR_INTERNAL_ERROR,
 + %s, _(cannot set autostart for transient 
 domain));
  return -1;
  }

 @@ -3039,6 +3053,20 @@
  if (vm-autostart == autostart)
  return 0;

 +if (asprintf(configFile, %s/%s.xml,
 + driver-configDir, vm-def-name)  0) {
 +configFile = NULL;
 +qemudReportError(dom-conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
 +goto cleanup;
 +}
 +
 +if (asprintf(autostartLink, %s/%s.xml,
 + driver-autostartDir, vm-def-name)  0) {

Your 6/7 patch has this:

if (asprintf(autostartLink, %s/%s,

Is the different format deliberate?
Maybe a helper function for the dom-autostartLink name, too?

 +autostartLink = NULL;
 +qemudReportError(dom-conn, dom, NULL, VIR_ERR_NO_MEMORY, NULL);
 +goto cleanup;
 +}
 +
...
 +cleanup:
 +VIR_FREE(configFile);
 +VIR_FREE(autostartLink);
 +
 +return ret;
  }

  /* This uses the 'info blockstats' monitor command which was

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] The logic in veth.c that searches for free interface names takes into account

2008-08-06 Thread Dan Smith
only current devices, but not device names already planned for the other
half of a container's device pair.  Thus, the search can result in attempting
to create a pair of devices such as veth1 and veth1, which obviously does
not work.

This patch augments the logic to be a little smarter in this regard, and should
fix one case where attempting to start a container results in an error message
of unable to create device pair.

diff -r 8c5e6387e449 -r 8545f7ac1f0f src/veth.c
--- a/src/veth.cTue Aug 05 16:45:07 2008 +
+++ b/src/veth.cWed Aug 06 08:14:16 2008 -0700
@@ -92,17 +92,18 @@
 
 DEBUG(veth1: %s veth2: %s, veth1, veth2);
 
-if (1  strlen(veth1)) {
+while ((1  strlen(veth1)) || STREQ(veth1, veth2)) {
 vethDev = getFreeVethName(veth1, veth1MaxLen, 0);
 ++vethDev;
 DEBUG(assigned veth1: %s, veth1);
 }
 
-if (1  strlen(veth2)) {
+while ((1  strlen(veth2)) || STREQ(veth1, veth2)) {
 vethDev = getFreeVethName(veth2, veth2MaxLen, vethDev);
 DEBUG(assigned veth2: %s, veth2);
 }
 
+DEBUG(veth1: %s veth2: %s, veth1, veth2);
 rc = virRun(NULL, (char**)argv, cmdResult);
 
 if (0 == rc) {

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] storage pool discovery

2008-08-06 Thread David Lively
On Fri, 2008-08-01 at 10:40 +0100, Daniel P. Berrange wrote: 
 On Wed, Jul 30, 2008 at 04:30:01PM -0400, David Lively wrote:
Finally, there's an underspecification issue.  The XML pool
  descriptions returned are supposed to be usable as valid input to
  virStoragePoolDefineXML.  But these descriptions include some data (pool
  name, target path) that isn't specified by the discover input or the
  discovered resources.  For now, I'm making up a somewhat arbitrary pool
  name (logical: VolGroup name, netfs: last component of export path).
  And I don't even specify targetpath in the netfs discovery output
  (which means it's not valid input to virStoragePoolDefineXML until a
  target path is added).
 
 Yep, my original intention was that you could send the XML straight
 back into the PoolDefineXML api. One alternative I've thought of 
 though, is that it perhaps it might be nicer to return all the 
 discovered pools as one XML doc
 
poolList type='netfs'
   source
 host name='someserver'/
 dir path='/exports/home'/
   /source
   source
 host name='someserver'/
 dir path='/exports/web'/
   /source
   source
 host name='someserver'/
 dir path='/exports/ftp'/
   /source
/poolList
 
 And just let the caller decide how they want to use this - they may not
 even want to define pools from them immediately - instead they might
 just want to display list of NFS exports to the user. It'd be easier
 than having to make up data for the name and target elements which
 is really something the client app wants to decide upon.

This is really two suggestions rolled into one:
  (1) just return source xml (not whole pool xml), and
  (2) instead of returning an array of strings, return a single (xml)
string wrapped with a poolList element

Either (1) or (2) could be done independently of the other, and I think
they're both worth considering.  I like the fact that (2) lets us
auto-generate the python binding, but I don't have strong feelings
either way.

I like (1) a lot, but it doesn't really work correctly for logical
storage pools in their current incarnation.  The source element for a
logical pool currently consists only of the device paths to the physical
volumes backing the volume group.  In particular, it doesn't specify the
volume group name (which seems to be assumed to be the same as the
libvirt pool name??).  This could be fixed by allowing the source
element for an existing volume group to specify (only) the volume group
name (which might be different from the pool name).  In this way,
logical pool discovery can return source elements that fully specify
existing pools.  And the client app can decide on pool names and target
paths as you propose.

[Note I'm proposing *extending* logical pool creation, so existing XML
should continue to work.  Specifically I'm proposing we extend source
with an optional name element which the logical storage backend will
interpret as volume group name.  For back-compatibility, the backend
will default the source name to the pool name when the source name isn't
specified.  The source name is used to instantiate existing volume
groups as well as to name new volume groups (whose source must also
specify the backing physical devices).]

Does this sound reasonable?


 There's some emacs rules in the HACKING file which will make sure it does
 correct indentation for you.  BTW, anyone fancy adding VIM equivalents...

Sorry, I'm an emacs guy :-)

[What we *really* need is an emacs mode (indent-assimilation-mode)
that will figure out the indentation settings for each file from the
code that's already there ... (assuming it's consistent ...).  I suppose
it wouldn't be that hard to at least get c-basic-offset, c-indent-level,
and indent-tabs-mode right.  (I know you can embed emacs directives in
source comments, but that's kind of ugly ...)]

In any case, thanks much for your comments.  I'm finally getting back to
working on this, so I should be able to submit my next take soon.

Thanks,
Dave




--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] storage pool discovery

2008-08-06 Thread David Lively
Thanks much for your comments, Jim.  They all look reasonable (though I
may be intentionally trimming a NL in one of these cases -- I'm
checking).

And I'll start following the HACKING file recommendations before
submitting my next attempt :-)

(Though note I'm not yet submitting tests since we haven't really
finished hashing out the API - at least some crucial XML details ...)

Dave



On Mon, 2008-08-04 at 08:25 +0200, Jim Meyering wrote:
 Hi David,
 
 I spotted a few things that would be good to change:
 
 David Lively [EMAIL PROTECTED] wrote:
  diff --git a/configure.in b/configure.in
  index 8e04f14..5ef0384 100644
  --- a/configure.in
  +++ b/configure.in
  @@ -660,6 +660,10 @@ if test $with_storage_fs = yes -o 
  $with_storage_fs = check; then
 fi
   fi
   AM_CONDITIONAL([WITH_STORAGE_FS], [test $with_storage_fs = yes])
  +if test $with_storage_fs = yes; then
  +  AC_PATH_PROG([SHOWMOUNT], [showmount], [], [$PATH:/sbin:/usr/sbin])
  +  AC_DEFINE_UNQUOTED([SHOWMOUNT], [$SHOWMOUNT], [Location or name of the 
  showmount program])
 
 Please split long lines:
 
 AC_DEFINE_UNQUOTED([SHOWMOUNT], [$SHOWMOUNT],
   [Location or name of the showmount program])
 
 ...
  diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
 ...
  +static int
  +virStorageBackendFileSystemNetDiscoverPoolsFunc(virConnectPtr conn 
  ATTRIBUTE_UNUSED,
  +   virStoragePoolObjPtr pool 
  ATTRIBUTE_UNUSED,
  +   char **const groups,
  +   void *data)
  +{
  +virNetfsDiscoverState *state = data;
  +virStringList *newItem;
  +const char *name, *path;
  +int len;
  +
  +path = groups[0];
  +
  +name = rindex(path, '/');
 
 rindex is deprecated.  Using it causes portability problems.
 Use strrchr instead.
 
  +if (name == NULL) {
  +   virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, %s, _(no / in 
  path?));
 
 If you include the offending string in the diagnostic
 and add a word of description, it'll be more useful:
 
   virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
 _(invalid netfs path (no slash): %s), path);
 
  +   return -1;
  +}
  +name += 1;
  +
  +/* Append new XML desc to list */
  +
  +if (VIR_ALLOC(newItem) != 0) {
  +virStorageReportError(conn, VIR_ERR_NO_MEMORY, %s, _(new xml 
  desc));
  +return -1;
  +}
  +
  +
  +/* regexp pattern is too greedy, so we may have trailing spaces to 
  trim.
  + * NB showmount output ambiguous for (evil) exports with names 
  w/trailing whitespace
 
 Too long.
 
  + */
  +len = 0;
  +while (name[len])
  +len++;
 
 This is equivalent to the three lines above:
len = strlen (name);
 
  +while (c_isspace(name[len-1]))
  +len--;
 
 It is customary to trim spaces and TABs (but less so CR, FF, NL),
 so c_isblank might be better than c_isspace here.
 
 ...
 
  +static int
  +virStorageBackendFileSystemNetDiscoverPools(virConnectPtr conn,
 ...
  + cleanup:
  +if (doc)
  +   xmlFreeDoc(doc);
  +if (xpath_ctxt)
 
 You can remove this if test.  It's unnecessary.
 BTW, make syntax-check should spot this and fail because of it.
 
  +   xmlXPathFreeContext(xpath_ctxt);
  +VIR_FREE(state.host);
  +while (state.list) {
  +   p = state.list-next;
  +   VIR_FREE(state.list);
  +   state.list = p;
  +}
  +
  +return n_descs;
  +}
 ...
  diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c
  index 9a0c27f..3c16d20 100644
  --- a/src/storage_backend_logical.c
  +++ b/src/storage_backend_logical.c
 ...
  @@ -257,6 +258,90 @@ virStorageBackendLogicalRefreshPoolFunc(virConnectPtr 
  conn ATTRIBUTE_UNUSED,
 
 
   static int
  +virStorageBackendLogicalDiscoverPoolsFunc(virConnectPtr conn 
  ATTRIBUTE_UNUSED,
  + virStoragePoolObjPtr pool 
  ATTRIBUTE_UNUSED,
  + size_t n_tokens,
  + char **const tokens,
  + void *data)
  +{
  +virStringList **rest = data;
  +virStringList *newItem;
  +const char *name;
  +int len;
  +
  +/* Append new XML desc to list */
  +
  +if (VIR_ALLOC(newItem) != 0) {
  +virStorageReportError(conn, VIR_ERR_NO_MEMORY, %s, _(new xml 
  desc));
  +return -1;
  +}
  +
  +if (n_tokens != 1) {
  +   virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, %s, _(n_tokens 
  should be 1));
  +   return -1;
  +}
  +
  +
  +name = tokens[0];
  +virSkipSpaces(name);
 
 Is is necessary to skip leading backslashes and carriage returns here?
 
  +len = 0;
  +while (name[len])
  +len++;
  +while (c_isspace(name[len-1]))
  +len--;
 
 A zero-length or all-space name would lead to referencing name[-1].
 You can use this instead:
 
 while (len  

[libvirt] [ANNOUNCE] virt-mem tools version 0.2.8 released

2008-08-06 Thread Richard W.M. Jones
I'm pleased to announce the latest release of the virt-mem tools,
version 0.2.8.

These are tools for system administrators which let you find things
like kernel messages, process lists and network information of your
guests.

For example:

  virt-uname
'uname' command, shows OS version, architecture, etc.
  virt-dmesg
'dmesg' command, shows kernel messages
  virt-ps
'ps' command, shows process list 

Nothing needs to be installed in the guest for this to work, and the
tools are specifically designed to allow easy scripting and
integration with databases and monitoring systems.

Source is available from the web page here:

  http://et.redhat.com/~rjones/virt-mem/

The latest version (0.2.8) reworks the internals substantially so that
we have direct access to basically any kernel structure, and this will
allow us to quickly add the remaining features that people have asked
for (memory usage information, lists of network interfaces and so on).

As usual, patches, feedback, suggestions etc. are very welcome!

Binaries will be available in Fedora 10 (Rawhide) at some point soon.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Install default storage pool

2008-08-06 Thread Cole Robinson
The attached patch adds a default pool definition to install
with libvirt. The pool is a directory pool, hardcoded to use
/var/lib/libvirt/images, though this is replaced with
%{_localstatedir}/lib/libvirt/images if installing via rpm.

Since /var/lib/libvirt/images may not exist if installing
from tar.gz, the pool is set not to autostart by default
via that method.

This patch isn't ready to apply though, since there is one
issue I don't know how to solve. We don't want every rpm
upgrade to install the default pool, since we don't want
the default to continually resurrect itself if a user
explicitly deletes it.

The default network handles this by checking if libvirtd
has been installed. Since libvirtd and virtual network
support were introduced around the same time, this makes
sense. However for storage, I can't think of any simple
check we can make. If we used the same as the default
network, all f8 or f9 upgrades wouldn't install the
default pool.

I can't really think of anything to check, besides maybe
doing some sort of time comparison on when 
/usr/share/libvirt/storage/default.xml was accessed. This
code is just hardcoded to always add it.

Any ideas?

Thanks,
Cole
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 1b572ba..8b7c1b8 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -184,6 +184,19 @@ rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/default.xml
 rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml
 # Strip auto-generated UUID - we need it generated per-install
 sed -i -e /uuid/d $RPM_BUILD_ROOT%{_datadir}/libvirt/networks/default.xml
+
+install -d -m 0755 $RPM_BUILD_ROOT%{_datadir}/libvirt/storage/
+cp $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/storage/default.xml \
+   $RPM_BUILD_ROOT%{_datadir}/libvirt/storage/default.xml
+rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/storage/default.xml
+# Strip auto-generated UUID - we need it generated per-install
+sed -i -e /uuid/d $RPM_BUILD_ROOT%{_datadir}/libvirt/storage/default.xml
+# Strip default target path
+sed -i -e /path/d $RPM_BUILD_ROOT%{_datadir}/libvirt/storage/default.xml
+# Specify target path as generated 'images' dir
+sed -i -e s,target,target\npath%{_localstatedir}/lib/libvirt/images/path, \
+  $RPM_BUILD_ROOT%{_datadir}/libvirt/storage/default.xml
+
 %find_lang %{name}
 
 %clean
@@ -205,6 +218,17 @@ then
 ln -s ../default.xml %{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml
 fi
 
+# We don't have the same luxury as the above, but I'm not sure what the
+# solution is. Unconditionally drop in the default storage pool for now...
+if /bin/true
+then
+UUID=`/usr/bin/uuidgen`
+sed -e s,/name,/name\n  uuid$UUID/uuid, \
+  %{_datadir}/libvirt/storage/default.xml \
+  %{_sysconfdir}/libvirt/storage/default.xml
+ln -s ../default.xml %{_sysconfdir}/libvirt/storage/autostart/default.xml
+fi
+
 /sbin/chkconfig --add libvirtd
 
 %preun
@@ -227,6 +251,8 @@ fi
 %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/
 %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/
 %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/autostart
+%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/storage
+%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/storage/autostart
 %{_sysconfdir}/rc.d/init.d/libvirtd
 %config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
 %config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
@@ -234,7 +260,9 @@ fi
 %config(noreplace) %{_sysconfdir}/sasl2/libvirt.conf
 %dir %{_datadir}/libvirt/
 %dir %{_datadir}/libvirt/networks/
+%dir %{_datadir}/libvirt/storage/
 %{_datadir}/libvirt/networks/default.xml
+%{_datadir}/libvirt/storage/default.xml
 %dir %{_localstatedir}/run/libvirt/
 %dir %{_localstatedir}/lib/libvirt/
 %dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/images/
diff --git a/qemud/Makefile.am b/qemud/Makefile.am
index abf5e09..3c848b6 100644
--- a/qemud/Makefile.am
+++ b/qemud/Makefile.am
@@ -4,7 +4,8 @@ INCLUDES = $(LIBVIRT_FEATURES)
 
 # Distribute the generated files so that rpcgen isn't required on the
 # target machine (although almost any Unix machine will have it).
-EXTRA_DIST = libvirtd.init.in libvirtd.sysconf default-network.xml \
+EXTRA_DIST = libvirtd.init.in libvirtd.sysconf \
+default-network.xml default-pool.xml\
 	remote_protocol.x \
 	remote_protocol.c remote_protocol.h \
 	remote_generate_stubs.pl rpcgen_fix.pl \
@@ -38,7 +39,8 @@ remote_protocol.c: remote_protocol.h
 
 if WITH_LIBVIRTD
 
-UUID=$(shell uuidgen)
+NETUUID=$(shell uuidgen)
+POOLUUID=$(shell uuidgen)
 
 sbin_PROGRAMS = libvirtd
 
@@ -84,24 +86,33 @@ libvirtd_CFLAGS += $(AVAHI_CFLAGS)
 libvirtd_LDADD += $(AVAHI_LIBS)
 endif
 
-default_xml_dest = libvirt/qemu/networks/default.xml
+default_net_xml_dest = libvirt/qemu/networks/default.xml
+default_pool_xml_dest = libvirt/storage/default.xml
 install-data-local: install-init install-data-sasl install-data-polkit
 	mkdir -p 

[libvirt] Is CVS server working?

2008-08-06 Thread Atsushi SAKAI
Hi,

CVS server [EMAIL PROTECTED]:2401/data/cvs is working?
I can see git repository but CVS repository are not.

Thanks
Atsushi SAKAI


--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] fix MinGW compilation(200808)

2008-08-06 Thread Atsushi SAKAI
Hi, Jim

I have a question about inet_pton().
I try to compile libvirt on MinGW after some modification.
The error message says follows.
C:/msys/1.0/home/sakaia/work/libvirt/src/network_conf.c:290: undefined 
reference to `inet_pton'
C:/msys/1.0/home/sakaia/work/libvirt/src/network_conf.c:296: undefined 
reference to `inet_pton'

I think it should edit gnulib/lib/Makefile.am.
Is this my guess correct.

Thanks
Atsushi SAKAI


Jim Meyering [EMAIL PROTECTED] wrote:

 Atsushi SAKAI [EMAIL PROTECTED] wrote:
 ...
  network_conf.c:290: warning: implicit declaration of function `inet_aton'
  network_conf.c:290: warning: nested extern declaration of `inet_aton'
 
 We can/should use inet_pton instead.  Then, not only do we use what seems
 to be the preferred interface, but there is a gnulib module by the same
 name that can come into play if it too is missing.
 
  network_conf.c:598: error: `S_IRUSR' undeclared (first use in this function)
 
 The remaining problems should be easy to resolve:
 Add this line to network_conf.c:
 
 #include sys/stat.h
 
  network_conf.c:598: error: (Each undeclared identifier is reported only once
  network_conf.c:598: error: for each function it appears in.)
  network_conf.c:598: error: `S_IWUSR' undeclared (first use in this function)


--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list