Re: [libvirt] [PATCH] net: merge virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC

2014-06-27 Thread Peter Krempa
On 06/26/14 17:29, Ján Tomko wrote:
 On 06/26/2014 04:51 PM, Peter Krempa wrote:
 Instead of maintaining two very similar APIs, add the @mac parameter
 to virNetworkGetDHCPLeases and kill virNetworkGetDHCPLeasesForMAC. Both
 of those functions would return data the same way, so making @mac an
 optional filter simplifies a lot of stuff.
 ---
  daemon/remote.c  | 69 +-
  include/libvirt/libvirt.h.in |  6 +---
  src/driver.h |  8 +
  src/libvirt.c| 70 
 ++-
  src/libvirt_public.syms  |  1 -
  src/network/bridge_driver.c  | 69 +++---
  src/remote/remote_driver.c   | 71 
 ++--
  src/remote/remote_protocol.x | 20 ++---
  src/remote_protocol-structs  | 15 +-
  tools/virsh-network.c|  5 +---
  10 files changed, 35 insertions(+), 299 deletions(-)

 
 diff --git a/src/libvirt.c b/src/libvirt.c
 index 566f984..49c9d16 100644
 --- a/src/libvirt.c
 +++ b/src/libvirt.c
 
 @@ -21110,65 +21117,6 @@ virNetworkGetDHCPLeases(virNetworkPtr network,
  return -1;
  }

 -/**
 - * virNetworkGetDHCPLeasesForMAC:
 - * @network: Pointer to network object
 - * @mac: ASCII formatted MAC address of an interface
 - * @leases: Pointer to a variable to store the array containing details on
 - *  obtained leases, or NULL if the list is not required (just 
 returns
 - *  number of leases).
 - * @flags: extra flags, not used yet, so callers should always pass 0
 - *
 - * The API fetches leases info of the interface which matches with the
 - * given @mac. There can be multiple leases for a single @mac because this
 - * API supports DHCPv6 too.
 - *
 - * Returns the number of leases found or -1 and sets @leases to NULL in 
 case of
 - * error. On success, the array stored into @leases is guaranteed to have an
 - * extra allocated element set to NULL but not included in the return count,
 - * to make iteration easier. The caller is responsible for calling
 - * virNetworkDHCPLeaseFree() on each array element, then calling free() on 
 @leases.
 - *
 - * See virNetworkGetDHCPLeases() for more details on list contents.
 - */
 -int
 -virNetworkGetDHCPLeasesForMAC(virNetworkPtr network,
 -  const char *mac,
 -  virNetworkDHCPLeasePtr **leases,
 -  unsigned int flags)
 -{
 -virConnectPtr conn;
 -
 -VIR_DEBUG(network=%p, mac=%s, leases=%p, flags=%x,
 -   network, mac, leases, flags);
 
 You should add mac to the debug message at the start of the other API.
 
 -
 -virResetLastError();
 -
 -if (leases)
 -*leases = NULL;
 -
 -virCheckNonNullArgGoto(mac, error);
 -
 -virCheckNetworkReturn(network, -1);
 
 
 --- a/src/remote/remote_driver.c
 +++ b/src/remote/remote_driver.c
 @@ -7614,6 +7615,7 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net,
  remoteDriverLock(priv);

  make_nonnull_network(args.net, net);
 +args.mac = mac == NULL ? NULL : (char **) mac;
 
 Nit: mac ? (char **) mac : NULL would be IMO nicer.
 
  args.flags = flags;
  args.need_results = !!leases;

 
 diff --git a/tools/virsh-network.c b/tools/virsh-network.c
 index 2d5b9be..e7499fa 100644
 --- a/tools/virsh-network.c
 +++ b/tools/virsh-network.c
 @@ -1348,10 +1348,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd 
 *cmd)
  if (!(network = vshCommandOptNetwork(ctl, cmd, name)))
  return false;

 -nleases = mac ? virNetworkGetDHCPLeasesForMAC(network, mac, leases, 
 flags)
 -: virNetworkGetDHCPLeases(network, leases, flags);
 -
 -if (nleases  0) {
 +if ((nleases = virNetworkGetDHCPLeases(network, mac, leases, flags)  
 0)) {
 
 Wrong parenthesising.
 
 ACK with the debug message added and virsh functionality fixed.
 
 Jan
 

I've resolved all your comments and pushed this patch.

Thanks

Peter



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

[libvirt] [python PATCHv2] Implement new virNetworkGetDHCPLeases API

2014-06-27 Thread Peter Krempa
From: Nehal J Wani nehaljw.k...@gmail.com

This API returns a list of DHCP leases for all network interfaces
connected to the given virtual network or limited output just for one
interface if mac is specified.

Example Output:
[{'iface': 'virbr3', 'ipaddr': '192.168.150.181', 'hostname': 'ubuntu14',
'expirytime': 1403737495L, 'prefix': 24, 'clientid': None,
'mac': '52:54:00:e8:73:eb', 'iaid': None, 'type': 0},
 {'iface': 'virbr3', 'ipaddr': '2001:db8:ca2:2:1::bd', 'hostname': 
'fedora20-test',
'expirytime': 1403738587L, 'prefix': 64, 'clientid': 
'00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd',
'mac': '52:54:00:5b:40:98', 'iaid': '5980312', 'type': 1}]

Signed-off-by: Peter Krempa pkre...@redhat.com
---
 examples/README  |  1 +
 examples/dhcpleases.py   | 53 +
 generator.py |  4 +++
 libvirt-override-api.xml |  7 
 libvirt-override.c   | 88 
 sanitytest.py|  6 
 6 files changed, 159 insertions(+)
 create mode 100755 examples/dhcpleases.py

diff --git a/examples/README b/examples/README
index f4db76c..5b5d405 100644
--- a/examples/README
+++ b/examples/README
@@ -10,6 +10,7 @@ domsave.py  - save all running domU's into a directory
 domrestore.py - restore domU's from their saved files in a directory
 esxlist.py  - list active domains of an VMware ESX host and print some info.
   also demonstrates how to use the libvirt.openAuth() method
+dhcpleases.py - list dhcp leases for a given virtual network

 The XML files in this directory are examples of the XML format that libvirt
 expects, and will have to be adapted for your setup. They are only needed
diff --git a/examples/dhcpleases.py b/examples/dhcpleases.py
new file mode 100755
index 000..c172dc2
--- /dev/null
+++ b/examples/dhcpleases.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# netdhcpleases - print leases info for given virtual network
+
+import libvirt
+import sys
+import time
+
+def usage():
+print Usage: %s [URI] NETWORK % sys.argv[0]
+print Print leases info for a given virtual network
+
+uri = None
+network = None
+args = len(sys.argv)
+
+if args == 2:
+network = sys.argv[1]
+elif args == 3:
+uri = sys.argv[1]
+network = sys.argv[2]
+else:
+usage()
+sys.exit(2)
+
+conn = libvirt.open(uri)
+if conn == None:
+print Unable to open connection to libvirt
+sys.exit(1)
+
+try:
+net = conn.networkLookupByName(network)
+except libvirt.libvirtError:
+print Network %s not found % network
+sys.exit(0)
+
+leases = net.DHCPLeases();
+if (leases == None):
+print Failed to get leases for %s % net.name()
+sys.exit(0)
+
+def toIPAddrType(addrType):
+if addrType == libvirt.VIR_IP_ADDR_TYPE_IPV4:
+return ipv4
+elif addrType == libvirt.VIR_IP_ADDR_TYPE_IPV6:
+return ipv6
+
+print  {0:20} {1:18} {2:9} {3:25} {4:15} {5}.format(Expiry Time, MAC 
address, Protocol, IP address, Hostname, Client ID or DUID)
+print -*115
+
+for lease in leases:
+print  {0:20}.format(time.strftime('%Y-%m-%d %H:%M:%S', 
time.localtime(lease['expirytime']))),
+print {0:18} {1:9}.format(lease['mac'], toIPAddrType(lease['type'])),
+print {0:25} {1:15} {2}.format({}/{}.format(lease['ipaddr'], 
lease['prefix']), lease['hostname'], lease['clientid'])
diff --git a/generator.py b/generator.py
index 03027c6..a12c52b 100755
--- a/generator.py
+++ b/generator.py
@@ -463,6 +463,7 @@ skip_impl = (
 'virDomainMigrateToURI3',
 'virConnectGetCPUModelNames',
 'virNodeGetFreePages',
+'virNetworkGetDHCPLeases',
 )

 lxc_skip_impl = (
@@ -568,6 +569,8 @@ skip_function = (
 virTypedParamsGetString,
 virTypedParamsGetUInt,
 virTypedParamsGetULLong,
+
+'virNetworkDHCPLeaseFree', # only useful in C, python code uses list
 )

 lxc_skip_function = (
@@ -1115,6 +1118,7 @@ def nameFixup(name, classe, type, file):
 elif name[0:13] == virNetworkGet:
 func = name[13:]
 func = func[0:1].lower() + func[1:]
+func = func.replace(dHCP, DHCP)
 elif name[0:10] == virNetwork:
 func = name[10:]
 func = func[0:1].lower() + func[1:]
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index bbf0ab1..09bbbf8 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -633,5 +633,12 @@
   arg name='flags' type='int' info='unused, pass 0'/
   return type='char *' info='the list available memory in the cells'/
 /function
+function name=virNetworkGetDHCPLeases file='python'
+  infoReturns a list of dhcp leases for interfaces connected to the 
given virtual network/info
+  arg name='network' type='virNetworkPtr' info='a network object'/
+  arg name='mac' type='const char *' info='optional mac address'/
+  arg name='flags' type='unsigned int' info='unused, pass 0'/
+  return type='char *' info=list of leases/
+/function
   /symbols
 /api
diff 

Re: [libvirt] [python PATCHv2] Implement new virNetworkGetDHCPLeases API

2014-06-27 Thread Daniel P. Berrange
On Fri, Jun 27, 2014 at 10:42:33AM +0200, Peter Krempa wrote:
 From: Nehal J Wani nehaljw.k...@gmail.com
 
 This API returns a list of DHCP leases for all network interfaces
 connected to the given virtual network or limited output just for one
 interface if mac is specified.
 
 Example Output:
 [{'iface': 'virbr3', 'ipaddr': '192.168.150.181', 'hostname': 'ubuntu14',
 'expirytime': 1403737495L, 'prefix': 24, 'clientid': None,
 'mac': '52:54:00:e8:73:eb', 'iaid': None, 'type': 0},
  {'iface': 'virbr3', 'ipaddr': '2001:db8:ca2:2:1::bd', 'hostname': 
 'fedora20-test',
 'expirytime': 1403738587L, 'prefix': 64, 'clientid': 
 '00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd',
 'mac': '52:54:00:5b:40:98', 'iaid': '5980312', 'type': 1}]
 
 Signed-off-by: Peter Krempa pkre...@redhat.com
 ---
  examples/README  |  1 +
  examples/dhcpleases.py   | 53 +
  generator.py |  4 +++
  libvirt-override-api.xml |  7 
  libvirt-override.c   | 88 
 
  sanitytest.py|  6 
  6 files changed, 159 insertions(+)
  create mode 100755 examples/dhcpleases.py

ACK looks like a reasonable mapping to python.


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 PATCHv2] Implement new virNetworkGetDHCPLeases API

2014-06-27 Thread Peter Krempa
On 06/27/14 10:57, Daniel P. Berrange wrote:
 On Fri, Jun 27, 2014 at 10:42:33AM +0200, Peter Krempa wrote:
 From: Nehal J Wani nehaljw.k...@gmail.com

 This API returns a list of DHCP leases for all network interfaces
 connected to the given virtual network or limited output just for one
 interface if mac is specified.

 Example Output:
 [{'iface': 'virbr3', 'ipaddr': '192.168.150.181', 'hostname': 'ubuntu14',
 'expirytime': 1403737495L, 'prefix': 24, 'clientid': None,
 'mac': '52:54:00:e8:73:eb', 'iaid': None, 'type': 0},
  {'iface': 'virbr3', 'ipaddr': '2001:db8:ca2:2:1::bd', 'hostname': 
 'fedora20-test',
 'expirytime': 1403738587L, 'prefix': 64, 'clientid': 
 '00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd',
 'mac': '52:54:00:5b:40:98', 'iaid': '5980312', 'type': 1}]

 Signed-off-by: Peter Krempa pkre...@redhat.com
 ---
  examples/README  |  1 +
  examples/dhcpleases.py   | 53 +
  generator.py |  4 +++
  libvirt-override-api.xml |  7 
  libvirt-override.c   | 88 
 
  sanitytest.py|  6 
  6 files changed, 159 insertions(+)
  create mode 100755 examples/dhcpleases.py
 
 ACK looks like a reasonable mapping to python.
 

Pushed; Thanks.

Peter




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 RFC 0/4] Expose Expose IOMMU and VFIO host capabilities

2014-06-27 Thread Richard W.M. Jones
On Thu, Jun 26, 2014 at 12:18:24PM +0200, Michal Privoznik wrote:
[...]
   enum name='bus'
 valueide/value
 valuefdc/value
 valuescsi/value
 valuevirtio/value
 valuexen/value
 valueusb/value
 valuesd/value
   /enum

Libguestfs could certainly use this ^.

Also we could use the features outlined in this bug:

https://bugzilla.redhat.com/show_bug.cgi?id=1107842#c0

 - If this works: bios useserial=yes  (ie. sgabios)

 - If this works: cpu mode=host-passthrough

 - Whether the hpet timer needs to be disabled (see also bug 1066145)

 - Whether guests need a dtb/ element

I wonder if we should or should not expose the version number of qemu
too?  Although it would tempt API users to key features based on the
version of qemu, which is wrong, it's useful for debugging.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/

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


Re: [libvirt] [PATCH RFC 0/4] Expose Expose IOMMU and VFIO host capabilities

2014-06-27 Thread Michal Privoznik

On 27.06.2014 12:54, Richard W.M. Jones wrote:

On Thu, Jun 26, 2014 at 12:18:24PM +0200, Michal Privoznik wrote:
[...]

   enum name='bus'
 valueide/value
 valuefdc/value
 valuescsi/value
 valuevirtio/value
 valuexen/value
 valueusb/value
 valuesd/value
   /enum


Libguestfs could certainly use this ^.

Also we could use the features outlined in this bug:

https://bugzilla.redhat.com/show_bug.cgi?id=1107842#c0

  - If this works: bios useserial=yes  (ie. sgabios)

  - If this works: cpu mode=host-passthrough

  - Whether the hpet timer needs to be disabled (see also bug 1066145)

  - Whether guests need a dtb/ element


Sure, but I'd rather focus on getting in the API (even if in its 
minimalistic reporting capabilities) and save your requests for a follow 
up patch.


Michal

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


Re: [libvirt] [PATCH RFC 0/4] Expose Expose IOMMU and VFIO host capabilities

2014-06-27 Thread Richard W.M. Jones
On Fri, Jun 27, 2014 at 01:41:50PM +0200, Michal Privoznik wrote:
 Sure, but I'd rather focus on getting in the API (even if in its
 minimalistic reporting capabilities) and save your requests for a
 follow up patch.

