[libvirt] [PATCH] AppArmor: Fix the place where the template should be installed

2014-02-12 Thread Cédric Bosdonnat
The security driver expects /etc/apparmor.d/libvirt/TEMPLATE but we
installed it to /etc/apparmor.d/libvirtd/TEMPLATE. Move the template to
the expected place since that code was here long before.
---
 examples/apparmor/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/apparmor/Makefile.am b/examples/apparmor/Makefile.am
index 6e69440..2630fef 100644
--- a/examples/apparmor/Makefile.am
+++ b/examples/apparmor/Makefile.am
@@ -32,7 +32,7 @@ abstractions_DATA = \
libvirt-qemu \
$(NULL)
 
-templatesdir = $(apparmordir)/libvirtd
+templatesdir = $(apparmordir)/libvirt
 templates_DATA = \
TEMPLATE \
$(NULL)
-- 
1.8.5.2

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


[libvirt] [PATCH] Fix leaks in vircapstest

2014-02-12 Thread Ján Tomko
Coverity complains about cell_cpus being leaked on error
and valgrind shows 'caps' is leaked on success.

Introduced in eb64e87.
---
 tests/vircapstest.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/vircapstest.c b/tests/vircapstest.c
index a40771d..4264e9e 100644
--- a/tests/vircapstest.c
+++ b/tests/vircapstest.c
@@ -40,7 +40,7 @@ static virCapsPtr
 buildNUMATopology(int seq)
 {
 virCapsPtr caps;
-virCapsHostNUMACellCPUPtr cell_cpus;
+virCapsHostNUMACellCPUPtr cell_cpus = NULL;
 int core_id, cell_id;
 int id;
 
@@ -75,6 +75,8 @@ buildNUMATopology(int seq)
 return caps;
 
 error:
+virCapabilitiesClearHostNUMACellCPUTopology(cell_cpus, MAX_CPUS_IN_CELL);
+VIR_FREE(cell_cpus);
 virObjectUnref(caps);
 return NULL;
 
@@ -87,7 +89,7 @@ test_virCapabilitiesGetCpusForNodemask(const void *data 
ATTRIBUTE_UNUSED)
 const char *nodestr = 3,4,5,6;
 virBitmapPtr nodemask = NULL;
 virBitmapPtr cpumap = NULL;
-virCapsPtr caps;
+virCapsPtr caps = NULL;
 int mask_size = 8;
 int ret = -1;
 
@@ -107,6 +109,7 @@ test_virCapabilitiesGetCpusForNodemask(const void *data 
ATTRIBUTE_UNUSED)
 ret = 0;
 
 error:
+virObjectUnref(caps);
 virBitmapFree(nodemask);
 virBitmapFree(cpumap);
 return ret;
-- 
1.8.3.2

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


Re: [libvirt] [PATCH] qemu driver: sync guest time via qemu-guest-agent when domain is resumed

2014-02-12 Thread Daniel P. Berrange
On Tue, Feb 11, 2014 at 11:48:58AM +0100, Michal Privoznik wrote:
 On 11.02.2014 01:04, Marcelo Tosatti wrote:
 On Mon, Feb 10, 2014 at 03:42:45PM -0700, Eric Blake wrote:
 On 02/10/2014 03:10 PM, Marcelo Tosatti wrote:
 
 Since QEMU commit kvmclock: clock should count only if vm is running
 (http://lists.gnu.org/archive/html/qemu-devel/2013-06/msg01225.html),
 guests have their realtime clock stopped during pause.
 
 To correct the situation, invoke guest agent to sync time from
 host time.
 
 This needs to be conditional on new API (either a flag to existing API
 [except that virDomainResumeFlags is not quite existing yet], or new API
 altogether).
 
 We cannot require an API to depend on guest interaction (which an agent
 command does) without an explicit flag mentioning that it is okay.  We
 may even decide to have conditional ACL checks (allowing some users the
 ability to restart a domain, but not to interact with the guest agent).
 
 For that matter, when we proposed adding virDomainResumeFlags as the way
 to add in a flag for requesting a sync via this API, Dan suggested it
 would be better to add a new API altogether instead of piggybacking on
 top of the existing API:
 
 https://www.redhat.com/archives/libvir-list/2014-February/msg00104.html
 
 So there's interesting, and I'm not sure I entirely agree about
 adding flags here. It seems to me that if the QEMU agent has a
 set-time capability we'd be better off having an explicit API
 virDomainSetTime(...).  The action of resume + set time cannot
 be atomic so I don't see any point in overloading the set time
 functionality into the resume API call. Just let apps call the
 set time method if they so desire.
 
 Apps desire the guest time to be synchronized to host time, which is the
 standard 99% of usecases configuration.
 
 Ok, i was thinking of adding a new element GuestSyncTimeOnResume to
 control this, which would default to on (as users expect their guests
 time to be correct at all times, without additional commands, and
 rightly so).
 
 It seems unreasonable to me that every API user has to keep track of
 every location which a guest can possibly resume execution from a paused
 state: this can be hidden inside libvirt.
 
 Daniel, all the logic behind the necessity to set-time after guest
 resume (*) can be hidden inside libvirt.
 
 (*) all instances of guest resume: upon migration continuation, upon
 ENOSPACE pause continuation, all of them.
 
 Don't see the need to force the knowledge and maintenance of this state
 on libvirt users.
 
 Are you OK with the new knob, default on, to control sync time on
 guest resume, then?
 
 
 
 I think we may need both approaches. I too think that resume with
 syncing guest time is so common use case that is deserves to be
 exposed as a single operation outside the libvirt.
 
 On the other hand, we certainly want to expose this as a new
 virDomain{Get,Set}Time() API.

I agree that this should be a completely separate command, not
merely a flag to the Resume API.  The reason is that you cannot
do sensible error reporting if you overload this in one API
call.  ie consider that resuming the CPUs succeeds, but syncing
time fails. If you return success to the caller you are lieing
about the result of time sync. If you return error to the caller
you are lieing about the result of resuming the CPUs.

If there is a separate API to invoke then the caller can clearly
see which operation succeeded vs failed.

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] [PATCHv2 2/6] event: server RPC protocol tweaks for domain lifecycle events

2014-02-12 Thread Daniel P. Berrange
On Tue, Feb 11, 2014 at 02:07:06PM -0700, Eric Blake wrote:
 On 02/11/2014 08:57 AM, Daniel P. Berrange wrote:
  On Wed, Jan 29, 2014 at 10:49:22AM -0700, Eric Blake wrote:
  This patch adds some new RPC call numbers, but for ease of review,
  they sit idle until a later patch adds the client counterpart to
  drive the new RPCs.  Also for ease of review, I limited this patch
 
  
  ACK
  
 
 Thanks for the review.
 
  
  
  @@ -5068,5 +5085,25 @@ enum remote_procedure {
* @generate: both
* @acl: none
*/
  -REMOTE_PROC_NETWORK_EVENT_LIFECYCLE = 315
  +REMOTE_PROC_NETWORK_EVENT_LIFECYCLE = 315,
  +
  +/**
  + * @generate: none
  + * @priority: high
  + * @acl: none
  + */
  +REMOTE_PROC_CONNECT_DOMAIN_EVENT_CALLBACK_REGISTER_ANY = 316,
  +
  +/**
  + * @generate: none
  + * @priority: high
  + * @acl: none
  + */
  +REMOTE_PROC_CONNECT_DOMAIN_EVENT_CALLBACK_DEREGISTER_ANY = 317,
  
  I believe these ACLs need to be non-none now
 
 The way 'make -C src check-aclrules' works is by correlating all RPC
 calls back into their API names - but I'm not inventing any new API
 names.  These new RPC calls are already covered by existing APIs, and
 the ACL checks performed there are already sufficient.  But it turns out
 that it doesn't hurt to make these ACLs match the other register RPC
 numbers, so I'm inclined to squash this in, unless you think that
 generating unused functions in src/access/viraccessapicheck.c is not
 worth the pollution:
 
 diff --git i/src/remote/remote_protocol.x w/src/remote/remote_protocol.x
 index 982ab1f..26abcdd 100644
 --- i/src/remote/remote_protocol.x
 +++ w/src/remote/remote_protocol.x
 @@ -5090,14 +5090,15 @@ enum remote_procedure {
  /**
   * @generate: none
   * @priority: high
 - * @acl: none
 + * @acl: connect:search_domains
 + * @aclfilter: domain:getattr
   */
  REMOTE_PROC_CONNECT_DOMAIN_EVENT_CALLBACK_REGISTER_ANY = 316,
 
  /**
   * @generate: none
   * @priority: high
 - * @acl: none
 + * @acl: connect:read
   */
  REMOTE_PROC_CONNECT_DOMAIN_EVENT_CALLBACK_DEREGISTER_ANY = 317,

ACK to this - it makes it clearer i think

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] Fixed build with clang.

2014-02-12 Thread Cédric Bosdonnat
Two unused global variables, and DBUS_TYPE_INVALID used as a const
char*.
---
 src/phyp/phyp_driver.c |  1 -
 src/storage/storage_backend_scsi.c | 24 
 src/util/virdbus.c |  2 +-
 3 files changed, 1 insertion(+), 26 deletions(-)

diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 20b5bd4..9adb6b0 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -66,7 +66,6 @@
  * */
 
 static unsigned const int HMC = 0;
-static unsigned const int IVM = 127;
 static unsigned const int PHYP_IFACENAME_SIZE = 24;
 static unsigned const int PHYP_MAC_SIZE = 12;
 
diff --git a/src/storage/storage_backend_scsi.c 
b/src/storage/storage_backend_scsi.c
index b38e530..44f17c9 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -107,30 +107,6 @@ struct diskType {
 unsigned long long magic;
 };
 
-static struct diskType const disk_types[] = {
-{ VIR_STORAGE_POOL_DISK_LVM2, 0x218, 8, 0x31303020324D564CULL },
-{ VIR_STORAGE_POOL_DISK_GPT,  0x200, 8, 0x5452415020494645ULL },
-{ VIR_STORAGE_POOL_DISK_DVH,  0x0,   4, 0x41A9E50BULL },
-{ VIR_STORAGE_POOL_DISK_MAC,  0x0,   2, 0x5245ULL },
-{ VIR_STORAGE_POOL_DISK_BSD,  0x40,  4, 0x82564557ULL },
-{ VIR_STORAGE_POOL_DISK_SUN,  0x1fc, 2, 0xBEDAULL },
-/*
- * NOTE: pc98 is funky; the actual signature is 0x55AA (just like dos), so
- * we can't use that.  At the moment I'm relying on the dummy IPL
- * bootloader data that comes from parted.  Luckily, the chances of running
- * into a pc98 machine running libvirt are approximately nil.
- */
-/*{ 0x1fe, 2, 0xAA55UL },*/
-{ VIR_STORAGE_POOL_DISK_PC98, 0x0,   8, 0x314C504900CBULL },
-/*
- * NOTE: the order is important here; some other disk types (like GPT and
- * and PC98) also have 0x55AA at this offset.  For that reason, the DOS
- * one must be the last one.
- */
-{ VIR_STORAGE_POOL_DISK_DOS,  0x1fe, 2, 0xAA55ULL },
-{ -1, 0x0,   0, 0x0ULL },
-};
-
 static int
 virStorageBackendSCSIUpdateVolTargetInfo(virStorageVolTargetPtr target,
  unsigned long long *allocation,
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index a0cbbfe..a6232b7 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -1281,7 +1281,7 @@ int virDBusIsServiceEnabled(const char *name)
   /org/freedesktop/DBus,
   org.freedesktop.DBus,
   ListActivatableNames,
-  DBUS_TYPE_INVALID)  0)
+  NULL)  0)
 return ret;
 
 if (!dbus_message_iter_init(reply, iter) ||
-- 
1.8.5.2

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


Re: [libvirt] [PATCH 4/8] storage: lvm: Separate creating of the volume from building

2014-02-12 Thread Ján Tomko
On 02/12/2014 07:29 AM, Michael Chapman wrote:
 On Thu, 16 Jan 2014, Peter Krempa wrote:
 On 01/09/14 23:40, Eric Blake wrote:
 On 01/06/2014 09:44 AM, Peter Krempa wrote:
 Separate the steps to create libvirt's volume metadata from the actual
 volume building process. This is already done for regular file based
 pools to allow job support for storage APIs.
 ---
  src/storage/storage_backend_logical.c | 60
 +--
  1 file changed, 37 insertions(+), 23 deletions(-)


 ACK; I'm borderline whether this should wait for the release, though.


 Now that 1.2.2 is out I've pushed this one and the rest with the same
 complaint.
 
 Hi Peter,
 
 This breaks volume creation in an LVM pool:
 
   # cat volume.xml
   volume type='block'
 nametest/name
 capacity unit='bytes'10737418240/capacity
 allocation unit='bytes'10737418240/allocation
   /volume
   # virsh vol-create vg volume.xml
   error: Failed to create vol from volume.xml
   error: key in virGetStorageVol must not be NULL
 
 The problem is a storage backend's createVol function is expected to set an
 appropriate key, but for an LVM volume this isn't done now until buildVol is
 called. The LV's UUID is used as the volume's key.

For the disk backend, volume keys are also generated in buildVol after the
volume is created.

IMO we should revert commits:
commit af1fb38f55d4fb87e0fcaee1e973fa9c6713b1e6
storage: lvm: Separate creating of the volume from building
commit 67ccf91bf29488783bd1fda46b362450f71a2078
storage: disk: Separate creating of the volume from building

unless we have a really good reason not to.

 
 vol-clone and vol-create-from are even worse: libvirtd crashes since the NULL
 return from virGetStorageVol isn't handled in storageVolCreateXMLFrom. We
 probably need:
 
   --- a/src/storage/storage_driver.c
   +++ b/src/storage/storage_driver.c
   @@ -1828,6 +1828,10 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
pool-volumes.objs[pool-volumes.count++] = newvol;
volobj = virGetStorageVol(obj-conn, pool-def-name, newvol-name,
  newvol-key, NULL, NULL);
   +if (!volobj) {
   +pool-volumes.count--;
   +goto cleanup;
   +}
 
/* Drop the pool lock during volume allocation */
pool-asyncjobs++;

ACK to this patch. No matter what way we fix the actual bug, virGetStorageVol
can still return NULL when we're out of memory. Would you like to write a
commit message and send it as a formal patch, or shall I do it?

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 4/8] storage: lvm: Separate creating of the volume from building

2014-02-12 Thread Michael Chapman

On Wed, 12 Feb 2014, Ján Tomko wrote:

  --- a/src/storage/storage_driver.c
  +++ b/src/storage/storage_driver.c
  @@ -1828,6 +1828,10 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
   pool-volumes.objs[pool-volumes.count++] = newvol;
   volobj = virGetStorageVol(obj-conn, pool-def-name, newvol-name,
 newvol-key, NULL, NULL);
  +if (!volobj) {
  +pool-volumes.count--;
  +goto cleanup;
  +}

   /* Drop the pool lock during volume allocation */
   pool-asyncjobs++;


ACK to this patch. No matter what way we fix the actual bug, virGetStorageVol
can still return NULL when we're out of memory. Would you like to write a
commit message and send it as a formal patch, or shall I do it?


I'll send a patch through shortly.

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

[libvirt] [PATCH] storage: handle NULL return from virGetStorageVol

2014-02-12 Thread Michael Chapman
virGetStorageVol can return NULL on out-of-memory. If it does, cleanly
abort the volume clone operation.

Signed-off-by: Michael Chapman m...@very.puzzling.org
---
 src/storage/storage_driver.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index c83aa8a..2f7b2e5 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1828,6 +1828,10 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
 pool-volumes.objs[pool-volumes.count++] = newvol;
 volobj = virGetStorageVol(obj-conn, pool-def-name, newvol-name,
   newvol-key, NULL, NULL);
+if (!volobj) {
+pool-volumes.count--;
+goto cleanup;
+}
 
 /* Drop the pool lock during volume allocation */
 pool-asyncjobs++;
-- 
1.8.3.1

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


Re: [libvirt] libvirt default network

2014-02-12 Thread Thierry Parmentelat
Hi again

So we did 2 changes in the specfile that are described below
This has gone through all our nightlies and all, so that works for us

I’m sorry that I can’t seem to get git send-email to work on my mac (complains 
about missing perl modules ?!?)
Fortunately the changes I did are so simple, I hope you can use the following 
material

http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=a0e03e6894d8e8486e79531967b92b83d6d59b86

http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=7f0c4d07b5faac3f0fb07cd8240f5ae0e1063560

Of course I can post using some other scheme if that’s not working for you guys 

Thanks — Thierry

On 11 Feb 2014, at 12:37, Daniel P. Berrange berra...@redhat.com wrote:

 On Tue, Feb 11, 2014 at 12:13:49PM +0100, Thierry Parmentelat wrote:
 Hello Laine; please see inline — many thanks for the feedback in any case — 
 Thierry
 
 4) Even if you are installing/upgrading libvirt-daemon-config-network
 and the system doesn't already have a default network in place, *if
 libvirt-daemon-config-network package is installed/updated after the
 libvirt-daemon package is installed/updated (i.e. libvirtd has already
 been restarted), then the newly placed default.xml will not be
 recognized until the libvirtd service is again restarted. (actually it
 appears that yum (or maybe rpm) is smart enough to do upgrade the files
 from all packages before running any %post scripts, so that may not be a
 problem).
 
 I value your explanations very much
 however it seems that in our case:
 . this is observed in a test framework, and we run into this problem right 
 after installing for the first time, there’s no upgrading in the loop
 . I should probably have added the extract below to the report
 this is captured at build-time when preparing the image that these nodes 
 will be running 
 as you can see the post install snippet responsible for creating the 
 /etc/libvirt/… stub fails because at that time, the source from 
 /usr/share/libvirt is not available yet
 
  Installing : libvirt-client-1.2.1-0.x86_64
 242/340
  Installing : libvirt-python-1.2.1-0.x86_64
 243/340
 ...
  Installing : libvirt-daemon-1.2.1-0.x86_64
 249/340
  Installing : libvirt-daemon-driver-secret-1.2.1-0.x86_64  
 250/340
  Installing : libvirt-daemon-driver-nodedev-1.2.1-0.x86_64 
 251/340
  Installing : libvirt-daemon-config-network-1.2.1-0.x86_64 
 252/340
 /var/tmp/rpm-tmp.4piryn: line 3: /usr/share/libvirt/networks/default.xml: No 
 such file or directory
 ln: failed to create symbolic link 
 '/etc/libvirt/qemu/networks/autostart/default.xml': No such file or directory
 warning: %post(libvirt-daemon-config-network-1.2.1-0.x86_64) scriptlet 
 failed, exit status 1
 Non-fatal POSTIN scriptlet failure in rpm package 
 libvirt-daemon-config-network-1.2.1-0.x86_64
  Installing : libvirt-daemon-driver-uml-1.2.1-0.x86_64 
 253/340
  Installing : libvirt-daemon-config-nwfilter-1.2.1-0.x86_64
 254/340
  Installing : ebtables-2.0.10-11.fc20.x86_64   
 255/340
  Installing : libvirt-daemon-driver-nwfilter-1.2.1-0.x86_64
 256/340
 ...
  Installing : libvirt-daemon-driver-network-1.2.1-0.x86_64 
 276/340
  Installing : libvirt-daemon-driver-lxc-1.2.1-0.x86_64 
 277/340
 
 Yep, this is pretty clear that we have a missing dep.
 
 libvirt-daemon-config-network Requires libvirt-daemon, which is fine
 when we do *not* have driver modules enabled.
 
 In your case though we do have driver modules enabled, so we must
 add a dep on  libvirt-daemon-driver-network from config-network
 
 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 v2 2/2] vircapstest: Introduce virCapabilitiesGetCpusForNodemask test

2014-02-12 Thread John Ferlan
Coverity has complained this morning about this change... see below.

Please send a patch to resolve.

