Re: [libvirt] [PATCH v5 0/3] support dumping guest memory in compressed format

2014-03-12 Thread qiaonuo...@cn.fujitsu.com
[off-list]

Hello,

We have just added 'Comment 3' in bugzilla.

On 03/06/2014 05:35 PM, Qiao, Nuohan/乔 诺涵 wrote:
 dumping guest's memroy is introduced without compression supported, and this 
 is
 a freature regression of 'virsh dump --memory-only'. This patchset is used to
 add support in libvirt side to make qemu dump guest's memory in 
 kdump-compressed
 format and please refer the following address to see implementation of the 
 qemu
 side, the lastest version of qemu side is v9(ready for being queued).

 http://lists.nongnu.org/archive/html/qemu-devel/2014-02/msg03016.html

 ChangLog:
 Changes from v4 to v5:
 1. modify some restriction check

 Changes from v3 to v4:
 1. dropping patch add dump_memory_format in qemu.conf
 2. fix to follow some conventions

 Changes from v2 to v3:
 1. address Jiri Denemark's comment about adding a new public API instead of
 changing an old one.

 Changes from v1 to v2:
 1. address Daniel P. Berrange's comment about using a new parameter to replace
 flags like VIR_DUMP_COMPRESS_ZLIB.


 qiaonuohan (3):
add new virDomainCoreDumpWithFormat API
add qemu support to virDomainCoreDumpWithFormat API
allow virsh dump --memory-only specify dump format

   include/libvirt/libvirt.h.in | 31 ++
   src/driver.h |  7 
   src/libvirt.c| 97 
 
   src/libvirt_public.syms  |  5 +++
   src/qemu/qemu_driver.c   | 49 ++
   src/qemu/qemu_monitor.c  |  7 ++--
   src/qemu/qemu_monitor.h  |  3 +-
   src/qemu/qemu_monitor_json.c |  4 +-
   src/qemu/qemu_monitor_json.h |  3 +-
   src/remote/remote_driver.c   |  1 +
   src/remote/remote_protocol.x | 15 ++-
   src/remote_protocol-structs  |  7 
   src/test/test_driver.c   | 20 +++--
   tests/qemumonitorjsontest.c  |  2 +-
   tools/virsh-domain.c | 45 +++-
   15 files changed, 275 insertions(+), 21 deletions(-)



-- 
Regards
Qiao Nuohan

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

[libvirt] [PATCH] docs: add VMmanager to web apps

2014-03-12 Thread Martin Kletzander
This is a request for adding a VMmanager application as requested and
described by Ksenya Phil.

Signed-off-by: Ksenya Phil philka2...@mail.ru
Signed-off-by: Martin Kletzander mklet...@redhat.com
---
 docs/apps.html.in | 9 +
 1 file changed, 9 insertions(+)

diff --git a/docs/apps.html.in b/docs/apps.html.in
index 7b581db..86e45fc 100644
--- a/docs/apps.html.in
+++ b/docs/apps.html.in
@@ -393,6 +393,15 @@
 with FreeIPA for Kerberos authentication, and in the future,
 certificate management.
   /dd
+  dta 
href=http://ispsystem.com/en/software/vmmanager;VMmanager/a/dt
+  dd
+VMmanager is a software solution for virtualization management
+that can be used both for hosting virtual machines and
+building a cloud.  VMmanager can manage not only one server,
+but a large cluster of hypervisors.  It delivers a number of
+functions, such as live migration that allows for load
+balancing between cluster nodes, monitoring CPU, memory.
+  /dd
 /dl

 h2a name=mobileMobile applications/a/h2
-- 
1.9.0

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


[libvirt] [PATCH] qemu.conf: Mention virtlockd in @lock_manager description

2014-03-12 Thread Michal Privoznik
When I played with virtlockd I was stunned by lacking
documentation. My frustration got bigger when I had to
read the patches to get the correct value to set in
qemu.conf.

Moreover, from pure libvirt-pride  I'm changing commented
value from sanlock to lockd. We want to favor our own
implementation after all.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 src/qemu/qemu.conf | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index e436084..f0e802f 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -402,11 +402,13 @@
 #allow_disk_format_probing = 1
 
 
-# To enable 'Sanlock' project based locking of the file
-# content (to prevent two VMs writing to the same
-# disk), uncomment this
+# In order to prevent accidentally starting two domains that
+# share one writable disk, libvirt offers two approaches for
+# locking files. The first one is sanlock, the other one,
+# virtlockd, is then our own implementation. Accepted values
+# are sanlock and lockd.
 #
-#lock_manager = sanlock
+#lock_manager = lockd
 
 
 
-- 
1.9.0

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


Re: [libvirt] [libvirt-java] [PATCH] Implement equals and hashCode methods for Connect and Domain

2014-03-12 Thread Claudio Bley
At Tue, 11 Mar 2014 11:18:57 +0100,
Claudio Bley wrote:
 
 
 Signed-off-by: Claudio Bley cb...@av-test.de
 ---
  src/main/java/org/libvirt/Connect.java  |   39 +
  src/main/java/org/libvirt/Domain.java   |   52 
 ++-
  src/test/java/org/libvirt/TestJavaBindings.java |4 ++
  3 files changed, 94 insertions(+), 1 deletion(-)
 
 diff --git a/src/main/java/org/libvirt/Connect.java 
 b/src/main/java/org/libvirt/Connect.java
 index fedc60e..7dca98a 100644
 --- a/src/main/java/org/libvirt/Connect.java
 +++ b/src/main/java/org/libvirt/Connect.java
 @@ -89,6 +89,45 @@ public class Connect {
   */
  protected ConnectionPointer VCP;
  
 +/* (non-Javadoc)
 + * @see java.lang.Object#hashCode()
 + */
 +@Override
 +public int hashCode() {
 +final int prime = 31;
 +int result = 1;
 +try {
 +result = prime * result + ((VCP == null) ? 0 : 
 this.getURI().hashCode());
 +} catch (LibvirtException e) {
 +throw new RuntimeException(libvirt error testing connection 
 equality, e);
 +}

Darn copy'n'paste; just pretend it says libvirt error generating hash
code, OK?! Likewise for the Domain class.

Claudio

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


Re: [libvirt] [PATCH] qemu.conf: Mention virtlockd in @lock_manager description

2014-03-12 Thread Daniel P. Berrange
On Wed, Mar 12, 2014 at 08:59:42AM +0100, Michal Privoznik wrote:
 When I played with virtlockd I was stunned by lacking
 documentation. My frustration got bigger when I had to
 read the patches to get the correct value to set in
 qemu.conf.
 
 Moreover, from pure libvirt-pride  I'm changing commented
 value from sanlock to lockd. We want to favor our own
 implementation after all.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/qemu/qemu.conf | 10 ++
  1 file changed, 6 insertions(+), 4 deletions(-)
 
 diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
 index e436084..f0e802f 100644
 --- a/src/qemu/qemu.conf
 +++ b/src/qemu/qemu.conf
 @@ -402,11 +402,13 @@
  #allow_disk_format_probing = 1
  
  
 -# To enable 'Sanlock' project based locking of the file
 -# content (to prevent two VMs writing to the same
 -# disk), uncomment this
 +# In order to prevent accidentally starting two domains that
 +# share one writable disk, libvirt offers two approaches for
 +# locking files. The first one is sanlock, the other one,
 +# virtlockd, is then our own implementation. Accepted values
 +# are sanlock and lockd.
  #
 -#lock_manager = sanlock
 +#lock_manager = lockd


ACK, I did actually have a patch floating around to turn on virtlockd
by default out of the box. I wonder if we should actually do that
finally ?


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH] qemu.conf: Mention virtlockd in @lock_manager description

2014-03-12 Thread Michal Privoznik

On 12.03.2014 11:31, Daniel P. Berrange wrote:

On Wed, Mar 12, 2014 at 08:59:42AM +0100, Michal Privoznik wrote:

When I played with virtlockd I was stunned by lacking
documentation. My frustration got bigger when I had to
read the patches to get the correct value to set in
qemu.conf.

Moreover, from pure libvirt-pride  I'm changing commented
value from sanlock to lockd. We want to favor our own
implementation after all.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
  src/qemu/qemu.conf | 10 ++
  1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index e436084..f0e802f 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -402,11 +402,13 @@
  #allow_disk_format_probing = 1


-# To enable 'Sanlock' project based locking of the file
-# content (to prevent two VMs writing to the same
-# disk), uncomment this
+# In order to prevent accidentally starting two domains that
+# share one writable disk, libvirt offers two approaches for
+# locking files. The first one is sanlock, the other one,
+# virtlockd, is then our own implementation. Accepted values
+# are sanlock and lockd.
  #
-#lock_manager = sanlock
+#lock_manager = lockd



ACK, I did actually have a patch floating around to turn on virtlockd
by default out of the box. I wonder if we should actually do that
finally ?


Sure, why not?

Michal

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


Re: [libvirt] [PATCH] qemu.conf: Mention virtlockd in @lock_manager description

2014-03-12 Thread Daniel P. Berrange
On Wed, Mar 12, 2014 at 11:47:24AM +0100, Michal Privoznik wrote:
 On 12.03.2014 11:31, Daniel P. Berrange wrote:
 On Wed, Mar 12, 2014 at 08:59:42AM +0100, Michal Privoznik wrote:
 When I played with virtlockd I was stunned by lacking
 documentation. My frustration got bigger when I had to
 read the patches to get the correct value to set in
 qemu.conf.
 
 Moreover, from pure libvirt-pride  I'm changing commented
 value from sanlock to lockd. We want to favor our own
 implementation after all.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
   src/qemu/qemu.conf | 10 ++
   1 file changed, 6 insertions(+), 4 deletions(-)
 
 diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
 index e436084..f0e802f 100644
 --- a/src/qemu/qemu.conf
 +++ b/src/qemu/qemu.conf
 @@ -402,11 +402,13 @@
   #allow_disk_format_probing = 1
 
 
 -# To enable 'Sanlock' project based locking of the file
 -# content (to prevent two VMs writing to the same
 -# disk), uncomment this
 +# In order to prevent accidentally starting two domains that
 +# share one writable disk, libvirt offers two approaches for
 +# locking files. The first one is sanlock, the other one,
 +# virtlockd, is then our own implementation. Accepted values
 +# are sanlock and lockd.
   #
 -#lock_manager = sanlock
 +#lock_manager = lockd
 
 
 ACK, I did actually have a patch floating around to turn on virtlockd
 by default out of the box. I wonder if we should actually do that
 finally ?
 
 Sure, why not?

Main reason is that it is a slight pain for developers running out of
GIT builds, to have to launch two daemons. I guess they can easily just
turn it off in the config file though.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] [PATCH] nwfilter: Add ARP src/dst IP mask for ebtables ARP

2014-03-12 Thread Stefan Berger
From: Stefan Berger stef...@linux.vnet.ibm.com

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=862887

Add a netmask for the source and destination IP address for the
ebtables --arp-ip-src and --arp-ip-dst options. Extend the XML
parser with support for XML attributes for these netmasks similar
to already supported netmasks. Extend the documentation.

Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
---
 docs/formatnwfilter.html.in   | 10 ++
 src/conf/nwfilter_conf.c  | 12 
 src/conf/nwfilter_conf.h  |  2 ++
 src/nwfilter/nwfilter_ebiptables_driver.c | 28 
 4 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/docs/formatnwfilter.html.in b/docs/formatnwfilter.html.in
index 5c06bf2..fb3a326 100644
--- a/docs/formatnwfilter.html.in
+++ b/docs/formatnwfilter.html.in
@@ -990,11 +990,21 @@
  tdSource IP address in ARP/RARP packet/td
/tr
tr
+ tdarpsrcipmask span class=since(Since 1.2.3)/span/td
+ tdIP_MASK/td
+ tdSource IP mask/td
+   /tr
+   tr
  tdarpdstipaddr/td
  tdIP_ADDR/td
  tdDestination IP address in ARP/RARP packet/td
/tr
tr
+ tdarpdstipmask span class=since(Since 1.2.3)/span/td
+ tdIP_MASK/td
+ tdDestination IP mask/td
+   /tr
+   tr
  tdcomment span class=since(Since 0.8.5)/span/td
  tdSTRING/td
  tdtext with max. 256 characters/td
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index d25e0cc..73e668f 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -173,7 +173,9 @@ static const char dstmacmask_str[]= dstmacmask;
 static const char arpsrcmacaddr_str[] = arpsrcmacaddr;
 static const char arpdstmacaddr_str[] = arpdstmacaddr;
 static const char arpsrcipaddr_str[]  = arpsrcipaddr;
+static const char arpsrcipmask_str[]  = arpsrcipmask;
 static const char arpdstipaddr_str[]  = arpdstipaddr;
+static const char arpdstipmask_str[]  = arpdstipmask;
 static const char srcipaddr_str[] = srcipaddr;
 static const char srcipmask_str[] = srcipmask;
 static const char dstipaddr_str[] = dstipaddr;
@@ -198,7 +200,9 @@ static const char ipsetflags_str[]= ipsetflags;
 #define ARPSRCMACADDR arpsrcmacaddr_str
 #define ARPDSTMACADDR arpdstmacaddr_str
 #define ARPSRCIPADDR  arpsrcipaddr_str
+#define ARPSRCIPMASK  arpsrcipmask_str
 #define ARPDSTIPADDR  arpdstipaddr_str
+#define ARPDSTIPMASK  arpdstipmask_str
 #define SRCIPADDR srcipaddr_str
 #define SRCIPMASK srcipmask_str
 #define DSTIPADDR dstipaddr_str
