Re: [libvirt] [PATCH v2 0/4] Add a domain masterKey secret for qemu,

2016-04-06 Thread John Ferlan


On 03/29/2016 07:11 PM, John Ferlan wrote:
> v1: http://www.redhat.com/archives/libvir-list/2016-March/msg01206.html
> 
> Patch 1 is already ACK'd. I assume this code won't go into 1.3.3, but
> would hopefully be early in 1.3.4 and I didn't want to break up the
> capability bits across releases...
> 
> Differences to v1
> 
>  - Patch 2 is new - it's taking the virUUIDGenerateRandomBytes and making
>it generic since we'll use it in Patch 3 (it already opens/reads from
>/dev/urandom, so I figured it'd be better to share than cut, copy, paste).
> 
>  - Patch 3 has changes from review:
> 
>* Less comments in qemuDomainGetMasterKeyFilePath
> 
>* Master key no longer base64 encoded to be written (or read). Instead
>  the Write code will open, truncate, and write the secret directly.
>  The Read code will read the secret directly
> 
>* The fallback algorithm for key generation uses virGenerateRandomBytes
> 
>* Changed 'masterKey' from "char *" to "uint8_t *" and added the
>  masterKeyLen
> 
>  - Patch 4 changes in order to tell qemu the format of the file is 'raw'.
>Also affects test .args file
> 
> 
> Removed references to encode/decode, adjusted commit messages.
> 
> Ran through Coverity checker... happy...
> 
> Created a domain that would pass/read the file...  Killed libvirtd, restarted
> and read the masterKey file properly. Also ensured the #else of the secret
> generation compiled...
> 
> John Ferlan (4):
>   qemu: Add capability bit for qemu secret object
>   util: Introduce virGenerateRandomBytes
>   qemu: Create domain master key
>   qemu: Introduce qemuBuildMasterKeyCommandLine
> 
>  src/libvirt_private.syms   |   1 +
>  src/qemu/qemu_alias.c  |  17 ++
>  src/qemu/qemu_alias.h  |   3 +
>  src/qemu/qemu_capabilities.c   |   2 +
>  src/qemu/qemu_capabilities.h   |   1 +
>  src/qemu/qemu_command.c|  68 ++
>  src/qemu/qemu_domain.c | 252 
> +
>  src/qemu/qemu_domain.h |  15 ++
>  src/qemu/qemu_process.c|  11 +
>  src/util/virutil.c |  36 +++
>  src/util/virutil.h |   3 +
>  src/util/viruuid.c |  30 +--
>  tests/qemucapabilitiesdata/caps_2.6.0-1.caps   |   1 +
>  tests/qemucapabilitiesdata/caps_2.6.0-1.replies|   3 +
>  .../qemuxml2argvdata/qemuxml2argv-master-key.args  |  23 ++
>  tests/qemuxml2argvdata/qemuxml2argv-master-key.xml |  30 +++
>  tests/qemuxml2argvtest.c   |   2 +
>  17 files changed, 469 insertions(+), 29 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-master-key.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-master-key.xml
> 

Made requested adjustments and pushed.

Working through the IV support now...

Tks for the review,

John

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


Re: [libvirt] [PATCH] libxl: libxl_domain_create_restore has an extra argument