On 02/08/2014 01:51 AM, Pradipta Kr. Banerjee wrote:
 This test creates a Fake NUMA topology with non-sequential cell ids
 to check if libvirt properly handles the same
 
 Signed-off-by: Shivaprasad G Bhat sb...@linux.vnet.ibm.com
 Signed-off-by: Pradipta Kr. Banerjee bpra...@in.ibm.com
 ---
  tests/Makefile.am   |   5 ++
  tests/vircapstest.c | 129 
 
  2 files changed, 134 insertions(+)
 
 diff --git a/tests/Makefile.am b/tests/Makefile.am
 index eb96f38..bb50ac5 100644
 --- a/tests/Makefile.am
 +++ b/tests/Makefile.am
 @@ -144,6 +144,7 @@ test_programs = virshtest sockettest \
   virstoragetest \
   virnetdevbandwidthtest \
   virkmodtest \
 +vircapstest \
   $(NULL)
  
  if WITH_REMOTE
 @@ -672,6 +673,10 @@ virkmodtest_SOURCES = \
   virkmodtest.c testutils.h testutils.c
  virkmodtest_LDADD = $(LDADDS)
  
 +vircapstest_SOURCES = \
 +vircapstest.c testutils.h testutils.c
 +vircapstest_LDADD = $(LDADDS)
 +
  if WITH_LIBVIRTD
  libvirtdconftest_SOURCES = \
   libvirtdconftest.c testutils.h testutils.c \
 diff --git a/tests/vircapstest.c b/tests/vircapstest.c
 new file mode 100644
 index 000..dab8f3b
 --- /dev/null
 +++ b/tests/vircapstest.c
 @@ -0,0 +1,129 @@
 +/*
 + * Copyright (C) IBM Corp 2014
 + *
 + * 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/.
 + *
 + */
 +
 +#include config.h
 +#include stdlib.h
 +
 +#include testutils.h
 +#include capabilities.h
 +#include virbitmap.h
 +
 +
 +#define VIR_FROM_THIS VIR_FROM_NONE
 +
 +#define MAX_CELLS 4
 +#define MAX_CPUS_IN_CELL 2
 +#define MAX_MEM_IN_CELL 2097152
 +
 +
 +/*
 + * Build  NUMA Toplogy with cell id starting from (0 + seq)
 + * for testing
 +*/
 +static virCapsPtr
 +buildNUMATopology(int seq)
 +{
 +virCapsPtr caps;
 +virCapsHostNUMACellCPUPtr cell_cpus;

  
This will need to be initialized to NULL too

 +int core_id, cell_id;
 +int id;
 +
 +if ((caps = virCapabilitiesNew(VIR_ARCH_X86_64, 0, 0)) == NULL)
 +goto error;
 +
 +id = 0;
 +for (cell_id = 0; cell_id  MAX_CELLS; cell_id++) {
 +if (VIR_ALLOC_N(cell_cpus, MAX_CPUS_IN_CELL)  0)
 +goto error;

'cell_cpus' is allocated here

 +
 +for (core_id = 0; core_id  MAX_CPUS_IN_CELL; core_id++) {
 +cell_cpus[core_id].id = id + core_id;
 +cell_cpus[core_id].socket_id = cell_id + seq;
 +cell_cpus[core_id].core_id = id + core_id;
 +if (!(cell_cpus[core_id].siblings =
 +  virBitmapNew(MAX_CPUS_IN_CELL)))
 +   goto error;

If we jump to error here, it'll be leaked, as would '.siblings' for each
that failed before.

 +ignore_value(virBitmapSetBit(cell_cpus[core_id].siblings, 
 id));
 +}
 +id++;
 +
 +if (virCapabilitiesAddHostNUMACell(caps, cell_id + seq,
 +   MAX_CPUS_IN_CELL,
 +   MAX_MEM_IN_CELL,
 +   cell_cpus)  0)
 +   goto error;

If we jump to error here it'll be leaked

 +
 +cell_cpus = NULL;
 +}
 +
 +return caps;
 +
 +error:

We cannot just VIR_FREE() here since I see the virBitmapNew() above for
the array element.  So it seems there needs to be a free routine called.

 +virObjectUnref(caps);
 +return NULL;
 +
 +}
 +
 +
 +static int
 +test_virCapabilitiesGetCpusForNodemask(const void *data ATTRIBUTE_UNUSED)
 +{
 +const char *nodestr = 3,4,5,6;
 +virBitmapPtr nodemask = NULL;
 +virBitmapPtr cpumap = NULL;
 +virCapsPtr caps;
 +int mask_size = 8;
 +int ret = -1;
 +
 +//Build a NUMA topology with cell_id (NUMA node id
 +//being 3(0 + 3),4(1 + 3), 5 and 6
 +if (!(caps = buildNUMATopology(3)))
 +goto error;
 +
 +if (virBitmapParse(nodestr, 0, nodemask, mask_size)  0)
 +goto error;
 +
 +if (!(cpumap = virCapabilitiesGetCpusForNodemask(caps, nodemask)))
 +goto error;
 +
 +ret = 0;
 +
 +error:
 +virBitmapFree(nodemask);
 +virBitmapFree(cpumap);
 +return ret;
 +
 +}
 +
 +
 +static int
 +mymain(void)
 

Re: [libvirt] [PATCH v2 2/2] vircapstest: Introduce virCapabilitiesGetCpusForNodemask test

2014-02-12 Thread Ján Tomko
On 02/12/2014 12:43 PM, John Ferlan wrote:
 Coverity has complained this morning about this change... see below.
 
 Please send a patch to resolve.
 

A patch has been sent this morning, please review:

https://www.redhat.com/archives/libvir-list/2014-February/msg00660.html



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] Fixed build with clang.

2014-02-12 Thread Eric Blake
On 02/12/2014 03:36 AM, Cédric Bosdonnat wrote:
 Two unused global variables, and DBUS_TYPE_INVALID used as a const
 char*.
 ---
  src/phyp/phyp_driver.c |  1 -
  src/storage/storage_backend_scsi.c | 24 
  src/util/virdbus.c |  2 +-
  3 files changed, 1 insertion(+), 26 deletions(-)


 +++ b/src/storage/storage_backend_scsi.c
 @@ -107,30 +107,6 @@ struct diskType {
  unsigned long long magic;
  };
  
 -static struct diskType const disk_types[] = {

This is the only use of 'struct diskType'; please also remove that
declaration a couple lines earlier.

ACK with that fix.

-- 
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] Fix leaks in vircapstest

2014-02-12 Thread Eric Blake
On 02/12/2014 02:47 AM, Ján Tomko wrote:
 Coverity complains about cell_cpus being leaked on error
 and valgrind shows 'caps' is leaked on success.
 
 Introduced in eb64e87.
 ---
  tests/vircapstest.c | 7 +--
  1 file changed, 5 insertions(+), 2 deletions(-)

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

Re: [libvirt] [PATCH] AppArmor: Fix the place where the template should be installed

2014-02-12 Thread Eric Blake
On 02/12/2014 02:41 AM, Cédric Bosdonnat wrote:
 The security driver expects /etc/apparmor.d/libvirt/TEMPLATE but we
 installed it to /etc/apparmor.d/libvirtd/TEMPLATE. Move the template to
 the expected place since that code was here long before.
 ---
  examples/apparmor/Makefile.am | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

ACK and pushed.

 
 diff --git a/examples/apparmor/Makefile.am b/examples/apparmor/Makefile.am
 index 6e69440..2630fef 100644
 --- a/examples/apparmor/Makefile.am
 +++ b/examples/apparmor/Makefile.am
 @@ -32,7 +32,7 @@ abstractions_DATA = \
   libvirt-qemu \
   $(NULL)
  
 -templatesdir = $(apparmordir)/libvirtd
 +templatesdir = $(apparmordir)/libvirt
  templates_DATA = \
   TEMPLATE \
   $(NULL)
 

-- 
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] Fixed build with clang.

2014-02-12 Thread Eric Blake
On 02/12/2014 06:31 AM, Eric Blake wrote:
 On 02/12/2014 03:36 AM, Cédric Bosdonnat wrote:
 Two unused global variables, and DBUS_TYPE_INVALID used as a const
 char*.
 ---
  src/phyp/phyp_driver.c |  1 -
  src/storage/storage_backend_scsi.c | 24 
  src/util/virdbus.c |  2 +-
  3 files changed, 1 insertion(+), 26 deletions(-)
 
 
 +++ b/src/storage/storage_backend_scsi.c
 @@ -107,30 +107,6 @@ struct diskType {
  unsigned long long magic;
  };
  
 -static struct diskType const disk_types[] = {
 
 This is the only use of 'struct diskType'; please also remove that
 declaration a couple lines earlier.
 
 ACK with that fix.

I made that change and pushed.

-- 
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] Fix leaks in vircapstest

2014-02-12 Thread Ján Tomko
On 02/12/2014 02:32 PM, Eric Blake wrote:
 On 02/12/2014 02:47 AM, Ján Tomko wrote:
 Coverity complains about cell_cpus being leaked on error
 and valgrind shows 'caps' is leaked on success.

 Introduced in eb64e87.
 ---
  tests/vircapstest.c | 7 +--
  1 file changed, 5 insertions(+), 2 deletions(-)
 
 ACK
 

Thank you, now pushed.

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] libvirt default network

2014-02-12 Thread Eric Blake
On 02/12/2014 04:41 AM, Thierry Parmentelat wrote:
 Hi again

[Please don't top-post on technical lists]

 
 So we did 2 changes in the specfile that are described below
 This has gone through all our nightlies and all, so that works for us
 
 I’m sorry that I can’t seem to get git send-email to work on my mac 
 (complains about missing perl modules ?!?)

Even if you can't get send-email working, at least using 'git
format-patch' and attaching the patch files to email is easier for
exposing your patches than making people chase URLs.

 Fortunately the changes I did are so simple, I hope you can use the following 
 material
 
 http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=a0e03e6894d8e8486e79531967b92b83d6d59b86
 
 http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=7f0c4d07b5faac3f0fb07cd8240f5ae0e1063560

Thanks!  Not the easiest to get to, but I managed to pull these two
commits into a single patch, by doing:

git fetch git://git.onelab.eu/libvirt.git 1.2.1
git cherry-pick a0e03e
git cherry-pick 7f0c4d
git rebase -i   # and squashing the two into one

Here's the result (I'm not quite sure it is completely correct, but
having it here on list makes for an easier review):


From b4c141b1aa5128c35491eaea13c73508d2bcff01 Mon Sep 17 00:00:00 2001
From: Thierry Parmentelat thierry.parmente...@inria.fr
Date: Tue, 11 Feb 2014 11:35:20 +0100
Subject: [PATCH] spec: add missing dependency for setting up default network

libvirt-daemon-config-network requires libvirt-daemon-driver-network
to ensure the 'default' network is setup properly, when modules
are in use.
---
 libvirt.spec.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index e006f2b..857eb3c 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -420,7 +420,9 @@ Requires: libvirt-daemon-driver-vbox =
%{version}-%{release}
 Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release}
 %endif

+   %if %{with_interface}
 Requires: libvirt-daemon-driver-interface = %{version}-%{release}
+   %endif
 Requires: libvirt-daemon-driver-secret = %{version}-%{release}
 Requires: libvirt-daemon-driver-storage = %{version}-%{release}
 Requires: libvirt-daemon-driver-network = %{version}-%{release}
@@ -718,6 +720,7 @@ Summary: Default configuration files for the
libvirtd daemon
 Group: Development/Libraries

 Requires: libvirt-daemon = %{version}-%{release}
+Requires: libvirt-daemon-driver-network = %{version}-%{release}

 %description daemon-config-network
 Default configuration files for setting up NAT based networking
-- 
1.8.5.3




-- 
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] [PATCHv5 1/7] storage: Add APIs for internal handling of files via the storage driver

2014-02-12 Thread Peter Krempa
On 02/11/14 17:26, Peter Krempa wrote:
 Some remote filesystems are not accessible via the local filesystem
 calls, but libvirt needs means to do operations on such files.
 
 This patch adds internal APIs into the storage driver that will allow
 operations on various networked and other filesystems.
 ---
 
 Notes:
 Version 5:
 - changed error reporting scheme and re-documented
 - fix indentation of makefile
 - simplified conditions according to review
 - fixed typos
 
  docs/hvsupport.pl|   4 +-
  po/POTFILES.in   |   1 +
  src/Makefile.am  |   1 +
  src/check-drivername.pl  |   1 +
  src/driver.h |  30 +++-
  src/libvirt_private.c| 180 
 +++
  src/libvirt_private.h|  61 
  src/libvirt_private.syms |   9 +++
  8 files changed, 285 insertions(+), 2 deletions(-)
  create mode 100644 src/libvirt_private.c
  create mode 100644 src/libvirt_private.h
 

 diff --git a/src/libvirt_private.c b/src/libvirt_private.c
 new file mode 100644
 index 000..330dd88
 --- /dev/null
 +++ b/src/libvirt_private.c

...

 +/**
 + * virStorageFileStat: returns stat struct of a file via storage driver
 + *
 + * @file: file structure pointing to the file
 + * @stat: stat structure to return data
 + *
 + * Returns 0 on success, -2 if the function isn't supported by the backend,
 + * -1 on other failure. Errno is set in case of failure.
 +*/
 +int
 +virStorageFileStat(virStorageFilePtr file,
 +   struct stat *stat)

Older complilers complain here that stat shadows a global symbol. I'll
change this variable name to st.

 +{
 +if (file-driver-storageFileStat)
 +return file-driver-storageFileStat(file, stat);
 +
 +errno = ENOSYS;
 +return -2;
 +}

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] libvirt default network

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 12, 2014 at 06:54:41AM -0700, Eric Blake wrote:
 On 02/12/2014 04:41 AM, Thierry Parmentelat wrote:
  Hi again
 
 [Please don't top-post on technical lists]
 
  
  So we did 2 changes in the specfile that are described below
  This has gone through all our nightlies and all, so that works for us
  
  I’m sorry that I can’t seem to get git send-email to work on my mac 
  (complains about missing perl modules ?!?)
 
 Even if you can't get send-email working, at least using 'git
 format-patch' and attaching the patch files to email is easier for
 exposing your patches than making people chase URLs.
 
  Fortunately the changes I did are so simple, I hope you can use the 
  following material
  
  http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=a0e03e6894d8e8486e79531967b92b83d6d59b86
  
  http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=7f0c4d07b5faac3f0fb07cd8240f5ae0e1063560
 
 Thanks!  Not the easiest to get to, but I managed to pull these two
 commits into a single patch, by doing:
 
 git fetch git://git.onelab.eu/libvirt.git 1.2.1
 git cherry-pick a0e03e
 git cherry-pick 7f0c4d
 git rebase -i   # and squashing the two into one
 
 Here's the result (I'm not quite sure it is completely correct, but
 having it here on list makes for an easier review):
 
 
 From b4c141b1aa5128c35491eaea13c73508d2bcff01 Mon Sep 17 00:00:00 2001
 From: Thierry Parmentelat thierry.parmente...@inria.fr
 Date: Tue, 11 Feb 2014 11:35:20 +0100
 Subject: [PATCH] spec: add missing dependency for setting up default network
 
 libvirt-daemon-config-network requires libvirt-daemon-driver-network
 to ensure the 'default' network is setup properly, when modules
 are in use.
 ---
  libvirt.spec.in | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/libvirt.spec.in b/libvirt.spec.in
 index e006f2b..857eb3c 100644
 --- a/libvirt.spec.in
 +++ b/libvirt.spec.in
 @@ -420,7 +420,9 @@ Requires: libvirt-daemon-driver-vbox =
 %{version}-%{release}
  Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release}
  %endif
 
 + %if %{with_interface}
  Requires: libvirt-daemon-driver-interface = %{version}-%{release}
 + %endif
  Requires: libvirt-daemon-driver-secret = %{version}-%{release}
  Requires: libvirt-daemon-driver-storage = %{version}-%{release}
  Requires: libvirt-daemon-driver-network = %{version}-%{release}
 @@ -718,6 +720,7 @@ Summary: Default configuration files for the
 libvirtd daemon
  Group: Development/Libraries
 
  Requires: libvirt-daemon = %{version}-%{release}
 +Requires: libvirt-daemon-driver-network = %{version}-%{release}

This will need to be conditional on  driver modules being
enabled

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 0/2] Partially revert separation of volume creating and building

2014-02-12 Thread Ján Tomko
The storage driver expects 'createVol' to fill out the volume key.
For disk and logical backends, we generate the key only after the volume
has been built. Revert the separation commits for these backends.

Ján Tomko (2):
  Revert storage: lvm: Separate creating of the volume from building
  Revert storage: disk: Separate creating of the volume from building

 src/storage/storage_backend_disk.c| 44 -
 src/storage/storage_backend_logical.c | 60 ++-
 2 files changed, 37 insertions(+), 67 deletions(-)

-- 
1.8.3.2

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

[libvirt] [PATCH 2/2] Revert storage: disk: Separate creating of the volume from building

2014-02-12 Thread Ján Tomko
This reverts commit 67ccf91bf29488783bd1fda46b362450f71a2078.
We only generate the volume key after we've built it, but the storage
driver expects it to be filled after createVol finishes.
Squash the volume building back with creating to fulfill this
expectation.
---
 src/storage/storage_backend_disk.c | 44 --
 1 file changed, 14 insertions(+), 30 deletions(-)

diff --git a/src/storage/storage_backend_disk.c 
b/src/storage/storage_backend_disk.c
index aa3b72f..a7a7d0e 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -617,43 +617,28 @@ virStorageBackendDiskPartBoundries(virStoragePoolObjPtr 
pool,
 
 static int
 virStorageBackendDiskCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-   virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+   virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
 {
-if (vol-target.encryption != NULL) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(storage pool does not support encrypted volumes));
-return -1;
-}
-
-vol-type = VIR_STORAGE_VOL_BLOCK;
-
-return 0;
-}
-
-
-static int
-virStorageBackendDiskBuildVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-  virStoragePoolObjPtr pool,
-  virStorageVolDefPtr vol,
-  unsigned int flags)
-{
 int res = -1;
 char *partFormat = NULL;
 unsigned long long startOffset = 0, endOffset = 0;
-virCommandPtr cmd = NULL;
-
-virCheckFlags(0, -1);
-
-cmd = virCommandNewArgList(PARTED,
-   pool-def-source.devices[0].path,
-   mkpart,
-   --script,
-   NULL);
+virCommandPtr cmd = virCommandNewArgList(PARTED,
+ pool-def-source.devices[0].path,
+ mkpart,
+ --script,
+ NULL);
 
-if (virStorageBackendDiskPartFormat(pool, vol, partFormat) != 0)
+if (vol-target.encryption != NULL) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   %s, _(storage pool does not support encrypted 
+   volumes));
 goto cleanup;
+}
 
+if (virStorageBackendDiskPartFormat(pool, vol, partFormat) != 0) {
+goto cleanup;
+}
 virCommandAddArg(cmd, partFormat);
 
 if (virStorageBackendDiskPartBoundries(pool, startOffset,
@@ -783,6 +768,5 @@ virStorageBackend virStorageBackendDisk = {
 
 .createVol = virStorageBackendDiskCreateVol,
 .deleteVol = virStorageBackendDiskDeleteVol,
-.buildVol = virStorageBackendDiskBuildVol,
 .buildVolFrom = virStorageBackendDiskBuildVolFrom,
 };
-- 
1.8.3.2

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


[libvirt] [PATCH 1/2] Revert storage: lvm: Separate creating of the volume from building

2014-02-12 Thread Ján Tomko
This reverts commit af1fb38f55d4fb87e0fcaee1e973fa9c6713b1e6.
With it, creating new logical volumes fails:
https://www.redhat.com/archives/libvir-list/2014-February/msg00658.html

In the storage driver, we expect CreateVol to fill out the volume key,
but the LVM backend fills the key with the uuid reported by lvs after the
logical volume is created.
---
 src/storage/storage_backend_logical.c | 60 ++-
 1 file changed, 23 insertions(+), 37 deletions(-)

diff --git a/src/storage/storage_backend_logical.c 
b/src/storage/storage_backend_logical.c
index 039d962..15b86dc 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -702,16 +702,32 @@ cleanup:
 
 
 static int
-virStorageBackendLogicalBuildVol(virConnectPtr conn,
- virStoragePoolObjPtr pool,
- virStorageVolDefPtr vol,
- unsigned int flags)
+virStorageBackendLogicalCreateVol(virConnectPtr conn,
+  virStoragePoolObjPtr pool,
+  virStorageVolDefPtr vol)
 {
 int fd = -1;
 virCommandPtr cmd = NULL;
 virErrorPtr err;
 
-virCheckFlags(0, -1);
+if (vol-target.encryption != NULL) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   %s, _(storage pool does not support encrypted 
+   volumes));
+return -1;
+}
+
+vol-type = VIR_STORAGE_VOL_BLOCK;
+
+if (vol-target.path != NULL) {
+/* A target path passed to CreateVol has no meaning */
+VIR_FREE(vol-target.path);
+}
+
+if (virAsprintf(vol-target.path, %s/%s,
+pool-def-target.path,
+vol-name) == -1)
+return -1;
 
 cmd = virCommandNewArgList(LVCREATE,
--name, vol-name,
@@ -770,7 +786,7 @@ virStorageBackendLogicalBuildVol(virConnectPtr conn,
 
 return 0;
 
-error:
+ error:
 err = virSaveLastError();
 VIR_FORCE_CLOSE(fd);
 virStorageBackendLogicalDeleteVol(conn, pool, vol, 0);
@@ -780,36 +796,6 @@ error:
 return -1;
 }
 
-
-static int
-virStorageBackendLogicalCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
-  virStoragePoolObjPtr pool,
-  virStorageVolDefPtr vol)
-{
-if (vol-target.encryption != NULL) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(storage pool does not support encrypted volumes));
-return -1;
-}
-
-vol-type = VIR_STORAGE_VOL_BLOCK;
-
-VIR_FREE(vol-target.path);
-if (virAsprintf(vol-target.path, %s/%s,
-pool-def-target.path,
-vol-name) == -1)
-return -1;
-
-if (virFileExists(vol-target.path)) {
-virReportError(VIR_ERR_OPERATION_INVALID,
-   _(volume target path '%s' already exists),
-   vol-target.path);
-return -1;
-}
-
-return 0;
-}
-
 static int
 virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
  virStoragePoolObjPtr pool,
@@ -837,7 +823,7 @@ virStorageBackend virStorageBackendLogical = {
 .refreshPool = virStorageBackendLogicalRefreshPool,
 .stopPool = virStorageBackendLogicalStopPool,
 .deletePool = virStorageBackendLogicalDeletePool,
-.buildVol = virStorageBackendLogicalBuildVol,
+.buildVol = NULL,
 .buildVolFrom = virStorageBackendLogicalBuildVolFrom,
 .createVol = virStorageBackendLogicalCreateVol,
 .deleteVol = virStorageBackendLogicalDeleteVol,
-- 
1.8.3.2

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


[libvirt] [PATCH 3/3] rbd: Set timeout options for librados

2014-02-12 Thread Wido den Hollander
These timeout values make librados/librbd return -ETIMEDOUT when a
operation is blocking due to a failing/unreachable Ceph cluster.

By having the operations time out libvirt will not block.
---
 src/storage/storage_backend_rbd.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index 8d1e320..2c97bf4 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -60,6 +60,9 @@ static int 
virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
 char secretUuid[VIR_UUID_STRING_BUFLEN];
 size_t i;
 char *mon_buff = NULL;
+const char *client_mount_timeout = 30;
+const char *mon_op_timeout = 30;
+const char *osd_op_timeout = 30;
 
 VIR_DEBUG(Found Cephx username: %s,
   pool-def-source.auth.cephx.username);
@@ -198,6 +201,20 @@ static int 
virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
 goto cleanup;
 }
 