@@ -1302,10 +1306,18 @@ static const virXMLAttr2Struct arpAttributes[] = {
 .datatype = DATATYPE_IPADDR,
 .dataIdx = offsetof(virNWFilterRuleDef, 
p.arpHdrFilter.dataARPSrcIPAddr),
 }, {
+.name = ARPSRCIPMASK,
+.datatype = DATATYPE_IPMASK,
+.dataIdx = offsetof(virNWFilterRuleDef, 
p.arpHdrFilter.dataARPSrcIPMask),
+}, {
 .name = ARPDSTIPADDR,
 .datatype = DATATYPE_IPADDR,
 .dataIdx = offsetof(virNWFilterRuleDef, 
p.arpHdrFilter.dataARPDstIPAddr),
 }, {
+.name = ARPDSTIPMASK,
+.datatype = DATATYPE_IPMASK,
+.dataIdx = offsetof(virNWFilterRuleDef, 
p.arpHdrFilter.dataARPDstIPMask),
+}, {
 .name = gratuitous,
 .datatype = DATATYPE_BOOLEAN,
 .dataIdx = offsetof(virNWFilterRuleDef, 
p.arpHdrFilter.dataGratuitousARP),
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index 8c59330..071343e 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -209,8 +209,10 @@ struct _arpHdrFilterDef {
 nwItemDesc dataOpcode;
 nwItemDesc dataARPSrcMACAddr;
 nwItemDesc dataARPSrcIPAddr;
+nwItemDesc dataARPSrcIPMask;
 nwItemDesc dataARPDstMACAddr;
 nwItemDesc dataARPDstIPAddr;
+nwItemDesc dataARPDstIPMask;
 nwItemDesc dataGratuitousARP;
 nwItemDesc dataComment;
 };
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c 
b/src/nwfilter/nwfilter_ebiptables_driver.c
index bea9535..a4b38e7 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -2059,6 +2059,7 @@ ebtablesCreateRuleInstance(char chainPrefix,
 {
 char macaddr[VIR_MAC_STRING_BUFLEN],
  ipaddr[INET_ADDRSTRLEN],
+ ipmask[INET_ADDRSTRLEN],
  ipv6addr[INET6_ADDRSTRLEN],
  number[MAX(INT_BUFSIZE_BOUND(uint32_t),
 INT_BUFSIZE_BOUND(int))],
@@ -2066,6 +2067,7 @@ ebtablesCreateRuleInstance(char chainPrefix,
 char chain[MAX_CHAINNAME_LENGTH];
 virBuffer buf = VIR_BUFFER_INITIALIZER;
 const char *target;
+bool hasMask;
 
 if (!ebtables_cmd_path) {
 virReportError(VIR_ERR_INTERNAL_ERROR, %s,
@@ -2269,11 +2271,20 @@ ebtablesCreateRuleInstance(char chainPrefix,
   rule-p.arpHdrFilter.dataARPSrcIPAddr)  0)
   

[libvirt] [PATCH] nwfilter: Add missing goto err_exit in error path

2014-03-12 Thread Stefan Berger
From: Stefan Berger stef...@linux.vnet.ibm.com

https://bugzilla.redhat.com/show_bug.cgi?id=1071095

Add a missing goto err_exit in the error path where an unsupported
value is assigned to the CTRL_IP_LEARNING key.

Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
---
 src/nwfilter/nwfilter_gentech_driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/nwfilter/nwfilter_gentech_driver.c 
b/src/nwfilter/nwfilter_gentech_driver.c
index e576dc4..5c3b25e 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -732,6 +732,7 @@ virNWFilterInstantiate(const unsigned char *vmuuid 
ATTRIBUTE_UNUSED,
_(filter '%s' 
  learning value '%s' invalid.),
filter-name, learning);
+goto err_exit;
 }
 } else
  goto err_unresolvable_vars;
-- 
1.8.1.4

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


[libvirt] libvirt: [PATCH] libxl: Check for control_d string to decide about dom0

2014-03-12 Thread Stefan Bader
I have been looking into a bug report (see BugLink) which reported
libvirt to fail starting inside a Xen guest. Upon further investigation
I found that some tools that help monitoring Xen guests will mount
xenfs to /proc/xen. This will create a capabilities files there even
if the guest is not dom0. However it will return nothing when reading
from it.

Ian, just to sanity check myself. I looked at the xenfs code and to
me there only seem to be those two outcomes (either control_d for
running in dom0 or notrhing if not).

With the following patch applied, libvirt starts up correctly in
the normal guests (with xenfs mounted) without initializing libxl.
And also in dom0 where it still enables the libxl driver (if the
xl toolstack is selected).

-Stefan

From f11949caca6dfe1a802472a2a6d4fe760115ccc6 Mon Sep 17 00:00:00 2001
From: Stefan Bader stefan.ba...@canonical.com
Date: Wed, 12 Mar 2014 11:37:16 +0100
Subject: [PATCH] libxl: Check for control_d string to decide about dom0

As soon as any guest mounts xenfs to /proc/xen, there is a capabilities
file in that directory. However it returns nothing when reading from it.
Change the test to actually check the contents of the file.

BugLink: http://bugs.launchpad.net/bugs/1248025

Signed-off-by: Stefan Bader stefan.ba...@canonical.com
---
 src/libxl/libxl_driver.c |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 65d80a2..844e828 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -944,6 +944,7 @@ libxlDriverShouldLoad(bool privileged)
 bool ret = false;
 virCommandPtr cmd;
 int status;
+char *output = NULL;
 
 /* Don't load if non-root */
 if (!privileged) {
@@ -951,8 +952,17 @@ libxlDriverShouldLoad(bool privileged)
 return ret;
 }
 
-/* Don't load if not running on a Xen control domain (dom0) */
-if (!virFileExists(/proc/xen/capabilities)) {
+/*
+ * Don't load if not running on a Xen control domain (dom0). It is not
+ * sufficient to check for the file to exist as any guest can mount
+ * xenfs to /proc/xen.
+ */
+status = virFileReadAll(/proc/xen/capabilities, 10. output);
+if (status = 0) {
+status = strncmp(output, control_d, 9);
+}
+VIR_FREE(output);
+if (status) {
 VIR_INFO(No Xen capabilities detected, probably not running 
  in a Xen Dom0.  Disabling libxenlight driver);
 
-- 
1.7.9.5

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


Re: [libvirt] libvirt: [PATCH] libxl: Check for control_d string to decide about dom0

2014-03-12 Thread Daniel P. Berrange
On Wed, Mar 12, 2014 at 01:03:26PM +0100, Stefan Bader wrote:
 I have been looking into a bug report (see BugLink) which reported
 libvirt to fail starting inside a Xen guest. Upon further investigation
 I found that some tools that help monitoring Xen guests will mount
 xenfs to /proc/xen. This will create a capabilities files there even
 if the guest is not dom0. However it will return nothing when reading
 from it.
 
 Ian, just to sanity check myself. I looked at the xenfs code and to
 me there only seem to be those two outcomes (either control_d for
 running in dom0 or notrhing if not).
 
 With the following patch applied, libvirt starts up correctly in
 the normal guests (with xenfs mounted) without initializing libxl.
 And also in dom0 where it still enables the libxl driver (if the
 xl toolstack is selected).
 
 -Stefan
 
 From f11949caca6dfe1a802472a2a6d4fe760115ccc6 Mon Sep 17 00:00:00 2001
 From: Stefan Bader stefan.ba...@canonical.com
 Date: Wed, 12 Mar 2014 11:37:16 +0100
 Subject: [PATCH] libxl: Check for control_d string to decide about dom0
 
 As soon as any guest mounts xenfs to /proc/xen, there is a capabilities
 file in that directory. However it returns nothing when reading from it.
 Change the test to actually check the contents of the file.
 
 BugLink: http://bugs.launchpad.net/bugs/1248025
 
 Signed-off-by: Stefan Bader stefan.ba...@canonical.com
 ---
  src/libxl/libxl_driver.c |   14 --
  1 file changed, 12 insertions(+), 2 deletions(-)
 
 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index 65d80a2..844e828 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -944,6 +944,7 @@ libxlDriverShouldLoad(bool privileged)
  bool ret = false;
  virCommandPtr cmd;
  int status;
 +char *output = NULL;
  
  /* Don't load if non-root */
  if (!privileged) {
 @@ -951,8 +952,17 @@ libxlDriverShouldLoad(bool privileged)
  return ret;
  }
  
 -/* Don't load if not running on a Xen control domain (dom0) */
 -if (!virFileExists(/proc/xen/capabilities)) {
 +/*
 + * Don't load if not running on a Xen control domain (dom0). It is not
 + * sufficient to check for the file to exist as any guest can mount
 + * xenfs to /proc/xen.
 + */
 +status = virFileReadAll(/proc/xen/capabilities, 10. output);
 +if (status = 0) {
 +status = strncmp(output, control_d, 9);
 +}
 +VIR_FREE(output);
 +if (status) {
  VIR_INFO(No Xen capabilities detected, probably not running 
   in a Xen Dom0.  Disabling libxenlight driver);

This looks reasonable to me. I recall that the initscripts for the old
XenD daemon would also check for this file to decide whether to start
or not.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] libvirt: [PATCH] libxl: Check for control_d string to decide about dom0

2014-03-12 Thread Ian Campbell
On Wed, 2014-03-12 at 13:03 +0100, Stefan Bader wrote:
 I have been looking into a bug report (see BugLink) which reported
 libvirt to fail starting inside a Xen guest. Upon further investigation
 I found that some tools that help monitoring Xen guests will mount
 xenfs to /proc/xen. This will create a capabilities files there even
 if the guest is not dom0. However it will return nothing when reading
 from it.

This seems consistent with the xencommons initscript which does:
# run this script only in dom0:
# no capabilities file in xenlinux domU kernel
# empty capabilities file in pv_ops domU kernel
if test -f /proc/xen/capabilities  \
   ! grep -q control_d /proc/xen/capabilities ; then
exit 0
fi

 
 Ian, just to sanity check myself. I looked at the xenfs code and to
 me there only seem to be those two outcomes (either control_d for
 running in dom0 or notrhing if not).
 
 With the following patch applied, libvirt starts up correctly in
 the normal guests (with xenfs mounted) without initializing libxl.
 And also in dom0 where it still enables the libxl driver (if the
 xl toolstack is selected).
 
 -Stefan
 
 From f11949caca6dfe1a802472a2a6d4fe760115ccc6 Mon Sep 17 00:00:00 2001
 From: Stefan Bader stefan.ba...@canonical.com
 Date: Wed, 12 Mar 2014 11:37:16 +0100
 Subject: [PATCH] libxl: Check for control_d string to decide about dom0
 
 As soon as any guest mounts xenfs to /proc/xen, there is a capabilities
 file in that directory. However it returns nothing when reading from it.
 Change the test to actually check the contents of the file.
 
 BugLink: http://bugs.launchpad.net/bugs/1248025
 
 Signed-off-by: Stefan Bader stefan.ba...@canonical.com
 ---
  src/libxl/libxl_driver.c |   14 --
  1 file changed, 12 insertions(+), 2 deletions(-)
 
 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index 65d80a2..844e828 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -944,6 +944,7 @@ libxlDriverShouldLoad(bool privileged)
  bool ret = false;
  virCommandPtr cmd;
  int status;
 +char *output = NULL;
  
  /* Don't load if non-root */
  if (!privileged) {
 @@ -951,8 +952,17 @@ libxlDriverShouldLoad(bool privileged)
  return ret;
  }
  
 -/* Don't load if not running on a Xen control domain (dom0) */
 -if (!virFileExists(/proc/xen/capabilities)) {
 +/*
 + * Don't load if not running on a Xen control domain (dom0). It is not
 + * sufficient to check for the file to exist as any guest can mount
 + * xenfs to /proc/xen.
 + */
 +status = virFileReadAll(/proc/xen/capabilities, 10. output);

Is this . supposed to be a ,?

 +if (status = 0) {
 +status = strncmp(output, control_d, 9);
 +}
 +VIR_FREE(output);
 +if (status) {
  VIR_INFO(No Xen capabilities detected, probably not running 
   in a Xen Dom0.  Disabling libxenlight driver);
  


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


Re: [libvirt] libvirt: [PATCH] libxl: Check for control_d string to decide about dom0

2014-03-12 Thread Stefan Bader
On 12.03.2014 13:08, Ian Campbell wrote:
 On Wed, 2014-03-12 at 13:03 +0100, Stefan Bader wrote:
 I have been looking into a bug report (see BugLink) which reported
 libvirt to fail starting inside a Xen guest. Upon further investigation
 I found that some tools that help monitoring Xen guests will mount
 xenfs to /proc/xen. This will create a capabilities files there even
 if the guest is not dom0. However it will return nothing when reading
 from it.
 
 This seems consistent with the xencommons initscript which does:
 # run this script only in dom0:
 # no capabilities file in xenlinux domU kernel
 # empty capabilities file in pv_ops domU kernel
 if test -f /proc/xen/capabilities  \
! grep -q control_d /proc/xen/capabilities ; then
 exit 0
 fi
 

 Ian, just to sanity check myself. I looked at the xenfs code and to
 me there only seem to be those two outcomes (either control_d for
 running in dom0 or notrhing if not).

 With the following patch applied, libvirt starts up correctly in
 the normal guests (with xenfs mounted) without initializing libxl.
 And also in dom0 where it still enables the libxl driver (if the
 xl toolstack is selected).

 -Stefan

 From f11949caca6dfe1a802472a2a6d4fe760115ccc6 Mon Sep 17 00:00:00 2001
 From: Stefan Bader stefan.ba...@canonical.com
 Date: Wed, 12 Mar 2014 11:37:16 +0100
 Subject: [PATCH] libxl: Check for control_d string to decide about dom0

 As soon as any guest mounts xenfs to /proc/xen, there is a capabilities
 file in that directory. However it returns nothing when reading from it.
 Change the test to actually check the contents of the file.

 BugLink: http://bugs.launchpad.net/bugs/1248025

 Signed-off-by: Stefan Bader stefan.ba...@canonical.com
 ---
  src/libxl/libxl_driver.c |   14 --
  1 file changed, 12 insertions(+), 2 deletions(-)

 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index 65d80a2..844e828 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -944,6 +944,7 @@ libxlDriverShouldLoad(bool privileged)
  bool ret = false;
  virCommandPtr cmd;
  int status;
 +char *output = NULL;
  
  /* Don't load if non-root */
  if (!privileged) {
 @@ -951,8 +952,17 @@ libxlDriverShouldLoad(bool privileged)
  return ret;
  }
  
 -/* Don't load if not running on a Xen control domain (dom0) */
 -if (!virFileExists(/proc/xen/capabilities)) {
 +/*
 + * Don't load if not running on a Xen control domain (dom0). It is not
 + * sufficient to check for the file to exist as any guest can mount
 + * xenfs to /proc/xen.
 + */
 +status = virFileReadAll(/proc/xen/capabilities, 10. output);
 
 Is this . supposed to be a ,?

Darn, I thought I had fixed that. Unfortunately in the wrong place. Yes, that
should be a ,. Sorry

-Stefan
 
 +if (status = 0) {
 +status = strncmp(output, control_d, 9);
 +}
 +VIR_FREE(output);
 +if (status) {
  VIR_INFO(No Xen capabilities detected, probably not running 
   in a Xen Dom0.  Disabling libxenlight driver);
  
 
 




signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] docs: add VMmanager to web apps

2014-03-12 Thread Eric Blake
On 03/12/2014 01:30 AM, Martin Kletzander wrote:
 This is a request for adding a VMmanager application as requested and
 described by Ksenya Phil.
 
 Signed-off-by: Ksenya Phil philka2...@mail.ru
 Signed-off-by: Martin Kletzander mklet...@redhat.com
 ---
  docs/apps.html.in | 9 +
  1 file changed, 9 insertions(+)

ACK

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 0/7] Test parsing of iscsiadm output

2014-03-12 Thread Ján Tomko
Introduce virCommandSetMockOutputFile for faking output of
asynchronous commands and use it to test parsing of iscsiadm
output in virStorageBackendISCSISession and
virStorageBackendISCSIScanTargets

Ján Tomko (7):
  Change virStorageBackendISCSISession 'probe' arg to bool
  Introduce virStoragePoolSourceDeviceClear
  Use size_t for ndevice in pool source definition
  Introduce vircommandpriv.h for functions used by tests
  Add virCommandSetMockOutputFile
  Add test for virStorageBackendISCSISession
  Add a test for virStorageBackendISCSIScanTargets

 src/Makefile.am  |   5 +-
 src/conf/storage_conf.c  |  36 ++---
 src/conf/storage_conf.h  |   3 +-
 src/libvirt_private.syms |   2 +
 src/storage/storage_backend_iscsi.c  |  14 +-
 src/storage/storage_backend_iscsipriv.h  |  36 +
 src/util/vircommand.c|  35 -
 src/util/vircommand.h|   2 -
 src/util/vircommandpriv.h|  29 
 tests/Makefile.am|  14 +-
 tests/storageiscsidata/iscsiadm_sendtargets  |   6 +
 tests/storageiscsidata/iscsiadm_session  |   6 +
 tests/storageiscsidata/iscsiadm_session_nonflash |   6 +
 tests/storageiscsitest.c | 186 +++
 tests/virkmodtest.c  |   2 +-
 tests/virnetdevbandwidthtest.c   |   2 +-
 16 files changed, 350 insertions(+), 34 deletions(-)
 create mode 100644 src/storage/storage_backend_iscsipriv.h
 create mode 100644 src/util/vircommandpriv.h
 create mode 100644 tests/storageiscsidata/iscsiadm_sendtargets
 create mode 100644 tests/storageiscsidata/iscsiadm_session
 create mode 100644 tests/storageiscsidata/iscsiadm_session_nonflash
 create mode 100644 tests/storageiscsitest.c

-- 
1.8.3.2

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

[libvirt] [PATCH 1/7] Change virStorageBackendISCSISession 'probe' arg to bool

2014-03-12 Thread Ján Tomko
It quacks like a bool.
---
 src/storage/storage_backend_iscsi.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/storage/storage_backend_iscsi.c 
b/src/storage/storage_backend_iscsi.c
index ada6c48..531d044 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -92,7 +92,7 @@ virStorageBackendISCSIExtractSession(virStoragePoolObjPtr 
pool,
 
 static char *
 virStorageBackendISCSISession(virStoragePoolObjPtr pool,
-  int probe)
+  bool probe)
 {
 /*
  * # iscsiadm --mode session
@@ -646,7 +646,7 @@ virStorageBackendISCSICheckPool(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 return -1;
 }
 
-if ((session = virStorageBackendISCSISession(pool, 1)) != NULL) {
+if ((session = virStorageBackendISCSISession(pool, true)) != NULL) {
 *isActive = true;
 VIR_FREE(session);
 }
@@ -806,7 +806,7 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
 return -1;
 }
 
-if ((session = virStorageBackendISCSISession(pool, 1)) == NULL) {
+if ((session = virStorageBackendISCSISession(pool, true)) == NULL) {
 if ((portal = virStorageBackendISCSIPortal(pool-def-source)) == 
NULL)
 goto cleanup;
 /*
@@ -843,7 +843,7 @@ virStorageBackendISCSIRefreshPool(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 
 pool-def-allocation = pool-def-capacity = pool-def-available = 0;
 
-if ((session = virStorageBackendISCSISession(pool, 0)) == NULL)
+if ((session = virStorageBackendISCSISession(pool, false)) == NULL)
 goto cleanup;
 if (virStorageBackendISCSIRescanLUNs(pool, session)  0)
 goto cleanup;
-- 
1.8.3.2

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


[libvirt] [PATCH 6/7] Add test for virStorageBackendISCSISession

2014-03-12 Thread Ján Tomko
Parse iscsiadm output with and without the recently introduced
flashnode info. [1]

This should check that commits like 57e17a7 (fixing [2]) do
not break iscsiadm output parsing.

[1] https://github.com/mikechristie/open-iscsi/commit/181af9a
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1067173
---
 src/Makefile.am  |   3 +-
 src/storage/storage_backend_iscsi.c  |   4 +-
 src/storage/storage_backend_iscsipriv.h  |  31 ++
 tests/Makefile.am|  14 ++-
 tests/storageiscsidata/iscsiadm_session  |   6 ++
 tests/storageiscsidata/iscsiadm_session_nonflash |   6 ++
 tests/storageiscsitest.c | 115 +++
 7 files changed, 174 insertions(+), 5 deletions(-)
 create mode 100644 src/storage/storage_backend_iscsipriv.h
 create mode 100644 tests/storageiscsidata/iscsiadm_session
 create mode 100644 tests/storageiscsidata/iscsiadm_session_nonflash
 create mode 100644 tests/storageiscsitest.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 25b33a7..055af83 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -823,7 +823,8 @@ STORAGE_DRIVER_LVM_SOURCES =
\
storage/storage_backend_logical.c
 
 STORAGE_DRIVER_ISCSI_SOURCES = \
-   storage/storage_backend_iscsi.h storage/storage_backend_iscsi.c
+   storage/storage_backend_iscsi.h storage/storage_backend_iscsi.c 
\
+   storage/storage_backend_iscsipriv.h
 
 STORAGE_DRIVER_SCSI_SOURCES =  \
storage/storage_backend_scsi.h storage/storage_backend_scsi.c
diff --git a/src/storage/storage_backend_iscsi.c 
b/src/storage/storage_backend_iscsi.c
index 531d044..143412d 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -36,7 +36,7 @@
 #include driver.h
 #include virerror.h
 #include storage_backend_scsi.h
-#include storage_backend_iscsi.h
+#include storage_backend_iscsipriv.h
 #include viralloc.h
 #include virlog.h
 #include virfile.h
@@ -90,7 +90,7 @@ virStorageBackendISCSIExtractSession(virStoragePoolObjPtr 
pool,
 return 0;
 }
 
-static char *
+char *
 virStorageBackendISCSISession(virStoragePoolObjPtr pool,
   bool probe)
 {
diff --git a/src/storage/storage_backend_iscsipriv.h 
b/src/storage/storage_backend_iscsipriv.h
new file mode 100644
index 000..25a2509
--- /dev/null
+++ b/src/storage/storage_backend_iscsipriv.h
@@ -0,0 +1,31 @@
+/*
+ * storage_backend_iscsipriv.h: functions for thesting the iscsi backend
+ *
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * http://www.gnu.org/licenses/.
+ */
+
+#ifndef __VIR_STORAGE_BACKEND_ISCSIPRIV_H__
+# define __VIR_STORAGE_BACKEND_ISCSIPRIV_H__
+
+# include storage_backend_iscsi.h
+
+char *
+virStorageBackendISCSISession(virStoragePoolObjPtr pool,
+  bool probe);
+
+
+#endif /* __VIR_STORAGE_BACKEND_ISCSIPRIV_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3267ad3..b4147ed 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -105,6 +105,7 @@ EXTRA_DIST =\
storagepoolschematest \
storagepoolxml2xmlin \
storagepoolxml2xmlout \
+   storageiscsidata \
storagevolxml2argvdata \
storagevolschemadata \
storagevolschematest \
@@ -247,7 +248,8 @@ endif WITH_STORAGE_SHEEPDOG
 test_programs += nwfilterxml2xmltest
 
 if WITH_STORAGE
-test_programs += storagevolxml2argvtest
+test_programs += storagevolxml2argvtest \
+   storageiscsitest
 endif WITH_STORAGE
 
 if WITH_LINUX
@@ -642,8 +644,16 @@ storagevolxml2argvtest_SOURCES = \
 testutils.c testutils.h
 storagevolxml2argvtest_LDADD = \
../src/libvirt_driver_storage_impl.la $(LDADDS)
+
+storageiscsitest_SOURCES = \
+   storageiscsitest.c \
+   testutils.c testutils.h
+storageiscsitest_LDADD = \
+   ../src/libvirt_driver_storage_impl.la $(LDADDS)
+
 else ! WITH_STORAGE
-EXTRA_DIST += storagevolxml2argvtest.c
+EXTRA_DIST += storagevolxml2argvtest.c \
+   storageiscsitest.c
 endif ! WITH_STORAGE
 
 storagevolxml2xmltest_SOURCES = \
diff --git a/tests/storageiscsidata/iscsiadm_session 
b/tests/storageiscsidata/iscsiadm_session
new file mode 

[libvirt] [PATCH 3/7] Use size_t for ndevice in pool source definition

2014-03-12 Thread Ján Tomko
This allows it to be used by the VIR_*_ELEMENT macros.

Also use them for parsing the definiton and remove the redundant
freeing of 'nodeset' before jumping to the cleanup label.
---
 src/conf/storage_conf.c | 23 ++-
 src/conf/storage_conf.h |  2 +-
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9c2962f..39fb416 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -642,23 +642,20 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
 if (nsource  0)
 goto cleanup;
 
-if (nsource  0) {
-if (VIR_ALLOC_N(source-devices, nsource)  0) {
-VIR_FREE(nodeset);
+for (i = 0; i  nsource; i++) {
+virStoragePoolSourceDevice dev = { .path = NULL };
+dev.path = virXMLPropString(nodeset[i], path);
+
+if (dev.path == NULL) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(missing storage pool source device path));
 goto cleanup;
 }
 
-for (i = 0; i  nsource; i++) {
-char *path = virXMLPropString(nodeset[i], path);
-if (path == NULL) {
-VIR_FREE(nodeset);
-virReportError(VIR_ERR_XML_ERROR, %s,
-   _(missing storage pool source device path));
-goto cleanup;
-}
-source-devices[i].path = path;
+if (VIR_APPEND_ELEMENT(source-devices, source-ndevice, dev)  0) {
+virStoragePoolSourceDeviceClear(dev);
+goto cleanup;
 }
-source-ndevice = nsource;
 }
 
 source-dir = virXPathString(string(./dir/@path), ctxt);
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 636c9aa..e410f41 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -266,7 +266,7 @@ struct _virStoragePoolSource {
 virStoragePoolSourceHostPtr hosts;
 
 /* And either one or more devices ... */
-int ndevice;
+size_t ndevice;
 virStoragePoolSourceDevicePtr devices;
 
 /* Or a directory */
-- 
1.8.3.2

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


[libvirt] [PATCH 7/7] Add a test for virStorageBackendISCSIScanTargets

2014-03-12 Thread Ján Tomko
Check the iscsiadm output parsing by reading it from a file.
---
 src/storage/storage_backend_iscsi.c |  2 +-
 src/storage/storage_backend_iscsipriv.h |  5 ++
 tests/storageiscsidata/iscsiadm_sendtargets |  6 +++
 tests/storageiscsitest.c| 71 +
 4 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 tests/storageiscsidata/iscsiadm_sendtargets

diff --git a/src/storage/storage_backend_iscsi.c 
b/src/storage/storage_backend_iscsi.c
index 143412d..316fb1b 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -470,7 +470,7 @@ virStorageBackendISCSITargetAutologin(const char *portal,
 }
 
 
-static int
+int
 virStorageBackendISCSIScanTargets(const char *portal,
   const char *initiatoriqn,
   size_t *ntargetsret,
diff --git a/src/storage/storage_backend_iscsipriv.h 
b/src/storage/storage_backend_iscsipriv.h
index 25a2509..897bfb4 100644
--- a/src/storage/storage_backend_iscsipriv.h
+++ b/src/storage/storage_backend_iscsipriv.h
@@ -27,5 +27,10 @@ char *
 virStorageBackendISCSISession(virStoragePoolObjPtr pool,
   bool probe);
 
+int
+virStorageBackendISCSIScanTargets(const char *portal,
+  const char *initiatoriqn,
+  size_t *ntargetsret,
+  char ***targetsret);
 
 #endif /* __VIR_STORAGE_BACKEND_ISCSIPRIV_H__ */
diff --git a/tests/storageiscsidata/iscsiadm_sendtargets 
b/tests/storageiscsidata/iscsiadm_sendtargets
new file mode 100644
index 000..acea8ee
--- /dev/null
+++ b/tests/storageiscsidata/iscsiadm_sendtargets
@@ -0,0 +1,6 @@
+10.20.30.40:3260,1 iqn.2004-06.example:example1:iscsi.test
+10.20.30.40:3260,1 iqn.2005-05.example:example1:iscsi.hello
+10.20.30.40:3260,1 iqn.2006-04.example:example1:iscsi.world
+10.20.30.40:3260,1 iqn.2007-04.example:example1:iscsi.foo
+10.20.30.40:3260,1 iqn.2008-04.example:example1:iscsi.bar
+10.20.30.40:3260,1 iqn.2009-04.example:example1:iscsi.seven
diff --git a/tests/storageiscsitest.c b/tests/storageiscsitest.c
index 212f524..304bb12 100644
--- a/tests/storageiscsitest.c
+++ b/tests/storageiscsitest.c
@@ -86,6 +86,60 @@ cleanup:
 return ret;
 }
 
+struct testScanTargetsInfo {
+const char *fake_cmd_output;
+const char *portal;
+const char **expected_targets;
+size_t nexpected;
+};
+
+static int
+testISCSIScanTargets(const void *data)
+{
+const struct testScanTargetsInfo *info = data;
+size_t ntargets = 0;
+char **targets = NULL;
+char *cmdout = NULL;
+int ret = -1;
+size_t i;
+
+if (virAsprintf(cmdout, %s/storageiscsidata/%s, abs_srcdir,
+info-fake_cmd_output)  0)
+goto cleanup;
+
+virCommandSetMockOutputFile(cmdout);
+
+if (virStorageBackendISCSIScanTargets(info-portal, NULL,
+  ntargets, targets)  0)
+goto cleanup;
+
+if (info-nexpected != ntargets) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   Expected %zu targets, got %zu,
+   info-nexpected, ntargets);
+goto cleanup;
+}
+
+for (i = 0; i  ntargets; i++) {
+if (STRNEQ(info-expected_targets[i], targets[i])) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   Expected target '%s', got '%s',
+   info-expected_targets[i], targets[i]);
+goto cleanup;
+}
+}
+
+ret = 0;
+
+cleanup:
+virCommandSetMockOutputFile(NULL);
+for (i = 0; i  ntargets; i++)
+VIR_FREE(targets[i]);
+VIR_FREE(targets);
+VIR_FREE(cmdout);
+return ret;
+}
+
 static int
 mymain(void)
 {
@@ -107,6 +161,23 @@ mymain(void)
 DO_SESSION_TEST(iqn.2009-04.example:example1:iscsi.seven, 7);
 DO_SESSION_TEST(iqn.2009-04.example:example1:iscsi.eight, NULL);
 
+const char *targets[] = {
+iqn.2004-06.example:example1:iscsi.test,
+iqn.2005-05.example:example1:iscsi.hello,
+iqn.2006-04.example:example1:iscsi.world,
+iqn.2007-04.example:example1:iscsi.foo,
+iqn.2008-04.example:example1:iscsi.bar,
+iqn.2009-04.example:example1:iscsi.seven
+};
+struct testScanTargetsInfo infoTargets = {
+.fake_cmd_output = iscsiadm_sendtargets,
+.portal = 10.20.30.45:3260,1,
+.expected_targets = targets,
+.nexpected = ARRAY_CARDINALITY(targets),
+};
+if (virtTestRun(ISCSI scan targets, testISCSIScanTargets, infoTargets) 
 0)
+rv = -1;
+
 if (rv  0)
 return EXIT_FAILURE;
 return EXIT_SUCCESS;
-- 
1.8.3.2

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


Re: [libvirt] [PATCH] qemu.conf: Mention virtlockd in @lock_manager description

2014-03-12 Thread Eric Blake
On 03/12/2014 01:59 AM, Michal Privoznik wrote:
 When I played with virtlockd I was stunned by lacking
 documentation. My frustration got bigger when I had to
 read the patches to get the correct value to set in
 qemu.conf.
 
 Moreover, from pure libvirt-pride  I'm changing commented
 value from sanlock to lockd. We want to favor our own
 implementation after all.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/qemu/qemu.conf | 10 ++
  1 file changed, 6 insertions(+), 4 deletions(-)
 
 diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
 index e436084..f0e802f 100644
 --- a/src/qemu/qemu.conf
 +++ b/src/qemu/qemu.conf
 @@ -402,11 +402,13 @@
  #allow_disk_format_probing = 1
  
  
 -# To enable 'Sanlock' project based locking of the file
 -# content (to prevent two VMs writing to the same
 -# disk), uncomment this
 +# In order to prevent accidentally starting two domains that
 +# share one writable disk, libvirt offers two approaches for
 +# locking files. The first one is sanlock, the other one,
 +# virtlockd, is then our own implementation. Accepted values

I'm not sure about that wording of that sentence.  Maybe:

..offers two approaches for locking files: 'sanlock' uses the external
sanlock daemon, and 'virtlockd' is implemented as part of libvirt.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 5/7] Add virCommandSetMockOutputFile

2014-03-12 Thread Ján Tomko
After this file is set, all commands executed will be replaced by
cat file.

This is useful for testing functions that parse output of asynchronous
commands.
---
 src/libvirt_private.syms  |  1 +
 src/util/vircommand.c | 33 +
 src/util/vircommandpriv.h |  1 +
 3 files changed, 35 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ea16cf5..8c15519 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1123,6 +1123,7 @@ virCommandSetInputFD;
 virCommandSetMaxFiles;
 virCommandSetMaxMemLock;
 virCommandSetMaxProcesses;
+virCommandSetMockOutputFile;
 virCommandSetOutputBuffer;
 virCommandSetOutputFD;
 virCommandSetPidFile;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 7a799f2..f954141 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -133,6 +133,9 @@ struct _virCommand {
 /* See virCommandSetDryRun for description for this variable */
 static virBufferPtr dryRunBuffer;
 
+/* See virCommandSetMockOutputFile */
+static const char *mockOutputFile;
+
 /*
  * virCommandFDIsSet:
  * @fd: FD to test
@@ -2278,6 +2281,19 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
 goto cleanup;
 }
 
+if (mockOutputFile) {
+VIR_DEBUG(Replacing %s with cat '%s', str, mockOutputFile);
+for (i = 0; i  cmd-nargs; i++)
+VIR_FREE(cmd-args[i]);
+cmd-nargs = 0;
+
+virCommandAddArgList(cmd, cat, mockOutputFile, NULL);
+if (cmd-has_error) {
+virReportOOMError();
+goto cleanup;
+}
+}
+
 VIR_DEBUG(About to run %s, str ? str : cmd-args[0]);
 ret = virExec(cmd);
 VIR_DEBUG(Command result %d, with PID %d,
@@ -2729,3 +2745,20 @@ virCommandSetDryRun(virBufferPtr buf)
 {
 dryRunBuffer = buf;
 }
+
+/**
+ * virCommandSetMockOutputFile:
+ * @path path to the file that should be concatenated
+ *   instead of running a command
+ *
+ * After calling this function, every command run will be replaced
+ * by 'cat @path'. This is useful for testing functions that
+ * parse output of asynchronous commands.
+ *
+ * NULL argument restores normal behavior.
+ */
+void
+virCommandSetMockOutputFile(const char *path)
+{
+mockOutputFile = path;
+}
diff --git a/src/util/vircommandpriv.h b/src/util/vircommandpriv.h
index 2fbf3de..4d83f00 100644
--- a/src/util/vircommandpriv.h
+++ b/src/util/vircommandpriv.h
@@ -25,4 +25,5 @@
 # include vircommand.h
 
 void virCommandSetDryRun(virBufferPtr buf);
+void virCommandSetMockOutputFile(const char *path);
 #endif /* __VIR_COMMAND_PRIV_H__ */
-- 
1.8.3.2

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


[libvirt] [PATCH 4/7] Introduce vircommandpriv.h for functions used by tests

2014-03-12 Thread Ján Tomko
So far it's just virCommandSetDryRun.
---
 src/Makefile.am|  2 +-
 src/util/vircommand.c  |  2 +-
 src/util/vircommand.h  |  2 --
 src/util/vircommandpriv.h  | 28 
 tests/virkmodtest.c|  2 +-
 tests/virnetdevbandwidthtest.c |  2 +-
 6 files changed, 32 insertions(+), 6 deletions(-)
 create mode 100644 src/util/vircommandpriv.h

diff --git a/src/Makefile.am b/src/Makefile.am
index a88b258..25b33a7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -91,7 +91,7 @@ UTIL_SOURCES =
\
util/virbuffer.c util/virbuffer.h   \
util/vircgroup.c util/vircgroup.h util/vircgrouppriv.h  \
util/virclosecallbacks.c util/virclosecallbacks.h   
\
-   util/vircommand.c util/vircommand.h \
+   util/vircommand.c util/vircommand.h util/vircommandpriv.h \
util/virconf.c util/virconf.h   \
util/vircrypto.c util/vircrypto.h   \
util/virdbus.c util/virdbus.h util/virdbuspriv.h\
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index db4166f..7a799f2 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -40,7 +40,7 @@
 # include sys/apparmor.h
 #endif
 
-#include vircommand.h
+#include vircommandpriv.h
 #include viralloc.h
 #include virerror.h
 #include virutil.h
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index 7485edc..10b4fa2 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -186,6 +186,4 @@ void virCommandAbort(virCommandPtr cmd);
 void virCommandFree(virCommandPtr cmd);
 
 void virCommandDoAsyncIO(virCommandPtr cmd);
-
-void virCommandSetDryRun(virBufferPtr buf);
 #endif /* __VIR_COMMAND_H__ */
diff --git a/src/util/vircommandpriv.h b/src/util/vircommandpriv.h
new file mode 100644
index 000..2fbf3de
--- /dev/null
+++ b/src/util/vircommandpriv.h
@@ -0,0 +1,28 @@
+/*
+ * vircommandpriv.h: Functions for testing virCommand APIs
+ *
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * http://www.gnu.org/licenses/.
+ *
+ */
+
+#ifndef __VIR_COMMAND_PRIV_H__
+# define __VIR_COMMAND_PRIV_H__
+
+# include vircommand.h
+
+void virCommandSetDryRun(virBufferPtr buf);
+#endif /* __VIR_COMMAND_PRIV_H__ */
diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c
index c6f5a72..e23ef67 100644
--- a/tests/virkmodtest.c
+++ b/tests/virkmodtest.c
@@ -23,7 +23,7 @@
 #ifdef __linux__
 
 # include stdlib.h
-# include vircommand.h
+# include vircommandpriv.h
 # include virkmod.h
 # include virstring.h
 
diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c
index 073fdf8..ab5d312 100644
--- a/tests/virnetdevbandwidthtest.c
+++ b/tests/virnetdevbandwidthtest.c
@@ -21,7 +21,7 @@
 #include config.h
 
 #include testutils.h
-#include vircommand.h
+#include vircommandpriv.h
 #include virnetdevbandwidth.h
 #include netdev_bandwidth_conf.c
 
-- 
1.8.3.2

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


[libvirt] [PATCH 4/7] Add ability to register callback for virCommand dry run

2014-03-12 Thread Daniel P. Berrange
To allow for fault injection of the virCommand dry run,
add the ability to register a callback. The callback will
be passed the argv, env and stdin buffer and is expected
to return the exit status and optionally fill stdout and
stderr buffers.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/util/vircommand.c  | 47 +++---
 src/util/vircommand.h  | 12 ++-
 tests/virkmodtest.c|  8 +++
 tests/virnetdevbandwidthtest.c |  3 ++-
 4 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index db4166f..42d0182 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -132,6 +132,9 @@ struct _virCommand {
 
 /* See virCommandSetDryRun for description for this variable */
 static virBufferPtr dryRunBuffer;
+static virCommandDryRunCallback dryRunCallback;
+static void *dryRunOpaque;
+static int dryRunStatus;
 
 /*
  * virCommandFDIsSet:
@@ -2264,16 +2267,25 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
 }
 
 str = virCommandToString(cmd);
-if (dryRunBuffer) {
+if (dryRunBuffer || dryRunCallback) {
+dryRunStatus = 0;
 if (!str) {
 /* error already reported by virCommandToString */
 goto cleanup;
 }
 
-VIR_DEBUG(Dry run requested, appending stringified 
-  command to dryRunBuffer=%p, dryRunBuffer);
-virBufferAdd(dryRunBuffer, str, -1);
-virBufferAddChar(dryRunBuffer, '\n');
+if (dryRunBuffer) {
+VIR_DEBUG(Dry run requested, appending stringified 
+  command to dryRunBuffer=%p, dryRunBuffer);
+virBufferAdd(dryRunBuffer, str, -1);
+virBufferAddChar(dryRunBuffer, '\n');
+}
+if (dryRunCallback) {
+dryRunCallback((const char *const*)cmd-args,
+   (const char *const*)cmd-env,
+   cmd-inbuf, cmd-outbuf, cmd-errbuf,
+   dryRunStatus, dryRunOpaque);
+}
 ret = 0;
 goto cleanup;
 }
@@ -2353,10 +2365,11 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
 return -1;
 }
 
-if (dryRunBuffer) {
-VIR_DEBUG(Dry run requested, claiming success);
+if (dryRunBuffer || dryRunCallback) {
+VIR_DEBUG(Dry run requested, returning status %d,
+  dryRunStatus);
 if (exitstatus)
-*exitstatus = 0;
+*exitstatus = dryRunStatus;
 return 0;
 }
 
@@ -2701,6 +2714,7 @@ virCommandDoAsyncIO(virCommandPtr cmd)
 /**
  * virCommandSetDryRun:
  * @buf: buffer to store stringified commands
+ * @callback: callback to process input/output/args
  *
  * Sometimes it's desired to not actually run given command, but
  * see its string representation without having to change the
@@ -2709,8 +2723,13 @@ virCommandDoAsyncIO(virCommandPtr cmd)
  * virCommandRun* API. The virCommandSetDryRun allows you to
  * modify this behavior: once called, every call to
  * virCommandRun* results in command string representation being
- * appended to @buf instead of being executed. the strings are
- * escaped for a shell and separated by a newline. For example:
+ * appended to @buf instead of being executed. If @callback is
+ * provided, then it is invoked with the argv, env and stdin
+ * data string for the command. It is expected to fill the stdout
+ * and stderr data strings and exit status variables.
+ *
+ * The strings stored in @buf are escaped for a shell and
+ * separated by a newline. For example:
  *
  * virBuffer buffer = VIR_BUFFER_INITIALIZER;
  * virCommandSetDryRun(buffer);
@@ -2722,10 +2741,14 @@ virCommandDoAsyncIO(virCommandPtr cmd)
  *
  * /bin/echo 'Hello world'\n
  *
- * To cancel this effect pass NULL.
+ * To cancel this effect pass NULL for @buf and @callback.
  */
 void
-virCommandSetDryRun(virBufferPtr buf)
+virCommandSetDryRun(virBufferPtr buf,
+virCommandDryRunCallback cb,
+void *opaque)
 {
 dryRunBuffer = buf;
+dryRunCallback = cb;
+dryRunOpaque = opaque;
 }
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index 7485edc..9405f5f 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -187,5 +187,15 @@ void virCommandFree(virCommandPtr cmd);
 
 void virCommandDoAsyncIO(virCommandPtr cmd);
 
-void virCommandSetDryRun(virBufferPtr buf);
+typedef void (*virCommandDryRunCallback)(const char *const*args,
+ const char *const*env,
+ const char *input,
+ char **output,
+ char **error,
+ int *status,
+ void *opaque);
+
+void virCommandSetDryRun(virBufferPtr buf,
+ virCommandDryRunCallback cb,
+ 

Re: [libvirt] [PATCH] nwfilter: Add missing goto err_exit in error path

2014-03-12 Thread Ján Tomko
On 03/12/2014 12:38 PM, Stefan Berger wrote:
 From: Stefan Berger stef...@linux.vnet.ibm.com
 
 https://bugzilla.redhat.com/show_bug.cgi?id=1071095
 
 Add a missing goto err_exit in the error path where an unsupported
 value is assigned to the CTRL_IP_LEARNING key.
 
 Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
 ---
  src/nwfilter/nwfilter_gentech_driver.c | 1 +
  1 file changed, 1 insertion(+)

ACK

Jan



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 5/7] Introduce an object for managing firewall rulesets

2014-03-12 Thread Daniel P. Berrange
The network and nwfilter drivers both have a need to update
firewall rules. The currently share no code for interacting
with iptables / firewalld. The nwfilter driver is fairly
tied to the concept of creating shell scripts to execute
which makes it very hard to port to talk to firewalld via
DBus APIs.

This patch introduces a virFirewallPtr object which is able
to represent a complete sequence of rule changes, with the
ability to have multiple transactional checkpoints with
rollbacks. By formally separating the definition of the rules
to be applied from the mechanism used to apply them, it is
also possible to write a firewall engine that uses firewalld
DBus APIs natively instead of via the slow firewalld-cmd.
---
 include/libvirt/virterror.h |   1 +
 po/POTFILES.in  |   1 +
 src/Makefile.am |   2 +
 src/libvirt_private.syms|  13 +
 src/util/virerror.c |   1 +
 src/util/virfirewall.c  | 653 
 src/util/virfirewall.h  |  93 +++
 src/util/virfirewallpriv.h  |  45 +++
 tests/Makefile.am   |   7 +
 tests/testutils.c   |  18 +-
 tests/virfirewalltest.c | 619 +
 11 files changed, 1449 insertions(+), 4 deletions(-)
 create mode 100644 src/util/virfirewall.c
 create mode 100644 src/util/virfirewall.h
 create mode 100644 src/util/virfirewallpriv.h
 create mode 100644 tests/virfirewalltest.c

diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 495c121..be90797 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -122,6 +122,7 @@ typedef enum {
 VIR_FROM_SYSTEMD = 56,  /* Error from systemd code */
 VIR_FROM_BHYVE = 57,/* Error from bhyve driver */
 VIR_FROM_CRYPTO = 58,   /* Error from crypto code */
+VIR_FROM_FIREWALL = 59, /* Error from firewall */
 
 # ifdef VIR_ENUM_SENTINELS
 VIR_ERR_DOMAIN_LAST
diff --git a/po/POTFILES.in b/po/POTFILES.in
index efac7b2..17c93f5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -162,6 +162,7 @@ src/util/virdbus.c
 src/util/virdnsmasq.c
 src/util/vireventpoll.c
 src/util/virfile.c
+src/util/virfirewall.c
 src/util/virhash.c
 src/util/virhook.c
 src/util/virhostdev.c
diff --git a/src/Makefile.am b/src/Makefile.am
index a88b258..299fcdb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -102,6 +102,8 @@ UTIL_SOURCES =  
\
util/virevent.c util/virevent.h \
util/vireventpoll.c util/vireventpoll.h \
util/virfile.c util/virfile.h   \
+   util/virfirewall.c util/virfirewall.h   \
+   util/virfirewallpriv.h  \
util/virhash.c util/virhash.h   \
util/virhashcode.c util/virhashcode.h   \
util/virhook.c util/virhook.h   \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f1607cd..0524569 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1272,6 +1272,19 @@ virFileWriteStr;
 virFindFileInPath;
 
 
+# util/virfirewall.h
+virFirewallAddRule;
+virFirewallApply;
+virFirewallFree;
+virFirewallNew;
+virFirewallRuleAddArg;
+virFirewallRuleAddArgFormat;
+virFirewallRuleAddArgList;
+virFirewallRuleAddArgSet;
+virFirewallStartRollback;
+virFirewallStartTransaction;
+
+
 # util/virhash.h
 virHashAddEntry;
 virHashCreate;
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 3eb4f5d..f64c4b2 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -126,6 +126,7 @@ VIR_ENUM_IMPL(virErrorDomain, VIR_ERR_DOMAIN_LAST,
   Systemd,
   Bhyve,
   Crypto,
+  Firewall,
 )
 
 
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
new file mode 100644
index 000..f1cf678
--- /dev/null
+++ b/src/util/virfirewall.c
@@ -0,0 +1,653 @@
+/*
+ * virfirewall.c: integration with firewalls
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * http://www.gnu.org/licenses/.
+ *
+ * Authors:
+ *Daniel P. Berrange berra...@redhat.com
+ */
+
+#include config.h
+
+#define __VIR_FIREWALL_PRIV_H_ALLOW__
+
+#include stdarg.h
+
+#include viralloc.h
+#include 

[libvirt] [PATCH 1/7] Introduce a new set of helper macros for mocking symbols

2014-03-12 Thread Daniel P. Berrange
Introduce virmock.h which provides some macros to assist in
creation of LD_PRELOAD overrides. When these are used, the
LD_PRELOAD code simply has some stubs which forward to a
wrapper function inside the main test case. This means that
logic for the test no longer has to be split between the
virXXXtest.c and virXXXmock.c files. It will also make it
possible to provide some common reusable modules for mocking
code like DBus.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 tests/Makefile.am |   3 +-
 tests/virmock.h   | 298 ++
 2 files changed, 300 insertions(+), 1 deletion(-)
 create mode 100644 tests/virmock.h

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3267ad3..459e104 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -123,7 +123,8 @@ EXTRA_DIST =\
xml2sexprdata \
xml2vmxdata \
vmwareverdata \
-   .valgrind.supp
+   .valgrind.supp \
+   virmock.h
 
 test_helpers = commandhelper ssh test_conf
 test_programs = virshtest sockettest \
diff --git a/tests/virmock.h b/tests/virmock.h
new file mode 100644
index 000..762b8d6
--- /dev/null
+++ b/tests/virmock.h
@@ -0,0 +1,298 @@
+/*
+ * virmock.h: helper for mocking C functions
+ *
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * http://www.gnu.org/licenses/.
+ *
+ */
+
+#ifndef __VIR_MOCK_H__
+# define __VIR_MOCK_H__
+
+# include dlfcn.h
+# include stdlib.h
+# include stdio.h
+
+# include internal.h
+
+# define VIR_MOCK_COUNT_ARGS(...) VIR_MOCK_ARG21(__VA_ARGS__, 20, 19, 18, 17, 
16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
+# define VIR_MOCK_ARG21(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, 
_13, _14, _15, _16, _17, _18, _19, _20, _21, ...) _21
+# define VIR_MOCK_ARG_PASTE(a, b, ...) a##b(__VA_ARGS__)
+
+# define VIR_MOCK_ARGNAME(a, b) b
+# define VIR_MOCK_ARGTYPE(a, b) a
+# define VIR_MOCK_ARGTYPENAME(a, b) a b
+# define VIR_MOCK_ARGTYPENAME_UNUSED(a, b) a b ATTRIBUTE_UNUSED
+
+# define VIR_MOCK_GET_ARG2(z, a, b) z(a, b)
+# define VIR_MOCK_GET_ARG3(z, a, b, c) z(a, b)
+# define VIR_MOCK_GET_ARG4(z, a, b, c, d) z(a, b),  z(c, d)
+# define VIR_MOCK_GET_ARG5(z, a, b, c, d, e) z(a, b),  z(c, d)
+# define VIR_MOCK_GET_ARG6(z, a, b, c, d, e, f) z(a, b),  z(c, d), z(e, f)
+# define VIR_MOCK_GET_ARG7(z, a, b, c, d, e, f, g) z(a, b),  z(c, d), z(e, f)
+# define VIR_MOCK_GET_ARG8(z, a, b, c, d, e, f, g, h) z(a, b),  z(c, d), z(e, 
f), z(g, h)
+# define VIR_MOCK_GET_ARG9(z, a, b, c, d, e, f, g, h, i) z(a, b),  z(c, d), 
z(e, f), z(g, h)
+# define VIR_MOCK_GET_ARG10(z, a, b, c, d, e, f, g, h, i, j) z(a, b),  z(c, 
d), z(e, f), z(g, h), z(i, j)
+# define VIR_MOCK_GET_ARG11(z, a, b, c, d, e, f, g, h, i, j, k) z(a, b),  z(c, 
d), z(e, f), z(g, h), z(i, j)
+# define VIR_MOCK_GET_ARG12(z, a, b, c, d, e, f, g, h, i, j, k, l) z(a, b),  
z(c, d), z(e, f), z(g, h), z(i, j), z(k, l)
+# define VIR_MOCK_GET_ARG13(z, a, b, c, d, e, f, g, h, i, j, k, l, m) z(a, b), 
 z(c, d), z(e, f), z(g, h), z(i, j), z(k, l)
+# define VIR_MOCK_GET_ARG14(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n) z(a, 
b),  z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n)
+# define VIR_MOCK_GET_ARG15(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) 
z(a, b),  z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n)
+# define VIR_MOCK_GET_ARG16(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) 
z(a, b),  z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), z(o, p)
+# define VIR_MOCK_GET_ARG17(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, 
q) z(a, b),  z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), z(o, p)
+# define VIR_MOCK_GET_ARG18(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, 
q, r) z(a, b),  z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), z(o, p), 
z(q, r)
+# define VIR_MOCK_GET_ARG19(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, 
q, r, s) z(a, b),  z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), z(o, 
p), z(q, r)
+# define VIR_MOCK_GET_ARG20(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, 
q, r, s, t) z(a, b),  z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), 
z(o, p), z(q, r), z(s, t)
+# define VIR_MOCK_GET_ARG21(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, 
q, r, s, t, u) z(a, b),  z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), 
z(o, p), z(q, r), z(s, t)
+
+# define 

