Re: [libvirt] [PATCH] vbox_tmpl.c: avoid leak on OOM error path

2010-02-17 Thread Jim Meyering
Matthias Bolte wrote:
 2010/2/15 Jim Meyering j...@meyering.net:
 Matthias Bolte wrote:
...
 ACK

All pushed.
BTW, thanks for all the reviews.

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


Re: [libvirt] [PATCH v2 9/9] reworked cpu-baseline command for virsh

2010-02-17 Thread Jiri Denemark
 diff --git a/tools/virsh.c b/tools/virsh.c
 index 7db48d9..95f5801 100644
 --- a/tools/virsh.c
 +++ b/tools/virsh.c
 @@ -7025,6 +7026,121 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
...
 +static int
 +cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
 +{
...
 +for (i = 0;i  obj-nodesetval-nodeNr;i++) {
 +buf = xmlBufferCreate();
 +if (buf == NULL)
 +goto no_memory;
 +sctxt = xmlSaveToBuffer(buf, NULL, 0);
 +if (sctxt == NULL)
Hmm, we would leak buf here, wouldn't we?
 +goto no_memory;
 +
 +xmlSaveTree(sctxt, obj-nodesetval-nodeTab[i]);
 +xmlSaveClose(sctxt);
 +
 +list = vshRealloc(ctl, list, sizeof(char *) * (count + 1));
 +list[count++] = (char *) buf-content;
 +buf-content = NULL;
 +buf = NULL;
 +}
 +
 +if (count == 0) {
 +vshError(ctl, _(No host CPU specified in '%s'), from);
 +ret = FALSE;
 +goto cleanup;
 +}
 +
 +result = virConnectBaselineCPU(ctl-conn, list, count, 0);
 +
 +if (result)
 +vshPrint(ctl, %s, result);
 +else
 +ret = FALSE;
 +
 +cleanup:
 +xmlXPathFreeObject(obj);
 +xmlXPathFreeContext(ctxt);
 +xmlFreeDoc(doc);
 +VIR_FREE(result);
 +if ((list != NULL)  (count  0)) {
 +for (i = 0;i  count;i++)
 +VIR_FREE(list[i]);
 +}
 +VIR_FREE(list);
 +VIR_FREE(buffer);

This would fix the leak:
   xmlBufferFree(buf);

 +return ret;
 +
 +no_memory:
 +vshError(ctl, %s, _(Out of memory));
 +ret = FALSE;
 +}

Except for the leak on error path, the patch looks good. ACK for the fixed
version.

Jirka

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


[libvirt] libvirt XML format.

2010-02-17 Thread Kumar L Srikanth-B22348
Hi,
I have some doubts regarding libvirt XML format.
Can anyone please let me know in detail, what is source and target
tags in the libvirt XML format?
Can I put '/' in the target tag or are there any exceptions if I put
'/' in that?
 
Please let me know.
 
Regards,
Srikanth.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] Remove unused functions from domain_conf

2010-02-17 Thread Matthew Booth
Remove virDomainDevicePCIAddressEqual and virDomainDeviceDriveAddressEqual,
which are defined but not used anywhere.

* src/conf/domain_conf.[ch]: Remove virDomainDevicePCIAddressEqual and
 virDomainDeviceDriveAddressEqual.
---
 src/conf/domain_conf.c |   24 
 src/conf/domain_conf.h |4 
 2 files changed, 0 insertions(+), 28 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7f3df78..df35209 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -972,30 +972,6 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf,
 
 #ifndef PROXY
 
-int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
-   virDomainDevicePCIAddressPtr b)
-{
-if (a-domain == b-domain 
-a-bus== b-bus 
-a-slot   == b-slot 
-a-function == b-function)
-return 1;
-
-return 0;
-}
-
-
-int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
- virDomainDeviceDriveAddressPtr b)
-{
-if (a-controller == b-controller 
-a-bus == b-bus 
-a-unit == b-unit)
-return 1;
-
-return 0;
-}
-
 
 static int
 virDomainDevicePCIAddressParseXML(xmlNodePtr node,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d9b2f28..307d9b5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -743,10 +743,6 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
 void virDomainVideoDefFree(virDomainVideoDefPtr def);
 void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
 void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
-int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
-   virDomainDevicePCIAddressPtr b);
-int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
- virDomainDeviceDriveAddressPtr b);
 int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
   int type);
 int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);
-- 
1.6.6

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


[libvirt] [PATCH] build: inform libtool of m4 directory

2010-02-17 Thread Eric Blake
Silence a libtoolize warning.

*  configure.ac (AC_CONFIG_MACRO_DIR): Add.
---
Libtool spits out this warning during ./autogen.sh:

| libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
| libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.