+/*
+ * Set timeout options for librados.
+ * In case the Ceph cluster is down libvirt won't block forever.
+ * Operations in librados will return -ETIMEDOUT when the timeout is 
reached.
+ */
+VIR_DEBUG(Setting RADOS option client_mount_timeout to %s, 
client_mount_timeout);
+rados_conf_set(ptr-cluster, client_mount_timeout, client_mount_timeout);
+
+VIR_DEBUG(Setting RADOS option rados_mon_op_timeout to %s, 
mon_op_timeout);
+rados_conf_set(ptr-cluster, rados_mon_op_timeout, mon_op_timeout);
+
+VIR_DEBUG(Setting RADOS option rados_osd_op_timeout to %s, 
osd_op_timeout);
+rados_conf_set(ptr-cluster, rados_osd_op_timeout, osd_op_timeout);
+
 ptr-starttime = time(0);
 r = rados_connect(ptr-cluster);
 if (r  0) {
-- 
1.7.9.5

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


[libvirt] [PATCH 1/3] rbd: Include return statusses from librados/librbd in logging

2014-02-12 Thread Wido den Hollander
With this information it's easier for the user to debug what is
going wrong.
---
 src/storage/storage_backend_rbd.c |  119 +
 1 file changed, 68 insertions(+), 51 deletions(-)

diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index 1b35cc4..bd21873 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -51,6 +51,7 @@ static int 
virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
  virStoragePoolObjPtr pool)
 {
 int ret = -1;
+int r = 0;
 unsigned char *secret_value = NULL;
 size_t secret_value_size;
 char *rados_key = NULL;
@@ -65,10 +66,10 @@ static int 
virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
 
 if (pool-def-source.auth.cephx.username != NULL) {
 VIR_DEBUG(Using cephx authorization);
-if (rados_create(ptr-cluster,
-pool-def-source.auth.cephx.username)  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(failed to initialize RADOS));
+r = rados_create(ptr-cluster, pool-def-source.auth.cephx.username);
+if (r  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(failed to initialize RADOS: %d), r);
 goto cleanup;
 }
 
@@ -198,10 +199,11 @@ static int 
virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
 }
 
 ptr-starttime = time(0);
-if (rados_connect(ptr-cluster)  0) {
+r = rados_connect(ptr-cluster);
+if (r  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(failed to connect to the RADOS monitor on: %s),
-   mon_buff);
+   _(failed to connect to the RADOS monitor on: %s: %d),
+   mon_buff, r);
 goto cleanup;
 }
 
@@ -248,18 +250,22 @@ static int 
volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
   virStorageBackendRBDStatePtr ptr)
 {
 int ret = -1;
+int r = 0;
 rbd_image_t image;
-if (rbd_open(ptr-ioctx, vol-name, image, NULL)  0) {
+
+r = rbd_open(ptr-ioctx, vol-name, image, NULL);
+if (r  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(failed to open the RBD image '%s'),
-   vol-name);
+   _(failed to open the RBD image '%s': %d),
+   vol-name, r);
 return ret;
 }
 
 rbd_image_info_t info;
-if (rbd_stat(image, info, sizeof(info))  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(failed to stat the RBD image));
+r = rbd_stat(image, info, sizeof(info));
+if (r  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(failed to stat the RBD image: %d), r);
 goto cleanup;
 }
 
@@ -297,6 +303,7 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr 
conn,
 size_t max_size = 1024;
 int ret = -1;
 int len = -1;
+int r = 0;
 char *name, *names = NULL;
 virStorageBackendRBDState ptr;
 ptr.cluster = NULL;
@@ -306,26 +313,28 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr 
conn,
 goto cleanup;
 }
 
-if (rados_ioctx_create(ptr.cluster,
-pool-def-source.name, ptr.ioctx)  0) {
+r = rados_ioctx_create(ptr.cluster, pool-def-source.name, ptr.ioctx);
+if (r  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(failed to create the RBD IoCTX. Does the pool '%s' 
exist?),
-   pool-def-source.name);
+   _(failed to create the RBD IoCTX. Does the pool '%s' 
exist?: %d),
+   pool-def-source.name, r);
 goto cleanup;
 }
 
 struct rados_cluster_stat_t clusterstat;
-if (rados_cluster_stat(ptr.cluster, clusterstat)  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(failed to stat the RADOS cluster));
+r = rados_cluster_stat(ptr.cluster, clusterstat);
+if (r  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(failed to stat the RADOS cluster: %d), r);
 goto cleanup;
 }
 
 struct rados_pool_stat_t poolstat;
-if (rados_ioctx_pool_stat(ptr.ioctx, poolstat)  0) {
+r = rados_ioctx_pool_stat(ptr.ioctx, poolstat);
+if (r  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(failed to stat the RADOS pool '%s'),
-   pool-def-source.name);
+   _(failed to stat the RADOS pool '%s': %d),
+   pool-def-source.name, r);
 goto cleanup;
 }
 
@@ -398,6 +407,7 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn,
  unsigned int flags)
 {
 int ret = -1;
+int r = 0;
 

[libvirt] [PATCH 0/3] Various RBD storage pool changes

2014-02-12 Thread Wido den Hollander
This series of patches changes a couple of things in the RBD storage pool
driver.

The first change is that it includes the return status of librados and librbd
in log and debug messages making it easier for users to track down the real
cause of the problem.

The second patch simplifies some code.

The third patch leverages the new timeout options from librados. Should the
backing Ceph cluster not respond for any reason librados will timeout.

This prevents libvirt from handing on a rados_* or rbd_* call and locking up
libvirt.

If the librados version on the system does not support these timeout options
nothing happens. libvirt compiles and runs just fine, but the timeout simply
won't work.

Wido den Hollander (3):
  rbd: Include return statusses from librados/librbd in logging
  rbd: Simplify opening RADOS IoCTX
  rbd: Set timeout options for librados

 src/storage/storage_backend_rbd.c |  137 ++---
 1 file changed, 80 insertions(+), 57 deletions(-)

-- 
1.7.9.5

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


[libvirt] [PATCH 2/3] rbd: Simplify opening RADOS IoCTX

2014-02-12 Thread Wido den Hollander
Reduces code and brings logging back to one function.
---
 src/storage/storage_backend_rbd.c |   43 ++---
 1 file changed, 16 insertions(+), 27 deletions(-)

diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index bd21873..8d1e320 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -221,6 +221,17 @@ cleanup:
 return ret;
 }
 
+static int virStorageBackendRBDOpenIoCTX(virStorageBackendRBDStatePtr ptr, 
virStoragePoolObjPtr pool)
+{
+int r = rados_ioctx_create(ptr-cluster, pool-def-source.name, 
ptr-ioctx);
+if (r  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(failed to create the RBD IoCTX. Does the pool '%s' 
exist?: %d),
+   pool-def-source.name, r);
+}
+return r;
+}
+
 static int virStorageBackendRBDCloseRADOSConn(virStorageBackendRBDStatePtr ptr)
 {
 int ret = 0;
@@ -313,11 +324,7 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr 
conn,
 goto cleanup;
 }
 
-r = rados_ioctx_create(ptr.cluster, pool-def-source.name, ptr.ioctx);
-if (r  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(failed to create the RBD IoCTX. Does the pool '%s' 
exist?: %d),
-   pool-def-source.name, r);
+if (virStorageBackendRBDOpenIoCTX(ptr, pool)  0) {
 goto cleanup;
 }
 
@@ -422,11 +429,7 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr 
conn,
 goto cleanup;
 }
 
-r = rados_ioctx_create(ptr.cluster, pool-def-source.name, ptr.ioctx);
-if (r  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(failed to create the RBD IoCTX. Does the pool '%s' 
exist?: %d),
-   pool-def-source.name, r);
+if (virStorageBackendRBDOpenIoCTX(ptr, pool)  0) {
 goto cleanup;
 }
 
@@ -510,13 +513,8 @@ virStorageBackendRBDBuildVol(virConnectPtr conn,
 if (virStorageBackendRBDOpenRADOSConn(ptr, conn, pool)  0)
 goto cleanup;
 
-r = rados_ioctx_create(ptr.cluster, pool-def-source.name, ptr.ioctx);
-if (r  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(failed to create the RBD IoCTX. Does the pool '%s' 
exist?: %d),
-   pool-def-source.name, r);
+if (virStorageBackendRBDOpenIoCTX(ptr, pool)  0)
 goto cleanup;
-}
 
 if (vol-target.encryption != NULL) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
@@ -551,17 +549,12 @@ static int virStorageBackendRBDRefreshVol(virConnectPtr 
conn,
 ptr.cluster = NULL;
 ptr.ioctx = NULL;
 int ret = -1;
-int r = 0;
 
 if (virStorageBackendRBDOpenRADOSConn(ptr, conn, pool)  0) {
 goto cleanup;
 }
 
-r = rados_ioctx_create(ptr.cluster, pool-def-source.name, ptr.ioctx);
-if (r  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(failed to create the RBD IoCTX. Does the pool '%s' 
exist?: %d),
-   pool-def-source.name, r);
+if (virStorageBackendRBDOpenIoCTX(ptr, pool)  0) {
 goto cleanup;
 }
 
@@ -595,11 +588,7 @@ static int virStorageBackendRBDResizeVol(virConnectPtr 
conn ATTRIBUTE_UNUSED,
 goto cleanup;
 }
 
-r = rados_ioctx_create(ptr.cluster, pool-def-source.name, ptr.ioctx);
-if (r  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(failed to create the RBD IoCTX. Does the pool '%s' 
exist?: %d),
-   pool-def-source.name, r);
+if (virStorageBackendRBDOpenIoCTX(ptr, pool)  0) {
 goto cleanup;
 }
 
-- 
1.7.9.5

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


Re: [libvirt] [PATCH 0/2] Partially revert separation of volume creating and building

2014-02-12 Thread Peter Krempa
On 02/12/14 15:03, Ján Tomko wrote:
 The storage driver expects 'createVol' to fill out the volume key.
 For disk and logical backends, we generate the key only after the volume
 has been built. Revert the separation commits for these backends.
 
 Ján Tomko (2):
   Revert storage: lvm: Separate creating of the volume from building
   Revert storage: disk: Separate creating of the volume from building
 
  src/storage/storage_backend_disk.c| 44 -
  src/storage/storage_backend_logical.c | 60 
 ++-
  2 files changed, 37 insertions(+), 67 deletions(-)
 

ACK series, these changes are not needed in the end for my gluster series.

Sorry for breaking that :/

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] [PATCHv5 1/7] storage: Add APIs for internal handling of files via the storage driver

2014-02-12 Thread Daniel P. Berrange
On Tue, Feb 11, 2014 at 05:26:53PM +0100, Peter Krempa wrote:
 Some remote filesystems are not accessible via the local filesystem
 calls, but libvirt needs means to do operations on such files.
 
 This patch adds internal APIs into the storage driver that will allow
 operations on various networked and other filesystems.
 ---
 
 Notes:
 Version 5:
 - changed error reporting scheme and re-documented
 - fix indentation of makefile
 - simplified conditions according to review
 - fixed typos
 
  docs/hvsupport.pl|   4 +-
  po/POTFILES.in   |   1 +
  src/Makefile.am  |   1 +
  src/check-drivername.pl  |   1 +
  src/driver.h |  30 +++-
  src/libvirt_private.c| 180 
 +++
  src/libvirt_private.h|  61 
  src/libvirt_private.syms |   9 +++

I'm not really convinced we should be modifying any of these files
for this. None of this stuff is being exposed in either the wire
protocol or public API.

When we made the QEMU driver have a direct dep on the network
driver, so didn't wire that stuff up into the driver framework.
We just exported APIs in network/bridge_driver.h and had QEMU
call them. I'd expect the storage/storage_driver.h to just
export APIs we need in a similar manner.

That said, if we're finding we need these extra capabilities
from the storage driver, then this is a good sign that our
public API themselves need to also be enhanced. Admittedly
the latter is a bigger job, so we shouldn't block on that.

I do think we shouldn't wire any of this up into the driver
framework though.

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] storage: handle NULL return from virGetStorageVol

2014-02-12 Thread Ján Tomko
On 02/12/2014 12:05 PM, Michael Chapman wrote:
 virGetStorageVol can return NULL on out-of-memory. If it does, cleanly
 abort the volume clone operation.
 
 Signed-off-by: Michael Chapman m...@very.puzzling.org
 ---
  src/storage/storage_driver.c | 4 
  1 file changed, 4 insertions(+)
 

ACK and pushed.

Thank you!

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 0/2] Partially revert separation of volume creating and building

2014-02-12 Thread Ján Tomko
On 02/12/2014 03:15 PM, Peter Krempa wrote:
 On 02/12/14 15:03, Ján Tomko wrote:
 The storage driver expects 'createVol' to fill out the volume key.
 For disk and logical backends, we generate the key only after the volume
 has been built. Revert the separation commits for these backends.

 Ján Tomko (2):
   Revert storage: lvm: Separate creating of the volume from building
   Revert storage: disk: Separate creating of the volume from building

  src/storage/storage_backend_disk.c| 44 -
  src/storage/storage_backend_logical.c | 60 
 ++-
  2 files changed, 37 insertions(+), 67 deletions(-)

 
 ACK series, these changes are not needed in the end for my gluster series.
 

Now pushed.

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] libvirt default network