[libvirt] [PATCH 3/7] Switch systemd test to use generic dbus mock

2014-03-12 Thread Daniel P. Berrange
Remove the virsystemdmock.la library and instead make use
of the shared virmockdbus.la library

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 tests/Makefile.am  |  13 ++---
 tests/virsystemdmock.c | 139 -
 tests/virsystemdtest.c |  89 +--
 3 files changed, 88 insertions(+), 153 deletions(-)
 delete mode 100644 tests/virsystemdmock.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8ac200d..baf0483 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -349,7 +349,7 @@ test_libraries += libqemumonitortestutils.la \
 endif WITH_QEMU
 
 if WITH_DBUS
-test_libraries += virsystemdmock.la \
+test_libraries += \
virmockdbus.la
 endif WITH_DBUS
 
@@ -863,17 +863,12 @@ virmockdbus_la_LDFLAGS = -module -avoid-version \
 
 virsystemdtest_SOURCES = \
virsystemdtest.c testutils.h testutils.c
-virsystemdtest_CFLAGS = $(AM_CFLAGS)
+virsystemdtest_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 virsystemdtest_LDADD = $(LDADDS)
-
-virsystemdmock_la_SOURCES = \
-   virsystemdmock.c
-virsystemdmock_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
-virsystemdmock_la_LDFLAGS = -module -avoid-version \
--rpath /evil/libtool/hack/to/force/shared/lib/creation
+virsystemdtest_LDFLAGS = $(DRIVER_MODULE_LDFLAGS)
 
 else ! WITH_DBUS
-EXTRA_DIST += virdbustest.c virmockdbus.c virsystemdtest.c virsystemdmock.c
+EXTRA_DIST += virdbustest.c virmockdbus.c virsystemdtest.c
 endif ! WITH_DBUS
 
 viruritest_SOURCES = \