I've checked that there is no significant difference in the generated
files when applying this patch to silence the warning, and that autoconf
2.59 supplied this macro.

 configure.ac |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1c7c24c..743a357 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,6 +4,7 @@ AC_INIT([libvirt], [0.7.6])
 AC_CONFIG_SRCDIR([src/libvirt.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
 dnl Make automake keep quiet about wildcards  other GNUmake-isms
 AM_INIT_AUTOMAKE([-Wno-portability])

-- 
1.6.6

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


Re: [libvirt] libvirt XML format.

2010-02-17 Thread Matthew Booth
On 17/02/10 12:36, Kumar L Srikanth-B22348 wrote:
 Hi,

Hi Kumar,

 I have some doubts regarding libvirt XML format.
 Can anyone please let me know in detail, what is /source/ and
 /target/ tags in the libvirt XML format?

The best documentation is available here:
http://libvirt.org/formatdomain.html

If that's not enough, could you post an example of what you're trying to
do? Doesn't matter if it's wrong.

 Can I put '/' in the /target/ tag or are there any exceptions if I put
 '/' in that?

The domain XML is a valid XML document. Syntactically, you can put /
anywhere it would be valid in an XML document.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

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


[libvirt] [PATCH] openvzLoadDomains: don't ignore failing virUUIDFormat

2010-02-17 Thread Jim Meyering


From 23d248cec6efee5265bfa61071527506afdab137 Mon Sep 17 00:00:00 2001
From: Jim Meyering meyer...@redhat.com
Date: Wed, 17 Feb 2010 15:06:01 +0100
Subject: [PATCH] openvzLoadDomains: don't ignore failing virUUIDFormat

* src/openvz/openvz_conf.c (openvzLoadDomains): Diagnose failure of
virUUIDFormat.
---
 src/openvz/openvz_conf.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 51dbde5..a4aab1e 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -908,7 +908,11 @@ static int
 openvzSetUUID(int vpsid){
 unsigned char uuid[VIR_UUID_BUFLEN];

-virUUIDGenerate(uuid);
+if (virUUIDGenerate(uuid)) {
+openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
+%s, _(Failed to generate UUID));
+return -1;
+}

 return openvzSetDefinedUUID(vpsid, uuid);
 }
--
1.7.0.219.g6bb57

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


Re: [libvirt] [PATCH] build: inform libtool of m4 directory

2010-02-17 Thread Jim Meyering
Eric Blake wrote:
 Silence a libtoolize warning.

 *  configure.ac (AC_CONFIG_MACRO_DIR): Add.
 ---
 Libtool spits out this warning during ./autogen.sh:

 | libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
 | libtoolize: rerunning libtoolize, to keep the correct libtool macros 
 in-tree.

 I've checked that there is no significant difference in the generated
 files when applying this patch to silence the warning, and that autoconf
 2.59 supplied this macro.

  configure.ac |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

 diff --git a/configure.ac b/configure.ac
 index 1c7c24c..743a357 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -4,6 +4,7 @@ AC_INIT([libvirt], [0.7.6])
  AC_CONFIG_SRCDIR([src/libvirt.c])
  AC_CONFIG_AUX_DIR([build-aux])
  AC_CONFIG_HEADERS([config.h])
 +AC_CONFIG_MACRO_DIR([m4])
  dnl Make automake keep quiet about wildcards  other GNUmake-isms
  AM_INIT_AUTOMAKE([-Wno-portability])

Thanks!  Pushed.

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


[libvirt] [PATCH] Fix typo in comment

2010-02-17 Thread Matthew Booth
* src/qemu/qemu_driver.c: Fix typo in comment
---
 src/qemu/qemu_driver.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8766ca2..b4728e5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2724,7 +2724,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
 }
 
 /*
- * Normally PCI addresses are assigned inhe virDomainCreate
+ * Normally PCI addresses are assigned in the virDomainCreate
  * or virDomainDefine methods. We might still need to assign
  * some here to cope with the question of upgrades. Regardless
  * we also need to populate the PCi address set cache for later
-- 
1.6.6

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


[libvirt] [PATCH] Fix whitespace in domain.rng

2010-02-17 Thread Matthew Booth
* src/schemas/domain.rng: Replace tabs with 8 spaces
---
 docs/schemas/domain.rng |   52 +++---
 1 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index a834705..1ac5943 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -538,7 +538,7 @@
 ref name=unsignedInt/
   /attribute
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -603,7 +603,7 @@
 /group
   /choice
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -762,7 +762,7 @@
 /element
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /interleave
   /define
@@ -1015,7 +1015,7 @@
 /element
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /interleave
   /define
@@ -1159,9 +1159,9 @@
   ref name=guestfwdTarget/
   ref name=virtioTarget/
 /choice
-   optional
- ref name=address/
-   /optional
+optional
+  ref name=address/
+/optional
   /interleave
 /element
   /define
@@ -1183,7 +1183,7 @@
 /attribute
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -1212,12 +1212,12 @@
   group
 element name=source
   choice
-   group
+group
   ref name=usbproduct/
- optional
-   ref name=usbaddress/
- /optional
-   /group
+  optional
+ref name=usbaddress/
+  /optional
+/group
 ref name=usbaddress/
 element name=address
   ref name=pciaddress/
@@ -1276,7 +1276,7 @@
 /optional
 optional
   attribute name=bus
-   ref name=driveBus/
+ref name=driveBus/
   /attribute
 /optional
 attribute name=unit
@@ -1415,18 +1415,18 @@
   define name=address
 element name=address
   choice
-   group
- attribute name=type
-   valuepci/value
- /attribute
- ref name=pciaddress/
-   /group
-   group
- attribute name=type
-   valuedrive/value
- /attribute
- ref name=driveaddress/
-   /group
+group
+  attribute name=type
+valuepci/value
+  /attribute
+  ref name=pciaddress/
+/group
+group
+  attribute name=type
+valuedrive/value
+  /attribute
+  ref name=driveaddress/
+/group
   /choice
 /element
   /define
-- 
1.6.6

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


[libvirt] [PATCH] Fix DSO linking problem for nodeinfotest

2010-02-17 Thread Daniel Veillard
  Following changes in Fedora about exposing shared libraries
dependancies, libvirt built failed for one of the test binaries
because it didn't explicitely required -ldl

gcc -DHAVE_CONFIG_H -I. -I.. -I../gnulib/lib -I../gnulib/lib
-I../include -I../include -I../src -I../src/util -I../src/conf
-I/usr/include/libxml2   -DGETTEXT_PACKAGE=\libvirt\  -Wall
-Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs
-Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings
-Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
-Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fasynchronous-unwind-tables  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom
-fasynchronous-unwind-tables -c nodeinfotest.c
  CCLD   nodeinfotest
/usr/bin/ld:
../src/.libs/libvirt_test.a(libvirt_driver_vbox_la-vbox_XPCOMCGlue.o):
undefined reference to symbol 'dlopen@@GLIBC_2.1'
/usr/bin/ld: note: 'dlopen@@GLIBC_2.1' is defined in DSO /lib/libdl.so.2
so try adding it to the linker command line
/lib/libdl.so.2: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

  the following patch fixes it,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 090b320..ea604d8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -317,7 +317,7 @@ conftest_LDADD = $(LDADDS)
 
 nodeinfotest_SOURCES = \
nodeinfotest.c testutils.h testutils.c
-nodeinfotest_LDADD = $(LDADDS)
+nodeinfotest_LDADD = $(LDADDS) -ldl
 
 statstest_SOURCES = \
statstest.c testutils.h testutils.c
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] Fix whitespace in domain.rng

2010-02-17 Thread Daniel Veillard
On Wed, Feb 17, 2010 at 03:32:12PM +, Matthew Booth wrote:
 * src/schemas/domain.rng: Replace tabs with 8 spaces
 ---
  docs/schemas/domain.rng |   52 +++---
  1 files changed, 26 insertions(+), 26 deletions(-)

  Okay, done manually since patch didn't apply

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


[libvirt] [PATCH] Fix whitespace in domain.rng

2010-02-17 Thread Matthew Booth
* src/schemas/domain.rng: Replace tabs with 8 spaces
---
 docs/schemas/domain.rng |   52 +++---
 1 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 1ff0944..53b82ce 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -537,7 +537,7 @@
 ref name=unsignedInt/
   /attribute
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -602,7 +602,7 @@
 /group
   /choice
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -761,7 +761,7 @@
 /element
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /interleave
   /define
@@ -1014,7 +1014,7 @@
 /element
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /interleave
   /define
@@ -1145,9 +1145,9 @@
   interleave
 ref name=qemucdevSrcDef/
 ref name=guestfwdTarget/
-   optional
- ref name=address/
-   /optional
+optional
+  ref name=address/
+/optional
   /interleave
 /element
   /define
@@ -1169,7 +1169,7 @@
 /attribute
   /optional
   optional
-   ref name=address/
+ref name=address/
   /optional
 /element
   /define
@@ -1198,12 +1198,12 @@
   group
 element name=source
   choice
-   group
+group
   ref name=usbproduct/
- optional
-   ref name=usbaddress/
- /optional
-   /group
+  optional
+ref name=usbaddress/
+  /optional
+/group
 ref name=usbaddress/
 element name=address
   ref name=pciaddress/
@@ -1262,7 +1262,7 @@
 /optional
 optional
   attribute name=bus
-   ref name=driveBus/
+ref name=driveBus/
   /attribute
 /optional
 attribute name=unit
@@ -1401,18 +1401,18 @@
   define name=address
 element name=address
   choice
-   group
- attribute name=type
-   valuepci/value
- /attribute
- ref name=pciaddress/
-   /group
-   group
- attribute name=type
-   valuedrive/value
- /attribute
- ref name=driveaddress/
-   /group
+group
+  attribute name=type
+valuepci/value
+  /attribute
+  ref name=pciaddress/
+/group
+group
+  attribute name=type
+valuedrive/value
+  /attribute
+  ref name=driveaddress/
+/group
   /choice
 /element
   /define
-- 
1.6.6

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


[libvirt] [PATCH] Add build require for xmlrpc-c-client

2010-02-17 Thread Daniel Veillard
libxmlrpc_client.so.3 moved from xmlrpc-c-devel to xmlrpc-c-client
in latest release :-(

  CCLD   libvirtd
  /usr/bin/ld: cannot find /usr/lib/libxmlrpc_client.so.3
  collect2: ld returned 1 exit status
  make[3]: Leaving directory
  `/builddir/build/BUILD/libvirt-0.7.6/daemon'

so we need to add an extra dependency, I think the following should
solve it in the most generic way,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
diff --git a/libvirt.spec.in b/libvirt.spec.in
index b1c1c99..7927b8a 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -249,6 +249,9 @@ BuildRequires: xen-devel
 %endif
 %if %{with_one}
 BuildRequires: xmlrpc-c-devel = 1.14.0
+%if 0%{?fedora}  12 || 0%{?rhel}  6
+BuildRequires: xmlrpc-c-client
+%endif
 %endif
 BuildRequires: libxml2-devel
 BuildRequires: xhtml1-dtds
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] Remove unused functions from domain_conf

2010-02-17 Thread Daniel Veillard
On Wed, Feb 17, 2010 at 01:27:23PM +, Matthew Booth wrote:
 Remove virDomainDevicePCIAddressEqual and virDomainDeviceDriveAddressEqual,
 which are defined but not used anywhere.
 
 * src/conf/domain_conf.[ch]: Remove virDomainDevicePCIAddressEqual and
  virDomainDeviceDriveAddressEqual.
 ---
  src/conf/domain_conf.c |   24 
  src/conf/domain_conf.h |4 
  2 files changed, 0 insertions(+), 28 deletions(-)
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index 7f3df78..df35209 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -972,30 +972,6 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf,
  
  #ifndef PROXY
  
 -int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
 -   virDomainDevicePCIAddressPtr b)
 -{
 -if (a-domain == b-domain 
 -a-bus== b-bus 
 -a-slot   == b-slot 
 -a-function == b-function)
 -return 1;
 -
 -return 0;
 -}
 -
 -
 -int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
 - virDomainDeviceDriveAddressPtr b)
 -{
 -if (a-controller == b-controller 
 -a-bus == b-bus 
 -a-unit == b-unit)
 -return 1;
 -
 -return 0;
 -}
 -
  
  static int
  virDomainDevicePCIAddressParseXML(xmlNodePtr node,
 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
 index d9b2f28..307d9b5 100644
 --- a/src/conf/domain_conf.h
 +++ b/src/conf/domain_conf.h
 @@ -743,10 +743,6 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr 
 def);
  void virDomainVideoDefFree(virDomainVideoDefPtr def);
  void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
  void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
 -int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
 -   virDomainDevicePCIAddressPtr b);
 -int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
 - virDomainDeviceDriveAddressPtr b);
  int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
int type);
  int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);

  Hum, virDomainDevicePCIAddressEqual is actually exposed in
src/libvirt_private.syms so that would have to be cleaned up there too.
If no ongoing patches is needing them I'm fine removeing those,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


[libvirt] virtio-serial support

2010-02-17 Thread Matthew Booth
These patches rebase my previously posted virtio-serial patches, add support for
max_ports and vectors, and allow multiple virtio-serial devices to be used. I
wasn't going to bother with the latter, however it turns out this can be useful
if the user wants more than 31 virtserialports.

N.B. These apply on top of 2 previously posted patches. Specifically Fix 
whitespace in domain.rng and Remove unused functions from domain_conf.

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


Re: [libvirt] [PATCH] openvzLoadDomains: don't ignore failing virUUIDFormat

2010-02-17 Thread Daniel Veillard
On Wed, Feb 17, 2010 at 03:08:09PM +0100, Jim Meyering wrote:
 
 
 From 23d248cec6efee5265bfa61071527506afdab137 Mon Sep 17 00:00:00 2001
 From: Jim Meyering meyer...@redhat.com
 Date: Wed, 17 Feb 2010 15:06:01 +0100
 Subject: [PATCH] openvzLoadDomains: don't ignore failing virUUIDFormat
 
 * src/openvz/openvz_conf.c (openvzLoadDomains): Diagnose failure of
 virUUIDFormat.
 ---
  src/openvz/openvz_conf.c |6 +-
  1 files changed, 5 insertions(+), 1 deletions(-)
 
 diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
 index 51dbde5..a4aab1e 100644
 --- a/src/openvz/openvz_conf.c
 +++ b/src/openvz/openvz_conf.c
 @@ -908,7 +908,11 @@ static int
  openvzSetUUID(int vpsid){
  unsigned char uuid[VIR_UUID_BUFLEN];
 
 -virUUIDGenerate(uuid);
 +if (virUUIDGenerate(uuid)) {
 +openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
 +%s, _(Failed to generate UUID));
 +return -1;
 +}
 
  return openvzSetDefinedUUID(vpsid, uuid);
  }

  ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


[libvirt] [PATCH 2/2] Add QEMU support for virtio channel

2010-02-17 Thread Matthew Booth
Support virtio-serial controller and virtio channel in QEMU backend. Will output
the following for virtio-serial controller:

-device 
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4,max_ports=16,vectors=4

and the following for a virtio channel:

-chardev pty,id=channel0 \
-device 
virtserialport,bus=virtio-serial0.0,chardev=channel0,name=org.linux-kvm.port.0

* src/qemu/qemu_conf.c: Add argument output for virtio
* tests/qemuxml2argvtest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
  : Add test for QEMU command line generation
---
 src/qemu/qemu_conf.c   |   91 +++-
 .../qemuxml2argv-channel-virtio.args   |1 +
 tests/qemuxml2argvtest.c   |1 +
 3 files changed, 92 insertions(+), 1 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 456ee34..110409d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2168,7 +2168,6 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, 
qemuDomainPCIAddressSetPtr addrs)
 }
 for (i = 0; i  def-nchannels ; i++) {
 /* Nada - none are PCI based (yet) */