2014-02-12 Thread Laine Stump
On 02/12/2014 03:54 PM, Eric Blake wrote:
 On 02/12/2014 04:41 AM, Thierry Parmentelat wrote:
 Hi again
 [Please don't top-post on technical lists]

 So we did 2 changes in the specfile that are described below
 This has gone through all our nightlies and all, so that works for us

 I’m sorry that I can’t seem to get git send-email to work on my mac 
 (complains about missing perl modules ?!?)
 Even if you can't get send-email working, at least using 'git
 format-patch' and attaching the patch files to email is easier for
 exposing your patches than making people chase URLs.

 Fortunately the changes I did are so simple, I hope you can use the 
 following material

 http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=a0e03e6894d8e8486e79531967b92b83d6d59b86

 http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=7f0c4d07b5faac3f0fb07cd8240f5ae0e1063560
 Thanks!  Not the easiest to get to, but I managed to pull these two
 commits into a single patch,

No need to put them in a single patch - they are for two separate issues.

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

Re: [libvirt] [PATCH] Fixed build with clang.

2014-02-12 Thread Cedric Bosdonnat
On Wed, 2014-02-12 at 06:31 -0700, Eric Blake wrote:
 On 02/12/2014 03:36 AM, Cédric Bosdonnat wrote:
  Two unused global variables, and DBUS_TYPE_INVALID used as a const
  char*.
  ---
   src/phyp/phyp_driver.c |  1 -
   src/storage/storage_backend_scsi.c | 24 
   src/util/virdbus.c |  2 +-
   3 files changed, 1 insertion(+), 26 deletions(-)
 
 
  +++ b/src/storage/storage_backend_scsi.c
  @@ -107,30 +107,6 @@ struct diskType {
   unsigned long long magic;
   };
   
  -static struct diskType const disk_types[] = {
 
 This is the only use of 'struct diskType'; please also remove that
 declaration a couple lines earlier.

Weird that clang didn't report that one after the patch.

--
Cedric

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

Re: [libvirt] [PATCH] Fixed build with clang.

2014-02-12 Thread Eric Blake
On 02/12/2014 08:04 AM, Cedric Bosdonnat wrote:
 On Wed, 2014-02-12 at 06:31 -0700, Eric Blake wrote:
 On 02/12/2014 03:36 AM, Cédric Bosdonnat wrote:
 Two unused global variables, and DBUS_TYPE_INVALID used as a const
 char*.
 ---
  src/phyp/phyp_driver.c |  1 -
  src/storage/storage_backend_scsi.c | 24 
  src/util/virdbus.c |  2 +-
  3 files changed, 1 insertion(+), 26 deletions(-)


 +++ b/src/storage/storage_backend_scsi.c
 @@ -107,30 +107,6 @@ struct diskType {
  unsigned long long magic;
  };
  
 -static struct diskType const disk_types[] = {

 This is the only use of 'struct diskType'; please also remove that
 declaration a couple lines earlier.
 
 Weird that clang didn't report that one after the patch.

Unused variables are different than unused types.  And if clang were to
warn about unused types, we'd be in trouble: gnulib's verify() module
depends on the ability to create dummy unused types.

-- 
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 v4 0/3] Network hooks

2014-02-12 Thread Michal Privoznik
Tier four.

Michal Privoznik (3):
  network_conf: Expose virNetworkDefFormatInternal
  network: Introduce network hooks
  network: Taint networks that are using hook script

 docs/hooks.html.in  |  98 --
 src/conf/network_conf.c |  64 ++---
 src/conf/network_conf.h |  20 
 src/libvirt_private.syms|   4 ++
 src/lxc/lxc_driver.c|   4 +-
 src/lxc/lxc_process.c   |   6 +--
 src/network/bridge_driver.c | 111 ++--
 src/network/bridge_driver.h |  19 
 src/qemu/qemu_command.c |   2 +-
 src/qemu/qemu_hotplug.c |  14 +++---
 src/qemu/qemu_process.c |   4 +-
 src/util/virhook.c  |  13 +-
 src/util/virhook.h  |  11 +
 13 files changed, 321 insertions(+), 49 deletions(-)

-- 
1.8.5.3

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


[libvirt] [PATCH v4 2/3] network: Introduce network hooks

2014-02-12 Thread Michal Privoznik
There might be some use cases, where user wants to prepare the host or
its environment prior to starting a network and do some cleanup after
the network has been shut down. Consider all the functionality that
libvirt doesn't currently have as an example what a hook script can
possibly do.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 docs/hooks.html.in  | 98 ++---
 src/lxc/lxc_driver.c|  4 +-
 src/lxc/lxc_process.c   |  6 +--
 src/network/bridge_driver.c | 91 +++--
 src/network/bridge_driver.h | 19 +
 src/qemu/qemu_command.c |  2 +-
 src/qemu/qemu_hotplug.c | 14 +++
 src/qemu/qemu_process.c |  4 +-
 src/util/virhook.c  | 13 +-
 src/util/virhook.h  | 11 +
 10 files changed, 220 insertions(+), 42 deletions(-)

diff --git a/docs/hooks.html.in b/docs/hooks.html.in
index f0f692b..29995f7 100644
--- a/docs/hooks.html.in
+++ b/docs/hooks.html.in
@@ -13,9 +13,15 @@
actions occur:/p
 ul
   liThe libvirt daemon starts, stops, or reloads its
-  configurationbr/br//li
-  liA QEMU guest is started or stoppedbr/br//li
-  liAn LXC guest is started or stoppedbr/br//li
+  configuration
+  (span class=sincesince 0.8.0/span)br/br//li
+  liA QEMU guest is started or stopped
+ (span class=sincesince 0.8.0/span)br/br//li
+ liAn LXC guest is started or stopped
+ (span class=sincesince 0.8.0/span)br/br//li
+  liA network is started or stopped or an interface is
+  un-/plugged from/to the network
+  (span class=sincesince 1.2.2/span)br/br//li
 /ul
 
 h2a name=locationScript location/a/h2
@@ -44,6 +50,9 @@
   Executed when a QEMU guest is started, stopped, or 
migratedbr/br//li
   licode/etc/libvirt/hooks/lxc/codebr /br/
   Executed when an LXC guest is started or stopped/li
+  licode/etc/libvirt/hooks/network/codebr/br/
+  Executed when a network is started or stopped or an
+  interface is un-/plugged from/to the network/li
 /ul
 br/
 
@@ -66,6 +75,39 @@
XML description for the domain on their stdin. This includes items
such the UUID of the domain and its storage information, and is
intended to provide all the libvirt information the script needs./p
+pFor all cases, stdin of the network hook script is provided with the
+   full XML description of the network status in the following form:/p
+
+prelt;hookDatagt;
+  lt;networkgt;
+ lt;namegt;$network_namelt;/namegt;
+ lt;uuidgt;----lt;/uuidgt;
+ ...
+  lt;/networkgt;
+lt;/hookDatagt;/pre
+
+pIn the case of an interface
+   being plugged/unplugged to the network, the network XML will be followed
+   with the full XML description of the domain containing the interface
+   that is being plugged/unplugged:/p
+
+prelt;hookDatagt;
+  lt;networkgt;
+ lt;namegt;$network_namelt;/namegt;
+ lt;uuidgt;----lt;/uuidgt;
+ ...
+  lt;/networkgt;
+  lt;domain type='$domain_type' id='$domain_id'gt;
+ lt;namegt;$domain_namelt;/namegt;
+ lt;uuidgt;----lt;/uuidgt;
+ ...
+  lt;/domaingt;
+lt;/hookDatagt;/pre
+
+pPlease note that this approach is different to other cases such as
+   codedaemon/code, codeqemu/code or codelxc/code hook scripts,
+   because two XMLs may be passed here, while in the other cases only a 
single
+   XML is passed./p
 
 pThe command line arguments take this approach:/p
 ol
@@ -181,25 +223,51 @@
 pre/etc/libvirt/hooks/lxc guest_name reconnect begin -/pre
   /li
 /ul
+
+h5a name=network/etc/libvirt/hooks/network/a/h5
+ul
+  lispan class=sinceSince 1.2.2/span, before a network is started,
+this script is called as:br/
+  pre/etc/libvirt/hooks/network network_name start begin -/pre/li
+  liAfter the network is started, up and; running, the script is
+called as:br/
+  pre/etc/libvirt/hooks/network network_name started begin 
-/pre/li
+  liWhen a network is shut down, this script is called as:br/
+  pre/etc/libvirt/hooks/network network_name stopped end -/pre/li
+  liLater, when network is started and there's an interface from a
+domain to be plugged into the network (plugged may not be the correct
+expression when it comes to bridgeless networks, perhaps allocated is
+better one then), the hook script is called as:br/
+  pre/etc/libvirt/hooks/network network_name plugged begin -/pre
+Please note, that in this case, the script is passed both network and
+domain XMLs on its stdin./li
+  liWhen the domain from previous case is shutting down, the interface
+is unplugged. This leads to another script invocation:br/
+  

[libvirt] [PATCH v4 3/3] network: Taint networks that are using hook script

2014-02-12 Thread Michal Privoznik
Basically, the idea is copied from domain code, where tainting
exists for a while. Currently, only one taint reason exists -
VIR_NETWORK_TAINT_HOOK to mark those networks which caused invoking
of hook script.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 src/conf/network_conf.c | 52 -
 src/conf/network_conf.h | 17 +++
 src/libvirt_private.syms|  3 +++
 src/network/bridge_driver.c | 20 +
 4 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 8b6236d..bac0465 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -72,6 +72,22 @@ VIR_ENUM_IMPL(virNetworkDNSForwardPlainNames,
   yes,
   no)
 
+VIR_ENUM_IMPL(virNetworkTaint, VIR_NETWORK_TAINT_LAST,
+  hook-script);
+
+bool
+virNetworkObjTaint(virNetworkObjPtr obj,
+   enum virNetworkTaintFlags taint)
+{
+unsigned int flag = (1  taint);
+
+if (obj-taint  flag)
+return false;
+
+obj-taint |= flag;
+return true;
+}
+
 virNetworkObjPtr virNetworkFindByUUID(virNetworkObjListPtr nets,
   const unsigned char *uuid)
 {
@@ -2784,6 +2800,7 @@ virNetworkObjFormat(virNetworkObjPtr net,
 {
 virBuffer buf = VIR_BUFFER_INITIALIZER;
 char *class_id = virBitmapFormat(net-class_id);
+size_t i;
 
 if (!class_id)
 goto no_memory;
@@ -2793,6 +2810,12 @@ virNetworkObjFormat(virNetworkObjPtr net,
 virBufferAsprintf(buf,   floor sum='%llu'/\n, net-floor_sum);
 VIR_FREE(class_id);
 
+for (i = 0; i  VIR_NETWORK_TAINT_LAST; i++) {
+if (net-taint  (1  i))
+virBufferAsprintf(buf,   taint flag='%s'/\n,
+  virNetworkTaintTypeToString(i));
+}
+
 virBufferAdjustIndent(buf, 2);
 if (virNetworkDefFormatBuf(buf, net-def, flags)  0)
 goto error;
@@ -2903,10 +2926,13 @@ virNetworkLoadState(virNetworkObjListPtr nets,
 virNetworkDefPtr def = NULL;
 virNetworkObjPtr net = NULL;
 xmlDocPtr xml = NULL;
-xmlNodePtr node = NULL;
+xmlNodePtr node = NULL, *nodes = NULL;
 xmlXPathContextPtr ctxt = NULL;
 virBitmapPtr class_id_map = NULL;
 unsigned long long floor_sum_val = 0;
+unsigned int taint = 0;
+int n;
+size_t i;
 
 
 if ((configFile = virNetworkConfigFile(stateDir, name)) == NULL)
@@ -2962,6 +2988,27 @@ virNetworkLoadState(virNetworkObjListPtr nets,
 goto error;
 }
 VIR_FREE(floor_sum);
+
+if ((n = virXPathNodeSet(./taint, ctxt, nodes))  0)
+goto error;
+
+for (i = 0; i  n; i++) {
+char *str = virXMLPropString(nodes[i], flag);
+if (str) {
+int flag = virNetworkTaintTypeFromString(str);
+if (flag  0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(Unknown taint flag %s), str);
+VIR_FREE(str);
+goto error;
+}
+VIR_FREE(str);
+/* Compute taint mask here. The network object does not
+ * exist yet, so we can't use virNetworkObjtTaint. */
+taint |= (1  flag);
+}
+}
+VIR_FREE(nodes);
 }
 
 /* create the object */
@@ -2978,6 +3025,8 @@ virNetworkLoadState(virNetworkObjListPtr nets,
 if (floor_sum_val  0)
 net-floor_sum = floor_sum_val;
 
+net-taint = taint;
+
 cleanup:
 VIR_FREE(configFile);
 xmlFreeDoc(xml);
@@ -2985,6 +3034,7 @@ cleanup:
 return net;
 
 error:
+VIR_FREE(nodes);
 virBitmapFree(class_id_map);
 virNetworkDefFree(def);
 goto cleanup;
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 47124ce..3abe180 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -287,6 +287,8 @@ struct _virNetworkObj {
 
 virBitmapPtr class_id; /* bitmap of class IDs for QoS */
 unsigned long long floor_sum; /* sum of all 'floor'-s of attached NICs */
+
+unsigned int taint;
 };
 
 typedef struct _virNetworkObjList virNetworkObjList;
@@ -296,12 +298,26 @@ struct _virNetworkObjList {
 virNetworkObjPtr *objs;
 };
 
+enum virNetworkTaintFlags {
+VIR_NETWORK_TAINT_HOOK, /* Hook script was executed over
+   network. We can't guarantee
+   connectivity or other settings
+   as the script may have played
+   with iptables, tc, you name it.
+ */
+
+VIR_NETWORK_TAINT_LAST
+};
+
 static inline int
 virNetworkObjIsActive(const virNetworkObj *net)
 {
 return net-active;
 }
 
+bool virNetworkObjTaint(virNetworkObjPtr obj,
+

[libvirt] [PATCH v4 1/3] network_conf: Expose virNetworkDefFormatInternal

2014-02-12 Thread Michal Privoznik
In the next patch I'm going to need the network format function that
takes virBuffer as argument. However, slightly change of name is more
appropriate then: virNetworkDefFormatBuf to match the rest of functions
that format an object to buffer.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 src/conf/network_conf.c  | 12 ++--
 src/conf/network_conf.h  |  3 +++
 src/libvirt_private.syms |  1 +
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index dd3fa19..8b6236d 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2593,10 +2593,10 @@ cleanup:
 return ret;
 }
 
-static int
-virNetworkDefFormatInternal(virBufferPtr buf,
-const virNetworkDef *def,
-unsigned int flags)
+int
+virNetworkDefFormatBuf(virBufferPtr buf,
+   const virNetworkDef *def,
+   unsigned int flags)
 {
 const unsigned char *uuid;
 char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -2763,7 +2763,7 @@ virNetworkDefFormat(const virNetworkDef *def,
 {
 virBuffer buf = VIR_BUFFER_INITIALIZER;
 
-if (virNetworkDefFormatInternal(buf, def, flags)  0)
+if (virNetworkDefFormatBuf(buf, def, flags)  0)
 goto error;
 
 if (virBufferError(buf))
@@ -2794,7 +2794,7 @@ virNetworkObjFormat(virNetworkObjPtr net,
 VIR_FREE(class_id);
 
 virBufferAdjustIndent(buf, 2);
-if (virNetworkDefFormatInternal(buf, net-def, flags)  0)
+if (virNetworkDefFormatBuf(buf, net-def, flags)  0)
 goto error;
 
 virBufferAdjustIndent(buf, -2);
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index b84762a..47124ce 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -338,6 +338,9 @@ virNetworkDefPtr virNetworkDefParseFile(const char 
*filename);
 virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml,
 xmlNodePtr root);
 char *virNetworkDefFormat(const virNetworkDef *def, unsigned int flags);
+int virNetworkDefFormatBuf(virBufferPtr buf,
+   const virNetworkDef *def,
+   unsigned int flags);
 
 static inline const char *
 virNetworkDefForwardIf(const virNetworkDef *def, size_t n)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2c9536a..b554f11 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -504,6 +504,7 @@ virNetworkConfigChangeSetup;
 virNetworkConfigFile;
 virNetworkDefCopy;
 virNetworkDefFormat;
+virNetworkDefFormatBuf;
 virNetworkDefFree;
 virNetworkDefGetIpByIndex;
 virNetworkDefParseFile;
-- 
1.8.5.3

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


Re: [libvirt] [PATCH v3 03/21] LXC from native: import rootfs

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:01PM +0100, Cédric Bosdonnat wrote:
 LXC rootfs can be either a directory or a block device or an image
 file. The first two types have been implemented, but the image file is
 still to be done since LXC auto-guesses the file format at mount time
 and the LXC driver doesn't support the 'auto' format.
 ---
  src/lxc/lxc_native.c | 69 
 
  tests/lxcconf2xmldata/lxcconf2xml-simple.xml |  4 ++
  2 files changed, 73 insertions(+)

ACK

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 v3 02/21] LXC driver: started implementing connectDomainXMLFromNative

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:00PM +0100, Cédric Bosdonnat wrote:
 This function aims at converting LXC configuration into a libvirt
 domain XML description to help users migrate from LXC to libvirt.
 
 Here is an example of how the lxc configuration works:
 virsh -c lxc:/// domxml-from-native lxc-tools /var/lib/lxc/migrate_test/config
 
 It is possible that some parts couldn't be properly mapped into a
 domain XML fragment, so users should carefully review the result
 before creating the domain.
 
 fstab files in lxc.mount lines will need to be merged into the
 configuration file as lxc.mount.entry.
 
 As we can't know the amount of memory of the host, we have to set a
 default value for max_balloon that users will probably want to adjust.
 ---
  .gitignore  |   1 +
  po/POTFILES.in  |   1 +
  src/Makefile.am |   1 +
  src/lxc/lxc_driver.c|  31 +++
  src/lxc/lxc_native.c|  86 +++
  src/lxc/lxc_native.h|  32 +++
  tests/Makefile.am   |   7 +-
  tests/lxcconf2xmldata/lxcconf2xml-simple.config |  38 +
  tests/lxcconf2xmldata/lxcconf2xml-simple.xml|  17 
  tests/lxcconf2xmltest.c | 107 
 
  10 files changed, 320 insertions(+), 1 deletion(-)
  create mode 100644 src/lxc/lxc_native.c
  create mode 100644 src/lxc/lxc_native.h
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-simple.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-simple.xml
  create mode 100644 tests/lxcconf2xmltest.c

ACK

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 v3 01/21] Improve virConf parse to handle LXC config format

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:09:59PM +0100, Cédric Bosdonnat wrote:
 virConf now honours a VIR_CONF_FLAG_LXC_FORMAT flag to handle LXC
 configuration files. The differences are that property names can
 contain '.' character and values are all strings without any bounding
 quotes.
 
 Provide a new virConfWalk function calling a handler on all non-comment
 values. This function will be used by the LXC conversion code to loop
 over LXC configuration lines.
 ---
  src/libvirt_private.syms |  1 +
  src/util/virconf.c   | 46 --
  src/util/virconf.h   | 10 ++
  3 files changed, 55 insertions(+), 2 deletions(-)

ACK

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 v3 04/21] LXC from native: migrate fstab and lxc.mount.entry

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:02PM +0100, Cédric Bosdonnat wrote:
 Tmpfs relative size and default 50% size values aren't supported as
 we have no idea of the available memory at the conversion time.
 ---
  src/lxc/lxc_container.c |   2 +-
  src/lxc/lxc_container.h |   2 +
  src/lxc/lxc_native.c| 251 
 +++-
  tests/lxcconf2xmldata/lxcconf2xml-fstab.config  |  37 
  tests/lxcconf2xmldata/lxcconf2xml-simple.config |   4 +-
  tests/lxcconf2xmldata/lxcconf2xml-simple.xml|   9 +
  tests/lxcconf2xmltest.c |  60 +++---
  7 files changed, 336 insertions(+), 29 deletions(-)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-fstab.config
 
 diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
 index c6bdc8c..f08dbc2 100644
 --- a/src/lxc/lxc_container.c
 +++ b/src/lxc/lxc_container.c
 @@ -744,7 +744,7 @@ static const virLXCBasicMountInfo lxcBasicMounts[] = {
  };
  
  
 -static bool lxcIsBasicMountLocation(const char *path)
 +bool lxcIsBasicMountLocation(const char *path)
  {
  size_t i;
  
 diff --git a/src/lxc/lxc_container.h b/src/lxc/lxc_container.h
 index e74a7d7..67292ab 100644
 --- a/src/lxc/lxc_container.h
 +++ b/src/lxc/lxc_container.h
 @@ -71,4 +71,6 @@ virArch lxcContainerGetAlt32bitArch(virArch arch);
  
  int lxcContainerChown(virDomainDefPtr def, const char *path);
  
 +bool lxcIsBasicMountLocation(const char *path);
 +
  #endif /* LXC_CONTAINER_H */
 diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
 index 86d0dd3..acd68db 100644
 --- a/src/lxc/lxc_native.c
 +++ b/src/lxc/lxc_native.c
 @@ -21,10 +21,13 @@
   */
  
  #include config.h
 +#include stdio.h
  
  #include internal.h
 +#include lxc_container.h
  #include lxc_native.h
  #include util/viralloc.h
 +#include util/virfile.h
  #include util/virlog.h
  #include util/virstring.h
  #include util/virconf.h
 @@ -33,7 +36,11 @@
  
  
  static virDomainFSDefPtr
 -lxcCreateFSDef(int type, char *src, char* dst)
 +lxcCreateFSDef(int type,
 +   char *src,
 +   char* dst,
 +   bool readonly,
 +   unsigned long long usage)
  {
  virDomainFSDefPtr def;
  
 @@ -44,16 +51,124 @@ lxcCreateFSDef(int type, char *src, char* dst)
  def-accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH;
  def-src = src;
  def-dst = dst;
 +def-readonly = readonly;
 +def-usage = usage;
  
  return def;
  }
  
 +typedef struct _lxcFstab lxcFstab;
 +typedef lxcFstab *lxcFstabPtr;
 +struct _lxcFstab {
 +lxcFstabPtr next;
 +char *src;
 +char *dst;
 +char *type;
 +char *options;
 +};
 +
 +static void
 +lxcFstabFree(lxcFstabPtr fstab)
 +{
 +while (fstab) {
 +lxcFstabPtr next = NULL;
 +next = fstab-next;
 +
 +VIR_FREE(fstab-src);
 +VIR_FREE(fstab-dst);
 +VIR_FREE(fstab-type);
 +VIR_FREE(fstab-options);
 +VIR_FREE(fstab);
 +
 +fstab = next;
 +}
 +}
 +
 +static char ** lxcStringSplit(const char *string)
 +{
 +char *tmp;
 +size_t i;
 +size_t ntokens = 0;
 +char **parts;
 +char **result = NULL;
 +
 +if (VIR_STRDUP(tmp, string)  0)
 +return NULL;
 +
 +/* Replace potential \t by a space */
 +for (i = 0; tmp[i]; i++) {
 +if (tmp[i] == '\t')
 +tmp[i] = ' ';
 +}
 +
 +parts = virStringSplit(tmp,  , 0);

Not checking parts for NULL

 +for (i = 0; parts[i]; i++) {
 +if (STREQ(parts[i], ))
 +continue;
 +
 +if (VIR_EXPAND_N(result, ntokens, 1)  0)
 +goto error;
 +
 +if (VIR_STRDUP(result[ntokens-1], parts[i])  0)
 +goto error;
 +}
 +
 +/* Append NULL element */
 +if (VIR_EXPAND_N(result, ntokens, 1)  0)
 +goto error;

A really subtle problem here - we need results to be
NULL terminated at all times, not only when the loop
is finished. If the VIR_EXPAND_N or VIR_STRDUP calls
in the loop body fail, we jump to error where we
call virStringFreeList which expects NULL termination.
As it stands we have array out of bounds access on OOM.

 +
 +VIR_FREE(tmp);
 +virStringFreeList(parts);
 +return result;
 +
 +error:
 +VIR_FREE(tmp);
 +virStringFreeList(parts);
 +virStringFreeList(result);
 +return NULL;
 +}
 +
 +static lxcFstabPtr
 +lxcParseFstabLine(char *fstabLine)
 +{
 +lxcFstabPtr fstab = NULL;
 +char **parts;
 +
 +if (!fstabLine || VIR_ALLOC(fstab)  0)
 +return NULL;
 +
 +parts = lxcStringSplit(fstabLine);

Not checking for NULL

 +
 +if (!parts[0] || !parts[1] || !parts[2] || !parts[3])
 +goto error;
 +
 +if (VIR_STRDUP(fstab-src, parts[0])  0 ||
 +VIR_STRDUP(fstab-dst, parts[1])  0 ||
 +VIR_STRDUP(fstab-type, parts[2])  0 ||
 +VIR_STRDUP(fstab-options, parts[3])  0)
 +goto error;
 +
 +virStringFreeList(parts);
 +
 +return 

Re: [libvirt] [PATCH v3 03/21] LXC from native: import rootfs

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 12, 2014 at 05:23:39PM +, Daniel P. Berrange wrote:
 On Wed, Feb 05, 2014 at 03:10:01PM +0100, Cédric Bosdonnat wrote:
  LXC rootfs can be either a directory or a block device or an image
  file. The first two types have been implemented, but the image file is
  still to be done since LXC auto-guesses the file format at mount time
  and the LXC driver doesn't support the 'auto' format.
  ---
   src/lxc/lxc_native.c | 69 
  
   tests/lxcconf2xmldata/lxcconf2xml-simple.xml |  4 ++
   2 files changed, 73 insertions(+)
 
 ACK

Actually there's a crash on OOM in this patch due to a double-free
of the 'src' and 'dst' strings. I'm going to squash the following
change in before pushing it

Daniel

diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 86d0dd3..af9d34e 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -33,7 +33,9 @@
 
 
 static virDomainFSDefPtr
-lxcCreateFSDef(int type, char *src, char* dst)
+lxcCreateFSDef(int type,
+   const char *src,
+   const char* dst)
 {
 virDomainFSDefPtr def;
 
@@ -42,14 +44,23 @@ lxcCreateFSDef(int type, char *src, char* dst)
 
 def-type = type;
 def-accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH;
-def-src = src;
-def-dst = dst;
+if (src  VIR_STRDUP(def-src, src)  0)
+goto error;
+if (VIR_STRDUP(def-dst, dst)  0)
+goto error;
 
 return def;
+
+ error:
+virDomainFSDefFree(def);
+return NULL;
 }
 
 static int
-lxcAddFSDef(virDomainDefPtr def, int type, char *src, char *dst)
+lxcAddFSDef(virDomainDefPtr def,
+int type,
+const char *src,
+const char *dst)
 {
 virDomainFSDefPtr fsDef = NULL;
 
@@ -71,30 +82,23 @@ static int
 lxcSetRootfs(virDomainDefPtr def,
  virConfPtr properties)
 {
-char *fssrc = NULL;
-char *fsdst = NULL;
 int type = VIR_DOMAIN_FS_TYPE_MOUNT;
 virConfValuePtr value;
 
 if (!(value = virConfGetValue(properties, lxc.rootfs)) ||
-   !value-str ||
-   (VIR_STRDUP(fssrc, value-str)  0) ||
-VIR_STRDUP(fsdst, /)  0)
-goto error;
+!value-str) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(Missing lxc.rootfs configuration));
+return -1;
+}
 
-if (STRPREFIX(fssrc, /dev/))
+if (STRPREFIX(value-str, /dev/))
 type = VIR_DOMAIN_FS_TYPE_BLOCK;
 
-
-if (lxcAddFSDef(def, type, fssrc, fsdst)  0)
-goto error;
+if (lxcAddFSDef(def, type, value-str, /)  0)
+return -1;
 
 return 0;
-
-error:
-VIR_FREE(fssrc);
-VIR_FREE(fsdst);
-return -1;
 }
 
 virDomainDefPtr

-- 
|: 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 v3 10/21] LXC from native: convert lxc.id_map into idmap

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:08PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c   | 44 
 ++
  tests/lxcconf2xmldata/lxcconf2xml-idmap.config |  5 +++
  tests/lxcconf2xmldata/lxcconf2xml-idmap.xml| 28 
  tests/lxcconf2xmltest.c|  1 +
  4 files changed, 78 insertions(+)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-idmap.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-idmap.xml

ACK

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 v3 06/21] LXC from native: migrate veth network configuration

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:04PM +0100, Cédric Bosdonnat wrote:
 Some of the LXC configuration properties aren't migrated since they
 would only cause problems in libvirt-lxc:
   * lxc.network.ipv[46]: LXC driver doesn't setup IP address of guests,
 see rhbz#1059624
   * lxc.network.name, see rhbz#1059630
 ---
  src/lxc/lxc_native.c | 114 
 ---
  tests/lxcconf2xmldata/lxcconf2xml-simple.xml |   5 ++
  2 files changed, 107 insertions(+), 12 deletions(-)

ACK

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 v3 08/21] LXC from native: convert lxc.tty to console devices

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:06PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c | 44 
 
  tests/lxcconf2xmldata/lxcconf2xml-simple.xml |  6 
  2 files changed, 50 insertions(+)


ACK

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 v3 11/21] LXC from native: migrate memory tuning

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:09PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c | 40 
 
  tests/lxcconf2xmldata/lxcconf2xml-memtune.config | 10 ++
  tests/lxcconf2xmldata/lxcconf2xml-memtune.xml| 29 +
  tests/lxcconf2xmltest.c  |  1 +
  4 files changed, 80 insertions(+)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-memtune.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-memtune.xml

ACK

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 v3 12/21] LXC from native: map lxc.cgroup.cpu.*

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:10PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c | 34 
 
  tests/lxcconf2xmldata/lxcconf2xml-cputune.config |  7 +
  tests/lxcconf2xmldata/lxcconf2xml-cputune.xml| 29 
  tests/lxcconf2xmltest.c  |  1 +
  4 files changed, 71 insertions(+)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cputune.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cputune.xml

ACK

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 v3 16/21] LXC from native: map block filesystems

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:14PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c | 4 
  1 file changed, 4 insertions(+)

ACK

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 v3 18/21] LXC: added some doc on domxml-from-native with mention of limitations

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:16PM +0100, Cédric Bosdonnat wrote:
 ---
  docs/drvlxc.html.in | 34 +-
  1 file changed, 33 insertions(+), 1 deletion(-)

ACK

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 v3 15/21] LXC from native: map lxc.arch to /domain/os/type@arch

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:13PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c| 9 +
  tests/lxcconf2xmldata/lxcconf2xml-simple.config | 1 +
  tests/lxcconf2xmldata/lxcconf2xml-simple.xml| 2 +-
  3 files changed, 11 insertions(+), 1 deletion(-)

ACK

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 v3 13/21] LXC from native: map lxc.cgroup.cpuset.*

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:11PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c   | 30 
 ++
  .../lxcconf2xmldata/lxcconf2xml-cpusettune.config  |  6 +
  tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml   | 27 +++
  tests/lxcconf2xmltest.c|  1 +
  4 files changed, 64 insertions(+)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cpusettune.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml

ACK

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 v3 07/21] LXC from native: convert phys network types to net hostdev devices

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:05PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c   | 44 
 +++---
  .../lxcconf2xmldata/lxcconf2xml-physnetwork.config |  6 +++
  tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml  | 26 +
  tests/lxcconf2xmltest.c|  1 +
  4 files changed, 72 insertions(+), 5 deletions(-)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml

ACK

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 v3 14/21] LXC from native: add lxc.cgroup.blkio.* mapping

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:12PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c   | 63 
 ++
  tests/lxcconf2xmldata/lxcconf2xml-blkiotune.config |  7 +++
  tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml| 35 
  tests/lxcconf2xmltest.c|  1 +
  4 files changed, 106 insertions(+)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-blkiotune.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml

 +if ((!(parts = lxcStringSplit(value-str))  (!parts[0] || !parts[1]))) 
 {
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(invalid blkio.device_weight value: '%s'),
 +   value-str);
 +goto error;
 +}

The conditional here is wrong and crashes if lxcStringSplit returns
NULL.


ACK and will add the following

@@ -709,7 +709,10 @@ lxcBlkioDeviceWalkCallback(const char *name, 
virConfValuePtr value, void *data)
 if (STRNEQ(name, lxc.cgroup.blkio.device_weight) || !value-str)
 return 0;
 
-if ((!(parts = lxcStringSplit(value-str))  (!parts[0] || !parts[1]))) {
+if (!(parts = lxcStringSplit(value-str)))
+return -1;
+
+if (!parts[0] || !parts[1]) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(invalid blkio.device_weight value: '%s'),
value-str);


-- 
|: 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 v3 19/21] LXC from native: convert blkio throttle config

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:17PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c   | 68 
 ++
  tests/lxcconf2xmldata/lxcconf2xml-blkiotune.config |  4 ++
  tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml|  4 ++
  3 files changed, 65 insertions(+), 11 deletions(-)

ACK

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 v3 17/21] LXC from native: map vlan network type

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:15PM +0100, Cédric Bosdonnat wrote:
 The problem with VLAN is that the user still has to manually create the
 vlan interface on the host. Then the generated configuration will use
 it as a nerwork hostdev device. So the generated configurations of the
 following two fragments are equivalent (see rhbz#1059637).
 
 lxc.network.type = phys
 lxc.network.link = eth0.5
 
 lxc.network.type = vlan
 lxc.network.link = eth0
 lxc.network.vlan.id = 5
 ---
  src/lxc/lxc_native.c   | 28 
 ++
  .../lxcconf2xmldata/lxcconf2xml-vlannetwork.config | 12 ++
  tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml  | 26 
  tests/lxcconf2xmltest.c|  1 +
  4 files changed, 62 insertions(+), 5 deletions(-)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml

ACK

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] [PATCHv2 2/6] event: server RPC protocol tweaks for domain lifecycle events

2014-02-12 Thread Eric Blake
On 02/12/2014 03:23 AM, Daniel P. Berrange wrote:
 On Tue, Feb 11, 2014 at 02:07:06PM -0700, Eric Blake wrote:
 On 02/11/2014 08:57 AM, Daniel P. Berrange wrote:
 On Wed, Jan 29, 2014 at 10:49:22AM -0700, Eric Blake wrote:
 This patch adds some new RPC call numbers, but for ease of review,
 they sit idle until a later patch adds the client counterpart to
 drive the new RPCs.  Also for ease of review, I limited this patch


 ACK


 Thanks for the review.

  /**
   * @generate: none
   * @priority: high
 - * @acl: none
 + * @acl: connect:read
   */
  REMOTE_PROC_CONNECT_DOMAIN_EVENT_CALLBACK_DEREGISTER_ANY = 317,
 
 ACK to this - it makes it clearer i think

Series now pushed with this in.

-- 
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 v3 09/21] LXC from native: convert macvlan network configuration

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:07PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c   | 47 
 +-
  .../lxcconf2xml-macvlannetwork.config  | 13 ++
  .../lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml | 26 
  tests/lxcconf2xmltest.c|  1 +
  4 files changed, 77 insertions(+), 10 deletions(-)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml

ACK

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 v3 17/21] LXC from native: map vlan network type

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:15PM +0100, Cédric Bosdonnat wrote:
 The problem with VLAN is that the user still has to manually create the
 vlan interface on the host. Then the generated configuration will use
 it as a nerwork hostdev device. So the generated configurations of the
 following two fragments are equivalent (see rhbz#1059637).
 
 lxc.network.type = phys
 lxc.network.link = eth0.5
 
 lxc.network.type = vlan
 lxc.network.link = eth0
 lxc.network.vlan.id = 5
 ---
  src/lxc/lxc_native.c   | 28 
 ++
  .../lxcconf2xmldata/lxcconf2xml-vlannetwork.config | 12 ++
  tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml  | 26 
  tests/lxcconf2xmltest.c|  1 +
  4 files changed, 62 insertions(+), 5 deletions(-)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml
 
 diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
 index 9a16523..8d8c50a 100644
 --- a/src/lxc/lxc_native.c
 +++ b/src/lxc/lxc_native.c
 @@ -411,22 +411,33 @@ lxcAddNetworkDefinition(virDomainDefPtr def,
  const char *link,
  const char *mac,
  const char *flag,
 -const char *macvlanmode)
 +const char *macvlanmode,
 +const char *vlanid)
  {
  virDomainNetDefPtr net = NULL;
  virDomainHostdevDefPtr hostdev = NULL;
 +bool isPhys, isVlan = false;
  
  if ((type == NULL) || STREQ(type, empty) || STREQ(type, ) ||
  STREQ(type, none))
  return 0;
  
 -if (type != NULL  STREQ(type, phys)) {
 +isPhys = STREQ(type, phys);
 +isVlan = STREQ(type, vlan);
 +if (type != NULL  (isPhys || isVlan)) {
  if (!link ||
  !(hostdev = 
 lxcCreateHostdevDef(VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
  VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
  link)))
  goto error;
  
 +/* This still requires the user to manually setup the vlan interface
 + * on the host */
 +if (isVlan  !(link  vlanid 
 +virAsprintf(hostdev-source.caps.u.net.iface,
 +%s.%s, link, vlanid) = 0))
 +goto error;

Small memory leak as this virAsprintf overwrites memory allocated
by lxcCreateHostdevDef. Will fx that when pushing

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 v3 00/21] LXC configuration conversion

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:09:58PM +0100, Cédric Bosdonnat wrote:
 Here is an updated version of the patch set fixing comments from Daniel.
 It also adds 3 commits:
   * One adding conversion for the newly supported blkio throttle tune
 in lxc driver.
   * One actually using the state of the veth network device in lxc
 driver.
   * One adding the ability to give major:minor numbers instead of a path
 for blkio tune devices.
 
 The last one is a way to address Daniel's comment on the /dev/block/...
 paths.
 
 Cédric Bosdonnat (21):
   Improve virConf parse to handle LXC config format
   LXC driver: started implementing connectDomainXMLFromNative
   LXC from native: import rootfs
   LXC from native: migrate fstab and lxc.mount.entry
   LXC from native: implement no network conversion
   LXC from native: migrate veth network configuration
   LXC from native: convert phys network types to net hostdev devices
   LXC from native: convert lxc.tty to console devices
   LXC from native: convert macvlan network configuration
   LXC from native: convert lxc.id_map into idmap
   LXC from native: migrate memory tuning
   LXC from native: map lxc.cgroup.cpu.*
   LXC from native: map lxc.cgroup.cpuset.*
   LXC from native: add lxc.cgroup.blkio.* mapping
   LXC from native: map lxc.arch to /domain/os/type@arch
   LXC from native: map block filesystems
   LXC from native: map vlan network type
   LXC: added some doc on domxml-from-native with mention of limitations
   LXC from native: convert blkio throttle config
   lxc: honor link state=up for veth interfaces
   blkiotune: allow node major='' minor=''/ in place of path
 
  .gitignore |   1 +
  docs/drvlxc.html.in|  34 +-
  docs/formatdomain.html.in  |  10 +-
  po/POTFILES.in |   1 +
  src/Makefile.am|   1 +
  src/conf/domain_conf.c |  45 +-
  src/conf/domain_conf.h |   2 +
  src/libvirt_private.syms   |   1 +
  src/lxc/lxc_cgroup.c   |   5 +
  src/lxc/lxc_container.c|   2 +-
  src/lxc/lxc_container.h|   2 +
  src/lxc/lxc_driver.c   |  41 +
  src/lxc/lxc_native.c   | 952 
 +
  src/lxc/lxc_native.h   |  32 +
  src/lxc/lxc_process.c  |   5 +
  src/qemu/qemu_cgroup.c |   5 +
  src/qemu/qemu_driver.c |  10 +
  src/util/vircgroup.c   | 126 ++-
  src/util/vircgroup.h   |  10 +
  src/util/virconf.c |  46 +-
  src/util/virconf.h |  10 +
  tests/Makefile.am  |   7 +-
  tests/lxcconf2xmldata/lxcconf2xml-blkiotune.config |  11 +
  tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml|  39 +
  .../lxcconf2xmldata/lxcconf2xml-cpusettune.config  |   6 +
  tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml   |  27 +
  tests/lxcconf2xmldata/lxcconf2xml-cputune.config   |   7 +
  tests/lxcconf2xmldata/lxcconf2xml-cputune.xml  |  29 +
  tests/lxcconf2xmldata/lxcconf2xml-fstab.config |  37 +
  tests/lxcconf2xmldata/lxcconf2xml-idmap.config |   5 +
  tests/lxcconf2xmldata/lxcconf2xml-idmap.xml|  28 +
  .../lxcconf2xml-macvlannetwork.config  |  13 +
  .../lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml |  26 +
  tests/lxcconf2xmldata/lxcconf2xml-memtune.config   |  10 +
  tests/lxcconf2xmldata/lxcconf2xml-memtune.xml  |  29 +
  .../lxcconf2xmldata/lxcconf2xml-nonenetwork.config |   4 +
  tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml  |  21 +
  tests/lxcconf2xmldata/lxcconf2xml-nonetwork.config |   3 +
  tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml|  24 +
  .../lxcconf2xmldata/lxcconf2xml-physnetwork.config |   6 +
  tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml  |  26 +
  tests/lxcconf2xmldata/lxcconf2xml-simple.config|  41 +
  tests/lxcconf2xmldata/lxcconf2xml-simple.xml   |  41 +
  .../lxcconf2xmldata/lxcconf2xml-vlannetwork.config |  12 +
  tests/lxcconf2xmldata/lxcconf2xml-vlannetwork.xml  |  26 +
  tests/lxcconf2xmltest.c| 131 +++
  46 files changed, 1865 insertions(+), 85 deletions(-)
  create mode 100644 src/lxc/lxc_native.c
  create mode 100644 src/lxc/lxc_native.h
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-blkiotune.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-blkiotune.xml
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cpusettune.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cpusettune.xml
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cputune.config
  create mode 100644 

Re: [libvirt] [PATCH v3 10/21] LXC from native: convert lxc.id_map into idmap

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:08PM +0100, Cédric Bosdonnat wrote:
 ---
  src/lxc/lxc_native.c   | 44 
 ++
  tests/lxcconf2xmldata/lxcconf2xml-idmap.config |  5 +++
  tests/lxcconf2xmldata/lxcconf2xml-idmap.xml| 28 
  tests/lxcconf2xmltest.c|  1 +
  4 files changed, 78 insertions(+)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-idmap.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-idmap.xml
 
 diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
 index b413e42..dd706f8 100644
 --- a/src/lxc/lxc_native.c
 +++ b/src/lxc/lxc_native.c

 +static int
 +lxcIdmapWalkCallback(const char *name, virConfValuePtr value, void *data)
 +{
 +virDomainDefPtr def = data;
 +virDomainIdMapEntryPtr idmap = NULL;
 +char type;
 +unsigned long start, target, count;
 +
 +if (STRNEQ(name, lxc.id_map) || !value-str)
 +return 0;
 +
 +if (sscanf(value-str, %c %lu %lu %lu, type,
 +   target, start, count) != 4) {
 +virReportError(VIR_ERR_INTERNAL_ERROR, _(invalid lxc.id_map: '%s'),
 +   value-str);
 +return -1;
 +}
 +
 +if (VIR_ALLOC(idmap)  0)
 +return -1;

This alloc is bogus since we assign to 'idmap' a few lines later.
I'm removing it when i push.

 +
 +if (type == 'u') {
 +if (VIR_EXPAND_N(def-idmap.uidmap, def-idmap.nuidmap, 1)  0)
 +return -1;
 +idmap = def-idmap.uidmap[def-idmap.nuidmap - 1];
 +} else if (type == 'g') {
 +if (VIR_EXPAND_N(def-idmap.gidmap, def-idmap.ngidmap, 1)  0)
 +return -1;
 +idmap = def-idmap.gidmap[def-idmap.ngidmap - 1];
 +} else {
 +return -1;
 +}
 +
 +idmap-start = start;
 +idmap-target = target;
 +idmap-count = count;
 +
 +return 0;
 +}


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 v3 05/21] LXC from native: implement no network conversion

2014-02-12 Thread Daniel P. Berrange
On Wed, Feb 05, 2014 at 03:10:03PM +0100, Cédric Bosdonnat wrote:
 If no network configuration is provided, LXC only provides the loopback
 interface. To match this, we need to use the privnet feature. LXC will
 also define a 'none' network type in its 1.0.0 version that fits
 libvirt LXC driver's default.
 ---
  src/lxc/lxc_native.c   | 55 
 ++
  .../lxcconf2xmldata/lxcconf2xml-nonenetwork.config |  4 ++
  tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml  | 21 +
  tests/lxcconf2xmldata/lxcconf2xml-nonetwork.config |  3 ++
  tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml| 24 ++
  tests/lxcconf2xmltest.c|  2 +
  6 files changed, 109 insertions(+)
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-nonenetwork.xml
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-nonetwork.config
  create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-nonetwork.xml


ACK

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 v4 1/3] network_conf: Expose virNetworkDefFormatInternal