diff --git a/tests/virsystemdmock.c b/tests/virsystemdmock.c
deleted file mode 100644
index b4fcf6e..000
--- a/tests/virsystemdmock.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2013 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * http://www.gnu.org/licenses/.
- *
- * Author: Daniel P. Berrange berra...@redhat.com
- */
-
-#include config.h
-
-#ifdef __linux__
-# include internal.h
-
-# include stdlib.h
-
-# include dbus/dbus.h
-
-void dbus_connection_set_change_sigpipe(dbus_bool_t will_modify_sigpipe 
ATTRIBUTE_UNUSED)
-{
-}
-
-DBusConnection *dbus_bus_get(DBusBusType type ATTRIBUTE_UNUSED,
- DBusError *error ATTRIBUTE_UNUSED)
-{
-return (DBusConnection *)0x1;
-}
-
-void dbus_connection_set_exit_on_disconnect(DBusConnection *connection 
ATTRIBUTE_UNUSED,
-dbus_bool_t exit_on_disconnect 
ATTRIBUTE_UNUSED)
-{
-}
-
-
-dbus_bool_t dbus_connection_set_watch_functions(DBusConnection *connection 
ATTRIBUTE_UNUSED,
-DBusAddWatchFunction 
add_function ATTRIBUTE_UNUSED,
-DBusRemoveWatchFunction 
remove_function ATTRIBUTE_UNUSED,
-DBusWatchToggledFunction 
toggled_function ATTRIBUTE_UNUSED,
-void *data ATTRIBUTE_UNUSED,
-DBusFreeFunction 
free_data_function ATTRIBUTE_UNUSED)
-{
-return 1;
-}
-
-dbus_bool_t dbus_message_set_reply_serial(DBusMessage *message 
ATTRIBUTE_UNUSED,
-  dbus_uint32_t serial 
ATTRIBUTE_UNUSED)
-{
-return 1;
-}
-
-DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection 
*connection ATTRIBUTE_UNUSED,
-   DBusMessage *message,
-   int 
timeout_milliseconds ATTRIBUTE_UNUSED,
-   DBusError *error 
ATTRIBUTE_UNUSED)
-{
-DBusMessage *reply = NULL;
-const char *service = dbus_message_get_destination(message);
-const char *member = dbus_message_get_member(message);
-
-if (STREQ(service, org.freedesktop.machine1)) {
-if (getenv(FAIL_BAD_SERVICE)) {
-DBusMessageIter iter;
-const char *error_message = Something went wrong creating the 
machine;
-if (!(reply = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR)))
-return NULL;
-dbus_message_set_error_name(reply, 
org.freedesktop.systemd.badthing);
-dbus_message_iter_init_append(reply, iter);
-if (!dbus_message_iter_append_basic(iter,
-DBUS_TYPE_STRING,
-

[libvirt] [PATCH 2/7] Create a re-usable DBus LD_PRELOAD mock library

2014-03-12 Thread Daniel P. Berrange
A number of test suites want to mock the DBus APIs. To avoid
re-inventing the wheel create a re-usable virmockdbus.la
library for LD_PRELOAD usage.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 tests/Makefile.am   | 11 +++--
 tests/virmockdbus.c | 64 +
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 tests/virmockdbus.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 459e104..8ac200d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -349,7 +349,8 @@ test_libraries += libqemumonitortestutils.la \
 endif WITH_QEMU
 
 if WITH_DBUS
-test_libraries += virsystemdmock.la
+test_libraries += virsystemdmock.la \
+   virmockdbus.la
 endif WITH_DBUS
 
 if WITH_LINUX
@@ -854,6 +855,12 @@ virdbustest_SOURCES = \
 virdbustest_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 virdbustest_LDADD = $(LDADDS) $(DBUS_LIBS)
 
+virmockdbus_la_SOURCES = \
+   virmockdbus.c
+virmockdbus_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
+virmockdbus_la_LDFLAGS = -module -avoid-version \
+-rpath /evil/libtool/hack/to/force/shared/lib/creation
+
 virsystemdtest_SOURCES = \
virsystemdtest.c testutils.h testutils.c
 virsystemdtest_CFLAGS = $(AM_CFLAGS)
@@ -866,7 +873,7 @@ virsystemdmock_la_LDFLAGS = -module -avoid-version \
 -rpath /evil/libtool/hack/to/force/shared/lib/creation
 
 else ! WITH_DBUS
-EXTRA_DIST += virdbustest.c virsystemdtest.c virsystemdmock.c
+EXTRA_DIST += virdbustest.c virmockdbus.c virsystemdtest.c virsystemdmock.c
 endif ! WITH_DBUS
 
 viruritest_SOURCES = \
diff --git a/tests/virmockdbus.c b/tests/virmockdbus.c
new file mode 100644
index 000..8a01d9d
--- /dev/null
+++ b/tests/virmockdbus.c
@@ -0,0 +1,64 @@
+/*
+ * virmockdbus.c: mocking of dbus message send/reply
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * http://www.gnu.org/licenses/.
+ *
+ * Author: Daniel P. Berrange berra...@redhat.com
+ */
+
+#include config.h
+
+#ifdef WITH_DBUS
+# include virmock.h
+# include dbus/dbus.h
+
+VIR_MOCK_STUB_VOID_ARGS(dbus_connection_set_change_sigpipe,
+dbus_bool_t, will_modify_sigpipe)
+
+
+VIR_MOCK_STUB_RET_ARGS(dbus_bus_get,
+   DBusConnection *, (DBusConnection *)0x1,
+   DBusBusType, type,
+   DBusError *, error)
+
+VIR_MOCK_STUB_VOID_ARGS(dbus_connection_set_exit_on_disconnect,
+DBusConnection *, connection,
+dbus_bool_t, exit_on_disconnect)
+
+VIR_MOCK_STUB_RET_ARGS(dbus_connection_set_watch_functions,
+   dbus_bool_t, 1,
+   DBusConnection *, connection,
+   DBusAddWatchFunction, add_function,
+   DBusRemoveWatchFunction, remove_function,
+   DBusWatchToggledFunction, toggled_function,
+   void *, data,
+   DBusFreeFunction, free_data_function)
+
+VIR_MOCK_STUB_RET_ARGS(dbus_message_set_reply_serial,
+   dbus_bool_t, 1,
+   DBusMessage *, message,
+   dbus_uint32_t, serial)
+
+
+VIR_MOCK_LINK_RET_ARGS(dbus_connection_send_with_reply_and_block,
+   DBusMessage *,
+   DBusConnection *, connection,
+   DBusMessage *, message,
+   int, timeout_milliseconds,
+   DBusError *, error)
+
+#endif /* WITH_DBUS */
-- 
1.8.5.3

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


[libvirt] [PATCH 7/7] Convert ebtables code over to use firewall APIs

2014-03-12 Thread Daniel P. Berrange
Convert the virebtables.{c,h} files to use the new virFirewall
APIs for changing ebtables rules.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/util/virebtables.c | 187 -
 1 file changed, 46 insertions(+), 141 deletions(-)

diff --git a/src/util/virebtables.c b/src/util/virebtables.c
index 01fb15e..8fbae98 100644
--- a/src/util/virebtables.c
+++ b/src/util/virebtables.c
@@ -25,65 +25,16 @@
 
 #include config.h
 
-#include stdio.h
-#include stdlib.h
-#include stdarg.h
-#include string.h
-#include errno.h
-#include limits.h
-#include unistd.h
-#include fcntl.h
-#include sys/types.h
-#include sys/stat.h
-#include sys/wait.h
-
-#ifdef HAVE_PATHS_H
-# include paths.h
-#endif
-
 #include internal.h
 #include virebtables.h
-#include vircommand.h
 #include viralloc.h
 #include virerror.h
-#include virfile.h
 #include virlog.h
-#include virthread.h
 #include virstring.h
-#include virutil.h
+#include virfirewall.h
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
-#if HAVE_FIREWALLD
-static char *firewall_cmd_path = NULL;
-
-static int
-virEbTablesOnceInit(void)
-{
-firewall_cmd_path = virFindFileInPath(firewall-cmd);
-if (!firewall_cmd_path) {
-VIR_INFO(firewall-cmd not found on system. 
- firewalld support disabled for ebtables.);
-} else {
-virCommandPtr cmd = virCommandNew(firewall_cmd_path);
-
-virCommandAddArgList(cmd, --state, NULL);
-if (virCommandRun(cmd, NULL)  0) {
-VIR_INFO(firewall-cmd found but disabled for ebtables);
-VIR_FREE(firewall_cmd_path);
-firewall_cmd_path = NULL;
-} else {
-VIR_INFO(using firewalld for ebtables commands);
-}
-virCommandFree(cmd);
-}
-return 0;
-}
-
-VIR_ONCE_GLOBAL_INIT(virEbTables)
-
-#endif
-
 struct _ebtablesContext
 {
 char *chain;
@@ -94,84 +45,6 @@ enum {
 REMOVE,
 };
 
-
-static int ATTRIBUTE_SENTINEL
-ebtablesAddRemoveRule(const char *arg, ...)
-{
-va_list args;
-int retval = ENOMEM;
-char **argv;
-const char *s;
-int n;
-
-n = 1 + /* /sbin/ebtables  */
-2 + /*   --table foo   */
-2 + /*   --insert bar  */
-1;  /*   arg   */
-
-#if HAVE_FIREWALLD
-virEbTablesInitialize();
-if (firewall_cmd_path)
-n += 3; /* --direct --passthrough eb */
-#endif
-
-va_start(args, arg);
-while (va_arg(args, const char *))
-n++;
-
-va_end(args);
-
-if (VIR_ALLOC_N(argv, n + 1)  0)
-goto error;
-
-n = 0;
-
-#if HAVE_FIREWALLD
-if (firewall_cmd_path) {
-if (VIR_STRDUP(argv[n++], firewall_cmd_path)  0)
-goto error;
-if (VIR_STRDUP(argv[n++], --direct)  0)
-goto error;
-if (VIR_STRDUP(argv[n++], --passthrough)  0)
-goto error;
-if (VIR_STRDUP(argv[n++], eb)  0)
-goto error;
-} else
-#endif
-if (VIR_STRDUP(argv[n++], EBTABLES_PATH)  0)
-goto error;
-
-if (VIR_STRDUP(argv[n++], arg)  0)
-goto error;
-
-va_start(args, arg);
-
-while ((s = va_arg(args, const char *))) {
-if (VIR_STRDUP(argv[n++], s)  0) {
-va_end(args);
-goto error;
-}
-}
-
-va_end(args);
-
-if (virRun((const char **)argv, NULL)  0) {
-retval = errno;
-goto error;
-}
-
- error:
-if (argv) {
-n = 0;
-while (argv[n])
-VIR_FREE(argv[n++]);
-VIR_FREE(argv);
-}
-
-return retval;
-}
-
-
 /**
  * ebtablesContextNew:
  *
@@ -214,12 +87,30 @@ ebtablesContextFree(ebtablesContext *ctx)
 int
 ebtablesAddForwardPolicyReject(ebtablesContext *ctx)
 {
-ebtablesAddRemoveRule(--new-chain, ctx-chain, NULL,
-  NULL);
-ebtablesAddRemoveRule(--insert, FORWARD, --jump,
-  ctx-chain, NULL);
-return ebtablesAddRemoveRule(-P, ctx-chain, DROP,
- NULL);
+virFirewallPtr fw = NULL;
+int ret = -1;
+
+fw = virFirewallNew();
+virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS);
+virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET,
+   --new-chain, ctx-chain,
+   NULL);
+virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET,
+   --insert, FORWARD,
+   --jump, ctx-chain, NULL);
+
+virFirewallStartTransaction(fw, 0);
+virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET,
+   -P, ctx-chain, DROP,
+   NULL);
+
+if (virFirewallApply(fw)  0)
+goto cleanup;
+
+ret = 0;
+ cleanup:
+virFirewallFree(fw);
+return ret;
 }
 
 
@@ -232,12 +123,26 @@ ebtablesForwardAllowIn(ebtablesContext *ctx,
const char *macaddr,
int action)
 {
-return ebtablesAddRemoveRule(action == ADD ? --insert : --delete,
-   

[libvirt] libvirtError: this function is not supported by the connection driver: virInterfaceDefineXML

2014-03-12 Thread Sijo Jose
Hi,
Could anyone help I'm getting the following error when I tried to add a new
network interface.

DETAILS


Connection
---
import libvirt
conn = libvirt.open('qemu:///system')

Interface XML
--

interface type=bridge name=br0
  start mode=onboot/
  mtu size=1500/
  protocol family=ipv4
dhcp/
  /protocol
  bridge stp=off delay=0.01
interface type=ethernet name=eth0
  mac address=ab:bb:cc:dd:ee:ff/
/interface
interface type=ethernet name=eth1/
  /bridge
/interface





In [96]:

conn.interfaceDefineXML(interfacexml,0)

---libvirtError
 Traceback (most recent call
last)/home/saju/ipython-input-96-0536ffe3fa23 in module() 1
conn.interfaceDefineXML(br1xml,0)
/usr/lib/python2.7/dist-packages/libvirt.pyc in
interfaceDefineXML(self, xml, flags)   2750 libvirtd. 
2751 ret = libvirtmod.virInterfaceDefineXML(self._o, xml,
flags)- 2752 if ret is None:raise
libvirtError('virInterfaceDefineXML() failed', conn=self)   2753
  __tmp = virInterface(self, _obj=ret)   2754 return __tmp
libvirtError: this function is not supported by the connection driver:
virInterfaceDefineXML





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

Re: [libvirt] [PATCH] qemu: Forbid sgio support for SCSI generic host device

2014-03-12 Thread Jiri Denemark
On Fri, Mar 07, 2014 at 22:23:26 +0800, Osier Yang wrote:
 The kernel didn't support the unprivileged SGIO for SCSI generic
 device finally, and since it's unknow whether the way to support
 unprivileged SGIO for SCSI generic device will be similar as for
 SCSI block device or not, even it's simliar (I.e. via sysfs, for
 SCSI block device, it's /sys/dev/block/8\:0/queue/unpriv_sgio,
 for example), the file name might be different, So it's better not
 guess what it should be like currently.
 
 This patch removes the related code (mainly about the shareable
 checking on the sgio setting, it's not supported at all, why
 we leave checking code there? :-), and error out if sgio is
 specified in the domain config.
 ---
  src/qemu/qemu_conf.c | 87 
 
  1 file changed, 20 insertions(+), 67 deletions(-)
 
 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index 2c397b0..ad6348d 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
...
 @@ -1135,22 +1102,15 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
  } else if (dev-type == VIR_DOMAIN_DEVICE_HOSTDEV) {
  hostdev = dev-data.hostdev;
  
 -if (!hostdev-shareable ||
 -!(hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS 
 -  hostdev-source.subsys.type == 
 VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI))
 -return 0;

In the follow-up patch, you recovered just the

hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI

part. Shouldn't the other checks in this condition remain?

 -
 -if (!(hostdev_name = virSCSIDeviceGetDevName(NULL,
 - 
 hostdev-source.subsys.u.scsi.adapter,
 - 
 hostdev-source.subsys.u.scsi.bus,
 - 
 hostdev-source.subsys.u.scsi.target,
 - 
 hostdev-source.subsys.u.scsi.unit)))
 -goto cleanup;
 -
 -if (virAsprintf(hostdev_path, /dev/%s, hostdev_name)  0)
 +if (hostdev-source.subsys.u.scsi.sgio) {

In other words, should this be something like

if (hostdev-shareable 
hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS 
hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI 
hostdev-source.subsys.u.scsi.sgio) {

 +virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 +   _('sgio' is not supported for SCSI 
 + generic device yet ));
 +ret = -1;
  goto cleanup;
 +}
  
 -path = hostdev_path;
 +return 0;
  } else {
  return 0;
  }

Jirka

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


[libvirt] [PATCH 2/7] Introduce virStoragePoolSourceDeviceClear

2014-03-12 Thread Ján Tomko
Open-coding one VIR_FREE in the test suite just doesn't seem right.
---
 src/conf/storage_conf.c  | 13 +
 src/conf/storage_conf.h  |  1 +
 src/libvirt_private.syms |  1 +
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index ac323d0..9c2962f 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -357,6 +357,13 @@ 
virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapter adapter)
 }
 
 void
+virStoragePoolSourceDeviceClear(virStoragePoolSourceDevicePtr dev)
+{
+VIR_FREE(dev-freeExtents);
+VIR_FREE(dev-path);
+}
+
+void
 virStoragePoolSourceClear(virStoragePoolSourcePtr source)
 {
 size_t i;
@@ -369,10 +376,8 @@ virStoragePoolSourceClear(virStoragePoolSourcePtr source)
 }
 VIR_FREE(source-hosts);
 
-for (i = 0; i  source-ndevice; i++) {
-VIR_FREE(source-devices[i].freeExtents);
-VIR_FREE(source-devices[i].path);
-}
+for (i = 0; i  source-ndevice; i++)
+virStoragePoolSourceDeviceClear(source-devices[i]);
 VIR_FREE(source-devices);
 VIR_FREE(source-dir);
 VIR_FREE(source-name);
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 251b968..636c9aa 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -432,6 +432,7 @@ int virStoragePoolObjDeleteDef(virStoragePoolObjPtr pool);
 
 void virStorageVolDefFree(virStorageVolDefPtr def);
 void virStoragePoolSourceClear(virStoragePoolSourcePtr source);
+void virStoragePoolSourceDeviceClear(virStoragePoolSourceDevicePtr dev);
 void virStoragePoolSourceFree(virStoragePoolSourcePtr source);
 void virStoragePoolDefFree(virStoragePoolDefPtr def);
 void virStoragePoolObjFree(virStoragePoolObjPtr pool);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f1607cd..ea16cf5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -710,6 +710,7 @@ virStoragePoolObjUnlock;
 virStoragePoolSourceAdapterTypeTypeFromString;
 virStoragePoolSourceAdapterTypeTypeToString;
 virStoragePoolSourceClear;
+virStoragePoolSourceDeviceClear;
 virStoragePoolSourceFindDuplicate;
 virStoragePoolSourceFindDuplicateDevices;
 virStoragePoolSourceFree;
-- 
1.8.3.2

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


Re: [libvirt] [PATCH 4/7] Introduce vircommandpriv.h for functions used by tests

2014-03-12 Thread Daniel P. Berrange
On Wed, Mar 12, 2014 at 02:08:14PM +0100, Ján Tomko wrote:
 So far it's just virCommandSetDryRun.
 ---
  src/Makefile.am|  2 +-
  src/util/vircommand.c  |  2 +-
  src/util/vircommand.h  |  2 --
  src/util/vircommandpriv.h  | 28 
  tests/virkmodtest.c|  2 +-
  tests/virnetdevbandwidthtest.c |  2 +-
  6 files changed, 32 insertions(+), 6 deletions(-)
  create mode 100644 src/util/vircommandpriv.h
 1
 diff --git a/src/Makefile.am b/src/Makefile.am
 index a88b258..25b33a7 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -91,7 +91,7 @@ UTIL_SOURCES =  
 \
   util/virbuffer.c util/virbuffer.h   \
   util/vircgroup.c util/vircgroup.h util/vircgrouppriv.h  \
   util/virclosecallbacks.c util/virclosecallbacks.h   
 \
 - util/vircommand.c util/vircommand.h \
 + util/vircommand.c util/vircommand.h util/vircommandpriv.h \
   util/virconf.c util/virconf.h   \
   util/vircrypto.c util/vircrypto.h   \
   util/virdbus.c util/virdbus.h util/virdbuspriv.h\
 diff --git a/src/util/vircommand.c b/src/util/vircommand.c
 index db4166f..7a799f2 100644
 --- a/src/util/vircommand.c
 +++ b/src/util/vircommand.c
 @@ -40,7 +40,7 @@
  # include sys/apparmor.h
  #endif
  
 -#include vircommand.h
 +#include vircommandpriv.h
  #include viralloc.h
  #include virerror.h
  #include virutil.h
 diff --git a/src/util/vircommand.h b/src/util/vircommand.h
 index 7485edc..10b4fa2 100644
 --- a/src/util/vircommand.h
 +++ b/src/util/vircommand.h
 @@ -186,6 +186,4 @@ void virCommandAbort(virCommandPtr cmd);
  void virCommandFree(virCommandPtr cmd);
  
  void virCommandDoAsyncIO(virCommandPtr cmd);
 -
 -void virCommandSetDryRun(virBufferPtr buf);
  #endif /* __VIR_COMMAND_H__ */
 diff --git a/src/util/vircommandpriv.h b/src/util/vircommandpriv.h
 new file mode 100644
 index 000..2fbf3de
 --- /dev/null
 +++ b/src/util/vircommandpriv.h
 @@ -0,0 +1,28 @@
 +/*
 + * vircommandpriv.h: Functions for testing virCommand APIs
 + *
 + * Copyright (C) 2014 Red Hat, Inc.
 + *
 + * This library is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * This library is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with this library.  If not, see
 + * http://www.gnu.org/licenses/.
 + *
 + */
 +

Also add in

#ifndef __VIR_COMMAND_PRIV_H_ALLOW__
# error vircommandpriv.h may only be included by vircommand.c or test suites
#endif

and then make vircommand.c and any relevant test suites #define
this symbol before including the file.

 +#ifndef __VIR_COMMAND_PRIV_H__
 +# define __VIR_COMMAND_PRIV_H__
 +
 +# include vircommand.h
 +
 +void virCommandSetDryRun(virBufferPtr buf);
 +#endif /* __VIR_COMMAND_PRIV_H__ */


ACK with that change.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

Re: [libvirt] [PATCH 5/7] Add virCommandSetMockOutputFile

2014-03-12 Thread Daniel P. Berrange
On Wed, Mar 12, 2014 at 02:08:15PM +0100, Ján Tomko wrote:
 After this file is set, all commands executed will be replaced by
 cat file.

I think this is a bit too special case and unecessarily forces
use of an external cat command. I think your test would be
easier if using this callback approach I've just proposed

https://www.redhat.com/archives/libvir-list/2014-March/msg00733.html

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

Re: [libvirt] [PATCH 1/7] Change virStorageBackendISCSISession 'probe' arg to bool

2014-03-12 Thread Daniel P. Berrange
On Wed, Mar 12, 2014 at 02:08:11PM +0100, Ján Tomko wrote:
 It quacks like a bool.
 ---
  src/storage/storage_backend_iscsi.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

Re: [libvirt] [PATCH 7/7] Add a test for virStorageBackendISCSIScanTargets

2014-03-12 Thread Daniel P. Berrange
On Wed, Mar 12, 2014 at 02:08:17PM +0100, Ján Tomko wrote:
 diff --git a/tests/storageiscsidata/iscsiadm_sendtargets 
 b/tests/storageiscsidata/iscsiadm_sendtargets
 new file mode 100644
 index 000..acea8ee
 --- /dev/null
 +++ b/tests/storageiscsidata/iscsiadm_sendtargets
 @@ -0,0 +1,6 @@
 +10.20.30.40:3260,1 iqn.2004-06.example:example1:iscsi.test
 +10.20.30.40:3260,1 iqn.2005-05.example:example1:iscsi.hello
 +10.20.30.40:3260,1 iqn.2006-04.example:example1:iscsi.world
 +10.20.30.40:3260,1 iqn.2007-04.example:example1:iscsi.foo
 +10.20.30.40:3260,1 iqn.2008-04.example:example1:iscsi.bar
 +10.20.30.40:3260,1 iqn.2009-04.example:example1:iscsi.seven

If we use the callback approach I suggested, then this data can just
be a constant string inlined in the storageiscsitest.c file. I think
that is preferrable since we're not likely to need to have 100's of
external data files as we do for other tests

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

Re: [libvirt] [PATCH 3/7] Use size_t for ndevice in pool source definition

2014-03-12 Thread Daniel P. Berrange
On Wed, Mar 12, 2014 at 02:08:13PM +0100, Ján Tomko wrote:
 This allows it to be used by the VIR_*_ELEMENT macros.
 
 Also use them for parsing the definiton and remove the redundant
 freeing of 'nodeset' before jumping to the cleanup label.
 ---
  src/conf/storage_conf.c | 23 ++-
  src/conf/storage_conf.h |  2 +-
  2 files changed, 11 insertions(+), 14 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

Re: [libvirt] [PATCH 0/7] Test parsing of iscsiadm output

2014-03-12 Thread Daniel P. Berrange
On Wed, Mar 12, 2014 at 02:08:10PM +0100, Ján Tomko wrote:
 Introduce virCommandSetMockOutputFile for faking output of
 asynchronous commands and use it to test parsing of iscsiadm
 output in virStorageBackendISCSISession and
 virStorageBackendISCSIScanTargets
 
 Ján Tomko (7):
   Change virStorageBackendISCSISession 'probe' arg to bool
   Introduce virStoragePoolSourceDeviceClear
   Use size_t for ndevice in pool source definition
   Introduce vircommandpriv.h for functions used by tests
   Add virCommandSetMockOutputFile
   Add test for virStorageBackendISCSISession
   Add a test for virStorageBackendISCSIScanTargets

Strangely I've still not received patch 2, but ACK to that patch
based on what's in the mailing list archives.


If you want to do any more work in this area, I think one other good
idea would be to introduce a src/util/viriscsi.{c,h} helper API which
exposes a set of APIs for core iSCSI operations we need. This would
isolate all the iscsiadm command code in one place, separated from the
storage backend implementation, so both sides of the code would be
easier to follow.

I think I'd extend this API to other stuff the storage backends do
too. eg a virlvm.{c,h} and a virscsi.{c,h} etc, to again isolate code
that is invoking commands + parsing their output, from the code that
actually uses this functionality.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

Re: [libvirt] [PATCH] nwfilter: Add missing goto err_exit in error path

2014-03-12 Thread Stefan Berger
Ján Tomko jto...@redhat.com wrote on 03/12/2014 09:11:35 AM:

 
 On 03/12/2014 12:38 PM, Stefan Berger wrote:
  From: Stefan Berger stef...@linux.vnet.ibm.com
  
  https://bugzilla.redhat.com/show_bug.cgi?id=1071095
  
  Add a missing goto err_exit in the error path where an unsupported
  value is assigned to the CTRL_IP_LEARNING key.
  
  Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
  ---
   src/nwfilter/nwfilter_gentech_driver.c | 1 +
   1 file changed, 1 insertion(+)
 
 ACK

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

Re: [libvirt] [PATCH 00/13] Add multiple trace backend function and add new ftrace backend for libvirt

2014-03-12 Thread Daniel P. Berrange
On Mon, Mar 10, 2014 at 08:17:21AM +, yangzy.f...@cn.fujitsu.com wrote:
 From: Xinghai Yu yuxing...@cn.fujitsu.com
 
 This patch set will let libvirt to support multiple trace backend function
 and add a new 'ftrace' backend at the same time.
 Then, libvirt would have 2 trace backend: dtrace, ftrace.They can be used
 alone or together.
 
 Patchs 1,2,3,4,5 are used for supporting multiple trace backend function.
 Patch 6 are used for adding ftrace as a new trace backend for libvirt.
 Patchs 7,8,9,10,11,12,13 add ftrace initial code in programs who use it.
 
 Thanks very much for Stefan Hajnoczi for I have used his scripts in patch 
 4 which commited in qemu.
 Thanks very much for Eiichi Tsukata for I have used his ftrace codes in 
 patch 6 which commited in qemu.
 
 Backgroud:
 The existing trace mechanism in libvirt is dtrace. Although the dtrace
 can work, it's not work well enough. Every time we want get information
 from the trace point we must write a systemtap script and run it
 together with libvirt.
 
 That's really unpractical on some occasion, especially on production
 server since the systemtap script can't be executed automatically.
 And some problems may be not easy to reproduce, then it will cost a
 lot of time to get the trace information again.
 
 So I think it is essential to add supporting for record the trace
 information automatically in libvirt to satisfy the user's requirement.
 That's why I implemented multiple trace backend function and ftrace 
 support in libvirt.

FYI, i've put this on my todo list to review. From a quick glance
through there's a few things in here that I'm not liking very
much, but I'll need to take take to analyse them in more detail

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 20/49] extract general code from qemuUpdateActiveUsbHostdevs

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:47PM +0800, Chunyan Liu wrote:
 Extract general code from qemuUpdateActiveUsbHostdevs to
 virHostdevUpdateActiveUsbHostdevs.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 22 +++---
  1 file changed, 15 insertions(+), 7 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 19/49] extract general code from qemuUpdateActivePciHostdevs

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:46PM +0800, Chunyan Liu wrote:
 Extract general code from qemuUpdateActivePciHostdevs to
 virHostdevUpdateActivePciHostdevs.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 22 +++---
  1 file changed, 15 insertions(+), 7 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 21/49] extract general code from qemuUpdateActiveScsiHostdevs

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:48PM +0800, Chunyan Liu wrote:
 Extract general code from qemuUpdateActiveScsiHostdevs to
 virHostdevUpdateActiveScsiHostdevs
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 22 +++---
  1 file changed, 15 insertions(+), 7 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 22/49] pass driver_name as parameter of virHostdevUpdate*Hostdevs functions

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:49PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 17 ++---
  1 file changed, 10 insertions(+), 7 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 18/49] move virHostdevPrepare(ReAttach)PCIDevices to virhostdev.c

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:45PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libvirt_private.syms |   3 +-
  src/qemu/qemu_hostdev.c  | 647 --
  src/qemu/qemu_hostdev.h  |   5 -
  src/qemu/qemu_process.c  |   1 +
  src/util/virhostdev.c| 648 
 +++
  src/util/virhostdev.h|  25 ++
  6 files changed, 676 insertions(+), 653 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH 4/7] Introduce vircommandpriv.h for functions used by tests