-/* XXX virtio-serial will need one */
 }
 if (def-watchdog 
 def-watchdog-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
@@ -2465,6 +2464,23 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def)
 virBufferVSprintf(buf, ,id=scsi%d, def-idx);
 break;
 
+case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
+if (def-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+virBufferAddLit(buf, virtio-serial-pci);
+} else {
+virBufferAddLit(buf, virtio-serial);
+}
+virBufferVSprintf(buf, ,id=virtio-serial%d, def-idx);
+if (def-opts.vioserial.max_ports != -1) {
+virBufferVSprintf(buf, ,max_ports=%d,
+  def-opts.vioserial.max_ports);
+}
+if (def-opts.vioserial.vectors != -1) {
+virBufferVSprintf(buf, ,vectors=%d,
+  def-opts.vioserial.vectors);
+}
+break;
+
 /* We always get an IDE controller, whether we want it or not. */
 case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
 default:
@@ -3830,6 +3846,79 @@ int qemudBuildCommandLine(virConnectPtr conn,
 }
 VIR_FREE(addr);
 ADD_ARG(devstr);
+break;
+
+case VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO:
+if (!(qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE)) {
+qemuReportError(VIR_ERR_NO_SUPPORT, %s,
+_(virtio channel requires QEMU to support -device));
+goto error;
+}
+
+ADD_ARG_LIT(-chardev);
+if (!(devstr = qemuBuildChrChardevStr(channel)))
+goto error;
+ADD_ARG(devstr);
+
+virBuffer virtiodev = VIR_BUFFER_INITIALIZER;
+virBufferAddLit(virtiodev, virtserialport);
+
+if (channel-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+/* Check it's a virtio-serial address */
+if (channel-info.type !=
+VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL)
+{
+qemuReportError(VIR_ERR_INTERNAL_ERROR,
+_(virtio serial device has invalid 
+  address type));
+virBufferFreeAndReset(virtiodev);
+goto error;
+}
+
+/* Look for the virtio-serial controller */
+const char *vsalias = NULL;
+int vs = 0;
+int c;
+for (c = 0; c  def-ncontrollers; c++) {
+if (def-controllers[c]-type !=
+VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
+{
+continue;
+}
+
+if (vs == channel-info.addr.vioserial.controller) {
+vsalias = def-controllers[c]-info.alias;
+break;
+}
+
+vs++;
+}
+
+if (!vsalias) {
+qemuReportError(VIR_ERR_INTERNAL_ERROR,
+_(virtio serial device address controller 

+  does not exist));
+virBufferFreeAndReset(virtiodev);
+goto error;
+}
+
+virBufferVSprintf(virtiodev, ,bus=%s.%d,
+  vsalias, channel-info.addr.vioserial.bus);
+}
+
+virBufferVSprintf(virtiodev, ,chardev=%s, channel-info.alias);
+if (channel-target.name) {
+virBufferVSprintf(virtiodev, ,name=%s, 
channel-target.name);

[libvirt] [PATCH 1/2] Add domain support for virtio channel

2010-02-17 Thread Matthew Booth
Add support for virtio-serial by defining a new 'virtio' channel target type and
a virtio-serial controller. Allows the following to be specified in a domain:

controller type='virtio-serial' index='0' max_ports='16' vectors='4'/
channel type='pty'
  target type='virtio' name='org.linux-kvm.port.0'/
  address type='virtio-serial' controller='0' bus='0'/
/channel

* docs/schemas/domain.rng: Add virtio-serial controller and virtio channel type.
* src/conf/domain_conf.[ch]: Domain parsing/serialization for virtio-serial
 controller and virtio channel.
* tests/qemuxml2xmltest.c
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
   : add domain xml parsing test
* src/libvirt_private.syms
  src/qemu/qemu_conf.c: virDomainDefAddDiskControllers() renamed to
virDomainDefAddImplicitControllers()
---
 docs/schemas/domain.rng|   71 +-
 src/conf/domain_conf.c |  234 +---
 src/conf/domain_conf.h |   25 ++-
 src/libvirt_private.syms   |2 +-
 src/qemu/qemu_conf.c   |2 +-
 .../qemuxml2argv-channel-virtio.xml|   35 +++
 tests/qemuxml2xmltest.c|1 +
 7 files changed, 320 insertions(+), 50 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 53b82ce..85df8b8 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -523,16 +523,36 @@
   /define
   define name=controller
 element name=controller
-  optional
-attribute name=type
-  choice
-valuefdc/value
-valueide/value
-valuescsi/value
-valuesata/value
-  /choice
-/attribute
-  /optional
+  choice
+group
+  optional
+attribute name=type
+  choice
+valuefdc/value
+valueide/value
+valuescsi/value
+valuesata/value
+  /choice
+/attribute
+  /optional
+/group
+!-- virtio-serial can have 2 additional attributes --
+group
+  attribute name=type
+valuevirtio-serial/value
+  /attribute
+  optional
+attribute name=max_ports
+  ref name=unsignedInt/
+/attribute
+  /optional
+  optional
+attribute name=vectors
+  ref name=unsignedInt/
+/attribute
+  /optional
+/group
+  /choice
   attribute name=index
 ref name=unsignedInt/
   /attribute
@@ -1139,12 +1159,25 @@
   attribute name=port/
 /element
   /define
+  define name=virtioTarget
+element name=target
+  attribute name=type
+  valuevirtio/value
+  /attribute
+  optional
+attribute name=name/
+  /optional
+/element
+  /define
   define name=channel
 element name=channel
   ref name=qemucdevSrcType/
   interleave
 ref name=qemucdevSrcDef/
-ref name=guestfwdTarget/
+choice
+  ref name=guestfwdTarget/
+  ref name=virtioTarget/
+/choice
 optional
   ref name=address/
 /optional
@@ -1269,6 +1302,16 @@
   ref name=driveUnit/
 /attribute
   /define
+  define name=virtioserialaddress
+attribute name=controller
+  ref name=driveController/
+/attribute
+optional
+  attribute name=bus
+ref name=driveBus/
+  /attribute
+/optional
+  /define
   !--
   Devices attached to a domain.
 --
@@ -1413,6 +1456,12 @@
   /attribute
   ref name=driveaddress/
 /group
+group
+  attribute name=type
+valuevirtio-serial/value
+  /attribute
+  ref name=virtioserialaddress/
+/group
   /choice
 /element
   /define
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 59fd251..58f353b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -93,7 +93,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
 VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
   none,
   pci,
-  drive);
+  drive,
+  virtio-serial);
 
 VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST,
   block,