2014-02-12 Thread Laine Stump
On 02/12/2014 07:07 PM, Michal Privoznik wrote:
 In the next patch I'm going to need the network format function that
 takes virBuffer as argument. However, slightly change of name is more
 appropriate then: virNetworkDefFormatBuf to match the rest of functions
 that format an object to buffer.

 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/conf/network_conf.c  | 12 ++--
  src/conf/network_conf.h  |  3 +++
  src/libvirt_private.syms |  1 +
  3 files changed, 10 insertions(+), 6 deletions(-)

 diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
 index dd3fa19..8b6236d 100644
 --- a/src/conf/network_conf.c
 +++ b/src/conf/network_conf.c
 @@ -2593,10 +2593,10 @@ cleanup:
  return ret;
  }
  
 -static int
 -virNetworkDefFormatInternal(virBufferPtr buf,
 -const virNetworkDef *def,
 -unsigned int flags)
 +int
 +virNetworkDefFormatBuf(virBufferPtr buf,
 +   const virNetworkDef *def,
 +   unsigned int flags)
  {
  const unsigned char *uuid;
  char uuidstr[VIR_UUID_STRING_BUFLEN];
 @@ -2763,7 +2763,7 @@ virNetworkDefFormat(const virNetworkDef *def,
  {
  virBuffer buf = VIR_BUFFER_INITIALIZER;
  
 -if (virNetworkDefFormatInternal(buf, def, flags)  0)
 +if (virNetworkDefFormatBuf(buf, def, flags)  0)
  goto error;
  
  if (virBufferError(buf))
 @@ -2794,7 +2794,7 @@ virNetworkObjFormat(virNetworkObjPtr net,
  VIR_FREE(class_id);
  
  virBufferAdjustIndent(buf, 2);
 -if (virNetworkDefFormatInternal(buf, net-def, flags)  0)
 +if (virNetworkDefFormatBuf(buf, net-def, flags)  0)
  goto error;
  
  virBufferAdjustIndent(buf, -2);
 diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
 index b84762a..47124ce 100644
 --- a/src/conf/network_conf.h
 +++ b/src/conf/network_conf.h
 @@ -338,6 +338,9 @@ virNetworkDefPtr virNetworkDefParseFile(const char 
 *filename);
  virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml,
  xmlNodePtr root);
  char *virNetworkDefFormat(const virNetworkDef *def, unsigned int flags);
 +int virNetworkDefFormatBuf(virBufferPtr buf,
 +   const virNetworkDef *def,
 +   unsigned int flags);
  
  static inline const char *
  virNetworkDefForwardIf(const virNetworkDef *def, size_t n)
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 2c9536a..b554f11 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -504,6 +504,7 @@ virNetworkConfigChangeSetup;
  virNetworkConfigFile;
  virNetworkDefCopy;
  virNetworkDefFormat;
 +virNetworkDefFormatBuf;
  virNetworkDefFree;
  virNetworkDefGetIpByIndex;
  virNetworkDefParseFile;

ACK.

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


Re: [libvirt] [PATCHv5 2/7] storage: Implement file storage APIs in the default storage driver

2014-02-12 Thread Eric Blake
On 02/11/2014 09:26 AM, Peter Krempa wrote:
 Implement the APIs added by the previous patch in the default storage
 driver used by qemu.
 ---
 
 Notes:
 Version 5:
 - adapt to error reporting change
 
  src/check-aclrules.pl |  1 +
  src/storage/storage_backend.c | 37 +
  src/storage/storage_backend.h | 43 
  src/storage/storage_driver.c  | 95 
 +++
  4 files changed, 176 insertions(+)

I tend to agree with Dan's comment on patch 1 (that is, exposing these
directly in storage_driver.c instead of making it go through the
driver.h interface), which may have some fallout on this patch.  That
said, I'll review this one.

 +++ b/src/storage/storage_backend.c
 @@ -121,6 +121,12 @@ static virStorageBackendPtr backends[] = {
  NULL
  };
 
 +
 +static virStorageFileBackendPtr fileBackends[] = {
 +NULL
 +};

At first I wondered why an empty array, then I realized - this is the
framework, then later patches add in new backends.  Okay.


 +
 +struct _virStorageFileBackend {
 +int type;
 +int protocol;
 +
 +virStorageFileBackendInit backendInit;
 +virStorageFileBackendDeinit backendDeinit;
 +
 +virStorageFileBackendCreate storageFileCreate;
 +virStorageFileBackendUnlink storageFileUnlink;
 +virStorageFileBackendStat   storageFileStat;

No need to copy existing bad examples; please document which of these
callbacks (if any) must be non-NULL, or explicitly state that all
callbacks are optional.  (When I first added the gluster backend, I had
a hard time figuring out which callbacks storage_driver expected to be
able to use).  It would also be nice to document the contract placed on
implementations of each callback (such as when a callback should return
-1 vs -2, or whether errno must be set on error), at the point where you
declare typedefs for each callback signature.

This patch looks okay in isolation for driving the new callbacks, once
later patches implement them.  ACK with comments added.

-- 
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 v4 2/3] network: Introduce network hooks

2014-02-12 Thread Laine Stump
On 02/12/2014 07:07 PM, Michal Privoznik wrote:
 There might be some use cases, where user wants to prepare the host or
 its environment prior to starting a network and do some cleanup after
 the network has been shut down. Consider all the functionality that
 libvirt doesn't currently have as an example what a hook script can
 possibly do.

 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  docs/hooks.html.in  | 98 
 ++---
  src/lxc/lxc_driver.c|  4 +-
  src/lxc/lxc_process.c   |  6 +--
  src/network/bridge_driver.c | 91 +++--
  src/network/bridge_driver.h | 19 +
  src/qemu/qemu_command.c |  2 +-
  src/qemu/qemu_hotplug.c | 14 +++
  src/qemu/qemu_process.c |  4 +-
  src/util/virhook.c  | 13 +-
  src/util/virhook.h  | 11 +
  10 files changed, 220 insertions(+), 42 deletions(-)

 diff --git a/docs/hooks.html.in b/docs/hooks.html.in
 index f0f692b..29995f7 100644
 --- a/docs/hooks.html.in
 +++ b/docs/hooks.html.in
 @@ -13,9 +13,15 @@
 actions occur:/p
  ul
liThe libvirt daemon starts, stops, or reloads its
 -  configurationbr/br//li
 -  liA QEMU guest is started or stoppedbr/br//li
 -  liAn LXC guest is started or stoppedbr/br//li
 +  configuration
 +  (span class=sincesince 0.8.0/span)br/br//li
 +  liA QEMU guest is started or stopped
 + (span class=sincesince 0.8.0/span)br/br//li
 + liAn LXC guest is started or stopped
 + (span class=sincesince 0.8.0/span)br/br//li
 +  liA network is started or stopped or an interface is
 +  un-/plugged from/to the network
 +  (span class=sincesince 1.2.2/span)br/br//li
  /ul
  
  h2a name=locationScript location/a/h2
 @@ -44,6 +50,9 @@
Executed when a QEMU guest is started, stopped, or 
 migratedbr/br//li
licode/etc/libvirt/hooks/lxc/codebr /br/
Executed when an LXC guest is started or stopped/li
 +  licode/etc/libvirt/hooks/network/codebr/br/
 +  Executed when a network is started or stopped or an
 +  interface is un-/plugged from/to the network/li


further down you use plugged/unplugged, which I think looks better
(you'll then want to change from/to to to/from as well, or just use
to for simplicity)


  /ul
  br/
  
 @@ -66,6 +75,39 @@
 XML description for the domain on their stdin. This includes items
 such the UUID of the domain and its storage information, and is
 intended to provide all the libvirt information the script needs./p
 +pFor all cases, stdin of the network hook script is provided with the
 +   full XML description of the network status in the following form:/p
 +
 +prelt;hookDatagt;
 +  lt;networkgt;
 + lt;namegt;$network_namelt;/namegt;
 + lt;uuidgt;----lt;/uuidgt;
 + ...
 +  lt;/networkgt;
 +lt;/hookDatagt;/pre
 +
 +pIn the case of an interface
 +   being plugged/unplugged to the network, the network XML will be 
 followed
 +   with the full XML description of the domain containing the interface
 +   that is being plugged/unplugged:/p
 +
 +prelt;hookDatagt;
 +  lt;networkgt;
 + lt;namegt;$network_namelt;/namegt;
 + lt;uuidgt;----lt;/uuidgt;


Do we use ... for uuid examples anywhere else? The few examples I
found in the existing documentation were actual valid uuids.


 + ...
 +  lt;/networkgt;
 +  lt;domain type='$domain_type' id='$domain_id'gt;
 + lt;namegt;$domain_namelt;/namegt;
 + lt;uuidgt;----lt;/uuidgt;
 + ...
 +  lt;/domaingt;
 +lt;/hookDatagt;/pre
 +
 +pPlease note that this approach is different to other cases such as


different from other cases


 +   codedaemon/code, codeqemu/code or codelxc/code hook 
 scripts,
 +   because two XMLs may be passed here, while in the other cases only a 
 single
 +   XML is passed./p
  
  pThe command line arguments take this approach:/p
  ol
 @@ -181,25 +223,51 @@
  pre/etc/libvirt/hooks/lxc guest_name reconnect begin -/pre
/li
  /ul
 +
 +h5a name=network/etc/libvirt/hooks/network/a/h5
 +ul
 +  lispan class=sinceSince 1.2.2/span, before a network is 
 started,
 +this script is called as:br/
 +  pre/etc/libvirt/hooks/network network_name start begin 
 -/pre/li
 +  liAfter the network is started, up and; running, the script is
 +called as:br/
 +  pre/etc/libvirt/hooks/network network_name started begin 
 -/pre/li
 +  liWhen a network is shut down, this script is called as:br/
 +  pre/etc/libvirt/hooks/network network_name stopped end 
 -/pre/li
 +  liLater, when network is started and there's an interface from a
 +domain to be plugged into the network (plugged may not be the correct
 +

Re: [libvirt] [libvirt-users] Help? Running into problems with migrateToURI2() and virDomainDefCheckABIStability()

2014-02-12 Thread Cole Robinson
On 02/12/2014 01:03 PM, Chris Friesen wrote:
 On 02/11/2014 04:45 PM, Cole Robinson wrote:
 On 02/10/2014 06:46 PM, Chris Friesen wrote:
 Hi,

 We've run into a problem with libvirt 1.1.2 and are looking for some 
 comments
 on whether this is a bug or design intent.

 We're trying to use migrateToURI() but we're using a few things (numatune,
 vcpu mask, etc.) that may need adjustment during the migration.  We found 
 that
 migrateToURI2() mostly works if we use XML created by copying the domain XML
 from the running instance and modifying the appropriate sections.

 The problem that we're seeing is that the serial console checking in
 libvirt/src/conf/domain_conf.c::virDomainDefCheckABIStability() is failing
 even though we haven't touched the serial console XML:
 
 I think we will have to see the XML your passing before and after edit to
 figure out what's going wrong. Also, showing all the arguments you are
 invoking the migration APIs with.
 
 
 Okay, this is going to be a long message.  :)
 
 We're calling it as:
 
 dom.migrateToURI2(duri, muri, xml_str, logical_sum, None, 
 CONF.live_migration_bandwidth)
 
 Here are the supplied arguments:
 duri = u'qemu+tcp://compute-0/system'
 muri = u'tcp://compute-0'
 flaglist = ['VIR_MIGRATE_UNDEFINE_SOURCE', 'VIR_MIGRATE_PEER2PEER', 
 'VIR_MIGRATE_LIVE']
 logical_sum = 19,  (logical OR of flaglist)
 CONF.live_migration_bandwidth = 0
 
 Grabbing original XML prior to migration:
 
 dom_xml = etree.fromstring(dom.XMLDesc(0))
 xml_str = etree.tostring(dom_xml)
 
 xml_str (BEFORE) =
 domain type=qemu id=2
   nameinstance-0006/name
   uuid2e13869b-edc0-40dc-92e3-1f2ffde60cce/uuid
   dpdk
 process type=secondary/
 file prefix=vs/
 cpu list=0/
 memory channels=4/
   /dpdk
   memory unit=KiB262144/memory
   currentMemory unit=KiB262144/currentMemory
   memoryBacking
 hugepages/
   /memoryBacking
   vcpu placement=static cpuset=1-22/vcpu
   cputune
 vcpupin vcpu=0 cpuset=1/
 vcpupin vcpu=1 cpuset=2/
 emulatorpin cpuset=1-2/
   /cputune
   numatune
 memory mode=preferred nodeset=0/
   /numatune
   sysinfo type=smbios
 system
   entry name=manufacturerOpenStack Foundation/entry
   entry name=productOpenStack Nova/entry
   entry name=version2013.2.2/entry
   entry name=serial771a1b10-d2f7-4ebb-b21e-4040560732f5/entry
   entry name=uuid2e13869b-edc0-40dc-92e3-1f2ffde60cce/entry
 /system
   /sysinfo
   os
 type arch=x86_64 machine=pc-i440fx-1.4hvm/type
 boot dev=hd/
 smbios mode=sysinfo/
   /os
   features
 acpi/
 apic/
   /features
   clock offset=utc/
   on_poweroffdestroy/on_poweroff
   on_rebootrestart/on_reboot
   on_crashdestroy/on_crash
   devices
 emulator/usr/bin/qemu-system-x86_64/emulator
 disk type=file device=disk
   driver name=qemu type=qcow2 cache=none/
   source 
 file=/etc/nova/instances/2e13869b-edc0-40dc-92e3-1f2ffde60cce/disk/
   target dev=vda bus=virtio/
   alias name=virtio-disk0/
   address type=pci domain=0x bus=0x00 slot=0x05 
 function=0x0/
 /disk
 controller type=usb index=0
   alias name=usb0/
   address type=pci domain=0x bus=0x00 slot=0x01 
 function=0x2/
 /controller
 controller type=pci index=0 model=pci-root
   alias name=pci.0/
 /controller
 interface type=vswitch
   mac address=fa:16:3e:fb:34:6b/
   source network=4db95d31-64f1-4f10-9138-5fe68c0d77ac/
   target dev=7bc76b0e-b12a-4153-8ce8-d3d145c51e6f/
   model type=e1000/
   alias name=net0/
   address type=pci domain=0x bus=0x00 slot=0x03 
 function=0x0/
 /interface
 interface type=vswitch
   mac address=fa:16:3e:d5:b9:50/
   source network=8512742c-af3e-4787-b2d8-b0b9ab160297/
   target dev=33ab1061-7fa4-4250-99a4-dd7eb4029aa1/
   model type=e1000/
   alias name=net1/
   address type=pci domain=0x bus=0x00 slot=0x04 
 function=0x0/
 /interface
 serial type=file
   source 
 path=/etc/nova/instances/2e13869b-edc0-40dc-92e3-1f2ffde60cce/console.log/
   target port=0/
   alias name=serial0/
 /serial
 serial type=pty
   source path=/dev/pts/1/
   target port=1/
   alias name=serial1/
 /serial
 console type=file
   source 
 path=/etc/nova/instances/2e13869b-edc0-40dc-92e3-1f2ffde60cce/console.log/
   target type=serial port=0/
   alias name=serial0/
 /console
 input type=tablet bus=usb
   alias name=input0/
 /input
 input type=mouse bus=ps2/
 graphics type=vnc port=5900 autoport=yes listen=0.0.0.0 
 keymap=en-us
   listen type=address address=0.0.0.0/
 /graphics
 video
   model type=cirrus vram=9216 heads=1/
   alias name=video0/
   address type=pci domain=0x bus=0x00 slot=0x02 
 function=0x0/
 /video
 memballoon model=virtio
   alias name=balloon0/
   address type=pci domain=0x bus=0x00 slot=0x06 
 function=0x0/
 /memballoon
   /devices
 

Re: [libvirt] [PATCHv5 4/7] storage: Add storage file backends for gluster

2014-02-12 Thread Eric Blake
On 02/11/2014 09:26 AM, Peter Krempa wrote:
 Implement storage backend functions to deal with gluster volumes and
 implement the stat and unlink backend APIs.
 ---
 

 +
 +static void
 +virStorageFileBackendGlusterDeinit(virStorageFilePtr file)
 +{
 +VIR_DEBUG(deinitializing gluster storage file %p(%s@%s),
 +  file, file-path, file-hosts[0].name);

A bit unusual to list file@host, instead of host/file, but not a
show-stopper.


 +static int
 +virStorageFileBackendGlusterInit(virStorageFilePtr file)
 +{
 +virStorageFileBackendPrivPtr backPriv = file-priv;
 +virStorageFileBackendGlusterPrivPtr priv = NULL;
 +virDomainDiskHostDefPtr host = (file-hosts[0]);
 +const char *hostname = host-name;
 +int port = 0;
 +
 +VIR_DEBUG(initializing gluster storage file %p(%s@%s),
 +  file, file-path, hostname);
 +
 +if (VIR_ALLOC(priv)  0)
 +return -1;
 +
 +if (VIR_STRDUP(priv-volname, file-path)  0)
 +goto error;
 +
 +if (!(priv-path  = strchr(priv-volname, '/'))) {
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(invalid path of gluster volume: '%s'),
 +   file-path);
 +goto error;
 +}

This looks like a lot of shared code; any chance we use a common routine
as the basis of both this and virStorageBackendGlusterOpen()?

But what you have works, so ACK (a refactor can be a followup).

-- 
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] [PATCHv5 3/7] storage: add file functions for local and block files

2014-02-12 Thread Eric Blake
On 02/11/2014 09:26 AM, Peter Krempa wrote:
 Implement the stat and unlink function for file volumes and stat
 for block volumes using the regular system calls.

s/block//

 ---
 

 +static int
 +virStorageFileBackendFileUnlink(virStorageFilePtr file)
 +{
 +int ret;
 +
 +ret = unlink(file-path);
 +/* preserve errno */
 +
 +VIR_DEBUG(removing storage file %p(%s): ret=%d,errno=%d,

Maybe a space after the comma, but not the end of the world in a debug
message.

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

Re: [libvirt] [PATCHv5 5/7] qemu: Switch snapshot deletion to the new API functions

2014-02-12 Thread Eric Blake
On 02/11/2014 09:26 AM, Peter Krempa wrote:
 Use the new storage driver APIs to delete snapshot backing files in case
 of failure instead of directly relying on unlink. This will help us in
 the future when we will be adding network based storage without local
 representation in the host.
 ---
 
 Notes:
 Version 5:
 - no change, wasn't reviewed yet

Finally getting a review :)

 
  src/qemu/qemu_driver.c | 32 +++-
  1 file changed, 23 insertions(+), 9 deletions(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 94844df..b94382d 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -94,6 +94,7 @@
  #include virstring.h
  #include viraccessapicheck.h
  #include viraccessapicheckqemu.h
 +#include libvirt_private.h

Based on Dan's comment on patch 1, it may be sufficient to just include
storage_driver.h instead, which may affect the function names you call.
 But the conversion looks sane - instead of calling direct file system
syscalls, we now call polymorphic storage calls, and let the storage
driver manage whether it is a syscall or a gluster library call (or any
future other backends that also add in their driver).

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

Re: [libvirt] [PATCHv5 6/7] qemu: snapshot: Use new APIs to detect presence of existing storage files

2014-02-12 Thread Eric Blake
On 02/11/2014 09:26 AM, Peter Krempa wrote:
 Use the new storage driver based stat api to detect exiting files just
 as we did with local files.
 ---
 
 Notes:
 Version 5:
 - new in sereis
 
  src/qemu/qemu_driver.c | 59 
 +++---
  1 file changed, 27 insertions(+), 32 deletions(-)
 

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

Re: [libvirt] [PATCHv5 7/7] qemu: snapshot: Add support for external active snapshots on gluster

2014-02-12 Thread Eric Blake
On 02/11/2014 09:26 AM, Peter Krempa wrote:
 Add support for gluster backed images as sources for snapshots in the
 qemu driver. This will also simplify adding further network backed
 volumes as sources for snapshot in case qemu will support them.
 ---
 

Looks a bit confusing the number of variables we have to track as we
swap between original and new, then fallback or commit.  But I didn't
spot anything obviously wrong in how you did it.  I suspect that if we
ever convert over to having domain XML track full backing chain
semantics, we will have a lot to rewrite in this area of code to take
advantage of that, but the future shouldn't hold up incremental progress
in the present.  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

Re: [libvirt] libvirt default network

2014-02-12 Thread Eric Blake
On 02/12/2014 07:29 AM, Laine Stump wrote:
 On 02/12/2014 03:54 PM, Eric Blake wrote:
 On 02/12/2014 04:41 AM, Thierry Parmentelat wrote:
 Hi again
 [Please don't top-post on technical lists]

 So we did 2 changes in the specfile that are described below
 This has gone through all our nightlies and all, so that works for us

 I’m sorry that I can’t seem to get git send-email to work on my mac 
 (complains about missing perl modules ?!?)
 Even if you can't get send-email working, at least using 'git
 format-patch' and attaching the patch files to email is easier for
 exposing your patches than making people chase URLs.

 Fortunately the changes I did are so simple, I hope you can use the 
 following material

 http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=a0e03e6894d8e8486e79531967b92b83d6d59b86

 http://git.onelab.eu/?p=libvirt.git;a=commitdiff;h=7f0c4d07b5faac3f0fb07cd8240f5ae0e1063560
 Thanks!  Not the easiest to get to, but I managed to pull these two
 commits into a single patch,
 
 No need to put them in a single patch - they are for two separate issues.

Good point.  ACK to 7f0c4d so I pushed it; and I will shortly post a
revised version for the other issue.

-- 
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] rpm: create libvirt-wireshark sub-package

2014-02-12 Thread Eric Blake
On 02/05/2014 02:51 AM, Daniel P. Berrange wrote:
 On Tue, Feb 04, 2014 at 03:15:56PM -0700, Eric Blake wrote:
 On Fedora 20, with wireshark-devel installed, 'make rpm' failed
 due to installed but unpackaged files related to wireshark.  As
 F20 is already released without wireshark, I chose to add a new
 sub-package that is enabled only for F21 and later.  Furthermore,
 all existing wireshark plugins belong to the wireshark package,
 so I got to invent behavior of how the first third-part wireshark
 module will behave.

 * libvirt.spec.in (with_wireshark): Add new conditional.
 * configure.ac (ws-plugindir): Improve wording.

 Signed-off-by: Eric Blake ebl...@redhat.com
 ---

 I was tempted to push this as a build-breaker fix for 'make rpm',
 but rpms are close enough to black magic that I decided a review
 is safer, after all.  Tested with both F20 (not built) and F21
 (new subpackage built just fine), using normal build of all
 subpackages and also a build with '%client_only 1' in ~/.rpmmacros
 to ensure that it indeed works in a client-only setup.

  configure.ac|  4 ++--
  libvirt.spec.in | 34 ++
  2 files changed, 36 insertions(+), 2 deletions(-)
 
 ACK

Hmm, should the generic 'libvirt' metapackage also Require: the
libvirt-wireshark subpackage, so that we keep the status quo that
installing just libvirt pulls in all subpackages?

-- 
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] spec: add missing dep of libvirt-daemon-config-network

2014-02-12 Thread Eric Blake
From: Thierry Parmentelat thierry.parmente...@inria.fr

When building modules, libvirt-daemon-config-network requires
libvirt-daemon-driver-network to ensure the 'default' network
is setup properly

Signed-off-by: Eric Blake ebl...@redhat.com
---

v2: make dep dependent on whether subpackage is created

 libvirt.spec.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 4d804e6..d3e6048 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -720,6 +720,9 @@ Summary: Default configuration files for the libvirtd daemon
 Group: Development/Libraries

 Requires: libvirt-daemon = %{version}-%{release}
+%if %{with_driver_modules}
+Requires: libvirt-daemon-driver-network = %{version}-%{release}
+%endif

 %description daemon-config-network
 Default configuration files for setting up NAT based networking
-- 
1.8.5.3

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


[libvirt] [PATCH] spec: require libvirt-wireshark from libvirt metapackage

2014-02-12 Thread Eric Blake
In general, the 'libvirt' metapackage should pull in all subpackages.
Fix this for the wireshark subpackage created in commit f9ada9f.

* libvirt.spec.in (Requires): Add dependency.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 libvirt.spec.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index d3e6048..2d57c71 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -428,6 +428,9 @@ Requires: libvirt-daemon-driver-storage = 
%{version}-%{release}
 Requires: libvirt-daemon-driver-network = %{version}-%{release}
 Requires: libvirt-daemon-driver-nodedev = %{version}-%{release}
 %endif
+%if %{with_wireshark}
+Requires: libvirt-wireshark = %{version}-%{release}
+%endif
 %endif
 Requires: libvirt-client = %{version}-%{release}

-- 
1.8.5.3

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


Re: [libvirt] [PATCH 1/5] qmp: rename query_option_descs() to get_param_infolist()

2014-02-12 Thread Eric Blake
On 01/27/2014 08:53 PM, Amos Kong wrote:
 Signed-off-by: Amos Kong ak...@redhat.com
 ---
  util/qemu-config.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Eric Blake ebl...@redhat.com

-- 
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 2/5] introduce two marcos to dump the options info

2014-02-12 Thread Eric Blake
On 01/27/2014 08:53 PM, Amos Kong wrote:

s/marcos/macros/ in the subject line

 We will use the marocs to generate two tables, which contain

s/marocs/macros/

(wow, two different ways to mis-spell the word)

 the option name and argument information.
 
 Signed-off-by: Amos Kong ak...@redhat.com
 ---
  qemu-options-wrapper.h | 18 ++
  1 file changed, 18 insertions(+)
 

Reviewed-by: Eric Blake ebl...@redhat.com

although I'd probably squash this with the patch that actually defines
QEMU_OPTIONS_GENERATE_{NAME,HASARG}, as this patch is useless on its own.

-- 
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 3/5] query-command-line-options: query all the options in qemu-options.hx

2014-02-12 Thread Eric Blake
On 01/27/2014 08:53 PM, Amos Kong wrote:
 vm_config_groups[] contain the options which have parameter, but some
 legcy options haven't been added to vm_config_groups[].

s/legcy/legacy/

 
 All the options can be found in qemu-options.hx, this patch used two
 new marcos to generate two tables, we can check if the option name is

s/marcos/macros/

 valid and if the option has arguments.
 
 This patch also try to visit all the options in option_names[], then
 we won't lost the legacy options that weren't added to vm_config_groups[].

s/lost/lose/

 The options have no arguments will also be returned (eg: -enable-fips)

s/options/options that/

 
 Signed-off-by: Amos Kong ak...@redhat.com
 ---
  util/qemu-config.c | 41 +++--
  1 file changed, 35 insertions(+), 6 deletions(-)
 

-- 
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 4/5] introduce QEMU_OPTIONS_GENERATE_HELPMSG

2014-02-12 Thread Eric Blake
On 01/27/2014 08:53 PM, Amos Kong wrote:
 This patch introduced a new maroc, it will be used to dump the help
 messages of all the options.
 
 Signed-off-by: Amos Kong ak...@redhat.com
 ---
  qemu-options-wrapper.h | 9 +
  1 file changed, 9 insertions(+)

Again, this patch is useless on its own, I'd squash it with the first
client that defines QEMU_OPTIONS_GENERATE_HELPMSG.

-- 
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] qemu driver: sync guest time via qemu-guest-agent when domain is resumed

2014-02-12 Thread Marcelo Tosatti
On Wed, Feb 12, 2014 at 10:22:11AM +, Daniel P. Berrange wrote:
 I agree that this should be a completely separate command, not
 merely a flag to the Resume API.  The reason is that you cannot
 do sensible error reporting if you overload this in one API
 call.  ie consider that resuming the CPUs succeeds, but syncing
 time fails. If you return success to the caller you are lieing
 about the result of time sync. If you return error to the caller
 you are lieing about the result of resuming the CPUs.
 
 If there is a separate API to invoke then the caller can clearly
 see which operation succeeded vs failed.

Well then just require a new guest agent command. No need
for a separate command.

Going from resume to resume-and-sync versus

Going from resume to resume; send-guest-agent-command 

Is not very different is it? In both cases qemu guest agent channel 
must be operational.

I'll go write a virsh alias and virt-manager patch.

(BTW, error reporting would be in the libvirt logs,
GuestAgentError with all the details why time-sync failed).

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


Re: [libvirt] [PATCH] qemu driver: sync guest time via qemu-guest-agent when domain is resumed

2014-02-12 Thread Marcelo Tosatti
On Wed, Feb 12, 2014 at 06:45:28PM -0200, Marcelo Tosatti wrote:
 On Wed, Feb 12, 2014 at 10:22:11AM +, Daniel P. Berrange wrote:
  I agree that this should be a completely separate command, not
  merely a flag to the Resume API.  The reason is that you cannot
  do sensible error reporting if you overload this in one API
  call.  ie consider that resuming the CPUs succeeds, but syncing
  time fails. If you return success to the caller you are lieing
  about the result of time sync. If you return error to the caller
  you are lieing about the result of resuming the CPUs.
  
  If there is a separate API to invoke then the caller can clearly
  see which operation succeeded vs failed.
 
 Well then just require a new guest agent command. No need
 for a separate command.
 
 Going from resume to resume-and-sync versus
 
 Going from resume to resume; send-guest-agent-command 
 
 Is not very different is it? In both cases qemu guest agent channel 
 must be operational.

Well doh which fails to hide QEMU. Ok then, resume-and-sync-time
command.

 I'll go write a virsh alias and virt-manager patch.
 
 (BTW, error reporting would be in the libvirt logs,
 GuestAgentError with all the details why time-sync failed).

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


Re: [libvirt] [Qemu-devel] [PATCH 5/5] query-command-line-options: return help message for legacy options

2014-02-12 Thread Eric Blake
On 02/11/2014 05:19 AM, Markus Armbruster wrote:
 [Note cc: Eric]
 
 Amos Kong ak...@redhat.com writes:
 
 Some legacy options that have arguments weren't added to
 vm_config_groups[], so query-command-line-options returns a
 NULL parameters infolist. This patch try to return help message
 for this kind of legacy options.

 Example:
  {
  helpmsg: \-vnc displaystart a VNC server on display\\n\,
  parameters: [
  ],
  option: vnc
  },
 
 Do we have prospective users for this feature?