2014-03-12 Thread Ján Tomko
On 03/12/2014 03:24 PM, Daniel P. Berrange wrote:
 On Wed, Mar 12, 2014 at 02:08:14PM +0100, Ján Tomko wrote:
 So far it's just virCommandSetDryRun.
 ---
  src/Makefile.am|  2 +-
  src/util/vircommand.c  |  2 +-
  src/util/vircommand.h  |  2 --
  src/util/vircommandpriv.h  | 28 
  tests/virkmodtest.c|  2 +-
  tests/virnetdevbandwidthtest.c |  2 +-
  6 files changed, 32 insertions(+), 6 deletions(-)
  create mode 100644 src/util/vircommandpriv.h

 
 Also add in
 
 #ifndef __VIR_COMMAND_PRIV_H_ALLOW__
 # error vircommandpriv.h may only be included by vircommand.c or test suites
 #endif
 
 and then make vircommand.c and any relevant test suites #define
 this symbol before including the file.
 
 +#ifndef __VIR_COMMAND_PRIV_H__
 +# define __VIR_COMMAND_PRIV_H__
 +
 +# include vircommand.h
 +
 +void virCommandSetDryRun(virBufferPtr buf);
 +#endif /* __VIR_COMMAND_PRIV_H__ */
 
 
 ACK with that change.
 

I've changed that and pushed patches 1-4.

Thanks for the review.

Jan




signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v14 23/49] move virHostdevUpdate* functions to virhostdev.c

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:50PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libvirt_private.syms |   3 +
  src/qemu/qemu_hostdev.c  | 151 
 ---
  src/util/virhostdev.c| 151 
 +++
  src/util/virhostdev.h|  12 
  4 files changed, 166 insertions(+), 151 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 25/49] rename qemu*USBDevices to virHostdev*USBDevices

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:52PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 16 
  1 file changed, 8 insertions(+), 8 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 24/49] extract general code from qemuPrepareHostUSBDevices

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:51PM +0800, Chunyan Liu wrote:
 Extract general code from qemuPrepareHostUSBDevices to
 virHostdevPrepareHostUSBDevices.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 27 +++
  1 file changed, 19 insertions(+), 8 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 26/49] pass driver name to virHostdevPrepareUSBDevices

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:53PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 8 +---
  1 file changed, 5 insertions(+), 3 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 29/49] pass driver name as parameter to virHostdevPrepareSCSIDevices

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:56PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 9 +
  1 file changed, 5 insertions(+), 4 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 27/49] move virHostdevPrepareHostUSBDevices to virhostdev.c

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:54PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libvirt_private.syms |   1 +
  src/qemu/qemu_hostdev.c  | 217 
 ---
  src/util/virhostdev.c| 216 ++
  src/util/virhostdev.h|   7 ++
  4 files changed, 224 insertions(+), 217 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 28/49] extract general code from qemuPrepareHostSCSIDevices

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:55PM +0800, Chunyan Liu wrote:
 Extract general code from qemuPrepareHostSCSIDevices to
 virHostdevPrepareHostSCSIDevices.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 63 
 +
  1 file changed, 37 insertions(+), 26 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 30/49] move virHostdevPrepareHostSCSIDevices to virhostdev.c

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:57PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libvirt_private.syms |   1 +
  src/qemu/qemu_hostdev.c  | 111 
 ---
  src/util/virhostdev.c| 111 
 +++
  src/util/virhostdev.h|   6 +++
  4 files changed, 118 insertions(+), 111 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 31/49] extract general code from qemuDomainReAttachHostUsbDevices

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:58PM +0800, Chunyan Liu wrote:
 Extract general code from qemuDomainReAttachHostUsbDevices to
 virHostdevDomainReAttachHostUsbDevices.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 23 ---
  1 file changed, 16 insertions(+), 7 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 32/49] pass driver name as paramter to virHostdevReAttachUsbHostdevs

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:59PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v5 1/3] add new virDomainCoreDumpWithFormat API

2014-03-12 Thread Martin Kletzander
On Thu, Mar 06, 2014 at 09:35:47AM +, qiaonuo...@cn.fujitsu.com wrote:
 --memory-only option is introduced without compression supported. Therefore,
 this is a freature regression of virsh dump. Now qemu has support dumping 
 memory

s/freature/feature/

but I would not use the word regression since that never worked.
Also it would help mentioning the commit ID or a version it
got included in qemu.  On that note, is there a possibility of
of introspection of that feature, so we can gracefully error out in
case older qemu is used?

 in kdump-compressed format. This patch is adding new 
 virDomainCoreDumpWithFormat
 API, so that the format in which qemu dump domain's memory can be specified.
 

s/dump/dumps/

Looking at the rest, I rather fixed what I wanted to change in my repo
and here's the diff I'd squash in.  Let me know if you're OK with
that.  I'll still want an ACK from someone in order to push that,
though.  And feel free to ask about that changes as well.

Martin

diff --git c/include/libvirt/libvirt.h.in i/include/libvirt/libvirt.h.in
index 12d64ab..41cd28c 100644
--- c/include/libvirt/libvirt.h.in
+++ i/include/libvirt/libvirt.h.in
@@ -1186,15 +1186,15 @@ typedef enum {
  * Values for specifying different formats of domain core dumps.
  */
 typedef enum {
-VIR_DUMP_FORMAT_RAW,  /* dump guest memory in raw format */
-VIR_DUMP_FORMAT_KDUMP_ZLIB,   /* dump guest memory in kdump-compressed
- format, with zlib-compressed */
-VIR_DUMP_FORMAT_KDUMP_LZO,/* dump guest memory in kdump-compressed
- format, with lzo-compressed */
-VIR_DUMP_FORMAT_KDUMP_SNAPPY, /* dump guest memory in kdump-compressed
- format, with snappy-compressed */
+VIR_DOMAIN_CORE_DUMP_FORMAT_RAW,  /* dump guest memory in raw 
format */
+VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB,   /* kdump-compressed format, with
+   * zlib compression */
+VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_LZO,/* kdump-compressed format, with
+   * lzo compression */
+VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_SNAPPY, /* kdump-compressed format, with
+   * snappy compression */
 #ifdef VIR_ENUM_SENTINELS
-VIR_DUMP_FORMAT_LAST
+VIR_DOMAIN_CORE_DUMP_FORMAT_LAST
 /*
  * NB: this enum value will increase over time as new events are
  * added to the libvirt API. It reflects the last state supported
@@ -1756,10 +1756,10 @@ int virDomainCoreDump   
(virDomainPtr domain,
 /*
  * Domain core dump with format specified
  */
-int virDomainCoreDumpWithFormat (virDomainPtr domain,
- const char *to,
- unsigned int dumpformat,
- unsigned int flags);
+int virDomainCoreDumpWithFormat (virDomainPtr domain,
+ const char *to,
+ unsigned int dumpformat,
+ unsigned int flags);

 /*
  * Screenshot of current domain console
diff --git c/src/libvirt.c i/src/libvirt.c
index cb8f0d2..a4787a8 100644
--- c/src/libvirt.c
+++ i/src/libvirt.c
@@ -3032,7 +3032,7 @@ virDomainCoreDumpWithFormat(virDomainPtr domain, const 
char *to, unsigned int
 {
 virConnectPtr conn;

-VIR_DOMAIN_DEBUG(domain, to=%s, flags=%x, to, flags);
+VIR_DOMAIN_DEBUG(domain, to=%s, dumpformat=%u, flags=%x, to, dumpformat, 
flags);

 virResetLastError();

@@ -3042,7 +3042,7 @@ virDomainCoreDumpWithFormat(virDomainPtr domain, const 
char *to, unsigned int
 virCheckReadOnlyGoto(conn-flags, error);
 virCheckNonNullArgGoto(to, error);

-if (dumpformat = VIR_DUMP_FORMAT_LAST) {
+if (dumpformat = VIR_DOMAIN_CORE_DUMP_FORMAT_LAST) {
 virReportInvalidArg(flags, _(dumpformat '%d' is not supproted),
 dumpformat);
 goto error;
@@ -3056,7 +3056,7 @@ virDomainCoreDumpWithFormat(virDomainPtr domain, const 
char *to, unsigned int

 if ((flags  VIR_DUMP_CRASH)  (flags  VIR_DUMP_RESET)) {
 virReportInvalidArg(flags, %s,
- _(crash and reset flags are mutually exclusive));
+_(crash and reset flags are mutually exclusive));
 goto error;
 }

diff --git c/src/remote_protocol-structs i/src/remote_protocol-structs
index 0e2101c..456d0da 100644
--- c/src/remote_protocol-structs
+++ i/src/remote_protocol-structs
@@ -560,7 +560,7 @@ struct remote_domain_core_dump_args {
 struct remote_domain_core_dump_with_format_args {
 remote_nonnull_domain  dom;
 remote_nonnull_string  to;
-u_int  dompformat;
+ 

Re: [libvirt] [PATCH v14 34/49] extract general code from qemuDomainReAttachHostScsiDevices

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:01PM +0800, Chunyan Liu wrote:
 Extract general code from qemuDomainReAttachHostScsiDevices to
 virHostdevDomainReAttachHostScsiDevices.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 40 +++-
  1 file changed, 27 insertions(+), 13 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 33/49] move virHostdevReAttachUsbHostdevs to virhostdev.c

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:00PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libvirt_private.syms |  1 +
  src/qemu/qemu_hostdev.c  | 66 
 
  src/util/virhostdev.c| 66 
 
  src/util/virhostdev.h|  6 +
  4 files changed, 73 insertions(+), 66 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 37/49] extract general code of NodeDeviceDetach

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:04PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_driver.c | 34 ++
  1 file changed, 22 insertions(+), 12 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 35/49] pass driver name as parameter to virHostdevReAttachScciHostdevs

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:02PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 36/49] move virHostdevReAttachHostScsiDevices to virhostdev.c

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:03PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libvirt_private.syms |  1 +
  src/qemu/qemu_hostdev.c  | 62 
 
  src/util/virhostdev.c| 62 
 
  src/util/virhostdev.h|  6 +
  4 files changed, 69 insertions(+), 62 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 39/49] extract general code of NodeDeviceReset

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:06PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_driver.c | 29 -
  1 file changed, 20 insertions(+), 9 deletions(-)

ACK

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 38/49] extract general code of NodeDeviceReAttach

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:05PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_driver.c | 61 
 +-
  1 file changed, 36 insertions(+), 25 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 40/49] move virHostdevNodeDevice* to virhostdev.c

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:07PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libvirt_private.syms |  3 ++
  src/qemu/qemu_driver.c   | 81 
 
  src/util/virhostdev.c| 81 
 
  src/util/virhostdev.h|  8 +
  4 files changed, 92 insertions(+), 81 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 41/49] improve parameter name to let it more meaningful

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:08PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/util/virhostdev.c | 44 +++-
  src/util/virhostdev.h | 12 ++--
  2 files changed, 29 insertions(+), 27 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 43/49] improve virHostdevUpdate* parameters to make it more widely used

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:10PM +0800, Chunyan Liu wrote:
 Changes parameter from vm def to specific hostdevs info and name info, so that
 it could be used more widely, e.g, could be used without full vm def info.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/qemu/qemu_hostdev.c |  9 ++---
  src/util/virhostdev.c   | 34 --
  src/util/virhostdev.h   | 12 +---
  3 files changed, 35 insertions(+), 20 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 44/49] add 3 wrapper functions for prepare/reattach/update domain hostdevs

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:11PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libvirt_private.syms |   4 ++
  src/util/virhostdev.c| 103 
 +++
  src/util/virhostdev.h|  20 +
  3 files changed, 127 insertions(+)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v5 2/3] add qemu support to virDomainCoreDumpWithFormat API

2014-03-12 Thread Martin Kletzander
On Thu, Mar 06, 2014 at 09:35:47AM +, qiaonuo...@cn.fujitsu.com wrote:

s/to/for/ in the $SUBJ or you can rephrase it to:

qemu: add support for virDomainCoreDumpWithFormat API

 This patch makes qemu driver supprot virDomainCoreDumpWithFormat API.

s/supprot/support/

And again like with previous patch, here's a diff of what I'd change.
For this one I'm still missing the detection of kdump-compressed dump
capability in qemu.

Martin

diff --git c/src/qemu/qemu_driver.c i/src/qemu/qemu_driver.c
index 995cae0..ee8fcf9 100644
--- c/src/qemu/qemu_driver.c
+++ i/src/qemu/qemu_driver.c
@@ -2676,6 +2676,13 @@ VIR_ENUM_IMPL(qemuSaveCompression, QEMU_SAVE_FORMAT_LAST,
   xz,
   lzop)

+VIR_ENUM_DECL(qemuDumpFormat)
+VIR_ENUM_IMPL(qemuDumpFormat, VIR_DOMAIN_CORE_DUMP_FORMAT_LAST,
+  elf,
+  kdump-zlib,
+  kdump-lzo,
+  kdump-snappy)
+
 typedef struct _virQEMUSaveHeader virQEMUSaveHeader;
 typedef virQEMUSaveHeader *virQEMUSaveHeaderPtr;
 struct _virQEMUSaveHeader {
@@ -3453,25 +3460,20 @@ doCoreDump(virQEMUDriverPtr driver,
 goto cleanup;

 if (dump_flags  VIR_DUMP_MEMORY_ONLY) {
-if (dumpformat == VIR_DUMP_FORMAT_RAW)
-memory_dump_format = elf;
-else if (dumpformat == VIR_DUMP_FORMAT_KDUMP_ZLIB)
-memory_dump_format = kdump-zlib;
-else if (dumpformat == VIR_DUMP_FORMAT_KDUMP_LZO)
-memory_dump_format = kdump-lzo;
-else if (dumpformat == VIR_DUMP_FORMAT_KDUMP_SNAPPY)
-memory_dump_format = kdump-snappy;
-else {
+if (!(memory_dump_format = qemuDumpFormatTypeToString(dumpformat))) {
 virReportError(VIR_ERR_INVALID_ARG,
_(unknown dumpformat '%d'), dumpformat);
+goto cleanup;
 }
 ret = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP,
memory_dump_format);
 } else {
-if (dumpformat != VIR_DUMP_FORMAT_RAW)
+if (dumpformat != VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) {
 virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
-   _(kdump-compressed format is only work with guest 
- memory dump));
+   _(kdump-compressed format is only supported with 
+ memory-only dump));
+goto cleanup;
+}
 ret = qemuMigrationToFile(driver, vm, fd, 0, path,
   qemuCompressProgramName(compress), false,
   QEMU_ASYNC_JOB_DUMP);
@@ -3643,7 +3645,8 @@ static int qemuDomainCoreDump(virDomainPtr dom,
   const char *path,
   unsigned int flags)
 {
-return qemuDomainCoreDumpWithFormat(dom, path, VIR_DUMP_FORMAT_RAW, flags);
+return qemuDomainCoreDumpWithFormat(dom, path,
+VIR_DOMAIN_CORE_DUMP_FORMAT_RAW, 
flags);
 }

 static char *
@@ -3770,7 +3773,7 @@ static void processWatchdogEvent(virQEMUDriverPtr driver, 
virDomainObjPtr vm, in
 flags |= cfg-autoDumpBypassCache ? VIR_DUMP_BYPASS_CACHE: 0;
 ret = doCoreDump(driver, vm, dumpfile,
  getCompressionType(driver), flags,
- VIR_DUMP_FORMAT_RAW);
+ VIR_DOMAIN_CORE_DUMP_FORMAT_RAW);
 if (ret  0)
 virReportError(VIR_ERR_OPERATION_FAILED,
%s, _(Dump failed));
@@ -3834,7 +3837,8 @@ doCoreDumpToAutoDumpPath(virQEMUDriverPtr driver,

 flags |= cfg-autoDumpBypassCache ? VIR_DUMP_BYPASS_CACHE: 0;
 ret = doCoreDump(driver, vm, dumpfile,
- getCompressionType(driver), flags, VIR_DUMP_FORMAT_RAW);
+ getCompressionType(driver), flags,
+ VIR_DOMAIN_CORE_DUMP_FORMAT_RAW);
 if (ret  0)
 virReportError(VIR_ERR_OPERATION_FAILED,
%s, _(Dump failed));
--


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] qemu: Forbid sgio support for SCSI generic host device

2014-03-12 Thread Osier Yang

On 12/03/14 21:54, Jiri Denemark wrote:

On Fri, Mar 07, 2014 at 22:23:26 +0800, Osier Yang wrote:

The kernel didn't support the unprivileged SGIO for SCSI generic
device finally, and since it's unknow whether the way to support
unprivileged SGIO for SCSI generic device will be similar as for
SCSI block device or not, even it's simliar (I.e. via sysfs, for
SCSI block device, it's /sys/dev/block/8\:0/queue/unpriv_sgio,
for example), the file name might be different, So it's better not
guess what it should be like currently.

This patch removes the related code (mainly about the shareable
checking on the sgio setting, it's not supported at all, why
we leave checking code there? :-), and error out if sgio is
specified in the domain config.
---
  src/qemu/qemu_conf.c | 87 
  1 file changed, 20 insertions(+), 67 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2c397b0..ad6348d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c

...

@@ -1135,22 +1102,15 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
  } else if (dev-type == VIR_DOMAIN_DEVICE_HOSTDEV) {
  hostdev = dev-data.hostdev;
  
-if (!hostdev-shareable ||

-!(hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS 
-  hostdev-source.subsys.type == 
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI))
-return 0;

In the follow-up patch, you recovered just the

 hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI

part. Shouldn't the other checks in this condition remain?


-
-if (!(hostdev_name = virSCSIDeviceGetDevName(NULL,
- 
hostdev-source.subsys.u.scsi.adapter,
- 
hostdev-source.subsys.u.scsi.bus,
- 
hostdev-source.subsys.u.scsi.target,
- 
hostdev-source.subsys.u.scsi.unit)))
-goto cleanup;
-
-if (virAsprintf(hostdev_path, /dev/%s, hostdev_name)  0)
+if (hostdev-source.subsys.u.scsi.sgio) {

In other words, should this be something like

 if (hostdev-shareable 
 hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS 
 hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI 
 hostdev-source.subsys.u.scsi.sgio) {




Should be:

If (hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS 
hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI 
hostdev-source.subsys.u.scsi.sgio) {

Regardless of whether the SCSI generic device is shareable or not. We 
won't support
the unpiv_sgio setting.  I lost the SUBSYS checking in the follow up 
patch indeed. If no

other issue, I can squash it in when pushing.   Thanks for the reviewing.

Osier

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


Re: [libvirt] [PATCH v14 45/49] add parameter checks to common interfaces

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:12PM +0800, Chunyan Liu wrote:
 Check NULL parameter inputs
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/util/virhostdev.c | 57 
 +++
  1 file changed, 57 insertions(+)
 
 diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
 index 577de48..5f61bfc 100644
 --- a/src/util/virhostdev.c
 +++ b/src/util/virhostdev.c
 @@ -468,6 +468,11 @@ virHostdevPreparePciHostdevs(virHostdevManagerPtr 
 hostdev_mgr,
  size_t i;
  int ret = -1;
  
 +if (!nhostdevs)
 +return 0;

This is reasonable because it is an expected case.

 +if (hostdev_mgr == NULL)
 +return -1;

This is something that should never happen except by programmer
error, since this is allocated right at libvirtd startup and
then never changed thereafter.

It is preferrable to use ATTRIBUTE_NONNULL() in the header
file for these kind of things.


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v5 3/3] allow virsh dump --memory-only specify dump format

2014-03-12 Thread Martin Kletzander
On Thu, Mar 06, 2014 at 09:35:47AM +, qiaonuo...@cn.fujitsu.com wrote:
 This patch is used to add --compress and [--compression-format] string 
 to

s/is used to add/adds/

 virsh dump --memory-only. And virsh dump --memory-only is going be
 implemented by new virDomainCoreDumpWithFormat API.
 

How about rewording it like this:

... to virsh dump --memory-only, which is changed to use the new
virDomainCoreDumpWithFormat API.

The same about the following diff as with the first patch applies.

Martin

diff --git c/tools/virsh-domain.c w/tools/virsh-domain.c
index f8e8e57..51881ef 100644
--- c/tools/virsh-domain.c
+++ w/tools/virsh-domain.c
@@ -4487,8 +4487,8 @@ static const vshCmdOptDef opts_dump[] = {
  .help = N_(dump domain's memory only)
 },
 {.name = compress,
- .type = VSH_OT_BOOL,
- .help = N_(make qemu dump domain's memory in kdump-compressed format)
+ .type = VSH_OT_ALIAS,
+ .help = compression-format=zlib,
 },
 {.name = compression-format,
  .type = VSH_OT_DATA,
@@ -4509,9 +4509,8 @@ doDump(void *opaque)
 const char *name = NULL;
 const char *to = NULL;
 unsigned int flags = 0;
-bool optCompress;
 const char *compression_format = NULL;
-unsigned int memory_dump_format = VIR_DUMP_FORMAT_RAW;
+unsigned int memory_dump_format = VIR_DOMAIN_CORE_DUMP_FORMAT_RAW;

 sigemptyset(sigmask);
 sigaddset(sigmask, SIGINT);
@@ -4535,36 +4534,26 @@ doDump(void *opaque)
 if (vshCommandOptBool(cmd, memory-only))
 flags |= VIR_DUMP_MEMORY_ONLY;

-optCompress = vshCommandOptBool(cmd, compress);
-if (optCompress  !(flags  VIR_DUMP_MEMORY_ONLY)) {
+if (vshCommandOptBool(cmd, compression-format) 
+!(flags  VIR_DUMP_MEMORY_ONLY)) {
 vshError(ctl, %s,
  _(compress flag cannot be set without memory-only flag));
 goto out;
 }

 if (vshCommandOptString(cmd, compression-format, compression_format)) {
-if (!optCompress) {
-vshError(ctl, %s,
- _(compression-format cannot be set without compress 
-   flag));
-goto out;
-}
-
 if (STREQ(compression_format, zlib))
-memory_dump_format = VIR_DUMP_FORMAT_KDUMP_ZLIB;
+memory_dump_format = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB;
 else if (STREQ(compression_format, lzo))
-memory_dump_format = VIR_DUMP_FORMAT_KDUMP_LZO;
+memory_dump_format = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_LZO;
 else if (STREQ(compression_format, snappy))
-memory_dump_format = VIR_DUMP_FORMAT_KDUMP_SNAPPY;
+memory_dump_format = VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_SNAPPY;
 else {
 vshError(ctl, _(compression format '%s' is not supported, 
 expecting 'zlib', 'lzo' or 'snappy'.),
  compression_format);
 goto out;
 }
-} else {
-if (optCompress)
-memory_dump_format = VIR_DUMP_FORMAT_KDUMP_ZLIB;
 }

 if (virDomainCoreDumpWithFormat(dom, to, memory_dump_format, flags)  0) {
diff --git c/tools/virsh.pod w/tools/virsh.pod
index cefce1b..0eb7ac6 100644
--- c/tools/virsh.pod
+++ w/tools/virsh.pod
@@ -995,6 +995,7 @@ Iformat argument may be Bxen-xm or Bxen-sxpr.

 =item Bdump Idomain Icorefilepath [I--bypass-cache]
 { [I--live] | [I--crash] | [I--reset] } [I--verbose] [I--memory-only]
+[I--compression-format Istring]

 Dumps the core of a domain to a file for analysis.
 If I--live is specified, the domain continues to run until the core
@@ -1008,6 +1009,10 @@ cache, although this may slow down the operation.
 If I--memory-only is specified, the file is elf file, and will only
 include domain's memory and cpu common register value. It is very
 useful if the domain uses host devices directly.
+I--compression-format Istring can be used to specify that the
+output file should be in kdump-compressed format using the specified
+compression; zlib, lzo, snappy.
+I--compress is an alias for I--compression-format Ilzo.

 The progress may be monitored using Bdomjobinfo virsh command and canceled
 with Bdomjobabort command (sent by another virsh instance). Another option
--


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v14 42/49] rename some function names to keep consistency

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:09PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libvirt_private.syms |  8 
  src/qemu/qemu_hostdev.c  | 16 +++
  src/util/virhostdev.c| 52 
 
  src/util/virhostdev.h| 40 ++---
  4 files changed, 58 insertions(+), 58 deletions(-)
 
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 5bb529c..e7d9d56 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1297,10 +1297,10 @@ virHostdevManagerGetDefault;
  virHostdevPciNodeDeviceDetach;
  virHostdevPciNodeDeviceReAttach;
  virHostdevPciNodeDeviceReset;
 -virHostdevPreparePCIDevices;
 -virHostdevPrepareSCSIDevices;
 -virHostdevPrepareUSBDevices;
 -virHostdevReAttachPCIDevices;
 +virHostdevPreparePciHostdevs;
 +virHostdevPrepareScsiHostdevs;
 +virHostdevPrepareUsbHostdevs;
 +virHostdevReAttachPciHostdevs;
  virHostdevReAttachScsiHostdevs;
  virHostdevReAttachUsbHostdevs;
  virHostdevUpdateActivePciHostdevs;

IMHO this is fixing the wrong side of the inconsistency.

PCI, USB and SCSI are all abbreviations, so using capitalization
is correct. We should instead fix the Pci, Usb and Scsi names.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] [PATCHv2 0/7] arbitrary qemu monitor events

2014-03-12 Thread Eric Blake
v1 was here:
https://www.redhat.com/archives/libvir-list/2014-February/msg0.html

Many of the patches in the series were acked back then, but the
'virsh' changes were made conditional on getting 'virsh event'
working first, so it missed the last release.  Changes in v2:
rebase to master, s/1.2.2/1.2.3/, simplify virsh patch (2/7) to
use framework for event tracking.

Also, the python bindings need review (no change to v1):
https://www.redhat.com/archives/libvir-list/2014-February/msg00197.html

Note that Dan was hesitant about patches 6 and 7 in v1, but if
we don't take those patches, then the API is over-engineered.
Either we are willing to support filtering on specific event
names and patterns, or I should respin a v3 of this series that
simplifies the API in patch 1 to not expose that possibility.
Personally, I think the ability to expose all 'spice_*' related
events at once, without being drowned by other events, is worth
the complexity of server-side filtering.  I also note that the
bulk of the complexity was isolated to the qemu-specific code
with no noticeable impact to the normal event code (the changes
to domain_event.c are primarily additions, and the changes to
object_event.c are merely tweaks to allow qemu filtering to be
server-side only in comparison to normal events that can do
some of the filtering client side).

Eric Blake (7):
  qemu: new API for tracking arbitrary monitor events
  qemu: virsh wrapper for qemu events
  qemu: create object for qemu monitor events
  qemu: wire up RPC for qemu monitor events
  qemu: enable monitor event reporting
  qemu: enable monitor event filtering by name
  qemu: allow filtering events by regex

 daemon/libvirtd.h  |   2 +
 daemon/remote.c| 209 
 include/libvirt/libvirt-qemu.h |  46 +++-
 src/conf/domain_event.c| 234 +
 src/conf/domain_event.h|  23 
 src/conf/object_event.c|  40 ---
 src/driver.h   |  15 +++
 src/libvirt-qemu.c | 124 ++
 src/libvirt_private.syms   |   2 +
 src/libvirt_qemu.syms  |   6 ++
 src/qemu/qemu_driver.c |  51 +
 src/qemu/qemu_monitor.c|  14 +++
 src/qemu/qemu_monitor.h|  13 ++-
 src/qemu/qemu_monitor_json.c   |  21 +++-
 src/qemu/qemu_process.c|  29 +
 src/qemu_protocol-structs  |  22 
 src/remote/qemu_protocol.x |  50 -
 src/remote/remote_driver.c | 143 -
 src/rpc/gendispatch.pl |  13 +--
 tools/virsh-domain.c   | 148 ++
 tools/virsh.pod|  30 +-
 21 files changed, 1203 insertions(+), 32 deletions(-)

-- 
1.8.5.3

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


[libvirt] [PATCHv2 1/7] qemu: new API for tracking arbitrary monitor events

2014-03-12 Thread Eric Blake
Several times in the past, qemu has implemented a new event,
but libvirt has not yet caught up to reporting that event to
the user applications.  While it is possible to track libvirt
logs to see that an unknown event was received and ignored,
it would be nicer to copy what 'virsh qemu-monitor-command'
does, and expose this information to the end developer as
one of our unsupported qemu-specific commands.

If you find yourself needing to use this API for more than
just development purposes, please ask on the libvirt list
for a supported counterpart event to be added in libvirt.so.

While the supported virConnectDomainEventRegisterAny() API
takes an id which determines the signature of the callback,
this version takes a string filter and always uses the same
signature.  Furthermore, I chose to expose this as a new API
instead of trying to add a new eventID at the top level, in
part because the generic option lacks event name filtering,
and in part because the normal domain event namespace should
not be polluted by a qemu-only event.  I also added a flags
argument; unused for now, but we might decide to use it to
allow a user to request event names by glob or regex instead
of literal match.

This API intentionally requires full write access (while
normal event registration is allowed on read-only clients);
this is in part due to the fact that it should only be used
by debugging situations, and in part because the design of
per-event filtering in later patches ended up allowing for
duplicate registrations that could potentially be abused to
exhaust server memory - requiring write privileges means
that such abuse will not serve as a denial of service attack
against users with higher privileges.

* include/libvirt/libvirt-qemu.h
(virConnectDomainQemuMonitorEventCallback)
(virConnectDomainQemuMonitorEventRegister)
(virConnectDomainQemuMonitorEventDeregister): New prototypes.
* src/libvirt-qemu.c (virConnectDomainQemuMonitorEventRegister)
(virConnectDomainQemuMonitorEventDeregister): New functions.
* src/libvirt_qemu.syms (LIBVIRT_QEMU_1.2.1): Export them.
* src/driver.h (virDrvConnectDomainQemuMonitorEventRegister)
(virDrvConnectDomainQemuMonitorEventDeregister): New callbacks.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 include/libvirt/libvirt-qemu.h |  36 +++-
 src/driver.h   |  15 +
 src/libvirt-qemu.c | 121 +
 src/libvirt_qemu.syms  |   6 ++
 4 files changed, 177 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
index 3e79a8c..ed6d3d2 100644
--- a/include/libvirt/libvirt-qemu.h
+++ b/include/libvirt/libvirt-qemu.h
@@ -4,7 +4,7 @@
  * Description: Provides the interfaces of the libvirt library to handle
  *  qemu specific methods
  *
- * Copyright (C) 2010, 2012 Red Hat, Inc.
+ * Copyright (C) 2010-2014 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -54,6 +54,40 @@ typedef enum {
 char *virDomainQemuAgentCommand(virDomainPtr domain, const char *cmd,
 int timeout, unsigned int flags);

+/**
+ * virConnectDomainQemuMonitorEventCallback:
+ * @conn: the connection pointer
+ * @dom: the domain pointer
+ * @event: the name of the event
+ * @seconds: the qemu timestamp of the event: seconds since Epoch, or -1 if
+ *   not available
+ * @micros: the qemu timestamp of the event: microseconds within the second
+ * @details: the JSON details of the event, if any were given
+ * @opaque: application specified data
+ *
+ * The callback signature to use when registering for a qemu monitor
+ * event with virConnectDomainQemuMonitorEventRegister().
+ */
+typedef void (*virConnectDomainQemuMonitorEventCallback)(virConnectPtr conn,
+ virDomainPtr dom,
+ const char *event,
+ long long seconds,
+ unsigned int micros,
+ const char *details,
+ void *opaque);
+
+int virConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
+ virDomainPtr dom,
+ const char *event,
+ 
virConnectDomainQemuMonitorEventCallback cb,
+ void *opaque,
+ virFreeCallback freecb,
+ unsigned int flags);
+
+int virConnectDomainQemuMonitorEventDeregister(virConnectPtr conn,
+   int callbackID);
+
+
 # ifdef __cplusplus
 }
 # 