In that case, concentrating on the proposed API:

+ * virConnectGetDomainCapabilities:
+ * @conn: pointer to the hypervisor connection
+ * @emulatorbin: path to emulator
+ * @arch: domain architecture
+ * @machine: machine type
+ * @virttype: virtualization type
+ * @flags: extra flags; not used yet, so callers should always pass 0

It looks fine and is something we could use in libguestfs.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org

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


[libvirt] new openvz driver (bossonvz)

2014-06-27 Thread Bosson VZ
Hello,

in the company I work for, we use openvz and qemu/kvm on our clusters 
side-by-side. To manage our domains, we used libvirt/qemu for qemu/kvm domains 
and vz tools for openvz domains in the past. This was very inconvinient since 
the management differed in many ways. So we have decided to unify our 
management and use libvirt exclusively. Since the openvz driver already 
included in libvirt lacks features that need, we have implemented a new libvirt 
backend driver for openvz called the bossonvz driver.

Unlike the openvz driver, bossonvz is a complete, feature-rich stateful libvirt 
driver. It uses the libvirt driver API exclusively and communicates with the 
kernel directly, much like the LXC driver. The code is hugely inspired by the 
LXC driver and the Qemu driver, but adds a bit of functionality to the libvirt 
core too. More details and the source code can be found at

http://bossonvz.bosson.eu/

The driver is completely independent of vz tools, it needs only a running vz 
kernel. One of the things, we are most proud of, is the possibility to access 
the domain's tty via VNC (hurray to uniform management web interfaces).

Since the code was developed in-house (primarily for internal purposes), it is 
based on an older libvirt release (1.1.2). There are also some modifications to 
the libvirt core (virCommand) and the domain file (mount options syntax) which 
might need some redesign.

At the moment I would like to get some feedback on the driver. In the future, I 
would like to see the driver merged upstream, and am prepared to do the work 
but I need to know if there is any interest in doing so.

-- 
Cluster Design, s.r.o.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] cpu: Add new Broadwell CPU model

2014-06-27 Thread Jiri Denemark
On Wed, Jun 25, 2014 at 12:56:04 -0600, Eric Blake wrote:
 On 06/25/2014 06:41 AM, Jiri Denemark wrote:
  Signed-off-by: Jiri Denemark jdene...@redhat.com
  ---
  
  Notes:
  The corresponding patch [1] for QEMU is not usptream yet but nobody
  seems to be complaining about that model. And chances are the patch gets
  in before QEMU enters hard freeze for 2.1. So please review this patch
  but I won't push it until the model gets pushed to QEMU.
 
 We seem to be piling up a number of these gated patches :)
 
  
  [1] https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg04025.html
  
   src/cpu/cpu_map.xml | 8 
   1 file changed, 8 insertions(+)
  
 
 ACK.

The QEMU patch was pushed to qemu.git yesterday and it will be part of
the upcoming 2.1 release. So I pushed this patch so that libvirt 1.2.6
can make use of it.

Jirka

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


[libvirt] [libvirt-glib] [PATCHv2 1/2] libvirt-gobject-domain: Add _fetch_snapshots