Libvirt probably won't care about helpmsg other than the fact that it
gets logged as part of the QMP reply, and the log is more legible if
human-readable text is included.  I don't care if you add it or omit it;
the REAL change here is...

  ##
  { 'type': 'CommandLineOptionInfo',
 -  'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'] } }
 +  'data': { 'option': 'str',
 +'*parameters': ['CommandLineParameterInfo'],

changing parameters from mandatory to optional, and omitting it when
supplying information on an arg-less option.  And that is what libvirt
wants, for learning about things like -enable-fips.

 +'*helpmsg': 'str' } }
  
  ##
  # @query-command-line-options:
 
 Aha, here's the schema change missing in PATCH 3/5.

Indeed; please resubmit the series so that every patch builds on its own.

 
 The schema needs to cover these kinds of options:
 
 1. No argument
 
{ 'option': OPT-NAME }

This is newly allowed by your schema change.

 
 2. QemuOpts argument
 
 2a. with known parameters (QemuOptsList member desc[] not empty)
 
{ 'option': OPT-NAME,
  'parameters': [ { 'name': PAR-NAME, 'type': PAR-TYPE }, ... ] }

Existing before your patch.

 
 2b. with unknown parameters (desc[] empty)
 
{ 'option': OPT-NAME, parameters: [] }

Existing before your patch.

 
 3. Other argument
 
{ 'option': OPT-NAME, ? }
 
 This patch adds 3.  We need to decide what we want there.
 
 Any particular reason why we have to invent something new, and can't
 simply fold it into 2b?

Or even into 1?  That is, the presence of 'parameters' is a witness of
whether a flag is boolean (-enable-fips) or takes arguments (-device);
then the length of the 'parameters' array is a witness of whether we
know all option arguments (modern code) or have unknown parameters
(older options that have not yet been converted to modern form).

 
 Note that I completely left out help strings, both on the option and on
 the parameter level.  Both for brevity of presentation, and because I'd
 like to see a use before we add them.

Libvirt won't be hurt if you don't present help strings.

-- 
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/5] query-command-line-options: return help message for legacy options

2014-02-12 Thread Eric Blake
On 01/27/2014 08:53 PM, Amos Kong wrote:
 Some legacy options that have arguments weren't added to
 vm_config_groups[], so query-command-line-options returns a
 NULL parameters infolist. This patch try to return help message
 for this kind of legacy options.
 
 Example:
  {
  helpmsg: \-vnc displaystart a VNC server on display\\n\,
  parameters: [
  ],
  option: vnc
  },
 
 Signed-off-by: Amos Kong ak...@redhat.com
 ---
  qapi-schema.json   | 5 -
  util/qemu-config.c | 3 +++
  2 files changed, 7 insertions(+), 1 deletion(-)
 
 diff --git a/qapi-schema.json b/qapi-schema.json
 index 05ced9d..b3e6f46 100644
 --- a/qapi-schema.json
 +++ b/qapi-schema.json
 @@ -3943,13 +3943,16 @@
  # Details about a command line option, including its list of parameter 
 details
  #
  # @option: option name
 +# @helpmsg: help message for legacy options

Missing #optional and (since 2.0) designations

  #
  # @parameters: an array of @CommandLineParameterInfo

Might be worth documenting #optional since 2.0 (we don't yet have good
precedent for documenting when a formerly mandatory field became optional).

Groan.  This is an output struct.  On input structs, changing a
mandatory field to optional is safe - old callers will always supply the
field.  But on output structs, changing a mandatory field to optional is
backwards-incompatible.  Old callers may be blindly expecting the field,
and crash when it is not present.

Your approach needs to be modified.

  #
  # Since 1.5
  ##
  { 'type': 'CommandLineOptionInfo',
 -  'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'] } }
 +  'data': { 'option': 'str',
 +'*parameters': ['CommandLineParameterInfo'],
 +'*helpmsg': 'str' } }

I suggest:


# @parameters: array of @CommandLineParameterInfo, possibly empty
# @argument: @optional present if the @parameters array is empty. If
#true, then the option takes unspecified arguments, if
#false, then the option is merely a boolean flag (since 2.0)

{ 'type': 'CommandLineOptionInfo',
'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'],
  '*argument': 'bool' } }

used as:
[
  { option:enable-fips, parameters:[], argument:false },
  { option:smbios, parameters:[], argument:true },
  { option:iscsi, paramters:[ ... ] },
  ...
]

which adequately differentiates between -iscsi taking arguments (but
where we haven't yet hooked it in to introspect those arguments) vs.
-enable-fips being boolean.

-- 
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] qemu driver: sync guest time via qemu-guest-agent when domain is resumed

2014-02-12 Thread Eric Blake
On 02/12/2014 01:45 PM, Marcelo Tosatti wrote:
 On Wed, Feb 12, 2014 at 10:22:11AM +, Daniel P. Berrange wrote:
 I agree that this should be a completely separate command, not
 merely a flag to the Resume API.  The reason is that you cannot
 do sensible error reporting if you overload this in one API
 call.  ie consider that resuming the CPUs succeeds, but syncing
 time fails. If you return success to the caller you are lieing
 about the result of time sync. If you return error to the caller
 you are lieing about the result of resuming the CPUs.

 If there is a separate API to invoke then the caller can clearly
 see which operation succeeded vs failed.
 
 Well then just require a new guest agent command. No need
 for a separate command.
 
 Going from resume to resume-and-sync versus
 
 Going from resume to resume; send-guest-agent-command 
 
 Is not very different is it? In both cases qemu guest agent channel 
 must be operational.

You're confusing things.  'resume' is a command to qemu.  'sync' is a
command to the guest agent.  The guest agent can't respond unless the
guest is running.  If 'resume' fails, the guest is not running.  But if
'sync' fails, the guest is necessarily in a different state than when
you started.  Having to report failure after the guest ran an
indeterminate number of instructions is not good.

The guest agent is not in charge of resume, therefore adding a guest
agent command to do resume-and-sync is not possible.

And qemu is not in charge of talking to the guest, only the agent is.
So adding a new qemu command to resume-and-sync is not possible.

We really are talking about two disparate operations by two different
actors, and where failure of the second action cannot be rolled back to
the state of the first action.

 
 I'll go write a virsh alias and virt-manager patch.
 
 (BTW, error reporting would be in the libvirt logs,
 GuestAgentError with all the details why time-sync failed).
 
 
 

-- 
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] qemu driver: sync guest time via qemu-guest-agent when domain is resumed

2014-02-12 Thread Eric Blake
On 02/12/2014 02:05 PM, Eric Blake wrote:

 

 I'll go write a virsh alias and virt-manager patch.

A single virsh command that makes multiple API calls under the hood is
just fine - on partial failure, it can make it quite clear which of the
steps failed.  I have no problem with creating a 'virsh resume --sync'
that issues both the resume API call and the sync agent API call.  But
that doesn't change the fact that the libvirt.so API still needs to be
separate.

-- 
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] spec: require libvirt-wireshark from libvirt metapackage

2014-02-12 Thread Martin Kletzander
On Wed, Feb 12, 2014 at 01:28:43PM -0700, Eric Blake wrote:
 In general, the 'libvirt' metapackage should pull in all subpackages.
 Fix this for the wireshark subpackage created in commit f9ada9f.

 * libvirt.spec.in (Requires): Add dependency.

 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
  libvirt.spec.in | 3 +++
  1 file changed, 3 insertions(+)

 diff --git a/libvirt.spec.in b/libvirt.spec.in
 index d3e6048..2d57c71 100644
 --- a/libvirt.spec.in
 +++ b/libvirt.spec.in
 @@ -428,6 +428,9 @@ Requires: libvirt-daemon-driver-storage = 
 %{version}-%{release}
  Requires: libvirt-daemon-driver-network = %{version}-%{release}
  Requires: libvirt-daemon-driver-nodedev = %{version}-%{release}
  %endif
 +%if %{with_wireshark}
 +Requires: libvirt-wireshark = %{version}-%{release}
 +%endif
  %endif
  Requires: libvirt-client = %{version}-%{release}

 --
 1.8.5.3

ACK,

Martin


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

Re: [libvirt] [PATCHv2] spec: add missing dep of libvirt-daemon-config-network

2014-02-12 Thread Martin Kletzander
On Wed, Feb 12, 2014 at 01:25:11PM -0700, Eric Blake wrote:
 From: Thierry Parmentelat thierry.parmente...@inria.fr

 When building modules, libvirt-daemon-config-network requires
 libvirt-daemon-driver-network to ensure the 'default' network
 is setup properly

 Signed-off-by: Eric Blake ebl...@redhat.com
 ---

 v2: make dep dependent on whether subpackage is created

  libvirt.spec.in | 3 +++
  1 file changed, 3 insertions(+)

 diff --git a/libvirt.spec.in b/libvirt.spec.in
 index 4d804e6..d3e6048 100644
 --- a/libvirt.spec.in
 +++ b/libvirt.spec.in
 @@ -720,6 +720,9 @@ Summary: Default configuration files for the libvirtd 
 daemon
  Group: Development/Libraries

  Requires: libvirt-daemon = %{version}-%{release}
 +%if %{with_driver_modules}
 +Requires: libvirt-daemon-driver-network = %{version}-%{release}
 +%endif

  %description daemon-config-network
  Default configuration files for setting up NAT based networking
 --
 1.8.5.3


ACK.

Shouldn't the same be done with the daemon-config-nwfilter package?
ACK for that too if you want to add it to this patch (or separately).

Martin


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

Re: [libvirt] [PATCHv2] spec: add missing dep of libvirt-daemon-config-network

2014-02-12 Thread Eric Blake
On 02/12/2014 02:26 PM, Martin Kletzander wrote:
 On Wed, Feb 12, 2014 at 01:25:11PM -0700, Eric Blake wrote:
 From: Thierry Parmentelat thierry.parmente...@inria.fr

 When building modules, libvirt-daemon-config-network requires
 libvirt-daemon-driver-network to ensure the 'default' network
 is setup properly

 Signed-off-by: Eric Blake ebl...@redhat.com
 ---

 v2: make dep dependent on whether subpackage is created


 
 ACK.

Thanks; pushed.

 
 Shouldn't the same be done with the daemon-config-nwfilter package?
 ACK for that too if you want to add it to this patch (or separately).

Separate patch; coming up later once I do more testing.

-- 
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] spec: require libvirt-wireshark from libvirt metapackage

2014-02-12 Thread Eric Blake
On 02/12/2014 02:20 PM, Martin Kletzander wrote:
 On Wed, Feb 12, 2014 at 01:28:43PM -0700, Eric Blake wrote:
 In general, the 'libvirt' metapackage should pull in all subpackages.
 Fix this for the wireshark subpackage created in commit f9ada9f.

 * libvirt.spec.in (Requires): Add dependency.


 
 ACK,

Pushed.


-- 
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] spec: add missing dep of libvirt-daemon-config-nwfilter

2014-02-12 Thread Eric Blake
Similar to cf76c4b, if modules are used, then nwfilter configuration
requires the nwfilter driver module.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 libvirt.spec.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 2d57c71..2b44c21 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -737,6 +737,9 @@ Summary: Network filter configuration files for the 
libvirtd daemon
 Group: Development/Libraries

 Requires: libvirt-daemon = %{version}-%{release}
+%if %{with_driver_modules}
+Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release}
+%endif

 %description daemon-config-nwfilter
 Network filter configuration files for cleaning guest traffic
-- 
1.8.5.3

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


[libvirt] [PATCH] bandwidth: Adjust documentation

2014-02-12 Thread John Ferlan
Recent autotest/virt-test testing on f20 discovered an anomaly in how
the bandwidth options are documented and used. This was discovered due
to a bug fix in the /sbin/tc utility found in iproute-3.11.0.1 (on f20)
in which overflow was actually caught and returned as an error. The fix
was first introduced in iproute-3.10 (search on iproute2 commit 'a303853e').

The autotest/virt-test test for virsh domiftune was attempting to send
the largest unsigned integer value (4294967295) for maximum value
testing. The libvirt xml implementation was designed to manage values
in kibibytes (eg, 1024 blocks of bytes), thus when this value was
passed to /sbin/tc, it (now) properly rejected the 4294967295kbps value.

Investigation of the problem discovered that formatdomain.html.in and
formatnetwork.html.in described the elements and property types slightly
differently, although they use the same code - virNetDevBandwidthParseRate()
(shared by portgroups, domains, and networks xml parsers). Rather than
have the descriptions in two places, this patch will combine and reword
the description under formatnetwork.html.in and have formatdomain.html.in
link to that description.

This documentation faux pas was continued into the virsh man page where
the bandwidth description for both 'attach-interface' and 'domiftune'
did not indicate the scope of each value, thus leading to the test using
largest unsigned integer value, which ultimately will be wrong.

Additionally, modified the virnetdevbandwidth.h to use kibibytes instead
of kbytes (to be more clear).

Signed-off-by: John Ferlan jfer...@redhat.com
---
 docs/formatdomain.html.in | 35 +++
 docs/formatnetwork.html.in| 81 ---
 src/util/virnetdevbandwidth.h |  8 ++---
 tools/virsh.pod   | 10 --
 4 files changed, 77 insertions(+), 57 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 4660983..ea1a97b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3750,37 +3750,10 @@ qemu-kvm -net nic,model=? /dev/null
 
 p
   This part of interface XML provides setting quality of service. Incoming
-  and outgoing traffic can be shaped independently. The
-  codebandwidth/code element can have at most one codeinbound/code
-  and at most one codeoutbound/code child elements. Leaving any of 
these
-  children element out result in no QoS applied on that traffic direction.
-  So, when you want to shape only domain's incoming traffic, use
-  codeinbound/code only, and vice versa. Each of these elements have 
one
-  mandatory attribute codeaverage/code (or codefloor/code as
-  described below). codeaverage/code specifies average bit rate on
-  the interface being shaped. Then there are two optional attributes:
-  codepeak/code, which specifies maximum rate at which interface can 
send
-  data, and codeburst/code, amount of bytes that can be burst at
-  codepeak/code speed. Accepted values for attributes are integer
-  numbers. The units for codeaverage/code and codepeak/code 
attributes
-  are kilobytes per second, and for the codeburst/code just kilobytes.
-  Note the limitation of implementation: the codepeak/code attribute in
-  codeoutbound/code element is ignored (as linux ingress filters don't
-  know it yet). span class=sinceSince 0.9.4/span The 
codeinbound/code can
-  optionally have codefloor/code attribute. This is there for
-  guaranteeing minimal throughput for shaped interfaces. This, however,
-  requires that all traffic goes through one point where QoS decisions can
-  take place. That's why this attribute works only for virtual networks for
-  now (that is codelt;interface type='network'/gt;/code with a
-  forward type of route, nat, or no forward at all). Moreover, the
-  virtual network the interface is connected to is required to have at 
least
-  inbound QoS set (codeaverage/code at least). Moreover, with
-  codefloor/code attribute users don't need to specify
-  codeaverage/code. However, codepeak/code and codeburst/code
-  attributes still require codeaverage/code. Currently, linux kernel
-  doesn't allow ingress qdiscs to have any classes therefore
-  codefloor/code can be applied only on codeinbound/code and not
-  codeoutbound/code. span class=sinceSince 1.0.1/span
+  and outgoing traffic can be shaped independently.
+  The codebandwidth/code element and its child elements are described
+  in the a href=formatnetwork.html#elementQoSQoS/a section of
+  the Network XML.
 /p
 
 h5a name=elementVlanTagSetting VLAN tag (on supported network types 
only)/a/h5
diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index 1ca1bec..de71ebf 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -412,40 +412,81 @@
 
   p
 The codelt;bandwidthgt;/code 

Re: [libvirt] [PATCH] bandwidth: Adjust documentation

2014-02-12 Thread John Ferlan

I meant to add something under the -- in my email, but the fingers were
too quick... Although the commit message is quite lengthy - it does
hopefully give enough context to decisions made.

There was some consideration to perform kibibyte range checking in
libvirt; however, if the underlying utility (/sbin/tc) or kernel ever
changes that could be restrictive.

I also considered changing virsh to accept the 'bps' value and convert
it prior to calling the save routine; however, the problem with that is
once someone sets value they should expect the following get on the
value to be what was set, not what was actually set using integer
arithmetic. Thus changing the documentation to indicate to use kibibytes
seemed the most reasonable option. Unfortunately we do leave some bytes
on the table in the maximum range.

Changing the code to use bps would be really invasive. Although I
suppose the XML could change to default to kbps and accept bps,
gbps, or tbps as the unit of measurement. I didn't see a
need/requirement for that (yet) though.

Finally after just switching between multiple screens and thinking about
everything I've read, the kbps used in virNetDevBandwidthSet() is
according to the /sbin/tc code 'kilobytes per second' and not kibps or
'kibibytes per second'. So now, I'm beginning to think perhaps another
patch is needed to change the kbps to kibps. But if I change that,
then it almost seems reasonable to convert to bps on that call.
H...  But doing that still requires us to read existing xml files
that would have values saved as (purportedly) kibibytes.  I'll see what
feedback I get this and go from there...

John

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


[libvirt] [PATCH V2 09/13] libxl: use job functions in libxlDomainCoreDump

2014-02-12 Thread Jim Fehlig
Dumping a domain's core can take considerable time.  Use the
recently added job functions and unlock the virDomainObj while
dumping core.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---

V2: Check libxlDomainObjEndJob() return value

 src/libxl/libxl_driver.c | 38 +++---
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 839754d..9c42e28 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2063,6 +2063,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, 
unsigned int flags)
 libxlDomainObjPrivatePtr priv;
 virDomainObjPtr vm;
 virObjectEventPtr event = NULL;
+bool remove_dom = false;
 bool paused = false;
 int ret = -1;
 
@@ -2074,9 +2075,12 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, 
unsigned int flags)
 if (virDomainCoreDumpEnsureACL(dom-conn, vm-def)  0)
 goto cleanup;
 
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY)  0)
+goto cleanup;
+
 if (!virDomainObjIsActive(vm)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s, _(Domain is not 
running));
-goto cleanup;
+goto endjob;
 }
 
 priv = vm-privateData;
@@ -2088,39 +2092,42 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, 
unsigned int flags)
_(Before dumping core, failed to suspend domain 
'%d'
   with libxenlight),
dom-id);
-goto cleanup;
+goto endjob;
 }
 virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_DUMP);
 paused = true;
 }
 
-if (libxl_domain_core_dump(priv-ctx, dom-id, to, NULL) != 0) {
+/* Unlock virDomainObj while dumping core */
+virObjectUnlock(vm);
+ret = libxl_domain_core_dump(priv-ctx, dom-id, to, NULL);
+virObjectLock(vm);
+if (ret != 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to dump core of domain '%d' with 
libxenlight),
dom-id);
-goto cleanup_unpause;
+ret = -1;
+goto unpause;
 }
 
 if (flags  VIR_DUMP_CRASH) {
 if (libxl_domain_destroy(priv-ctx, dom-id, NULL)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to destroy domain '%d'), dom-id);
-goto cleanup_unpause;
+goto unpause;
 }
 
 libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED);
 event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
  VIR_DOMAIN_EVENT_STOPPED_CRASHED);
-if (!vm-persistent) {
-virDomainObjListRemove(driver-domains, vm);
-vm = NULL;
-}
+if (!vm-persistent)
+remove_dom = true;
 }
 
 ret = 0;
 
-cleanup_unpause:
-if (vm  virDomainObjIsActive(vm)  paused) {
+unpause:
+if (virDomainObjIsActive(vm)  paused) {
 if (libxl_domain_unpause(priv-ctx, dom-id) != 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(After dumping core, failed to resume domain '%d' 
with
@@ -2130,7 +2137,16 @@ cleanup_unpause:
  VIR_DOMAIN_RUNNING_UNPAUSED);
 }
 }
+
+endjob:
+if (!libxlDomainObjEndJob(driver, vm))
+vm = NULL;
+
 cleanup:
+if (remove_dom  vm) {
+virDomainObjListRemove(driver-domains, vm);
+vm = NULL;
+}
 if (vm)
 virObjectUnlock(vm);
 if (event)
-- 
1.8.1.4

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


[libvirt] [PATCH V2 05/13] libxl: use job functions in libxlDomainSetMemoryFlags

2014-02-12 Thread Jim Fehlig
Large balloon operation can be time consuming.  Use the recently
added job functions and unlock the virDomainObj while ballooning.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---

V2: Check libxlDomainObjEndJob() return value

 src/libxl/libxl_driver.c | 33 +++--
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ecd1b8d..87771f7 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1632,6 +1632,9 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long 
newmem,
 if (virDomainSetMemoryFlagsEnsureACL(dom-conn, vm-def, flags)  0)
 goto cleanup;
 
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY)  0)
+goto cleanup;
+
 isActive = virDomainObjIsActive(vm);
 
 if (flags == VIR_DOMAIN_MEM_CURRENT) {
@@ -1650,19 +1653,19 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned 
long newmem,
 if (!isActive  (flags  VIR_DOMAIN_MEM_LIVE)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(cannot set memory on an inactive domain));
-goto cleanup;
+goto endjob;
 }
 
 if (flags  VIR_DOMAIN_MEM_CONFIG) {
 if (!vm-persistent) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(cannot change persistent config of a transient 
domain));
-goto cleanup;
+goto endjob;
 }
 if (!(persistentDef = virDomainObjGetPersistentDef(cfg-caps,
driver-xmlopt,
vm)))
-goto cleanup;
+goto endjob;
 }
 
 if (flags  VIR_DOMAIN_MEM_MAXIMUM) {
@@ -1674,7 +1677,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long 
newmem,
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to set maximum memory for domain '%d'
   with libxenlight), dom-id);
-goto cleanup;
+goto endjob;
 }
 }
 
@@ -1685,7 +1688,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long 
newmem,
 if (persistentDef-mem.cur_balloon  newmem)
 persistentDef-mem.cur_balloon = newmem;
 ret = virDomainSaveConfig(cfg-configDir, persistentDef);