[libvirt] [PATCHv2 6/7] qemu: enable monitor event filtering by name

2014-03-12 Thread Eric Blake
Filtering monitor events by name requires tracking the name for
the duration of the filtering.  In order to free the name, I
found it easiest to just piggyback on the user's freecb function,
which gets called when the event is deregistered.

For events without a name filter, we have the design of multiple
client registrations sharing a common server registration, because
the server side uses the same callback function and we reject
duplicate use of the same function.  But with events in the mix,
we want to be able to allow the same function pointer to be used
with more than one event name.  The solution is to tweak the
duplicate detection code to only act when there is no additional
filtering; if name filtering is in use, there is exactly one
client registration per server registration.  Yes, this means
that there is no longer a bound on the number of server
registrations possible, so a malicious client could repeatedly
register for the same name event to exhaust server memory.  On
the other hand, we already restricted monitor events to require
write access (compared to normal events only needing read access),
and separated it into the intentionally unsupported
libvirt-qemu.so, with documentation that using this function is
for debug purposes only; so it is not a security risk worth
worrying about a client trying to abuse multiple registrations.

* src/conf/domain_event.c (virDomainQemuMonitorEventData): New
struct.
(virDomainQemuMonitorEventFilter)
(virDomainQemuMonitorEventCleanup): New functions.
(virDomainQemuMonitorEventDispatchFunc)
(virDomainQemuMonitorEventStateRegisterID): Use new struct.
* src/conf/object_event.c (virObjectEventCallbackListCount)
(virObjectEventCallbackListAddID)
(virObjectEventCallbackListRemoveID)
(virObjectEventCallbackListMarkDeleteID): Drop duplicate detection
when filtering is in effect.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 src/conf/domain_event.c | 71 +++--
 src/conf/object_event.c | 40 ++--
 2 files changed, 89 insertions(+), 22 deletions(-)

diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 01c0ae6..a2880fd 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -1383,6 +1383,18 @@ error:
 }