@@ -125,7 +126,8 @@ VIR_ENUM_IMPL(virDomainController, 
VIR_DOMAIN_CONTROLLER_TYPE_LAST,
   ide,
   fdc,
   scsi,
-  sata)
+  sata,
+  virtio-serial)
 
 VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
   mount,
@@ -150,7 +152,8 @@ VIR_ENUM_IMPL(virDomainChrTarget, 
VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
   

Re: [libvirt] [PATCH] Remove unused functions from domain_conf

2010-02-17 Thread Matthew Booth
On 17/02/10 17:08, Daniel Veillard wrote:
   Hum, virDomainDevicePCIAddressEqual is actually exposed in
 src/libvirt_private.syms so that would have to be cleaned up there too.
 If no ongoing patches is needing them I'm fine removeing those,

Hadn't spotted that. Attached new patch which touches
src/libvirt_private.syms.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
From 5612c7c7a5969a84cc97f50ad2bdf9070ef95210 Mon Sep 17 00:00:00 2001
From: Matthew Booth mbo...@redhat.com
Date: Wed, 17 Feb 2010 13:25:41 +
Subject: [PATCH] Remove unused functions from domain_conf

Remove virDomainDevicePCIAddressEqual and virDomainDeviceDriveAddressEqual,
which are defined but not used anywhere.

* src/conf/domain_conf.[ch]
  src/libvirt_private.syms: Remove virDomainDevicePCIAddressEqual and
virDomainDeviceDriveAddressEqual.
---
 src/conf/domain_conf.c   |   24 
 src/conf/domain_conf.h   |4 
 src/libvirt_private.syms |1 -
 3 files changed, 0 insertions(+), 29 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 561fa22..59fd251 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -966,30 +966,6 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf,
 
 #ifndef PROXY
 
-int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
-   virDomainDevicePCIAddressPtr b)
-{
-if (a-domain == b-domain 
-a-bus== b-bus 
-a-slot   == b-slot 
-a-function == b-function)
-return 1;
-
-return 0;
-}
-
-
-int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
- virDomainDeviceDriveAddressPtr b)
-{
-if (a-controller == b-controller 
-a-bus == b-bus 
-a-unit == b-unit)
-return 1;
-
-return 0;
-}
-
 
 static int
 virDomainDevicePCIAddressParseXML(xmlNodePtr node,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 231d8c8..782af95 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -740,10 +740,6 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
 void virDomainVideoDefFree(virDomainVideoDefPtr def);
 void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
 void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
-int virDomainDevicePCIAddressEqual(virDomainDevicePCIAddressPtr a,
-   virDomainDevicePCIAddressPtr b);
-int virDomainDeviceDriveAddressEqual(virDomainDeviceDriveAddressPtr a,
- virDomainDeviceDriveAddressPtr b);
 int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
   int type);
 int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index aa826d6..4dd7e98 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -179,7 +179,6 @@ virDomainObjListInit;
 virDomainObjListDeinit;
 virDomainObjRef;
 virDomainObjUnref;
-virDomainDevicePCIAddressEqual;
 virDomainDeviceAddressIsValid;
 virDomainDevicePCIAddressIsValid;
 virDomainDeviceInfoIsSet;
-- 
1.6.6

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

Re: [libvirt] Cannot enumerate physical devices with libvirt 0.7.6

2010-02-17 Thread Dave Allan

On 02/16/2010 05:11 PM, Frédéric Grelot wrote:

Hi Dave and all


have four on my test system, which I just installed.  How did you
install the box, install F12, then what?  Just to rule this out, did
you rebuild the RPM?


I first built it from source (0.7.6), but, when the package was released in rawvirt (repo 
enabled in my system), I uninstalled my version (make uninstall in the 
directory where I installed it from), then installed that of rawvirt...
When I started having these problems, I uninstalled / reinstalled again, but it 
didn't change anything.

Well... you solved my problem anyway : to sort this out, I tried that again. Thus I noticed that after having 
uninstalled everything (yum remove + make uninstall), the libvirtd command still 
worked (with errors). I checked... and there was a /sbin/libvirtd, left by I-don-t-know-which 
install! . It was one of those last, undoubtly, since libvirtd --version  actually returned 
0.7.6... (And, of course, in the default PATH, /sbin stands before /usr/bin/...)
I removed (=backuped just in case...) it, installed with yum, and it works at 
last!

Thanks for your help, you got me to the right path... And sorry for the inconvenient of a 
custom install...


Glad it's working for you now.


However, I don't explain why this libvirtd was left there... Were the paths 
changed lately?


It's possible to leave files installed if you install to one prefix and 
then install to a second location without uninstalling the first.  If 
you re-execute configure the location of any existing installation is lost.


Dave



Frederic


- Dave Allandal...@redhat.com  a écrit :


On 02/16/2010 03:04 PM, Frédéric Grelot wrote:

Yep, here is what I get (see at the end) :


(snip)


I think the times when I get those lines matches with my virsh

nodedev-list requests (or something like this : virt-manager tries to
create a vm, add hardware...).


Does this help?


That's odd, you only have two entries in the node driver array, and I

have four on my test system, which I just installed.  How did you
install the box, install F12, then what?  Just to rule this out, did
you
rebuild the RPM?


Frederic.


- Dave Allandal...@redhat.com   a écrit :


On 02/16/2010 03:00 AM, Frédéric Grelot wrote:

Daniel was referring to the libvirt udev driver--the libvirt

code

that


interacts with udev--not to udev itself, which is what you're

testing


with udevadm.


Ok, sorry... At least I ensured that udev itself is on...


In any of your logs when you have libvirt debug logging
turned on, do you see the message:

Registering udev node device backend