2014-06-27 Thread Timm Bäder
This function can be used to fetch the snapshots of a domain (according
to the given GVirDomainSnapshotListFlags) and save them in a
domain-internal GHashTable. A function to access them from outside will
be added in a later patch.
---
 libvirt-gobject/libvirt-gobject-domain.c | 61 
 libvirt-gobject/libvirt-gobject-domain.h | 36 +++
 libvirt-gobject/libvirt-gobject.sym  |  2 ++
 3 files changed, 99 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
b/libvirt-gobject/libvirt-gobject-domain.c
index c6e30e5..a527d4e 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -38,6 +38,7 @@ struct _GVirDomainPrivate
 {
 virDomainPtr handle;
 gchar uuid[VIR_UUID_STRING_BUFLEN];
+GHashTable *snapshots;
 };
 
 G_DEFINE_TYPE(GVirDomain, gvir_domain, G_TYPE_OBJECT);
@@ -121,6 +122,10 @@ static void gvir_domain_finalize(GObject *object)
 
 g_debug(Finalize GVirDomain=%p, domain);
 
+if (priv-snapshots) {
+g_hash_table_unref (priv-snapshots);
+}
+
 virDomainFree(priv-handle);
 
 G_OBJECT_CLASS(gvir_domain_parent_class)-finalize(object);
@@ -1514,3 +1519,59 @@ gvir_domain_create_snapshot(GVirDomain *dom,
 g_free(custom_xml);
 return dom_snapshot;
 }