+/* In order to filter by event name, we need to store a copy of the
+ * name to filter on.  By wrapping the caller's freecb, we can
+ * piggyback our cleanup to happen at the same time the caller
+ * deregisters.  */
+struct virDomainQemuMonitorEventData {
+char *event;
+void *opaque;
+virFreeCallback freecb;
+};
+typedef struct virDomainQemuMonitorEventData virDomainQemuMonitorEventData;
+
+
 static void
 virDomainQemuMonitorEventDispatchFunc(virConnectPtr conn,
   virObjectEventPtr event,
@@ -1391,6 +1403,7 @@ virDomainQemuMonitorEventDispatchFunc(virConnectPtr conn,
 {
 virDomainPtr dom = virGetDomain(conn, event-meta.name, event-meta.uuid);
 virDomainQemuMonitorEventPtr qemuMonitorEvent;
+virDomainQemuMonitorEventData *data = cbopaque;

 if (!dom)
 return;
@@ -1402,7 +1415,7 @@ virDomainQemuMonitorEventDispatchFunc(virConnectPtr conn,
qemuMonitorEvent-seconds,
qemuMonitorEvent-micros,
qemuMonitorEvent-details,
-   cbopaque);
+   data-opaque);
 virDomainFree(dom);
 }

@@ -1577,6 +1590,41 @@ virDomainEventStateDeregister(virConnectPtr conn,


 /**
+ * virDomainQemuMonitorEventFilter:
+ * @conn: the connection pointer
+ * @event: the event about to be dispatched
+ * @opaque: the opaque data registered with the filter
+ *
+ * Callback for filtering based on event names.  Returns true if the
+ * event should be dispatched.
+ */
+static bool
+virDomainQemuMonitorEventFilter(virConnectPtr conn ATTRIBUTE_UNUSED,
+virObjectEventPtr event,
+void *opaque)
+{
+virDomainQemuMonitorEventData *data = opaque;
+virDomainQemuMonitorEventPtr monitorEvent;
+
+monitorEvent = (virDomainQemuMonitorEventPtr) event;
+
+return STREQ(monitorEvent-event, data-event);
+}
+
+
+static void
+virDomainQemuMonitorEventCleanup(void *opaque)
+{
+virDomainQemuMonitorEventData *data = opaque;
+
+VIR_FREE(data-event);
+if (data-freecb)
+(data-freecb)(data-opaque);
+VIR_FREE(data);
+}
+
+
+/**
  * virDomainQemuMonitorEventStateRegisterID:
  * @conn: connection to associate with callback
  * @state: object event state
@@ -1604,23 +1652,30 @@ virDomainQemuMonitorEventStateRegisterID(virConnectPtr 
conn,
  unsigned int flags,
  int *callbackID)
 {
+virDomainQemuMonitorEventData *data = NULL;
+

[libvirt] [PATCHv2 4/7] qemu: wire up RPC for qemu monitor events

2014-03-12 Thread Eric Blake
These are the first async events in the qemu protocol, so this
patch looks rather big compared to most RPC additions.  However,
a large majority of this patch is just mechanical copy-and-paste
from recently-added network events.  It didn't help that this
is also the first virConnect rather than virDomain prefix
associated with a qemu-specific API.

* src/remote/qemu_protocol.x (qemu_*_domain_monitor_event_*): New
structs and RPC messages.
* src/rpc/gendispatch.pl: Adjust naming conventions.
* daemon/libvirtd.h (daemonClientPrivate): Track qemu events.
* daemon/remote.c (remoteClientFreeFunc): Likewise.
(remoteRelayDomainQemuMonitorEvent)
(qemuDispatchConnectDomainMonitorEventRegister)
(qemuDispatchConnectDomainMonitorEventDeregister): New functions.
* src/remote/remote_driver.c (qemuEvents): Handle qemu events.
(doRemoteOpen): Register for events.
(remoteNetworkBuildEventLifecycle)
(remoteConnectDomainQemuMonitorEventRegister)
(remoteConnectDomainQemuMonitorEventDeregister): New functions.
* src/qemu_protocol-structs: Regenerate.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 daemon/libvirtd.h  |   2 +
 daemon/remote.c| 209 +
 src/qemu_protocol-structs  |  22 +
 src/remote/qemu_protocol.x |  50 ++-
 src/remote/remote_driver.c | 143 ++-
 src/rpc/gendispatch.pl |  13 +--
 6 files changed, 428 insertions(+), 11 deletions(-)

diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index c4f1f27..49df33e 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -55,6 +55,8 @@ struct daemonClientPrivate {
 size_t ndomainEventCallbacks;
 daemonClientEventCallbackPtr *networkEventCallbacks;
 size_t nnetworkEventCallbacks;
+daemonClientEventCallbackPtr *qemuEventCallbacks;
+size_t nqemuEventCallbacks;

 # if WITH_SASL
 virNetSASLSessionPtr sasl;
diff --git a/daemon/remote.c b/daemon/remote.c
index b48d456..f18ce6b 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -53,6 +53,7 @@
 #include domain_conf.h
 #include network_conf.h
 #include viraccessapicheck.h
+#include viraccessapicheckqemu.h

 #define VIR_FROM_THIS VIR_FROM_RPC

@@ -186,6 +187,33 @@ cleanup:
 }


+static bool
+remoteRelayDomainQemuMonitorEventCheckACL(virNetServerClientPtr client,
+  virConnectPtr conn, virDomainPtr dom)
+{
+virDomainDef def;
+virIdentityPtr identity = NULL;
+bool ret = false;
+
+/* For now, we just create a virDomainDef with enough contents to
+ * satisfy what viraccessdriverpolkit.c references.  This is a bit
+ * fragile, but I don't know of anything better.  */
+def.name = dom-name;
+memcpy(def.uuid, dom-uuid, VIR_UUID_BUFLEN);
+
+if (!(identity = virNetServerClientGetIdentity(client)))
+goto cleanup;
+if (virIdentitySetCurrent(identity)  0)
+goto cleanup;
+ret = virConnectDomainQemuMonitorEventRegisterCheckACL(conn, def);
+
+cleanup:
+ignore_value(virIdentitySetCurrent(NULL));
+virObjectUnref(identity);
+return ret;
+}
+
+
 static int
 remoteRelayDomainEventLifecycle(virConnectPtr conn,
 virDomainPtr dom,
@@ -958,6 +986,52 @@ static virConnectNetworkEventGenericCallback 
networkEventCallbacks[] = {

 verify(ARRAY_CARDINALITY(networkEventCallbacks) == VIR_NETWORK_EVENT_ID_LAST);

+static void
+remoteRelayDomainQemuMonitorEvent(virConnectPtr conn,
+  virDomainPtr dom,
+  const char *event,
+  long long seconds,
+  unsigned int micros,
+  const char *details,
+  void *opaque)
+{
+daemonClientEventCallbackPtr callback = opaque;
+qemu_domain_monitor_event_msg data;
+char **details_p = NULL;
+
+if (callback-callbackID  0 ||
+!remoteRelayDomainQemuMonitorEventCheckACL(callback-client, conn,
+   dom))
+return;
+
+VIR_DEBUG(Relaying qemu monitor event %s %s, callback %d,
+  event, details, callback-callbackID);
+
+/* build return data */
+memset(data, 0, sizeof(data));
+data.callbackID = callback-callbackID;
+if (VIR_STRDUP(data.event, event)  0)
+goto error;
+data.seconds = seconds;
+data.micros = micros;
+if (details 
+((VIR_ALLOC(details_p)  0) ||
+ VIR_STRDUP(*details_p, details)  0))
+goto error;
+data.details = details_p;
+make_nonnull_domain(data.dom, dom);
+
+remoteDispatchObjectEventSend(callback-client, qemuProgram,
+  QEMU_PROC_DOMAIN_MONITOR_EVENT,
+  (xdrproc_t)xdr_qemu_domain_monitor_event_msg,
+  data);
+return;
+
+error:
+VIR_FREE(data.event);
+VIR_FREE(details_p);
+}
+
 /*
  * You must hold 

[libvirt] [PATCHv2 5/7] qemu: enable monitor event reporting

2014-03-12 Thread Eric Blake
Wire up all the pieces to send arbitrary qemu events to a
client using libvirt-qemu.so.  If the extra bookkeeping of
generating event objects even when no one is listening turns
out to be noticeable, we can try to further optimize things
by adding a counter for how many connections are using events,
and only dump events when the counter is non-zero; but for
now, I didn't think it was worth the code complexity.

* src/qemu/qemu_driver.c
(qemuConnectDomainQemuMonitorEventRegister)
(qemuConnectDomainQemuMonitorEventDeregister): New functions.
* src/qemu/qemu_monitor.h (qemuMonitorEmitEvent): New prototype.
(qemuMonitorDomainEventCallback): New typedef.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONIOProcessEvent):
Report events.
* src/qemu/qemu_monitor.c (qemuMonitorEmitEvent): New function, to
pass events through.
* src/qemu/qemu_process.c (qemuProcessHandleEvent): Likewise.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 src/qemu/qemu_driver.c   | 51 
 src/qemu/qemu_monitor.c  | 14 
 src/qemu/qemu_monitor.h  | 13 ++-
 src/qemu/qemu_monitor_json.c | 21 +-
 src/qemu/qemu_process.c  | 29 +
 5 files changed, 126 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b167949..378006c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16453,6 +16453,55 @@ cleanup:
 return result;
 }

+
+static int
+qemuConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
+  virDomainPtr dom,
+  const char *event,
+  
virConnectDomainQemuMonitorEventCallback callback,
+  void *opaque,
+  virFreeCallback freecb,
+  unsigned int flags)
+{
+virQEMUDriverPtr driver = conn-privateData;
+int ret = -1;
+
+if (virConnectDomainQemuMonitorEventRegisterEnsureACL(conn)  0)
+goto cleanup;
+
+if (virDomainQemuMonitorEventStateRegisterID(conn,
+ driver-domainEventState,
+ dom, event, callback,
+ opaque, freecb, flags,
+ ret)  0)
+ret = -1;
+
+cleanup:
+return ret;
+}
+
+
+static int
+qemuConnectDomainQemuMonitorEventDeregister(virConnectPtr conn,
+int callbackID)
+{
+virQEMUDriverPtr driver = conn-privateData;
+int ret = -1;
+
+if (virConnectDomainQemuMonitorEventDeregisterEnsureACL(conn)  0)
+goto cleanup;
+
+if (virObjectEventStateDeregisterID(conn, driver-domainEventState,
+callbackID)  0)
+goto cleanup;
+
+ret = 0;
+
+cleanup:
+return ret;
+}
+
+
 static int
 qemuDomainFSTrim(virDomainPtr dom,
  const char *mountPoint,
@@ -16796,6 +16845,8 @@ static virDriver qemuDriver = {
 .domainQemuMonitorCommand = qemuDomainQemuMonitorCommand, /* 0.8.3 */
 .domainQemuAttach = qemuDomainQemuAttach, /* 0.9.4 */
 .domainQemuAgentCommand = qemuDomainQemuAgentCommand, /* 0.10.0 */
+.connectDomainQemuMonitorEventRegister = 
qemuConnectDomainQemuMonitorEventRegister, /* 1.2.3 */
+.connectDomainQemuMonitorEventDeregister = 
qemuConnectDomainQemuMonitorEventDeregister, /* 1.2.3 */
 .domainOpenConsole = qemuDomainOpenConsole, /* 0.8.6 */
 .domainOpenGraphics = qemuDomainOpenGraphics, /* 0.9.7 */
 .domainInjectNMI = qemuDomainInjectNMI, /* 0.9.2 */
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index e4707b7..38bf169 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1164,6 +1164,20 @@ int qemuMonitorGetDiskSecret(qemuMonitorPtr mon,
 }


+int
+qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
+ long long seconds, unsigned int micros,
+ const char *details)
+{
+int ret = -1;
+VIR_DEBUG(mon=%p event=%s, mon, event);
+
+QEMU_MONITOR_CALLBACK(mon, ret, domainEvent, mon-vm, event, seconds,
+  micros, details);
+return ret;
+}
+
+
 int qemuMonitorEmitShutdown(qemuMonitorPtr mon)
 {
 int ret = -1;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 7bb465b..f626cc1 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1,7 +1,7 @@
 /*
  * qemu_monitor.h: interaction with QEMU monitor console
  *
- * Copyright (C) 2006-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2014 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -90,6 +90,13 @@ typedef int 
(*qemuMonitorDiskSecretLookupCallback)(qemuMonitorPtr mon,

[libvirt] [PATCHv2 3/7] qemu: create object for qemu monitor events

2014-03-12 Thread Eric Blake
Create qemu monitor events as a distinct class to normal domain
events, because they will be filtered differently.  For ease of
review, the logic for filtering by event name is saved for a later
patch.

* src/conf/domain_event.c (virDomainQemuMonitorEventClass): New
class.
(virDomainEventsOnceInit): Register it.
(virDomainQemuMonitorEventDispose, virDomainQemuMonitorEventNew)
(virDomainQemuMonitorEventDispatchFunc)
(virDomainQemuMonitorEventStateRegisterID): New functions.
* src/conf/domain_event.h (virDomainQemuMonitorEventNew)
(virDomainQemuMonitorEventStateRegisterID): New prototypes.
* src/libvirt_private.syms (conf/domain_conf.h): Export them.
---
 src/conf/domain_event.c  | 144 +++
 src/conf/domain_event.h  |  23 
 src/libvirt_private.syms |   2 +
 3 files changed, 169 insertions(+)

diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 9c18922..01c0ae6 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -48,6 +48,7 @@ static virClassPtr virDomainEventTrayChangeClass;
 static virClassPtr virDomainEventBalloonChangeClass;
 static virClassPtr virDomainEventDeviceRemovedClass;
 static virClassPtr virDomainEventPMClass;
+static virClassPtr virDomainQemuMonitorEventClass;


 static void virDomainEventDispose(void *obj);
@@ -62,6 +63,7 @@ static void virDomainEventTrayChangeDispose(void *obj);
 static void virDomainEventBalloonChangeDispose(void *obj);
 static void virDomainEventDeviceRemovedDispose(void *obj);
 static void virDomainEventPMDispose(void *obj);
+static void virDomainQemuMonitorEventDispose(void *obj);

 static void
 virDomainEventDispatchDefaultFunc(virConnectPtr conn,
@@ -69,6 +71,12 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
   virConnectObjectEventGenericCallback cb,
   void *cbopaque);

+static void
+virDomainQemuMonitorEventDispatchFunc(virConnectPtr conn,
+  virObjectEventPtr event,
+  virConnectObjectEventGenericCallback cb,
+  void *cbopaque);
+
 struct _virDomainEvent {
 virObjectEvent parent;

@@ -181,6 +189,17 @@ struct _virDomainEventPM {
 typedef struct _virDomainEventPM virDomainEventPM;
 typedef virDomainEventPM *virDomainEventPMPtr;

+struct _virDomainQemuMonitorEvent {
+virObjectEvent parent;
+
+char *event;
+long long seconds;
+unsigned int micros;
+char *details;
+};
+typedef struct _virDomainQemuMonitorEvent virDomainQemuMonitorEvent;
+typedef virDomainQemuMonitorEvent *virDomainQemuMonitorEventPtr;
+

 static int
 virDomainEventsOnceInit(void)
@@ -257,6 +276,12 @@ virDomainEventsOnceInit(void)
   sizeof(virDomainEventPM),
   virDomainEventPMDispose)))
 return -1;
+if (!(virDomainQemuMonitorEventClass =
+  virClassNew(virClassForObjectEvent(),
+  virDomainQemuMonitorEvent,
+  sizeof(virDomainQemuMonitorEvent),
+  virDomainQemuMonitorEventDispose)))
+return -1;
 return 0;
 }

@@ -382,6 +407,16 @@ virDomainEventPMDispose(void *obj)
 VIR_DEBUG(obj=%p, event);
 }

+static void
+virDomainQemuMonitorEventDispose(void *obj)
+{
+virDomainQemuMonitorEventPtr event = obj;
+VIR_DEBUG(obj=%p, event);
+
+VIR_FREE(event-event);
+VIR_FREE(event-details);
+}
+

 static void *
 virDomainEventNew(virClassPtr klass,
@@ -1313,6 +1348,65 @@ cleanup:
 }


+virObjectEventPtr
+virDomainQemuMonitorEventNew(int id,
+ const char *name,
+ const unsigned char *uuid,
+ const char *event,
+ long long seconds,
+ unsigned int micros,
+ const char *details)
+{
+virDomainQemuMonitorEventPtr ev;
+
+if (virDomainEventsInitialize()  0)
+return NULL;
+
+if (!(ev = virObjectEventNew(virDomainQemuMonitorEventClass,
+ virDomainQemuMonitorEventDispatchFunc,
+ 0, id, name, uuid)))
+return NULL;
+
+/* event is mandatory, details are optional */
+if (VIR_STRDUP(ev-event, event) = 0)
+goto error;
+ev-seconds = seconds;
+ev-micros = micros;
+if (VIR_STRDUP(ev-details, details)  0)
+goto error;
+
+return (virObjectEventPtr)ev;
+
+error:
+virObjectUnref(ev);
+return NULL;
+}
+
+
+static void
+virDomainQemuMonitorEventDispatchFunc(virConnectPtr conn,
+  virObjectEventPtr event,
+  virConnectObjectEventGenericCallback cb,
+  void *cbopaque)
+{
+virDomainPtr dom = virGetDomain(conn, event-meta.name, event-meta.uuid);
+virDomainQemuMonitorEventPtr qemuMonitorEvent;
+
+  

[libvirt] [PATCHv2 7/7] qemu: allow filtering events by regex

2014-03-12 Thread Eric Blake
When listening for a subset of monitor events, it can be tedious
to register for each event name in series; nicer is to register
for multiple events in one go.  Implement a flag to use regex
interpretation of the event filter.

While at it, prove how much I hate the shift key, by adding a
way to filter for 'shutdown' instead of 'SHUTDOWN'. :)

* include/libvirt/libvirt-qemu.h
(virConnectDomainQemuMonitorEventRegisterFlags): New enum.
* src/libvirt-qemu.c (virConnectDomainQemuMonitorEventRegister):
Document flags.
* tools/virsh-domain.c (cmdQemuMonitorEvent): Expose them.
* tools/virsh.pod (qemu-monitor-event): Document this.
* src/conf/domain_event.c
(virDomainQemuMonitorEventStateRegisterID): Add flags.
(virDomainQemuMonitorEventFilter): Handle regex, and optimize
client side.
(virDomainQemuMonitorEventCleanup): Clean up regex.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 include/libvirt/libvirt-qemu.h | 10 ++
 src/conf/domain_event.c| 45 +-
 src/libvirt-qemu.c | 11 +++
 tools/virsh-domain.c   | 13 
 tools/virsh.pod|  5 -
 5 files changed, 74 insertions(+), 10 deletions(-)

diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
index ed6d3d2..0c5d650 100644
--- a/include/libvirt/libvirt-qemu.h
+++ b/include/libvirt/libvirt-qemu.h
@@ -76,6 +76,16 @@ typedef void 
(*virConnectDomainQemuMonitorEventCallback)(virConnectPtr conn,
  const char *details,
  void *opaque);

+
+typedef enum {
+/* Event filter is a regex rather than a literal string */
+VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX = (1  0),
+
+/* Event filter is case insensitive */
+VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_NOCASE = (1  1),
+} virConnectDomainQemuMonitorEventRegisterFlags;
+
+
 int virConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
  virDomainPtr dom,
  const char *event,
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index a2880fd..ac41d2b 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -24,6 +24,8 @@

 #include config.h

+#include regex.h
+
 #include domain_event.h
 #include object_event.h
 #include object_event_private.h
@@ -1389,6 +1391,8 @@ error:
  * deregisters.  */
 struct virDomainQemuMonitorEventData {
 char *event;
+regex_t regex;
+unsigned int flags;
 void *opaque;
 virFreeCallback freecb;
 };
@@ -1608,6 +1612,12 @@ virDomainQemuMonitorEventFilter(virConnectPtr conn 
ATTRIBUTE_UNUSED,

 monitorEvent = (virDomainQemuMonitorEventPtr) event;

+if (data-flags == -1)
+return true;
+if (data-flags  VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX)
+return regexec(data-regex, monitorEvent-event, 0, NULL, 0) == 0;
+if (data-flags  VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_NOCASE)
+return STRCASEEQ(monitorEvent-event, data-event);
 return STREQ(monitorEvent-event, data-event);
 }

@@ -1618,6 +1628,8 @@ virDomainQemuMonitorEventCleanup(void *opaque)
 virDomainQemuMonitorEventData *data = opaque;

 VIR_FREE(data-event);
+if (data-flags  VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX)
+regfree(data-regex);
 if (data-freecb)
 (data-freecb)(data-opaque);
 VIR_FREE(data);
@@ -1633,7 +1645,8 @@ virDomainQemuMonitorEventCleanup(void *opaque)
  * @cb: function to invoke when event occurs
  * @opaque: data blob to pass to callback
  * @freecb: callback to free @opaque
- * @flags: -1 for client, or set of registration flags on server
+ * @flags: -1 for client, valid virConnectDomainQemuMonitorEventRegisterFlags
+ * for server
  * @callbackID: filled with callback ID
  *
  * Register the function @cb with connection @conn, from @state, for
@@ -1659,12 +1672,34 @@ virDomainQemuMonitorEventStateRegisterID(virConnectPtr 
conn,
 return -1;

 if (flags != -1)
-virCheckFlags(0, -1);
+virCheckFlags(VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX |
+  VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_NOCASE,
+  -1);
 if (VIR_ALLOC(data)  0)
 return -1;
-if (VIR_STRDUP(data-event, event)  0) {
-VIR_FREE(data);
-return -1;
+data-flags = flags;
+if (flags != -1) {
+int rflags = REG_NOSUB;
+
+if (flags  VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_NOCASE)
+rflags |= REG_ICASE;
+if (flags  VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX) {
+int err = regcomp(data-regex, event, rflags);
+
+if (err) {
+char error[100];
+regerror(err, data-regex, error, sizeof(error));
+

Re: [libvirt] [PATCH v5 1/3] add new virDomainCoreDumpWithFormat API

2014-03-12 Thread Eric Blake
On 03/12/2014 09:04 AM, Martin Kletzander wrote:
 On Thu, Mar 06, 2014 at 09:35:47AM +, qiaonuo...@cn.fujitsu.com wrote:
 --memory-only option is introduced without compression supported. Therefore,
 this is a freature regression of virsh dump. Now qemu has support dumping 
 memory
 
 s/freature/feature/
 
 but I would not use the word regression since that never worked.
 Also it would help mentioning the commit ID or a version it
 got included in qemu.  On that note, is there a possibility of
 of introspection of that feature, so we can gracefully error out in
 case older qemu is used?

Yes - qemu 2.0 is adding 'query-dump-guest-memory-capability', which can
be used for two purposes: 1. if this command exists, 'dump-guest-memory'
supports the new optional 'format' argument; and 2. calling this command
will return a list of WHICH formats are supported by the given qemu
binary (since configure-time choices can disable some of the formats
from actually working).  So you need to have a patch that modifies
src/qemu/qemu_capabilities.[ch] to do the probing and set capability
bits, so that we can gracefully error out when talking to a too-old
qemu, or requesting a format that was not compiled in to a new qemu.


 
 Looking at the rest, I rather fixed what I wanted to change in my repo
 and here's the diff I'd squash in.  Let me know if you're OK with
 that.  I'll still want an ACK from someone in order to push that,
 though.  And feel free to ask about that changes as well.

I suppose the capability detection could be done as an add-on patch, but
I'm personally thinking it's better to hold off on this series until ALL
the work is done, so we don't forget to do the capability detection work.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 5/7] Add virCommandSetMockOutputFile

2014-03-12 Thread Ján Tomko
On 03/12/2014 03:26 PM, Daniel P. Berrange wrote:
 On Wed, Mar 12, 2014 at 02:08:15PM +0100, Ján Tomko wrote:
  After this file is set, all commands executed will be replaced by
  cat file.
 I think this is a bit too special case and unecessarily forces
 use of an external cat command. I think your test would be
 easier if using this callback approach I've just proposed
 
 https://www.redhat.com/archives/libvir-list/2014-March/msg00733.html

Definitely nicer, but it doesn't work with asynchronous commands.

Jan



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] Load CPU map from builddir when run uninstalled

2014-03-12 Thread Jiri Denemark
On Tue, Mar 11, 2014 at 11:05:34 +0100, Jiri Denemark wrote:
 On Mon, Mar 10, 2014 at 12:31:00 -0600, Eric Blake wrote:
  On 03/10/2014 09:26 AM, Jiri Denemark wrote:
   When libvirtd is run from a build directory without being installed, it
   should not depend on files from a libvirt package installed in the
   system. Not only because there may not be any libvirt installed at all.
   We already do a good job for plugins but cpu_map.xml was still loaded
   from the system.
   
   The Makefile.am change is necessary to make this all work from VPATH
   builds since libvirtd has no idea where to find libvirt sources. It only
   knows the path from which it was started, i.e, a builddir.
   
  
   +++ b/src/Makefile.am
   @@ -977,6 +977,10 @@ libvirt_la_BUILT_LIBADD += libvirt_cpu.la
libvirt_cpu_la_CFLAGS = \
 -I$(top_srcdir)/src/conf $(AM_CFLAGS)
libvirt_cpu_la_SOURCES = $(CPU_SOURCES)
   +libvirt_cpu_la_DEPENDENCIES = $(abs_builddir)/cpu/cpu_map.xml
   +
   +$(abs_builddir)/cpu/cpu_map.xml:
   + $(AM_V_GEN)ln -s $(srcdir)/cpu/cpu_map.xml $@
  
  Does this really work in both VPATH (create the link) and in-tree builds
  (you would be linking a file to itself, but then again the file is
  already up-to-date so the ln doesn't get run)?  Does it pass 'make
  distcheck'?  It looks a bit odd to me, but if it works, I'm okay ACKing it.
 
 It works in in-tree builds as well as VPATH builds as long as VPATH is
 not relative. Thanks for suggesting make distcheck, which revealed this
 bug. The link command needs to be changed to
 
 $(AM_V_GEN)ln -s $(abs_srcdir)/cpu/cpu_map.xml $@
 
 so that it also works in relative VPATH build.

I pushed the patch with this small change squashed in after checking
with Eric this satisfies the if it works, I'm okay ACKing it
condition.

Jirka

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


[libvirt] [PATCH] Make ABI stability issue easier to debug

2014-03-12 Thread Jiri Denemark
When ABI stability check fails, we only log the error message describing
the incompatibility. Let's log both XMLs in case of an error to make it
easier to analyze where and why the stability check failed.

Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 src/conf/domain_conf.c | 125 -
 1 file changed, 72 insertions(+), 53 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e1b0115..a528257 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13866,13 +13866,16 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
   virDomainDefPtr dst)
 {
 size_t i;
+virErrorPtr err;
+char *strSrc;
+char *strDst;
 
 if (src-virtType != dst-virtType) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain virt type %s does not match source 
%s),
virDomainVirtTypeToString(dst-virtType),
virDomainVirtTypeToString(src-virtType));
-return false;
+goto error;
 }
 
 if (memcmp(src-uuid, dst-uuid, VIR_UUID_BUFLEN) != 0) {
@@ -13883,7 +13886,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain uuid %s does not match source %s),
uuiddst, uuidsrc);
-return false;
+goto error;
 }
 
 /* Not strictly ABI related, but we want to make sure domains
@@ -13894,60 +13897,60 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain name '%s' does not match source '%s'),
dst-name, src-name);
-return false;
+goto error;
 }
 
 if (src-mem.max_balloon != dst-mem.max_balloon) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain max memory %lld does not match source 
%lld),
dst-mem.max_balloon, src-mem.max_balloon);
-return false;
+goto error;
 }
 if (src-mem.cur_balloon != dst-mem.cur_balloon) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain current memory %lld does not match 
source %lld),
dst-mem.cur_balloon, src-mem.cur_balloon);
-return false;
+goto error;
 }
 if (src-mem.hugepage_backed != dst-mem.hugepage_backed) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain huge page backing %d does not match 
source %d),
dst-mem.hugepage_backed,
src-mem.hugepage_backed);
-return false;
+goto error;
 }
 
 if (src-vcpus != dst-vcpus) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain vCPU count %d does not match source 
%d),
dst-vcpus, src-vcpus);
-return false;
+goto error;
 }
 if (src-maxvcpus != dst-maxvcpus) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain vCPU max %d does not match source %d),
dst-maxvcpus, src-maxvcpus);
-return false;
+goto error;
 }
 
 if (STRNEQ(src-os.type, dst-os.type)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain OS type %s does not match source %s),
dst-os.type, src-os.type);
-return false;
+goto error;
 }
 if (src-os.arch != dst-os.arch){
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain architecture %s does not match source 
%s),
virArchToString(dst-os.arch),
virArchToString(src-os.arch));
-return false;
+goto error;
 }
 if (STRNEQ_NULLABLE(src-os.machine, dst-os.machine)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Target domain OS type %s does not match source %s),
dst-os.machine, src-os.machine);
-return false;
+goto error;
 }
 
 if (src-os.smbios_mode != dst-os.smbios_mode) {
@@ -13955,203 +13958,203 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
_(Target domain SMBIOS mode %s does not match source 
%s),
virDomainSmbiosModeTypeToString(dst-os.smbios_mode),
virDomainSmbiosModeTypeToString(src-os.smbios_mode));
-return false;
+goto error;
 }
 
 if (!virDomainDefFeaturesCheckABIStability(src, dst))
-return false;
+goto error;
 
 if (src-clock.ntimers != dst-clock.ntimers) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
_(Target domain timers do not match source));
-return 

Re: [libvirt] [PATCH] Make ABI stability issue easier to debug

2014-03-12 Thread Eric Blake
On 03/12/2014 09:52 AM, Jiri Denemark wrote:
 When ABI stability check fails, we only log the error message describing
 the incompatibility. Let's log both XMLs in case of an error to make it
 easier to analyze where and why the stability check failed.
 
 Signed-off-by: Jiri Denemark jdene...@redhat.com
 ---
  src/conf/domain_conf.c | 125 
 -
  1 file changed, 72 insertions(+), 53 deletions(-)


  if (!virDomainPanicCheckABIStability(src-panic, dst-panic))
 -return false;
 +goto error;
  
  return true;
 +
 +error:
 +err = virSaveLastError();
 +
 +strSrc = virDomainDefFormat(src, 0);
 +strDst = virDomainDefFormat(dst, 0);
 +VIR_DEBUG(XMLs that failed stability check were: src=\%s\, 
 dst=\%s\,
 +  NULLSTR(strSrc), NULLSTR(strDst));

Of course, the log filters have to be turned higher to allow debug
output; which means we may not see this information on bug reports until
we tell a person to rerun their test.  But the idea makes sense, and
doesn't hurt the normal path of compatible API.

ACK.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCHv2 2/7] qemu: virsh wrapper for qemu events

2014-03-12 Thread Eric Blake
Any new API deserves a good virsh wrapper :)

qemu-monitor-event [domain] [event] [--pretty] [--loop] [--timeout 
number]

Very similar to the previous work on 'virsh event'.  For an
example session:

$ virsh -c qemu:///system qemu-monitor-event --event SHUTDOWN
$ virsh -c qemu:///system start f18-live
Domain f18-live started

$ virsh -c qemu:///system destroy f18-live
Domain f18-live destroyed

event SHUTDOWN at 1391212552.026544 for domain f18-live: (null)
events received: 1

[1]+  Donevirsh -c qemu:///system qemu-monitor-event 
--event SHUTDOWN
$

* tools/virsh-domain.c (cmdQemuMonitorEvent): New command.
* tools/virsh.pod (qemu-monitor-event): Document it.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 tools/virsh-domain.c | 135 +++
 tools/virsh.pod  |  27 +--
 2 files changed, 158 insertions(+), 4 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 1d3c5f0..a5808d8 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7912,6 +7912,135 @@ cleanup:
 }

 /*
+ * qemu-monitor-event command
+ */
+
+struct vshQemuEventData {
+vshControl *ctl;
+bool loop;
+bool pretty;
+int count;
+};
+typedef struct vshQemuEventData vshQemuEventData;
+
+static void
+vshEventPrint(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainPtr dom,
+  const char *event, long long seconds, unsigned int micros,
+  const char *details, void *opaque)
+{
+vshQemuEventData *data = opaque;
+virJSONValuePtr pretty = NULL;
+char *str = NULL;
+
+if (!data-loop  data-count)
+return;
+if (data-pretty  details) {
+pretty = virJSONValueFromString(details);
+if (pretty  (str = virJSONValueToString(pretty, true)))
+details = str;
+}
+vshPrint(data-ctl, event %s at %lld.%06u for domain %s: %s\n,
+ event, seconds, micros, virDomainGetName(dom), NULLSTR(details));
+data-count++;
+if (!data-loop)
+vshEventDone(data-ctl);
+
+VIR_FREE(str);
+}
+
+static const vshCmdInfo info_qemu_monitor_event[] = {
+{.name = help,
+ .data = N_(QEMU Monitor Events)
+},
+{.name = desc,
+ .data = N_(Listen for QEMU Monitor Events)
+},
+{.name = NULL}
+};
+
+static const vshCmdOptDef opts_qemu_monitor_event[] = {
+{.name = domain,
+ .type = VSH_OT_DATA,
+ .help = N_(filter by domain name, id or uuid)
+},
+{.name = event,
+ .type = VSH_OT_DATA,
+ .help = N_(filter by event name)
+},
+{.name = pretty,
+ .type = VSH_OT_BOOL,
+ .help = N_(pretty-print any JSON output)
+},
+{.name = loop,
+ .type = VSH_OT_BOOL,
+ .help = N_(loop until timeout or interrupt, rather than one-shot)
+},
+{.name = timeout,
+ .type = VSH_OT_INT,
+ .help = N_(timeout seconds)
+},
+{.name = NULL}
+};
+
+static bool
+cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd)
+{
+virDomainPtr dom = NULL;
+bool ret = false;
+unsigned int flags = 0;
+int eventId = -1;
+int timeout = 0;
+const char *event = NULL;
+vshQemuEventData data;
+
+data.ctl = ctl;
+data.loop = vshCommandOptBool(cmd, loop);
+data.pretty = vshCommandOptBool(cmd, pretty);
+data.count = 0;
+if (vshCommandOptTimeoutToMs(ctl, cmd, timeout)  0)
+return false;
+if (vshCommandOptString(cmd, event, event)  0)
+return false;
+
+if (vshCommandOptBool(cmd, domain))
+dom = vshCommandOptDomain(ctl, cmd, NULL);
+if (vshEventStart(ctl, timeout)  0)
+goto cleanup;
+
+if ((eventId = virConnectDomainQemuMonitorEventRegister(ctl-conn, dom,
+event,
+vshEventPrint,
+data, NULL,
+flags))  0)
+goto cleanup;
+switch (vshEventWait(ctl)) {
+case VSH_EVENT_INTERRUPT:
+vshPrint(ctl, _(event loop interrupted\n));
+break;
+case VSH_EVENT_TIMEOUT:
+vshPrint(ctl, _(event loop timed out\n));
+break;
+case VSH_EVENT_DONE:
+break;
+default:
+goto cleanup;
+}
+vshPrint(ctl, _(events received: %d\n), data.count);
+if (data.count)
+ret = true;
+
+cleanup:
+vshEventCleanup(ctl);
+if (eventId = 0 
+virConnectDomainQemuMonitorEventDeregister(ctl-conn, eventId)  0)
+ret = false;
+if (dom)
+virDomainFree(dom);
+
+return ret;
+}
+
+/*
  * qemu-attach command
  */
 static const vshCmdInfo info_qemu_attach[] = {
@@ -11546,6 +11675,12 @@ const vshCmdDef domManagementCmds[] = {
  .info = info_qemu_monitor_command,
  .flags = 0
 },
+{.name = qemu-monitor-event,
+ .handler = cmdQemuMonitorEvent,
+ .opts = opts_qemu_monitor_event,
+ .info = 

Re: [libvirt] [PATCH v14 48/49] add hostdev pci backend type for xen

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:15PM +0800, Chunyan Liu wrote:
 Add VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN. For legacy xen, it will use pciback 
 as
 stub driver.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  docs/schemas/domaincommon.rng |  1 +
  src/conf/domain_conf.c|  3 ++-
  src/conf/domain_conf.h|  1 +
  src/libxl/libxl_domain.c  |  9 +
  src/qemu/qemu_command.c   |  3 +--
  src/qemu/qemu_hostdev.c   |  1 +
  src/qemu/qemu_hotplug.c   |  4 +---
  src/util/virhostdev.c | 10 ++
  8 files changed, 26 insertions(+), 6 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 46/49] add unit test for new virhostdev common library

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:13PM +0800, Chunyan Liu wrote:
 Add unit test for hostdev common library. Current tests are based on 
 virpcimock.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  .gitignore |   1 +
  tests/Makefile.am  |   5 +
  tests/virhostdevtest.c | 507 
 +
  3 files changed, 513 insertions(+)
  create mode 100644 tests/virhostdevtest.c

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 49/49] add pci passthrough to libxl driver

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:16PM +0800, Chunyan Liu wrote:
 Add pci passthrough to libxl driver, support attach-device, detach-device and
 start a vm with pci hostdev specified.
 
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/libxl/libxl_conf.c   |  63 +++
  src/libxl/libxl_conf.h   |   7 +-
  src/libxl/libxl_driver.c | 454 
 ++-
  3 files changed, 518 insertions(+), 6 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 47/49] change lxc_hostdev.c to use virhostdev common library APIs

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:53:14PM +0800, Chunyan Liu wrote:
 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  src/lxc/lxc_hostdev.c | 305 
 ++
  1 file changed, 10 insertions(+), 295 deletions(-)