2016-04-06 Thread Doug Goldstein
On 4/5/16 9:20 AM, Wei Liu wrote:
> In the latest libxenlight code, libxl_domain_create_restore accepts a
> new argument. Update libvirt's libxl driver for that. Use the macro
> provided by libxenlight to detect which version should be used.
> 
> The new parameter (send_back_fd) is set to -1 because libvirt provides
> no such fd.
> 
> Signed-off-by: Wei Liu 
> ---
> Build test with Xen 4.6.1 (old API) and Xen unstable (new API).
> ---
>  src/libxl/libxl_domain.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
> index 04962a0..aed904b 100644
> --- a/src/libxl/libxl_domain.c
> +++ b/src/libxl/libxl_domain.c
> @@ -1070,7 +1070,12 @@ libxlDomainStart(libxlDriverPrivatePtr driver, 
> virDomainObjPtr vm,
>  ret = libxl_domain_create_new(cfg->ctx, _config,
>, NULL, _console_how);
>  } else {
> -#ifdef LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS
> +#if defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD)
> +params.checkpointed_stream = 0;
> +ret = libxl_domain_create_restore(cfg->ctx, _config, ,
> +  restore_fd, -1, , NULL,
> +  _console_how);
> +#elif defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS)
>  params.checkpointed_stream = 0;
>  ret = libxl_domain_create_restore(cfg->ctx, _config, ,
>restore_fd, , NULL,
> 

ACK

This fixes integration testing that Xen Project does with libvirt and
Xen so it would be nice to get in for 1.3.3.

-- 
Doug Goldstein



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

[libvirt] 200ms delay waiting for qemu monitor

2016-04-06 Thread Richard W.M. Jones
[Thanks to Dan Berrangé for doing the analysis of this one]

I was investigating a 200+ millisecond delay when libvirt starts a
qemu guest.  You can see the traces here:

http://oirase.annexia.org/tmp/libvirt.log
http://oirase.annexia.org/tmp/libvirtd.log

The delay happens at around 16:52:57.327-6:52:57.528 in the libvirtd log.
As you can see the delay is almost precisely 200ms.

Dan found the cause which seems to be this code:

https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_monitor.c;h=10a6713c06ad36e2055f8144fba00b78630971e5;hb=HEAD#l365

(There are other examples of the same anti-pattern in src/fdstream.c
and src/qemu/qemu_agent.c, but it's the particular code above which
seems to be causing the delay).

To give you some sense why I regard this as a problem, the TOTAL time
taken to launch and shutdown the libguestfs appliance (that includes
qemu, BIOS, guest kernel, probing and mouting disks, running the
guestfs daemon, and the shutdown process in reverse), without libvirt,
is now 900ms.  Libvirt adds about 220ms on top of this.

What can we do about this?  Obviously we could simply reduce the
delay, but even if it was set to 20ms, that would be too much (aim is
to reduce the whole process from 900ms down to 150ms), and it would
also mean that libvirt was essentially polling.

Can we use inotify to detect if the socket has been created?  Seems to
create portability problems.

Dan suggested:

Can we create the socket in libvirtd and pass it to qemu?

Can we pass a file descriptor to qemu?

Other suggestions?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top

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


Re: [libvirt] [PATCH] Link xen driver against libxl

2016-04-06 Thread Guido Günther
On Wed, Apr 06, 2016 at 09:53:06AM +0200, Jiri Denemark wrote:
> On Tue, Apr 05, 2016 at 18:16:29 +0200, Guido Günther wrote:
> > >From 4e302ea482d58c5ae034f85ea27d0318cb0b59c5 Mon Sep 17 00:00:00 2001
> > Message-Id: 
> > <4e302ea482d58c5ae034f85ea27d0318cb0b59c5.1459872920.git@sigxcpu.org>
> > From: =?UTF-8?q?Guido=20G=C3=BCnther?= 
> > Date: Thu, 31 Mar 2016 14:57:24 +0200
> > Subject: [PATCH] Link libvirt_xenconfig instead of libvirt against libxl
> > To: libvir-list@redhat.com
> > Status: O
> > Content-Length: 975
> > Lines: 24
> > 
> > to avoid the test failure
> > 
> >  7) Test driver "xen"  ... 2016-03-31 12:53:26.950+: 22430: debug : 
> > virDriverLoadModule:54 : Module load xen
> >  2016-03-31 12:53:26.950+: 22430: error : virDriverLoadModule:73 : 
> > failed to load module 
> > /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so 
> > /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so: 
> > undefined symbol: xlu_cfg_destroy
> > FAILED
> > ---
> >  src/Makefile.am | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/Makefile.am b/src/Makefile.am
> > index 1726d06..e63b81d 100644
> > --- a/src/Makefile.am
> > +++ b/src/Makefile.am
> > @@ -1134,7 +1134,7 @@ endif WITH_VMX
> >  if WITH_XENCONFIG
> >  noinst_LTLIBRARIES += libvirt_xenconfig.la
> >  libvirt_la_BUILT_LIBADD += libvirt_xenconfig.la
> > -libvirt_la_LIBADD += $(LIBXL_LIBS)
> > +libvirt_xenconfig_la_LIBADD = $(LIBXL_LIBS)
> >  libvirt_xenconfig_la_CFLAGS = \
> > -I$(srcdir)/conf $(AM_CFLAGS)
> >  libvirt_xenconfig_la_SOURCES = $(XENCONFIG_SOURCES)
> 
> ACK

Pushed. Thanks a lot!
 -- Guido

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


Re: [libvirt] [PATCH 2/2] qemu: alias: Fix calculation of memory device aliases

2016-04-06 Thread Pavel Hrdina
On Wed, Apr 06, 2016 at 05:52:49PM +0200, Peter Krempa wrote:
> For device hotplug, the new alias ID needs to be checked in the list
> rather than using the count of devices. Unplugging a device that is not
> last in the array will make further hotplug impossible due to alias
> collision.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551
> ---
>  src/qemu/qemu_alias.c   | 27 +++
>  src/qemu/qemu_alias.h   |  4 
>  src/qemu/qemu_hotplug.c |  2 +-
>  3 files changed, 32 insertions(+), 1 deletion(-)

ACK with the same update as for first patch.

Pavel

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


Re: [libvirt] [PATCH 1/2] qemu: alias: Fix calculation of RNG device aliases

2016-04-06 Thread Pavel Hrdina
On Wed, Apr 06, 2016 at 05:52:48PM +0200, Peter Krempa wrote:
> For device hotplug, the new alias ID needs to be checked in the list
> rather than using the count of devices. Unplugging a device that is not
> last in the array will make further hotplug impossible due to alias
> collision.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551
> ---
>  src/qemu/qemu_alias.c   | 20 ++--
>  src/qemu/qemu_alias.h   |  3 ++-
>  src/qemu/qemu_hotplug.c |  2 +-
>  3 files changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
> index 010d6b9..052a829 100644
> --- a/src/qemu/qemu_alias.c
> +++ b/src/qemu/qemu_alias.c
> @@ -382,9 +382,25 @@ qemuAssignDeviceRedirdevAlias(virDomainDefPtr def,
> 
> 
>  int
> -qemuAssignDeviceRNGAlias(virDomainRNGDefPtr rng,
> +qemuAssignDeviceRNGAlias(virDomainDefPtr def,
> + virDomainRNGDefPtr rng,
>   size_t idx)
>  {
> +if (idx == -1) {
> +size_t i;
> +idx = 0;
> +for (i = 0; i < def->nrngs; i++) {
> +int thisidx;
> +if ((thisidx = qemuDomainDeviceAliasIndex(>rngs[i]->info, 
> "rng")) < 0) {
> +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +   _("Unable to determine device index for rng 
> device"));
> +return -1;

For net and hostdev alias this was updated by recent commit 8f74f527 to ignore
that fact and just continue with next device.  This error isn't required since 
we
are trying only to create a non-collision alias matching 'rng[0-9]+'.

ACK with that fixed.

Pavle

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


[libvirt] [PATCH 6/8] qemu: driver: Reuse qemuDomainGetMonitor in qemuDomainMemoryStats

2016-04-06 Thread Peter Krempa
---
 src/qemu/qemu_driver.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a00268b..8b9801a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11471,7 +11471,6 @@ qemuDomainMemoryStats(virDomainPtr dom,
   unsigned int flags)
 {
 virQEMUDriverPtr driver = dom->conn->privateData;
-qemuDomainObjPrivatePtr priv;
 virDomainObjPtr vm;
 int ret = -1;
 long rss;
@@ -11494,9 +11493,8 @@ qemuDomainMemoryStats(virDomainPtr dom,
 }

 if (qemuDomainDefHasMemballoon(vm->def)) {
-priv = vm->privateData;
 qemuDomainObjEnterMonitor(driver, vm);
-ret = qemuMonitorGetMemoryStats(priv->mon, stats, nr_stats);
+ret = qemuMonitorGetMemoryStats(qemuDomainGetMonitor(vm), stats, 
nr_stats);
 if (qemuDomainObjExitMonitor(driver, vm) < 0)
 ret = -1;

-- 
2.8.0

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


[libvirt] [PATCH 7/8] qemu: process: Simplify condition in qemuProcessRefreshBalloonState

2016-04-06 Thread Peter Krempa
No need to store failure and re-check right away.
---
 src/qemu/qemu_process.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4911c1d..a8c5139 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1942,10 +1942,7 @@ qemuProcessRefreshBalloonState(virQEMUDriverPtr driver,
 return -1;

 rc = qemuMonitorGetBalloonInfo(qemuDomainGetMonitor(vm), );
-if (qemuDomainObjExitMonitor(driver, vm) < 0)
-rc = -1;
-
-if (rc < 0)
+if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
 return -1;

 vm->def->mem.cur_balloon = balloon;
-- 
2.8.0

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


[libvirt] [PATCH 3/8] qemu: command: Drop obsolete comment

2016-04-06 Thread Peter Krempa
The change that made qemu not add the memballoon by default happened
prior to 0.12.0. Additionaly the comment was misleading due to the code
that was added below. Since we always need to add a balloon on the
commandline drop the comment.
---
 src/qemu/qemu_command.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bcd2408..5843516 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3453,12 +3453,7 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,
virQEMUCapsPtr qemuCaps)
 {
 char *optstr;
-/* QEMU changed its default behavior to not include the virtio balloon
- * device.  Explicitly request it to ensure it will be present.
- *
- * NB: Earlier we declared that VirtIO balloon will always be in
- * slot 0x3 on bus 0x0
- */
+
 if (STREQLEN(def->os.machine, "s390-virtio", 10) &&
 virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon)
 def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
-- 
2.8.0

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


[libvirt] [PATCH 8/8] qemu: hotplug: Properly recalculate/reload balloon size after hot(un)plug

2016-04-06 Thread Peter Krempa
Rather than trying some magic calculations on our side query the monitor
for the current size of the memory balloon both on hotplug and
hotunplug.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1220702
---
 src/qemu/qemu_hotplug.c | 15 ++-
 src/qemu/qemu_process.c |  2 +-
 src/qemu/qemu_process.h |  4 
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 48bea6a..f77d65a 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -33,6 +33,7 @@
 #include "qemu_command.h"
 #include "qemu_hostdev.h"
 #include "qemu_interface.h"
+#include "qemu_process.h"
 #include "domain_audit.h"
 #include "netdev_bandwidth_conf.h"
 #include "domain_nwfilter.h"
@@ -1742,7 +1743,6 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
 const char *backendType;
 virJSONValuePtr props = NULL;
 virObjectEventPtr event;
-bool fix_balloon = false;
 int id;
 int ret = -1;

@@ -1757,9 +1757,6 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
 if (virAsprintf(, "mem%s", mem->info.alias) < 0)
 goto cleanup;

-if (vm->def->mem.cur_balloon == virDomainDefGetMemoryActual(vm->def))
-fix_balloon = true;
-
 if (!(devstr = qemuBuildMemoryDeviceStr(mem)))
 goto cleanup;

@@ -1800,9 +1797,8 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
 event = virDomainEventDeviceAddedNewFromObj(vm, objalias);
 qemuDomainEventQueue(driver, event);

-/* fix the balloon size if it was set to maximum */
-if (fix_balloon)
-vm->def->mem.cur_balloon += mem->size;
+/* fix the balloon size */
+ignore_value(qemuProcessRefreshBalloonState(driver, vm, 
QEMU_ASYNC_JOB_NONE));

 /* mem is consumed by vm->def */
 mem = NULL;
@@ -2939,13 +2935,14 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
 if (rc < 0)
 return -1;

-vm->def->mem.cur_balloon -= mem->size;
-
 if ((idx = virDomainMemoryFindByDef(vm->def, mem)) >= 0)
 virDomainMemoryRemove(vm->def, idx);

 virDomainMemoryDefFree(mem);

+/* fix the balloon size */
+ignore_value(qemuProcessRefreshBalloonState(driver, vm, 
QEMU_ASYNC_JOB_NONE));
+
 /* decrease the mlock limit after memory unplug if necessary */
 ignore_value(qemuDomainAdjustMaxMemLock(vm));

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a8c5139..c7456af 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1923,7 +1923,7 @@ qemuRefreshVirtioChannelState(virQEMUDriverPtr driver,
 }


-static int
+int
 qemuProcessRefreshBalloonState(virQEMUDriverPtr driver,
virDomainObjPtr vm,
int asyncJob)
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index d5f50f2..98cc9a8 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -193,4 +193,8 @@ int qemuProcessSetupIOThread(virDomainObjPtr vm,

 int qemuRefreshVirtioChannelState(virQEMUDriverPtr driver,
   virDomainObjPtr vm);
+
+int qemuProcessRefreshBalloonState(virQEMUDriverPtr driver,
+   virDomainObjPtr vm,
+   int asyncJob);
 #endif /* __QEMU_PROCESS_H__ */
-- 
2.8.0

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


[libvirt] [PATCH 4/8] qemu: command: Refactor memballoon command line formatting

2016-04-06 Thread Peter Krempa
Now that there is just one format of the memory balloon command line
used the code can be merged into a single function.

Additionally with some tweaks to the control flow the code is easier to
read.
---
 src/qemu/qemu_command.c | 76 +++--
 src/qemu/qemu_command.h |  4 ---
 2 files changed, 29 insertions(+), 51 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5843516..a2448bf 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3397,14 +3397,29 @@ qemuBuildWatchdogCommandLine(virCommandPtr cmd,
 }


-char *
-qemuBuildMemballoonDevStr(const virDomainDef *def,
-  virDomainMemballoonDefPtr dev,
-  virQEMUCapsPtr qemuCaps)
+static int
+qemuBuildMemballoonCommandLine(virCommandPtr cmd,
+   const virDomainDef *def,
+   virQEMUCapsPtr qemuCaps)
 {
 virBuffer buf = VIR_BUFFER_INITIALIZER;

-switch (dev->info.type) {
+if (STREQLEN(def->os.machine, "s390-virtio", 10) &&
+virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon)
+def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
+
+if (!def->memballoon ||
+def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)
+return 0;
+
+if (def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("Memory balloon device type '%s' is not supported by 
this version of qemu"),
+   
virDomainMemballoonModelTypeToString(def->memballoon->model));
+return -1;
+}
+
+switch (def->memballoon->info.type) {
 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
 virBufferAddLit(, "virtio-balloon-pci");
 break;
@@ -3417,15 +3432,15 @@ qemuBuildMemballoonDevStr(const virDomainDef *def,
 default:
 virReportError(VIR_ERR_XML_ERROR,
_("memballoon unsupported with address type '%s'"),
-   virDomainDeviceAddressTypeToString(dev->info.type));
+   
virDomainDeviceAddressTypeToString(def->memballoon->info.type));
 goto error;
 }

-virBufferAsprintf(, ",id=%s", dev->info.alias);
-if (qemuBuildDeviceAddressStr(, def, >info, qemuCaps) < 0)
+virBufferAsprintf(, ",id=%s", def->memballoon->info.alias);
+if (qemuBuildDeviceAddressStr(, def, >memballoon->info, qemuCaps) 
< 0)
 goto error;

-if (dev->autodeflate != VIR_TRISTATE_SWITCH_ABSENT) {
+if (def->memballoon->autodeflate != VIR_TRISTATE_SWITCH_ABSENT) {
 if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("deflate-on-oom is not supported by this QEMU 
binary"));
@@ -3433,49 +3448,16 @@ qemuBuildMemballoonDevStr(const virDomainDef *def,
 }

 virBufferAsprintf(, ",deflate-on-oom=%s",
-  virTristateSwitchTypeToString(dev->autodeflate));
+  
virTristateSwitchTypeToString(def->memballoon->autodeflate));
 }

-if (virBufferCheckError() < 0)
-goto error;
-
-return virBufferContentAndReset();
+virCommandAddArg(cmd, "-device");
+virCommandAddArgBuffer(cmd, );
+return 0;

  error:
 virBufferFreeAndReset();
-return NULL;
-}
-
-
-static int
-qemuBuildMemballoonCommandLine(virCommandPtr cmd,
-   const virDomainDef *def,
-   virQEMUCapsPtr qemuCaps)
-{
-char *optstr;
-
-if (STREQLEN(def->os.machine, "s390-virtio", 10) &&
-virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon)
-def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
-
-if (def->memballoon &&
-def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
-if (def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _("Memory balloon device type '%s' is not supported 
by this version of qemu"),
-   
virDomainMemballoonModelTypeToString(def->memballoon->model));
-return -1;
-}
-
-virCommandAddArg(cmd, "-device");
-
-optstr = qemuBuildMemballoonDevStr(def, def->memballoon, qemuCaps);
-if (!optstr)
-return -1;
-virCommandAddArg(cmd, optstr);
-VIR_FREE(optstr);
-}
-return 0;
+return -1;
 }


diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index a3e6a00..3e8ccd8 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -130,10 +130,6 @@ char *qemuBuildControllerDevStr(const virDomainDef 
*domainDef,
 virQEMUCapsPtr qemuCaps,
 int 

[libvirt] [PATCH 5/8] qemu: domain: Add helper to determine presence of memory baloon

2016-04-06 Thread Peter Krempa
---
 src/qemu/qemu_command.c |  3 +--
 src/qemu/qemu_domain.c  | 11 +--
 src/qemu/qemu_domain.h  |  1 +
 src/qemu/qemu_driver.c  | 12 
 src/qemu/qemu_process.c |  9 +++--
 5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a2448bf..1518a53 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3408,8 +3408,7 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,
 virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon)
 def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;

-if (!def->memballoon ||
-def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE)
+if (!qemuDomainDefHasMemballoon(def))
 return 0;

 if (def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f38b0f3..c13acd1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4218,6 +4218,14 @@ qemuDomainMachineHasBuiltinIDE(const virDomainDef *def)
 }


+bool
+qemuDomainDefHasMemballoon(const virDomainDef *def)
+{
+return def->memballoon &&
+   def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
+}
+
+
 /**
  * qemuDomainUpdateCurrentMemorySize:
  *
@@ -4242,8 +4250,7 @@ qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,

 /* if no balloning is available, the current size equals to the current
  * full memory size */
-if (!vm->def->memballoon ||
-vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
+if (!qemuDomainDefHasMemballoon(vm->def)) {
 vm->def->mem.cur_balloon = virDomainDefGetMemoryActual(vm->def);
 return 0;
 }
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 54d7bd7..2992214 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -516,6 +516,7 @@ bool qemuDomainHasBlockjob(virDomainObjPtr vm, bool 
copy_only)
 int qemuDomainAlignMemorySizes(virDomainDefPtr def);
 void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
  virDomainMemoryDefPtr mem);
+bool qemuDomainDefHasMemballoon(const virDomainDef *def);

 virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index eaabe58..a00268b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2505,8 +2505,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr 
dom, int period,
 priv = vm->privateData;

 if (def) {
-if (!def->memballoon ||
-def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
+if (!qemuDomainDefHasMemballoon(def)) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Memory balloon model must be virtio to set the"
  " collection period"));
@@ -2529,8 +2528,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr 
dom, int period,
 }

 if (persistentDef) {
-if (!persistentDef->memballoon ||
-persistentDef->memballoon->model != 
VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
+if (!qemuDomainDefHasMemballoon(persistentDef)) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Memory balloon model must be virtio to set the"
  " collection period"));
@@ -11495,8 +11493,7 @@ qemuDomainMemoryStats(virDomainPtr dom,
 goto endjob;
 }

-if (vm->def->memballoon &&
-vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
+if (qemuDomainDefHasMemballoon(vm->def)) {
 priv = vm->privateData;
 qemuDomainObjEnterMonitor(driver, vm);
 ret = qemuMonitorGetMemoryStats(priv->mon, stats, nr_stats);
@@ -19061,8 +19058,7 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver 
ATTRIBUTE_UNUSED,
 unsigned long long cur_balloon = 0;
 int err = 0;

-if (dom->def->memballoon &&
-dom->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
+if (!qemuDomainDefHasMemballoon(dom->def)) {
 cur_balloon = virDomainDefGetMemoryActual(dom->def);
 } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BALLOON_EVENT)) {
 cur_balloon = dom->def->mem.cur_balloon;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d9dca74..4911c1d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1933,8 +1933,7 @@ qemuProcessRefreshBalloonState(virQEMUDriverPtr driver,

 /* if no ballooning is available, the current size equals to the current
  * full memory size */
-if (!vm->def->memballoon ||
-vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
+if (!qemuDomainDefHasMemballoon(vm->def)) {
 vm->def->mem.cur_balloon = virDomainDefGetMemoryActual(vm->def);
 return 0;
 }
@@ -4382,8 +4381,7 @@ qemuProcessSetupBalloon(virQEMUDriverPtr 

[libvirt] [PATCH 2/8] qemu: caps: Deprecate QEMU_CAPS_BALLOON

2016-04-06 Thread Peter Krempa
The flag is now unused and all qemus supported by libvirt already
support it.
---
 src/qemu/qemu_capabilities.c  | 3 ---
 src/qemu/qemu_capabilities.h  | 2 +-
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps  | 1 -
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps  | 1 -
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps  | 1 -
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps  | 1 -
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps  | 1 -
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 -
 tests/qemucapabilitiesdata/caps_2.1.1-1.caps  | 1 -
 tests/qemucapabilitiesdata/caps_2.4.0-1.caps  | 1 -
 tests/qemucapabilitiesdata/caps_2.5.0-1.caps  | 1 -
 tests/qemucapabilitiesdata/caps_2.6.0-1.caps  | 1 -
 tests/qemuhelptest.c  | 8 
 13 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2823843..b0c741e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1163,8 +1163,6 @@ virQEMUCapsComputeCmdFlags(const char *help,
 if (strstr(help, "-chardev spiceport"))
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEPORT);
 }
-if (strstr(help, "-balloon"))
-virQEMUCapsSet(qemuCaps, QEMU_CAPS_BALLOON);
 if (strstr(help, "-device")) {
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE);
 /*
@@ -3226,7 +3224,6 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps)
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL);
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV);
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_MONITOR_JSON);
-virQEMUCapsSet(qemuCaps, QEMU_CAPS_BALLOON);
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE);
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_SDL);
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index caf3d1b..3047d1b 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -81,7 +81,7 @@ typedef enum {
 QEMU_CAPS_MONITOR_JSON, /* JSON mode for monitor */

 /* 25 */
-QEMU_CAPS_BALLOON, /* -balloon available */
+X_QEMU_CAPS_BALLOON, /* -balloon available */
 QEMU_CAPS_DEVICE, /* Is the new -device arg available */
 QEMU_CAPS_SDL, /* Is the new -sdl arg available */
 QEMU_CAPS_SMP_TOPOLOGY, /* -smp has sockets/cores/threads */
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps 
b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
index 2e452ea..9ea36a6 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
@@ -4,7 +4,6 @@
 
 
 
-
 
 
 
diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps 
b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
index 5ad56aa..8c237ef 100644
--- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
@@ -4,7 +4,6 @@
 
 
 
-
 
 
 
diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps 
b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
index d0341fd..fe98a57 100644
--- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
@@ -4,7 +4,6 @@
 
 
 
-
 
 
 
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps 
b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
index 93ea687..6e9ec3e 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
@@ -4,7 +4,6 @@
 
 
 
-
 
 
 
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps 
b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
index c25b076..da371a4 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
@@ -4,7 +4,6 @@
 
 
 
-
 
 
 
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps 
b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
index 30b70e9..1e2fb6a 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
@@ -4,7 +4,6 @@
 
 
 
-
 
 
 
diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps 
b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps
index 59d0323..8175743 100644
--- a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps
@@ -4,7 +4,6 @@
 
 
 
-
 
 
 
diff --git a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps 
b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps
index efbf9af..883bf50 100644
--- a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps
@@ -4,7 +4,6 @@
 
 
 
-
 
 
 
diff --git a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps 
b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps
index 5fd3bce..2b73b73 100644
--- a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps
@@ -4,7 

[libvirt] [PATCH 0/8] qemu: Fix current ballooned size after memory hot(un)plug

2016-04-06 Thread Peter Krempa
Clean up some of the memory balloon code and fix the calculation of size after
hotplug.

Peter Krempa (8):
  qemu: command: Assume QEMU_CAPS_DEVICE when building memballoon args
  qemu: caps: Deprecate QEMU_CAPS_BALLOON
  qemu: command: Drop obsolete comment
  qemu: command: Refactor memballoon command line formatting
  qemu: domain: Add helper to determine presence of memory baloon
  qemu: driver: Reuse qemuDomainGetMonitor in qemuDomainMemoryStats
  qemu: process: Simplify condition in qemuProcessRefreshBalloonState
  qemu: hotplug: Properly recalculate/reload balloon size after
hot(un)plug

 src/qemu/qemu_capabilities.c  |  3 -
 src/qemu/qemu_capabilities.h  |  2 +-
 src/qemu/qemu_command.c   | 83 +--
 src/qemu/qemu_command.h   |  4 --
 src/qemu/qemu_domain.c| 11 +++-
 src/qemu/qemu_domain.h|  1 +
 src/qemu/qemu_driver.c| 16 ++
 src/qemu/qemu_hotplug.c   | 15 ++---
 src/qemu/qemu_process.c   | 16 ++
 src/qemu/qemu_process.h   |  4 ++
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps  |  1 -
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps  |  1 -
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps  |  1 -
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps  |  1 -
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps  |  1 -
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps |  1 -
 tests/qemucapabilitiesdata/caps_2.1.1-1.caps  |  1 -
 tests/qemucapabilitiesdata/caps_2.4.0-1.caps  |  1 -
 tests/qemucapabilitiesdata/caps_2.5.0-1.caps  |  1 -
 tests/qemucapabilitiesdata/caps_2.6.0-1.caps  |  1 -
 tests/qemuhelptest.c  |  8 ---
 21 files changed, 59 insertions(+), 114 deletions(-)

-- 
2.8.0

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


[libvirt] [PATCH 1/8] qemu: command: Assume QEMU_CAPS_DEVICE when building memballoon args

2016-04-06 Thread Peter Krempa
---
 src/qemu/qemu_command.c | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a6afaec..bcd2408 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3452,6 +3452,7 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
 {
+char *optstr;
 /* QEMU changed its default behavior to not include the virtio balloon
  * device.  Explicitly request it to ensure it will be present.
  *
@@ -3470,18 +3471,14 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,

virDomainMemballoonModelTypeToString(def->memballoon->model));
 return -1;
 }
-if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-char *optstr;
-virCommandAddArg(cmd, "-device");

-optstr = qemuBuildMemballoonDevStr(def, def->memballoon, qemuCaps);
-if (!optstr)
-return -1;
-virCommandAddArg(cmd, optstr);
-VIR_FREE(optstr);
-} else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BALLOON)) {
-virCommandAddArgList(cmd, "-balloon", "virtio", NULL);
-}
+virCommandAddArg(cmd, "-device");
+
+optstr = qemuBuildMemballoonDevStr(def, def->memballoon, qemuCaps);
+if (!optstr)
+return -1;
+virCommandAddArg(cmd, optstr);
+VIR_FREE(optstr);
 }
 return 0;
 }
-- 
2.8.0

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


Re: [libvirt] [PATCH 06/18] domain_conf: cleanup error paths for graphics parser

2016-04-06 Thread Ján Tomko
On Mon, Apr 04, 2016 at 03:20:23PM +0200, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina 
> ---
>  src/conf/domain_conf.c | 100 
> ++---
>  1 file changed, 45 insertions(+), 55 deletions(-)

> @@ -10846,17 +10845,19 @@ 
> virDomainGraphicsDefParseXMLSdl(virDomainGraphicsDefPtr def,
>  } else {
>  virReportError(VIR_ERR_INTERNAL_ERROR,
> _("unknown fullscreen value '%s'"), fullscreen);
> -VIR_FREE(fullscreen);
> -return -1;
> +goto error;
>  }
> -VIR_FREE(fullscreen);
>  } else {
>  def->data.sdl.fullscreen = false;
>  }
> +
>  def->data.sdl.xauth = virXMLPropString(node, "xauth");
>  def->data.sdl.display = virXMLPropString(node, "display");
>  
> -return 0;
> +ret = 0;
> + error:

If you're adding a new label, 'cleanup' is better for paths shared by
the success and the error paths.

> +VIR_FREE(fullscreen);
> +return ret;
>  }
>  
>  

> @@ -10866,52 +10867,44 @@ 
> virDomainGraphicsDefParseXMLRdp(virDomainGraphicsDefPtr def,
>  }
>  
> -if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
> -if (STREQ(autoport, "yes"))
> -def->data.rdp.autoport = true;
> -
> -VIR_FREE(autoport);
> -}
> +if (autoport && STREQ(autoport, "yes"))
> +def->data.rdp.autoport = true;
>  

Could be STREQ_NULLABLE.

>  if (def->data.rdp.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
>  def->data.rdp.port = 0;
>  
> -if ((replaceUser = virXMLPropString(node, "replaceUser")) != NULL) {
> -if (STREQ(replaceUser, "yes"))
> -def->data.rdp.replaceUser = true;
> -VIR_FREE(replaceUser);
> -}
> +if (replaceUser && STREQ(replaceUser, "yes"))
> +def->data.rdp.replaceUser = true;
>  
> -if ((multiUser = virXMLPropString(node, "multiUser")) != NULL) {
> -if (STREQ(multiUser, "yes"))
> -def->data.rdp.multiUser = true;
> -VIR_FREE(multiUser);
> -}
> +if (multiUser && STREQ(multiUser, "yes"))
> +def->data.rdp.multiUser = true;
>  
>  ret = 0;
>   error:
> +VIR_FREE(port);
> +VIR_FREE(autoport);
> +VIR_FREE(replaceUser);
> +VIR_FREE(multiUser);
>  return ret;
>  }
>  

> @@ -10930,16 +10924,18 @@ 
> virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def,
>  } else {
>  virReportError(VIR_ERR_INTERNAL_ERROR,
> _("unknown fullscreen value '%s'"), fullscreen);
> -VIR_FREE(fullscreen);
> -return -1;
> +goto error;
>  }
> -VIR_FREE(fullscreen);
>  } else {
>  def->data.desktop.fullscreen = false;
>  }
>  
>  def->data.desktop.display = virXMLPropString(node, "display");
> -return 0;
> +
> +ret = 0;
> + error:

s/error/cleanup/

> +VIR_FREE(fullscreen);
> +return ret;
>  }

ACK

Jan

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


[libvirt] [PATCH 0/2] Fix alias asignment code for hotplugged RNGs/memory

2016-04-06 Thread Peter Krempa
I messed up the original impl and then copied it to memory devices. Sigh.

Peter Krempa (2):
  qemu: alias: Fix calculation of RNG device aliases
  qemu: alias: Fix calculation of memory device aliases

 src/qemu/qemu_alias.c   | 47 +--
 src/qemu/qemu_alias.h   |  7 ++-
 src/qemu/qemu_hotplug.c |  4 ++--
 3 files changed, 53 insertions(+), 5 deletions(-)

-- 
2.8.0

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


[libvirt] [PATCH 1/2] qemu: alias: Fix calculation of RNG device aliases

2016-04-06 Thread Peter Krempa
For device hotplug, the new alias ID needs to be checked in the list
rather than using the count of devices. Unplugging a device that is not
last in the array will make further hotplug impossible due to alias
collision.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551
---
 src/qemu/qemu_alias.c   | 20 ++--
 src/qemu/qemu_alias.h   |  3 ++-
 src/qemu/qemu_hotplug.c |  2 +-
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index 010d6b9..052a829 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -382,9 +382,25 @@ qemuAssignDeviceRedirdevAlias(virDomainDefPtr def,


 int
-qemuAssignDeviceRNGAlias(virDomainRNGDefPtr rng,
+qemuAssignDeviceRNGAlias(virDomainDefPtr def,
+ virDomainRNGDefPtr rng,
  size_t idx)
 {
+if (idx == -1) {
+size_t i;
+idx = 0;
+for (i = 0; i < def->nrngs; i++) {
+int thisidx;
+if ((thisidx = qemuDomainDeviceAliasIndex(>rngs[i]->info, 
"rng")) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Unable to determine device index for rng 
device"));
+return -1;
+}
+if (thisidx >= idx)
+idx = thisidx + 1;
+}
+}
+
 if (virAsprintf(>info.alias, "rng%zu", idx) < 0)
 return -1;

@@ -480,7 +496,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr 
qemuCaps)
 return -1;
 }
 for (i = 0; i < def->nrngs; i++) {
-if (qemuAssignDeviceRNGAlias(def->rngs[i], i) < 0)
+if (virAsprintf(>rngs[i]->info.alias, "rng%zu", i) < 0)
 return -1;
 }
 if (def->tpm) {
diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h
index b915f73..f311583 100644
--- a/src/qemu/qemu_alias.h
+++ b/src/qemu/qemu_alias.h
@@ -54,7 +54,8 @@ int qemuAssignDeviceRedirdevAlias(virDomainDefPtr def,
   virDomainRedirdevDefPtr redirdev,
   int idx);

-int qemuAssignDeviceRNGAlias(virDomainRNGDefPtr rng,
+int qemuAssignDeviceRNGAlias(virDomainDefPtr def,
+ virDomainRNGDefPtr rng,
  size_t idx);

 int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 48bea6a..93cc8e2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1625,7 +1625,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
 const char *type;
 int ret = -1;

-if (qemuAssignDeviceRNGAlias(rng, vm->def->nrngs) < 0)
+if (qemuAssignDeviceRNGAlias(vm->def, rng, -1) < 0)
 return -1;

 /* preallocate space for the device definition */
-- 
2.8.0

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


[libvirt] [PATCH 2/2] qemu: alias: Fix calculation of memory device aliases

2016-04-06 Thread Peter Krempa
For device hotplug, the new alias ID needs to be checked in the list
rather than using the count of devices. Unplugging a device that is not
last in the array will make further hotplug impossible due to alias
collision.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551
---
 src/qemu/qemu_alias.c   | 27 +++
 src/qemu/qemu_alias.h   |  4 
 src/qemu/qemu_hotplug.c |  2 +-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index 052a829..c56e5e4 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -409,6 +409,33 @@ qemuAssignDeviceRNGAlias(virDomainDefPtr def,


 int
+qemuAssignDeviceMemoryAlias(virDomainDefPtr def,
+virDomainMemoryDefPtr mem,
+size_t idx)
+{
+if (idx == -1) {
+size_t i;
+idx = 0;
+for (i = 0; i < def->nmems; i++) {
+int thisidx;
+if ((thisidx = qemuDomainDeviceAliasIndex(>mems[i]->info, 
"dimm")) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Unable to determine device index for memory 
device"));
+return -1;
+}
+if (thisidx >= idx)
+idx = thisidx + 1;
+}
+}
+
+if (virAsprintf(>info.alias, "dimm%zu", idx) < 0)
+return -1;
+
+return 0;
+}
+
+
+int
 qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
 {
 size_t i;
diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h
index f311583..ba91d32 100644
--- a/src/qemu/qemu_alias.h
+++ b/src/qemu/qemu_alias.h
@@ -58,6 +58,10 @@ int qemuAssignDeviceRNGAlias(virDomainDefPtr def,
  virDomainRNGDefPtr rng,
  size_t idx);

+int qemuAssignDeviceMemoryAlias(virDomainDefPtr def,
+virDomainMemoryDefPtr mems,
+size_t idx);
+
 int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);

 int qemuDomainDeviceAliasIndex(const virDomainDeviceInfo *info,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 93cc8e2..010eccd 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1751,7 +1751,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
 if (qemuDomainDefValidateMemoryHotplug(vm->def, priv->qemuCaps, mem) < 0)
 goto cleanup;

-if (virAsprintf(>info.alias, "dimm%zu", vm->def->nmems) < 0)
+if (qemuAssignDeviceMemoryAlias(vm->def, mem, -1) < 0)
 goto cleanup;

 if (virAsprintf(, "mem%s", mem->info.alias) < 0)
-- 
2.8.0

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


Re: [libvirt] [PATCH 05/18] domain_conf: split graphics xml parser into multiple functions

2016-04-06 Thread Ján Tomko
On Mon, Apr 04, 2016 at 03:20:22PM +0200, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina 
> ---
>  src/conf/domain_conf.c | 835 
> +++--
>  1 file changed, 453 insertions(+), 382 deletions(-)
> 

s/ParseXMLVnc/ParseXMLVNC/g
s/ParseXMLSdl/ParseXMLSDL/g
s/ParseXMLRdp/ParseXMLRDP/g

would IMO look nicer.

> +
> +if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) {
> +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +   _("unknown graphics device type '%s'"), type);
> +goto error;
> +}
> +
> +if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
> +goto error;
> +
> +switch (def->type) {

You could also cast the type to the enum, to annoy anyone adding a new
graphics type to add it to this switch too.

ACK

Jan

> +case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
> +if (virDomainGraphicsDefParseXMLVnc(def, node, flags) < 0)
> +goto error;
> +break;
> +case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
> +if (virDomainGraphicsDefParseXMLSdl(def, node) < 0)
> +goto error;
> +break;
> +case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
> +if (virDomainGraphicsDefParseXMLRdp(def, node, flags) < 0)
> +goto error;
> +break;
> +case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
> +if (virDomainGraphicsDefParseXMLDesktop(def, node) < 0)
> +goto error;
> +break;
> +case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
> +if (virDomainGraphicsDefParseXMLSpice(def, node, flags) < 0)
> +goto error;
> +break;
>  }
>  

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


Re: [libvirt] [RFC 6/6] qemu: Cache GIC capabilities

2016-04-06 Thread Andrea Bolognani
On Wed, 2016-03-30 at 16:29 -0400, John Ferlan wrote:
> On 03/21/2016 01:28 PM, Andrea Bolognani wrote:
> > diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> > index 64007f0..23c3740 100644
> > --- a/src/qemu/qemu_capabilities.c
> > +++ b/src/qemu/qemu_capabilities.c
> > @@ -2906,6 +2906,77 @@ virQEMUCapsLoadCache(virQEMUCapsPtr qemuCaps, const 
> > char *filename,
> >  }
> >  VIR_FREE(nodes);
> >  
> > +if ((n = virXPathNodeSet("./gic", ctxt, )) < 0) {
> > +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > +   _("failed to parse qemu capabilities gic"));
> > +goto cleanup;
> > +}
> > +if (n > 0) {
> > +unsigned int uintValue;
> > +bool boolValue;
> > +
> > +qemuCaps->ngicCapabilities = n;
> > +if (VIR_ALLOC_N(qemuCaps->gicCapabilities, n) < 0)
> > +goto cleanup;
> > +
> > +for (i = 0; i < n; i++) {
> > +virGICCapabilityPtr cap = >gicCapabilities[i];
> > +
> > +if (!(str = virXMLPropString(nodes[i], "version"))) {
> > +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > +   _("missing GIC version "
> > + "in QEMU capabilities cache"));
> > +goto cleanup;
> > +}
> > +if (str &&
> > +virStrToLong_ui(str, NULL, 10, ) < 0) {
> > +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > +   _("malformed GIC version "
> > + "in QEMU capabilities cache"));
> > +goto cleanup;
> > +}
> > +cap->version = uintValue;
> > +VIR_FREE(str);
> > +
> > +if (!(str = virXMLPropString(nodes[i], "kernel"))) {
> > +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > +   _("missing in-kernel GIC information "
> > + "in QEMU capabilities cache"));
> > +goto cleanup;
> > +}
> > +if (str &&
> > +!(boolValue = STREQ(str, "true")) &&
> > +STRNEQ(str, "false")) {
> > +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > +   _("malformed in-kernel GIC information "
> > + "in QEMU capabilities cache"));
> > +goto cleanup;
> > +}
> > +if (boolValue)
> > +cap->implementation |= VIR_GIC_IMPLEMENTATION_KERNEL;
> > +VIR_FREE(str);
> > +
> > +if (!(str = virXMLPropString(nodes[i], "emulated"))) {
> > +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > +   _("missing emulated GIC information "
> > + "in QEMU capabilities cache"));
> > +goto cleanup;
> > +}
> > +if (str &&
> > +!(boolValue = STREQ(str, "true")) &&
> > +STRNEQ(str, "false")) {
> > +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > +   _("malformed emulated GIC information "
> > + "in QEMU capabilities cache"));
> > +goto cleanup;
> > +}
> > +if (boolValue)
> > +cap->implementation |= VIR_GIC_IMPLEMENTATION_EMULATED;
> 
> Since these are processed as either/or in patch 5 based on virttype, I'm
> beginning to think perhaps you'd have :
> 
> 
> 
> but this works, I'm still trying to process the whole domaincaps code
> and what the use case would be. It looks like merely the output to
> domcapabilities. In which case, I'm wonder if printing the gic_version
> inside  would be sufficient.

I believe all of these were addressed in my previous comments.

Let me know if that was actually not the case :)

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

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

Re: [libvirt] [PATCH 04/18] domain_conf: cleanup virDomainGraphicsListensParseXML

2016-04-06 Thread Ján Tomko
On Mon, Apr 04, 2016 at 03:20:21PM +0200, Pavel Hrdina wrote:
> Refactor the listen parser to use only one loop.
> 
> Signed-off-by: Pavel Hrdina 
> ---
>  src/conf/domain_conf.c | 117 
> +
>  1 file changed, 50 insertions(+), 67 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index a0ef3d9..9d48d07 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c

>  
> +/* listen attribute of  is also supported by these,
> + * but must match the 'address' attribute of the first listen
> + * that is type='address' (if present) */
> +listenAddr = virXMLPropString(node, "listen");
> +if (listenAddr && !listenAddr[0])
> +VIR_FREE(listenAddr);
> +
> +if (STREQ_NULLABLE(address->address, listenAddr) < 0) {

This is dead code, since it expands to strcmp(a,b) == 0.

Drop the comparison against zero and use STRNEQ_NULLABLE instead.

Also, the check should only be done if address is non-NULL, for XMLs
with no  elements.

ACK with that fixed.

Jan

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


Re: [libvirt] [RFC 5/6] qemu: Fill in GIC capabilities

2016-04-06 Thread Andrea Bolognani
On Wed, 2016-03-30 at 16:12 -0400, John Ferlan wrote:
> On 03/21/2016 01:28 PM, Andrea Bolognani wrote:
> > +static int
> > +virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps,
> > +virDomainCapsPtr domCaps)
> > +{
> > +virDomainCapsFeatureGICPtr gic = >gic;
> > +size_t i;
> > +
> > +if (domCaps->arch != VIR_ARCH_ARMV7L &&
> > +domCaps->arch != VIR_ARCH_AARCH64)
> > +return 0;
> > +
> > +if (STRNEQ(domCaps->machine, "virt") &&
> > +!STRPREFIX(domCaps->machine, "virt-"))
> > +return 0;
> > +
> > +for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
> > +virGICCapabilityPtr cap = >gicCapabilities[i];
> > +
> > +if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM &&
> > +!(cap->implementation & VIR_GIC_IMPLEMENTATION_KERNEL))
> > +continue;
> > +
> > +if (domCaps->virttype == VIR_DOMAIN_VIRT_QEMU &&
> > +!(cap->implementation & VIR_GIC_IMPLEMENTATION_EMULATED))
> > +continue;
> 
> For these, patch 6 would need to be already in place I think if
> circumstances were "just right" (so to speak).

The feature is not really expected to work properly until the
entire series has been applied, right?

We can still shuffle patches around to implement proper caching
of the capabilities even before such capabilities are actually
filled in, but I don't think it's a blocker per se.

> > +
> > +gic->supported = true;
> > +VIR_DOMAIN_CAPS_ENUM_SET(gic->version,
> > + cap->version);
> 
> Can there be more than one?

Definitely! An example is hardware supporting both GIC v2
and GIC v3; another one is QEMU eventually implementing an
emulated GIC v3. In both cases we'll end up with

  

  
2
3
  

  

> How is that handled!

With a bit of magic, really ;)

Basically virDomainCapsEnumSet() packs enum values very
tightly, as if they were declared as flags to begin with,
and virDomainCapsFormat() later unpacks them and presents
them as above.

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

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

Re: [libvirt] [PATCH 01/18] tests: remove unwanted VIR_FREE of spice and vnc default listen

2016-04-06 Thread Ján Tomko
On Mon, Apr 04, 2016 at 03:20:18PM +0200, Pavel Hrdina wrote:
> After the test and qemu_process refactor now we can benefit from default
> listen address for spice and vnc in tests.
> 
> Signed-off-by: Pavel Hrdina 
> ---
>  tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args | 2 +-
>  tests/qemuxml2argvtest.c| 3 ---
>  2 files changed, 1 insertion(+), 4 deletions(-)
> 

ACK

Jan

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


Re: [libvirt] [PATCH 03/18] domain_conf: introduce virDomainGraphicsListensParseXML

2016-04-06 Thread Ján Tomko
On Mon, Apr 04, 2016 at 03:20:20PM +0200, Pavel Hrdina wrote:
> Move code, that parses graphics listens, to it's own function.

s/it's/its/

> 
> Signed-off-by: Pavel Hrdina 
> ---
>  src/conf/domain_conf.c | 79 
> ++
>  1 file changed, 47 insertions(+), 32 deletions(-)
> 

ACK

Jan

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


Re: [libvirt] [RFC 4/6] conf: Expose GIC capabilities

2016-04-06 Thread Andrea Bolognani
On Wed, 2016-03-30 at 16:10 -0400, John Ferlan wrote:
> > diff --git a/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml 
> > b/tests/domaincapsschemadata/domaincaps-
> > qemu_1.6.50-1.xml
> > index 37d2102..990661b 100644
> > --- a/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
> > +++ b/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
> > @@ -56,4 +56,7 @@
> >
> >  
> >
> > +  
> > +
> > +  
> >  
> 
> I first wondered why the XML file was modified, but later understood -
> sort of...

We will need more tests for the new feature, of course.

I wanted to gather feedback on the interface with the RFC
before I spent too much time testing or documenting it.

> Still not fully clear on how what this schema output should
> look like... For prior to 2.6 should it even be printed?  For 2.6 and
> beyond what would it look like?

There might be a case for not printing it, but we don't
perform such optimization for the rest of the information
that's part of domain capabilities, so I'm not sure
whether we should bother in this case.

Versions prior to 2.6, and 2.6 itself on non-ARM
architectures would yield

  

  

whereas 2.6 onward on ARM would yield something like

  

  
2
  

  

which mirrors exactly the type of  element the
user can expect to be able to use inside the 
element in the domain XML, eg.

  

  

or none at all.

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

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

Re: [libvirt] [PATCH v2] secret: Introduce virSecretGetSecretString

2016-04-06 Thread Ján Tomko
On Mon, Apr 04, 2016 at 10:19:58PM -0400, John Ferlan wrote:
> Commit id 'fb2bd208' essentially copied the qemuGetSecretString
> creating an libxlGetSecretString.  Rather than have multiple copies
> of the same code, create src/secret/secret_util.{c,h} files and
> place the common function in there.
> 
> Modify the the build in order to build the module as a library
> which is then pulled in by both the qemu and libxl drivers for
> usage from both qemu_command.c and libxl_conf.c
> 
> Signed-off-by: John Ferlan 
> ---
> 
> My Makefile.am skills are weak at best - not sure I got it totally
> right, but I think I'm at least close (it builds and links).
> 
>  po/POTFILES.in   |   1 +
>  src/Makefile.am  |  17 ++-
>  src/libvirt_private.syms |   4 ++
>  src/libxl/libxl_conf.c   |  82 +++-
>  src/qemu/qemu_command.c  |  87 --
>  src/secret/secret_util.c | 120 
> +++
>  src/secret/secret_util.h |  35 ++
>  7 files changed, 190 insertions(+), 156 deletions(-)
>  create mode 100644 src/secret/secret_util.c
>  create mode 100644 src/secret/secret_util.h
> 

ACK

Jan

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


Re: [libvirt] [PATCH 6/7] storage:dir: adapts .refreshVol .refreshPool for ploop volumes

2016-04-06 Thread Olga Krishtal

On 06/04/16 16:07, Ján Tomko wrote:

On Wed, Apr 06, 2016 at 03:57:17PM +0300, Olga Krishtal wrote:

On 06/04/16 15:11, Ján Tomko wrote:

On Wed, Apr 06, 2016 at 11:18:22AM +0300, Olga Krishtal wrote:

The thing is that if we changed the size, the content of root.hds and
had left the old DiskDeskriptor.xml - it becomes impossible to operate.
I mean that DiskDescriptor.xml stores this info - size, Celinders,
Sectors, and what is more important - all information about snapshot.
In the situation when we have uploaded previously snapshoted volume -
the content of volume and DiskDescriptor will be inconsistent.
And work upon such volume will be impossible.
But if you have any idea, where such refresh of DiskDescriptor.xml could
be done - I will be glad to know.

DiskDeskriptor should be changed at the same time as root.hds -
if libvirt does the resize/content change, it should refresh the XML as
part of the API that changes the volume.

Libvirt's pool refresh or vol refresh should only update libvirtd's
in-memory metadata to match the on-disk state.

DiskDescriptor.xml content is based on root.hsd - ploop
restore-desciptor uses root.hds header.
  From this point of view I just copy the info from root.hds yo DD.xml


If the on-disk state was left inconsistent by some other application,
it's a problem of that application. I don't think libvirt should be
working around that.

Jan

But what about the uploadVol. As I understand volume ulpload is
asynchronous operation - I mean,
that virStorageVolUpload will returned before the content will be updated:
   if (virStorageVolUpload(vol, st, offset, length, 0) < 0) { --
returned from ulpoad, but I can not generate new DiskDeskriptor.xml it
is too early. I need volume with new content.
  vshError(ctl, _("cannot upload to volume %s"), name);
  goto cleanup;
  }

  if (virStreamSendAll(st, cmdVolUploadSource, ) < 0) { - I
can do it. Volume is ready to use.
  vshError(ctl, _("cannot send data to volume %s"), name);
  goto cleanup;
  }
I

storageVolUpload registers virStorageVolFDStreamCloseCb as the callback
that is executed after the volume has finished uploading.
The virStorageVolPoolRefreshThread is only called by
virStorageVolFDStreamCloseCb and looks like it could regenerate
DiskDeskriptor.xml before refreshing the pool.

Jan

Ok, thanks. I'll try to do it.
I have one more question:  we have ploop volume, the xml that describing 
the vz containers usually looks like:


 
We do not use disk, when we create the ct.
I want to add new type 'volume'.
This will add the possibility to use the volume as the source for ct 
root directory.

It will look smth like:

 

Would you be so kind to think it over: do you like such an idea.

I have look through code - it is also possible for lxc containers to use 
filesystem upon volume.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 6/7] storage:dir: adapts .refreshVol .refreshPool for ploop volumes

2016-04-06 Thread Ján Tomko
On Wed, Apr 06, 2016 at 03:57:17PM +0300, Olga Krishtal wrote:
> On 06/04/16 15:11, Ján Tomko wrote:
> > On Wed, Apr 06, 2016 at 11:18:22AM +0300, Olga Krishtal wrote:
> >> The thing is that if we changed the size, the content of root.hds and
> >> had left the old DiskDeskriptor.xml - it becomes impossible to operate.
> >> I mean that DiskDescriptor.xml stores this info - size, Celinders,
> >> Sectors, and what is more important - all information about snapshot.
> >> In the situation when we have uploaded previously snapshoted volume -
> >> the content of volume and DiskDescriptor will be inconsistent.
> >> And work upon such volume will be impossible.
> >> But if you have any idea, where such refresh of DiskDescriptor.xml could
> >> be done - I will be glad to know.
> > DiskDeskriptor should be changed at the same time as root.hds -
> > if libvirt does the resize/content change, it should refresh the XML as
> > part of the API that changes the volume.
> >
> > Libvirt's pool refresh or vol refresh should only update libvirtd's
> > in-memory metadata to match the on-disk state.
> DiskDescriptor.xml content is based on root.hsd - ploop 
> restore-desciptor uses root.hds header.
>  From this point of view I just copy the info from root.hds yo DD.xml
> 
> >
> > If the on-disk state was left inconsistent by some other application,
> > it's a problem of that application. I don't think libvirt should be
> > working around that.
> >
> > Jan
> But what about the uploadVol. As I understand volume ulpload is 
> asynchronous operation - I mean,
> that virStorageVolUpload will returned before the content will be updated:
>   if (virStorageVolUpload(vol, st, offset, length, 0) < 0) { -- 
> returned from ulpoad, but I can not generate new DiskDeskriptor.xml it 
> is too early. I need volume with new content.
>  vshError(ctl, _("cannot upload to volume %s"), name);
>  goto cleanup;
>  }
> 
>  if (virStreamSendAll(st, cmdVolUploadSource, ) < 0) { - I 
> can do it. Volume is ready to use.
>  vshError(ctl, _("cannot send data to volume %s"), name);
>  goto cleanup;
>  }
> I

storageVolUpload registers virStorageVolFDStreamCloseCb as the callback
that is executed after the volume has finished uploading.
The virStorageVolPoolRefreshThread is only called by
virStorageVolFDStreamCloseCb and looks like it could regenerate
DiskDeskriptor.xml before refreshing the pool.

Jan

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


Re: [libvirt] [PATCH] virt-admin: get rid of LIBVIRT_DEFAULT_ADMIN_URI env var

2016-04-06 Thread Erik Skultety
On 06/04/16 15:00, Ján Tomko wrote:
> There is a LIBVIRT_ADMIN_DEFAULT_URI environment variable
> which is honored by virAdmConnectOpen and documented
> in the virt-admin man page.
> 
> LIBVIRT_DEFAULT_ADMIN_URI is undocumented and this is its
> only occurrence.
> ---
>  tools/virt-admin.c | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/tools/virt-admin.c b/tools/virt-admin.c
> index edb8690..f0a49a3 100644
> --- a/tools/virt-admin.c
> +++ b/tools/virt-admin.c
> @@ -670,7 +670,6 @@ main(int argc, char **argv)
>  {
>  vshControl _ctl, *ctl = &_ctl;
>  vshAdmControl virtAdminCtl;
> -const char *defaultConn;
>  bool ret = true;
>  
>  memset(ctl, 0, sizeof(vshControl));
> @@ -719,9 +718,6 @@ main(int argc, char **argv)
>  
>  virFileActivateDirOverride(argv[0]);
>  
> -if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI")))
> -ctl->connname = vshStrdup(ctl, defaultConn);
> -
>  if (!vshInit(ctl, cmdGroups, NULL))
>  exit(EXIT_FAILURE);
>  
> 

ACK

Erik

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

[libvirt] [PATCH] virt-admin: get rid of LIBVIRT_DEFAULT_ADMIN_URI env var

2016-04-06 Thread Ján Tomko
There is a LIBVIRT_ADMIN_DEFAULT_URI environment variable
which is honored by virAdmConnectOpen and documented
in the virt-admin man page.

LIBVIRT_DEFAULT_ADMIN_URI is undocumented and this is its
only occurrence.
---
 tools/virt-admin.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index edb8690..f0a49a3 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -670,7 +670,6 @@ main(int argc, char **argv)
 {
 vshControl _ctl, *ctl = &_ctl;
 vshAdmControl virtAdminCtl;
-const char *defaultConn;
 bool ret = true;
 
 memset(ctl, 0, sizeof(vshControl));
@@ -719,9 +718,6 @@ main(int argc, char **argv)
 
 virFileActivateDirOverride(argv[0]);
 
-if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI")))
-ctl->connname = vshStrdup(ctl, defaultConn);
-
 if (!vshInit(ctl, cmdGroups, NULL))
 exit(EXIT_FAILURE);
 
-- 
2.4.10

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


Re: [libvirt] [PATCH 6/7] storage:dir: adapts .refreshVol .refreshPool for ploop volumes

2016-04-06 Thread Olga Krishtal

On 06/04/16 15:11, Ján Tomko wrote:

On Wed, Apr 06, 2016 at 11:18:22AM +0300, Olga Krishtal wrote:

On 05/04/16 18:01, Ján Tomko wrote:

On Mon, Mar 14, 2016 at 07:00:39PM +0300, Olga Krishtal wrote:

Refreshes meta-information such as allocation, capacity, format, etc.
Ploop volumes differ from other volume types. Path to volume is the path
to directory with image file root.hds and DiskDescriptor.xml.
https://openvz.org/Ploop/format
Due to this fact, operations of opening the volume have to be done once
again. get the information.

To decide whether the given volume is ploops one, it is necessary to check
the presence of root.hds and DiskDescriptor.xml files in volumes' directory.
Only in this case the volume can be manipulated as the ploops one.
Such strategy helps us to resolve problems that might occure, when we
upload some other volume type from ploop source.

Signed-off-by: Olga Krishtal 
---
   src/storage/storage_backend.c| 62 --
   src/storage/storage_backend.h|  5 
   src/storage/storage_backend_fs.c | 64 
+---
   src/util/virstoragefile.c|  7 +++--
   4 files changed, 129 insertions(+), 9 deletions(-)

@@ -69,6 +109,7 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
   int fd = -1;
   int ret = -1;
   int rc;
+int format = VIR_STORAGE_FILE_AUTO;
   virStorageSourcePtr meta = NULL;
   struct stat sb;
   
@@ -84,14 +125,26 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,

   goto cleanup;
   
   if (S_ISDIR(sb.st_mode)) {

-target->format = VIR_STORAGE_FILE_DIR;
-ret = 0;
-goto cleanup;
+if (virStorageBackendIsPloopDir(target->path)) {
+if (virStorageBackendRedoPloopUpdate(target, , ,
+ 
VIR_STORAGE_VOL_FS_PROBE_FLAGS)
+< 0)
+goto cleanup;
+/* Refresh information stored in DiskDescriptor.xml according
+ * to ploop image file content.*/
+if (virStorageBackendPloopRestoreDesc(target->path) < 0)
+goto cleanup;

Probing a volume should not change its contents - libvirt should only
refresh this XML when it changed the volume.

The rest looks good to me.

Jan

The thing is that if we changed the size, the content of root.hds and
had left the old DiskDeskriptor.xml - it becomes impossible to operate.
I mean that DiskDescriptor.xml stores this info - size, Celinders,
Sectors, and what is more important - all information about snapshot.
In the situation when we have uploaded previously snapshoted volume -
the content of volume and DiskDescriptor will be inconsistent.
And work upon such volume will be impossible.
But if you have any idea, where such refresh of DiskDescriptor.xml could
be done - I will be glad to know.

DiskDeskriptor should be changed at the same time as root.hds -
if libvirt does the resize/content change, it should refresh the XML as
part of the API that changes the volume.

Libvirt's pool refresh or vol refresh should only update libvirtd's
in-memory metadata to match the on-disk state.
DiskDescriptor.xml content is based on root.hsd - ploop 
restore-desciptor uses root.hds header.

From this point of view I just copy the info from root.hds yo DD.xml



If the on-disk state was left inconsistent by some other application,
it's a problem of that application. I don't think libvirt should be
working around that.

Jan
But what about the uploadVol. As I understand volume ulpload is 
asynchronous operation - I mean,

that virStorageVolUpload will returned before the content will be updated:
 if (virStorageVolUpload(vol, st, offset, length, 0) < 0) { -- 
returned from ulpoad, but I can not generate new DiskDeskriptor.xml it 
is too early. I need volume with new content.

vshError(ctl, _("cannot upload to volume %s"), name);
goto cleanup;
}

if (virStreamSendAll(st, cmdVolUploadSource, ) < 0) { - I 
can do it. Volume is ready to use.

vshError(ctl, _("cannot send data to volume %s"), name);
goto cleanup;
}
I

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


Re: [libvirt] [PATCH 6/7] storage:dir: adapts .refreshVol .refreshPool for ploop volumes

2016-04-06 Thread Ján Tomko
On Wed, Apr 06, 2016 at 11:18:22AM +0300, Olga Krishtal wrote:
> On 05/04/16 18:01, Ján Tomko wrote:
> > On Mon, Mar 14, 2016 at 07:00:39PM +0300, Olga Krishtal wrote:
> >> Refreshes meta-information such as allocation, capacity, format, etc.
> >> Ploop volumes differ from other volume types. Path to volume is the path
> >> to directory with image file root.hds and DiskDescriptor.xml.
> >> https://openvz.org/Ploop/format
> >> Due to this fact, operations of opening the volume have to be done once
> >> again. get the information.
> >>
> >> To decide whether the given volume is ploops one, it is necessary to check
> >> the presence of root.hds and DiskDescriptor.xml files in volumes' 
> >> directory.
> >> Only in this case the volume can be manipulated as the ploops one.
> >> Such strategy helps us to resolve problems that might occure, when we
> >> upload some other volume type from ploop source.
> >>
> >> Signed-off-by: Olga Krishtal 
> >> ---
> >>   src/storage/storage_backend.c| 62 
> >> --
> >>   src/storage/storage_backend.h|  5 
> >>   src/storage/storage_backend_fs.c | 64 
> >> +---
> >>   src/util/virstoragefile.c|  7 +++--
> >>   4 files changed, 129 insertions(+), 9 deletions(-)
> >>
> >> @@ -69,6 +109,7 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
> >>   int fd = -1;
> >>   int ret = -1;
> >>   int rc;
> >> +int format = VIR_STORAGE_FILE_AUTO;
> >>   virStorageSourcePtr meta = NULL;
> >>   struct stat sb;
> >>   
> >> @@ -84,14 +125,26 @@ virStorageBackendProbeTarget(virStorageSourcePtr 
> >> target,
> >>   goto cleanup;
> >>   
> >>   if (S_ISDIR(sb.st_mode)) {
> >> -target->format = VIR_STORAGE_FILE_DIR;
> >> -ret = 0;
> >> -goto cleanup;
> >> +if (virStorageBackendIsPloopDir(target->path)) {
> >> +if (virStorageBackendRedoPloopUpdate(target, , ,
> >> + 
> >> VIR_STORAGE_VOL_FS_PROBE_FLAGS)
> >> +< 0)
> >> +goto cleanup;
> >
> >> +/* Refresh information stored in DiskDescriptor.xml according
> >> + * to ploop image file content.*/
> >> +if (virStorageBackendPloopRestoreDesc(target->path) < 0)
> >> +goto cleanup;
> > Probing a volume should not change its contents - libvirt should only
> > refresh this XML when it changed the volume.
> >
> > The rest looks good to me.
> >
> > Jan
> The thing is that if we changed the size, the content of root.hds and 
> had left the old DiskDeskriptor.xml - it becomes impossible to operate.
> I mean that DiskDescriptor.xml stores this info - size, Celinders, 
> Sectors, and what is more important - all information about snapshot.
> In the situation when we have uploaded previously snapshoted volume - 
> the content of volume and DiskDescriptor will be inconsistent.
> And work upon such volume will be impossible.
> But if you have any idea, where such refresh of DiskDescriptor.xml could 
> be done - I will be glad to know.

DiskDeskriptor should be changed at the same time as root.hds -
if libvirt does the resize/content change, it should refresh the XML as
part of the API that changes the volume.

Libvirt's pool refresh or vol refresh should only update libvirtd's
in-memory metadata to match the on-disk state.

If the on-disk state was left inconsistent by some other application,
it's a problem of that application. I don't think libvirt should be
working around that.

Jan

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


Re: [libvirt] [RFC 3/6] schema: Validate GIC capabilities

2016-04-06 Thread Andrea Bolognani
On Wed, 2016-03-30 at 15:36 -0400, John Ferlan wrote:
> On 03/21/2016 01:28 PM, Andrea Bolognani wrote:
> > 
> > We need to expose GIC capabilities in the domain capabilities
> > XML: update the schema to validate documents that contain the
> > new information.
> > ---
> >  docs/schemas/domaincaps.rng | 18 ++
> >  1 file changed, 18 insertions(+)
>
> I think patches 3 and 4 should be combined and 5 is not too far behind!

I usually try to keep patches as small and self-contained
as possible, provided doing so doesn't break the check and
syntax-check targets and the changes represent some sort
of meaningful unit.

The balance is of course very hard to get right, so I fully
expect other people to disagree with the way I've orgainzed
them :)

If you feel like squashing a bunch of commits together will
help you during review, then I'll definitely do that.

> "features" is fairly generic for something so specific, but I'm not sure
> I have other great suggestions for a "domain capabilities" section that
> has path, domain, machine, arch, vcpu, os, and devices already. It is a
> cpu interrupt controller - so maybe it's an "interrupt" device.

In the domain XML, the  element will be a child of the
 element, so this name seemed like a natural choice.

The documentation[1] claims

  The available features can be found by asking for the
  capabilities XML

so it will have to be updated, because in this case the
information would be in the *domain* capabilities and not in
the *host* capabilities. At least the name of the containing
element will be the same.

> When the XML is created what is it going to look like?
> 
>  
>
>  
>2
>3
>  
>
>  

Yes, it's going to look exactly like that. As you mentioned
later on, the documentation will have to contain examples.

> Is putting it after "" a back compat thing? I guess I would
> think it was more logical after the  or even more radical as part
> of it:
> 
>   armv7l

Users should not be relying on the order of elements anyway,
so if we want it to appear right after  I guess there's
nothing stopping us from doing so.

Merging this into  would not work, because you have to
report information about more than a single version...

As for the other attributes, the reason why this is in domain
capabilities in the first place is because that way the user
doesn't need to worry about the difference between 'kernel'
and 'emulated': in the capabilities for a kvm domain we will
only report the GIC versions that are implemented in kernel,
whereas for a qemu domain we will only report those that can
be emulated. The user only needs to look at the XML and pick
one of the versions listed.

> Additionally, docs/formatdomaincaps.html.in will need an update to
> describe this...

Absolutely.

> And then there's virsh.pod - not sure if it needs an update...

Don't think so.

Cheers.


[1] https://libvirt.org/formatdomain.html#elementsFeatures
-- 
Andrea Bolognani
Software Engineer - Virtualization Team

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

Re: [libvirt] [PATCH 3/3] libvirt-admin: do not crash on URI without a scheme

2016-04-06 Thread Erik Skultety
On 06/04/16 10:51, Ján Tomko wrote:
> ---
>  src/libvirt-admin.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
> index 54af90c..6577c87 100644
> --- a/src/libvirt-admin.c
> +++ b/src/libvirt-admin.c
> @@ -121,10 +121,10 @@ getSocketPath(virURIPtr uri)
>  }
>  
>  if (!sock_path) {
> -if (STRNEQ(uri->scheme, "libvirtd")) {
> +if (STRNEQ_NULLABLE(uri->scheme, "libvirtd")) {
>  virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> _("Unsupported URI scheme '%s'"),
> -   uri->scheme);
> +   NULLSTR(uri->scheme));
>  goto error;
>  }
>  if (STREQ_NULLABLE(uri->path, "/system")) {
> 

ACK, we should also check the URI form if user provided socket path as
well, I added that one on my TODO list.

Erik

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

[libvirt] [PATCH 1/3] vz: simplify getting strings from vzsdk

2016-04-06 Thread Nikolay Shirokovskiy
SDK does not allocate memory when getting strings thus we
need to call every function that returns string twice.
First to obtain string length, second to obtain string
itself. It is tedious. Let's move this logic into macro
that generates wrapper. Luckily all functions we need
to wrap have 3 parameters: some handle, pointer to
string and string length.

Signed-off-by: Nikolay Shirokovskiy 
---
 src/vz/vz_sdk.c | 167 +++-
 1 file changed, 56 insertions(+), 111 deletions(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 8691887..0d853d0 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -201,6 +201,44 @@ waitJobHelper(PRL_HANDLE job, unsigned int timeout,
 waitJobHelper(job, JOB_INFINIT_WAIT_TIMEOUT, __FILE__,  \
   __FUNCTION__, __LINE__)
 
+#define PRLSDK_GENERATE_STRING_GETTER(FUN)  \
+static char*\
+FUN ## _Alloc(PRL_HANDLE handle)\
+{   \
+PRL_RESULT pret;\
+PRL_UINT32 buflen = 0;  \
+char *str = NULL;   \
+\
+pret = FUN(handle, NULL, );  \
+prlsdkCheckRetGoto(pret, error);\
+\
+if (VIR_ALLOC_N(str, buflen) < 0)   \
+goto error; \
+\
+pret = FUN(handle, str, );   \
+prlsdkCheckRetGoto(pret, error);\
+\
+return str; \
+\
+ error: \
+VIR_FREE(str);  \
+return NULL;\
+}
+
+PRLSDK_GENERATE_STRING_GETTER(PrlResult_GetParamAsString)
+
+PRLSDK_GENERATE_STRING_GETTER(PrlVmCfg_GetName)
+PRLSDK_GENERATE_STRING_GETTER(PrlVmCfg_GetVNCHostName)
+PRLSDK_GENERATE_STRING_GETTER(PrlVmCfg_GetCpuMask)
+PRLSDK_GENERATE_STRING_GETTER(PrlVmCfg_GetHomePath)
+
+PRLSDK_GENERATE_STRING_GETTER(PrlVmDev_GetFriendlyName)
+PRLSDK_GENERATE_STRING_GETTER(PrlVmDev_GetImagePath)
+
+PRLSDK_GENERATE_STRING_GETTER(PrlVmDevHd_GetMountPoint)
+
+PRLSDK_GENERATE_STRING_GETTER(PrlVmDevNet_GetHostInterfaceName)
+PRLSDK_GENERATE_STRING_GETTER(PrlVmDevNet_GetVirtualNetworkId)
 
 int
 prlsdkInit(void)
@@ -346,19 +384,8 @@ prlsdkGetDomainIds(PRL_HANDLE sdkdom,
 PRL_UINT32 len;
 PRL_RESULT pret;
 
-if (name) {
-len = 0;
-*name = NULL;
-/* get name length */
-pret = PrlVmCfg_GetName(sdkdom, NULL, );
-prlsdkCheckRetGoto(pret, error);
-
-if (VIR_ALLOC_N(*name, len) < 0)
-goto error;
-
-pret = PrlVmCfg_GetName(sdkdom, *name, );
-prlsdkCheckRetGoto(pret, error);
-}
+if (name && !(*name = PrlVmCfg_GetName_Alloc(sdkdom)))
+goto error;
 
 if (uuid) {
 len = sizeof(uuidstr);
@@ -465,7 +492,6 @@ prlsdkGetDiskInfo(vzConnPtr privconn,
   bool isCt)
 {
 char *buf = NULL;
-PRL_UINT32 buflen = 0;
 PRL_RESULT pret;
 PRL_UINT32 emulatedType;
 PRL_UINT32 ifType;
@@ -497,15 +523,9 @@ prlsdkGetDiskInfo(vzConnPtr privconn,
 disk->device = VIR_DOMAIN_DISK_DEVICE_DISK;
 }
 
-pret = PrlVmDev_GetFriendlyName(prldisk, NULL, );
-prlsdkCheckRetGoto(pret, cleanup);
-
-if (VIR_ALLOC_N(buf, buflen) < 0)
+if (!(buf = PrlVmDev_GetFriendlyName_Alloc(prldisk)))
 goto cleanup;
 
-pret = PrlVmDev_GetFriendlyName(prldisk, buf, );
-prlsdkCheckRetGoto(pret, cleanup);
-
 if (virDomainDiskSetSource(disk, buf) < 0)
 goto cleanup;
 
@@ -567,8 +587,6 @@ prlsdkGetFSInfo(PRL_HANDLE prldisk,
 virDomainFSDefPtr fs)
 {
 char *buf = NULL;
-PRL_UINT32 buflen = 0;
-PRL_RESULT pret;
 int ret = -1;
 
 fs->type = VIR_DOMAIN_FS_TYPE_FILE;
@@ -580,27 +598,15 @@ prlsdkGetFSInfo(PRL_HANDLE prldisk,
 fs->readonly = false;
 fs->symlinksResolved = false;
 
-pret = PrlVmDev_GetImagePath(prldisk, NULL, );
-prlsdkCheckRetGoto(pret, cleanup);
-
-if (VIR_ALLOC_N(buf, buflen) < 0)
+if (!(buf = PrlVmDev_GetImagePath_Alloc(prldisk)))
 goto cleanup;
 
-pret = PrlVmDev_GetImagePath(prldisk, buf, );
-prlsdkCheckRetGoto(pret, cleanup);
-
 fs->src = buf;
 buf = NULL;
 
-pret = PrlVmDevHd_GetMountPoint(prldisk, NULL, );
-prlsdkCheckRetGoto(pret, cleanup);
-
-if (VIR_ALLOC_N(buf, buflen) < 0)
+if (!(buf = PrlVmDevHd_GetMountPoint_Alloc(prldisk)))
 goto cleanup;
 
-pret = PrlVmDevHd_GetMountPoint(prldisk, buf, );
-prlsdkCheckRetGoto(pret, cleanup);
-
 

[libvirt] [PATCH 3/3] vz: simplify getting fixed size strings from vzsdk

2016-04-06 Thread Nikolay Shirokovskiy
Getting strings of predictable length from vz SDK is still
not convinient. We don't need length feedback from sdk
function but still need to allocate and set length variable
just to be able to call the function. Let's introduce another
macro that generates suitable wrapper in this case.

Signed-off-by: Nikolay Shirokovskiy 
---
 src/vz/vz_sdk.c | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 443f753..1200b0d 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -225,12 +225,24 @@ FUN ## _Alloc(PRL_HANDLE handle)\
 return NULL;\
 }
 
+#define PRLSDK_GENERATE_STRING_GETTER_FIXED(FUN)\
+static PRL_RESULT   \
+FUN ## _Fixed(PRL_HANDLE handle, char *buf, size_t size)\
+{   \
+PRL_UINT32 buflen = size;   \
+\
+return FUN(handle, buf, );   \
+}
+
 PRLSDK_GENERATE_STRING_GETTER(PrlResult_GetParamAsString)
 
+PRLSDK_GENERATE_STRING_GETTER_FIXED(PrlEvent_GetIssuerId)
+
 PRLSDK_GENERATE_STRING_GETTER(PrlVmCfg_GetName)
 PRLSDK_GENERATE_STRING_GETTER(PrlVmCfg_GetVNCHostName)
 PRLSDK_GENERATE_STRING_GETTER(PrlVmCfg_GetCpuMask)
 PRLSDK_GENERATE_STRING_GETTER(PrlVmCfg_GetHomePath)
+PRLSDK_GENERATE_STRING_GETTER_FIXED(PrlVmCfg_GetUuid)
 
 PRLSDK_GENERATE_STRING_GETTER(PrlVmDev_GetFriendlyName)
 PRLSDK_GENERATE_STRING_GETTER(PrlVmDev_GetImagePath)
@@ -239,6 +251,8 @@ PRLSDK_GENERATE_STRING_GETTER(PrlVmDevHd_GetMountPoint)
 
 PRLSDK_GENERATE_STRING_GETTER(PrlVmDevNet_GetHostInterfaceName)
 PRLSDK_GENERATE_STRING_GETTER(PrlVmDevNet_GetVirtualNetworkId)
+PRLSDK_GENERATE_STRING_GETTER_FIXED(PrlVmDevNet_GetMacAddressCanonical)
+PRLSDK_GENERATE_STRING_GETTER_FIXED(PrlVmDevNet_GetMacAddress)
 
 int
 prlsdkInit(void)
@@ -381,15 +395,13 @@ prlsdkGetDomainIds(PRL_HANDLE sdkdom,
unsigned char *uuid)
 {
 char uuidstr[VIR_UUID_STRING_BUFLEN + 2];
-PRL_UINT32 len;
 PRL_RESULT pret;
 
 if (name && !(*name = PrlVmCfg_GetName_Alloc(sdkdom)))
 goto error;
 
 if (uuid) {
-len = sizeof(uuidstr);
-pret = PrlVmCfg_GetUuid(sdkdom, uuidstr, );
+pret = PrlVmCfg_GetUuid_Fixed(sdkdom, uuidstr, sizeof(uuidstr));
 prlsdkCheckRetGoto(pret, error);
 
 if (prlsdkUUIDParse(uuidstr, uuid) < 0) {
@@ -720,7 +732,6 @@ static int
 prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt)
 {
 char macstr[VIR_MAC_STRING_BUFLEN];
-PRL_UINT32 buflen;
 PRL_UINT32 netAdapterIndex;
 PRL_UINT32 emulatedType;
 PRL_RESULT pret;
@@ -748,8 +759,8 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
 return 0;
 }
 
-buflen = ARRAY_CARDINALITY(macstr);
-pret = PrlVmDevNet_GetMacAddressCanonical(netAdapter, macstr, );
+pret = PrlVmDevNet_GetMacAddressCanonical_Fixed(netAdapter, macstr,
+sizeof(macstr));
 prlsdkCheckRetGoto(pret, cleanup);
 
 if (virMacAddrParse(macstr, >mac) < 0)
@@ -1628,7 +1639,6 @@ prlsdkEventsHandler(PRL_HANDLE prlEvent, PRL_VOID_PTR 
opaque)
 PRL_HANDLE_TYPE handleType;
 char uuidstr[VIR_UUID_STRING_BUFLEN + 2];
 unsigned char uuid[VIR_UUID_BUFLEN];
-PRL_UINT32 bufsize = ARRAY_CARDINALITY(uuidstr);
 PRL_EVENT_TYPE prlEventType;
 
 pret = PrlHandle_GetType(prlEvent, );
@@ -1641,7 +1651,7 @@ prlsdkEventsHandler(PRL_HANDLE prlEvent, PRL_VOID_PTR 
opaque)
 if (privconn == NULL)
 goto cleanup;
 
-pret = PrlEvent_GetIssuerId(prlEvent, uuidstr, );
+pret = PrlEvent_GetIssuerId_Fixed(prlEvent, uuidstr, sizeof(uuidstr));
 prlsdkCheckRetGoto(pret, cleanup);
 
 pret = PrlEvent_GetType(prlEvent, );
@@ -2863,7 +2873,6 @@ prlsdkFindNetByMAC(PRL_HANDLE sdkdom, virMacAddrPtr mac)
 PRL_UINT32 adaptersCount;
 PRL_UINT32 i;
 PRL_HANDLE adapter = PRL_INVALID_HANDLE;
-PRL_UINT32 len;
 char adapterMac[PRL_MAC_STRING_BUFNAME];
 char expectedMac[PRL_MAC_STRING_BUFNAME];
 
@@ -2876,12 +2885,11 @@ prlsdkFindNetByMAC(PRL_HANDLE sdkdom, virMacAddrPtr mac)
 pret = PrlVmCfg_GetNetAdapter(sdkdom, i, );
 prlsdkCheckRetGoto(pret, cleanup);
 
-len = sizeof(adapterMac);
-memset(adapterMac, 0, sizeof(adapterMac));
-pret = PrlVmDevNet_GetMacAddress(adapter, adapterMac, );
+pret = PrlVmDevNet_GetMacAddress_Fixed(adapter, adapterMac,
+   sizeof(adapterMac));
 prlsdkCheckRetGoto(pret, cleanup);
 
-if (memcmp(adapterMac, expectedMac, PRL_MAC_STRING_BUFNAME) == 0)
+if (STREQ(adapterMac, expectedMac))
 return adapter;
 
 

[libvirt] [PATCH 0/3] vz: simplify getting strings from vz sdk

2016-04-06 Thread Nikolay Shirokovskiy
Nikolay Shirokovskiy (3):
  vz: simplify getting strings from vzsdk
  vz: fix memory leak
  vz: simplify getting fixed size strings from vzsdk

 src/vz/vz_sdk.c | 203 +---
 1 file changed, 77 insertions(+), 126 deletions(-)

-- 
1.8.3.1

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


[libvirt] [PATCH 2/3] vz: fix memory leak

2016-04-06 Thread Nikolay Shirokovskiy
we don't need to allocate mastr at all as it is array
and already have the the space it needs.

Signed-off-by: Nikolay Shirokovskiy 
---
 src/vz/vz_sdk.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 0d853d0..443f753 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -749,8 +749,6 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
 }
 
 buflen = ARRAY_CARDINALITY(macstr);
-if (VIR_ALLOC_N(macstr, buflen))
-goto cleanup;
 pret = PrlVmDevNet_GetMacAddressCanonical(netAdapter, macstr, );
 prlsdkCheckRetGoto(pret, cleanup);
 
-- 
1.8.3.1

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


Re: [libvirt] [PATCH] spec: Include KVM support on RHEL 7 ppc64 and newer

2016-04-06 Thread Andrea Bolognani
On Wed, 2016-04-06 at 13:24 +0200, Jiri Denemark wrote:
> > So can I amend the commit with your proposed version
> > and push it?
> 
> Yeah, thanks.

Done, thanks :)

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

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

Re: [libvirt] [PATCH] spec: Include KVM support on RHEL 7 ppc64 and newer

2016-04-06 Thread Jiri Denemark
On Wed, Apr 06, 2016 at 13:21:03 +0200, Andrea Bolognani wrote:
> On Wed, 2016-04-06 at 12:17 +0200, Jiri Denemark wrote:
> > > diff --git a/libvirt.spec.in b/libvirt.spec.in
> > > index 03e2438..fdea12a 100644
> > > --- a/libvirt.spec.in
> > > +++ b/libvirt.spec.in
> > > @@ -77,7 +77,11 @@
> > >  
> > >  %if 0%{?rhel}
> > >  %define with_qemu_tcg 0
> > > -%define qemu_kvm_arches x86_64
> > > +%if 0%{?rhel} >= 7
> > > +%define qemu_kvm_arches x86_64 %{power64}
> > > +%else
> > > +%define qemu_kvm_arches x86_64
> > > +%endif
> > >  %endif
> > >  
> > >  %ifarch %{qemu_kvm_arches}
> > 
> >  %if 0%{?rhel}
> >  %define with_qemu_tcg 0
> >  %define qemu_kvm_arches x86_64
> > +%if 0%{?rhel} >= 7
> > +%define qemu_kvm_arches x86_64 %{power64}
> > +%endif
> >  %endif
> >  
> >  %ifarch %{qemu_kvm_arches}
> > 
> > Would be better since it makes adding new releases easier. See, e.g.,
> > how it looks nice and clear for fedora:
> > 
> > %if 0%{?fedora}
> > %if 0%{?fedora} < 16
> > # Fedora doesn't have any QEMU on ppc64 until FC16 - only ppc
> > # I think F17 is the first release with the power64 macro
> > %ifarch ppc64
> > %define with_qemu_tcg 0
> > %endif
> > %endif
> > %if 0%{?fedora} >= 18
> > %define qemu_kvm_arches %{ix86} x86_64 %{power64} s390x
> > %endif
> > %if 0%{?fedora} >= 20
> > %define qemu_kvm_arches %{ix86} x86_64 %{power64} s390x %{arm} 
> > aarch64
> > %endif
> > %endif
> 
> Yeah, it does look better.
> 
> So can I amend the commit with your proposed version
> and push it?

Yeah, thanks.

Jirka

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


Re: [libvirt] [PATCH] libxl: libxl_domain_create_restore has an extra argument

2016-04-06 Thread Wei Liu
On Tue, Apr 05, 2016 at 04:12:57PM +0100, Ian Jackson wrote:
> Wei Liu writes ("Re: [PATCH] libxl: libxl_domain_create_restore has an extra 
> argument"):
> > CC Jim as well
> > 
> > On Tue, Apr 05, 2016 at 03:20:12PM +0100, Wei Liu wrote:
> > > In the latest libxenlight code, libxl_domain_create_restore accepts a
> > > new argument. Update libvirt's libxl driver for that. Use the macro
> > > provided by libxenlight to detect which version should be used.
> > > 
> > > The new parameter (send_back_fd) is set to -1 because libvirt provides
> > > no such fd.
> ...
> > > -#ifdef LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS
> > > +#if defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD)
> > > +params.checkpointed_stream = 0;
> > > +ret = libxl_domain_create_restore(cfg->ctx, _config, ,
> > > +  restore_fd, -1, , NULL,
> > > +  _console_how);
> > > +#elif defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS)
> > >  params.checkpointed_stream = 0;
> > >  ret = libxl_domain_create_restore(cfg->ctx, _config, ,
> > >restore_fd, , NULL,
> 
> Another approach would be 
> 
>  ret = libxl_domain_create_restore(cfg->ctx, _config, ,
>restore_fd,
> #ifdef LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD
>-1,
> #endif
> #ifdef LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS
>,
> #endif
>NULL, _console_how);
> 
> But which to choose is a matter of taste.
> 

I merely followed the existing style. Let's keep it that way for now.

Wei.

> Ian.

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


Re: [libvirt] [PATCH] spec: Include KVM support on RHEL 7 ppc64 and newer

2016-04-06 Thread Andrea Bolognani
On Wed, 2016-04-06 at 12:17 +0200, Jiri Denemark wrote:
> > diff --git a/libvirt.spec.in b/libvirt.spec.in
> > index 03e2438..fdea12a 100644
> > --- a/libvirt.spec.in
> > +++ b/libvirt.spec.in
> > @@ -77,7 +77,11 @@
> >  
> >  %if 0%{?rhel}
> >  %define with_qemu_tcg 0
> > -%define qemu_kvm_arches x86_64
> > +%if 0%{?rhel} >= 7
> > +%define qemu_kvm_arches x86_64 %{power64}
> > +%else
> > +%define qemu_kvm_arches x86_64
> > +%endif
> >  %endif
> >  
> >  %ifarch %{qemu_kvm_arches}
> 
>  %if 0%{?rhel}
>  %define with_qemu_tcg 0
>  %define qemu_kvm_arches x86_64
> +%if 0%{?rhel} >= 7
> +%define qemu_kvm_arches x86_64 %{power64}
> +%endif
>  %endif
>  
>  %ifarch %{qemu_kvm_arches}
> 
> Would be better since it makes adding new releases easier. See, e.g.,
> how it looks nice and clear for fedora:
> 
> %if 0%{?fedora}
> %if 0%{?fedora} < 16
> # Fedora doesn't have any QEMU on ppc64 until FC16 - only ppc
> # I think F17 is the first release with the power64 macro
> %ifarch ppc64
> %define with_qemu_tcg 0
> %endif
> %endif
> %if 0%{?fedora} >= 18
> %define qemu_kvm_arches %{ix86} x86_64 %{power64} s390x
> %endif
> %if 0%{?fedora} >= 20
> %define qemu_kvm_arches %{ix86} x86_64 %{power64} s390x %{arm} aarch64
> %endif
> %endif

Yeah, it does look better.

So can I amend the commit with your proposed version
and push it?

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

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

Re: [libvirt] [PATCH 2/3] tools: remove unnecessary defaultConn variable

2016-04-06 Thread Erik Skultety
On 06/04/16 10:51, Ján Tomko wrote:
> vshStrdup returns NULL without exiting on NULL input.
> ---
>  tools/virsh.c  | 4 +---
>  tools/virt-admin.c | 4 +---
>  2 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 8c616d6..fe33839 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -908,7 +908,6 @@ main(int argc, char **argv)
>  {
>  vshControl _ctl, *ctl = &_ctl;
>  virshControl virshCtl;
> -const char *defaultConn;
>  bool ret = true;
>  
>  memset(ctl, 0, sizeof(vshControl));
> @@ -977,8 +976,7 @@ main(int argc, char **argv)
>  exit(EXIT_FAILURE);
>  }
>  
> -if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
> -ctl->connname = vshStrdup(ctl, defaultConn);
> +ctl->connname = vshStrdup(ctl, 
> virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI"));
>  
>  if (!ctl->imode) {
>  ret = vshCommandRun(ctl, ctl->cmd);
> diff --git a/tools/virt-admin.c b/tools/virt-admin.c
> index da847d2..18048d1 100644
> --- a/tools/virt-admin.c
> +++ b/tools/virt-admin.c
> @@ -670,7 +670,6 @@ main(int argc, char **argv)
>  {
>  vshControl _ctl, *ctl = &_ctl;
>  vshAdmControl virtAdminCtl;
> -const char *defaultConn;
>  bool ret = true;
>  
>  memset(ctl, 0, sizeof(vshControl));
> @@ -728,8 +727,7 @@ main(int argc, char **argv)
>  exit(EXIT_FAILURE);
>  }
>  
> -if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI")))
> -ctl->connname = vshStrdup(ctl, defaultConn);
> +ctl->connname = vshStrdup(ctl, 
> virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI"));
>  
>  if (!ctl->imode) {
>  ret = vshCommandRun(ctl, ctl->cmd);
> 

Like I said in 1/3, if we agree that getting the default connection URI
can be done solely in libvirt-admin library, you don't need the second
bit of the patch. ACK to the virsh part though.

Erik

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

Re: [libvirt] [PATCH 1/3] tools: read default connection uri from env later

2016-04-06 Thread Erik Skultety
On 06/04/16 10:51, Ján Tomko wrote:
> Postpone filling out the default connection in ctl->connname
> after calling virshInit.
> 
> This allows printing help without a connection to the daemon.
> ---
>  tools/virsh.c  | 6 +++---
>  tools/virt-admin.c | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 57b4ff3..8c616d6 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -968,9 +968,6 @@ main(int argc, char **argv)
>  
>  virFileActivateDirOverride(argv[0]);
>  
> -if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
> -ctl->connname = vshStrdup(ctl, defaultConn);
> -
>  if (!vshInit(ctl, cmdGroups, NULL))
>  exit(EXIT_FAILURE);
>  
> @@ -980,6 +977,9 @@ main(int argc, char **argv)
>  exit(EXIT_FAILURE);
>  }
>  
> +if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
> +ctl->connname = vshStrdup(ctl, defaultConn);
> +
>  if (!ctl->imode) {
>  ret = vshCommandRun(ctl, ctl->cmd);
>  } else {

^^This one's correct.

> diff --git a/tools/virt-admin.c b/tools/virt-admin.c
> index edb8690..da847d2 100644
> --- a/tools/virt-admin.c
> +++ b/tools/virt-admin.c
> @@ -719,9 +719,6 @@ main(int argc, char **argv)
>  
>  virFileActivateDirOverride(argv[0]);
>  
> -if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI")))
> -ctl->connname = vshStrdup(ctl, defaultConn);
> -
>  if (!vshInit(ctl, cmdGroups, NULL))
>  exit(EXIT_FAILURE);
>  
> @@ -731,6 +728,9 @@ main(int argc, char **argv)
>  exit(EXIT_FAILURE);
>  }
>  
> +if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI")))
> +ctl->connname = vshStrdup(ctl, defaultConn);
> +
>  if (!ctl->imode) {
>  ret = vshCommandRun(ctl, ctl->cmd);
>  } else {
> 

^^But I don't think you need this one here, because unlike
VIRSH_DEFAULT_CONNECT_URI which is deprecated by LIBVIRT_DEFAULT_URI and
we can't drop it, LIBVIRT_DEFAULT_ADMIN_URI isn't and from my
perspective the only way for this to not work would be a new virt-admin
client and old libvirt-admin library which would not support NULL as
connection name which is impossible since none of those were released
yet, so in conclusion I don't think that getting the default conn in
virt-admin is necessary at all and could be removed.

ACK to the first part (for virsh) of the patch.

Erik

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

[libvirt] Release of libvirt-1.3.3

2016-04-06 Thread Daniel Veillard
  With a bit of delay the release is now out and git is open again,
I tagged the release in head, and pushed signed tarball and rpms to the
usual place:

   ftp://libvirt.org/libvirt/

  UI also tagged and pushed signed tarball and rpms for the python
bindings for 1.3.3 at:

   ftp://libvirt.org/libvirt/python/

  This is a rather large lreales with a lot of development and user
visible features. The majority of the nearly 400 commits are incremental
improvements (which may explain why stabilization for release took a little
longuer than usual), but there is a decent amount of bug fixes too!


Features:
- perf events (Qiaowei Ren)
- post-copy migration support (Cristian Klein, Jiri Denemark)
- NSS module (Michal Privoznik)

Documentation:
- docs: fix logfile paragraph (Boris Fiuczynski)
- docs: Remove useless p:first-line CSS rule (Andrea Bolognani)
- docs: Remove unused #sponsor CSS rule (Andrea Bolognani)
- docs: Make most headers a bit smaller (Andrea Bolognani)
- docs: Use bold text for all headers (Andrea Bolognani)
- docs: Don't use bold text for menu entries (Andrea Bolognani)
- docs: Make menu entries smaller (Andrea Bolognani)
- docs: Don't use  in headers (Andrea Bolognani)
- docs: Remove empty CSS rule (Andrea Bolognani)
- docs: Adjust vertical whitespace in CSS (Andrea Bolognani)
- docs: fix qemu version for hyperv features (Pavel Hrdina)
- docs: Document NSS module (Michal Privoznik)
- docs: website: more header spacing tweaks (Cole Robinson)
- docs: Update the hyperv feature qemu supported version (John Ferlan)
- docs: generic.css: Indentation and spacing tweaks (Cole Robinson)
- docs: generic.css: font size tweaks (Cole Robinson)
- docs: generic.css: minor cleanups (Cole Robinson)
- docs: website: Remove the et.redhat.com footer (Cole Robinson)
- Fix minor typos (Yuri Chornoivan)
- docs: Clarify interface/target/@dev docs (Jiri Denemark)

Portability:
- build: workaround broken SASL header (again) (Fabiano Fidêncio)
- nss: FreeBSD support (Roman Bogorodskiy)
- perf: fix build on non-Linux (Roman Bogorodskiy)
- storage: rbd: Fix build (Peter Krempa)
- storage/rbd: Use correct printf-modifier for uint64 (Christophe Fergeau)
- tests: Produce predictable results in nsstest (Michal Privoznik)
- nss: don't try to build nss plugin when disabled (Roman Bogorodskiy)
- virlog: Fix build breaker with "comparison between signed and unsigned" (Erik 
Skultety)
- _virtualboxCreateMachine: Avoid unbounded stack (Michal Privoznik)
- datatypes.c: Replace 'close' with 'closeData' (Michal Privoznik)
- util: Fix build without polkit (Jiri Denemark)

Bug Fixes:
- qemu: Fix mis-merge of qemuBuildRedirdevCommandLine (John Ferlan)
- qemu: Fix mis-merge of qemuBuildConsoleCommandLine (John Ferlan)
- qemu: Fix mis-merge of qemuBuildChannelsCommandLine (John Ferlan)
- qemu: Fix mis-merge of qemuBuildParallelsCommandLine (John Ferlan)
- qemu: Fix mis-merge of qemuBuildSerialCommandLine (John Ferlan)
- qemu: Fix mis-merge of qemuBuildSmartcardCommandLine (John Ferlan)
- nodedev: Fix parsing of generated XMLs (Martin Kletzander)
- qemu: fix alias name for  (Laine Stump)
- qemu: Clear generated private paths (Martin Kletzander)
- apparmor: QEMU monitor socket moved (Guido Günther)
- Revert "hostdev: Use actual device when reattaching" (Andrea Bolognani)
- Pass the correct cpu count when calling virDomainGetCPUStats. (Nitesh Konkar)
- migration: convert speed from MiB/sec to bytes/sec in drive-mirror jobs (Rudy 
Zhang)
- libxl: fix net device detach (Jim Fehlig)
- libxl: fix attaching net device of type hostdev (Jim Fehlig)
- qemuProcessVerifyGuestCPU: Avoid coverity false positive (Michal Privoznik)
- virDomain{Get,Set}PerfEvents: support --config --live --current (Michal 
Privoznik)
- qemu: command: Pass numad nodeset when formatting memory devices at boot 
(Peter Krempa)
- libxl: only disable domain death events in libxlDomainCleanup (Jim Fehlig)
- libxl: fix resource leaks in libxlDomainStart error paths (Chunyan Liu)
- conf: decrease iterations complexity when formatting iothreads (Peter Krempa)
- qemu: Fix /proc/**/stat parsing (Jiri Denemark)
- bhyve: fix invalid hostsysinfo freeing (Maxim Nestratov)
- libxl: remove reference to non-existent out label (Jim Fehlig)
- util: avoid getting stuck on macvtapN name created outside libvirt (Laine 
Stump)
- libxl: fix hot add/remove VF from a pool (Chunyan Liu)
- tests: storagepoolxml2xmltest: Fix pool-rbd test (Anatole Denis)
- Revert "zfs: Only raw volumes are supported" (Roman Bogorodskiy)
- Revert "logical: Only raw volumes are supported" (Roman Bogorodskiy)
- network: differentiate macvtap/bridge from host-bridge based networks (Laine 
Stump)
- test: Fix typo in testutils.h header guard (Christophe Fergeau)
- virTestSetEnvPath: Avoid clearing out PATH (Michal Privoznik)
- admin_server: Avoid accessing unallocated memory (Michal Privoznik)
- testutils: Adapt to highly unlikely case (Michal Privoznik)
- tests: virlogtest: Fix testLogParseOutputs return value (Erik 

Re: [libvirt] [PATCH] spec: Include KVM support on RHEL 7 ppc64 and newer

2016-04-06 Thread Jiri Denemark
On Thu, Mar 17, 2016 at 11:24:34 +0100, Andrea Bolognani wrote:
> ---
> Definitely not an expert on spec files, but I did a test build
> on RHEL 7.2 ppc64le and it resulted in
> 
>   libvirt-daemon-driver-qemu-1.3.3-1.el7.ppc64le.rpm
>   libvirt-daemon-kvm-1.3.3-1.el7.ppc64le.rpm
>   libvirt-lock-sanlock-1.3.3-1.el7.ppc64le.rpm
> 
> being built in addition to what was built even before, so it
> looks reasonable I guess? Comments very welcome :)
> 
>  libvirt.spec.in | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libvirt.spec.in b/libvirt.spec.in
> index 03e2438..fdea12a 100644
> --- a/libvirt.spec.in
> +++ b/libvirt.spec.in
> @@ -77,7 +77,11 @@
>  
>  %if 0%{?rhel}
>  %define with_qemu_tcg 0
> -%define qemu_kvm_arches x86_64
> +%if 0%{?rhel} >= 7
> +%define qemu_kvm_arches x86_64 %{power64}
> +%else
> +%define qemu_kvm_arches x86_64
> +%endif
>  %endif
>  
>  %ifarch %{qemu_kvm_arches}

 %if 0%{?rhel}
 %define with_qemu_tcg 0
 %define qemu_kvm_arches x86_64
+%if 0%{?rhel} >= 7
+%define qemu_kvm_arches x86_64 %{power64}
+%endif
 %endif
 
 %ifarch %{qemu_kvm_arches}

Would be better since it makes adding new releases easier. See, e.g.,
how it looks nice and clear for fedora:

%if 0%{?fedora}
%if 0%{?fedora} < 16
# Fedora doesn't have any QEMU on ppc64 until FC16 - only ppc
# I think F17 is the first release with the power64 macro
%ifarch ppc64
%define with_qemu_tcg 0
%endif
%endif
%if 0%{?fedora} >= 18
%define qemu_kvm_arches %{ix86} x86_64 %{power64} s390x
%endif
%if 0%{?fedora} >= 20
%define qemu_kvm_arches %{ix86} x86_64 %{power64} s390x %{arm} aarch64
%endif
%endif

Jirka

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


Re: [libvirt] [PATCH] spec: Include KVM support on RHEL 7 ppc64 and newer

2016-04-06 Thread Andrea Bolognani
On Thu, 2016-03-17 at 11:24 +0100, Andrea Bolognani wrote:
> ---
> Definitely not an expert on spec files, but I did a test build
> on RHEL 7.2 ppc64le and it resulted in
> 
>   libvirt-daemon-driver-qemu-1.3.3-1.el7.ppc64le.rpm
>   libvirt-daemon-kvm-1.3.3-1.el7.ppc64le.rpm
>   libvirt-lock-sanlock-1.3.3-1.el7.ppc64le.rpm
> 
> being built in addition to what was built even before, so it
> looks reasonable I guess? Comments very welcome :)
> 
>  libvirt.spec.in | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libvirt.spec.in b/libvirt.spec.in
> index 03e2438..fdea12a 100644
> --- a/libvirt.spec.in
> +++ b/libvirt.spec.in
> @@ -77,7 +77,11 @@
>  
>  %if 0%{?rhel}
>  %define with_qemu_tcg 0
> -%define qemu_kvm_arches x86_64
> +%if 0%{?rhel} >= 7
> +%define qemu_kvm_arches x86_64 %{power64}
> +%else
> +%define qemu_kvm_arches x86_64
> +%endif
>  %endif
>  
>  %ifarch %{qemu_kvm_arches}

Ping?

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

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

[libvirt] [PATCH 2/3] tools: remove unnecessary defaultConn variable

2016-04-06 Thread Ján Tomko
vshStrdup returns NULL without exiting on NULL input.
---
 tools/virsh.c  | 4 +---
 tools/virt-admin.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 8c616d6..fe33839 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -908,7 +908,6 @@ main(int argc, char **argv)
 {
 vshControl _ctl, *ctl = &_ctl;
 virshControl virshCtl;
-const char *defaultConn;
 bool ret = true;
 
 memset(ctl, 0, sizeof(vshControl));
@@ -977,8 +976,7 @@ main(int argc, char **argv)
 exit(EXIT_FAILURE);
 }
 
-if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
-ctl->connname = vshStrdup(ctl, defaultConn);
+ctl->connname = vshStrdup(ctl, 
virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI"));
 
 if (!ctl->imode) {
 ret = vshCommandRun(ctl, ctl->cmd);
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index da847d2..18048d1 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -670,7 +670,6 @@ main(int argc, char **argv)
 {
 vshControl _ctl, *ctl = &_ctl;
 vshAdmControl virtAdminCtl;
-const char *defaultConn;
 bool ret = true;
 
 memset(ctl, 0, sizeof(vshControl));
@@ -728,8 +727,7 @@ main(int argc, char **argv)
 exit(EXIT_FAILURE);
 }
 
-if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI")))
-ctl->connname = vshStrdup(ctl, defaultConn);
+ctl->connname = vshStrdup(ctl, 
virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI"));
 
 if (!ctl->imode) {
 ret = vshCommandRun(ctl, ctl->cmd);
-- 
2.4.10

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


[libvirt] [PATCH 3/3] libvirt-admin: do not crash on URI without a scheme

2016-04-06 Thread Ján Tomko
---
 src/libvirt-admin.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index 54af90c..6577c87 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -121,10 +121,10 @@ getSocketPath(virURIPtr uri)
 }
 
 if (!sock_path) {
-if (STRNEQ(uri->scheme, "libvirtd")) {
+if (STRNEQ_NULLABLE(uri->scheme, "libvirtd")) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported URI scheme '%s'"),
-   uri->scheme);
+   NULLSTR(uri->scheme));
 goto error;
 }
 if (STREQ_NULLABLE(uri->path, "/system")) {
-- 
2.4.10

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


[libvirt] [PATCH 0/3] tools: virsh/virt-admin uri handling spring series 2016

2016-04-06 Thread Ján Tomko
*** <""/.a... ***

Ján Tomko (3):
  tools: read default connection uri from env later
  tools: remove unnecessary defaultConn variable
  libvirt-admin: do not crash on URI without a scheme

 src/libvirt-admin.c | 4 ++--
 tools/virsh.c   | 6 ++
 tools/virt-admin.c  | 6 ++
 3 files changed, 6 insertions(+), 10 deletions(-)

-- 
2.4.10

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

[libvirt] [PATCH 1/3] tools: read default connection uri from env later

2016-04-06 Thread Ján Tomko
Postpone filling out the default connection in ctl->connname
after calling virshInit.

This allows printing help without a connection to the daemon.
---
 tools/virsh.c  | 6 +++---
 tools/virt-admin.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 57b4ff3..8c616d6 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -968,9 +968,6 @@ main(int argc, char **argv)
 
 virFileActivateDirOverride(argv[0]);
 
-if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
-ctl->connname = vshStrdup(ctl, defaultConn);
-
 if (!vshInit(ctl, cmdGroups, NULL))
 exit(EXIT_FAILURE);
 
@@ -980,6 +977,9 @@ main(int argc, char **argv)
 exit(EXIT_FAILURE);
 }
 
+if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
+ctl->connname = vshStrdup(ctl, defaultConn);
+
 if (!ctl->imode) {
 ret = vshCommandRun(ctl, ctl->cmd);
 } else {
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index edb8690..da847d2 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -719,9 +719,6 @@ main(int argc, char **argv)
 
 virFileActivateDirOverride(argv[0]);
 
-if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI")))
-ctl->connname = vshStrdup(ctl, defaultConn);
-
 if (!vshInit(ctl, cmdGroups, NULL))
 exit(EXIT_FAILURE);
 
@@ -731,6 +728,9 @@ main(int argc, char **argv)
 exit(EXIT_FAILURE);
 }
 
+if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI")))
+ctl->connname = vshStrdup(ctl, defaultConn);
+
 if (!ctl->imode) {
 ret = vshCommandRun(ctl, ctl->cmd);
 } else {
-- 
2.4.10

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


Re: [libvirt] [PATCH 6/7] storage:dir: adapts .refreshVol .refreshPool for ploop volumes

2016-04-06 Thread Olga Krishtal

On 05/04/16 18:01, Ján Tomko wrote:

On Mon, Mar 14, 2016 at 07:00:39PM +0300, Olga Krishtal wrote:

Refreshes meta-information such as allocation, capacity, format, etc.
Ploop volumes differ from other volume types. Path to volume is the path
to directory with image file root.hds and DiskDescriptor.xml.
https://openvz.org/Ploop/format
Due to this fact, operations of opening the volume have to be done once
again. get the information.

To decide whether the given volume is ploops one, it is necessary to check
the presence of root.hds and DiskDescriptor.xml files in volumes' directory.
Only in this case the volume can be manipulated as the ploops one.
Such strategy helps us to resolve problems that might occure, when we
upload some other volume type from ploop source.

Signed-off-by: Olga Krishtal 
---
  src/storage/storage_backend.c| 62 --
  src/storage/storage_backend.h|  5 
  src/storage/storage_backend_fs.c | 64 +---
  src/util/virstoragefile.c|  7 +++--
  4 files changed, 129 insertions(+), 9 deletions(-)

@@ -69,6 +109,7 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
  int fd = -1;
  int ret = -1;
  int rc;
+int format = VIR_STORAGE_FILE_AUTO;
  virStorageSourcePtr meta = NULL;
  struct stat sb;
  
@@ -84,14 +125,26 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,

  goto cleanup;
  
  if (S_ISDIR(sb.st_mode)) {

-target->format = VIR_STORAGE_FILE_DIR;
-ret = 0;
-goto cleanup;
+if (virStorageBackendIsPloopDir(target->path)) {
+if (virStorageBackendRedoPloopUpdate(target, , ,
+ 
VIR_STORAGE_VOL_FS_PROBE_FLAGS)
+< 0)
+goto cleanup;



+/* Refresh information stored in DiskDescriptor.xml according
+ * to ploop image file content.*/
+if (virStorageBackendPloopRestoreDesc(target->path) < 0)
+goto cleanup;

Probing a volume should not change its contents - libvirt should only
refresh this XML when it changed the volume.

The rest looks good to me.

Jan
The thing is that if we changed the size, the content of root.hds and 
had left the old DiskDeskriptor.xml - it becomes impossible to operate.
I mean that DiskDescriptor.xml stores this info - size, Celinders, 
Sectors, and what is more important - all information about snapshot.
In the situation when we have uploaded previously snapshoted volume - 
the content of volume and DiskDescriptor will be inconsistent.

And work upon such volume will be impossible.
But if you have any idea, where such refresh of DiskDescriptor.xml could 
be done - I will be glad to know.


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


[libvirt] [PATCH] makefile: Move include/Makefile.am to include/libvirt/Makefile.am

2016-04-06 Thread Erik Skultety
The reason for this is to fix the automatic rebuild of libvirt-common.h.in.
All *.in files should be automatically rebuilt each time they're modified.
It works well for makefiles and pkgconfig files, since they do have a valid
dependency in the top-level Makefile. However, with libvirt-common.h.in
there is no dependency in the top-level Makefile and there's no need for it
either, so this rule

include/libvirt/libvirt-common.h: $(top_builddir)/config.status \
$(top_srcdir)/include/libvirt/libvirt-common.h.in
cd $(top_builddir) && $(SHELL) ./config.status $@

is never hit and should be moved to include/Makefile, but that's automake's
job. According to GNU automake docs:

"Files created by AC_CONFIG_FILES, be they
Automake Makefiles or not, are all removed by ‘make distclean’. Their inputs
are automatically distributed, unless they are the output of prior
AC_CONFIG_FILES commands. Finally, rebuild rules are generated in the Automake
Makefile existing in the subdirectory of the output file, if there is one, or
in the top-level Makefile otherwise."

Which means that if we want to have the rule for libvirt-common.h automatically
generated by automake, the include/Makefile.am needs to be moved into libvirt/
subdirectory and $SUBDIRS in the top-level Makefile need to be adjusted as
well. This patch moves Makefile.am from include/ to include/libvirt, adjusting
the prefixes accordingly as well as updates the top-level Makefile $SUBDIRS to
properly hint automake to generate all rules at proper places.

Best way to see the changes, use -M with 'git show'.

Signed-off-by: Erik Skultety 
---
 Makefile.am   |  2 +-
 configure.ac  |  2 +-
 include/{ => libvirt}/Makefile.am | 12 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)
 rename include/{ => libvirt}/Makefile.am (76%)

diff --git a/Makefile.am b/Makefile.am
index ffe0517..9298082 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,7 @@
 LCOV = lcov
 GENHTML = genhtml
 
-SUBDIRS = . gnulib/lib include src daemon tools docs gnulib/tests \
+SUBDIRS = . gnulib/lib include/libvirt src daemon tools docs gnulib/tests \
   tests po examples
 
 ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index 85fc6e1..1e83b8f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2744,7 +2744,7 @@ 
AC_DEFINE_UNQUOTED([base64_encode_alloc],[libvirt_gl_base64_encode_alloc],[Hack
 AC_CONFIG_FILES([run],
 [chmod +x,-w run])
 AC_CONFIG_FILES([\
-Makefile src/Makefile include/Makefile docs/Makefile \
+Makefile src/Makefile include/libvirt/Makefile docs/Makefile \
 gnulib/lib/Makefile \
 gnulib/tests/Makefile \
 libvirt.pc \
diff --git a/include/Makefile.am b/include/libvirt/Makefile.am
similarity index 76%
rename from include/Makefile.am
rename to include/libvirt/Makefile.am
index dde955e..a59b8ab 100644
--- a/include/Makefile.am
+++ b/include/libvirt/Makefile.am
@@ -18,15 +18,15 @@
 
 virincdir = $(includedir)/libvirt
 
-allheaders = $(wildcard $(srcdir)/libvirt/*.h)
-virinc_HEADERS = $(filter-out $(srcdir)/libvirt/libvirt-admin.h \
-$(srcdir)/libvirt/libvirt-common.h, 
$(allheaders))
-virinc_HEADERS += libvirt/libvirt-common.h
+allheaders = $(wildcard $(srcdir)/*.h)
+virinc_HEADERS = $(filter-out $(srcdir)/libvirt-admin.h \
+$(srcdir)/libvirt-common.h, $(allheaders))
+virinc_HEADERS += libvirt-common.h
 
-EXTRA_DIST = libvirt/libvirt-common.h.in
+EXTRA_DIST = libvirt-common.h.in
 
 # Temporarily disabled, but we need it for building
-EXTRA_DIST += libvirt/libvirt-admin.h
+EXTRA_DIST += libvirt-admin.h
 
 install-exec-hook:
$(mkinstalldirs) $(DESTDIR)$(virincdir)
-- 
2.4.11

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

Re: [libvirt] [PATCH] Link xen driver against libxl

2016-04-06 Thread Jiri Denemark
On Tue, Apr 05, 2016 at 18:16:29 +0200, Guido Günther wrote:
> >From 4e302ea482d58c5ae034f85ea27d0318cb0b59c5 Mon Sep 17 00:00:00 2001
> Message-Id: 
> <4e302ea482d58c5ae034f85ea27d0318cb0b59c5.1459872920.git@sigxcpu.org>
> From: =?UTF-8?q?Guido=20G=C3=BCnther?= 
> Date: Thu, 31 Mar 2016 14:57:24 +0200
> Subject: [PATCH] Link libvirt_xenconfig instead of libvirt against libxl
> To: libvir-list@redhat.com
> Status: O
> Content-Length: 975
> Lines: 24
> 
> to avoid the test failure
> 
>  7) Test driver "xen"  ... 2016-03-31 12:53:26.950+: 22430: debug : 
> virDriverLoadModule:54 : Module load xen
>  2016-03-31 12:53:26.950+: 22430: error : virDriverLoadModule:73 : failed 
> to load module 
> /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so 
> /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so: 
> undefined symbol: xlu_cfg_destroy
> FAILED
> ---
>  src/Makefile.am | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 1726d06..e63b81d 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -1134,7 +1134,7 @@ endif WITH_VMX
>  if WITH_XENCONFIG
>  noinst_LTLIBRARIES += libvirt_xenconfig.la
>  libvirt_la_BUILT_LIBADD += libvirt_xenconfig.la
> -libvirt_la_LIBADD += $(LIBXL_LIBS)
> +libvirt_xenconfig_la_LIBADD = $(LIBXL_LIBS)
>  libvirt_xenconfig_la_CFLAGS = \
>   -I$(srcdir)/conf $(AM_CFLAGS)
>  libvirt_xenconfig_la_SOURCES = $(XENCONFIG_SOURCES)

ACK

Jirka

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


Re: [libvirt] [PATCH 0/2] boot order storage/parsing cleanup

2016-04-06 Thread Peter Krempa
On Tue, Apr 05, 2016 at 17:36:27 +0200, Ján Tomko wrote:
> On Thu, Mar 31, 2016 at 04:05:01PM +0200, Peter Krempa wrote:

...

> ACK to both

Pushed; Thanks.

Peter


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