+
+
+
+/**
+ * gvir_domain_fetch_snapshots:
+ * @dom: The domain
+ * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags
+ * @error: (allow-none): Place-holder for error or NULL
+ *
+ * Returns: TRUE on success, FALSE otherwise.
+ */
+gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
+ guint list_flags,
+ GError **error)
+{
+GVirDomainPrivate *priv;
+virDomainSnapshotPtr *snapshots = NULL;
+GVirDomainSnapshot *snap;
+int n_snaps = 0;
+int i;
+
+g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+g_return_val_if_fail((error == NULL) || (*error == NULL), FALSE);
+
+priv = dom-priv;
+
+if (priv-snapshots != NULL) {
+g_hash_table_unref (priv-snapshots);
+}
+
+priv-snapshots = g_hash_table_new_full(g_str_hash,
+g_str_equal,
+NULL,
+g_object_unref);
+
+
+n_snaps = virDomainListAllSnapshots(priv-handle, snapshots, list_flags);
+
+if (n_snaps  0) {
+gvir_set_error(error, GVIR_DOMAIN_ERROR, 0,
+   Unable to fetch snapshots of %s,
+   gvir_domain_get_name (dom));
+return FALSE;
+}
+
+for (i = 0; i  n_snaps; i ++) {
+snap = GVIR_DOMAIN_SNAPSHOT(g_object_new(GVIR_TYPE_DOMAIN_SNAPSHOT,
+ handle, snapshots[i],
+ NULL));
+g_hash_table_insert(priv-snapshots,
+(gpointer)gvir_domain_snapshot_get_name(snap),
+snap);
+}
+free(snapshots);
+return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h 
b/libvirt-gobject/libvirt-gobject-domain.h
index 38d3458..fb33e2b 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -183,6 +183,39 @@ typedef enum {
 GVIR_DOMAIN_REBOOT_GUEST_AGENT= VIR_DOMAIN_REBOOT_GUEST_AGENT,
 } GVirDomainRebootFlags;
 
+/**
+ * GVirDomainSnapshotListFlags:
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_ALL: List all snapshots
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS: List all descendants, not just
+ * children, when listing a snapshot.
+ * For historical reasons, groups do 
not use contiguous bits.
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_ROOTS: Filter by snapshots with no parents, when 
listing a domain
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_METADATA: Filter by snapshots which have metadata
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_LEAVES: Filter by snapshots with no children
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES: Filter by snapshots that have children
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA: Filter by snapshots with no metadata
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_INACTIVE: Filter by snapshots taken while guest 
was shut off
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_ACTIVE: Filter by snapshots taken while guest 
was active, and with memory state
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY: Filter by snapshots taken while guest 
was active, but without memory state
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_INTERNAL: Filter by snapshots stored internal to 
disk images
+ * @GVIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL: Filter by snapshots that use files 
external to disk images
+ */
+typedef enum {
+GVIR_DOMAIN_SNAPSHOT_LIST_ALL = 0,
+GVIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS = 
VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS,
+GVIR_DOMAIN_SNAPSHOT_LIST_ROOTS   = VIR_DOMAIN_SNAPSHOT_LIST_ROOTS,
+

[libvirt] [libvirt-glib] [PATCHv2 2/2] libvirt-gobject-domain: Add _get_snapshots

2014-06-27 Thread Timm Bäder
... which returns a GList of GVirDomainSnapshots, i.e. without any tree
structure or other relationship between the snapshots.
---
 libvirt-gobject/libvirt-gobject-domain.c | 21 +
 libvirt-gobject/libvirt-gobject-domain.h |  4 
 libvirt-gobject/libvirt-gobject.sym  |  1 +
 3 files changed, 26 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
b/libvirt-gobject/libvirt-gobject-domain.c
index a527d4e..e4c99ed 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1575,3 +1575,24 @@ gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
 free(snapshots);
 return TRUE;
 }
+
+/**
+ * gvir_domain_get_snapshots:
+ * @dom: The domain
+ * Returns: (element-type LibvirtGObject.DomainSnapshot) (transfer full): A
+ * list of all the snapshots available for the given domain. The returned
+ * list should be freed with g_list_free(), after its elements have been
+ * unreffed with g_object_unref().
+ */
+GList *gvir_domain_get_snapshots(GVirDomain *dom)
+{
+GList *snapshots = NULL;
+g_return_val_if_fail(GVIR_IS_DOMAIN(dom), NULL);
+
+if (dom-priv-snapshots != NULL) {
+snapshots = g_hash_table_get_values(dom-priv-snapshots);
+g_list_foreach(snapshots, (GFunc)g_object_ref, NULL);
+}
+
+return snapshots;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h 
b/libvirt-gobject/libvirt-gobject-domain.h
index fb33e2b..acea7c2 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -366,6 +366,10 @@ gvir_domain_create_snapshot(GVirDomain *dom,
 gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
  guint flags,
  GError **error);
+
+GList *gvir_domain_get_snapshots(GVirDomain *dom);
+
+
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index 781310f..28e547a 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -237,6 +237,7 @@ LIBVIRT_GOBJECT_0.1.5 {
 LIBVIRT_GOBJECT_0.1.9 {
   global:
gvir_domain_fetch_snapshots;
+   gvir_domain_get_snapshots;
gvir_domain_snapshot_delete;
gvir_domain_snapshot_list_flags_get_type;
 } LIBVIRT_GOBJECT_0.1.5;
-- 
2.0.0

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


[libvirt] [PATCH] qemu: fix domxml-to-native failing when spice_tls is not enabled

2014-06-27 Thread Jincheng Miao
The default graphics channel mode is 'any', so as to defaultMode attribute.
If defaultMode and channel mode are all the default value 'any',
qemuConnectDomainXMLToNative will set TLSPort.
But in qemuBuildGraphicsSPICECommandLine, if spice_tls is not enabled, libvirtd
will report an error to tell the user that spice TLS is disabled in qemu.conf.

So qemuConnectDomainXMLToNative should check spice_tls is enabled,
then decide to allocate an tlsPort number to this graphics.

If user specified defaultMode is 'secure', qemuConnectDomainXMLToNative
could allocate tlsPort, and then let qemuBuildGraphicsSPICECommandLine reports
the spice_tls disabled error.

The related bug is:
https://bugzilla.redhat.com/show_bug.cgi?id=1113868

Signed-off-by: Jincheng Miao jm...@redhat.com
---
 src/qemu/qemu_driver.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d34da6f..d1e3b2f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6013,7 +6013,8 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr 
conn,
 break;
 
 case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY:
-needTLSPort = true;
+if (cfg-spiceTLS)
+needTLSPort = true;
 needPort = true;
 break;
 }
-- 
1.7.1

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


[libvirt] [PATCH] qemu_domain: fix startup policy for disks

2014-06-27 Thread Pavel Hrdina
https://bugzilla.redhat.com/show_bug.cgi?id=1086121

We now support startupPolicy='optional' for disks, but this
should work only for cold boot, not for restore or migrate.

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---
 src/qemu/qemu_domain.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9e38d02..a8cce76 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2230,11 +2230,16 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr 
driver,
 {
 char uuid[VIR_UUID_STRING_BUFLEN];
 int startupPolicy = vm-def-disks[diskIndex]-startupPolicy;
+int device = vm-def-disks[diskIndex]-device;
 
 virUUIDFormat(vm-def-uuid, uuid);
 
 switch ((virDomainStartupPolicy) startupPolicy) {
 case VIR_DOMAIN_STARTUP_POLICY_OPTIONAL:
+if (!cold_boot 
+device != VIR_DOMAIN_DISK_DEVICE_FLOPPY 
+device != VIR_DOMAIN_DISK_DEVICE_CDROM)
+goto error;
 break;
 
 case VIR_DOMAIN_STARTUP_POLICY_MANDATORY:
-- 
1.8.5.5

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


[libvirt] [PATCH 1/5] virstorage: Introduce virStorageAuthDef

2014-06-27 Thread John Ferlan
Introduce virStorageAuthDef and friends.  Future patches will merge/utilize
their view of storage source/pool auth/secret definitions.

New API's include:
virStorageAuthDefParse:  Parse the auth XML data for either the
 domain disk or storage pool returning a
 virStorageAuthDefPtr
virStorageAuthDefCopy:   Copy a virStorageAuthDefPtr - to be used by
 the qemuTranslateDiskSourcePoolAuth when it
 copies storage pool auth data into domain
 disk auth data
virStorageAuthDefFormat: Common output of the auth in the domain
 disk or storage pool XML
virStorageAuthDefFree:   Free memory associated with virStorageAuthDef

Subsequent patches will utilize the new functions for the domain disk and
storage pools.

Future work in the hostdev pass through can then make use of common data
structures and code.

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/libvirt_private.syms  |   4 +
 src/util/virstoragefile.c | 205 ++
 src/util/virstoragefile.h |  27 ++
 3 files changed, 236 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1e1dd84..17dcd67 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1879,6 +1879,10 @@ virStorageGenerateQcowPassphrase;
 
 
 # util/virstoragefile.h
+virStorageAuthDefCopy;
+virStorageAuthDefFormat;
+virStorageAuthDefFree;
+virStorageAuthDefParse;
 virStorageFileCanonicalizePath;
 virStorageFileChainGetBroken;
 virStorageFileChainLookup;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 0c50de1..056e59e 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -29,6 +29,8 @@
 #include fcntl.h
 #include stdlib.h
 #include viralloc.h
+#include virxml.h
+#include viruuid.h
 #include virerror.h
 #include virlog.h
 #include virfile.h
@@ -97,6 +99,10 @@ VIR_ENUM_IMPL(virStorageSourcePoolMode,
   host,
   direct)
 
+VIR_ENUM_IMPL(virStorageAuth,
+  VIR_STORAGE_AUTH_TYPE_LAST,
+  none, chap, ceph)
+
 enum lv_endian {
 LV_LITTLE_ENDIAN = 1, /* 1234 */
 LV_BIG_ENDIAN /* 4321 */
@@ -1500,6 +1506,205 @@ virStorageNetHostDefCopy(size_t nhosts,
 }
 
 
+void
+virStorageAuthDefFree(virStorageAuthDefPtr authdef)
+{
+if (!authdef)
+return;
+
+VIR_FREE(authdef-username);
+VIR_FREE(authdef-secrettype);
+if (authdef-secretType == VIR_STORAGE_SECRET_TYPE_USAGE)
+VIR_FREE(authdef-secret.usage);
+VIR_FREE(authdef);
+}
+
+
+virStorageAuthDefPtr
+virStorageAuthDefCopy(const virStorageAuthDef *src)
+{
+virStorageAuthDefPtr ret;
+
+if (VIR_ALLOC(ret)  0)
+return NULL;
+
+if (VIR_STRDUP(ret-username, src-username)  0)
+goto error;
+/* Not present for storage pool, but used for disk source */
+if (src-secrettype)
+if (VIR_STRDUP(ret-secrettype, src-secrettype)  0)
+goto error;
+ret-authType = src-authType;
+ret-secretType = src-secretType;
+if (ret-secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
+memcpy(ret-secret.uuid, src-secret.uuid, sizeof(ret-secret.uuid));
+} else if (ret-secretType == VIR_STORAGE_SECRET_TYPE_USAGE) {
+if (VIR_STRDUP(ret-secret.usage, src-secret.usage)  0)
+goto error;
+}
+return ret;
+
+ error:
+virStorageAuthDefFree(ret);
+return NULL;
+}
+
+
+static int
+virStorageAuthDefParseSecret(xmlXPathContextPtr ctxt,
+ virStorageAuthDefPtr authdef)
+{
+char *uuid;
+char *usage;
+int ret = -1;
+
+/* Used by the domain disk xml parsing in order to ensure the
+ * secret type='%s' value matches the expected secret type for
+ * the style of disk (iscsi is chap, nbd is ceph). For some reason
+ * the virSecretUsageType{From|To}String() cannot be linked here
+ * and because only the domain parsing code cares - just keep
+ * it as a string.
+ */
+authdef-secrettype = virXPathString(string(./secret/@type), ctxt);
+
+uuid = virXPathString(string(./secret/@uuid), ctxt);
+usage = virXPathString(string(./secret/@usage), ctxt);
+if (uuid == NULL  usage == NULL) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(missing auth secret uuid or usage attribute));
+goto cleanup;
+}
+
+if (uuid  usage) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(either auth secret uuid or usage expected));
+goto cleanup;
+}
+
+if (uuid) {
+if (virUUIDParse(uuid, authdef-secret.uuid)  0) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+_(invalid auth secret uuid));
+goto cleanup;
+}
+authdef-secretType = VIR_STORAGE_SECRET_TYPE_UUID;
+} else {
+authdef-secret.usage = 

[libvirt] [PATCH 0/5] Reorganize storage auth (both disk and pool)

2014-06-27 Thread John Ferlan
While understandably not really a 1.2.6 candidate, I figured I'd post this
now in hopes that it gets the ball rolling.  The changes will help with
a related bz to support libiscsi for SCSI passthrough devices where a
hostdev entry for an iscsi adapter would be able to have auth data.

The bulk of changes are code motion/merge. The details for each are:

The first patch will create new API's which will then be used by the
parse domain disk and the parse storage pool code if the auth element
is found. The logic merges the parsing found in the domain disk and
storage pool code with one slight caveat - the domain disk code expects
to find secret type='', where  is 'iscsi' or 'ceph'. Trying
use the Type{To/From}String API's in virstoragefile.c resulted in a
link time failure (even though secret_conf.h was included).  Never quite
figured it out - I will take suggestions though. Although since the
domain disk code is all that really cares about it and the domain_conf
code can use the Type{To/From}String API's - I just left it as is. The
new copy API is used when the pool code needs to copy it's auth data into
each domain disk's auth entry.

The second patch will fix a not-run test that tests the auth.  It seems
it was not added to the active list of tests because the output generated
did not include the usage information (eg  usage='mycluster_myname) that
is part of the secret element. Additionally because it did not include
it the output was secret type='iscsi' /auth.  So rather than ignore
the test - add to the filters to avoid looking for secret - through
to the closing .  The -auth.xml and -auth.args files needed adjustments
to follow the non -auth version of the files that have changed over time,
but not also changed int the -auth files.

The third patch will cause the domain disk algorithms to utilize the
new generic parse and format APIs as well as using the 'authdef' instead
of the inline structure fields.  This patch also restores the checking for
/auth in the recently restored auth test.  Still avoiding the whole
secret... / line as I saw no way to filter just the usage that's in
the stored XML file.

The fourth patch is a mostly innocuous html change - it could go early,
but it just felt better in this place.

The fifth patch will cause the storage pool algorithms to utilize the
new generic parse/format API's as well as new authdef structure for
accessing the data. The removal of the duplicated cephx/chap structures
seems (in my mind at least) to simplify things. They were essentially
copies of each other with no seemingly real value in keeping separate
other than the visual in the code of .chap. or .cephx.. 

John Ferlan (5):
  virstorage: Introduce virStorageAuthDef
  qemuargv2xmltest: Resurrect RBD and iSCSI auth
  Utilize virDomainDiskAuth for domain disk
  formatdomain: Fix issues found describing auth
  Utilize virDomainDiskAuth for storage pools

 docs/formatdomain.html.in  |  24 +--
 src/conf/domain_conf.c | 106 ++
 src/conf/storage_conf.c| 152 ++
 src/conf/storage_conf.h|  38 +---
 src/libvirt_private.syms   |   5 +-
 src/qemu/qemu_command.c|  72 ---
 src/qemu/qemu_conf.c   |  46 +
 src/storage/storage_backend_iscsi.c|  41 ++--
 src/storage/storage_backend_rbd.c  |  65 +++---
 src/util/virstoragefile.c  | 219 +++--
 src/util/virstoragefile.h  |  37 +++-
 tests/qemuargv2xmltest.c   |   3 +
 ...qemuxml2argv-disk-drive-network-iscsi-auth.args |   4 +-
 .../qemuxml2argv-disk-drive-network-iscsi-auth.xml |  12 +-
 .../qemuxml2argv-disk-drive-network-rbd-auth.xml   |   4 +-
 15 files changed, 415 insertions(+), 413 deletions(-)

-- 
1.9.3

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


[libvirt] [PATCH 2/5] qemuargv2xmltest: Resurrect RBD and iSCSI auth

2014-06-27 Thread John Ferlan
Ressurect the disk-drive-network-iscsi-auth and disk-drive-network-rbd-auth
tests.  Make adjustments to the args and xml file to be compatible with
other changes made to the non -auth so that the only difference is the
authentication information.

Adjust the qemuargv2xmltest.c to filter out secret and /auth since
the args - xml has no concept of usage it doesn't get printed. This results
in the /auth being printed on the same line as secret and the secret
XML is not closed - a bit of an issue, but soon to be fixed.

Signed-off-by: John Ferlan jfer...@redhat.com
---
 tests/qemuargv2xmltest.c |  4 
 .../qemuxml2argv-disk-drive-network-iscsi-auth.args  |  4 +++-
 .../qemuxml2argv-disk-drive-network-iscsi-auth.xml   | 12 +---
 .../qemuxml2argv-disk-drive-network-rbd-auth.xml |  4 +++-
 4 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 2cbbe3d..04d5a65 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -26,6 +26,8 @@ static int blankProblemElements(char *data)
 if (virtTestClearLineRegex(name[[:alnum:]]+/name, data)  0 ||
 virtTestClearLineRegex(uuid([[:alnum:]]|-)+/uuid, data)  0 ||
 virtTestClearLineRegex(memory.*[[:digit:]]+/memory, data)  0 ||
+virtTestClearLineRegex(secret.*, data)  0 ||
+virtTestClearLineRegex(/auth.*, data)  0 ||
 virtTestClearLineRegex(currentMemory.*[[:digit:]]+/currentMemory,
data)  0 ||
 virtTestClearLineRegex(readonly/, data)  0 ||
@@ -226,8 +228,10 @@ mymain(void)
 DO_TEST(disk-drive-network-nbd-ipv6-export);
 DO_TEST(disk-drive-network-nbd-unix);
 DO_TEST(disk-drive-network-iscsi);
+DO_TEST(disk-drive-network-iscsi-auth);
 DO_TEST(disk-drive-network-gluster);
 DO_TEST(disk-drive-network-rbd);
+DO_TEST(disk-drive-network-rbd-auth);
 DO_TEST(disk-drive-network-rbd-ipv6);
 /* older format using CEPH_ARGS env var */
 DO_TEST(disk-drive-network-rbd-ceph-env);
diff --git 
a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.args 
b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.args
index dd8fee4..4c5e1be 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.args
@@ -3,5 +3,7 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test 
QEMU_AUDIO_DRV=none \
 -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
 -no-acpi -boot c -usb \
 -drive file=iscsi://myname:aqcvn5ho6hzfahaaq0ncv8jtjcice+hoblm...@example.org\
-/iqn.1992-01.com.example,if=virtio,format=raw \
+:6000/iqn.1992-01.com.example,if=virtio,format=raw \
+-drive file=iscsi://example.org:6000/iqn.1992-01.com.example/1,if=virtio,\
+format=raw \
 -net none -serial none -parallel none
diff --git 
a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.xml
index ee87bdf..45df270 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth.xml
@@ -20,13 +20,19 @@
 secret type='iscsi' usage='mycluster_myname'/
   /auth
   source protocol='iscsi' name='iqn.1992-01.com.example'
-host name='example.org'/
+host name='example.org' port='6000'/
   /source
   target dev='vda' bus='virtio'/
 /disk
+disk type='network' device='disk'
+  driver name='qemu' type='raw'/
+  source protocol='iscsi' name='iqn.1992-01.com.example/1'
+host name='example.org' port='6000'/
+  /source
+  target dev='vdb' bus='virtio'/
+/disk
 controller type='usb' index='0'/
-controller type='ide' index='0'/
 controller type='pci' index='0' model='pci-root'/
-memballoon model='virtio'/
+memballoon model='none'/
   /devices
 /domain
diff --git 
a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.xml
index 189ce6b..72923ea 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.xml
@@ -15,6 +15,7 @@
   devices
 emulator/usr/bin/qemu/emulator
 disk type='block' device='disk'
+  driver name='qemu' type='raw'/
   source dev='/dev/HostVG/QEMUGuest1'/
   target dev='hda' bus='ide'/
   address type='drive' controller='0' bus='0' target='0' unit='0'/
@@ -33,6 +34,7 @@
 /disk
 controller type='usb' index='0'/
 controller type='ide' index='0'/
-memballoon model='virtio'/
+controller type='pci' index='0' model='pci-root'/
+memballoon model='none'/
   /devices
 /domain
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com

[libvirt] [PATCH 5/5] Utilize virDomainDiskAuth for storage pools

2014-06-27 Thread John Ferlan
Replace the authType, chap, and cephx unions in virStoragePoolSource
with a single pointer to a virStorageAuthDefPtr.  Adjust all users of
the previous chap/cephx and secret unions with the source-auth data.

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/conf/storage_conf.c | 152 +---
 src/conf/storage_conf.h |  38 +
 src/qemu/qemu_conf.c|  46 ++-
 src/storage/storage_backend_iscsi.c |  41 +-
 src/storage/storage_backend_rbd.c   |  65 ---
 5 files changed, 80 insertions(+), 262 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 8b6fd79..5b152f1 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -44,9 +44,12 @@
 #include viralloc.h
 #include virfile.h
 #include virstring.h
+#include virlog.h
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
+VIR_LOG_INIT(conf.storage_conf);
+
 #define DEFAULT_POOL_PERM_MODE 0755
 #define DEFAULT_VOL_PERM_MODE  0600
 
@@ -98,10 +101,6 @@ VIR_ENUM_IMPL(virStoragePoolSourceAdapter,
   VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_LAST,
   default, scsi_host, fc_host)
 
-VIR_ENUM_IMPL(virStoragePoolAuth,
-  VIR_STORAGE_POOL_AUTH_LAST,
-  none, chap, ceph)
-
 typedef const char *(*virStorageVolFormatToString)(int format);
 typedef int (*virStorageVolFormatFromString)(const char *format);
 typedef const char *(*virStorageVolFeatureToString)(int feature);
@@ -374,18 +373,9 @@ virStoragePoolSourceClear(virStoragePoolSourcePtr source)
 VIR_FREE(source-name);
 virStoragePoolSourceAdapterClear(source-adapter);
 VIR_FREE(source-initiator.iqn);
+virStorageAuthDefFree(source-auth);
 VIR_FREE(source-vendor);
 VIR_FREE(source-product);
-
-if (source-authType == VIR_STORAGE_POOL_AUTH_CHAP) {
-VIR_FREE(source-auth.chap.username);
-VIR_FREE(source-auth.chap.secret.usage);
-}
-
-if (source-authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
-VIR_FREE(source-auth.cephx.username);
-VIR_FREE(source-auth.cephx.secret.usage);
-}
 }
 
 void
@@ -462,106 +452,17 @@ virStoragePoolObjRemove(virStoragePoolObjListPtr pools,
 }
 
 static int
-virStoragePoolDefParseAuthSecret(xmlXPathContextPtr ctxt,
- virStoragePoolAuthSecretPtr secret)
-{
-char *uuid = NULL;
-int ret = -1;
-
-uuid = virXPathString(string(./auth/secret/@uuid), ctxt);
-secret-usage = virXPathString(string(./auth/secret/@usage), ctxt);
-if (uuid == NULL  secret-usage == NULL) {
-virReportError(VIR_ERR_XML_ERROR, %s,
-   _(missing auth secret uuid or usage attribute));
-return -1;
-}
-
-if (uuid != NULL) {
-if (secret-usage != NULL) {
-virReportError(VIR_ERR_XML_ERROR, %s,
-   _(either auth secret uuid or usage expected));
-goto cleanup;
-}
-if (virUUIDParse(uuid, secret-uuid)  0) {
-virReportError(VIR_ERR_XML_ERROR, %s,
-   _(invalid auth secret uuid));
-goto cleanup;
-}
-secret-uuidUsable = true;
-} else {
-secret-uuidUsable = false;
-}
-
-ret = 0;
- cleanup:
-VIR_FREE(uuid);
-return ret;
-}
-
-static int
-virStoragePoolDefParseAuth(xmlXPathContextPtr ctxt,
-   virStoragePoolSourcePtr source)
-{
-int ret = -1;
-char *authType = NULL;
-char *username = NULL;
-
-authType = virXPathString(string(./auth/@type), ctxt);
-if (authType == NULL) {
-source-authType = VIR_STORAGE_POOL_AUTH_NONE;
-ret = 0;
-goto cleanup;
-}
-
-if ((source-authType =
- virStoragePoolAuthTypeFromString(authType))  0) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _(unknown auth type '%s'),
-   authType);
-goto cleanup;
-}
-
-username = virXPathString(string(./auth/@username), ctxt);
-if (username == NULL) {
-virReportError(VIR_ERR_XML_ERROR, %s,
-   _(missing auth username attribute));
-goto cleanup;
-}
-
-if (source-authType == VIR_STORAGE_POOL_AUTH_CHAP) {
-source-auth.chap.username = username;
-username = NULL;
-if (virStoragePoolDefParseAuthSecret(ctxt,
- source-auth.chap.secret)  0)
-goto cleanup;
-}
-else if (source-authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
-source-auth.cephx.username = username;
-username = NULL;
-if (virStoragePoolDefParseAuthSecret(ctxt,
- source-auth.cephx.secret)  0)
-goto cleanup;
-}
-
-ret = 0;
-
- cleanup:
-VIR_FREE(authType);
-VIR_FREE(username);
-return ret;
-}
-
-static int
 virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
   