-goto cleanup;
+goto endjob;
 }
 
 } else {
@@ -1694,17 +1697,23 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned 
long newmem,
 if (newmem  vm-def-mem.max_balloon) {
 virReportError(VIR_ERR_INVALID_ARG, %s,
_(cannot set memory higher than max memory));
-goto cleanup;
+goto endjob;
 }
 
 if (flags  VIR_DOMAIN_MEM_LIVE) {
+int res;
+
 priv = vm-privateData;
-if (libxl_set_memory_target(priv-ctx, dom-id, newmem, 0,
-/* force */ 1)  0) {
+/* Unlock virDomainObj while ballooning memory */
+virObjectUnlock(vm);
+res = libxl_set_memory_target(priv-ctx, dom-id, newmem, 0,
+  /* force */ 1);
+virObjectLock(vm);
+if (res  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to set memory for domain '%d'
   with libxenlight), dom-id);
-goto cleanup;
+goto endjob;
 }
 }
 
@@ -1712,12 +1721,16 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned 
long newmem,
 sa_assert(persistentDef);
 persistentDef-mem.cur_balloon = newmem;
 ret = virDomainSaveConfig(cfg-configDir, persistentDef);
-goto cleanup;
+goto endjob;
 }
 }
 
 ret = 0;
 
+endjob:
+if (!libxlDomainObjEndJob(driver, vm))
+vm = NULL;
+
 cleanup:
 if (vm)
 virObjectUnlock(vm);
-- 
1.8.1.4

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


[libvirt] [PATCH V2 01/13] libxl: always set vm id to -1 on shutdown

2014-02-12 Thread Jim Fehlig
Once a domain has reached the shutdown state, set its ID to -1.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---
 src/libxl/libxl_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 8e4242a..0cd0ec8 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -266,15 +266,15 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
 char *file;
 size_t i;
 
+vm-def-id = -1;
+
 if (priv-deathW) {
 libxl_evdisable_domain_death(priv-ctx, priv-deathW);
 priv-deathW = NULL;
 }
 
-if (vm-persistent) {
-vm-def-id = -1;
+if (vm-persistent)
 virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
-}
 
 if (virAtomicIntDecAndTest(driver-nactive)  driver-inhibitCallback)
 driver-inhibitCallback(false, driver-inhibitOpaque);
-- 
1.8.1.4

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


[libvirt] [PATCH V2 07/13] libxl: use job functions when cleaning up a domain

2014-02-12 Thread Jim Fehlig
When explicitly destroying a domain (libxlDomainDestroyFlags), or
handling an out-of-band domain shutdown event, cleanup the domain
in the context of a job.  Introduce libxlVmCleanupJob to wrap
libxlVmCleanup in a job block.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---

V2:
  Introduce libxlVmCleanupJob and call it when needing libxlVmCleanup
  in a job block.
  Check libxlDomainObjEndJob() return value

 src/libxl/libxl_driver.c | 38 ++
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 36fc9f5..0c2c1d7 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -317,6 +317,26 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
 }
 
 /*
+ * Cleanup function for domain that has reached shutoff state.
+ * Executed in the context of a job.
+ *
+ * virDomainObjPtr should be locked on invocation
+ * Returns true if references remain on virDomainObjPtr, false otherwise.
+ */
+static bool
+libxlVmCleanupJob(libxlDriverPrivatePtr driver,
+  virDomainObjPtr vm,
+  virDomainShutoffReason reason)
+{
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_DESTROY)  0)
+return true;
+
+libxlVmCleanup(driver, vm, reason);
+
+return libxlDomainObjEndJob(driver, vm);
+}
+
+/*
  * Handle previously registered event notification from libxenlight.
  *
  * Note: Xen 4.3 removed the const from the event handler signature.
@@ -364,10 +384,11 @@ libxlDomainShutdownThread(void *opaque)
 reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN;
 }
 libxl_domain_destroy(ctx, vm-def-id, NULL);
-libxlVmCleanup(driver, vm, reason);
-if (!vm-persistent) {
-virDomainObjListRemove(driver-domains, vm);
-vm = NULL;
+if (libxlVmCleanupJob(driver, vm, reason)) {
+if (!vm-persistent) {
+virDomainObjListRemove(driver-domains, vm);
+vm = NULL;
+}
 }
 break;
 case LIBXL_SHUTDOWN_REASON_REBOOT:
@@ -1561,10 +1582,11 @@ libxlDomainDestroyFlags(virDomainPtr dom,
 goto cleanup;
 }
 
-libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
-if (!vm-persistent) {
-virDomainObjListRemove(driver-domains, vm);
-vm = NULL;
+if (libxlVmCleanupJob(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED)) {
+if (!vm-persistent) {
+virDomainObjListRemove(driver-domains, vm);
+vm = NULL;
+}
 }
 
 ret = 0;
-- 
1.8.1.4

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


[libvirt] [PATCH V2 11/13] libxl: use job functions in device attach and detach functions

2014-02-12 Thread Jim Fehlig
These operations aren't necessarily time consuming, but need to
wait in the queue of modify jobs.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---

V2: Check libxlDomainObjEndJob() return value

 src/libxl/libxl_driver.c | 42 --
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 1f3ea51..f19d551 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3423,6 +3423,9 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char 
*xml,
 if (virDomainAttachDeviceFlagsEnsureACL(dom-conn, vm-def, flags)  0)
 goto cleanup;
 
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY)  0)
+goto cleanup;
+
 if (virDomainObjIsActive(vm)) {
 if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
 flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
@@ -3433,14 +3436,14 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const 
char *xml,
 if (flags  VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
 virReportError(VIR_ERR_OPERATION_INVALID,
%s, _(Domain is not running));
-goto cleanup;
+goto endjob;
 }
 }
 
 if ((flags  VIR_DOMAIN_DEVICE_MODIFY_CONFIG)  !vm-persistent) {
  virReportError(VIR_ERR_OPERATION_INVALID,
 %s, _(cannot modify device on transient domain));
- goto cleanup;
+ goto endjob;
 }
 
 priv = vm-privateData;
@@ -3449,15 +3452,15 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const 
char *xml,
 if (!(dev = virDomainDeviceDefParse(xml, vm-def,
 cfg-caps, driver-xmlopt,
 VIR_DOMAIN_XML_INACTIVE)))
-goto cleanup;
+goto endjob;
 
 /* Make a copy for updated domain. */
 if (!(vmdef = virDomainObjCopyPersistentDef(vm, cfg-caps,
 driver-xmlopt)))
-goto cleanup;
+goto endjob;
 
 if ((ret = libxlDomainAttachDeviceConfig(vmdef, dev))  0)
-goto cleanup;
+goto endjob;
 } else {
 ret = 0;
 }
@@ -3468,10 +3471,10 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const 
char *xml,
 if (!(dev = virDomainDeviceDefParse(xml, vm-def,
 cfg-caps, driver-xmlopt,
 VIR_DOMAIN_XML_INACTIVE)))
-goto cleanup;
+goto endjob;
 
 if ((ret = libxlDomainAttachDeviceLive(priv, vm, dev))  0)
-goto cleanup;
+goto endjob;
 
 /*
  * update domain status forcibly because the domain status may be
@@ -3490,6 +3493,10 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const 
char *xml,
 }
 }
 
+endjob:
+if (!libxlDomainObjEndJob(driver, vm))
+vm = NULL;
+
 cleanup:
 virDomainDefFree(vmdef);
 virDomainDeviceDefFree(dev);
@@ -3527,6 +3534,9 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char 
*xml,
 if (virDomainDetachDeviceFlagsEnsureACL(dom-conn, vm-def, flags)  0)
 goto cleanup;
 
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY)  0)
+goto cleanup;
+
 if (virDomainObjIsActive(vm)) {
 if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
 flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
@@ -3537,14 +3547,14 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const 
char *xml,
 if (flags  VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
 virReportError(VIR_ERR_OPERATION_INVALID,
%s, _(Domain is not running));
-goto cleanup;
+goto endjob;
 }
 }
 
 if ((flags  VIR_DOMAIN_DEVICE_MODIFY_CONFIG)  !vm-persistent) {
  virReportError(VIR_ERR_OPERATION_INVALID,
 %s, _(cannot modify device on transient domain));
- goto cleanup;
+ goto endjob;
 }
 
 priv = vm-privateData;
@@ -3553,15 +3563,15 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const 
char *xml,
 if (!(dev = virDomainDeviceDefParse(xml, vm-def,
 cfg-caps, driver-xmlopt,
 VIR_DOMAIN_XML_INACTIVE)))
-goto cleanup;
+goto endjob;
 
 /* Make a copy for updated domain. */
 if (!(vmdef = virDomainObjCopyPersistentDef(vm, cfg-caps,
 driver-xmlopt)))
-goto cleanup;
+goto endjob;
 
 if ((ret = libxlDomainDetachDeviceConfig(vmdef, dev))  0)
-goto cleanup;
+goto endjob;
 } else {
 ret = 0;
 }
@@ -3572,10 +3582,10 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const 
char *xml,
 if (!(dev = virDomainDeviceDefParse(xml, vm-def,

[libvirt] [PATCH V2 00/13] libxl: add job support

2014-02-12 Thread Jim Fehlig
This patch series adds job support to the libxl driver, using a simplified
version of the technique used in the qemu driver.  One benefit of this
series is no longer blocking get operations during long running modify
operations.  E.g. with these patches 'vish dominfo dom' will work while
'virsh save dom ...' is in progress.

The first two patches are new to the series, following review of V1.
Patch1 changes the cleanup logic to unconditionally set dom id to -1 on
domain shutdown.  Patch2 removes libxlVmReap, giving callers more control
over domain destruction/cleanup.

The remaining patches are updates to V1 based on Daniel's and Michal's
comments.

Jim Fehlig (13):
  libxl: always set vm id to -1 on shutdown
  libxl: remove libxlVmReap function
  libxl: Add job support to libxl driver
  libxl: use job functions in libxlVmStart
  libxl: use job functions in libxlDomainSetMemoryFlags
  libxl: use job functions in libxlDomain{Suspend,Resume}
  libxl: use job functions when cleaning up a domain
  libxl: use job functions in domain save operations
  libxl: use job functions in libxlDomainCoreDump
  libxl: use job functions in vcpu set and pin functions
  libxl: use job functions in device attach and detach functions
  libxl: use job functions in libxlDomainSetAutostart
  libxl: use job functions in libxlDomainSetSchedulerParametersFlags

 src/libxl/libxl_domain.c | 128 +++
 src/libxl/libxl_domain.h |  38 +
 src/libxl/libxl_driver.c | 405 +++
 3 files changed, 432 insertions(+), 139 deletions(-)

-- 
1.8.1.4

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


[libvirt] [PATCH V2 02/13] libxl: remove libxlVmReap function

2014-02-12 Thread Jim Fehlig
This function, which only has five call sites, simply calls
libxl_domain_destroy and libxlVmCleanup.  Call those functions
directly at the call sites, allowing more control over how a
domain is destroyed and cleaned up.  This patch maintains the
existing semantic, leaving changes to a subsequent patch.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---
 src/libxl/libxl_driver.c | 39 ---
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 0cd0ec8..342ad3b 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -317,28 +317,6 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
 }
 
 /*
- * Reap a domain from libxenlight.
- *
- * virDomainObjPtr should be locked on invocation
- */
-static int
-libxlVmReap(libxlDriverPrivatePtr driver,
-virDomainObjPtr vm,
-virDomainShutoffReason reason)
-{
-libxlDomainObjPrivatePtr priv = vm-privateData;
-
-if (libxl_domain_destroy(priv-ctx, vm-def-id, NULL)  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(Unable to cleanup domain %d), vm-def-id);
-return -1;
-}
-
-libxlVmCleanup(driver, vm, reason);
-return 0;
-}
-
-/*
  * Handle previously registered event notification from libxenlight.
  *
  * Note: Xen 4.3 removed the const from the event handler signature.
@@ -385,14 +363,16 @@ libxlDomainShutdownThread(void *opaque)
 } else {
 reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN;
 }
-libxlVmReap(driver, vm, reason);
+libxl_domain_destroy(ctx, vm-def-id, NULL);
+libxlVmCleanup(driver, vm, reason);
 if (!vm-persistent) {
 virDomainObjListRemove(driver-domains, vm);
 vm = NULL;
 }
 break;
 case LIBXL_SHUTDOWN_REASON_REBOOT:
-libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
+libxl_domain_destroy(ctx, vm-def-id, NULL);
+libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
 libxlVmStart(driver, vm, 0, -1);
 break;
 default:
@@ -1533,6 +1513,7 @@ libxlDomainDestroyFlags(virDomainPtr dom,
 virDomainObjPtr vm;
 int ret = -1;
 virObjectEventPtr event = NULL;
+libxlDomainObjPrivatePtr priv;
 
 virCheckFlags(0, -1);
 
@@ -1551,12 +1532,14 @@ libxlDomainDestroyFlags(virDomainPtr dom,
 event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
  VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
 
-if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED) != 0) {
+priv = vm-privateData;
+if (libxl_domain_destroy(priv-ctx, vm-def-id, NULL)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to destroy domain '%d'), dom-id);
 goto cleanup;
 }
 
+libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
 if (!vm-persistent) {
 virDomainObjListRemove(driver-domains, vm);
 vm = NULL;
@@ -1872,12 +1855,13 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, 
virDomainObjPtr vm,
 event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
  VIR_DOMAIN_EVENT_STOPPED_SAVED);
 
-if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED) != 0) {
+if (libxl_domain_destroy(priv-ctx, vm-def-id, NULL)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to destroy domain '%d'), vm-def-id);
 goto cleanup;
 }
 
+libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED);
 vm-hasManagedSave = true;
 ret = 0;
 
@@ -2045,12 +2029,13 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, 
unsigned int flags)
 }
 
 if (flags  VIR_DUMP_CRASH) {
-if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED) != 0) {
+if (libxl_domain_destroy(priv-ctx, dom-id, NULL)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to destroy domain '%d'), dom-id);
 goto cleanup_unpause;
 }
 
+libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED);
 event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
  VIR_DOMAIN_EVENT_STOPPED_CRASHED);
 if (!vm-persistent) {
-- 
1.8.1.4

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


[libvirt] [PATCH V2 03/13] libxl: Add job support to libxl driver

2014-02-12 Thread Jim Fehlig
Follows the pattern used in the QEMU driver for managing multiple,
simultaneous jobs within the driver.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---

V2:
  Add ATTRIBUTE_RETURN_CHECK to libxlDomainObjEndJob

 src/libxl/libxl_domain.c | 128 +++
 src/libxl/libxl_domain.h |  38 ++
 2 files changed, 166 insertions(+)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index eb2e50e..fdc4661 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -30,10 +30,18 @@
 #include virerror.h
 #include virlog.h
 #include virstring.h
+#include virtime.h
 
 #define VIR_FROM_THIS VIR_FROM_LIBXL
 
 
+VIR_ENUM_IMPL(libxlDomainJob, LIBXL_JOB_LAST,
+  none,
+  query,
+  destroy,
+  modify,
+);
+
 /* Object used to store info related to libxl event registrations */
 typedef struct _libxlEventHookInfo libxlEventHookInfo;
 typedef libxlEventHookInfo *libxlEventHookInfoPtr;
@@ -284,6 +292,119 @@ static const libxl_osevent_hooks libxl_event_callbacks = {
 .timeout_deregister = libxlDomainObjTimeoutDeregisterEventHook,
 };
 
+static int
+libxlDomainObjInitJob(libxlDomainObjPrivatePtr priv)
+{
+memset(priv-job, 0, sizeof(priv-job));
+
+if (virCondInit(priv-job.cond)  0)
+return -1;
+
+return 0;
+}
+
+static void
+libxlDomainObjResetJob(libxlDomainObjPrivatePtr priv)
+{
+struct libxlDomainJobObj *job = priv-job;
+
+job-active = LIBXL_JOB_NONE;
+job-owner = 0;
+}
+
+static void
+libxlDomainObjFreeJob(libxlDomainObjPrivatePtr priv)
+{
+ignore_value(virCondDestroy(priv-job.cond));
+}
+
+/* Give up waiting for mutex after 30 seconds */
+#define LIBXL_JOB_WAIT_TIME (1000ull * 30)
+
+/*
+ * obj must be locked before calling, libxlDriverPrivatePtr must NOT be locked
+ *
+ * This must be called by anything that will change the VM state
+ * in any way
+ *
+ * Upon successful return, the object will have its ref count increased,
+ * successful calls must be followed by EndJob eventually
+ */
+int
+libxlDomainObjBeginJob(libxlDriverPrivatePtr driver ATTRIBUTE_UNUSED,
+   virDomainObjPtr obj,
+   enum libxlDomainJob job)
+{
+libxlDomainObjPrivatePtr priv = obj-privateData;
+unsigned long long now;
+unsigned long long then;
+
+if (virTimeMillisNow(now)  0)
+return -1;
+then = now + LIBXL_JOB_WAIT_TIME;
+
+virObjectRef(obj);
+
+while (priv-job.active) {
+VIR_DEBUG(Wait normal job condition for starting job: %s,
+  libxlDomainJobTypeToString(job));
+if (virCondWaitUntil(priv-job.cond, obj-parent.lock, then)  0)
+goto error;
+}
+
+libxlDomainObjResetJob(priv);
+
+VIR_DEBUG(Starting job: %s, libxlDomainJobTypeToString(job));
+priv-job.active = job;
+priv-job.owner = virThreadSelfID();
+
+return 0;
+
+error:
+VIR_WARN(Cannot start job (%s) for domain %s;
+  current job is (%s) owned by (%d),
+ libxlDomainJobTypeToString(job),
+ obj-def-name,
+ libxlDomainJobTypeToString(priv-job.active),
+ priv-job.owner);
+
+if (errno == ETIMEDOUT)
+virReportError(VIR_ERR_OPERATION_TIMEOUT,
+   %s, _(cannot acquire state change lock));
+else
+virReportSystemError(errno,
+ %s, _(cannot acquire job mutex));
+
+virObjectUnref(obj);
+return -1;
+}
+
+/*
+ * obj must be locked before calling
+ *
+ * To be called after completing the work associated with the
+ * earlier libxlDomainBeginJob() call
+ *
+ * Returns true if the remaining reference count on obj is
+ * non-zero, false if the reference count has dropped to zero
+ * and obj is disposed.
+ */
+bool
+libxlDomainObjEndJob(libxlDriverPrivatePtr driver ATTRIBUTE_UNUSED,
+ virDomainObjPtr obj)
+{
+libxlDomainObjPrivatePtr priv = obj-privateData;
+enum libxlDomainJob job = priv-job.active;
+
+VIR_DEBUG(Stopping job: %s,
+  libxlDomainJobTypeToString(job));
+
+libxlDomainObjResetJob(priv);
+virCondSignal(priv-job.cond);
+
+return virObjectUnref(obj);
+}
+
 static void *
 libxlDomainObjPrivateAlloc(void)
 {
@@ -300,6 +421,12 @@ libxlDomainObjPrivateAlloc(void)
 return NULL;
 }
 
+if (libxlDomainObjInitJob(priv)  0) {
+virChrdevFree(priv-devs);
+virObjectUnref(priv);
+return NULL;
+}
+
 return priv;
 }
 
@@ -311,6 +438,7 @@ libxlDomainObjPrivateDispose(void *obj)
 if (priv-deathW)
 libxl_evdisable_domain_death(priv-ctx, priv-deathW);
 
+libxlDomainObjFreeJob(priv);
 virChrdevFree(priv-devs);
 libxl_ctx_free(priv-ctx);
 if (priv-logger_file)
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 8565820..0a29d38 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -30,6 +30,31 @@
 # include libxl_conf.h
 

[libvirt] [PATCH V2 06/13] libxl: use job functions in libxlDomain{Suspend, Resume}

2014-02-12 Thread Jim Fehlig
These operations aren't necessarily time consuming, but need to
wait in the queue of modify jobs.

Signed-off-by: Jim Fehlig jfeh...@suse.com
---

V2: Check libxlDomainObjEndJob() return value

 src/libxl/libxl_driver.c | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 87771f7..36fc9f5 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1342,9 +1342,12 @@ libxlDomainSuspend(virDomainPtr dom)
 if (virDomainSuspendEnsureACL(dom-conn, vm-def)  0)
 goto cleanup;
 
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY)  0)
+goto cleanup;
+
 if (!virDomainObjIsActive(vm)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s, _(Domain is not 
running));
-goto cleanup;
+goto endjob;
 }
 
 priv = vm-privateData;
@@ -1354,7 +1357,7 @@ libxlDomainSuspend(virDomainPtr dom)
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to suspend domain '%d' with libxenlight),
dom-id);
-goto cleanup;
+goto endjob;
 }
 
 virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER);
@@ -1364,10 +1367,14 @@ libxlDomainSuspend(virDomainPtr dom)
 }
 
 if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
-goto cleanup;
+goto endjob;
 
 ret = 0;
 
+endjob:
+if (!libxlDomainObjEndJob(driver, vm))
+vm = NULL;
+
 cleanup:
 if (vm)
 virObjectUnlock(vm);
@@ -1394,9 +1401,12 @@ libxlDomainResume(virDomainPtr dom)
 if (virDomainResumeEnsureACL(dom-conn, vm-def)  0)
 goto cleanup;
 
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY)  0)
+goto cleanup;
+
 if (!virDomainObjIsActive(vm)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s, _(Domain is not 
running));
-goto cleanup;
+goto endjob;
 }
 
 priv = vm-privateData;
@@ -1406,7 +1416,7 @@ libxlDomainResume(virDomainPtr dom)
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Failed to resume domain '%d' with libxenlight),
dom-id);
-goto cleanup;
+goto endjob;
 }
 
 virDomainObjSetState(vm, VIR_DOMAIN_RUNNING,
@@ -1417,10 +1427,14 @@ libxlDomainResume(virDomainPtr dom)
 }
 
 if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
-goto cleanup;
+goto endjob;
 
 ret = 0;
 
+endjob:
+if (!libxlDomainObjEndJob(driver, vm))
+vm = NULL;
+
 cleanup:
 if (vm)
 virObjectUnlock(vm);
-- 
1.8.1.4

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


  1   2   >