[libvirt] [PATCH] docs: removed old changelog file, as it is no longer relevant

2010-10-22 Thread Justin Clift
We instead point to the live git log URL for the few links still
needing to point to something.
---
 docs/ChangeLog.awk   |   49 -
 docs/ChangeLog.xsl   |   37 -
 docs/Makefile.am |   13 +
 docs/news.html.in|2 +-
 docs/sitemap.html.in |2 +-
 5 files changed, 3 insertions(+), 100 deletions(-)
 delete mode 100755 docs/ChangeLog.awk
 delete mode 100644 docs/ChangeLog.xsl

diff --git a/docs/ChangeLog.awk b/docs/ChangeLog.awk
deleted file mode 100755
index d9d92fc..000
--- a/docs/ChangeLog.awk
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/awk -f
-function translate(str) {
-while (sub(//, #amp;, str) == 1);
-while (sub(/#amp;/, \\amp;, str) == 1); # fun isn't it ?
-while (sub(//, \\lt;, str) == 1);
-while (sub(//, \\gt;, str) == 1);
-sub(/[0-9][0-9][0-9][0-9][0-9]+/, bug number=''/, str)
-return(str)
-}
-BEGIN {
-   nb_entry = 0
-in_entry = 0
-in_item = 0
-   print ?xml version='1.0' encoding='ISO-8859-1'?
-   print log
- }
-END   {
-if (in_item == 1)  printf(%s/item\n, translate(item))
-if (in_entry == 1) print   /entry
-print /log
- }
-/^[ \t]*$/{ next }
-/^[A-Za-z0-9]/ {
-match($0, \(.*\) \([A-Z]+\) \([0-9][0-9][0-9][0-9]\) \(.*\) 
\(.*\), loge)
-if (in_item == 1)  printf(%s/item\n, translate(item))
-if (in_entry == 1) print   /entry
-   nb_entry = nb_entry + 1
-   if (nb_entry  50) {
-   in_entry = 0
-   in_item = 0
-   exit
-   }
-in_entry = 1
-in_item = 0
-   printf(  entry date='%s' timezone='%s' year='%s'\n 
who='%s' email='%s'\n, loge[1], loge[2], loge[3], loge[4], loge[5])
- }
-/^[ \t]*\*/   {
-if (in_item == 1)  printf(%s/item\n, translate(item))
-in_item = 1
-   printf(item)
-match($0, [ \t]*. *\(.*\), loge)
-   item = loge[1]
-  }
-/^[ \t]*[a-zA-Z0-9\#]/{
-if (in_item == 1) {
-   match($0, [ \t]*\(.*\)[ \t]*, loge)
-   item = sprintf(%s %s,  item, loge[1])
-   }
-  }
diff --git a/docs/ChangeLog.xsl b/docs/ChangeLog.xsl
deleted file mode 100644
index f2c6816..000
--- a/docs/ChangeLog.xsl
+++ /dev/null
@@ -1,37 +0,0 @@
-?xml version=1.0?
-!-- this stylesheet builds the ChangeLog.html --
-xsl:stylesheet version=1.0
-  xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
-
-  !-- Generate XHTML-1.0 transitional --
-  xsl:output method=xml encoding=UTF-8 indent=yes
-  doctype-public=-//W3C//DTD XHTML 1.0//EN
-  doctype-system=http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd/
-
-  xsl:template match=item
-lixsl:apply-templates//li
-  /xsl:template
-
-  xsl:template match=entry
-p
-  span class=authorxsl:value-of select=@who/ /span
-  span class=datexsl:value-of select=@date/ /span
-  span class=timezonexsl:value-of select=@timezone/ /span
-/p
-ul
-  xsl:apply-templates select=item/
-/ul
-  /xsl:template
-
-  xsl:template match=log
-html
-  body
-h1Log of recent changes to libvirt/h1
-div id=changelog
-  xsl:apply-templates select=entry/
-/div
-  /body
-/html
-  /xsl:template
-
-/xsl:stylesheet
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 13ab0c2..ae13c46 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -73,13 +73,12 @@ fig = \
 
 EXTRA_DIST=\
   apibuild.py \
-  site.xsl newapi.xsl news.xsl page.xsl ChangeLog.xsl \
+  site.xsl newapi.xsl news.xsl page.xsl \
   $(dot_html) $(dot_html_in) $(gif) $(apihtml) $(apipng) \
   $(devhelphtml) $(devhelppng) $(devhelpcss) $(devhelpxsl) \
   $(xml) $(fig) $(png) \
   $(patches) \
   sitemap.html.in \
-  ChangeLog.awk \
   todo.pl todo.cfg-example
 
 MAINTAINERCLEANFILES = $(dot_html) $(apihtml) $(devhelphtml)
@@ -90,16 +89,6 @@ api: libvirt-api.xml libvirt-refs.xml
 
 web: $(dot_html) html/index.html devhelp/index.html
 
-ChangeLog.xml: ../ChangeLog ChangeLog.awk
-   $(AWK) -f ChangeLog.awk  $  $@
-
-ChangeLog.html.in: ChangeLog.xml ChangeLog.xsl
-   @if [ -x $(XSLTPROC) ] ; then \
- echo Generating $@; \
- name=`echo $@ | sed -e 's/.tmp//'`; \
- $(XSLTPROC) --nonet $(top_srcdir)/docs/ChangeLog.xsl $  $@ \
-   || { rm $@  exit 1; }; fi
-
 todo.html.in: todo.pl
if [ -f  todo.cfg ]; then \
echo Generating $@; \
diff --git a/docs/news.html.in b/docs/news.html.in
index 4a9329d..bbf1e8b 100644
--- a/docs/news.html.in
+++ b/docs/news.html.in
@@ -6,7 +6,7 @@
   body
 h1 Releases/h1
 pHere is the list of official 

[libvirt] [PATCH] docs: added a table of contents to the new c sharp bindings page

2010-10-22 Thread Justin Clift
---
 docs/csharp.html.in |   20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/docs/csharp.html.in b/docs/csharp.html.in
index 3e15176..a32fbd2 100644
--- a/docs/csharp.html.in
+++ b/docs/csharp.html.in
@@ -3,7 +3,9 @@
   body
 h1C# API bindings/h1
 
-h2Description/h2
+ul id=toc/ul
+
+h2a name=descriptionDescription/a/h2
 
 p
   The C# libvirt bindings are a class library.  They use a Microsoft
@@ -18,7 +20,7 @@
 
 pnbsp;/p
 
-h2Requirements/h2
+h2a name=requirementsRequirements/a/h2
 
 p
   These bindings depend upon the libvirt libraries being installed.
@@ -29,7 +31,7 @@
 pnbsp;/p
 
 !-- 2010-10-19 JC: Commented out until we have C# tarballs to download
-h2Getting them/h2
+h2a name=gettingGetting them/a/h2
 
 p
   The latest versions of the libvirt C# bindings can be downloaded from:
@@ -41,7 +43,7 @@
 /ul
 --
 
-h2GIT source repository/h2
+h2a name=gitGIT source repository/a/h2
 p
   The C# bindings source code is maintained in a a
   href=http://git-scm.com/;git/a repository available on
@@ -62,7 +64,7 @@ git clone git://libvirt.org/libvirt-csharp.git
 
 pnbsp;/p
 
-h2Usage/h2
+h2a name=usageUsage/a/h2
 
 p
   The class library exposes the bLibvirtBindings/b namespace.
@@ -80,7 +82,7 @@ git clone git://libvirt.org/libvirt-csharp.git
 
 pnbsp;/p
 
-h2Authors/h2
+h2a name=authorsAuthors/a/h2
 
 p
   The C# bindings are the work of Arnaud Champion
@@ -90,7 +92,7 @@ git clone git://libvirt.org/libvirt-csharp.git
 
 pnbsp;/p
 
-h2Notes on testing/h2
+h2a name=notesNotes on testing/a/h2
 
 p
   Windows testing is performed on Windows 7, with .NET 4, Visual Studio 
2010, and MonoDevelop 2.4.
@@ -101,7 +103,7 @@ git clone git://libvirt.org/libvirt-csharp.git
 
 pnbsp;/p
 
-h2Type Coverage/h2
+h2a name=typeType Coverage/a/h2
 
 p
   Coverage of the libvirt types is:
@@ -178,7 +180,7 @@ git clone git://libvirt.org/libvirt-csharp.git
 
 pnbsp;/p
 
-h2Function Coverage/h2
+h2a name=funccoverFunction Coverage/a/h2
 
 p
   Coverage of the libvirt functions is:
-- 
1.7.2.3

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


Re: [libvirt] [libvirt-tck 3/3] Add test case for daemon hook testing

2010-10-22 Thread Osier
updated, and patch attached.

- Osier
- Daniel P. Berrange berra...@redhat.com wrote:

 On Tue, Oct 19, 2010 at 03:41:55AM -0400, Osier wrote:
  attach updated patch for daemon hook testing..
  
  replaced cat with slurp, corrected typos.
 
  From 963158c860d5415117e70b67458745c2b4cf9c13 Mon Sep 17 00:00:00
 2001
  From: Osier Yang jy...@redhat.com
  Date: Tue, 19 Oct 2010 15:32:17 +0800
  Subject: [libvirt-tck 4/4] Add test case for daemon hook testing
  
  Validate daemon hook is invoked correctly while start, stop,
  restart, reload libvirtd
  ---
   scripts/hooks/051-daemon-hook.t |  153
 +++
   1 files changed, 153 insertions(+), 0 deletions(-)
   create mode 100644 scripts/hooks/051-daemon-hook.t
 
 This still needs to skip execution if the Sys::Virt::TCK 
 connection object is not lxc:/// or qemu:///system
 
 Regards,
 Daniel
 -- 
 |: Red Hat, Engineering, London-o-  
 http://people.redhat.com/berrange/ :|
 |: http://libvirt.org -o- http://virt-manager.org -o-
 http://deltacloud.org :|
 |: http://autobuild.org-o-
 http://search.cpan.org/~danberr/ :|
 |: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B
 9505 :|
From 8d2a62528a7820939c4d7c86dd10cbf16ea5d751 Mon Sep 17 00:00:00 2001
From: Osier Yang jy...@redhat.com
Date: Fri, 22 Oct 2010 14:40:13 +0800
Subject: [TCK] Skip daemon hook testing if URI is not qemu:///system or lxc:///
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Skip the case execution if Sys::Virt::TCK connection object is
not qemu:///system or lxc:///
---
 scripts/hooks/051-daemon-hook.t |  178 +--
 1 files changed, 96 insertions(+), 82 deletions(-)

diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t
index bc9714c..c378bd0 100644
--- a/scripts/hooks/051-daemon-hook.t
+++ b/scripts/hooks/051-daemon-hook.t
@@ -30,124 +30,138 @@ use warnings;
 
 use Slurp;
 
-use Test::More tests = 12;
+use Sys::Virt::TCK;
 use Sys::Virt::TCK::Hooks;
 
-my $hook = Sys::Virt::TCK::Hooks-new(type = 'daemon',
-  conf_dir = '/etc/libvirt/hooks',
-  log_name = '/tmp/daemon.log');
+use Test::More tests = 12;
+
+my $tck = Sys::Virt::TCK-new();
+my $conn = eval { $tck-setup(); };
+BAIL_OUT failed to setup test harness: $@ if $@;
+END { $tck-cleanup if $tck; }
+
+SKIP: {
+my $uri = $conn-get_uri();
+
+skip 12, NOT using QEMU/LXC driver unless
+$uri eq qemu:///system or $uri eq lxc:///;
+
+my $hook = Sys::Virt::TCK::Hooks-new(type = 'daemon',
+  conf_dir = '/etc/libvirt/hooks',
+  log_name = '/tmp/daemon.log');
 
-$hook-libvirtd_status;
-BAIL_OUT libvirtd is not running, Exit... 
-if ($hook-{libvirtd_status} eq 'stopped');
+$hook-libvirtd_status;
+BAIL_OUT libvirtd is not running, Exit... 
+if ($hook-{libvirtd_status} eq 'stopped');
 
-eval { $hook-prepare; };
-BAIL_OUT failed to setup hooks testing ENV: $@ if $@;
+eval { $hook-prepare; };
+BAIL_OUT failed to setup hooks testing ENV: $@ if $@;
 
-diag restart libvirtd for hooks scripts taking effect;
-$hook-action('restart');
-$hook-service_libvirtd;
-unlink $hook-{log_name} unless -f $hook-{log_name};
+diag restart libvirtd for hooks scripts taking effect;
+$hook-action('restart');
+$hook-service_libvirtd;
+unlink $hook-{log_name} unless -f $hook-{log_name};
 
-# stop libvirtd
-$hook-action('stop');
-$hook-expect_log;
+# stop libvirtd
+$hook-action('stop');
+$hook-expect_log;
 
-diag $hook-{action} libvirtd;
-$hook-service_libvirtd;
+diag $hook-{action} libvirtd;
+$hook-service_libvirtd;
 
-my $hook_data = slurp($hook-{name});
-diag hook script: $hook-{name} '$hook_data';
+my $hook_data = slurp($hook-{name});
+diag hook script: $hook-{name} '$hook_data';
 
-sleep 3;
-diag check if $hook-{name} is invoked;
-ok(-f $hook-{name}, $hook-{name} is invoked);
+sleep 3;
+diag check if $hook-{name} is invoked;
+ok(-f $hook-{name}, $hook-{name} is invoked);
 
-my $actual_log_data = slurp($hook-{log_name});
-diag actual log: $hook-{log_name} '$actual_log_data';
+my $actual_log_data = slurp($hook-{log_name});
+diag actual log: $hook-{log_name} '$actual_log_data';
 
-diag expected log:\n$hook-{expect_log};
+diag expected log:\n$hook-{expect_log};
 
-diag check if the actual log is same with expected log;
-ok($hook-compare_log, $hook-{name} is invoked correctly while $hook-{action} libvirtd);
+diag check if the actual log is same with expected log;
+ok($hook-compare_log, $hook-{name} is invoked correctly while $hook-{action} libvirtd);
 
-diag check if libvirtd is stopped;
-ok(`service libvirtd status` =~ /stopped/, libvirtd is stopped); 
+diag check if libvirtd is stopped;
+ok(`service libvirtd status` =~ 

Re: [libvirt] Initial working Mac OS X libvirt client build

2010-10-22 Thread Justin Clift
On 10/22/2010 05:18 PM, Ruben Kerkhof wrote:
snip
 I thought I'd give it a try, to see how far I get on Leopard (10.5).

Hey Ruben, thanks for the attempt. :)

Would you be ok to try a slightly updated version of the libvirt
formula?  If so, you just need to update the libvirt.rb formula file,
to use this url and md5:

  url
'http://justinclift.fedorapeople.org/libvirt_experimental/libvirt-0.8.4-7.tar.gz'
  md5 '2b8948e336070c94c5278ccd36495709'

It uses a somewhat newer source snapshot for libvirt than the previous
one, plus Mitchell Hashimoto has been hacking away at it to further
increase it's robustness on OSX.

No guarantees, but I think it's worth a shot, just in case. :)

?

Regards and best wishes,

Justin Clift

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


Re: [libvirt] [libvirt-tck 3/3] Add test case for daemon hook testing

2010-10-22 Thread Daniel P. Berrange
On Fri, Oct 22, 2010 at 02:32:20AM -0400, Osier wrote:
 updated, and patch attached.
 

 From 8d2a62528a7820939c4d7c86dd10cbf16ea5d751 Mon Sep 17 00:00:00 2001
 From: Osier Yang jy...@redhat.com
 Date: Fri, 22 Oct 2010 14:40:13 +0800
 Subject: [TCK] Skip daemon hook testing if URI is not qemu:///system or 
 lxc:///
 MIME-Version: 1.0
 Content-Type: text/plain; charset=utf-8
 Content-Transfer-Encoding: 8bit
 
 Skip the case execution if Sys::Virt::TCK connection object is
 not qemu:///system or lxc:///
 ---
  scripts/hooks/051-daemon-hook.t |  178 
 +--
  1 files changed, 96 insertions(+), 82 deletions(-)

ACK, this looks good now

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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 05/11] Remove pointless nwIPAddress struct void *casts

2010-10-22 Thread Daniel P. Berrange
On Thu, Oct 21, 2010 at 02:02:44PM -0600, Eric Blake wrote:
 On 10/21/2010 12:17 PM, Daniel P. Berrange wrote:
 The nwIPAddress was simply a wrapper about virSocketAddr.
 Just use the latter directly, removing all the extra field
 de-references from code  helper APIs for parsing/formatting.
 
 Also remove all the redundant casts from strong types to
 void * and then immediately back to strong types.
 
 * src/conf/nwfilter_conf.h: Remove nwIPAddress
 * src/conf/nwfilter_conf.c, src/nwfilter/nwfilter_ebiptables_driver.c:
Update to use virSocketAddr and remove void * casts.
 ---
   src/conf/nwfilter_conf.c  |  103 
   +
   src/conf/nwfilter_conf.h  |9 +--
   src/nwfilter/nwfilter_ebiptables_driver.c |4 +-
   3 files changed, 34 insertions(+), 82 deletions(-)
 
 diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
 index 40fbf5e..6fd07d4 100644
 --- a/src/conf/nwfilter_conf.c
 +++ b/src/conf/nwfilter_conf.c
 @@ -1325,26 +1325,6 @@ virNWMACAddressParser(const char *input,
   }
 
 
 -static bool
 -virNWIPv4AddressParser(const char *input,
 -   nwIPAddressPtr output)
 -{
 -if (virSocketParseIpv4Addr(input,output-addr) == -1)
 -return 0;
 -return 1;
 
 Good change.  I'd rather see functions return true/false than 0/1 when 
 labeled as bool, so I'm glad to see this go.
 
 -*(uint8_t *)storage_ptr =
 -   (uint8_t)uint_val;
 +item-u.u8 = (uint8_t)uint_val;
 
 Technically, the (uint8_t) cast isn't needed, either, since in C, 
 assignment auto-narrows.  But I don't know if it might trigger a picky 
 compiler warning and thus a -Werror failure, so it's probably okay to 
 leave it in.

Yes, IIRC this one was a case where I needed a cast to avoid a
compiler warning.

 
 
 -typedef struct _nwIPAddress nwIPAddress;
 -typedef nwIPAddress *nwIPAddressPtr;
 -struct _nwIPAddress {
 -virSocketAddr addr;
 -};
 
 I suppose nwfilter originally wrapped this, in case it needs to add 
 another member.  But if that is the case, then we can probably add that 
 member directly in virSocketAddr, as it would probably be useful elsewhere.

I was thinking that nwIPAddress just originally pre-dated the virSocket
struct existing, either way, I think its now redundant.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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 1/2] Add dtrace static probes in libvirtd

2010-10-22 Thread Daniel P. Berrange
On Thu, Oct 21, 2010 at 09:59:55PM +0200, Daniel Veillard wrote:
 On Thu, Oct 21, 2010 at 07:19:32PM +0100, Daniel P. Berrange wrote:
  Adds initial support for dtrace static probes in libvirtd
  daemon, assuming use of systemtap dtrace compat shim on
  Linux. The probes are inserted for network client connect,
  disconnect, TLS handshake states and authentication protocol
  states.
  
  This can be tested by running the xample program and then
  attempting to connect with any libvirt client (virsh,
  virt-manager, etc).
  
   # stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
  
  For unknown reasons, libvirtd must be restarted after
  the stap script is launched, otherwise the probes are
  not enabled. This bug needs to be fixed, probably in
  systemtap itself, to allow probing an existing running
  daemon.
 
   Wasn't that problem found ? I though so ...

Yes it is partially solved, I'll remove this comment since
it isn't really relevant to the changeset.

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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] Convert virNetwork to use virSocketAddr everywhere

2010-10-22 Thread Daniel P. Berrange
On Thu, Oct 21, 2010 at 03:14:25PM -0600, Eric Blake wrote:
 On 10/21/2010 12:21 PM, Daniel P. Berrange wrote:
 Instead of storing the IP address string in virNetwork related
 structs, store the parsed virSocketAddr. This will make it
 easier to add IPv6 support in the future, by letting driver
 code directly check what address family is present
 
 * src/conf/network_conf.c, src/conf/network_conf.h,
src/network/bridge_driver.c: Convert to use virSocketAddr
in virNetwork, instead of char *.
 * src/util/bridge.c, src/util/bridge.h,
src/util/dnsmasq.c, src/util/dnsmasq.h,
src/util/iptables.c, src/util/iptables.h: Convert to
take a virSocketAddr instead of char * for any IP
address parameters
 * src/util/network.h: Add macros to determine if an address
is set, and what address family is set.
 ---
   src/conf/network_conf.c |  121 +--
   src/conf/network_conf.h |   16 ++--
   src/network/bridge_driver.c |  162 +-
   src/util/bridge.c   |   14 +--
   src/util/bridge.h   |5 +-
   src/util/dnsmasq.c  |   17 ++-
   src/util/dnsmasq.h  |4 +-
   src/util/iptables.c |  230 
   +++
   src/util/iptables.h |   18 ++--
   src/util/network.h  |6 +
   10 files changed, 353 insertions(+), 240 deletions(-)
 
 Big change, but mostly good.
 
 @@ -1112,12 +1134,10 @@ static int 
 networkCheckRouteCollision(virNetworkObjPtr network)
   addr_val= mask_val;
 
   if ((net_dest == addr_val)
 -(innetmask.data.inet4.sin_addr.s_addr == mask_val)) {
 +(network-def-netmask.data.inet4.sin_addr.s_addr == 
 mask_val)) {
   networkReportError(VIR_ERR_INTERNAL_ERROR,
 -  _(Network %s/%s is already in use by 
 -interface %s),
 -network-def-ipAddress,
 -network-def-netmask, iface);
 +   _(Network is already in use by interface 
 %s),
 +   iface);
 
 This one loses some information in the error message; is that okay?

It wasn't ideal, but I didn't fancy doing a string conversion 
just to add the address in here.

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Daniel P. Berrange
On Thu, Oct 21, 2010 at 09:52:51PM +0200, Daniel Veillard wrote:
  The SMBIOS data are a standardized set of data structures available
 in the BIOS area of PCs. Those blocks of data describe things like
 BIOS version informations, machine vendor, model and identifiers,
 as well as various parts of the machine capability. On a linux
 machine running dmidecode allows to dump those informations.
 
   Spec available at the DMTF: http://dmtf.org/standards/smbios
 
   From a virtualization POV, it's mostly the first block describing
 the BIOS named type 0 and the second block describing the machine
 named type 1 which are of interest. Those data are usually accessed
 either from the OS or from management application, and being able to
 override the default setings may be needed for such management.
 
   The suggested XML description follows the logical structure of the
 data, one top smbios description, with one or more blocks, each
 containing the entries, the example below gives an idea:
 
   smbios
 table type=0
   entry name=VendorQEmu/KVM/entry
   entry name=Version0.13/entry
 /table
 table type=1
   entry name=ManufacturerFedora/entry
   entry name=ProductVirt-Manager/entry
   entry name=Version0.8.2-3.fc14/entry
   entry name=UUIDc7a5fdbdedaf9455926ad65c16db1809/entry
 /table
   /smbios

I've never really been a fan of the idea of including SMBios
data in the XML because it is an x86 specific concept, which
only works with HVM guests  the type=1/2/3 is rather opaque
in meaning. 

I can't help thinking that we should define a set of general
metadata tags, and then have a internal mapping of those to 
SMBIOS fields, in the same way that the uuid is automatically
mapped to SMBIOS.

eg, define a set of metadata like this:

  metadata
bios-vendorSeaBIOS/bios-vendor
bios-version0.13/bios-version
system-manufacturerFedora/system-manufacturer
system-productKVM/system-product
system-version0.8.2/system-version
system-uuidc7a5fdbdedaf9455926ad65c16db1809/system-uuid
  /metadata

And for smbios just indicate what the source of the data is:

smbios mode=host|emulate/

  host - copy from host SMBIOS
  emulate - generic emulator settings + metadata overrides

This would map better to what VMWare is letting you do, and let us expose
the metadata through other non-SMBIOS data channels

Regards,
Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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] 1/4 SMBIOS XML format extension

2010-10-22 Thread Daniel Veillard
On Thu, Oct 21, 2010 at 03:35:37PM -0600, Eric Blake wrote:
 On 10/21/2010 02:13 PM, Daniel Veillard wrote:
The suggested XML description follows the logical structure of the
 data, one top smbios description, with one or more blocks, each
 containing the entries, the example below gives an idea:
 
smbios
  table type=0
entry name=VendorQEmu/KVM/entry
entry name=Version0.13/entry
  /table
  table type=1
entry name=ManufacturerFedora/entry
entry name=ProductVirt-Manager/entry
entry name=Version0.8.2-3.fc14/entry
entry name=UUIDc7a5fdbdedaf9455926ad65c16db1809/entry
  /table
/smbios
 
 Seems reasonable to me.
 
 +define name=smbios-name
 +data type=string
 +param name='pattern'[a-zA-Z0-9\-_\. ]+/param
^^^
 
 Is that the range of characters from \ to _, or is just the two
 characters - and _?

  just the two characters, \is an escape code to avoid the sequence

 Currently missing is the conf code to save the data back, and
 documentation for the domain extension.
 
 Indeed.

TODO :-)

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] 2/4 Add conf parsing and freeing

2010-10-22 Thread Daniel Veillard
On Thu, Oct 21, 2010 at 03:45:40PM -0600, Eric Blake wrote:
 On 10/21/2010 02:16 PM, Daniel Veillard wrote:
   This lacks the saving of the smbios data, should not be hard really,
 and the parsing is rather trivial, the data structures follow the XML
 format:
 
 Daniel
 
 
 +static void virSmbiosEntriesFree(virSmbiosEntryPtr cur)
 
 Should this function be added to the list of useless_free_options in cfg.mk?
 
 +{
 +virSmbiosEntryPtr next;
 +
 +if (cur == NULL)
 +return;
 
 Redundant, given that
 
 +
 +while (cur != NULL) {
 
 this safely skips a NULL argument.

  ah, true :-) fixed

 @@ -3341,6 +3385,150 @@ error:
   goto cleanup;
   }
 
 +static virSmbiosEntryPtr
 +virSmbiosEntryParseXML(xmlXPathContextPtr ctxt)
 +{
 +char *name, *value;
 +virSmbiosEntryPtr def;
 +
 +name = virXPathString(string(./@name), ctxt);
 +if (name == NULL) {
 +virDomainReportError(VIR_ERR_XML_ERROR, %s,
 +  _(XML element 'entry' requires a 'name' attrbute));
 
 s/attrbute/attribute/

  heh,  good spotting 

[...]
 +if ((type  0) || (type  32)) {
 +virDomainReportError(VIR_ERR_XML_ERROR,
 +  _(XML 'type' attribute on 'table' out of 0..32 range got 
 %ld),
 +type);
 +return(NULL);
 +}
 
 Should you also be checking for duplicate types, or is it okay to do:
 
   smbios
 table type=0
   entry name=VendorQEmu/KVM/entry
 /table
 table type=0
   entry name=Version0.13/entry
 /table
   /smbios

  For type 0 and 1 no they are unique in theory, but other tables
can have duplicates like type 4 since there is one per processor.
I don't think we should go too deep trying to assert semantic at
that level, since anyway the drivers will have a very restricted
view of the whole thing, and will only pick some of the information
they can process. Still I wanted the format to be as generic as
possible,

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] 3/4 Add SMBIOS QEmu driver

2010-10-22 Thread Daniel Veillard
On Thu, Oct 21, 2010 at 03:58:50PM -0600, Eric Blake wrote:
 On 10/21/2010 02:23 PM, Daniel Veillard wrote:
 The main trouble here is that the QEmu command uses names which are
 similar to the official names for the entries used by the DMTF, but
 that mean we cant base on name equality. I was tempted to use
 
 s/cant/can't/
 
 something like strcasestr to go fishing on the names but since we
 never used this in libvirt yet, and I'm not sure it's available in
 gnulib, I did the patch using strstr, assuming entries provided by the
 
 Gnulib provides strcasestr() as LGPLv2+ (but beware - it only does
 what you want in unibyte locales); it also provides the c-strcasestr
 module (which is probably exactly what you want!), but it is
 currently LGPLv3+, although I can request on the gnulib list to have
 it relaxed if you'd like.
 
 users would contain the word in lower case usually except maybe for the
 first character. The matching glue is certainly perfectible.
 
 c_strcasestr() would certainly make it easier.
 
 Or, is this something where STRCASEEQ() would be good enough?  That
 is, do we expect a user to always provide the full DMTF name BIOS
 Version, or is the substring matching important because we want to
 all the user the shortcut of Version?

  Well coming from a QEmu usage, people will likely just expect
version as that's what is used on the command line. I think matching
by subset is less likely to get users wondering why this doesn't work
as expected. Since we don't do exact name checking on input, I think
it's better to be flexible.

 Also decided that if we can't associate an entry with an existing
 QEmu SMBIOS command we would ignore it. On the ther hand if a block
 
 s/ther/other/
 
 other than type 0 or 1 is used in the XML definition we would emit
 a warning, but still not fail.
 
 +/*
 + * QEmu accepts only a limited set of System informations, and
 + * use command line arguments shortcuts from the DMTF real names
 + * so go fishing for those
 + */
 +cur = def-entries;
 +while (cur != NULL) {
 +/* 0:Vendor */
 +if ((def-type == 0)  (strstr(cur-name, endor)))
 +virBufferVSprintf(buf, ,vendor=\%s\, cur-value);
 +/* 0:BIOS Version */
 +else if ((def-type == 0)  (strstr(cur-name, ersion)))
 +virBufferVSprintf(buf, ,version=\%s\, cur-value);
 +/* 0:BIOS Release Date */
 +else if ((def-type == 0)  (strstr(cur-name, ate)))
 +virBufferVSprintf(buf, ,date=\%s\, cur-value);
 +/* 0:System BIOS Major Release and 0:System BIOS Minor Release */
 +else if ((def-type == 0)  (strstr(cur-name, elease)))
 +virBufferVSprintf(buf, ,date=\%s\, cur-value);
 
 If the user provides both Date and Major Release names, does
 qemu complain about the doubled-up date= option?

  No actually that's different entries :-)
But qemu will complain if release is not formated as %d.%d, it takes as
a string what is 2 byte values in the SMBIOS tables. I didn't tried to
validate that at the driver level, rather let qemu report the error
I checked it shows up back up to virt-manager if something is not
formatted to its taste like the UUID

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] 0/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Daniel Veillard
On Fri, Oct 22, 2010 at 09:28:48AM +0100, Daniel P. Berrange wrote:
 On Thu, Oct 21, 2010 at 09:52:51PM +0200, Daniel Veillard wrote:
   The SMBIOS data are a standardized set of data structures available
  in the BIOS area of PCs. Those blocks of data describe things like
  BIOS version informations, machine vendor, model and identifiers,
  as well as various parts of the machine capability. On a linux
  machine running dmidecode allows to dump those informations.
  
Spec available at the DMTF: http://dmtf.org/standards/smbios
  
From a virtualization POV, it's mostly the first block describing
  the BIOS named type 0 and the second block describing the machine
  named type 1 which are of interest. Those data are usually accessed
  either from the OS or from management application, and being able to
  override the default setings may be needed for such management.
  
The suggested XML description follows the logical structure of the
  data, one top smbios description, with one or more blocks, each
  containing the entries, the example below gives an idea:
  
smbios
  table type=0
entry name=VendorQEmu/KVM/entry
entry name=Version0.13/entry
  /table
  table type=1
entry name=ManufacturerFedora/entry
entry name=ProductVirt-Manager/entry
entry name=Version0.8.2-3.fc14/entry
entry name=UUIDc7a5fdbdedaf9455926ad65c16db1809/entry
  /table
/smbios
 
 I've never really been a fan of the idea of including SMBios
 data in the XML because it is an x86 specific concept, which
 only works with HVM guests  the type=1/2/3 is rather opaque
 in meaning. 

  The semantic is well defined it's information available
from the BIOS, c.f. the DMTF spec. The we know how to get it
from a guest, and it's not dependant on the virtualization
layer used, it may or may not support it, but at least
the expectation are clear.

 I can't help thinking that we should define a set of general
 metadata tags, and then have a internal mapping of those to 
 SMBIOS fields, in the same way that the uuid is automatically
 mapped to SMBIOS.
 
 eg, define a set of metadata like this:
 
   metadata
 bios-vendorSeaBIOS/bios-vendor
 bios-version0.13/bios-version
 system-manufacturerFedora/system-manufacturer
 system-productKVM/system-product
 system-version0.8.2/system-version
 system-uuidc7a5fdbdedaf9455926ad65c16db1809/system-uuid
   /metadata

  Okay, but what is the semantic of system-product for example ?
Does that mean SMBIOS type 1 Product Name or something else left
to the appreciation of the driver or of the user ?

 And for smbios just indicate what the source of the data is:
 
 smbios mode=host|emulate/
 
   host - copy from host SMBIOS
   emulate - generic emulator settings + metadata overrides
 
 This would map better to what VMWare is letting you do, and let us expose
 the metadata through other non-SMBIOS data channels

  Your suggestion is far more flexible, but that comes with the
trouble that we have to define those metadata semantic, or we don't
define their semantic, and it may get messy in the long term.

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] 0/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Daniel P. Berrange
On Fri, Oct 22, 2010 at 11:23:45AM +0200, Daniel Veillard wrote:
 On Fri, Oct 22, 2010 at 09:28:48AM +0100, Daniel P. Berrange wrote:
  On Thu, Oct 21, 2010 at 09:52:51PM +0200, Daniel Veillard wrote:
The SMBIOS data are a standardized set of data structures available
   in the BIOS area of PCs. Those blocks of data describe things like
   BIOS version informations, machine vendor, model and identifiers,
   as well as various parts of the machine capability. On a linux
   machine running dmidecode allows to dump those informations.
   
 Spec available at the DMTF: http://dmtf.org/standards/smbios
   
 From a virtualization POV, it's mostly the first block describing
   the BIOS named type 0 and the second block describing the machine
   named type 1 which are of interest. Those data are usually accessed
   either from the OS or from management application, and being able to
   override the default setings may be needed for such management.
   
 The suggested XML description follows the logical structure of the
   data, one top smbios description, with one or more blocks, each
   containing the entries, the example below gives an idea:
   
 smbios
   table type=0
 entry name=VendorQEmu/KVM/entry
 entry name=Version0.13/entry
   /table
   table type=1
 entry name=ManufacturerFedora/entry
 entry name=ProductVirt-Manager/entry
 entry name=Version0.8.2-3.fc14/entry
 entry name=UUIDc7a5fdbdedaf9455926ad65c16db1809/entry
   /table
 /smbios
  
  I've never really been a fan of the idea of including SMBios
  data in the XML because it is an x86 specific concept, which
  only works with HVM guests  the type=1/2/3 is rather opaque
  in meaning. 
 
   The semantic is well defined it's information available
 from the BIOS, c.f. the DMTF spec. The we know how to get it
 from a guest, and it's not dependant on the virtualization
 layer used, it may or may not support it, but at least
 the expectation are clear.
 
  I can't help thinking that we should define a set of general
  metadata tags, and then have a internal mapping of those to 
  SMBIOS fields, in the same way that the uuid is automatically
  mapped to SMBIOS.
  
  eg, define a set of metadata like this:
  
metadata
  bios-vendorSeaBIOS/bios-vendor
  bios-version0.13/bios-version
  system-manufacturerFedora/system-manufacturer
  system-productKVM/system-product
  system-version0.8.2/system-version
  system-uuidc7a5fdbdedaf9455926ad65c16db1809/system-uuid
/metadata
 
   Okay, but what is the semantic of system-product for example ?
 Does that mean SMBIOS type 1 Product Name or something else left
 to the appreciation of the driver or of the user ?

It is simply a NULL terminated string for the system product name.


  And for smbios just indicate what the source of the data is:
  
  smbios mode=host|emulate/
  
host - copy from host SMBIOS
emulate - generic emulator settings + metadata overrides
  
  This would map better to what VMWare is letting you do, and let us expose
  the metadata through other non-SMBIOS data channels
 
   Your suggestion is far more flexible, but that comes with the
 trouble that we have to define those metadata semantic, or we don't
 define their semantic, and it may get messy in the long term.

It is worth the extra work, because it gives us a representation 
of data which is hypervisor-agnostic, which is the primary goal
of our XML format.  If I want to specify a 'product name' for
the LXC containers, I don't want to have to use different XML
for that, compared to setting 'product name' for KVM.

With the exception of the UUID field, these are all simply NULL
terminated free form strings, so defining a mapping to SMBIOS
fields is pretty straightforward.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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


[libvirt] [PATCH v2 1/2] support compressed crashdump of guests

2010-10-22 Thread KAMEZAWA Hiroyuki
Thank you for advices for v1. This version adss dump_image_format config
for qemu.conf. 1/2 adds dump_image_format, 2/2 adds the check for availability 
of
compression program for save_image_format and dump_image_format.
==
Add dump_image_format[] to qemu.conf and support compressed dump
at virsh dump. coredump compression is important for saving disk space
in an environment where multiple guest run.
(In general, disk space for dump is specially allocated and will be
 a dead space in the system. It's used only at emergency. So, it's better
 to have both of save_image_format and dump_image_format. save is done
 in scheduled manner with enough calculated disk space for it.)

This code reuses some of save_image_format[] and supports the same format
with virsh save.

---
 src/qemu/qemu.conf |4 
 src/qemu/qemu_conf.c   |   11 +++
 src/qemu/qemu_conf.h   |1 +
 src/qemu/qemu_driver.c |   30 +-
 4 files changed, 41 insertions(+), 5 deletions(-)

Index: libvirt-0.8.4/src/qemu/qemu_conf.c
===
--- libvirt-0.8.4.orig/src/qemu/qemu_conf.c
+++ libvirt-0.8.4/src/qemu/qemu_conf.c
@@ -324,6 +324,17 @@ int qemudLoadDriverConfig(struct qemud_d
 }
 }
 
+p = virConfGetValue (conf, dump_image_format);
+CHECK_TYPE (dump_image_format, VIR_CONF_STRING);
+if (p  p-str) {
+   VIR_FREE(driver-dumpImageFormat);
+   if (!(driver-dumpImageFormat = strdup(p-str))) {
+   virReportOOMError();
+   virConfFree(conf);
+   return -1;
+   }
+}
+
  p = virConfGetValue (conf, hugetlbfs_mount);
  CHECK_TYPE (hugetlbfs_mount, VIR_CONF_STRING);
  if (p  p-str) {
Index: libvirt-0.8.4/src/qemu/qemu_conf.h
===
--- libvirt-0.8.4.orig/src/qemu/qemu_conf.h
+++ libvirt-0.8.4/src/qemu/qemu_conf.h
@@ -159,6 +159,7 @@ struct qemud_driver {
 virSecurityDriverPtr securitySecondaryDriver;
 
 char *saveImageFormat;
+char *dumpImageFormat;
 
 pciDeviceList *activePciHostdevs;
 
Index: libvirt-0.8.4/src/qemu/qemu.conf
===
--- libvirt-0.8.4.orig/src/qemu/qemu.conf
+++ libvirt-0.8.4/src/qemu/qemu.conf
@@ -144,7 +144,11 @@
 # saving a domain in order to save disk space; the list above is in descending
 # order by performance and ascending order by compression ratio.
 #
+# save_image_format is used when you use 'virsh save' at scheduled saving.
+# dump_image_format is used when you use 'virsh dump' at emergency crashdump.
+#
 # save_image_format = raw
+# dump_image_format = raw
 
 # If provided by the host and a hugetlbfs mount point is configured,
 # a guest may request huge page backing.  When this mount point is
Index: libvirt-0.8.4/src/qemu/qemu_driver.c
===
--- libvirt-0.8.4.orig/src/qemu/qemu_driver.c
+++ libvirt-0.8.4/src/qemu/qemu_driver.c
@@ -5716,11 +5716,15 @@ static int qemudDomainCoreDump(virDomain
 int resume = 0, paused = 0;
 int ret = -1, fd = -1;
 virDomainEventPtr event = NULL;
-const char *args[] = {
-cat,
-NULL,
-};
+int compress;
 qemuDomainObjPrivatePtr priv;
+/*
+ * We reuse save flag for dump here. Then, we can support the same
+ * format in save and dump.
+ */
+compress = QEMUD_SAVE_FORMAT_RAW;
+if (driver-dumpImageFormat)
+   compress = qemudSaveCompressionTypeFromString(driver-dumpImageFormat);
 
 qemuDriverLock(driver);
 vm = virDomainFindByUUID(driver-domains, dom-uuid);
@@ -5787,9 +5791,25 @@ static int qemudDomainCoreDump(virDomain
 }
 
 qemuDomainObjEnterMonitorWithDriver(driver, vm);
-ret = qemuMonitorMigrateToFile(priv-mon,
+if (compress == QEMUD_SAVE_FORMAT_RAW) {
+   const char *args[] = {
+   cat,
+   NULL,
+   };
+   ret = qemuMonitorMigrateToFile(priv-mon,
QEMU_MONITOR_MIGRATE_BACKGROUND,
args, path, 0);
+} else {
+   const char *prog = qemudSaveCompressionTypeToString(compress);
+   const char *args[] = {
+   prog,
+   -c,
+   NULL,
+   };
+   ret = qemuMonitorMigrateToFile(priv-mon,
+   QEMU_MONITOR_MIGRATE_BACKGROUND,
+   args, path, 0);
+}
 qemuDomainObjExitMonitorWithDriver(driver, vm);
 if (ret  0)
 goto endjob;

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


[libvirt] [PATCH v2 2/2] check compression program is available at config

2010-10-22 Thread KAMEZAWA Hiroyuki

At compression, external programs are used but it is not checked whether
the program is available or not.
Check it at parsing qemu.conf and find problems in early stage.

---
 src/qemu/qemu_conf.c |   46 +++---
 1 file changed, 39 insertions(+), 7 deletions(-)

Index: libvirt-0.8.4/src/qemu/qemu_conf.c
===
--- libvirt-0.8.4.orig/src/qemu/qemu_conf.c
+++ libvirt-0.8.4/src/qemu/qemu_conf.c
@@ -316,22 +316,54 @@ int qemudLoadDriverConfig(struct qemud_d
 p = virConfGetValue (conf, save_image_format);
 CHECK_TYPE (save_image_format, VIR_CONF_STRING);
 if (p  p-str) {
-VIR_FREE(driver-saveImageFormat);
-if (!(driver-saveImageFormat = strdup(p-str))) {
-virReportOOMError();
-virConfFree(conf);
-return -1;
-}
+   int find = 1;
+   if (strcmp(p-str, raw)) {
+   char *c;
+   c = virFindFileInPath(p-str);
+   if (!c)
+   find = 0;
+   else
+ VIR_FREE(c);
+   }
+   VIR_FREE(driver-saveImageFormat);
+   if (find) {
+if (!(driver-saveImageFormat = strdup(p-str))) {
+   virReportOOMError();
+   virConfFree(conf);
+   return -1;
+   }
+   } else {
+   qemuReportError(VIR_ERR_INTERNAL_ERROR,
+save_image_format cannot find program %s, p-str);
+   virConfFree(conf);
+   return -1;
+   }
 }
 
 p = virConfGetValue (conf, dump_image_format);
 CHECK_TYPE (dump_image_format, VIR_CONF_STRING);
 if (p  p-str) {
+   int find = 1;
+   if (strcmp(p-str, raw)) {
+char *c;
+   c = virFindFileInPath(p-str);
+   if (!c)
+   find = 0;
+   else
+   VIR_FREE(c);
+   }
VIR_FREE(driver-dumpImageFormat);
-   if (!(driver-dumpImageFormat = strdup(p-str))) {
+   if (find) {
+   if (!(driver-dumpImageFormat = strdup(p-str))) {
virReportOOMError();
virConfFree(conf);
return -1;
+   }
+   } else {
+   qemuReportError(VIR_ERR_INTERNAL_ERROR,
+dump_image_format cannot find program %s, p-str);
+   virConfFree(conf);
+   return -1;
}
 }
 

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


[libvirt] [TCK] Add test case for domain hook testing.

2010-10-22 Thread Osier Yang
The test case will be valid only when the Sys::Virt::TCK connection
object is qemu:///system or lxc:///, because currently libvirt
only support hooks for QEMU and LXC domain.

Also update scripts/hooks/051-daemon-hook.t, replace $hook-foo
with $hook-foo().
---
 lib/Sys/Virt/TCK/Hooks.pm   |8 +-
 scripts/hooks/051-daemon-hook.t |   36 
 scripts/hooks/052-domain-hook.t |  183 +++
 3 files changed, 205 insertions(+), 22 deletions(-)
 create mode 100644 scripts/hooks/052-domain-hook.t

diff --git a/lib/Sys/Virt/TCK/Hooks.pm b/lib/Sys/Virt/TCK/Hooks.pm
index 7d20fa4..eb5e8f9 100644
--- a/lib/Sys/Virt/TCK/Hooks.pm
+++ b/lib/Sys/Virt/TCK/Hooks.pm
@@ -35,7 +35,7 @@ sub new {
 conf_dir = $params{conf_dir} ? $params{conf_dir} : $HOOKS_CONF_DIR,
 name = $params{conf_dir}.'/'.$params{type},
 expect_result = $params{expect_result} ? $params{expect_result} : 0,
-log_name = $params{log_name} ? $params{log_name} : 
/tmp/$self-{type}.log,
+log_name = $params{log_name} ? $params{log_name} : 
/tmp/$params{type}.log,
 libvirtd_status = undef,
 domain_name = undef,
 domain_state = undef,
@@ -144,13 +144,13 @@ sub expect_log {
 }
 }
 } elsif ($self-{type} eq 'qemu' or $self-{type} eq 'lxc') {
-if ($domain_state eq 'running') {
-if ($action eq 'stop') {
+if ($domain_state eq Sys::Virt::Domain::STATE_RUNNING) {
+if ($action eq 'destroy') {
$expect_log = $hook $domain_name stopped end -;
 } else {
 die hooks testing doesn't support $action running domain;
 }
-} elsif ($domain_state eq 'shut off') {
+} elsif ($domain_state eq Sys::Virt::Domain::STATE_SHUTOFF) {
 if ($action eq 'start') {
$expect_log = $hook $domain_name start begin -;
 } else {
diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t
index c378bd0..5218d24 100644
--- a/scripts/hooks/051-daemon-hook.t
+++ b/scripts/hooks/051-daemon-hook.t
@@ -50,24 +50,24 @@ SKIP: {
   conf_dir = '/etc/libvirt/hooks',
   log_name = '/tmp/daemon.log');
 
-$hook-libvirtd_status;
+$hook-libvirtd_status();
 BAIL_OUT libvirtd is not running, Exit... 
 if ($hook-{libvirtd_status} eq 'stopped');
 
-eval { $hook-prepare; };
+eval { $hook-prepare(); };
 BAIL_OUT failed to setup hooks testing ENV: $@ if $@;
 
-diag restart libvirtd for hooks scripts taking effect;
-$hook-action('restart');
-$hook-service_libvirtd;
+diag reload libvirtd for hooks scripts taking effect;
+$hook-action('reload');
+$hook-service_libvirtd();
 unlink $hook-{log_name} unless -f $hook-{log_name};
 
 # stop libvirtd
 $hook-action('stop');
-$hook-expect_log;
+$hook-expect_log();
 
 diag $hook-{action} libvirtd;
-$hook-service_libvirtd;
+$hook-service_libvirtd();
 
 my $hook_data = slurp($hook-{name});
 diag hook script: $hook-{name} '$hook_data';
@@ -82,17 +82,17 @@ SKIP: {
 diag expected log:\n$hook-{expect_log};
 
 diag check if the actual log is same with expected log;
-ok($hook-compare_log, $hook-{name} is invoked correctly while 
$hook-{action} libvirtd);
+ok($hook-compare_log(), $hook-{name} is invoked correctly while 
$hook-{action} libvirtd);
 
 diag check if libvirtd is stopped;
 ok(`service libvirtd status` =~ /stopped/, libvirtd is stopped); 
 
 # start libvirtd
 $hook-action('start');
-$hook-expect_log;
+$hook-expect_log();
 
 diag $hook-{action} libvirtd;
-$hook-service_libvirtd;
+$hook-service_libvirtd();
 
 $hook_data = slurp($hook-{name});
 diag hook script: $hook-{name} '$hook_data';
@@ -107,17 +107,17 @@ SKIP: {
 diag expected log: \n$hook-{expect_log};
 
 diag check if the actual log is same with expected log;
-ok($hook-compare_log, $hook-{name} is invoked correctly while 
$hook-{action} libvirtd);
+ok($hook-compare_log(), $hook-{name} is invoked correctly while 
$hook-{action} libvirtd);
 
 diag check if libvirtd is still running;
 ok(`service libvirtd status` =~ /running/, libvirtd is running); 
 
 # restart libvirtd
 $hook-action('restart');
-$hook-expect_log;
+$hook-expect_log();
 
 diag $hook-{action} libvirtd;
-$hook-service_libvirtd;
+$hook-service_libvirtd();
 
 $hook_data = slurp($hook-{name});
 diag hook script: $hook-{name} '$hook_data';
@@ -132,17 +132,17 @@ SKIP: {
 diag expected log: \n$hook-{expect_log};
 
 diag check if the actual log is same with expected log;
-ok($hook-compare_log, $hook-{name} is invoked correctly while 
$hook-{action} libvirtd);
+ok($hook-compare_log(), $hook-{name} is invoked correctly while 
$hook-{action} libvirtd);
 
 diag check if libvirtd 

Re: [libvirt] Initial working Mac OS X libvirt client build

2010-10-22 Thread Ruben Kerkhof
On Fri, Oct 22, 2010 at 08:54, Justin Clift jcl...@redhat.com wrote:
 On 10/22/2010 05:18 PM, Ruben Kerkhof wrote:
 snip
 I thought I'd give it a try, to see how far I get on Leopard (10.5).

 Hey Ruben, thanks for the attempt. :)

 Would you be ok to try a slightly updated version of the libvirt
 formula?  If so, you just need to update the libvirt.rb formula file,
 to use this url and md5:

  url
 'http://justinclift.fedorapeople.org/libvirt_experimental/libvirt-0.8.4-7.tar.gz'
  md5 '2b8948e336070c94c5278ccd36495709'

 It uses a somewhat newer source snapshot for libvirt than the previous
 one, plus Mitchell Hashimoto has been hacking away at it to further
 increase it's robustness on OSX.

 No guarantees, but I think it's worth a shot, just in case. :)

 ?

Ah, great, I'll give it a shot when I get home in a few hours!

Thanks,

Ruben

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

Re: [libvirt] [PATCH 00/11] Misc fixes and changes related to virSocket APIs

2010-10-22 Thread Daniel P. Berrange
On Thu, Oct 21, 2010 at 07:17:14PM +0100, Daniel P. Berrange wrote:
 In working on the DTrace patches I needed to be able to format
 a struct sockaddr into a string easily. The virSocketFormatAddr
 API was close to what I needed, but couldn't handle including
 the port number, nor UNIX domain sockets.
 
 This patch series addresses that limitation. Along the way it
 fixes miscellaneous bugs with the virSocket APis, adds a test
 suite, removes  bans all use of inet_* functions and replaces
 the addrToString methods used in SASL code and simplifies 
 some nwfilter code using virSocket.

Pushed all these with the suggested changes, and one fix to the
nwfilter code identified by the TCK tests

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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 2/2] Include socket address in client probe data

2010-10-22 Thread Daniel P. Berrange
On Thu, Oct 21, 2010 at 10:05:42PM +0200, Daniel Veillard wrote:
 On Thu, Oct 21, 2010 at 07:19:33PM +0100, Daniel P. Berrange wrote:
  It is useful to know where the client is connecting from,
  so include the socket address in probe data.
  
  * daemon/libvirtd.h: Use virSocketAddr for storing client
address and keep printable address handy for logging
 
   Ah ... that's the reason of the big socket revamp :-)
 
  * daemon/libvirtd.c: Include socket address in client
connect/disconnect probes
  * daemon/probes.d: Add socket address to probes
  * examples/systemtap/client.stp: Print socket address
  * src/util/network.h: Add sockaddr_un to virSocketAddr union
  ---
   configure.ac  |2 +-
   daemon/libvirtd.c |   82 
  +---
   daemon/libvirtd.h |   15 +--
   daemon/libvirtd.stp   |2 +
   daemon/probes.d   |2 +-
   daemon/remote.c   |2 +-
   examples/systemtap/client.stp |4 +-
   src/util/network.h|6 +++
   8 files changed, 66 insertions(+), 49 deletions(-)
 [...]
   static int qemudDispatchServer(struct qemud_server *server, struct 
  qemud_socket *sock) {
   int fd;
  -struct sockaddr_storage addr;
  -socklen_t addrlen = (socklen_t) (sizeof addr);
  +virSocketAddr addr;
  +char *addrstr = NULL;
 
   Patch looks fine, there is actually quite a bit of cleanup too
 
 ACK,

Ok, pushed this and the other dtrace patch

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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 v2] qemu: call drive_unplug in DetachPciDiskDevice

2010-10-22 Thread Daniel P. Berrange
On Thu, Oct 21, 2010 at 09:56:48PM -0500, Ryan Harper wrote:
 Currently libvirt doesn't confirm whether the guest has responded to the
 disk removal request.  In some cases this can leave the guest with
 continued access to the device while the mgmt layer believes that it has
 been removed.  With a recent qemu monitor command[1] we can
 deterministically revoke a guests access to the disk (on the QEMU side)
 to ensure no futher access is permitted.
 
 This patch adds support for the drive_unplug() command and introduces it
 in the disk removal paths.  There is some discussion to be had about how
 to handle the case where the guest is running in a QEMU without this
 command (and the fact that we currently don't have a way of detecting
 what monitor commands are available).
 
 Changes since v1:
  - return  0 when command isn't present,  0 on command failure
  - detect when drive_unplug command isn't present and log error
instead of failing entire command
 
 Signed-off-by: Ryan Harper ry...@us.ibm.com
 +int qemuMonitorJSONDriveUnplug(qemuMonitorPtr mon,
 + const char *drivestr)
 +{

 +
 +if (ret == 0) {
 +/* See if drive_unplug isn't supported */
 +if (qemuMonitorJSONHasError(reply, CommandNotFound)) {
 +qemuReportError(VIR_ERR_OPERATION_FAILED, %s,
 +_(unplugging disk is not supported.  
 +  This may leak data if disk is reassigned));
 +ret = 1;
 +goto cleanup;
 +}
 +ret = qemuMonitorJSONCheckError(cmd, reply);
 +}

  
 +/* Attempts to unplug a drive.  Returns 1 if unsupported, 0 if ok, and -1 on
 + * other failure */
 +int qemuMonitorTextDriveUnplug(qemuMonitorPtr mon,
 + const char *drivestr)
 +{
 +


 +if (strstr(reply, unknown command:)) {
 +qemuReportError(VIR_ERR_OPERATION_FAILED, %s,
 +_(unplugging disk is not supported.  
 +  This may leak data if disk is reassigned));
 +ret = 1;
 +goto cleanup;

For these 2 non-fatal errors, qemuReportError shouldn't be used. Instead
just directly call VIR_WARN or VIR_ERROR  logging functions

Regards,
Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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] docs: removed old changelog file, as it is no longer relevant

2010-10-22 Thread Daniel P. Berrange
On Fri, Oct 22, 2010 at 05:10:39PM +1100, Justin Clift wrote:
 We instead point to the live git log URL for the few links still
 needing to point to something.
 ---
  docs/ChangeLog.awk   |   49 -
  docs/ChangeLog.xsl   |   37 -
  docs/Makefile.am |   13 +
  docs/news.html.in|2 +-
  docs/sitemap.html.in |2 +-
  5 files changed, 3 insertions(+), 100 deletions(-)
  delete mode 100755 docs/ChangeLog.awk
  delete mode 100644 docs/ChangeLog.xsl

ACK

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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] docs: added a table of contents to the new c sharp bindings page

2010-10-22 Thread Daniel P. Berrange
On Fri, Oct 22, 2010 at 05:30:53PM +1100, Justin Clift wrote:
 ---
  docs/csharp.html.in |   20 +++-
  1 files changed, 11 insertions(+), 9 deletions(-)
 
 diff --git a/docs/csharp.html.in b/docs/csharp.html.in
 index 3e15176..a32fbd2 100644
 --- a/docs/csharp.html.in
 +++ b/docs/csharp.html.in

ACK

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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] [TCK] Add test case for domain hook testing.

2010-10-22 Thread Daniel P. Berrange
On Fri, Oct 22, 2010 at 06:05:46AM +0800, Osier Yang wrote:
 The test case will be valid only when the Sys::Virt::TCK connection
 object is qemu:///system or lxc:///, because currently libvirt
 only support hooks for QEMU and LXC domain.
 
 Also update scripts/hooks/051-daemon-hook.t, replace $hook-foo
 with $hook-foo().
 ---
  lib/Sys/Virt/TCK/Hooks.pm   |8 +-
  scripts/hooks/051-daemon-hook.t |   36 
  scripts/hooks/052-domain-hook.t |  183 
 +++
  3 files changed, 205 insertions(+), 22 deletions(-)
  create mode 100644 scripts/hooks/052-domain-hook.t

ACK

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Daniel P. Berrange
On Fri, Oct 22, 2010 at 11:23:45AM +0200, Daniel Veillard wrote:
 On Fri, Oct 22, 2010 at 09:28:48AM +0100, Daniel P. Berrange wrote:
  On Thu, Oct 21, 2010 at 09:52:51PM +0200, Daniel Veillard wrote:
The SMBIOS data are a standardized set of data structures available
   in the BIOS area of PCs. Those blocks of data describe things like
   BIOS version informations, machine vendor, model and identifiers,
   as well as various parts of the machine capability. On a linux
   machine running dmidecode allows to dump those informations.
   
 Spec available at the DMTF: http://dmtf.org/standards/smbios
   
 From a virtualization POV, it's mostly the first block describing
   the BIOS named type 0 and the second block describing the machine
   named type 1 which are of interest. Those data are usually accessed
   either from the OS or from management application, and being able to
   override the default setings may be needed for such management.
   
 The suggested XML description follows the logical structure of the
   data, one top smbios description, with one or more blocks, each
   containing the entries, the example below gives an idea:
   
 smbios
   table type=0
 entry name=VendorQEmu/KVM/entry
 entry name=Version0.13/entry
   /table
   table type=1
 entry name=ManufacturerFedora/entry
 entry name=ProductVirt-Manager/entry
 entry name=Version0.8.2-3.fc14/entry
 entry name=UUIDc7a5fdbdedaf9455926ad65c16db1809/entry
   /table
 /smbios
  
  I've never really been a fan of the idea of including SMBios
  data in the XML because it is an x86 specific concept, which
  only works with HVM guests  the type=1/2/3 is rather opaque
  in meaning. 
 
   The semantic is well defined it's information available
 from the BIOS, c.f. the DMTF spec. The we know how to get it
 from a guest, and it's not dependant on the virtualization
 layer used, it may or may not support it, but at least
 the expectation are clear.
 
  I can't help thinking that we should define a set of general
  metadata tags, and then have a internal mapping of those to 
  SMBIOS fields, in the same way that the uuid is automatically
  mapped to SMBIOS.
  
  eg, define a set of metadata like this:
  
metadata
  bios-vendorSeaBIOS/bios-vendor
  bios-version0.13/bios-version
  system-manufacturerFedora/system-manufacturer
  system-productKVM/system-product
  system-version0.8.2/system-version
  system-uuidc7a5fdbdedaf9455926ad65c16db1809/system-uuid
/metadata
 
   Okay, but what is the semantic of system-product for example ?
 Does that mean SMBIOS type 1 Product Name or something else left
 to the appreciation of the driver or of the user ?
 
  And for smbios just indicate what the source of the data is:
  
  smbios mode=host|emulate/
  
host - copy from host SMBIOS
emulate - generic emulator settings + metadata overrides
  
  This would map better to what VMWare is letting you do, and let us expose
  the metadata through other non-SMBIOS data channels
 
   Your suggestion is far more flexible, but that comes with the
 trouble that we have to define those metadata semantic, or we don't
 define their semantic, and it may get messy in the long term.

How about a different variation on the theme.

   sysinfo type=smbios
 section name=bios
   entry name=VendorQEmu/KVM/entry
   entry name=Version0.13/entry
 /section
 section namee=platform
   entry name=ManufacturerFedora/entry
   entry name=ProductVirt-Manager/entry
   entry name=Version0.8.2-3.fc14/entry
   entry name=UUIDc7a5fdbdedaf9455926ad65c16db1809/entry
 /section
   /sysinfo

Where the valid section types, and entry names are defined according to
the sysinfo type. So with type='smbios', the valid section/entries names
would be 100% as per the SMBIOS spec.  If we add different sysinfo
types, we can define appropriate sections/entries as per the spec for
those types.  This keeps the strictly defined semantics, while avoiding
a schema that is tied to smbios

Regards,
Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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


[libvirt] [PATCH] vbox: Fix compile errors due to the virSocketAddr series

2010-10-22 Thread Matthias Bolte
---
 src/vbox/vbox_tmpl.c |  116 +++---
 1 files changed, 100 insertions(+), 16 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 5a859a4..ddbca97 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -626,6 +626,45 @@ static PRUnichar *PRUnicharFromInt(int n) {
 
 #endif /* !(VBOX_API_VERSION == 2002) */
 
+static PRUnichar *
+vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr)
+{
+char *utf8 = NULL;
+PRUnichar *utf16 = NULL;
+
+utf8 = virSocketFormatAddr(addr);
+
+if (utf8 == NULL) {
+return NULL;
+}
+
+VBOX_UTF8_TO_UTF16(utf8, utf16);
+VIR_FREE(utf8);
+
+return utf16;
+}
+
+static int
+vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16,
+ virSocketAddrPtr addr)
+{
+int result = -1;
+char *utf8 = NULL;
+
+VBOX_UTF16_TO_UTF8(utf16, utf8);
+
+if (virSocketParseAddr(utf8, addr, AF_UNSPEC)  0) {
+goto cleanup;
+}
+
+result = 0;
+
+cleanup:
+VBOX_UTF8_FREE(utf8);
+
+return result;
+}
+
 static virCapsPtr vboxCapsInit(void) {
 struct utsname utsname;
 virCapsPtr caps;
@@ -7073,8 +7112,8 @@ static virNetworkPtr 
vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
  * with contigious address space from start to end
  */
 if ((def-nranges = 1) 
-(def-ranges[0].start) 
-(def-ranges[0].end)) {
+VIR_SOCKET_HAS_ADDR(def-ranges[0].start) 
+VIR_SOCKET_HAS_ADDR(def-ranges[0].end)) {
 IDHCPServer *dhcpServer = NULL;
 
 data-vboxObj-vtbl-FindDHCPServerByNetworkName(data-vboxObj,
@@ -7094,11 +7133,21 @@ static virNetworkPtr 
vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
 PRUnichar *toIPAddressUtf16   = NULL;
 PRUnichar *trunkTypeUtf16 = NULL;
 
+ipAddressUtf16 = vboxSocketFormatAddrUtf16(data, 
def-ipAddress);
+networkMaskUtf16 = vboxSocketFormatAddrUtf16(data, 
def-netmask);
+fromIPAddressUtf16 = vboxSocketFormatAddrUtf16(data, 
def-ranges[0].start);
+toIPAddressUtf16 = vboxSocketFormatAddrUtf16(data, 
def-ranges[0].end);
+
+if (ipAddressUtf16 == NULL || networkMaskUtf16 == NULL ||
+fromIPAddressUtf16 == NULL || toIPAddressUtf16 == NULL) {
+VBOX_UTF16_FREE(ipAddressUtf16);
+VBOX_UTF16_FREE(networkMaskUtf16);
+VBOX_UTF16_FREE(fromIPAddressUtf16);
+VBOX_UTF16_FREE(toIPAddressUtf16);
+VBOX_RELEASE(dhcpServer);
+goto cleanup;
+}
 
-VBOX_UTF8_TO_UTF16(def-ipAddress, ipAddressUtf16);
-VBOX_UTF8_TO_UTF16(def-netmask, networkMaskUtf16);
-VBOX_UTF8_TO_UTF16(def-ranges[0].start, fromIPAddressUtf16);
-VBOX_UTF8_TO_UTF16(def-ranges[0].end, toIPAddressUtf16);
 VBOX_UTF8_TO_UTF16(netflt, trunkTypeUtf16);
 
 dhcpServer-vtbl-SetEnabled(dhcpServer, PR_TRUE);
@@ -7125,12 +7174,18 @@ static virNetworkPtr 
vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
 }
 
 if ((def-nhosts = 1) 
-(def-hosts[0].ip)) {
+VIR_SOCKET_HAS_ADDR(def-hosts[0].ip)) {
 PRUnichar *ipAddressUtf16   = NULL;
 PRUnichar *networkMaskUtf16 = NULL;
 
-VBOX_UTF8_TO_UTF16(def-netmask, networkMaskUtf16);
-VBOX_UTF8_TO_UTF16(def-hosts[0].ip, ipAddressUtf16);
+ipAddressUtf16 = vboxSocketFormatAddrUtf16(data, 
def-hosts[0].ip);
+networkMaskUtf16 = vboxSocketFormatAddrUtf16(data, def-netmask);
+
+if (ipAddressUtf16 == NULL || networkMaskUtf16 == NULL) {
+VBOX_UTF16_FREE(ipAddressUtf16);
+VBOX_UTF16_FREE(networkMaskUtf16);
+goto cleanup;
+}
 
 /* Current drawback is that since EnableStaticIpConfig() sets
  * IP and enables the interface so even if the dhcpserver is not
@@ -7393,6 +7448,7 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, 
int flags ATTRIBUTE_UNUSE
 PRUnichar *networkMaskUtf16   = NULL;
 PRUnichar *fromIPAddressUtf16 = NULL;
 PRUnichar *toIPAddressUtf16   = NULL;
+bool errorOccurred = false;
 
 dhcpServer-vtbl-GetIPAddress(dhcpServer, 
ipAddressUtf16);
 dhcpServer-vtbl-GetNetworkMask(dhcpServer, 
networkMaskUtf16);
@@ -7401,15 +7457,25 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, 
int flags ATTRIBUTE_UNUSE
 /* Currently virtualbox supports only one dhcp server 
per network
  * with contigious address space from start to end

Re: [libvirt] [PATCH] vbox: Fix compile errors due to the virSocketAddr series

2010-10-22 Thread Daniel P. Berrange
On Fri, Oct 22, 2010 at 02:23:15PM +0200, Matthias Bolte wrote:
 ---
  src/vbox/vbox_tmpl.c |  116 
 +++---
  1 files changed, 100 insertions(+), 16 deletions(-)
 
 diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
 index 5a859a4..ddbca97 100644
 --- a/src/vbox/vbox_tmpl.c
 +++ b/src/vbox/vbox_tmpl.c
 @@ -626,6 +626,45 @@ static PRUnichar *PRUnicharFromInt(int n) {
  
  #endif /* !(VBOX_API_VERSION == 2002) */
  
 +static PRUnichar *
 +vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr)
 +{
 +char *utf8 = NULL;
 +PRUnichar *utf16 = NULL;
 +
 +utf8 = virSocketFormatAddr(addr);
 +
 +if (utf8 == NULL) {
 +return NULL;
 +}
 +
 +VBOX_UTF8_TO_UTF16(utf8, utf16);
 +VIR_FREE(utf8);
 +
 +return utf16;
 +}
 +
 +static int
 +vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16,
 + virSocketAddrPtr addr)
 +{
 +int result = -1;
 +char *utf8 = NULL;
 +
 +VBOX_UTF16_TO_UTF8(utf16, utf8);
 +
 +if (virSocketParseAddr(utf8, addr, AF_UNSPEC)  0) {
 +goto cleanup;
 +}
 +
 +result = 0;
 +
 +cleanup:
 +VBOX_UTF8_FREE(utf8);
 +
 +return result;
 +}
 +
  static virCapsPtr vboxCapsInit(void) {
  struct utsname utsname;
  virCapsPtr caps;
 @@ -7073,8 +7112,8 @@ static virNetworkPtr 
 vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
   * with contigious address space from start to end
   */
  if ((def-nranges = 1) 
 -(def-ranges[0].start) 
 -(def-ranges[0].end)) {
 +VIR_SOCKET_HAS_ADDR(def-ranges[0].start) 
 +VIR_SOCKET_HAS_ADDR(def-ranges[0].end)) {
  IDHCPServer *dhcpServer = NULL;
  
  data-vboxObj-vtbl-FindDHCPServerByNetworkName(data-vboxObj,
 @@ -7094,11 +7133,21 @@ static virNetworkPtr 
 vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
  PRUnichar *toIPAddressUtf16   = NULL;
  PRUnichar *trunkTypeUtf16 = NULL;
  
 +ipAddressUtf16 = vboxSocketFormatAddrUtf16(data, 
 def-ipAddress);
 +networkMaskUtf16 = vboxSocketFormatAddrUtf16(data, 
 def-netmask);
 +fromIPAddressUtf16 = vboxSocketFormatAddrUtf16(data, 
 def-ranges[0].start);
 +toIPAddressUtf16 = vboxSocketFormatAddrUtf16(data, 
 def-ranges[0].end);
 +
 +if (ipAddressUtf16 == NULL || networkMaskUtf16 == NULL ||
 +fromIPAddressUtf16 == NULL || toIPAddressUtf16 == NULL) {
 +VBOX_UTF16_FREE(ipAddressUtf16);
 +VBOX_UTF16_FREE(networkMaskUtf16);
 +VBOX_UTF16_FREE(fromIPAddressUtf16);
 +VBOX_UTF16_FREE(toIPAddressUtf16);
 +VBOX_RELEASE(dhcpServer);
 +goto cleanup;
 +}
  
 -VBOX_UTF8_TO_UTF16(def-ipAddress, ipAddressUtf16);
 -VBOX_UTF8_TO_UTF16(def-netmask, networkMaskUtf16);
 -VBOX_UTF8_TO_UTF16(def-ranges[0].start, 
 fromIPAddressUtf16);
 -VBOX_UTF8_TO_UTF16(def-ranges[0].end, toIPAddressUtf16);
  VBOX_UTF8_TO_UTF16(netflt, trunkTypeUtf16);
  
  dhcpServer-vtbl-SetEnabled(dhcpServer, PR_TRUE);
 @@ -7125,12 +7174,18 @@ static virNetworkPtr 
 vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
  }
  
  if ((def-nhosts = 1) 
 -(def-hosts[0].ip)) {
 +VIR_SOCKET_HAS_ADDR(def-hosts[0].ip)) {
  PRUnichar *ipAddressUtf16   = NULL;
  PRUnichar *networkMaskUtf16 = NULL;
  
 -VBOX_UTF8_TO_UTF16(def-netmask, networkMaskUtf16);
 -VBOX_UTF8_TO_UTF16(def-hosts[0].ip, ipAddressUtf16);
 +ipAddressUtf16 = vboxSocketFormatAddrUtf16(data, 
 def-hosts[0].ip);
 +networkMaskUtf16 = vboxSocketFormatAddrUtf16(data, 
 def-netmask);
 +
 +if (ipAddressUtf16 == NULL || networkMaskUtf16 == NULL) {
 +VBOX_UTF16_FREE(ipAddressUtf16);
 +VBOX_UTF16_FREE(networkMaskUtf16);
 +goto cleanup;
 +}
  
  /* Current drawback is that since EnableStaticIpConfig() sets
   * IP and enables the interface so even if the dhcpserver is not
 @@ -7393,6 +7448,7 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, 
 int flags ATTRIBUTE_UNUSE
  PRUnichar *networkMaskUtf16   = NULL;
  PRUnichar *fromIPAddressUtf16 = NULL;
  PRUnichar *toIPAddressUtf16   = NULL;
 +bool errorOccurred = false;
  
  dhcpServer-vtbl-GetIPAddress(dhcpServer, 
 ipAddressUtf16);
  dhcpServer-vtbl-GetNetworkMask(dhcpServer, 
 networkMaskUtf16);
 @@ -7401,15 +7457,25 @@ static char *vboxNetworkDumpXML(virNetworkPtr 
 network, int 

Re: [libvirt] [PATCH] 0/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Daniel Veillard
On Fri, Oct 22, 2010 at 01:16:16PM +0100, Daniel P. Berrange wrote:
 On Fri, Oct 22, 2010 at 11:23:45AM +0200, Daniel Veillard wrote:
  On Fri, Oct 22, 2010 at 09:28:48AM +0100, Daniel P. Berrange wrote:
[...]
   I can't help thinking that we should define a set of general
   metadata tags, and then have a internal mapping of those to 
   SMBIOS fields, in the same way that the uuid is automatically
   mapped to SMBIOS.
   
   eg, define a set of metadata like this:
   
 metadata
   bios-vendorSeaBIOS/bios-vendor
   bios-version0.13/bios-version
   system-manufacturerFedora/system-manufacturer
   system-productKVM/system-product
   system-version0.8.2/system-version
   system-uuidc7a5fdbdedaf9455926ad65c16db1809/system-uuid
 /metadata
  
Okay, but what is the semantic of system-product for example ?
  Does that mean SMBIOS type 1 Product Name or something else left
  to the appreciation of the driver or of the user ?
  
   And for smbios just indicate what the source of the data is:
   
   smbios mode=host|emulate/
   
 host - copy from host SMBIOS
 emulate - generic emulator settings + metadata overrides
   
   This would map better to what VMWare is letting you do, and let us expose
   the metadata through other non-SMBIOS data channels
  
Your suggestion is far more flexible, but that comes with the
  trouble that we have to define those metadata semantic, or we don't
  define their semantic, and it may get messy in the long term.
 
 How about a different variation on the theme.
 
sysinfo type=smbios
  section name=bios
entry name=VendorQEmu/KVM/entry
entry name=Version0.13/entry
  /section
  section namee=platform
entry name=ManufacturerFedora/entry
entry name=ProductVirt-Manager/entry
entry name=Version0.8.2-3.fc14/entry
entry name=UUIDc7a5fdbdedaf9455926ad65c16db1809/entry
  /section
/sysinfo
 
 Where the valid section types, and entry names are defined according to
 the sysinfo type. So with type='smbios', the valid section/entries names
 would be 100% as per the SMBIOS spec.  If we add different sysinfo
 types, we can define appropriate sections/entries as per the spec for
 those types.  This keeps the strictly defined semantics, while avoiding
 a schema that is tied to smbios

  Okay, agreed, hierarchy may look a bit more complex as a result
but it allows to preserve both viewpoint.

  Also for the smbios element, should we make the mode a tristate:
- emulate: do not try to override the default set by the hypervisor
  (if any)
- host: get the values from the host (libvirtd may have to parse
  the dmidecode output as I don't see how to implement this for QEmu
  otherwise), the only useful mode for ESX driver
- sysinfo: get the values from sysinfo section and pass them to
  the hypervisor.
Also I'm wondering if we should treat smbios as a device or keep it
as a top level element along cpu etc.

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] esx: Add documentation about certificates and connection problems

2010-10-22 Thread Matthias Bolte
---
 docs/drvesx.html.in |  103 +-
 docs/remote.html.in |8 +++-
 2 files changed, 107 insertions(+), 4 deletions(-)

diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index dfc91bb..a0f87c1 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -74,7 +74,7 @@ vpx://example-vcenter.com/dc1/cluster1/example-esx.com
 /pre
 
 
-h4Extra parameters/h4
+h4a name=extraparamsExtra parameters/h4
 p
 Extra parameters can be added to a URI as part of the query string
 (the part following code?/code). A single parameter is formed by a
@@ -117,7 +117,7 @@ vpx://example-vcenter.com/dc1/cluster1/example-esx.com
 In order to perform a migration the driver needs to know the
 VMware vCenter for the ESX server. If set to code*/code,
 the driver connects to the vCenter known to the ESX server.
-This paramater in useful when connecting to an ESX server only.
+This parameter in useful when connecting to an ESX server only.
 /td
 /tr
 tr
@@ -129,7 +129,9 @@ vpx://example-vcenter.com/dc1/cluster1/example-esx.com
 /td
 td
 If set to 1, this disables libcurl client checks of the 
server's
-SSL certificate. The default value it 0.
+SSL certificate. The default value it 0. See the
+a href=#certificatesCertificates for HTTPS/a section for
+details.
 /td
 /tr
 tr
@@ -187,6 +189,101 @@ vpx://example-vcenter.com/dc1/cluster1/example-esx.com
 /p
 
 
+h3a name=certificatesCertificates for HTTPS/a/h3
+p
+By default the ESX driver uses HTTPS to communicate with an ESX server.
+Proper HTTPS communication requires correctly configured SSL
+certificates. This certificates are different from the ones libvirt
+uses for a href=remote.htmlsecure communication over TLS/a to a
+libvirtd one a remote server.
+/p
+p
+By default the driver tries to verify the server's SSL certificate
+using the CA certificate pool installed on your client computer. With
+an out-of-the-box installed ESX server this won't work, because a newly
+installed ESX server uses auto-generated self-signed certificates.
+Those are singed by a CA certificate that is typically not known to 
your
+client computer and libvirt will report an error like this one:
+/p
+pre
+error: internal error curl_easy_perform() returned an error: Peer certificate 
cannot be authenticated with known CA certificates (60)
+/pre
+p
+Where are two ways to solve this problem:
+/p
+ul
+li
+Use the codeno_verify=1/code a href=#extraparamsextra 
parameter/a
+to disable server certificate verification.
+/li
+li
+Generate new SSL certificates signed by a CA known to your client
+computer and replace the original ones on your ESX server. See the
+section iReplace a Default Certificate with a CA-Signed 
Certificate/i
+in the a 
href=http://www.vmware.com/pdf/vsphere4/r40/vsp_40_esx_server_config.pdf;ESX 
Configuration Guide/a
+/li
+/ul
+
+
+h3a name=connproblemsConnection problems/a/h3
+p
+There are also other causes for connection problems than the
+a href=#certificatesHTTPS certificate/a related ones.
+/p
+ul
+li
+As stated before the ESX driver doesn't need the
+a href=remote.htmlremote transport mechanism/a
+provided by the remote driver and libvirtd, nor does the ESX driver
+support it. Therefore, using an URI including a transport in the
+scheme won't work. Only a href=#uriformatURIs as described/a
+are supported by the ESX driver. Here's a collection of possible
+error messages:
+pre
+$ virsh -c esx+tcp://example.com/
+error: unable to connect to libvirtd at 'example.com': Connection refused
+/pre
+pre
+$ virsh -c esx+tls://example.com/
+error: Cannot access CA certificate '/etc/pki/CA/cacert.pem': No such file or 
directory
+/pre
+pre
+$ virsh -c esx+ssh://example.com/
+error: cannot recv data: ssh: connect to host example.com port 22: Connection 
refused
+/pre
+pre
+$ virsh -c esx+ssh://example.com/
+error: cannot recv data: Resource temporarily unavailable
+/pre
+/li
+li
+span class=sinceSince 0.7.0/span libvirt contains the ESX
+driver. Earlier versions of libvirt will report a misleading error
+about missing certificates when you try to connect to an ESX 
server.
+pre
+$ virsh -c esx://example.com/
+error: Cannot access CA certificate '/etc/pki/CA/cacert.pem': No such file or 
directory
+/pre
+p
+Don't let this error message confuse you. 

Re: [libvirt] [PATCH] 0/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Daniel Veillard
On Fri, Oct 22, 2010 at 01:09:30AM +0200, Matthias Bolte wrote:
 2010/10/21 Daniel Veillard veill...@redhat.com:

 Okay, I looked at what can be done for ESX.
 
 Looking at the SMBIOS data from _inside_ a ESX guest using dmidecode I
 can get this
 
  smbios
table type=0
  entry name=VendorPhoenix Technologies LTD/entry
  entry name=Version6.00/entry
/table
table type=1
  entry name=ManufacturerVMware Inc./entry
  entry name=ProductVMware Virtual Platform/entry
  entry name=VersionNone/entry
  entry name=SerialVMware-[domain/uuid]/entry
  entry name=UUID[domain/uuid]/entry
/table
  /smbios
 
 The UUID and Serial are basically the UUID of the guest.
 
 Putting smbios.reflecthost = true (defaults to false) in the VMX
 file results in
 
  smbios
table type=0
  entry name=VendorPhoenix Technologies LTD/entry
  entry name=Version6.00/entry
/table
table type=1
  entry name=ManufacturerLENOVO/entry
  entry name=Product7673J3G/entry
  entry name=VersionNone/entry
  entry name=SerialVMware-[domain/uuid]/entry
  entry name=UUID[domain/uuid]/entry
/table
  /smbios
 
 So Manufacturer and Product from the type 1 table are now inherited
 from the SMBIOS of the physical host.
 
 But this is all from inside the guest. From _outside_ the guest over
 the vSphere API I can only access LENOVO and 7673J3G, the data of
 the physical host.
 
 To make it even worse, it seems that none of this can be edited in any
 way (apart from the Serial/UUID because this is the domain UUID).
 
 Therefore, I think there is no possible useful implementation for this
 in the ESX driver, besides outputting static unchangeable data.

  Okay, I looked up for VirtualBox, and apparently there is some support
for editing some of the BIOS and system entries too based on this post
  http://forums.virtualbox.org/viewtopic.php?t=3224

but that looks like ad-hoc, the idea of trying to push a complete
SMBios implementation probably doesn't make that much sense, and a
simplified indirect version like Dan suggested might be sufficient
At least we should try to expose reflecthost = true at the libvirt
level, for ESX (and QEmu/VBox once we can parse the dmidecode output).

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] esx: Add documentation about certificates and connection problems

2010-10-22 Thread Daniel Veillard
On Fri, Oct 22, 2010 at 03:04:43PM +0200, Matthias Bolte wrote:
 ---
  docs/drvesx.html.in |  103 +-
  docs/remote.html.in |8 +++-
  2 files changed, 107 insertions(+), 4 deletions(-)
 
 diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
 index dfc91bb..a0f87c1 100644

  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] 0/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Daniel Veillard
On Fri, Oct 22, 2010 at 04:00:31PM +0200, Matthias Bolte wrote:
 2010/10/22 Daniel Veillard veill...@redhat.com:
   Okay, I looked up for VirtualBox, and apparently there is some support
  for editing some of the BIOS and system entries too based on this post
   http://forums.virtualbox.org/viewtopic.php?t=3224
 
 It seems that one of the posters suggests to hack the VirtualBox
 codebase. It doesn't look like the XPCOM API exposes this.

  Yeah, I misunderstood though it was a config file :-(

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 v3] qemu: call drive_unplug in DetachPciDiskDevice

2010-10-22 Thread Ryan Harper
Currently libvirt doesn't confirm whether the guest has responded to the
disk removal request.  In some cases this can leave the guest with
continued access to the device while the mgmt layer believes that it has
been removed.  With a recent qemu monitor command[1] we can
deterministically revoke a guests access to the disk (on the QEMU side)
to ensure no futher access is permitted.

This patch adds support for the drive_unplug() command and introduces it
in the disk removal paths.  There is some discussion to be had about how
to handle the case where the guest is running in a QEMU without this
command (and the fact that we currently don't have a way of detecting
what monitor commands are available).

Changes since v2:
 - use VIR_ERROR to report when unplug command not found
Changes since v1:
 - return  0 when command isn't present,  0 on command failure
 - detect when drive_unplug command isn't present and log error
   instead of failing entire command

Signed-off-by: Ryan Harper ry...@us.ibm.com


diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index abd8e9d..615427a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8646,6 +8646,7 @@ static int qemudDomainDetachPciDiskDevice(struct 
qemud_driver *driver,
 virDomainDiskDefPtr detach = NULL;
 qemuDomainObjPrivatePtr priv = vm-privateData;
 virCgroupPtr cgroup = NULL;
+char drivestr[PATH_MAX];
 
 i = qemudFindDisk(vm-def, dev-data.disk-dst);
 
@@ -8673,13 +8674,36 @@ static int qemudDomainDetachPciDiskDevice(struct 
qemud_driver *driver,
 goto cleanup;
 }
 
+/* build the actual drive id string as the disk-info.alias doesn't
+ * contain the QEMU_DRIVE_HOST_PREFIX that is passed to qemu */
+if ((ret = snprintf(drivestr, sizeof(drivestr), %s%s,
+   QEMU_DRIVE_HOST_PREFIX,
+   detach-info.alias))
+ 0 || ret = sizeof(drivestr)) {
+virReportOOMError();
+goto cleanup;
+}
+
 qemuDomainObjEnterMonitorWithDriver(driver, vm);
 if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
+ret = qemuMonitorDriveUnplug(priv-mon, drivestr);
+DEBUG(DriveUnplug ret=%d, ret);
+/* ret  0 indicates unplug isn't supported, issue will be logged */
+if (ret  0) {
+qemuDomainObjExitMonitor(vm);
+goto cleanup;
+}
 if (qemuMonitorDelDevice(priv-mon, detach-info.alias)  0) {
 qemuDomainObjExitMonitor(vm);
 goto cleanup;
 }
 } else {
+ret = qemuMonitorDriveUnplug(priv-mon, drivestr);
+/* ret  0 indicates unplug isn't supported, issue will be logged */
+if (ret  0) {
+qemuDomainObjExitMonitor(vm);
+goto cleanup;
+}
 if (qemuMonitorRemovePCIDevice(priv-mon,
detach-info.addr.pci)  0) {
 qemuDomainObjExitMonitor(vm);
@@ -8723,6 +8747,7 @@ static int qemudDomainDetachSCSIDiskDevice(struct 
qemud_driver *driver,
 virDomainDiskDefPtr detach = NULL;
 qemuDomainObjPrivatePtr priv = vm-privateData;
 virCgroupPtr cgroup = NULL;
+char drivestr[PATH_MAX];
 
 i = qemudFindDisk(vm-def, dev-data.disk-dst);
 
@@ -8749,7 +8774,22 @@ static int qemudDomainDetachSCSIDiskDevice(struct 
qemud_driver *driver,
 }
 }
 
+/* build the actual drive id string as the disk-info.alias doesn't
+ * contain the QEMU_DRIVE_HOST_PREFIX that is passed to qemu */
+if ((ret = snprintf(drivestr, sizeof(drivestr), %s%s,
+   QEMU_DRIVE_HOST_PREFIX,
+   detach-info.alias))
+ 0 || ret = sizeof(drivestr)) {
+virReportOOMError();
+goto cleanup;
+}
+
 qemuDomainObjEnterMonitorWithDriver(driver, vm);
+/* ret  0 indicates unplug isn't supported, issue will be logged */
+if (qemuMonitorDriveUnplug(priv-mon, drivestr)  0) {
+qemuDomainObjExitMonitor(vm);
+goto cleanup;
+}
 if (qemuMonitorDelDevice(priv-mon, detach-info.alias)  0) {
 qemuDomainObjExitMonitor(vm);
 goto cleanup;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2366fdb..285381d 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1781,6 +1781,25 @@ int qemuMonitorGetAllPCIAddresses(qemuMonitorPtr mon,
 return ret;
 }
 
+int qemuMonitorDriveUnplug(qemuMonitorPtr mon,
+ const char *drivestr)
+{
+DEBUG(mon=%p drivestr=%s, mon, drivestr);
+int ret;
+
+if (!mon) {
+qemuReportError(VIR_ERR_INVALID_ARG, %s,
+_(monitor must not be NULL));
+return -1;
+}
+
+if (mon-json)
+ret = qemuMonitorJSONDriveUnplug(mon, drivestr);
+else
+ret = qemuMonitorTextDriveUnplug(mon, drivestr);
+return ret;
+}
+
 int qemuMonitorDelDevice(qemuMonitorPtr mon,
  const char *devalias)
 {
diff --git a/src/qemu/qemu_monitor.h 

Re: [libvirt] [PATCH] docs: removed old changelog file, as it is no longer relevant

2010-10-22 Thread Justin Clift
On 10/22/2010 10:11 PM, Daniel P. Berrange wrote:
 On Fri, Oct 22, 2010 at 05:10:39PM +1100, Justin Clift wrote:
 We instead point to the live git log URL for the few links still
 needing to point to something.
snip
 
 ACK

Thanks Daniel, pushed.

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


Re: [libvirt] [PATCH] docs: added a table of contents to the new c sharp bindings page

2010-10-22 Thread Justin Clift
On 10/22/2010 10:11 PM, Daniel P. Berrange wrote:
 On Fri, Oct 22, 2010 at 05:30:53PM +1100, Justin Clift wrote:
 ---
  docs/csharp.html.in |   20 +++-
  1 files changed, 11 insertions(+), 9 deletions(-)

 diff --git a/docs/csharp.html.in b/docs/csharp.html.in
 index 3e15176..a32fbd2 100644
 --- a/docs/csharp.html.in
 +++ b/docs/csharp.html.in
 
 ACK

Pushed as well, thanks. :)

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


Re: [libvirt] Initial working Mac OS X libvirt client build

2010-10-22 Thread Mitchell Hashimoto
On Thu, Oct 21, 2010 at 11:18 PM, Ruben Kerkhof ru...@rubenkerkhof.com wrote:

 I thought I'd give it a try, to see how far I get on Leopard (10.5).


From what I know following this list, I don't think anyone has ever
tried to compile for Leopard (10.5) and has focussed exclusively on
Snow Leopard (10.6), so there very well may be errors during
compilation/linking.

I'll wait for you to try the new formula but if that errors as well
then I may have to spin up  a leopard VM to play around see if I can
figure out what is going on there.

Mitchell

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


Re: [libvirt] [PATCH] Convert virNetwork to use virSocketAddr everywhere

2010-10-22 Thread Eric Blake

On 10/21/2010 03:14 PM, Eric Blake wrote:

+++ b/src/util/dnsmasq.c
@@ -76,23 +76,28 @@ hostsfileFree(dnsmasqHostsfile *hostsfile)
static int
hostsfileAdd(dnsmasqHostsfile *hostsfile,
const char *mac,
- const char *ip,
+ virSocketAddr *ip,
const char *name)
{
+ char *ipstr;
if (VIR_REALLOC_N(hostsfile-hosts, hostsfile-nhosts + 1) 0)
goto alloc_error;


...

@@ -100,7 +105,7 @@ hostsfileAdd(dnsmasqHostsfile *hostsfile,

alloc_error:
virReportOOMError();
-
+ VIR_FREE(ipstr);


Ouch - freeing uninitialized memory.


Oops - you didn't fix that.  So I'm pushing this under the obvious rule:

diff --git i/src/util/dnsmasq.c w/src/util/dnsmasq.c
index 2cb25bf..3c0506c 100644
--- i/src/util/dnsmasq.c
+++ w/src/util/dnsmasq.c
@@ -79,7 +79,7 @@ hostsfileAdd(dnsmasqHostsfile *hostsfile,
  virSocketAddr *ip,
  const char *name)
 {
-char *ipstr;
+char *ipstr = NULL;
 if (VIR_REALLOC_N(hostsfile-hosts, hostsfile-nhosts + 1)  0)
 goto alloc_error;


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] bye to close(), welcome to VIR_(FORCE_)CLOSE()

2010-10-22 Thread Eric Blake

On 10/22/2010 05:19 AM, Stefan Berger wrote:

Using automated replacement with sed and editing I have now replaced all
occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
course. Some replacements were straight forward, others I needed to pay
attention. I hope I payed attention in all the right places... Please
have a look. This should have at least solved one more double-close
error.

Signed-off-by: Stefan Bergerstef...@us.ibm.com


Pre-review comment:
One more thing to do, which is adding something like this to cfg.mk:

sc_avoid_close:
@prohibit='\close *\('\
in_vc_files='\.c$$'\
halt='use VIR_(FORCE_)CLOSE instead of close'  \
  $(_sc_search_regexp)

along with adding .x-sc_avoid_close with contents of src/util/file.c to 
exempt the one valid use of close().


Would you mind testing 'make syntax-check' after folding that in, and 
addressing any other fallout that it detects, while I proceed with the 
rest of my review?


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


[libvirt] [PATCH] [TCK] Forgot to copy *.fwall.dat file

2010-10-22 Thread Stefan Berger

 Move to the format Eric suggested and copy the missing .fwall.dat file.

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

diff --git a/Build.PL b/Build.PL
index 2a4de43..97b4140 100644
--- a/Build.PL
+++ b/Build.PL
@@ -29,7 +29,7 @@ sub process_pkgdata_files {
 my $name = $File::Find::name;
 if (-d) {
 $tck_dirs{$name} = [];
-} elsif (-f  (/\.t$/ || /\.sh$/ || /\.fwall$/ || /\.xml$/)) {
+} elsif (-f  /\.(t|sh|fwall|xml|fwall\.dat)$/) {
 push @{$tck_dirs{$dir}}, $name;
 }
 };

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


[libvirt] [PATCH] tests: Silence qemuxml2argv test

2010-10-22 Thread Jiri Denemark
---
 tests/qemuxml2argvtest.c |  240 +-
 1 files changed, 132 insertions(+), 108 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 551d6c4..4eb3cc6 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -4,6 +4,7 @@
 #include stdlib.h
 #include unistd.h
 #include string.h
+#include stdbool.h
 
 #include sys/types.h
 #include fcntl.h
@@ -26,7 +27,8 @@ static struct qemud_driver driver;
 static int testCompareXMLToArgvFiles(const char *xml,
  const char *cmd,
  unsigned long long extraFlags,
- const char *migrateFrom) {
+ const char *migrateFrom,
+ bool expectError) {
 char argvData[MAX_FILE];
 char *expectargv = (argvData[0]);
 char *actualargv = NULL;
@@ -38,6 +40,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 virDomainDefPtr vmdef = NULL;
 virDomainChrDef monitor_chr;
 virConnectPtr conn;
+char *log = NULL;
 
 if (!(conn = virGetConnect()))
 goto fail;
@@ -80,12 +83,28 @@ static int testCompareXMLToArgvFiles(const char *xml,
 }
 
 
+free(virtTestLogContentAndReset());
+
 if (qemudBuildCommandLine(conn, driver,
   vmdef, monitor_chr, 0, flags,
   argv, qenv,
   NULL, NULL, migrateFrom, NULL)  0)
 goto fail;
 
+if ((log = virtTestLogContentAndReset()) == NULL)
+goto fail;
+
+if (!!strstr(log, : error :) != expectError) {
+if (virTestGetDebug())
+fprintf(stderr, \n%s, log);
+goto fail;
+}
+
+if (expectError) {
+/* need to suppress the errors */
+virResetLastError();
+}
+
 len = 1; /* for trailing newline */
 tmp = qenv;
 while (*tmp) {
@@ -125,6 +144,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 ret = 0;
 
  fail:
+free(log);
 free(actualargv);
 if (argv) {
 tmp = argv;
@@ -152,6 +172,7 @@ struct testInfo {
 const char *name;
 unsigned long long extraFlags;
 const char *migrateFrom;
+bool expectError;
 };
 
 static int testCompareXMLToArgvHelper(const void *data) {
@@ -162,7 +183,8 @@ static int testCompareXMLToArgvHelper(const void *data) {
  abs_srcdir, info-name);
 snprintf(args, PATH_MAX, %s/qemuxml2argvdata/qemuxml2argv-%s.args,
  abs_srcdir, info-name);
-return testCompareXMLToArgvFiles(xml, args, info-extraFlags, 
info-migrateFrom);
+return testCompareXMLToArgvFiles(xml, args, info-extraFlags,
+ info-migrateFrom, info-expectError);
 }
 
 
@@ -193,16 +215,18 @@ mymain(int argc, char **argv)
 if ((driver.hugepage_path = strdup(/dev/hugepages/libvirt/qemu)) == NULL)
 return EXIT_FAILURE;
 
-# define DO_TEST_FULL(name, extraFlags, migrateFrom) \
+# define DO_TEST_FULL(name, extraFlags, migrateFrom, expectError)   \
 do {\
-const struct testInfo info = { name, extraFlags, migrateFrom }; \
+const struct testInfo info = {  \
+name, extraFlags, migrateFrom, expectError  \
+};  \
 if (virtTestRun(QEMU XML-2-ARGV  name,\
 1, testCompareXMLToArgvHelper, info)  0)  \
 ret = -1;   \
 } while (0)
 
-# define DO_TEST(name, extraFlags)   \
-DO_TEST_FULL(name, extraFlags, NULL)
+# define DO_TEST(name, extraFlags, expectError) \
+DO_TEST_FULL(name, extraFlags, NULL, expectError)
 
 /* Unset or set all envvars here that are copied in qemudBuildCommandLine
  * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
@@ -217,175 +241,175 @@ mymain(int argc, char **argv)
 unsetenv(QEMU_AUDIO_DRV);
 unsetenv(SDL_AUDIODRIVER);
 
-DO_TEST(minimal, QEMUD_CMD_FLAG_NAME);
-DO_TEST(machine-aliases1, 0);
-DO_TEST(machine-aliases2, 0);
-DO_TEST(boot-cdrom, 0);
-DO_TEST(boot-network, 0);
-DO_TEST(boot-floppy, 0);
-DO_TEST(boot-multi, QEMUD_CMD_FLAG_BOOT_MENU);
-DO_TEST(boot-menu-disable, QEMUD_CMD_FLAG_BOOT_MENU);
-DO_TEST(bootloader, QEMUD_CMD_FLAG_DOMID);
-DO_TEST(clock-utc, 0);
-DO_TEST(clock-localtime, 0);
+DO_TEST(minimal, QEMUD_CMD_FLAG_NAME, false);
+DO_TEST(machine-aliases1, 0, false);
+DO_TEST(machine-aliases2, 0, true);
+DO_TEST(boot-cdrom, 0, false);
+DO_TEST(boot-network, 0, false);
+DO_TEST(boot-floppy, 0, false);
+DO_TEST(boot-multi, QEMUD_CMD_FLAG_BOOT_MENU, 

Re: [libvirt] [PATCH] 0/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Matthias Bolte
2010/10/22 Daniel Veillard veill...@redhat.com:
 On Fri, Oct 22, 2010 at 04:00:31PM +0200, Matthias Bolte wrote:
 2010/10/22 Daniel Veillard veill...@redhat.com:
   Okay, I looked up for VirtualBox, and apparently there is some support
  for editing some of the BIOS and system entries too based on this post
   http://forums.virtualbox.org/viewtopic.php?t=3224

 It seems that one of the posters suggests to hack the VirtualBox
 codebase. It doesn't look like the XPCOM API exposes this.

  Yeah, I misunderstood though it was a config file :-(

 Daniel


I just came a cross this forum post from 2008:

http://forums.virtualbox.org/viewtopic.php?f=2t=7731

I tested it and it works. This allows to override the defaults.

Matthias

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

Re: [libvirt] [PATCH] 0/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Matthias Bolte
2010/10/22 Matthias Bolte matthias.bo...@googlemail.com:
 2010/10/22 Daniel Veillard veill...@redhat.com:
 On Fri, Oct 22, 2010 at 04:00:31PM +0200, Matthias Bolte wrote:
 2010/10/22 Daniel Veillard veill...@redhat.com:
   Okay, I looked up for VirtualBox, and apparently there is some support
  for editing some of the BIOS and system entries too based on this post
   http://forums.virtualbox.org/viewtopic.php?t=3224

 It seems that one of the posters suggests to hack the VirtualBox
 codebase. It doesn't look like the XPCOM API exposes this.

  Yeah, I misunderstood though it was a config file :-(

 Daniel


 I just came a cross this forum post from 2008:

 http://forums.virtualbox.org/viewtopic.php?f=2t=7731

 I tested it and it works. This allows to override the defaults.

 Matthias


The [sg]etextradata functions are also available in the XPCOM API.

Matthias

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

Re: [libvirt] [PATCH] [TCK] Forgot to copy *.fwall.dat file

2010-10-22 Thread Eric Blake

On 10/22/2010 11:00 AM, Stefan Berger wrote:

Move to the format Eric suggested and copy the missing .fwall.dat file.

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

diff --git a/Build.PL b/Build.PL
index 2a4de43..97b4140 100644
--- a/Build.PL
+++ b/Build.PL
@@ -29,7 +29,7 @@ sub process_pkgdata_files {
my $name = $File::Find::name;
if (-d) {
$tck_dirs{$name} = [];
- } elsif (-f  (/\.t$/ || /\.sh$/ || /\.fwall$/ || /\.xml$/)) {
+ } elsif (-f  /\.(t|sh|fwall|xml|fwall\.dat)$/) {


...|fwall(\.dat)?|...
seems more compact still :)

ACK, whether or not you choose to further compress things.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] tests: Silence qemuxml2argv test

2010-10-22 Thread Eric Blake

On 10/22/2010 11:02 AM, Jiri Denemark wrote:

---
  tests/qemuxml2argvtest.c |  240 +-
  1 files changed, 132 insertions(+), 108 deletions(-)


ACK, and thanks for getting to this.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] tests: Silence qemuxml2argv test

2010-10-22 Thread Stefan Berger
libvir-list-boun...@redhat.com wrote on 10/22/2010 01:02:15 PM:

 
 ---
  tests/qemuxml2argvtest.c |  240 
 +-
  1 files changed, 132 insertions(+), 108 deletions(-)
 
 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
 index 551d6c4..4eb3cc6 100644
 --- a/tests/qemuxml2argvtest.c
 +++ b/tests/qemuxml2argvtest.c
 @@ -4,6 +4,7 @@
  #include stdlib.h
  #include unistd.h
  #include string.h
 +#include stdbool.h
 
  #include sys/types.h
  #include fcntl.h
 @@ -26,7 +27,8 @@ static struct qemud_driver driver;
  static int testCompareXMLToArgvFiles(const char *xml,
   const char *cmd,
   unsigned long long extraFlags,
 - const char *migrateFrom) {
 + const char *migrateFrom,
 + bool expectError) {
  char argvData[MAX_FILE];
  char *expectargv = (argvData[0]);
  char *actualargv = NULL;
 @@ -38,6 +40,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
  virDomainDefPtr vmdef = NULL;
  virDomainChrDef monitor_chr;
  virConnectPtr conn;
 +char *log = NULL;
 
  if (!(conn = virGetConnect()))
  goto fail;
 @@ -80,12 +83,28 @@ static int testCompareXMLToArgvFiles(const char 
*xml,
  }
 
 
 +free(virtTestLogContentAndReset());
 +
  if (qemudBuildCommandLine(conn, driver,
vmdef, monitor_chr, 0, flags,
argv, qenv,
NULL, NULL, migrateFrom, NULL)  0)
  goto fail;
 
 +if ((log = virtTestLogContentAndReset()) == NULL)
 +goto fail;
 +
 +if (!!strstr(log, : error :) != expectError) {
 +if (virTestGetDebug())
 +fprintf(stderr, \n%s, log);
 +goto fail;
 +}
 +
 +if (expectError) {
 +/* need to suppress the errors */
 +virResetLastError();
 +}
 +
  len = 1; /* for trailing newline */
  tmp = qenv;
  while (*tmp) {
 @@ -125,6 +144,7 @@ static int testCompareXMLToArgvFiles(const char 
*xml,
  ret = 0;
 
   fail:
 +free(log);
  free(actualargv);
  if (argv) {
  tmp = argv;
 @@ -152,6 +172,7 @@ struct testInfo {
  const char *name;
  unsigned long long extraFlags;
  const char *migrateFrom;
 +bool expectError;
  };
 
  static int testCompareXMLToArgvHelper(const void *data) {
 @@ -162,7 +183,8 @@ static int testCompareXMLToArgvHelper(const void 
*data) {
   abs_srcdir, info-name);
  snprintf(args, PATH_MAX, 
%s/qemuxml2argvdata/qemuxml2argv-%s.args,
   abs_srcdir, info-name);
 -return testCompareXMLToArgvFiles(xml, args, info-extraFlags, 
 info-migrateFrom);
 +return testCompareXMLToArgvFiles(xml, args, info-extraFlags,
 + info-migrateFrom, 
info-expectError);
  }
 
 
 @@ -193,16 +215,18 @@ mymain(int argc, char **argv)
  if ((driver.hugepage_path = strdup(/dev/hugepages/libvirt/
 qemu)) == NULL)
  return EXIT_FAILURE;
 
 -# define DO_TEST_FULL(name, extraFlags, migrateFrom)  \
 +# define DO_TEST_FULL(name, extraFlags, migrateFrom, expectError) \
  do { \
 -const struct testInfo info = { name, extraFlags, migrateFrom }; 
\
 +const struct testInfo info = { \
 +name, extraFlags, migrateFrom, expectError \
 +}; \
  if (virtTestRun(QEMU XML-2-ARGV  name, \
  1, testCompareXMLToArgvHelper, info)  0) \
  ret = -1; \
  } while (0)
 
 -# define DO_TEST(name, extraFlags)   \
 -DO_TEST_FULL(name, extraFlags, NULL)
 +# define DO_TEST(name, extraFlags, expectError) \
 +DO_TEST_FULL(name, extraFlags, NULL, expectError)
 
  /* Unset or set all envvars here that are copied in 
qemudBuildCommandLine
   * using ADD_ENV_COPY, otherwise these tests may fail due to 
unexpected
 @@ -217,175 +241,175 @@ mymain(int argc, char **argv)
  unsetenv(QEMU_AUDIO_DRV);
  unsetenv(SDL_AUDIODRIVER);
 
 -DO_TEST(minimal, QEMUD_CMD_FLAG_NAME);
 -DO_TEST(machine-aliases1, 0);

[...]

look good to me -- ACK

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

[libvirt] [PATCH] maint: ignore new test executable

2010-10-22 Thread Eric Blake
* tests/.gitignore: Sort, and add sockettest.
---

Pushing under the trivial rule, so that I don't accidentally add
a binary when I do 'git add .'.

 tests/.gitignore |   47 +++
 1 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/tests/.gitignore b/tests/.gitignore
index e7c74c5..8ad3e98 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,35 +1,34 @@
-Makefile
-Makefile.in
+*.exe
 .deps
 .libs
-sexpr2xmltest
-xml2sexprtest
-virshtest
 conftest
-reconnect
-xmconfigtest
-xencapstest
-qemuxml2xmltest
-qemuxml2argvtest
-qemuargv2xmltest
-qemuhelptest
+esxutilstest
+eventtest
+interfacexml2xmltest
 networkxml2xmltest
 nodedevxml2xmltest
-interfacexml2xmltest
-storagevolxml2xmltest
-storagepoolxml2xmltest
 nodeinfotest
-statstest
-qparamtest
-virbuftest
-seclabeltest
-eventtest
-*.exe
 object-locking
+object-locking-files.txt
 object-locking.cmi
 object-locking.cmx
-object-locking-files.txt
-esxutilstest
+qemuargv2xmltest
+qemuhelptest
+qemuxml2argvtest
+qemuxml2xmltest
+qparamtest
+reconnect
+secaatest
+seclabeltest
+sexpr2xmltest
+sockettest
+statstest
+storagepoolxml2xmltest
+storagevolxml2xmltest
+virbuftest
+virshtest
 vmx2xmltest
+xencapstest
+xmconfigtest
+xml2sexprtest
 xml2vmxtest
-secaatest
-- 
1.7.2.3

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


Re: [libvirt] [PATCH] bye to close(), welcome to VIR_(FORCE_)CLOSE()

2010-10-22 Thread Eric Blake

On 10/22/2010 05:19 AM, Stefan Berger wrote:

Using automated replacement with sed and editing I have now replaced all
occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
course. Some replacements were straight forward, others I needed to pay
attention. I hope I payed attention in all the right places... Please
have a look. This should have at least solved one more double-close
error.

Signed-off-by: Stefan Bergerstef...@us.ibm.com





Index: libvirt-acl/src/libvirt.c
===
--- libvirt-acl.orig/src/libvirt.c
+++ libvirt-acl/src/libvirt.c
@@ -10794,7 +10794,7 @@ virStreamRef(virStreamPtr stream)
   *  ... report an error 
   * done:
   *   virStreamFree(st);
- *   close(fd);
+ *   VIR_FORCE_CLOSE(fd);


Ignoring close() failure on read seems reasonable...


   *
   * Returns the number of bytes written, which may be less
   * than requested.
@@ -10884,7 +10884,7 @@ error:
   *  ... report an error 
   * done:
   *   virStreamFree(st);
- *   close(fd);
+ *   VIR_FORCE_CLOSE(fd);


but on write, we should instead change the recommendation to check for 
close() failure, since some file systems (yes, I'm looking at you, NFS) 
can successfully write() to kernel buffers but still fail to close() 
when actual network traffic is finally triggered.


 *   int fd = open(demo.iso, O_WRONLY, 0600)
 *
...
 *   if (virStreamFinish(st)  0 || VIR_CLOSE(fd)  0)
 *  ... report an error 
 * done:
 *   virStreamFree(st);
 *   VIR_FORCE_CLOSE(fd);

I'm wondering how much of the rest of your patch might be impacted by 
adopting this idiom.


Also, should we be thinking of a separate patch for VIR_FCLOSE for the 
FILE* variant?


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] bye to close(), welcome to VIR_(FORCE_)CLOSE()

2010-10-22 Thread Eric Blake

On 10/22/2010 05:19 AM, Stefan Berger wrote:

Using automated replacement with sed and editing I have now replaced all
occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
course. Some replacements were straight forward, others I needed to pay
attention. I hope I payed attention in all the right places... Please
have a look. This should have at least solved one more double-close
error.

Signed-off-by: Stefan Bergerstef...@us.ibm.com

---
  daemon/libvirtd.c |   46 ++-


Continuing on (looks like I'll be replying quite a few times today)...


@@ -127,7 +128,7 @@ static int lxcContainerExecInit(virDomai
  static int lxcContainerSetStdio(int control, int ttyfd)
  {
  int rc = -1;
-int open_max, i;
+int open_max, i, tpmfd;

  if (setsid()  0) {
  virReportSystemError(errno, %s,
@@ -145,8 +146,10 @@ static int lxcContainerSetStdio(int cont
   * close all FDs before executing the container */
  open_max = sysconf (_SC_OPEN_MAX);
  for (i = 0; i  open_max; i++)
-if (i != ttyfd  i != control)
-close(i);
+if (i != ttyfd  i != control) {
+tpmfd = i;
+VIR_FORCE_CLOSE(tpmfd);


Yeah, I guess you do have to introduce a temporary rather than 
clobbering your iterator.


s/tpmfd/tmpfd/, and perhaps reduce it's scope to just the for loop or if 
statement where it is needed.



Index: libvirt-acl/src/lxc/lxc_driver.c
===
--- libvirt-acl.orig/src/lxc/lxc_driver.c
+++ libvirt-acl/src/lxc/lxc_driver.c
@@ -1544,14 +1544,10 @@ cleanup:
  vethDelete(veths[i]);
  VIR_FREE(veths[i]);
  }
-if (rc != 0  priv-monitor != -1) {
-close(priv-monitor);
-priv-monitor = -1;
-}
-if (parentTty != -1)
-close(parentTty);
-if (logfd != -1)
-close(logfd);
+if (rc != 0)
+VIR_FORCE_CLOSE(priv-monitor);
+VIR_FORCE_CLOSE(parentTty);
+VIR_FORCE_CLOSE(logfd);


logfd might be one where we want to hoist a normal VIR_CLOSE and check 
for errors.



Index: libvirt-acl/src/phyp/phyp_driver.c


Pausing here for my lunch...

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] Initial working Mac OS X libvirt client build

2010-10-22 Thread Ruben Kerkhof
On Fri, Oct 22, 2010 at 18:19, Mitchell Hashimoto
mitchell.hashim...@gmail.com wrote:
 On Thu, Oct 21, 2010 at 11:18 PM, Ruben Kerkhof ru...@rubenkerkhof.com 
 wrote:

 I thought I'd give it a try, to see how far I get on Leopard (10.5).


 From what I know following this list, I don't think anyone has ever
 tried to compile for Leopard (10.5) and has focussed exclusively on
 Snow Leopard (10.6), so there very well may be errors during
 compilation/linking.

 I'll wait for you to try the new formula but if that errors as well
 then I may have to spin up  a leopard VM to play around see if I can
 figure out what is going on there.

 Mitchell

It's getting a bit further, the logs are at http://fpaste.org/DC3R/

It seems to have some problems with libxml2. I've also tried with
libxml2-2.7.7 installed by brew, but that didn't help
Readline has always been a problem on Tiger/Leopard. I remember
something about it being libedit in readline-compatibility mode.

Thanks for your help!

Ruben

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

Re: [libvirt] [PATCH] tests: Silence qemuxml2argv test

2010-10-22 Thread Jiri Denemark
tests/qemuxml2argvtest.c |  240 
  +-
1 files changed, 132 insertions(+), 108 deletions(-)
 
 ACK, and thanks for getting to this.

I pushed this patch, thanks.

Jirka

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


Re: [libvirt] [PATCH] [TCK] Forgot to copy *.fwall.dat file

2010-10-22 Thread Stefan Berger
libvir-list-boun...@redhat.com wrote on 10/22/2010 01:21:21 PM:

 [image removed] 
 
 Re: [libvirt] [PATCH] [TCK] Forgot to copy *.fwall.dat file
 
 Eric Blake 
 
 to:
 
 Stefan Berger
 
 10/22/2010 01:31 PM
 
 Sent by:
 
 libvir-list-boun...@redhat.com
 
 Cc:
 
 libvir-list
 
 On 10/22/2010 11:00 AM, Stefan Berger wrote:
  Move to the format Eric suggested and copy the missing .fwall.dat 
file.
 
  Signed-off-by: Stefan Berger stef...@us.ibm.com
 
  diff --git a/Build.PL b/Build.PL
  index 2a4de43..97b4140 100644
  --- a/Build.PL
  +++ b/Build.PL
  @@ -29,7 +29,7 @@ sub process_pkgdata_files {
  my $name = $File::Find::name;
  if (-d) {
  $tck_dirs{$name} = [];
  - } elsif (-f  (/\.t$/ || /\.sh$/ || /\.fwall$/ || /\.xml$/)) {
  + } elsif (-f  /\.(t|sh|fwall|xml|fwall\.dat)$/) {
 
 ...|fwall(\.dat)?|...
 seems more compact still :)

Actually due to an upcoming test for networks I would like to change this 
to

+ } elsif (-f  /\.(t|sh|fwall|xml|fwall|dat)$/) {

so that .fwall and .dat files get copied.

 
 ACK, whether or not you choose to further compress things.

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

Re: [libvirt] [PATCH] bye to close(), welcome to VIR_(FORCE_)CLOSE()

2010-10-22 Thread Stefan Berger
libvir-list-boun...@redhat.com wrote on 10/22/2010 02:24:38 PM:


 On 10/22/2010 05:19 AM, Stefan Berger wrote:
  Using automated replacement with sed and editing I have now replaced 
all
  occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
  course. Some replacements were straight forward, others I needed to 
pay
  attention. I hope I payed attention in all the right places... Please
  have a look. This should have at least solved one more double-close
  error.
 
  Signed-off-by: Stefan Bergerstef...@us.ibm.com
 
  ---
daemon/libvirtd.c |   46 ++-
 
 Continuing on (looks like I'll be replying quite a few times today)...
 
  @@ -127,7 +128,7 @@ static int lxcContainerExecInit(virDomai
static int lxcContainerSetStdio(int control, int ttyfd)
{
int rc = -1;
  -int open_max, i;
  +int open_max, i, tpmfd;
 
if (setsid()  0) {
virReportSystemError(errno, %s,
  @@ -145,8 +146,10 @@ static int lxcContainerSetStdio(int cont
 * close all FDs before executing the container */
open_max = sysconf (_SC_OPEN_MAX);
for (i = 0; i  open_max; i++)
  -if (i != ttyfd  i != control)
  -close(i);
  +if (i != ttyfd  i != control) {
  +tpmfd = i;
  +VIR_FORCE_CLOSE(tpmfd);
 
 Yeah, I guess you do have to introduce a temporary rather than 
 clobbering your iterator.
 
 s/tpmfd/tmpfd/, and perhaps reduce it's scope to just the for loop or if 

 statement where it is needed.

ha, what a typo...  making it a local variable.


  -close(logfd);
  +if (rc != 0)
  +VIR_FORCE_CLOSE(priv-monitor);
  +VIR_FORCE_CLOSE(parentTty);
  +VIR_FORCE_CLOSE(logfd);
 
 logfd might be one where we want to hoist a normal VIR_CLOSE and check 
 for errors.

Ok, so I call the virReportSystemError() on this now.

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

Re: [libvirt] [PATCH] vbox: Stop hardcoding a single path for VBoxXPCOMC.so

2010-10-22 Thread Eric Blake

On 10/22/2010 01:44 PM, Matthias Bolte wrote:

This partly reverts df90ca7661b0a789bd790ccf8258a4527c13eb8d.

Don't disable the VirtualBox driver when configure can't find
VBoxXPCOMC.so, rely on detection at runtime again instead.

Keep --with-vbox=/path/to/virtualbox intact, added to for:
https://bugzilla.redhat.com/show_bug.cgi?id=609185

Detection order for VBoxXPCOMC.so:

1. VBOX_APP_HOME environment variable
2. configure provided location
3. hardcoded list of known locations
4. dynamic linker search path

Also cleanup the glue code and improve error reporting.
-if test x$with_vbox = xyes || test x$with_vbox = xcheck; then
-AC_MSG_CHECKING([for VirtualBox XPCOMC location])
-
-for vbox in \
-/usr/lib/virtualbox/VBoxXPCOMC.so \
-/usr/lib64/virtualbox/VBoxXPCOMC.so \
-/usr/lib/VirtualBox/VBoxXPCOMC.so \
-/opt/virtualbox/VBoxXPCOMC.so \
-/opt/VirtualBox/VBoxXPCOMC.so \
-/opt/virtualbox/i386/VBoxXPCOMC.so \
-/opt/VirtualBox/i386/VBoxXPCOMC.so \
-/opt/virtualbox/amd64/VBoxXPCOMC.so \
-/opt/VirtualBox/amd64/VBoxXPCOMC.so \
-/usr/local/lib/virtualbox/VBoxXPCOMC.so \
-/usr/local/lib/VirtualBox/VBoxXPCOMC.so \
-/Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMC.dylib \
-; do
-if test -f $vbox; then
-vbox_xpcomc_dir=`AS_DIRNAME([$vbox])`
-break
-fi
-done


I'm wondering if we still want to keep this configure-time loop anyways. 
 As in:


--with-vbox=yes = configure-time check; fatal if not found
--with-vbox=no  = no vbox
--with-vbox=check   = configure-time of check; if it passes, use that 
path; if not, fall back dynamic check

--with-vbox=path= hard-code path at configure time

in which case, the default of --with-vbox=check still makes sense, but 
the reaction to not finding anything in the loop changes from disabling 
vbox over to the better action of enabling vbox via the dynamic search 
fallback.



+static int tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing)
  {
-size_t  cchHome = pszHome ? strlen(pszHome) : 0;
-size_t  cbBufNeeded;
-charszName[4096];
-int rc = -1;
+int result = -1;
+char *name = NULL;
+PFNVBOXGETXPCOMCFUNCTIONS pfnGetFunctions;


WESHOULDALLTALKINALLCAPSWITHNOSPACES :) What a horrid upstream coding 
convention.  But not your fault.


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] 0/4 Add SMBIOS settings to domain definition

2010-10-22 Thread Daniel Veillard
On Fri, Oct 22, 2010 at 07:15:43PM +0200, Matthias Bolte wrote:
 2010/10/22 Matthias Bolte matthias.bo...@googlemail.com:
  2010/10/22 Daniel Veillard veill...@redhat.com:
  On Fri, Oct 22, 2010 at 04:00:31PM +0200, Matthias Bolte wrote:
  2010/10/22 Daniel Veillard veill...@redhat.com:
    Okay, I looked up for VirtualBox, and apparently there is some support
   for editing some of the BIOS and system entries too based on this post
    http://forums.virtualbox.org/viewtopic.php?t=3224
 
  It seems that one of the posters suggests to hack the VirtualBox
  codebase. It doesn't look like the XPCOM API exposes this.
 
   Yeah, I misunderstood though it was a config file :-(
 
  Daniel
 
 
  I just came a cross this forum post from 2008:
 
  http://forums.virtualbox.org/viewtopic.php?f=2t=7731
 
  I tested it and it works. This allows to override the defaults.
 
  Matthias
 
 
 The [sg]etextradata functions are also available in the XPCOM API.

  Ah, good ! I had seen it too but it was looking fuzzier than the other
thread :-)

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] esx: Add documentation about certificates and connection problems

2010-10-22 Thread Matthias Bolte
2010/10/22 Daniel Veillard veill...@redhat.com:
 On Fri, Oct 22, 2010 at 03:04:43PM +0200, Matthias Bolte wrote:
 ---
  docs/drvesx.html.in |  103 
 +-
  docs/remote.html.in |    8 +++-
  2 files changed, 107 insertions(+), 4 deletions(-)

 diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
 index dfc91bb..a0f87c1 100644

  ACK,

 Daniel


Thanks, pushed.

Matthias

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

[libvirt] [PATCH] daemon: exclude requirement for probes.h on systems without systemtap

2010-10-22 Thread Justin Clift
This 1-liner was actually written by Eric Blake, over IRC. It
addresses a compilation failure in make dist and make rpm for
systems without the dtrace/systemtap development libraries
installed.
---
 daemon/Makefile.am |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 0e254d4..d1ffd97 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -168,7 +168,7 @@ EXTRA_DIST += probes.d libvirtd.stp
 
 if WITH_DTRACE
 libvirtd_LDADD += probes.o
-libvirtd_SOURCES += probes.h
+libvirtd_nodist_SOURCES = probes.h
 
 BUILT_SOURCES += probes.h
 
-- 
1.7.2.3

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


Re: [libvirt] [PATCH] daemon: exclude requirement for probes.h on systems without systemtap

2010-10-22 Thread Eric Blake

On 10/22/2010 02:57 PM, Justin Clift wrote:

This 1-liner was actually written by Eric Blake, over IRC. It
addresses a compilation failure in make dist and make rpm for
systems without the dtrace/systemtap development libraries
installed.
---
  daemon/Makefile.am |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 0e254d4..d1ffd97 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -168,7 +168,7 @@ EXTRA_DIST += probes.d libvirtd.stp

  if WITH_DTRACE
  libvirtd_LDADD += probes.o
-libvirtd_SOURCES += probes.h
+libvirtd_nodist_SOURCES = probes.h


Given your testing of my one-liner IRC comment:

ACK.

For more explanation for those not following IRC - probes.h is a 
generated file, but it can only be generated if you are using dtrace 
(systemtap-sdt-devel on Fedora). On the other hand, lack of probes.h 
does not affect compilation for people not using dtrace.  Unlike 
documentation, where we want it to be available even if the user can't 
regenerate it, we know that probes.h is safe to omit from the 
distribution tarball since the only people using dtrace already have the 
tools to regenerate it.


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] daemon: exclude requirement for probes.h on systems without systemtap

2010-10-22 Thread Justin Clift
On 10/23/2010 08:05 AM, Eric Blake wrote:
snip
   if WITH_DTRACE
   libvirtd_LDADD += probes.o
 -libvirtd_SOURCES += probes.h
 +libvirtd_nodist_SOURCES = probes.h
 
 Given your testing of my one-liner IRC comment:
 
 ACK.

Thanks.  Pushed. :)

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


Re: [libvirt] [PATCH] daemon: exclude requirement for probes.h on systems without systemtap

2010-10-22 Thread Eric Blake

On 10/22/2010 03:05 PM, Eric Blake wrote:

On 10/22/2010 02:57 PM, Justin Clift wrote:

This 1-liner was actually written by Eric Blake, over IRC. It
addresses a compilation failure in make dist and make rpm for
systems without the dtrace/systemtap development libraries
installed.
---
daemon/Makefile.am | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 0e254d4..d1ffd97 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -168,7 +168,7 @@ EXTRA_DIST += probes.d libvirtd.stp

if WITH_DTRACE
libvirtd_LDADD += probes.o
-libvirtd_SOURCES += probes.h
+libvirtd_nodist_SOURCES = probes.h


Given your testing of my one-liner IRC comment:

ACK.


Actually, the automake manual says this needs to be 
nodist_libvirtd_SOURCES (sorry I didn't check the manual before ACK'ing; 
and I'm assuming you tested without dtrace).


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] daemon: exclude requirement for probes.h on systems without systemtap

2010-10-22 Thread Justin Clift
On 10/23/2010 08:52 AM, Eric Blake wrote:
snip
 Given your testing of my one-liner IRC comment:

 ACK.
 
 Actually, the automake manual says this needs to be
 nodist_libvirtd_SOURCES (sorry I didn't check the manual before ACK'ing;
 and I'm assuming you tested without dtrace).

Just pushed the corrected fix.  Weirdly, it worked previously on my
system. :/

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


Re: [libvirt] [PATCH] bye to close(), welcome to VIR_(FORCE_)CLOSE()

2010-10-22 Thread Eric Blake

On 10/22/2010 05:19 AM, Stefan Berger wrote:

Using automated replacement with sed and editing I have now replaced all
occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
course. Some replacements were straight forward, others I needed to pay
attention. I hope I payed attention in all the right places... Please
have a look. This should have at least solved one more double-close
error.


Can you isolate any of those double-close errors into separate patches 
which we can apply now, rather than drowning them in the giant patch?




Signed-off-by: Stefan Bergerstef...@us.ibm.com

  src/phyp/phyp_driver.c|   13 ++--


Resuming...

Most of the changes are looking okay in limited context.

The point was raised on IRC that this patch is big enough that we 
probably ought to delay until post 0.8.5 to apply it, so as to maximize 
testing exposure over the full course of a release cycle rather than 
making this next week be all the testing we give.  Exceptions for true 
double-close bug fixes which can be applied as independent patches now.



Index: libvirt-acl/src/qemu/qemu_driver.c
@@ -6542,8 +6536,10 @@ static int qemudDomainSaveImageClose(int
  {
  int ret = 0;

-if (fd != -1)
-close(fd);
+if (VIR_CLOSE(fd)  0) {
+virReportSystemError(errno, %s,
+ _(cannot close file));
+}


Yep, this looks like a good case to convert over to reporting an error.


Index: libvirt-acl/src/qemu/qemu_monitor.c

@@ -694,8 +695,7 @@ void qemuMonitorClose(qemuMonitorPtr mon
  if (!mon-closed) {
  if (mon-watch)
  virEventRemoveHandle(mon-watch);
-if (mon-fd != -1)
-close(mon-fd);
+VIR_FORCE_CLOSE(mon-fd);
  /* NB: ordinarily one might immediately set mon-watch to -1
   * and mon-fd to -1, but there may be a callback active
   * that is still relying on these fields being valid. So


Ouch - given that comment, could we be frying a callback by setting 
mon-fd to -1 in VIR_FORCE_CLOSE?  We need to double check this, and 
possibly use a temporary variable if the callback indeed needs a 
non-negative mon-fd for a bit longer, or tighten the specification and 
all existing callbacks to tolerate mon-fd changing to -1.


Probably worth splitting this particular hunk into its own commit, 
rather than part of the giant patch.



Index: libvirt-acl/src/remote/remote_driver.c
===
--- libvirt-acl.orig/src/remote/remote_driver.c
+++ libvirt-acl/src/remote/remote_driver.c
@@ -82,6 +82,7 @@
  #include util.h
  #include event.h
  #include ignore-value.h
+#include files.h

  #define VIR_FROM_THIS VIR_FROM_REMOTE

@@ -711,7 +712,7 @@ doRemoteOpen (virConnectPtr conn,
  if (errno == ECONNREFUSED
  flags  VIR_DRV_OPEN_REMOTE_AUTOSTART
  trials  20) {
-close(priv-sock);
+VIR_FORCE_CLOSE(priv-sock);
  priv-sock = -1;


This line is now redundant.


Index: libvirt-acl/src/uml/uml_driver.c
@@ -811,7 +811,7 @@ static int umlStartVMDaemon(virConnectPt
  virDomainObjPtr vm) {
  const char **argv = NULL, **tmp;
  const char **progenv = NULL;
-int i, ret;
+int i, ret, tmpfd;
  pid_t pid;
  char *logfile;
  int logfd = -1;



  for (i = 0; i  FD_SETSIZE; i++)
-if (FD_ISSET(i,keepfd))
-close(i);
+if (FD_ISSET(i,keepfd)) {
+tmpfd = i;
+VIR_FORCE_CLOSE(tmpfd);


Another awfully large scope for a needed temporary.


Index: libvirt-acl/src/util/bridge.c
@@ -107,7 +108,7 @@ brShutdown(brControl *ctl)
  if (!ctl)
  return;

-close(ctl-fd);
+VIR_FORCE_CLOSE(ctl-fd);
  ctl-fd = 0;


Huh - is this an existing logic bug? Can we end up accidentally 
double-closing stdin?



Index: libvirt-acl/src/util/logging.c
===
--- libvirt-acl.orig/src/util/logging.c
+++ libvirt-acl/src/util/logging.c
@@ -40,6 +40,7 @@
  #include util.h
  #include buf.h
  #include threads.h
+#include files.h

  /*
   * Macro used to format the message as a string in virLogMessage
@@ -603,8 +604,7 @@ static int virLogOutputToFd(const char *
  static void virLogCloseFd(void *data) {
  int fd = (long) data;

-if (fd= 0)
-close(fd);
+VIR_FORCE_CLOSE(fd);


Should we fix this function to return an int value, and return 
VIR_CLOSE(fd) so that callers can choose to detect log close failures?



Index: libvirt-acl/src/util/macvtap.c
===
--- libvirt-acl.orig/src/util/macvtap.c
+++ libvirt-acl/src/util/macvtap.c
@@ -52,6 +52,7 @@
  # include conf/domain_conf.h
  # include virterror_internal.h
  # include uuid.h
+# include files.h

  # define VIR_FROM_THIS VIR_FROM_NET

@@ -94,7 +95,7 @@ static int nlOpen(void)

  

[libvirt] [PATCH] configure: adds an option for not using the readline library

2010-10-22 Thread Justin Clift
So we can use --with-readline=no for situations where that
helpful.  ie.  MacOS X 10.5.

By default, we use --with-readline=check.
---
 configure.ac |   47 ---
 1 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index e41f2b5..2831db0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -240,6 +240,10 @@ AC_ARG_WITH([remote],
 AC_ARG_WITH([libvirtd],
   AC_HELP_STRING([--with-libvirtd], [add libvirtd support 
@:@default=yes@:@]),[],[with_libvirtd=yes])
 
+dnl Add a --help string for the readline usage option
+AC_ARG_WITH([readline],
+  AC_HELP_STRING([--with-readline], [add readline support 
@:@default=check@:@]),[],[with_readline=check])
+
 dnl
 dnl in case someone want to build static binaries
 dnl STATIC_BINARIES=-static
@@ -1338,26 +1342,29 @@ AM_CONDITIONAL([HAVE_CAPNG], [test $with_capng != 
no])
 AC_SUBST([CAPNG_CFLAGS])
 AC_SUBST([CAPNG_LIBS])
 
+dnl If we've been instructed to not use readline, then don't even check for it
+if test $with_readline = no; then
+  lv_use_readline=no
+fi
+if test $with_readline != no; then
+  dnl virsh libraries
+  AC_CHECK_HEADERS([readline/readline.h])
 
-
-dnl virsh libraries
-AC_CHECK_HEADERS([readline/readline.h])
-
-# Check for readline.
-AC_CHECK_LIB([readline], [readline],
+  # Check for readline.
+  AC_CHECK_LIB([readline], [readline],
[lv_use_readline=yes; VIRSH_LIBS=$VIRSH_LIBS -lreadline],
[lv_use_readline=no])
 
-# If the above test failed, it may simply be that -lreadline requires
-# some termcap-related code, e.g., from one of the following libraries.
-# See if adding one of them to LIBS helps.
-if test $lv_use_readline = no; then
-lv_saved_libs=$LIBS
-LIBS=
-AC_SEARCH_LIBS([tgetent], [ncurses curses termcap termlib])
-case $LIBS in
-  no*) ;;  # handle no and none required
-  *) # anything else is a -lLIBRARY
+  # If the above test failed, it may simply be that -lreadline requires
+  # some termcap-related code, e.g., from one of the following libraries.
+  # See if adding one of them to LIBS helps.
+  if test $lv_use_readline = no; then
+  lv_saved_libs=$LIBS
+  LIBS=
+  AC_SEARCH_LIBS([tgetent], [ncurses curses termcap termlib])
+  case $LIBS in
+no*) ;;  # handle no and none required
+*) # anything else is a -lLIBRARY
# Now, check for -lreadline again, also using $LIBS.
# Note: this time we use a different function, so that
# we don't get a cached no result.
@@ -1366,12 +1373,14 @@ if test $lv_use_readline = no; then
 VIRSH_LIBS=$VIRSH_LIBS -lreadline $LIBS],,
[$LIBS])
;;
-esac
-test $lv_use_readline = no 
+  esac
+  test $lv_use_readline = no 
AC_MSG_WARN([readline library not found])
-LIBS=$lv_saved_libs
+  LIBS=$lv_saved_libs
+  fi
 fi
 
+dnl We now adjust things to suit the result of our checks for readline
 if test $lv_use_readline = yes; then
 AC_DEFINE_UNQUOTED([USE_READLINE], 1,
   [whether virsh can use readline])
-- 
1.7.2.3

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


[libvirt] [PATCH] Fix build for SystemTap 1.0

2010-10-22 Thread Matthias Bolte
With SystemTap 1.0 a part of the generated macros in probes.h
expands to:

volatile __typeof__(((name))) arg2 = (name);

GCC reports an 'invalid initialize' error when name has type
char[]. Therfore, add casts to char* to avoid this.
---
 daemon/libvirtd.c |4 ++--
 daemon/remote.c   |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 8e88d05..d3f003e 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1230,11 +1230,11 @@ remoteCheckCertificate(struct qemud_client *client)
 }
 }
 
-PROBE(CLIENT_TLS_ALLOW, fd=%d, name=%s, client-fd, name);
+PROBE(CLIENT_TLS_ALLOW, fd=%d, name=%s, client-fd, (char *)name);
 return 0;
 
 authdeny:
-PROBE(CLIENT_TLS_DENY, fd=%d, name=%s, client-fd, name);
+PROBE(CLIENT_TLS_DENY, fd=%d, name=%s, client-fd, (char *)name);
 return -1;
 
 authfail:
diff --git a/daemon/remote.c b/daemon/remote.c
index 3b72f98..50ccb3b 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4223,7 +4223,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server,
 goto authdeny;
 }
 PROBE(CLIENT_AUTH_ALLOW, fd=%d, auth=%d, username=%s,
-  client-fd, REMOTE_AUTH_POLKIT, ident);
+  client-fd, REMOTE_AUTH_POLKIT, (char *)ident);
 VIR_INFO(_(Policy allowed action %s from pid %d, uid %d),
  action, callerPid, callerUid);
 ret-complete = 1;
@@ -4238,7 +4238,7 @@ authfail:
 
 authdeny:
 PROBE(CLIENT_AUTH_DENY, fd=%d, auth=%d, username=%s,
-  client-fd, REMOTE_AUTH_POLKIT, ident);
+  client-fd, REMOTE_AUTH_POLKIT, (char *)ident);
 goto error;
 
 error:
-- 
1.7.0.4

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


Re: [libvirt] [PATCH] Fix build for SystemTap 1.0

2010-10-22 Thread Eric Blake

On 10/22/2010 05:08 PM, Matthias Bolte wrote:

With SystemTap 1.0 a part of the generated macros in probes.h
expands to:

volatile __typeof__(((name))) arg2 = (name);

GCC reports an 'invalid initialize' error when name has type
char[]. Therfore, add casts to char* to avoid this.
---
  daemon/libvirtd.c |4 ++--
  daemon/remote.c   |4 ++--
  2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 8e88d05..d3f003e 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1230,11 +1230,11 @@ remoteCheckCertificate(struct qemud_client *client)
  }
  }

-PROBE(CLIENT_TLS_ALLOW, fd=%d, name=%s, client-fd, name);
+PROBE(CLIENT_TLS_ALLOW, fd=%d, name=%s, client-fd, (char *)name);


Looks gross, but it doesn't affect too many probes, and expands the 
range of versions we support.


ACK.

--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


Re: [libvirt] [PATCH] Fix build for SystemTap 1.0

2010-10-22 Thread Justin Clift
On 10/23/2010 10:08 AM, Matthias Bolte wrote:
 With SystemTap 1.0 a part of the generated macros in probes.h
 expands to:

ACK, compiles fine here on Fedora 13 x86_64, when using --with-dtrace
and having systemtap-sdt-devel installed.  (1.3-2)

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


[libvirt] [PATCH] qemu: work around dash 0.5.5 bug in managed save

2010-10-22 Thread Eric Blake
* configure.ac (VIR_WRAPPER_SHELL): Define to a replacement shell,
if /bin/sh is broken on  redirection.
* src/qemu/qemu_monitor.h (VIR_WRAPPER_SHELL_PREFIX)
(VIR_WRAPPER_SHELL_SUFFIX): New macros.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextMigrateToFile): Use
them.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONMigrateToFile):
Likewise.
---

Took longer than I thought, but this should do the trick with no
overhead on decent systems, and while still avoiding buggy dash ==
/bin/sh with something that works elsewhere.

This passes for me on Fedora, where /bin/sh is bash; testing on
Ubuntu or other debian-based system where /bin/sh is dash 0.5.5
would be appreciated.

 configure.ac |   50 ++
 src/qemu/qemu_monitor.h  |   13 +++
 src/qemu/qemu_monitor_json.c |5 ++-
 src/qemu/qemu_monitor_text.c |5 ++-
 4 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index e41f2b5..6aa09f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -583,6 +583,56 @@ if test $with_lxc = yes ; then
 fi
 AM_CONDITIONAL([WITH_LXC], [test $with_lxc = yes])

+dnl
+dnl check for shell that understands  redirection without truncation,
+dnl needed by src/qemu/qemu_monitor_{text,json}.c.
+dnl
+if test $with_qemu = yes; then
+  lv_wrapper_shell=
+  AC_CACHE_CHECK([for shell that supports  redirection],
+[lv_cv_wrapper_shell],
+[
+# If cross-compiling, guess that /bin/sh is good enough except for
+# Linux, where it might be dash 0.5.5 which is known broken; and on
+# Linux, we have a good chance that /bin/bash will exist.
+# If we guess wrong, a user can override the cache variable.
+# Going through /bin/bash is a slight slowdown if /bin/sh works.
+if test $cross_compiling = yes; then
+  case $host_os in
+linux*) lv_cv_wrapper_shell=/bin/bash ;;
+*) lv_cv_wrapper_shell=/bin/sh ;;
+  esac
+else
+  for lv_cv_wrapper_shell in /bin/sh bash ksh zsh none; do
+test $lv_cv_wrapper_shell = none 
+  AC_MSG_ERROR([could not find decent shell])
+echo a  conftest.a
+$lv_cv_wrapper_shell -c ': 1conftest.a'
+case `cat conftest.a`.$lv_cv_wrapper_shell in
+  a./*) break;; dnl /bin/sh is good enough
+  a.*) dnl bash, ksh, and zsh all understand 'command', use that
+   dnl to determine the absolute path of the shell
+lv_cv_wrapper_shell=`$lv_cv_wrapper_shell -c \
+  'command -v $lv_cv_wrapper_shell'`
+case $lv_cv_wrapper_shell in
+  /*) break;;
+esac
+;;
+esac
+  done
+  rm -f conftest.a
+fi
+  ])
+  if test x$lv_cv_wrapper_shell != x/bin/sh; then
+lv_wrapper_shell=$lv_cv_wrapper_shell
+  fi
+  if test x$lv_wrapper_shell != x; then
+AC_DEFINE_UNQUOTED([VIR_WRAPPER_SHELL], [$lv_wrapper_shell],
+  [Define to the absolute path of a shell that does not truncate on
+redirection, if /bin/sh does not fit the bill])
+  fi
+fi
+

 dnl
 dnl check for kernel headers required by src/bridge.c
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 48f4c20..7d09145 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -391,4 +391,17 @@ int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const 
char *name);

 int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, const char *cmd, char 
**reply);

+/**
+ * When running two dd process and using  redirection, we need a
+ * shell that will not truncate files.  These two strings serve that
+ * purpose.
+ */
+# ifdef VIR_WRAPPER_SHELL
+#  define VIR_WRAPPER_SHELL_PREFIX VIR_WRAPPER_SHELL  -c '
+#  define VIR_WRAPPER_SHELL_SUFFIX '
+# else
+#  define VIR_WRAPPER_SHELL_PREFIX /* nothing */
+#  define VIR_WRAPPER_SHELL_SUFFIX /* nothing */
+# endif
+
 #endif /* QEMU_MONITOR_H */
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d3ab25f..d2c6f0a 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1698,8 +1698,9 @@ int qemuMonitorJSONMigrateToFile(qemuMonitorPtr mon,
  * allow starting at an alignment of 512, but without wasting
  * padding to get to the larger alignment useful for speed.  Use
  *  redirection to avoid truncating a regular file.  */
-if (virAsprintf(dest, exec:%s | { dd bs=%llu seek=%llu if=/dev/null  
-dd bs=%llu; } 1%s,
+if (virAsprintf(dest, exec: VIR_WRAPPER_SHELL_PREFIX %s | 
+{ dd bs=%llu seek=%llu if=/dev/null  
+dd bs=%llu; } 1%s VIR_WRAPPER_SHELL_SUFFIX,
 argstr, QEMU_MONITOR_MIGRATE_TO_FILE_BS,
 offset / QEMU_MONITOR_MIGRATE_TO_FILE_BS,
 QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE,
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 69971a6..d7e128c 100644
--- a/src/qemu/qemu_monitor_text.c
+++ 

Re: [libvirt] Initial working Mac OS X libvirt client build

2010-10-22 Thread Justin Clift
On 10/23/2010 06:06 AM, Ruben Kerkhof wrote:
snip
 It's getting a bit further, the logs are at http://fpaste.org/DC3R/
 
 It seems to have some problems with libxml2.

Daniel, any idea what would cause this libxml2 failure?

  GEN virt-pki-validate
  GEN virt-xml-validate.1
  GEN virt-pki-validate.1
  GEN virsh.1
  CCLD virsh
  Undefined symbols:
  _xmlSaveToBuffer, referenced from:
  _cmdCPUBaseline in virsh-virsh.o
  _rl_completion_matches, referenced from:
  _vshReadlineCompletion in virsh-virsh.o
  _vshReadlineCompletion in virsh-virsh.o
  ld: symbol(s) not found
  collect2: ld returned 1 exit status
  make[3]: *** [virsh] Error 1
  make[2]: *** [all] Error 2
  make[1]: *** [all-recursive] Error 1
  make: *** [all] Error 2

Ruben, the readline one can probably be worked around in the short
term.  I've just submitted a patch to libvirt, allowing the use of
readline can be disabled.  (easiest way forward)

We'll need to figure out the libxml2 problem though.  Probably not
going to be today, more likely sometime next week. (with luck)

:)

Regards and best wishes,

Justin Clift

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


[libvirt] [PATCH] [TCK] network: create networks and check for exected results

2010-10-22 Thread Stefan Berger
Derived from the nwfilter test program, this one works with libvirt's
networks. It creates networks from provided xml files and checks for
expected configuration in iptables, running processes and virsh output
using provided data files with commands to execute and the expected
results for after creating the network and after tearing it down
(*.post.dat). 3 tests are currently not passing due to a bug in
libvirt...

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

---
 Build.PL   |2 
 scripts/networks/100-apply-verify-host.t   |   10 
 scripts/networks/networkApplyTest.sh   |  343 +
 scripts/networks/networkxml2hostout/tck-testnet-1.dat  |   11 
 scripts/networks/networkxml2hostout/tck-testnet-1.post.dat |4 
 scripts/networks/networkxml2hostout/tck-testnet-2.dat  |8 
 scripts/networks/networkxml2hostout/tck-testnet-2.post.dat |4 
 scripts/networks/networkxml2xmlin/tck-testnet-1.xml|   12 
 scripts/networks/networkxml2xmlin/tck-testnet-2.xml|   12 
 9 files changed, 405 insertions(+), 1 deletion(-)

Index: libvirt-tck/scripts/networks/networkApplyTest.sh
===
--- /dev/null
+++ libvirt-tck/scripts/networks/networkApplyTest.sh
@@ -0,0 +1,343 @@
+#!/bin/bash
+
+VIRSH=virsh
+
+uri=
+if [ x${LIBVIRT_TCK_CONFIG}x != xx ]; then
+uri_exp=`cat ${LIBVIRT_TCK_CONFIG} | grep ^uri\s*= | sed -e 
's/uri\s*=\s*//' | tail -n 1`
+if [ x${uri_exp}x != xx ]; then
+eval uri=${uri_exp}
+fi
+if [ x${uri}x == xx ]; then
+uri=qemu:///system
+fi
+else
+uri=qemu:///system
+fi
+LIBVIRT_URI=${uri}
+
+
+FLAG_WAIT=$((10))
+FLAG_VERBOSE=$((12))
+FLAG_LIBVIRT_TEST=$((13))
+FLAG_TAP_TEST=$((14))
+FLAG_FORCE_CLEAN=$((15))
+
+failctr=0
+passctr=0
+attachfailctr=0
+attachctr=0
+
+TAP_FAIL_LIST=
+TAP_FAIL_CTR=0
+TAP_TOT_CTR=0
+
+function usage() {
+  local cmd=$0
+cat EOF
+Usage: ${cmd} [--help|-h|-?] [--noattach] [--wait] [--verbose]
+  [--libvirt-test] [--tap-test]
+
+Options:
+ --help,-h,-?   : Display this help screen.
+ --wait : Wait for the user to press the enter key once an error
+  was detected
+ --verbose  : Verbose output
+ --libvirt-test : Use the libvirt test output format
+ --tap-test : TAP format output
+ --force: Allow the automatic cleaning of VMs and networks
+  previously created by the TCK test suite
+
+This test creates libvirt 'networks' and checks for expected results
+(iptables, running processes (dnsmasq)) using provided xml and data
+file respectively.
+EOF
+}
+
+
+function tap_fail() {
+  echo not ok $1 - ${2:0:66}
+  TAP_FAIL_LIST+=$1 
+  ((TAP_FAIL_CTR++))
+  ((TAP_TOT_CTR++))
+}
+
+function tap_pass() {
+  echo ok $1 - ${2:0:70}
+  ((TAP_TOT_CTR++))
+}
+
+function tap_final() {
+  local okay
+
+  [ -n ${TAP_FAIL_LIST} ]  echo FAILED tests ${TAP_FAIL_LIST}
+
+  okay=`echo ($TAP_TOT_CTR-$TAP_FAIL_CTR)*100/$TAP_TOT_CTR | bc -l`
+  echo Failed ${TAP_FAIL_CTR}/${TAP_TOT_CTR} tests, ${okay:0:5}% okay
+}
+
+# A wrapper for mktemp in case it does not exist
+# Echos the name of a temporary file.
+function mktmpfile() {
+  local tmp
+  type -P mktemp  /dev/null
+  if [ $? -eq 0 ]; then
+tmp=$(mktemp -t nwfvmtest.XX)
+echo ${tmp}
+  else
+while :; do
+  tmp=/tmp/nwfvmtest.${RANDOM}
+  if [ ! -f ${tmp} ]; then
+  touch ${tmp}
+  chmod 666 ${tmp}
+  echo ${tmp}
+  break
+  fi
+done
+  fi
+  return 0
+}
+
+
+function checkExpectedOutput() {
+  local xmlfile=$1
+  local datafile=$2
+  local flags=$3
+  local skipregex=$4
+  local cmd line tmpfile tmpfile2 skip
+
+  tmpfile=`mktmpfile`
+  tmpfile2=`mktmpfile`
+
+  exec 4${datafile}
+
+  read 4
+  line=${REPLY}
+
+  while [ x${line}x != xx ]; do
+cmd=`echo ${line##\#}`
+
+skip=0
+if [ x${skipregex}x != xx ]; then
+   skip=`echo ${cmd} | grep -c -E ${skipregex}`
+fi
+
+eval ${cmd} 21 | tee ${tmpfile} 1/dev/null
+
+rm ${tmpfile2} 2/dev/null
+touch ${tmpfile2}
+
+while [ 1 ]; do
+  read 4
+  line=${REPLY}
+
+  if [ ${line:0:1} == # ] || [ x${line}x == xx  ]; then
+
+   if [ ${skip} -ne 0 ]; then
+ break
+   fi
+
+diff ${tmpfile} ${tmpfile2} /dev/null
+
+if [ $? -ne 0 ]; then
+  if [ $((flags  FLAG_VERBOSE)) -ne 0 ]; then
+echo FAIL ${xmlfile} : ${cmd}
+diff ${tmpfile} ${tmpfile2}
+  fi
+  ((failctr++))
+  if [ $((flags  FLAG_WAIT)) -ne 0 ]; then
+echo tmp files: $tmpfile, $tmpfile2
+   echo Press enter
+   read
+  fi
+  [ $((flags  FLAG_LIBVIRT_TEST)) -ne 0 ]  \
+  test_result $((passctr+failctr))  1
+  [ $((flags  FLAG_TAP_TEST)) -ne 0 ]  \
+ tap_fail $((passctr+failctr)) ${xmlfile} : ${cmd}
+

Re: [libvirt] [PATCH] bye to close(), welcome to VIR_(FORCE_)CLOSE()

2010-10-22 Thread Stefan Berger
libvir-list-boun...@redhat.com wrote on 10/22/2010 06:27:30 PM:


 libvir-list
 
 On 10/22/2010 05:19 AM, Stefan Berger wrote:
  Using automated replacement with sed and editing I have now replaced 
all
  occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
  course. Some replacements were straight forward, others I needed to 
pay
  attention. I hope I payed attention in all the right places... Please
  have a look. This should have at least solved one more double-close
  error.
 
 Can you isolate any of those double-close errors into separate patches 
 which we can apply now, rather than drowning them in the giant patch?
 
 
  Signed-off-by: Stefan Bergerstef...@us.ibm.com
 
src/phyp/phyp_driver.c|   13 ++--
 
 Resuming...
 
[...]
 
  Index: libvirt-acl/src/qemu/qemu_monitor.c
 
  @@ -694,8 +695,7 @@ void qemuMonitorClose(qemuMonitorPtr mon
if (!mon-closed) {
if (mon-watch)
virEventRemoveHandle(mon-watch);
  -if (mon-fd != -1)
  -close(mon-fd);
  +VIR_FORCE_CLOSE(mon-fd);
/* NB: ordinarily one might immediately set mon-watch to -1
 * and mon-fd to -1, but there may be a callback active
 * that is still relying on these fields being valid. So
 
 Ouch - given that comment, could we be frying a callback by setting 
 mon-fd to -1 in VIR_FORCE_CLOSE?  We need to double check this, and 
 possibly use a temporary variable if the callback indeed needs a 
 non-negative mon-fd for a bit longer, or tighten the specification and 
 all existing callbacks to tolerate mon-fd changing to -1.
 
 Probably worth splitting this particular hunk into its own commit, 
 rather than part of the giant patch.

Yes, good idea. Obviously I did not read the comment.

 
  Index: libvirt-acl/src/remote/remote_driver.c
  ===
  --- libvirt-acl.orig/src/remote/remote_driver.c
  +++ libvirt-acl/src/remote/remote_driver.c
  @@ -82,6 +82,7 @@
#include util.h
#include event.h
#include ignore-value.h
  +#include files.h
 
#define VIR_FROM_THIS VIR_FROM_REMOTE
 
  @@ -711,7 +712,7 @@ doRemoteOpen (virConnectPtr conn,
if (errno == ECONNREFUSED
flags  VIR_DRV_OPEN_REMOTE_AUTOSTART
trials  20) {
  -close(priv-sock);
  +VIR_FORCE_CLOSE(priv-sock);
priv-sock = -1;
 
 This line is now redundant.

Done.

 
  Index: libvirt-acl/src/uml/uml_driver.c
  @@ -811,7 +811,7 @@ static int umlStartVMDaemon(virConnectPt
virDomainObjPtr vm) {
const char **argv = NULL, **tmp;
const char **progenv = NULL;
  -int i, ret;
  +int i, ret, tmpfd;
pid_t pid;
char *logfile;
int logfd = -1;
 
for (i = 0; i  FD_SETSIZE; i++)
  -if (FD_ISSET(i,keepfd))
  -close(i);
  +if (FD_ISSET(i,keepfd)) {
  +tmpfd = i;
  +VIR_FORCE_CLOSE(tmpfd);
 
 Another awfully large scope for a needed temporary.

Ok.

 
  Index: libvirt-acl/src/util/bridge.c
  @@ -107,7 +108,7 @@ brShutdown(brControl *ctl)
if (!ctl)
return;
 
  -close(ctl-fd);
  +VIR_FORCE_CLOSE(ctl-fd);
ctl-fd = 0;
 
 Huh - is this an existing logic bug? Can we end up accidentally 
 double-closing stdin?

I'ld leave the patch for now as it is, i.e., do the VIR_FORCE_CLOSE and 
remember to investigate. So far, the changed does not have any further 
negative impact that already isn't there - but it also doesn't solve a 
potential problem.

 
  Index: libvirt-acl/src/util/logging.c
  ===
  --- libvirt-acl.orig/src/util/logging.c
  +++ libvirt-acl/src/util/logging.c
  @@ -40,6 +40,7 @@
#include util.h
#include buf.h
#include threads.h
  +#include files.h
 
/*
 * Macro used to format the message as a string in virLogMessage
  @@ -603,8 +604,7 @@ static int virLogOutputToFd(const char *
static void virLogCloseFd(void *data) {
int fd = (long) data;
 
  -if (fd= 0)
  -close(fd);
  +VIR_FORCE_CLOSE(fd);
 
 Should we fix this function to return an int value, and return 
 VIR_CLOSE(fd) so that callers can choose to detect log close failures?

Also that I would delay until further 'cause this may have consequences 
for those calling the function.

 
  Index: libvirt-acl/src/util/macvtap.c
  ===
  --- libvirt-acl.orig/src/util/macvtap.c
  +++ libvirt-acl/src/util/macvtap.c
  @@ -52,6 +52,7 @@
# include conf/domain_conf.h
# include virterror_internal.h
# include uuid.h
  +# include files.h
 
# define VIR_FROM_THIS VIR_FROM_NET
 
  @@ -94,7 +95,7 @@ static int nlOpen(void)
 
static void nlClose(int fd)
{
  -close(fd);
  +VIR_FORCE_CLOSE(fd);