[libvirt] [PATCH 3/5] Utilize virDomainDiskAuth for domain disk

2014-06-27 Thread John Ferlan
Replace the inline auth struct in virStorageSource with a pointer
to a virStorageAuthDefPtr and utilize between the domain_conf, qemu_conf,
and qemu_command sources for finding the auth data for a domain disk

Signed-off-by: John Ferlan jfer...@redhat.com
---
 src/conf/domain_conf.c| 106 +++---
 src/libvirt_private.syms  |   1 -
 src/qemu/qemu_command.c   |  72 +--
 src/qemu/qemu_conf.c  |  26 +++-
 src/util/virstoragefile.c |  14 +-
 src/util/virstoragefile.h |  10 +
 tests/qemuargv2xmltest.c  |   1 -
 7 files changed, 81 insertions(+), 149 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b7aa4f5..93f09a7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5203,7 +5203,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
 {
 virDomainDiskDefPtr def;
 xmlNodePtr sourceNode = NULL;
-xmlNodePtr cur, child;
+xmlNodePtr cur;
 xmlNodePtr save_ctxt = ctxt-node;
 char *type = NULL;
 char *device = NULL;
@@ -5227,10 +5227,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
 virStorageEncryptionPtr encryption = NULL;
 char *serial = NULL;
 char *startupPolicy = NULL;
-char *authUsername = NULL;
-char *authUsage = NULL;
-char *authUUID = NULL;
-char *usageType = NULL;
+virStorageAuthDefPtr authdef = NULL;
 char *tray = NULL;
 char *removable = NULL;
 char *logical_block_size = NULL;
@@ -5432,65 +5429,14 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
 VIR_FREE(ready);
 }
 } else if (xmlStrEqual(cur-name, BAD_CAST auth)) {
-authUsername = virXMLPropString(cur, username);
-if (authUsername == NULL) {
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(missing username for auth));
+if (!(authdef = virStorageAuthDefParse(node-doc, cur)))
+goto error;
+if ((auth_secret_usage =
+ virSecretUsageTypeFromString(authdef-secrettype))  0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(invalid secret type %s),
+   authdef-secrettype);
 goto error;
-}
-
-def-src-auth.secretType = VIR_STORAGE_SECRET_TYPE_NONE;
-child = cur-children;
-while (child != NULL) {
-if (child-type == XML_ELEMENT_NODE 
-xmlStrEqual(child-name, BAD_CAST secret)) {
-usageType = virXMLPropString(child, type);
-if (usageType == NULL) {
-virReportError(VIR_ERR_XML_ERROR, %s,
-   _(missing type for secret));
-goto error;
-}
-auth_secret_usage =
-virSecretUsageTypeFromString(usageType);
-if (auth_secret_usage  0) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _(invalid secret type %s),
-   usageType);
-goto error;
-}
-
-authUUID = virXMLPropString(child, uuid);
-authUsage = virXMLPropString(child, usage);
-
-if (authUUID != NULL  authUsage != NULL) {
-virReportError(VIR_ERR_XML_ERROR, %s,
-   _(only one of uuid and usage can 
be specified));
-goto error;
-}
-
-if (!authUUID  !authUsage) {
-virReportError(VIR_ERR_XML_ERROR, %s,
-   _(either uuid or usage should be 
- specified for a secret));
-goto error;
-}
-
-if (authUUID != NULL) {
-def-src-auth.secretType = 
VIR_STORAGE_SECRET_TYPE_UUID;
-if (virUUIDParse(authUUID,
- def-src-auth.secret.uuid)  0) {
-virReportError(VIR_ERR_XML_ERROR,
-   _(malformed uuid %s),
-   authUUID);
-goto error;
-}
-} else if (authUsage != NULL) {
-def-src-auth.secretType = 
VIR_STORAGE_SECRET_TYPE_USAGE;
-def-src-auth.secret.usage = 

[libvirt] [PATCH 4/5] formatdomain: Fix issues found describing auth

2014-06-27 Thread John Ferlan
Fix a couple of typos ('chap' should have been 'iscsi' and there was
a stray 'iqn.2013-07.com.example:iscsi-pool' entry.  Clean up the
description of the auth element for the disk

Signed-off-by: John Ferlan jfer...@redhat.com
---
 docs/formatdomain.html.in | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3075e16..d3e776b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1594,18 +1594,17 @@
 lt;host name='example.com' port='3260'/gt;
   lt;/sourcegt;
   lt;auth username='myuser'gt;
-lt;secret type='chap' usage='libvirtiscsi'/gt;
+lt;secret type='iscsi' usage='libvirtiscsi'/gt;
   lt;/authgt;
   lt;target dev='vda' bus='virtio'/gt;
 lt;/diskgt;
 lt;disk type='network' device='lun'gt;
   lt;driver name='qemu' type='raw'/gt;
   lt;source protocol='iscsi' 
name='iqn.2013-07.com.example:iscsi-nopool/1'gt;
-   iqn.2013-07.com.example:iscsi-pool
 lt;host name='example.com' port='3260'/gt;
   lt;/sourcegt;
   lt;auth username='myuser'gt;
-lt;secret type='chap' usage='libvirtiscsi'/gt;
+lt;secret type='iscsi' usage='libvirtiscsi'/gt;
   lt;/authgt;
   lt;target dev='sda' bus='scsi'/gt;
 lt;/diskgt;
@@ -1613,7 +1612,7 @@
   lt;driver name='qemu' type='raw'/gt;
   lt;source pool='iscsi-pool' volume='unit:0:0:1' mode='host'/gt;
   lt;auth username='myuser'gt;
-lt;secret type='chap' usage='libvirtiscsi'/gt;
+lt;secret type='iscsi' usage='libvirtiscsi'/gt;
   lt;/authgt;
   lt;target dev='vda' bus='virtio'/gt;
 lt;/diskgt;
@@ -1621,7 +1620,7 @@
   lt;driver name='qemu' type='raw'/gt;
   lt;source pool='iscsi-pool' volume='unit:0:0:2' mode='direct'/gt;
   lt;auth username='myuser'gt;
-lt;secret type='chap' usage='libvirtiscsi'/gt;
+lt;secret type='iscsi' usage='libvirtiscsi'/gt;
   lt;/authgt;
   lt;target dev='vda' bus='virtio'/gt;
 lt;/diskgt;
@@ -2180,7 +2179,10 @@
 are available, each defaulting to 0.
   /dd
   dtcodeauth/code/dt
-  ddIf present, the codeauth/code element provides the
+  ddThe codeauth/code element is supported for a disk
+codetype/code network that is using a codesource/code
+element with the codeprotocol/code attributes rbd or iscsi.
+If present, the codeauth/code element provides the
 authentication credentials needed to access the source.  It
 includes a mandatory attribute codeusername/code, which
 identifies the username to use during authentication, as well
@@ -2189,11 +2191,11 @@
 a a href=formatsecret.htmllibvirt secret object/a that
 holds the actual password or other credentials (the domain XML
 intentionally does not expose the password, only the reference
-to the object that does manage the password).  For now, the
-known secret codetype/codes are ceph, for Ceph RBD
-network sources, and iscsi, for CHAP authentication of iSCSI
-targets.  Both require either a codeuuid/code attribute
-with the UUID of the secret object, or a codeusage/code
+to the object that does manage the password).
+Known secret types are ceph for Ceph RBD network sources and
+iscsi for CHAP authentication of iSCSI targets.
+Both will require either a codeuuid/code attribute
+with the UUID of the secret object or a codeusage/code
 attribute matching the key that was specified in the
 secret object.  span class=sincelibvirt 0.9.7/span
   /dd
-- 
1.9.3

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


[libvirt] [PATCH] bhyve: fix build by fixing typo in variable name

2014-06-27 Thread Roman Bogorodskiy
Commit 80d0918b introduced a typo in variable name:

s/failIncomaptible/failIncompatible/

Pushed under the build breaker rule.
---
 src/bhyve/bhyve_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index d784ed1..eb5fc95 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1326,14 +1326,14 @@ bhyveConnectCompareCPU(virConnectPtr conn,
 if (virConnectCompareCPUEnsureACL(conn)  0)
 goto cleanup;
 
-failIncomaptible = !!(flags  VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE);
+failIncompatible = !!(flags  VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE);
 
 if (!(caps = bhyveDriverGetCapabilities(driver)))
 goto cleanup;
 
 if (!caps-host.cpu ||
 !caps-host.cpu-model) {
-if (failIncomaptible) {
+if (failIncompatible) {
 virReportError(VIR_ERR_CPU_INCOMPATIBLE, %s,
_(cannot get host CPU capabilities));
 } else {
@@ -1341,7 +1341,7 @@ bhyveConnectCompareCPU(virConnectPtr conn,
 ret = VIR_CPU_COMPARE_INCOMPATIBLE;
 }
 } else {
-ret = cpuCompareXML(caps-host.cpu, xmlDesc, failIncomaptible);
+ret = cpuCompareXML(caps-host.cpu, xmlDesc, failIncompatible);
 }
 
  cleanup:
-- 
1.9.0

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


[libvirt] [PATCH libvirt-tck] docs: typo fixes

2014-06-27 Thread Roman Bogorodskiy
Fix a few typos in docs/intro.pod.
---
 docs/intro.pod | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/docs/intro.pod b/docs/intro.pod
index 3684d51..09227ae 100644
--- a/docs/intro.pod
+++ b/docs/intro.pod
@@ -47,7 +47,7 @@ hypervisor and libvirt release is configured correctly
 =back
 
 Thus the libvirt TCK will allow developers, administrators and users
-to determine the level of compatability of their platform, and
+to determine the level of compatibility of their platform, and
 evaluate whether it will meet their needs, and get awareness of any
 regressions that may have occurred since a previous test run
 
@@ -249,7 +249,7 @@ running domain, replacing it with -1.
 
 =item *
 
-QEMU refuseed to boot kernel+initrd unless at least one disk
+QEMU refused to boot kernel+initrd unless at least one disk
 image is provided
 
 =back
@@ -261,7 +261,7 @@ The libvirt-tck tool outputs results in a number of 
formats. The
 default format is a simple plain test summary listing each test
 case, and the pass/fail state, and details of each check failure
 
-A more verbose text format otputs the full Perl TAP (Test Anything
+A more verbose text format outputs the full Perl TAP (Test Anything
 Protocol) format results as described in 'man 3 TAP' or
 'man 3 Test::Harness::TAP'.
 
@@ -301,7 +301,7 @@ flag
 
 The code as it stands is the bare minimum to get a proof of concept working
 for testing of domain APIs for Xen and QEMU drivers. The test suite though
-is intended to be independant of any driver, and also allow for coverage of
+is intended to be independent of any driver, and also allow for coverage of
 all the libvirt APIs.
 
 Of the top of my head, some important things that need doing
@@ -389,7 +389,7 @@ Fix up all the horribly broken areas of libvirt that this
 uncovers. This will entail deciding that the semantics for
 various edge cases are with each API. Deciding what errors
 codes need to be formally defined for each API. Figuring
-out how to implement/fix the neccessary semantics in the
+out how to implement/fix the necessary semantics in the
 drivers.
 
 =item Failure recording
-- 
1.9.0

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


[libvirt] [PATCH 0/2] memdev device: add share argument for type=file

2014-06-27 Thread Michele Paolino
This patch enables the possibility to run a qemu virtual machine with the 
share option for the memory-backend-file. The xml description looks like:

memdev type='file' share='on'
nameram0/name
source mem-path='/hugetlbfs'/
capacity unit='MiB'1024/capacity
/memdev

This work is based on the previous work of Chen Fan[1].
We are aware of the existing conflict with the previous numa patches[2].
We are sharing this because it is a dependency for some use cases of the
qemu vhost-user support(e.g. snabbswitch).

[1] http://www.redhat.com/archives/libvir-list/2014-June/msg01195.html
[2] http://www.redhat.com/archives/libvir-list/2014-June/msg00201.html

Michele Paolino (2):
  Add share argument to memdev devices(type=file)
  Documentation and test for the share argument in memdev device

 docs/formatdomain.html.in  |  7 +++
 docs/schemas/domaincommon.rng  |  3 +++
 src/conf/domain_conf.c | 16 
 src/conf/domain_conf.h |  1 +
 src/qemu/qemu_command.c|  3 +++
 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args |  2 +-
 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml  |  2 +-
 7 files changed, 32 insertions(+), 2 deletions(-)

-- 
1.9.3

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


[libvirt] [PATCH 1/2] Add share argument to memdev devices(type=file)

2014-06-27 Thread Michele Paolino
Add the share option in the XML parser and in the memdev domain 
structure.

Signed-off-by: Michele Paolino m.paol...@virtualopensystems.com
---
 src/conf/domain_conf.c  | 16 
 src/conf/domain_conf.h  |  1 +
 src/qemu/qemu_command.c |  3 +++
 3 files changed, 20 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 465a223..e73b6f5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9250,6 +9250,13 @@ virDomainMemDevDefParseXML(xmlNodePtr node,
 goto error;
 }
 
+if ((tmp = virXMLPropString(node, share)) != NULL) {
+if (STREQ(tmp, on))
+def-share = true;
+VIR_FREE(tmp);
+}
+
 if ((tmp = virXMLPropString(node, merge)) != NULL) {
 if (STREQ(tmp, yes))
 def-merge = true;
@@ -9297,6 +9304,13 @@ virDomainMemDevDefParseXML(xmlNodePtr node,
 goto error;
 }
 
+if (def-type == VIR_DOMAIN_MEMDEV_RAM  def-share) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(The share argument should be not specified when 
+ memory device type is 'ram'));
+goto error;
+}
+
 def-hostnodes = virXPathString(string(./source/@host-nodes), ctxt);
 
 policy = virXPathString(string(./source/@policy), ctxt);
@@ -16434,6 +16448,8 @@ virDomainMemDevDefFormat(virBufferPtr buf,
 }
 
 virBufferAsprintf(buf, memdev type='%s', type);
+if (def-type == VIR_DOMAIN_MEMDEV_FILE  def-share)
+virBufferAddLit(buf,  share='on');
 if (def-merge)
 virBufferAddLit(buf,  merge='yes');
 if (def-dump)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 06e6781..eb5bad7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1508,6 +1508,7 @@ struct _virDomainMemDevDef {
 
 unsigned long long capacity; /* bytes */
 
+bool share;
 bool merge;
 bool dump;
 bool prealloc;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index db6717f..25e5b3c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4631,6 +4631,9 @@ qemuBuildMemObjectStr(virDomainMemDevDefPtr dev,
 if (dev-type == VIR_DOMAIN_MEMDEV_FILE  dev-mempath)
 virBufferAsprintf(buf, ,mem-path=%s, dev-mempath);
 
+if (dev-type == VIR_DOMAIN_MEMDEV_FILE  dev-share)
+virBufferAsprintf(buf, ,share=on);
+
 if (dev-hostnodes)
 virBufferAsprintf(buf, ,host-nodes=%s, dev-hostnodes);
 
-- 
1.9.3

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


[libvirt] [PATCH 2/2] Documentation and test for the share argument in memdev device

2014-06-27 Thread Michele Paolino
This patch adds documentation and test for the memdev device
(type=file) share option.

Signed-off-by: Michele Paolino m.paol...@virtualopensystems.com
---
 docs/formatdomain.html.in  | 7 +++
 docs/schemas/domaincommon.rng  | 3 +++
 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args | 2 +-
 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml  | 2 +-
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0bc0139..3f8bbee 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5307,6 +5307,13 @@ qemu-kvm -net nic,model=? /dev/null
 The optional prealloc attribute enables memory preallocation.
   /p
 /dd
+dtcodeshare/code/dt
+dd
+  p
+The optional share attribute enables the share option for the backend
+memory-backed-file(type = 'file').
+  /p
+/dd
  dtcodesource/code/dt
   ddThe source element describes the device as seen from the host.
   the optional codemem-path/code element is required when specified 
type = 'file'.
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 709d13e..af51eee 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3157,6 +3157,9 @@
 /choice
   /attribute
   optional
+attribute name='share'
+  valueon/value
+/attribute
 attribute name='merge'
   valueyes/value
 /attribute
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args 
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args
index 3a1cd94..6c92194 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.args
@@ -1,7 +1,7 @@
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 /usr/bin/qemu -S -M pc \
 -m 214 \
--object 
memory-backend-file,id=ram0,size=109568K,merge=yes,dump=yes,prealloc=yes,mem-path=/hugepages,\
+-object 
memory-backend-file,id=ram0,size=109568K,merge=yes,dump=yes,prealloc=yes,mem-path=/hugepages,share=on,\
 host-nodes=0,policy=bind \
 -object 
memory-backend-file,id=ram1,size=109568K,mem-path=/hugepages,host-nodes=0,policy=bind
 \
 -smp 16 -numa node,nodeid=0,cpus=0-7,memdev=ram0 \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml
index 03e3a28..d30ee80 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa4.xml
@@ -21,7 +21,7 @@
   on_crashdestroy/on_crash
   devices
 emulator/usr/bin/qemu/emulator
-memdev type='file' merge='yes' dump='yes' prealloc='yes'
+memdev type='file' share='on' merge='yes' dump='yes' prealloc='yes'
   nameram0/name
   capacity unit='KiB'109550/capacity
   source mem-path='/hugepages' host-nodes='0' policy='bind'/
-- 
1.9.3

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


Re: [libvirt] [libvirt-glib] [PATCHv2 2/2] libvirt-gobject-domain: Add _get_snapshots

2014-06-27 Thread Christophe Fergeau
Looks good, ACK.


On Fri, Jun 27, 2014 at 04:35:07PM +0200, Timm Bäder wrote:
 ... which returns a GList of GVirDomainSnapshots, i.e. without any tree
 structure or other relationship between the snapshots.
 ---
  libvirt-gobject/libvirt-gobject-domain.c | 21 +
  libvirt-gobject/libvirt-gobject-domain.h |  4 
  libvirt-gobject/libvirt-gobject.sym  |  1 +
  3 files changed, 26 insertions(+)
 
 diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
 b/libvirt-gobject/libvirt-gobject-domain.c
 index a527d4e..e4c99ed 100644
 --- a/libvirt-gobject/libvirt-gobject-domain.c
 +++ b/libvirt-gobject/libvirt-gobject-domain.c
 @@ -1575,3 +1575,24 @@ gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
  free(snapshots);
  return TRUE;
  }
 +
 +/**
 + * gvir_domain_get_snapshots:
 + * @dom: The domain
 + * Returns: (element-type LibvirtGObject.DomainSnapshot) (transfer full): A
 + * list of all the snapshots available for the given domain. The returned
 + * list should be freed with g_list_free(), after its elements have been
 + * unreffed with g_object_unref().
 + */
 +GList *gvir_domain_get_snapshots(GVirDomain *dom)
 +{
 +GList *snapshots = NULL;
 +g_return_val_if_fail(GVIR_IS_DOMAIN(dom), NULL);
 +
 +if (dom-priv-snapshots != NULL) {
 +snapshots = g_hash_table_get_values(dom-priv-snapshots);
 +g_list_foreach(snapshots, (GFunc)g_object_ref, NULL);
 +}
 +
 +return snapshots;
 +}
 diff --git a/libvirt-gobject/libvirt-gobject-domain.h 
 b/libvirt-gobject/libvirt-gobject-domain.h
 index fb33e2b..acea7c2 100644
 --- a/libvirt-gobject/libvirt-gobject-domain.h
 +++ b/libvirt-gobject/libvirt-gobject-domain.h
 @@ -366,6 +366,10 @@ gvir_domain_create_snapshot(GVirDomain *dom,
  gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
   guint flags,
   GError **error);
 +
 +GList *gvir_domain_get_snapshots(GVirDomain *dom);
 +
 +
  G_END_DECLS
  
  #endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
 diff --git a/libvirt-gobject/libvirt-gobject.sym 
 b/libvirt-gobject/libvirt-gobject.sym
 index 781310f..28e547a 100644
 --- a/libvirt-gobject/libvirt-gobject.sym
 +++ b/libvirt-gobject/libvirt-gobject.sym
 @@ -237,6 +237,7 @@ LIBVIRT_GOBJECT_0.1.5 {
  LIBVIRT_GOBJECT_0.1.9 {
global:
   gvir_domain_fetch_snapshots;
 + gvir_domain_get_snapshots;
   gvir_domain_snapshot_delete;
   gvir_domain_snapshot_list_flags_get_type;
  } LIBVIRT_GOBJECT_0.1.5;
 -- 
 2.0.0
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list


pgpZ5tLU4_noS.pgp
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [libvirt-glib] [PATCHv2 1/2] libvirt-gobject-domain: Add _fetch_snapshots

2014-06-27 Thread Christophe Fergeau
On Fri, Jun 27, 2014 at 04:35:06PM +0200, Timm Bäder wrote:
 This function can be used to fetch the snapshots of a domain (according
 to the given GVirDomainSnapshotListFlags) and save them in a
 domain-internal GHashTable. A function to access them from outside will
 be added in a later patch.
 ---
  libvirt-gobject/libvirt-gobject-domain.c | 61 
 
  libvirt-gobject/libvirt-gobject-domain.h | 36 +++
  libvirt-gobject/libvirt-gobject.sym  |  2 ++
  3 files changed, 99 insertions(+)
 
 diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
 b/libvirt-gobject/libvirt-gobject-domain.c
 index c6e30e5..a527d4e 100644
 --- a/libvirt-gobject/libvirt-gobject-domain.c
 +++ b/libvirt-gobject/libvirt-gobject-domain.c
 @@ -38,6 +38,7 @@ struct _GVirDomainPrivate
  {
  virDomainPtr handle;
  gchar uuid[VIR_UUID_STRING_BUFLEN];
 +GHashTable *snapshots;
  };
  
  G_DEFINE_TYPE(GVirDomain, gvir_domain, G_TYPE_OBJECT);
 @@ -121,6 +122,10 @@ static void gvir_domain_finalize(GObject *object)
  
  g_debug(Finalize GVirDomain=%p, domain);
  
 +if (priv-snapshots) {
 +g_hash_table_unref (priv-snapshots);
 +}
 +
  virDomainFree(priv-handle);
  
  G_OBJECT_CLASS(gvir_domain_parent_class)-finalize(object);
 @@ -1514,3 +1519,59 @@ gvir_domain_create_snapshot(GVirDomain *dom,
  g_free(custom_xml);
  return dom_snapshot;
  }
 +
 +
 +
 +/**
 + * gvir_domain_fetch_snapshots:
 + * @dom: The domain
 + * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags
 + * @error: (allow-none): Place-holder for error or NULL
 + *
 + * Returns: TRUE on success, FALSE otherwise.
 + */
 +gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
 + guint list_flags,
 + GError **error)
 +{
 +GVirDomainPrivate *priv;
 +virDomainSnapshotPtr *snapshots = NULL;
 +GVirDomainSnapshot *snap;

It looks like the declaration of 'snap' can be moved to the inner for()
block.

ACK with this changed (I'll do it before pushing if you don't have push
access to libvirt.org).

Christophe


pgp84hus0Fmom.pgp
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] RFC: 'old' event for leaseshelper.c when lease renews

2014-06-27 Thread Nehal J Wani
In the current version of dnsmasq, the leases helper script/program
specified by --dhcp-script to dnsmasq is invoked on three events,
'add', 'old', 'del'. In short,
add: - a new lease has to be added to db
del: - a lease has to be deleted from db
old:- if lease has changed
Now, the lease can be considered to be changed in 2 ways.
[standard-change] The change could be to the associated hostname or MAC address
[auxiliary-change] The change associated with expiry time or clientid

When only --dhcp-script is set, 'old' events are sent only for
standard-lease changes. But when --dhcp-script is set along with
--leasefile-ro, 'old' events are sent for any change in the lease.

So, right now, if a lease is renewed, the reflected change doesn't
appear in our JSON formatted lease database interface-name.status.
We have the following options with this:

(i) We can simply add the --leasefile-ro option. But in that case, the
leases file database which is generated by dnsmasq by the name
network-name.leases will cease to exist. It won't contain any lease
information. All lease database handling will be done by our
leaseshelper. Note: this option given a lot of information which is
not stored in network-name.leases file.

(ii) We ask the dnsmasq developer(s) to add an extra command line
option to enable auxiliary changes in lease to be propagated to
leaseshelper via 'old' events. I had a small conversation with Simon
Kelley, and he said:
Yes. For that application (libvirt), you clearly don't want a
third-party patch. At very least I'd be willing to add a boolean
option to dnsmasq which enables old events when the lease expiry
time changes, independent of leasefile-ro.
If we do this, then can retain network-name.leases and have our helper too.

(iii) We do nothing.

IMO, we should go for (i), since network-name.leases becomes
obsolete, once we have our own leases helper. Also, enabling
--leasefile-ro enables a lot of other options, like vendor-class,
user-class, circuit-id and much more, which may be asked for in future
and get added to the virNetworkDHCPLeases struct. But we will have to
remove the option --dhcp-leasefile. Although it won't affect any
existing APIs, if people did rely on the dnsmasq's generated leases
file before, they will find it missing. There is one more point. The
man page of dnsmasq for the leasefile-ro option, states, In addition
to the invocations given in --dhcp-script the lease-change script is
called once, at dnsmasq startup, with the single argument init. When
called like this the script should write the saved state of the lease
database, in dnsmasq leasefile format, to stdout and exit with zero
exit code. This is something extra that we will have to add to
leaseshelper if we go with (i).

The easier option is to go with (ii), since Simon is already willing
to add that functionality.




-- 
Nehal J Wani

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


Re: [libvirt] [PATCH] qemu: Add cmd_per_lun, max_sectors to virtio-scsi

2014-06-27 Thread Mike Perez
On Thu, Jun 5, 2014 at 6:57 AM, Ján Tomko jto...@redhat.com wrote:
 On 05/23/2014 12:06 AM, Eric Blake wrote:
 On 05/22/2014 12:22 PM, Mike Perez wrote:
 This introduces two new attributes cmd_per_lun and max_sectors same
 with the names QEMU uses for virtio-scsi. An example of the XML:

 controller type='scsi' index='0' model='virtio-scsi' cmd_per_lun='50'
 max_sectors='512'/

 I'm not a fan of underscore (why type the shift key, when a dash will
 do).  The libvirt xml name does not have to exactly match the qemu
 option name, so maybe there's some room for bikeshedding what names we
 should actually present to the user.


 IMO using underscores here would be consistent with other disk-related options
 like read_iops_sec; dashes are mostly used for network-related options.

 We could also use camelCase [1], or just roll a dice.

Well underscores are originally what I had in my first patch [1]. Eric
what do you think?

[1] - http://www.redhat.com/archives/libvir-list/2014-May/msg00798.html

--
Mike Perez

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

[libvirt] Track an error

2014-06-27 Thread David kiarie
Hi there,

Just a silly question, do we have a simpler way of checking where
exactly a test is failing.The tests are failing after hacking stuff
around.

I have this error

../build-aux/test-driver: line 95: 20128 Segmentation fault  $@
 $log_file 21

Yes am having a segfault!

I don't know how to track it, well, I could review the whole file but
is there some other method I am missing.Could you help me interpret
the error, what  does 20128 stand for?

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