ACK


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v14 00/49] write separate module for hostdev passthrough

2014-03-12 Thread Daniel P. Berrange
On Fri, Mar 07, 2014 at 06:52:27PM +0800, Chunyan Liu wrote:
 These patches implements a separate module for hostdev passthrough so that it
 could be shared by different drivers and can maintain a global state of a host
 device.
 
 Patch 1: fix memory leak in virscsi.c
 Patch 2: improve virHostdevManager to use virOject wrapper and keep reference
 
 Patches 3~7: switch existing qemu and lxc driver to use virHostdevManager's
 lists, so that to maintain a global state of every host device.
 
 Patches 8~45 are to extract general code from qemu_hostdev.c piece by piece,
 make them reusable common APIs.
 
 Patches 46: unit test for the virhostdev common library
 Patches 47: add a hostdev backend type for xen
 Patches 48: add pci passthrough to libxl driver based on the common library
 Patches 49: change lxc to use common library APIs

I have now pushed all the patches together with the fixes for them
I suggested in various comments.


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [python PATCH 1/2] qemu: support arbitrary monitor events

2014-03-12 Thread Eric Blake
On 02/04/2014 07:01 PM, Eric Blake wrote:
 Wrap the new virConnectDomainQemuMonitorEventRegister function
 being added in libvirt 1.2.2.  This patch copies heavily from
 network events (commit 6ea5be0) and from event loop callbacks
 in libvirt-override.c, since in the libvirt_qemu module, we
 must expose top-level functions rather than class members.

Just realized I need to tweak this to say 1.2.3, since the new API
missed 1.2.


-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [libvirt-python PATCH] setup: Make libvirt API XML path configurable

2014-03-12 Thread Eric Blake
Revisiting an older thread

On 11/26/2013 07:38 AM, Martin Kletzander wrote:
 On Tue, Nov 26, 2013 at 10:14:36AM +, Daniel P. Berrange wrote:
 On Tue, Nov 26, 2013 at 10:58:25AM +0100, Martin Kletzander wrote:
 Adding a support for LIBVIRT_API_PATH evironment variable, which can
 control where the script should look for the 'libvirt-api.xml' file.
 This allows building libvirt-python against different libvirt than the
 one installed in the system.  This may be used for example in autotest
 or by packagers without the need to install libvirt into the system.


 -libvirt_api = get_pkgconfig_data([--variable, libvirt_api], 
 libvirt)
 +libvirt_api = os.getenv(LIBVIRT_API_PATH)
 +


 NACK, setting pkg-config already takes care of this. See the
 build-many.sh scrpit attached to this mail which demonstrates
 use of PKG_CONFIG_PATH to build against every version of libvirt
 back to 0.9.11

 
 This still means you have to configure libvirt with different prefix,
 install it and then you can use PKG_CONFIG_PATH.  This variable (which
 is unused if unset) makes it easier to use in case you have it built
 with default prefix etc.  It would help me a lot, but if everyone else
 is OK with installing libvirt in order to build python bindings just
 to test something, I'll keep this in my git.

I'm still interested in the ability to test libvirt-python against an
uninstalled libvirt tree.  Should we revisit this patch, or something
like it?

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v5 1/3] add new virDomainCoreDumpWithFormat API

2014-03-12 Thread Daniel P. Berrange
On Thu, Mar 06, 2014 at 09:35:47AM +, qiaonuo...@cn.fujitsu.com wrote:
 --memory-only option is introduced without compression supported. Therefore,
 this is a freature regression of virsh dump. Now qemu has support dumping 
 memory
 in kdump-compressed format. This patch is adding new 
 virDomainCoreDumpWithFormat
 API, so that the format in which qemu dump domain's memory can be specified.
 

 +int
 +virDomainCoreDumpWithFormat(virDomainPtr domain, const char *to, unsigned int
 +dumpformat, unsigned int flags)
 +{
 +virConnectPtr conn;
 +
 +VIR_DOMAIN_DEBUG(domain, to=%s, flags=%x, to, flags);
 +
 +virResetLastError();
 +
 +virCheckDomainReturn(domain, -1);
 +conn = domain-conn;
 +
 +virCheckReadOnlyGoto(conn-flags, error);
 +virCheckNonNullArgGoto(to, error);
 +
 +if (dumpformat = VIR_DUMP_FORMAT_LAST) {
 +virReportInvalidArg(flags, _(dumpformat '%d' is not supproted),


s/supproted/supported/


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] [PATCH] Fix type mismatch of virNetDev*NetConfig on non-Linux

2014-03-12 Thread Ján Tomko
Commit b4bbaee changed char* to const char*, but omitted
the non-Linux version.
---
Pushed as a build breaker fix.

 src/util/virnetdev.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 9d8b7cf..55781b2 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1802,11 +1802,11 @@ virNetDevLinkDump(const char *ifname ATTRIBUTE_UNUSED,
 }
 
 int
-virNetDevReplaceNetConfig(char *linkdev ATTRIBUTE_UNUSED,
+virNetDevReplaceNetConfig(const char *linkdev ATTRIBUTE_UNUSED,
   int vf ATTRIBUTE_UNUSED,
   const virMacAddr *macaddress ATTRIBUTE_UNUSED,
   int vlanid ATTRIBUTE_UNUSED,
-  char *stateDir ATTRIBUTE_UNUSED)
+  const char *stateDir ATTRIBUTE_UNUSED)
 {
 virReportSystemError(ENOSYS, %s,
  _(Unable to replace net config on this platform));
@@ -1815,9 +1815,9 @@ virNetDevReplaceNetConfig(char *linkdev ATTRIBUTE_UNUSED,
 }
 
 int
-virNetDevRestoreNetConfig(char *linkdev ATTRIBUTE_UNUSED,
+virNetDevRestoreNetConfig(const char *linkdev ATTRIBUTE_UNUSED,
   int vf ATTRIBUTE_UNUSED,
-  char *stateDir ATTRIBUTE_UNUSED)
+  const char *stateDir ATTRIBUTE_UNUSED)
 {
 virReportSystemError(ENOSYS, %s,
  _(Unable to restore net config on this platform));
-- 
1.8.3.2

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


Re: [libvirt] [PATCH v5 3/3] allow virsh dump --memory-only specify dump format

2014-03-12 Thread Daniel P. Berrange
On Thu, Mar 06, 2014 at 09:35:47AM +, qiaonuo...@cn.fujitsu.com wrote:
 This patch is used to add --compress and [--compression-format] string 
 to
 virsh dump --memory-only. And virsh dump --memory-only is going be
 implemented by new virDomainCoreDumpWithFormat API.
 
 Signed-off-by: Qiao Nuohan qiaonuo...@cn.fujitsu.com
 ---
  tools/virsh-domain.c | 45 -
  1 file changed, 44 insertions(+), 1 deletion(-)
 
 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
 index 2e3f0ed..70613e5 100644
 --- a/tools/virsh-domain.c
 +++ b/tools/virsh-domain.c
 @@ -4486,6 +4486,14 @@ static const vshCmdOptDef opts_dump[] = {
   .type = VSH_OT_BOOL,
   .help = N_(dump domain's memory only)
  },
 +{.name = compress,
 + .type = VSH_OT_BOOL,
 + .help = N_(make qemu dump domain's memory in kdump-compressed format)
 +},
 +{.name = compression-format,
 + .type = VSH_OT_DATA,
 + .help = N_(specify the compression format of kdump-compressed format)
 +},

As before, IMHO having two args here is silly. Just have a
single '--compress format' arg.

 @@ -4524,7 +4535,39 @@ doDump(void *opaque)
  if (vshCommandOptBool(cmd, memory-only))
  flags |= VIR_DUMP_MEMORY_ONLY;
  
 -if (virDomainCoreDump(dom, to, flags)  0) {

[snip]

 +if (virDomainCoreDumpWithFormat(dom, to, memory_dump_format, flags)  0) 
 {

This breaks virsh dump if used against an older libvirtd.

We must *only* invoke virDomainCoreDumpWithFormat if the user
has specified a 'memory_dump_format' value


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] RFC: Exposing backing chains in domain XML

2014-03-12 Thread Eric Blake
tl;dr:
I am working on a series of patches to expose backing chain information
in domain XML.  Comments are welcome, to make sure my XML design is on
the right track.

Purpose
===
Among other things, this will help us support Peter's proposal of
enhancing the block-pull and block-commit actions to specify a
destination by relative depth in the backing chain (where vda[0]
represents the active image, vda[1] represents the backing file of the
active image, and so on).

It will also help debug situations where libvirt and qemu disagree on
what constitutes a backing chain, and therefore causes sVirt labeling
discrepancies or prohibits block-pull/block-commit actions.  For
example, given the chain base - mid - top, if top forgot the
backing_fmt attribute, and /etc/libvirt/qemu.conf
allow_disk_format_probing=0 (which it is by default for security
resasons), libvirt treats 'mid' as a raw file and refuses to acknowledge
that 'base' is part of the chain, while qemu would happily treat mid as
qcow2 and therefore use 'base' if permissions allow it to.  I have
helped debug this scenario several times on IRC or in bugzilla reports.

This feature is being driven in part by
https://bugzilla.redhat.com/show_bug.cgi?id=1069407

Existing design
===
Note that libvirt can already expose backing file details (but only one
layer; it is not recursive) when using virStorageVolGetXMLDesc(); for
example:

# virsh vol-dumpxml --pool gluster img3
volume type='network'
  nameimg3/name
  keyvol1/img3/key
...
  target
pathgluster://localhost/vol1/img3/path
format type='qcow2'/
...
  /target
  backingStore
pathgluster://localhost/vol1/img2/path
format type='qcow2'/
permissions
  mode00/mode
  owner0/owner
  group0/group
/permissions
  /backingStore
/volume

In the current volume representation, if a backingStore element is
present, it gives the path to the backing file.  But this
representation is a bit limited: it is rather hard-coded to the
assumption that there is only one backing file, and does not do a good
job when the backing image is not in the same storage pool as the volume
it is describing.  Some of the enhancements I'm proposing for domain
should also be applied to the information output by volume XML, which
means I have to be careful that the design I'm proposing will mesh well
with the storage xml to maximize code reuse.

The volume approach is a bit painful to users trying to track the
backing chain of a disk tied to a domain because it necessitates
creating a storage pool and making multiple calls to follow the chain,
so we need to expose the backing chain directly in the disk element of
a domain, and recursively show the entire chain.  Furthermore, there are
some formats that require multiple resources: for example, both qemu
2.0's new quorum driver and HyperV VHDX images can have multiple backing
files, and where these files can in turn have more backing images.
Thus, any proper representation of disk resources needs to show a full
tree of relationships.  Thankfully, circular references in backing files
would form an invalid image (all known virtual disk image formats
require a DAG of relationships).

With existing API, we still have not fully implemented 'virsh
snapshot-delete' of external snapshots.  So our current advice is for
people to manually use qemu-img to alter backing chains, then update
libvirt to match.  Once libvirt starts tracking backing chains, it
becomes all the more important to provide two new actions in libvirt: we
need a validation mode (check that what is recorded on disk matches what
is recorded in XML and flag an error if they differ) and a correction
mode (ignore what is recorded in XML and regenerate it to match what is
actually on disk).

Proposal

For each disk of a domain, I will be adding a new backingStore
element.  The element is optional on input, which allows libvirt to
continue to understand input from older versions, but will always be
present on output, to show what libvirt is tracking as the backing chain.

For a file with no backing store (including raw file format), the usage
is simple:

disk type='file' device='disk'
  driver name='qemu' type='raw'/
  source file='/path/to/somewhere'/
  backingStore/
  target dev='vda' bus='virtio'/
/disk

The new explicit backingStore/ makes it clear that there is no backing
chain.

A backing chain of 3 files (base - mid - top) in the local file system:

disk type='file' device='disk'
  driver name='qemu' type='qcow2'/
  source file='/var/lib/libvirt/images/top.qcow2'/
  backingStore type='file'
driver name='qemu' type='qcow2'/
source file='/var/lib/libvirt/images/mid.qcow2'/
backingStore type='file'
  driver name='qemu' type='qcow2'/
  source file='/var/lib/libvirt/images/base.qcow2'/
  backingStore/
/backingStore
  /backingStore
  target dev='vda' bus='virtio'/
/disk

Note 

Re: [libvirt] RFC: Exposing backing chains in domain XML

2014-03-12 Thread Peter Krempa
On 03/12/14 21:21, Eric Blake wrote:
 tl;dr:
 I am working on a series of patches to expose backing chain information
 in domain XML.  Comments are welcome, to make sure my XML design is on
 the right track.
 

...

 Existing design
 ===

...

 a domain, and recursively show the entire chain.  Furthermore, there are
 some formats that require multiple resources: for example, both qemu
 2.0's new quorum driver and HyperV VHDX images can have multiple backing

With this in mind ...

 files, and where these files can in turn have more backing images.
 Thus, any proper representation of disk resources needs to show a full
 tree of relationships.  Thankfully, circular references in backing files
 would form an invalid image (all known virtual disk image formats
 require a DAG of relationships).

...

 
 Proposal
 
 For each disk of a domain, I will be adding a new backingStore
 element.  The element is optional on input, which allows libvirt to
 continue to understand input from older versions, but will always be
 present on output, to show what libvirt is tracking as the backing chain.
 
 A backing chain of 3 files (base - mid - top) in the local file system:
 
 disk type='file' device='disk'
   driver name='qemu' type='qcow2'/
   source file='/var/lib/libvirt/images/top.qcow2'/
   backingStore type='file'
 driver name='qemu' type='qcow2'/

... we should add an attribute with the index of the backing chain
element in the backing chain. This will:

1) allow easier user retrieval of the index to be used for block_rebase

2) allow us to avoid ambiguity when a backing chain will become a
backing tree without the need to invent some kind of hierarchical
indexing approach. Instead we can just number the backing elements in
some (internal) fashion and expect the users to provide the correct index.

 source file='/var/lib/libvirt/images/mid.qcow2'/
 backingStore type='file'
   driver name='qemu' type='qcow2'/
   source file='/var/lib/libvirt/images/base.qcow2'/
   backingStore/
 /backingStore
   /backingStore
   target dev='vda' bus='virtio'/
 /disk
 

My first impression is good though. I will go through the design again
tomorrow in a more in-depth way.

Peter



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] Fix Invalid write in virCryptoHashString()

2014-03-12 Thread Nehal J Wani
While running vircryptotest, it was found that valgrind pointed out the
following error:

==27453== Invalid write of size 1
==27453==at 0x4C7D7C9: virCryptoHashString (vircrypto.c:76)
==27453==by 0x401C4E: testCryptoHash (vircryptotest.c:41)
==27453==by 0x402A11: virtTestRun (testutils.c:199)
==27453==by 0x401AD5: mymain (vircryptotest.c:76)
==27453==by 0x40318D: virtTestMain (testutils.c:782)
==27453==by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
==27453==  Address 0x51f0541 is 0 bytes after a block of size 65 alloc'd
==27453==at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==27453==by 0x4C69F2E: virAllocN (viralloc.c:189)
==27453==by 0x4C7D76B: virCryptoHashString (vircrypto.c:69)
==27453==by 0x401C4E: testCryptoHash (vircryptotest.c:41)
==27453==by 0x402A11: virtTestRun (testutils.c:199)
==27453==by 0x401AD5: mymain (vircryptotest.c:76)
==27453==by 0x40318D: virtTestMain (testutils.c:782)
==27453==by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
==27453==

...and many more

---
The errors go away, if I either do:
Line 76: (*output)[hashstrlen - 1] = '\0';
or
Line 61: if (VIR_ALLOC_N(*output, hashstrlen + 1)  0)
But the second one seems less harmful, as anyway we are going to free
that memory.

 src/util/vircrypto.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c
index 3af3aa3..aa2b0c8 100644
--- a/src/util/vircrypto.c
+++ b/src/util/vircrypto.c
@@ -66,7 +66,7 @@ virCryptoHashString(virCryptoHash hash,
 return -1;
 }
 
-if (VIR_ALLOC_N(*output, hashstrlen)  0)
+if (VIR_ALLOC_N(*output, hashstrlen + 1)  0)
 return -1;
 
 for (i = 0; i  hashinfo[hash].hashlen; i++) {
-- 
1.7.1

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


Re: [libvirt] [PATCH] Fix Invalid write in virCryptoHashString()

2014-03-12 Thread Eric Blake
On 03/12/2014 03:44 PM, Nehal J Wani wrote:
 While running vircryptotest, it was found that valgrind pointed out the
 following error:
 
 ==27453== Invalid write of size 1
 ==27453==at 0x4C7D7C9: virCryptoHashString (vircrypto.c:76)

 
 ---
 The errors go away, if I either do:
 Line 76: (*output)[hashstrlen - 1] = '\0';

This is correct, since we  initialized hashstrlen to be strlen()+1 in
the first place.

 or
 Line 61: if (VIR_ALLOC_N(*output, hashstrlen + 1)  0)
 But the second one seems less harmful, as anyway we are going to free
 that memory.

Overallocating by 2 is pointless.  But so is writing a trailing NUL, as
the string is already zero-initialized by VIR_ALLOC_N.

So the CORRECT fix, which I am pushing shortly, is to just delete the
redundant line:
(*output)[hashstrlen] = '\0';


-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

  1   2   >