Nope, I checked in /var/log/* and libvirt.log in debug mode

(which,

after 1 1/2 day of debug activity enabled, is already 2Gb!)

There is no mention of udev. I think it means that the udev

driver

is not loaded in libvirt? How could enable it then? (or produce

some

message telling me why it is not) ?




These messages are the result of not being able to find the

device,

which is consistent with the other things you're seeing.  These

are

all symptoms of the node device code not running.


OK, I'll wait for your suggestions...


Do you see messages like:


14:35:01.849: debug : do_open:1205 : node driver 0 Test returned
DECLINED
14:35:01.849: debug : do_open:1205 : node driver 1 ESX returned
DECLINED
14:35:01.849: debug : do_open:1205 : node driver 2 remote returned
DECLINED
14:35:01.849: debug : do_open:1205 : node driver 3

udevDeviceMonitor

returned SUCCESS

in your debug log?



Frederic.





Have you any other Idea?
Frederic.


- Daniel P. Berrangeberra...@redhat.com a écrit :


On Fri, Feb 12, 2010 at 08:05:21PM +0100, Fr?d?ric Grelot

wrote:

Hi all,

I often update my F12 box with the rawvirt repository, which
just

installed libvirt 0.7.6. Since that, I cannot enumerate

physical

devices (and thus get a beautiful error when I start one of my

vms

that should use a USB device).


I don't think I changed anything else on that box, and, of
course, I

already restarted the libvirt daemon.

I haven't restarted the server itself, because it is

currently

used,

but I could do it if necessary...


I make good use of the qemu hypervisor, and I'm looking

forward

to

solve this issue!


Frederic.

# libvirtd --version libvirtd (libvirt) 0.7.6

# virsh --version 0.7.6

# virsh nodedev-list error :Failed to count node devices

error

:this function is not supported by the hypervisor:

virNodeNumOfDevices

It would appear that the udev driver failed to start - there

are

probably messages in syslog about the problem


Regards, 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

[libvirt] [PATCH 1/2] Add virFork() function to utils.

2010-02-17 Thread Laine Stump
virFork() contains bookkeeping that must be done any time a process
forks. Currently this includes:

1) Call virLogLock() prior to fork() and virLogUnlock() just after,
   to avoid a deadlock if some other thread happens to hold that lock
   during the fork.

2) Reset the logging hooks and send all child process log messages to
   stderr.

3) Block all signals prior to fork(), then either a) reset the signal
   mask for the parent process, or b) clear the signal mask for the
   child process.

util.c, util.h: add virFork() function, based on what is currently
done in __virExec().
---
 src/util/util.c |  115 +++
 src/util/util.h |1 +
 2 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index cdab300..f508f6b 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -296,6 +296,121 @@ static int virClearCapabilities(void)
 }
 #endif
 
+
+/* virFork() - fork a new process while avoiding various race/deadlock 
conditions
+
+   @pid - a pointer to a pid_t that will receive the return value from
+  fork()
+
+   on return from virFork(), if *pid  0, the fork failed and there is
+   no new process. Otherwise, just like fork(), if *pid == 0, it is the
+   child process returning, and if *pid  0, it is the parent.
+
+   Even if *pid = 0, if the return value from virFork() is  0, it
+   indicates a failure that occurred in the parent or child process
+   after the fork. In this case, the child process should call
+   _exit(1) after doing any additional error reporting.
+
+ */
+int virFork(pid_t *pid) {
+sigset_t oldmask, newmask;
+struct sigaction sig_action;
+int saved_errno, ret = -1;
+
+*pid = -1;
+
+/*
+ * Need to block signals now, so that child process can safely
+ * kill off caller's signal handlers without a race.
+ */
+sigfillset(newmask);
+if (pthread_sigmask(SIG_SETMASK, newmask, oldmask) != 0) {
+saved_errno = errno;
+virReportSystemError(errno,
+ %s, _(cannot block signals));
+goto cleanup;
+}
+
+/* Ensure we hold the logging lock, to protect child processes
+ * from deadlocking on another thread's inherited mutex state */
+virLogLock();
+
+*pid = fork();
+saved_errno = errno; /* save for caller */
+
+/* Unlock for both parent and child process */
+virLogUnlock();
+
+if (*pid  0) {
+virReportSystemError(saved_errno,
+ %s, _(cannot fork child process));
+goto cleanup;
+}
+
+if (*pid) {
+
+/* parent process */
+
+/* Restore our original signal mask now that the child is
+   safely running */
+if (pthread_sigmask(SIG_SETMASK, oldmask, NULL) != 0) {
+saved_errno = errno; /* save for caller */
+virReportSystemError(errno, %s, _(cannot unblock signals));
+goto cleanup;
+}
+ret = 0;
+
+} else {
+
+/* child process */
+
+int logprio;
+int i;
+
+/* Remove any error callback so errors in child now
+   get sent to stderr where they stand a fighting chance
+   of being seen / logged */
+virSetErrorFunc(NULL, NULL);
+
+/* Make sure any hook logging is sent to stderr, since child
+ * process may close the logfile FDs */
+logprio = virLogGetDefaultPriority();
+virLogReset();
+virLogSetDefaultPriority(logprio);
+
+/* Clear out all signal handlers from parent so nothing
+   unexpected can happen in our child once we unblock
+   signals */
+sig_action.sa_handler = SIG_DFL;
+sig_action.sa_flags = 0;
+sigemptyset(sig_action.sa_mask);
+
+for (i = 1; i  NSIG; i++) {
+/* Only possible errors are EFAULT or EINVAL
+   The former wont happen, the latter we
+   expect, so no need to check return value */
+
+sigaction(i, sig_action, NULL);
+}
+
+/* Unmask all signals in child, since we've no idea
+   what the caller's done with their signal mask
+   and don't want to propagate that to children */
+sigemptyset(newmask);
+if (pthread_sigmask(SIG_SETMASK, newmask, NULL) != 0) {
+saved_errno = errno; /* save for caller */
+virReportSystemError(errno, %s, _(cannot unblock signals));
+goto cleanup;
+}
+ret = 0;
+}
+
+cleanup:
+if (ret  0)
+errno = saved_errno;
+return ret;
+}
+
 /*
  * @argv argv to exec
  * @envp optional environment to use for exec
diff --git a/src/util/util.h b/src/util/util.h
index 4207508..8460100 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -81,6 +81,7 @@ int virRun(const char *const*argv, int *status) 
ATTRIBUTE_RETURN_CHECK;
 int virRunWithHook(const char *const*argv,
virExecHook hook, 

[libvirt] [PATCH 0/2] Make a wrapper for fork()

2010-02-17 Thread Laine Stump

This was partly prompted by DV's suggestion last week.

The first of these patches creates a new function called virFork()
which behaves (almost) like fork() but takes care of some important
details that pretty much any call to fork() should be doing. The 2nd
switches three fork-calling functions in util.c over to using
virFork() instead of fork().

In the future, except for odd circumstances, code that needs to fork
should call virFork() instead, and if there is anything determined to
be universally necessary at fork-time, it should be added to virFork()
rather than to the callers of virFork(); hopefully this will ease
maintenance and reduce replicated bugs.

(Note that, while this is just an overall code health patch, a
couple bug fix patches I'll be submitting either tomorrow or Thursday
will assume it as a prerequisite).

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


[libvirt] [PATCH 2/2] Use virFork() in __virExec(), virFileCreate() and virDirCreate()

2010-02-17 Thread Laine Stump
For __virExec() this should be a semantic NOP. virFileCreate() and
virDirCreate() gain the code to reset the logging and properly deal
with the signal handling race condition.
---
 src/util/util.c |  100 ++
 1 files changed, 26 insertions(+), 74 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index f508f6b..ae8c461 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -448,20 +448,6 @@ __virExec(const char *const*argv,
 int pipeerr[2] = {-1,-1};
 int childout = -1;
 int childerr = -1;
-int logprio;
-sigset_t oldmask, newmask;
-struct sigaction sig_action;
-
-/*
- * Need to block signals now, so that child process can safely
- * kill off caller's signal handlers without a race.
- */
-sigfillset(newmask);
-if (pthread_sigmask(SIG_SETMASK, newmask, oldmask) != 0) {
-virReportSystemError(errno,
- %s, _(cannot block signals));
-return -1;
-}
 
 if ((null = open(/dev/null, O_RDONLY))  0) {
 virReportSystemError(errno,
@@ -528,17 +514,9 @@ __virExec(const char *const*argv,
 childerr = null;
 }
 
-/* Ensure we hold the logging lock, to protect child processes
- * from deadlocking on another threads inheirited mutex state */
-virLogLock();
-pid = fork();
-
-/* Unlock for both parent and child process */
-virLogUnlock();
+int forkRet = virFork(pid);
 
 if (pid  0) {
-virReportSystemError(errno,
- %s, _(cannot fork child process));
 goto cleanup;
 }
 
@@ -553,12 +531,8 @@ __virExec(const char *const*argv,
 *errfd = pipeerr[0];
 }
 
-/* Restore our original signal mask now child is safely
-   running */
-if (pthread_sigmask(SIG_SETMASK, oldmask, NULL) != 0) {
-virReportSystemError(errno,
- %s, _(cannot unblock signals));
-return -1;
+if (forkRet  0) {
+goto cleanup;
 }
 
 *retpid = pid;
@@ -567,38 +541,10 @@ __virExec(const char *const*argv,
 
 /* child */
 
-/* Remove any error callback too, so errors in child now
-   get sent to stderr where they stand a fighting chance
-   of being seen / logged */
-virSetErrorFunc(NULL, NULL);
-
-/* Make sure any hook logging is sent to stderr, since virExec will
- * close any unknown FDs (including logging handlers) before launching
- * the new process */
-logprio = virLogGetDefaultPriority();
-virLogReset();
-virLogSetDefaultPriority(logprio);
-
-/* Clear out all signal handlers from parent so nothing
-   unexpected can happen in our child once we unblock
-   signals */
-sig_action.sa_handler = SIG_DFL;
-sig_action.sa_flags = 0;
-sigemptyset(sig_action.sa_mask);
-
-for (i = 1 ; i  NSIG ; i++)
-/* Only possible errors are EFAULT or EINVAL
-   The former wont happen, the latter we
-   expect, so no need to check return value */
-sigaction(i, sig_action, NULL);
-
-/* Unmask all signals in child, since we've no idea
-   what the caller's done with their signal mask
-   and don't want to propagate that to children */
-sigemptyset(newmask);
-if (pthread_sigmask(SIG_SETMASK, newmask, NULL) != 0) {
-virReportSystemError(errno,
- %s, _(cannot unblock signals));
+if (forkRet  0) {
+/* The fork was sucessful, but after that there was an error
+ * in the child (which was already logged).
+*/
 _exit(1);
 }
 
@@ -1367,14 +1313,10 @@ int virFileCreate(const char *path, mode_t mode,
  * following dance avoids problems caused by root-squashing
  * NFS servers. */
 
-virLogLock();
-pid = fork();
-virLogUnlock();
+int forkRet = virFork(pid);
 
 if (pid  0) {
 ret = errno;
-virReportSystemError(errno,
- _(cannot fork o create file '%s'), path);
 return ret;
 }
 
@@ -1426,7 +1368,15 @@ parenterror:
 return ret;
 }
 
-/* child - set desired uid/gid, then attempt to create the file */
+
+/* child */
+
+if (forkRet  0) {
+/* error encountered and logged in virFork() after the fork. */
+goto childerror;
+}
+
+/* set desired uid/gid, then attempt to create the file */
 
 if ((gid != 0)  (setgid(gid) != 0)) {
 ret = errno;
@@ -1477,15 +1427,10 @@ int virDirCreate(const char *path, mode_t mode,
 return virDirCreateSimple(path, mode, uid, gid, flags);
 }
 
-virLogLock();
-pid = fork();
-virLogUnlock();
+int forkRet = virFork(pid);
 
 if (pid  0) {
 ret = errno;
-virReportSystemError(errno,
- _(cannot fork to create directory '%s'),
- path);
 return ret;
 }
 
@@ 

[libvirt] [PATCH] macvtap teardown rework

2010-02-17 Thread Stefan Berger
I have reworked and simplified the teardown of the macvtap device.
Basically all devices with the same MAC address and link device are kept
alive and not attempted to be torn down. If a macvtap device linked to a
physical interface with a certain MAC address 'M' is to be created it
will automatically fail if the interface is 'up'ed and another macvtap
with the same properties (MAC addr 'M', link dev) happens to be 'up'.
This will prevent the VM from starting or the device from being attached
to a running VM. Stale interfaces are assumed to be there for some
reason and not stem from libvirt.

In the VM shutdown path I am assuming that an interface name is always
available so that if the device type is DIRECT it can be torn down using
its name.

Signed-off-by: Stefan Berger stef...@us.ibm.com

Index: libvirt-macvtap/src/util/macvtap.h
===
--- libvirt-macvtap.orig/src/util/macvtap.h
+++ libvirt-macvtap/src/util/macvtap.h
@@ -35,8 +35,7 @@ int openMacvtapTap(virConnectPtr conn,
int mode,
char **res_ifname);
 
-int delMacvtapByMACAddress(const unsigned char *macaddress,
-   int *hasBusyDev);
+void delMacvtap(const char *name);
 
 #endif /* WITH_MACVTAP */
 
Index: libvirt-macvtap/src/util/macvtap.c
===
--- libvirt-macvtap.orig/src/util/macvtap.c
+++ libvirt-macvtap/src/util/macvtap.c
@@ -447,15 +447,14 @@ buffer_too_small:
 
 
 static int
-link_del(const char *type,
- const char *name)
+link_del(const char *name)
 {
 int rc = 0;
 char nlmsgbuf[256];
 struct nlmsghdr *nlm = (struct nlmsghdr *)nlmsgbuf, *resp;
 struct nlmsgerr *err;
 char rtattbuf[64];
-struct rtattr *rta, *rta1;
+struct rtattr *rta;
 struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
 char *recvbuf = NULL;
 int recvbuflen;
@@ -467,23 +466,6 @@ link_del(const char *type,
 if (!nlAppend(nlm, sizeof(nlmsgbuf), ifinfo, sizeof(ifinfo)))
 goto buffer_too_small;
 
-rta = rtattrCreate(rtattbuf, sizeof(rtattbuf), IFLA_LINKINFO, NULL, 0);
-if (!rta)
-goto buffer_too_small;
-
-if (!(rta1 = nlAppend(nlm, sizeof(nlmsgbuf), rtattbuf, rta-rta_len)))
-goto buffer_too_small;
-
-rta = rtattrCreate(rtattbuf, sizeof(rtattbuf), IFLA_INFO_KIND,
-   type, strlen(type));
-if (!rta)
-goto buffer_too_small;
-
-if (!nlAppend(nlm, sizeof(nlmsgbuf), rtattbuf, rta-rta_len))
-goto buffer_too_small;
-
-rta1-rta_len = (char *)nlm + nlm-nlmsg_len - (char *)rta1;
-
 rta = rtattrCreate(rtattbuf, sizeof(rtattbuf), IFLA_IFNAME,
name, strlen(name)+1);
 if (!rta)
@@ -633,7 +615,8 @@ macvtapModeFromInt(enum virDomainNetdevM
 }
 
 
-/* openMacvtapTap:
+/**
+ * openMacvtapTap:
  * Create an instance of a macvtap device and open its tap character
  * device.
  * @conn: Pointer to virConnect object
@@ -707,14 +690,17 @@ create_name:
 rc = ifUp(cr_ifname, 1);
 if (rc != 0) {
 virReportSystemError(errno,
- _(cannot 'up' interface %s), cr_ifname);
+ _(cannot 'up' interface %s -- another 
+ macvtap device may be 'up' and have the same 
+ MAC address),
+ cr_ifname);
 rc = -1;
 goto link_del_exit;
 }
 
 rc = openTap(cr_ifname, 10);
 
-if (rc  0)
+if (rc = 0)
 *res_ifname = strdup(cr_ifname);
 else
 goto link_del_exit;
@@ -722,79 +708,22 @@ create_name:
 return rc;
 
 link_del_exit:
-link_del(type, ifname);
+link_del(cr_ifname);
 
 return rc;
 }
 
 
-/* Delete a macvtap type of interface given the MAC address. This
- * function will delete all macvtap type of interfaces that have the
- * given MAC address.
- * @macaddress : Pointer to 6 bytes holding the MAC address of the
- *macvtap device(s) to destroy
+/**
+ * delMacvtapByName:
+ * @ifname : The name of the macvtap interface
  *
- * Returns 0 in case of success, negative value in case of error.
+ * Delete an interface given its name.
  */
-int
-delMacvtapByMACAddress(const unsigned char *macaddress,
-   int *hasBusyDev)
+void
+delMacvtap(const char *ifname)
 {
-struct ifreq ifr;
-FILE *file;
-char *ifname, *pos;
-char buffer[1024];
-off_t oldpos = 0;
-int tapfd;
-
-*hasBusyDev = 0;
-
-file = fopen(/proc/net/dev, r);
-
-if (!file) {
-virReportSystemError(errno, %s,
- _(cannot open file to read network interfaces 
- from));
-return -1;
-}
-
-int sock = socket(AF_INET, SOCK_DGRAM, 0);
-if (sock  0) {
-virReportSystemError(errno, %s,
- _(cannot open socket));
-goto sock_err;
-}

Re: [libvirt] [PATCH] Run 'qmp_capabilities' command at monitor startup

2010-02-17 Thread Luiz Capitulino
On Mon, 15 Feb 2010 15:16:32 +
Daniel P. Berrange berra...@redhat.com wrote:

 On Mon, Feb 15, 2010 at 04:14:01PM +0100, Matthias Bolte wrote:
  2010/2/15 Daniel P. Berrange berra...@redhat.com:
   ---
    src/qemu/qemu_driver.c       |   18 ++
    src/qemu/qemu_monitor.c      |   13 +
    src/qemu/qemu_monitor.h      |    2 ++
    src/qemu/qemu_monitor_json.c |   20 
    src/qemu/qemu_monitor_json.h |    2 ++
    5 files changed, 51 insertions(+), 4 deletions(-)
  
  
  ACK.
  
  Why do we need to call qmp_capabilities at startup?
 
 Because QEMU developers just decided to add it and make it mandatory :-)

 Actually, it's because when a client connects QMP is in capabilities
negotiation mode. In this mode only the qmp_capabilities command can
be issued. When this is done QMP changes to command mode, where all
commands are accepted.

 This is QMP's capabilities negotiation support. It's a mandatory step
because new capabilities are reserved for protocol changes or features
which are not backward compatible. This way, it's important that server
and clients agree on what is going to be on the wire before any message
is exchanged.

 We don't have any capabilities yet, so qmp_capabilities is issued
without arguments. Which is what clients should do if they don't support
new features.

 /me is happy the JSON code is still disabled until QEMU 0.13 comes out

 Well, I was in favor of making QMP stable for 0.12, but today I realize
that this would have been a mistake, as the protocol wasn't mature yet.

 I understand that having to keep up to date with an unstable protocol
isn't always fun, on the other hand libvirt's early adoption and your
inputs are crucial to guide QMP's unstable phase into the right direction.

 Please, let me know if there's anything that we could improve on our side.

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

[libvirt] [PATCH] python: Actually add virConnectGetVersion to generated bindings

2010-02-17 Thread Cole Robinson
The recent commit to implement a python version of this function
didn't drop an explicit 'ignore' check in the generator, so this
never ended up in the bindings.

Signed-off-by: Cole Robinson crobi...@redhat.com
---
 python/generator.py |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/python/generator.py b/python/generator.py
index 37c0169..24eaf50 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -319,7 +319,6 @@ skip_function = (
 'virConnectListDomains', # Python API is called virConectListDomainsID for 
unknown reasons
 'virConnSetErrorFunc', # Not used in Python API  XXX is this a bug ?
 'virResetError', # Not used in Python API  XXX is this a bug ?
-'virConnectGetVersion', # Not used in Python API  XXX is this a bug ?
 'virGetVersion', # Python C code is manually written
 'virSetErrorFunc', # Python API is called virRegisterErrorHandler for 
unknown reasons
 'virConnCopyLastError', # Python API is called virConnGetLastError instead
-- 
1.6.5.2

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


Re: [libvirt] [PATCH] python: Actually add virConnectGetVersion to generated bindings

2010-02-17 Thread Daniel Veillard
On Wed, Feb 17, 2010 at 03:57:29PM -0500, Cole Robinson wrote:
 The recent commit to implement a python version of this function
 didn't drop an explicit 'ignore' check in the generator, so this
 never ended up in the bindings.
 
 Signed-off-by: Cole Robinson crobi...@redhat.com
 ---
  python/generator.py |1 -
  1 files changed, 0 insertions(+), 1 deletions(-)
 
 diff --git a/python/generator.py b/python/generator.py
 index 37c0169..24eaf50 100755
 --- a/python/generator.py
 +++ b/python/generator.py
 @@ -319,7 +319,6 @@ skip_function = (
  'virConnectListDomains', # Python API is called virConectListDomainsID 
 for unknown reasons
  'virConnSetErrorFunc', # Not used in Python API  XXX is this a bug ?
  'virResetError', # Not used in Python API  XXX is this a bug ?
 -'virConnectGetVersion', # Not used in Python API  XXX is this a bug ?
  'virGetVersion', # Python C code is manually written
  'virSetErrorFunc', # Python API is called virRegisterErrorHandler for 
 unknown reasons
  'virConnCopyLastError', # Python API is called virConnGetLastError 
 instead

  urgh ! ACK

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH] python: Actually add virConnectGetVersion to generated bindings

2010-02-17 Thread Cole Robinson
On 02/17/2010 04:04 PM, Daniel Veillard wrote:
 On Wed, Feb 17, 2010 at 03:57:29PM -0500, Cole Robinson wrote:
 The recent commit to implement a python version of this function
 didn't drop an explicit 'ignore' check in the generator, so this
 never ended up in the bindings.

 Signed-off-by: Cole Robinson crobi...@redhat.com
 ---
  python/generator.py |1 -
  1 files changed, 0 insertions(+), 1 deletions(-)

 diff --git a/python/generator.py b/python/generator.py
 index 37c0169..24eaf50 100755
 --- a/python/generator.py
 +++ b/python/generator.py
 @@ -319,7 +319,6 @@ skip_function = (
  'virConnectListDomains', # Python API is called virConectListDomainsID 
 for unknown reasons
  'virConnSetErrorFunc', # Not used in Python API  XXX is this a bug ?
  'virResetError', # Not used in Python API  XXX is this a bug ?
 -'virConnectGetVersion', # Not used in Python API  XXX is this a bug ?
  'virGetVersion', # Python C code is manually written
  'virSetErrorFunc', # Python API is called virRegisterErrorHandler for 
 unknown reasons
  'virConnCopyLastError', # Python API is called virConnGetLastError 
 instead
 
   urgh ! ACK
 
 Daniel
 

Thanks, pushed now.

- Cole

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


Re: [libvirt] [PATCH] Automatically pause QEMU guests when an error occurs

2010-02-17 Thread Daniel Veillard
On Tue, Feb 16, 2010 at 05:04:04PM +, Daniel P. Berrange wrote:
 With the QMP mode monitor, it is possible to get a notification
 that a disk I/O error occurs ina guest. This patch enables such
 reporting and when receiving an error updates libvirt's view
 of the guest to indicate that it is now paused. It also emits
 an event
 
   VIR_DOMAIN_EVENT_SUSPENDED
 
 with a detail of:
 
   VIR_DOMAIN_EVENT_SUSPENDED_IOERROR
 
 * include/libvirt/libvirt.h.in: Add VIR_DOMAIN_EVENT_SUSPENDED_IOERROR
 * src/qemu/qemu_driver.c: Update VM state to paused when IO error
   occurrs
 * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
   src/qemu/qemu_monitor_json.c: Wire up handlers for disk IO errors
 ---
  include/libvirt/libvirt.h.in |1 +
  src/qemu/qemu_conf.c |7 +--
  src/qemu/qemu_conf.h |2 +-
  src/qemu/qemu_driver.c   |   38 +++---
  src/qemu/qemu_monitor.c  |   16 
  src/qemu/qemu_monitor.h  |5 +
  src/qemu/qemu_monitor_json.c |6 ++
  7 files changed, 69 insertions(+), 6 deletions(-)
 
 diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
 index 260505e..b7a6922 100644
 --- a/include/libvirt/libvirt.h.in
 +++ b/include/libvirt/libvirt.h.in
 @@ -1361,6 +1361,7 @@ typedef enum {
  typedef enum {
  VIR_DOMAIN_EVENT_SUSPENDED_PAUSED = 0,   /* Normal suspend due to admin 
 pause */
  VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED = 1, /* Suspended for offline 
 migration */
 +VIR_DOMAIN_EVENT_SUSPENDED_IOERROR = 2,  /* Suspended due to a disk I/O 
 error */
  } virDomainEventSuspendedDetailType;
  
  /**
 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index c9fe55b..20076bc 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
 @@ -2385,6 +2385,9 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
  } else if (disk-shared  !disk-readonly) {
  virBufferAddLit(opt, ,cache=off);
  }
 +if (qemuCmdFlags  QEMUD_CMD_FLAG_MONITOR_JSON) {
 +virBufferVSprintf(opt, ,werror=stop,rerror=stop);
 +}
  
  if (virBufferError(opt)) {
  virReportOOMError();
 @@ -2400,7 +2403,7 @@ error:
  
  
  char *
 -qemuBuildDriveDevStr(virDomainDiskDefPtr disk)
 +qemuBuildDriveDevStr(virDomainDiskDefPtr disk, int qemuCmdFlags 
 ATTRIBUTE_UNUSED)
  {
  virBuffer opt = VIR_BUFFER_INITIALIZER;
  const char *bus = virDomainDiskQEMUBusTypeToString(disk-bus);
 @@ -3578,7 +3581,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
  } else {
  ADD_ARG_LIT(-device);
  
 -if (!(optstr = qemuBuildDriveDevStr(disk)))
 +if (!(optstr = qemuBuildDriveDevStr(disk, qemuCmdFlags)))
  goto error;
  ADD_ARG(optstr);
  }
 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
 index 7041489..ec8033a 100644
 --- a/src/qemu/qemu_conf.h
 +++ b/src/qemu/qemu_conf.h
 @@ -214,7 +214,7 @@ char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
  unsigned long long qemuCmdFlags);
  
  /* Current, best practice */
 -char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk);
 +char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk, int qemuCmdFlags);
  /* Current, best practice */
  char * qemuBuildControllerDevStr(virDomainControllerDefPtr def);
  
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 77306f3..23073bc 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -824,9 +824,41 @@ cleanup:
  return ret;
  }
  
 +
 +static int
 +qemuHandleDiskIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 +  virDomainObjPtr vm,
 +  const char *diskalias ATTRIBUTE_UNUSED)
 +{
 +struct qemud_driver *driver = qemu_driver;
 +virDomainEventPtr event = NULL;
 +
 +VIR_DEBUG(Received IO error on %p '%s': %s, vm, vm-def-name, 
 diskalias);
 +virDomainObjLock(vm);
 +
 +vm-state = VIR_DOMAIN_PAUSED;
 +event = virDomainEventNewFromObj(vm,
 + VIR_DOMAIN_EVENT_SUSPENDED,
 + VIR_DOMAIN_EVENT_SUSPENDED_IOERROR);
 +
 +if (virDomainSaveStatus(driver-caps, driver-stateDir, vm)  0)
 +VIR_WARN(Unable to save status on vm %s after IO error, 
 vm-def-name);
 +
 +virDomainObjUnlock(vm);
 +
 +if (event) {
 +qemuDriverLock(driver);
 +qemuDomainEventQueue(driver, event);
 +qemuDriverUnlock(driver);
 +}
 +return 0;
 +}
 +
 +
  static qemuMonitorCallbacks monitorCallbacks = {
  .eofNotify = qemuHandleMonitorEOF,
  .diskSecretLookup = findVolumeQcowPassphrase,
 +.diskIOError = qemuHandleDiskIOError,
  };
  
  static int
 @@ -5353,7 +5385,7 @@ static int qemudDomainAttachPciDiskDevice(struct 
 qemud_driver *driver,
  if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags)))
  goto error;
  
 -if (!(devstr = 

Re: [libvirt] [PATCH] macvtap teardown rework

2010-02-17 Thread Ed Swierk
On Wed, Feb 17, 2010 at 12:05 PM, Stefan Berger stef...@us.ibm.com wrote:
 I have reworked and simplified the teardown of the macvtap device.
 Basically all devices with the same MAC address and link device are kept
 alive and not attempted to be torn down. If a macvtap device linked to a
 physical interface with a certain MAC address 'M' is to be created it
 will automatically fail if the interface is 'up'ed and another macvtap
 with the same properties (MAC addr 'M', link dev) happens to be 'up'.
 This will prevent the VM from starting or the device from being attached
 to a running VM. Stale interfaces are assumed to be there for some
 reason and not stem from libvirt.

 In the VM shutdown path I am assuming that an interface name is always
 available so that if the device type is DIRECT it can be torn down using
 its name.

This is a huge improvement. It makes the normal shutdown path nice and
simple, and returns a clear error message instead of making an
elaborate attempt to work around a prior unclean shutdown.

Just one cosmetic nit: the name argument in the delMacvtap()
declaration in macvtap.h should be ifname for consistency with the
definition in macvtap.c.

--Ed

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


Re: [libvirt] libvirt XML format.

2010-02-17 Thread Kumar L Srikanth-B22348
Thanks for the reply Matt.
I created a Linux Container(container1) using lxc-tools. I created a
Domain(container1_vm) using libvirt and want to mount that container
file system in the created Domain. For that, I created following XML
format:
domain type='lxc' id='1'
  namecontainer1_vm/name
memory50/memory
  os
  typeexe/type
  init/bin/sh/init
  /os
  vcpu1/vcpu
  clock offset='utc'/
  on_poweroffdestroy/on_poweroff
  on_rebootrestart/on_reboot
  on_crashdestroy/on_crash
  devices
emulator/usr/libexec/libvirt_lxc/emulator
filesystem type='mount'
  source dir='/var/lib/lxc/container1/rootfs/rootfs'/ 
  target dir='/'/ 
/filesystem
console type='pty' /
  /devices
/domain

The above XML worked fine, and domain started.
Now, I created a bridge br0 in the host machine with the IP 172.16.1.10.
I want to assign an IP address[172.16.1.15] to the domain, so that the
host machine and domain will ping each other. I tried to assign
'default' network to the domain by adding the following XML block to the
above XML file:
interface type='network'
  source network='default'/
/interface
But, when I start the domain I got the following error in the virsh
console:

error: Failed to start domain vm1_fedora
error: Failed to add veth0 device to virbr0: No such device

Can you please let me know the XML format for assigning a statis IP
address to the Domain?

Regards,
Srikanth.

-Original Message-
From: libvir-list-boun...@redhat.com
[mailto:libvir-list-boun...@redhat.com] On Behalf Of Matthew Booth
Sent: Wednesday, February 17, 2010 7:38 PM
To: libvir-list@redhat.com
Subject: Re: [libvirt] libvirt XML format.

On 17/02/10 12:36, Kumar L Srikanth-B22348 wrote:
 Hi,

Hi Kumar,

 I have some doubts regarding libvirt XML format.
 Can anyone please let me know in detail, what is /source/ and 
 /target/ tags in the libvirt XML format?

The best documentation is available here:
http://libvirt.org/formatdomain.html

If that's not enough, could you post an example of what you're trying to
do? Doesn't matter if it's wrong.

 Can I put '/' in the /target/ tag or are there any exceptions if I 
 put '/' in that?

The domain XML is a valid XML document. Syntactically, you can put /
anywhere it would be valid in an XML document.

Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

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


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


[libvirt] [PATCH] xenDaemonDomainSetAutostart: avoid appearance of impropriety

2010-02-17 Thread Jim Meyering
Coverity noticed that of the 13 uses of sexpr_lookup,
only this one was unchecked, and here, the result is dereferenced.
It happens to be a false positive, due to the preceding sexpr_node
check, but worth fixing: sexpr_node is just a very thin wrapper
around sexpr_lookup so there's little justification for looking
up the same string twice.

From a9ab34214cf9d247d39731563dcc70b8f1dc73b5 Mon Sep 17 00:00:00 2001
From: Jim Meyering meyer...@redhat.com
Date: Wed, 17 Feb 2010 22:14:25 +0100
Subject: [PATCH] xenDaemonDomainSetAutostart: avoid appearance of impropriety

* src/xen/xend_internal.c (xenDaemonDomainSetAutostart): Rewrite to
avoid dereferencing the result of sexpr_lookup.  While in this
particular case, it was guaranteed never to be NULL, due to the
preceding if sexpr_node(...) guard, it's cleaner to skip the
sexpr_node call altogether, and also saves a lookup.
---
 src/xen/xend_internal.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 88923c8..1f8b106 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -4383,7 +4383,6 @@ xenDaemonDomainSetAutostart(virDomainPtr domain,
 int autostart)
 {
 struct sexpr *root, *autonode;
-const char *autostr;
 char buf[4096];
 int ret = -1;
 xenUnifiedPrivatePtr priv;
@@ -4408,16 +4407,17 @@ xenDaemonDomainSetAutostart(virDomainPtr domain,
 return (-1);
 }

-autostr = sexpr_node(root, domain/on_xend_start);
-if (autostr) {
-if (!STREQ(autostr, ignore)  !STREQ(autostr, start)) {
+autonode = sexpr_lookup(root, domain/on_xend_start);
+if (autonode) {
+const char *val = (autonode-u.s.car-kind == SEXPR_VALUE
+   ? autonode-u.s.car-u.value : NULL);
+if (!STREQ(val, ignore)  !STREQ(val, start)) {
 virXendError(domain-conn, VIR_ERR_INTERNAL_ERROR,
  %s, _(unexpected value from on_xend_start));
 goto error;
 }

 // Change the autostart value in place, then define the new sexpr
-autonode = sexpr_lookup(root, domain/on_xend_start);
 VIR_FREE(autonode-u.s.car-u.value);
 autonode-u.s.car-u.value = (autostart ? strdup(start)
 : strdup(ignore));
--
1.7.0.219.g6bb57

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


Re: [libvirt] [PATCH] openvzLoadDomains: don't ignore failing virUUIDFormat

2010-02-17 Thread Jim Meyering
Daniel Veillard wrote:
 Subject: [PATCH] openvzLoadDomains: don't ignore failing virUUIDFormat

 * src/openvz/openvz_conf.c (openvzLoadDomains): Diagnose failure of
 virUUIDFormat.
 ---
  src/openvz/openvz_conf.c |6 +-
  1 files changed, 5 insertions(+), 1 deletions(-)

 diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
 index 51dbde5..a4aab1e 100644
 --- a/src/openvz/openvz_conf.c
 +++ b/src/openvz/openvz_conf.c
 @@ -908,7 +908,11 @@ static int
  openvzSetUUID(int vpsid){
  unsigned char uuid[VIR_UUID_BUFLEN];

 -virUUIDGenerate(uuid);
 +if (virUUIDGenerate(uuid)) {
 +openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
 +%s, _(Failed to generate UUID));
 +return -1;
 +}

  return openvzSetDefinedUUID(vpsid, uuid);
  }

   ACK,

Thanks.  Pushed.

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