[libvirt] [PATCH RESEND RFC V2 1/2] Resctrl: Add new xml element to support cache tune

2017-07-04 Thread Eli Qiao
This patch adds new xml element to support cache tune as:


  ...
  
  ...


cacheId: reference of the host's cache banks id, it's from capabilities
  xml.
type:cache bank type, it could be both, code, data.
sizeKiB: must be multiple of granularity, must be greater than or equal
 to minimum.
vcpus:   cache allocation on vcpu set, if empty, will apply the allocation
 on all vcpus.

Signed-off-by: Eli Qiao 
---
 docs/schemas/domaincommon.rng |  29 +++
 src/conf/domain_conf.c| 112 ++
 src/conf/domain_conf.h|  19 +++
 3 files changed, 160 insertions(+)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index e259e3e..6e0262e 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -834,6 +834,25 @@
 
   
 
+
+  
+
+  
+
+
+  
+
+ 
+
+  
+
+
+  
+
+  
+
+  
+
 
   
 
@@ -5693,6 +5712,16 @@
   -1
 
   
+  
+
+  [0-9]+
+
+  
+  
+
+  (both|code|data)
+
+  
   
   
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0409c62..65a9486 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2927,6 +2927,11 @@ void virDomainDefFree(virDomainDefPtr def)
 
 xmlFreeNode(def->metadata);
 
+for (i = 0; i < def->cachetune.n_banks; i++)
+virBitmapFree(def->cachetune.cache_banks[i].vcpus);
+
+VIR_FREE(def->cachetune.cache_banks);
+
 VIR_FREE(def);
 }
 
@@ -16318,6 +16323,81 @@ virDomainVcpuPinDefParseXML(virDomainDefPtr def,
 return ret;
 }
 
+/* Parse the XML definition for cachetune
+ * and a cachetune has the form
+ * 

[libvirt] [PATCH RESEND RFC V2 0/2] Implement l3 CAT

2017-07-04 Thread Eli Qiao
Allow user to define cachetune in domain xml.

RESEND:
  * Fix stupid complile problem pointed out by Martin, check and syntax-check
passed.

V2 -> V1 changes:
  * Redefine cachetune xml in domain xml.
  * Create a struct for driver to talk with util/virresctrl.*
  * Nit fixes


Eli Qiao (2):
  Resctrl: Add new xml element to support cache tune
  Resctrl: Do cache allocation while boot a qemu VM

 docs/schemas/domaincommon.rng |  29 ++
 include/libvirt/virterror.h   |   1 +
 src/Makefile.am   |   1 +
 src/conf/domain_conf.c| 112 
 src/conf/domain_conf.h|  19 +
 src/libvirt_private.syms  |   9 +
 src/qemu/qemu_process.c   |  81 +++
 src/util/virerror.c   |   1 +
 src/util/virresctrl.c | 822 ++
 src/util/virresctrl.h |  88 
 tests/Makefile.am |   8 +-
 tests/virresctrldata/L3-free.schemata |   1 +
 tests/virresctrldata/L3CODE-free.schemata |   1 +
 tests/virresctrldata/L3DATA-free.schemata |   1 +
 tests/virresctrldata/linux-resctrl|   1 +
 tests/virresctrldata/linux-resctrl-cdp|   1 +
 tests/virresctrltest.c| 119 +
 17 files changed, 1294 insertions(+), 1 deletion(-)
 create mode 100644 src/util/virresctrl.c
 create mode 100644 src/util/virresctrl.h
 create mode 100644 tests/virresctrldata/L3-free.schemata
 create mode 100644 tests/virresctrldata/L3CODE-free.schemata
 create mode 100644 tests/virresctrldata/L3DATA-free.schemata
 create mode 12 tests/virresctrldata/linux-resctrl
 create mode 12 tests/virresctrldata/linux-resctrl-cdp
 create mode 100644 tests/virresctrltest.c

--
1.9.1

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


[libvirt] [PATCH RESEND RFC V2 2/2] Resctrl: Do cache allocation while boot a qemu VM

2017-07-04 Thread Eli Qiao
Set cachetune if user define cachetune in domain xml when using qemu
driver.

This patch adds 3 major private interface.

virResctrlGetFreeCache: return free cache, default cache substract cache
allocated.
virResctrlSetCachetunes: set cache banks which defined in a domain.
virResctrlRemoveCachetunes: remove cache allocation group from the
host.

Signed-off-by: Eli Qiao 
---
 include/libvirt/virterror.h   |   1 +
 src/Makefile.am   |   1 +
 src/libvirt_private.syms  |   9 +
 src/qemu/qemu_process.c   |  81 +++
 src/util/virerror.c   |   1 +
 src/util/virresctrl.c | 822 ++
 src/util/virresctrl.h |  88 
 tests/Makefile.am |   8 +-
 tests/virresctrldata/L3-free.schemata |   1 +
 tests/virresctrldata/L3CODE-free.schemata |   1 +
 tests/virresctrldata/L3DATA-free.schemata |   1 +
 tests/virresctrldata/linux-resctrl|   1 +
 tests/virresctrldata/linux-resctrl-cdp|   1 +
 tests/virresctrltest.c| 119 +
 14 files changed, 1134 insertions(+), 1 deletion(-)
 create mode 100644 src/util/virresctrl.c
 create mode 100644 src/util/virresctrl.h
 create mode 100644 tests/virresctrldata/L3-free.schemata
 create mode 100644 tests/virresctrldata/L3CODE-free.schemata
 create mode 100644 tests/virresctrldata/L3DATA-free.schemata
 create mode 12 tests/virresctrldata/linux-resctrl
 create mode 12 tests/virresctrldata/linux-resctrl-cdp
 create mode 100644 tests/virresctrltest.c

diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 2efee8f..4bc0c74 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -132,6 +132,7 @@ typedef enum {
 
 VIR_FROM_PERF = 65, /* Error from perf */
 VIR_FROM_LIBSSH = 66,   /* Error from libssh connection transport */
+VIR_FROM_RESCTRL = 67,  /* Error from resctrl */
 
 # ifdef VIR_ENUM_SENTINELS
 VIR_ERR_DOMAIN_LAST
diff --git a/src/Makefile.am b/src/Makefile.am
index eae32dc..8dbb778 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -167,6 +167,7 @@ UTIL_SOURCES =  
\
util/virprocess.c util/virprocess.h \
util/virqemu.c util/virqemu.h   \
util/virrandom.h util/virrandom.c   \
+   util/virresctrl.h util/virresctrl.c \
util/virrotatingfile.h util/virrotatingfile.c   \
util/virscsi.c util/virscsi.h   \
util/virscsihost.c util/virscsihost.h   \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c1e9471..72e5096 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2439,6 +2439,15 @@ virRandomGenerateWWN;
 virRandomInt;
 
 
+# util/virresctrl.h
+virResctrlBitmap2String;
+virResctrlFreeSchemata;
+virResctrlGetFreeCache;
+virResctrlRemoveCachetunes;
+virResctrlSetCachetunes;
+virResctrlTypeToString;
+
+
 # util/virrotatingfile.h
 virRotatingFileReaderConsume;
 virRotatingFileReaderFree;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index fa9990e..3b11caa 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -70,6 +70,7 @@
 #include "virbitmap.h"
 #include "viratomic.h"
 #include "virnuma.h"
+#include "virresctrl.h"
 #include "virstring.h"
 #include "virhostdev.h"
 #include "secret_util.h"
@@ -5130,6 +5131,77 @@ qemuProcessSetupVcpus(virDomainObjPtr vm)
 return 0;
 }
 
+static int
+qemuProcessSetCacheBanks(virCapsHostPtr caps, virDomainObjPtr vm)
+{
+size_t i, j;
+virDomainCachetunePtr cachetune;
+virResctrlCachetunePtr resctrl_cachetune;
+unsigned int max_vcpus = virDomainDefGetVcpusMax(vm->def);
+pid_t *pids = NULL;
+virDomainVcpuDefPtr vcpu;
+size_t npids = 0;
+size_t count = 0;
+int ret = -1;
+
+cachetune = &(vm->def->cachetune);
+
+if (VIR_ALLOC_N(resctrl_cachetune, cachetune->n_banks) < 0)
+goto cleanup;
+
+/* construct resctrl_cachetune array */
+for (i = 0; i < cachetune->n_banks; i++) {
+
+resctrl_cachetune[i].cache_id = cachetune->cache_banks[i].cache_id;
+resctrl_cachetune[i].type = cachetune->cache_banks[i].type;
+resctrl_cachetune[i].size = cachetune->cache_banks[i].size;
+
+/* get granularity from host's capabilities */
+for (j = 0; j < caps->ncaches; j++) {
+/* even enable CDP, granularity for code and data are same */
+if (caps->caches[j]->id == resctrl_cachetune[i].cache_id &&
+caps->caches[j]->controls) {
+resctrl_cachetune[i].granularity = 
caps->caches[j]->controls[0]->granularity;
+break;
+}
+}
+
+/* 

[libvirt] Release of libvirt-3.5.0

2017-07-04 Thread Daniel Veillard
  As planned, it is out, I tagged it in git and pushed signed tarball and
rpms to the usual place:

ftp://libvirt.org/libvirt/

I also made a release 3.5.0 of the python bindings with minimal changes
compared to 3.4.0, it can be found at:

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

 This is a balanced release with signiciant amounts of both new features,
improvements and bug fixes:


New features:

- qemu: Add support for loadparm for a boot device
Add an optional boot parameter 'loadparm' for a boot device. Loadparm
is an 8 byte parameter that, when present, is queried by S390 guests
via sclp or diag 308. Linux guests on S390 use it to select a boot
entry.

- Support controlling how video devices are exposed to the bhyve guests
The vgaconf attribute was added to video's driver element. Possible
values are: on, off, and io. It controlls the way how bhyve exposes
video devices to its guests; various guest OSes might require different
settings to boot properly.

- qemu: Add support for live updates of coalesce settings
Users can now use virsh update-device to change the coalesce settings
of an interfaces while the domain is running.

- qemu: Allow VirtIO devices to use vIOMMU
It is now possible to turn on IOTBL for the vIOMMU and have VirtIO
devices use it, provided they have been configured appropriately.

Improvements:

- qemu: block copy job can be used with persistent domains
Until now it was not possible to use block copy with persistent VMs. In
use cases where it's not required to recover the job after VM shutdown,
it's possible to specify VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB flag to
start the copy job.

- JSON pseudo-protocol backing store parser supports new format of qemu 2.9
QEMU 2.9 modified a few structures corresponding to the JSON format of
specifying a backing store for a disk image. Libvirt now implements the
new format.

- Capabilities now include info about host's CAT settings
Various information about resource control from the host is gathered
and presented in capabilities if available.

- apparmor: Several improvements
Allow access to Ceph config, EFI firmware on both x86_64 and aarch64,
device tree on ppc64 and more.

- qemu: Support host-model on POWER9 machines

Bug fixes:

- qemu: snapshot: retrieve image metadata from user provided files
Disk images of an external snapshot created with
VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT flag specified would not be
scanned for metadata after recent changes. The metadata is necessary to
allow keeping relative paths between images when doing a block-commit.

- Parse decimal numbers in a locale-independent way
Some locales, such as de_DE and pt_BR, use comma rather than dot to
separate the integer part from the fractional part of a decimal number;
however, several data sources such as the kernel use a
locale-independent representation and need to be treated accordingly.

- Support compilation with newer compiler and libc versions
Several fixes have been included to make compilation with Clang 4.0.0,
GCC 7.1 and glibc >= 2.25.90 possible.

- qemu: Query name for vhost-user interfaces at runtime
This makes it possible to use virsh subcommands such as domiflist and
domifstat on vhost-user interfaces.

- qemu: Set MTU for hotplugged interfaces correctly
When hotplugging a network interface, the MTU was only set on the guest
side. Set it on the host side as well.

- qemu: Forbid updating MTU for interfaces of running guests
The MTU setting can't be modified while the guest is running, so any
attempt to alter it at runtime will now result in an error rather than
being silently ignored.

- qemu: Fix specifying QXL heads with older QEMU releases
Specifying the number of QXL heads was not working correctly for QEMU
releases older than 1.6.

- qemu: Fix migration to older libvirt/QEMU versions
When the guest is started, libvirt updates the CPU definition to
reflect the actual CPU features to enforce ABI. We need to send
original and updated CPU definition in order to support migration to
older libvirt/QEMU versions. Only the updated CPU definition was sent
to destination.


  So thanks everybody for your help toward this release, be it code,
bug reports, reviews ideas or doc, it's all appreciated !

  So please enjoy this new release !

Daniel

-- 
Daniel Veillard  | Red Hat Developers Tools http://developer.redhat.com/
veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] Entering freeze for libvirt-3.5.0

2017-07-04 Thread Daniel P. Berrange
On Tue, Jul 04, 2017 at 06:26:22PM +0100, Daniel P. Berrange wrote:
> On Tue, Jul 04, 2017 at 05:32:03PM +0100, Daniel P. Berrange wrote:
> > On Tue, Jul 04, 2017 at 12:21:21PM +0100, Daniel P. Berrange wrote:
> > So I did some debugging and this is wierder than I can imagine possible.
> > 
> > I put a printf statement  in virNumaGetMaxNode in qemuxml2argvmock.c
> > to print out the return value.
> > 
> > I also put a printf statement in virNumaNodeIsAvailable in virnuma.c
> > (in the non-NUMACTL conditional block), that prints out the return
> > value received from virNumaGetMaxNode
> > 
> > The first printf displays 7, while the second printf displays -1
> > 
> > So we're definitely calling our mock override, but the return
> > value is getting mangled when seen by the caller, which is a
> > giant wtf to me.
> 
> I wrote an isolated test case
> 
> $ cat lib.h
> 
> int get_max(void) __attribute__((noinline));
> 
> int is_ok(int i);
> 
> 
> 
> $ cat lib.c
> 
> #include 
> #include "lib.h"
> 
> int get_max(void)
> {
>   fprintf(stderr, "In original max, returning 3\n");
>   return 3;
> }
> 
> int is_ok(int i)
> {
>   int max = get_max();
>   fprintf(stderr, "Received max %d\n", max);
>   return i > 0 && i <= max;
> }
> 
> 
> 
> $ cat mock.c
> 
> #include 
> #include "lib.h"
> 
> 
> int get_max(void)
> {
>   fprintf(stderr, "In mock max, returning 7\n");
>   return 7;
> }
> 
> 
> 
> $ cat run.c
> 
> #include 
> #include "lib.h"
> 
> int main(int argc, char **argv)
> 
> {
>   fprintf(stderr, "Is 5 in range ? %d\n", is_ok(5));
> }
> 
> 
> $ clang -O2 -g -Wall -shared -o libdemo.so  -fPIC lib.c
> $ clang -O2 -g -Wall -shared -o mock.so -fPIC  mock.c
> $ clang -O2 -Wall -o run run.c -L. -ldemo
> 
> 
> $ ./run
> In original max, returning 3
> Received max 3
> Is 5 in range ? 0
> $ LD_PRELOAD=mock.so  ./run
> In mock max, returning 7
> Received max 3
> Is 5 in range ? 0
> 
> 
> $ clang -O0 -g -Wall -shared -o libdemo.so  -fPIC lib.c
> $ LD_PRELOAD=mock.so  ./run
> In mock max, returning 7
> Received max 7
> Is 5 in range ? 1
> 
> 
> So clang is definitely *not* inlining the function, *is* running out mock
> function, but none the less getting the return value from the original
> function.
> 
> Turning on optimizer debugging i see
> 
> 
> $ clang -O2 -g -Wall -shared -o libdemo.so -Rpass=.* -fPIC lib.c
> lib.c:7:3: remark: marked this call a tail call candidate 
> [-Rpass=tailcallelim]
>   fprintf(stderr, "In original max, returning 3\n");
>   ^
> lib.c:11:15: remark: marked this call a tail call candidate 
> [-Rpass=tailcallelim]
> int is_ok(int i)
>   ^
> lib.c:13:13: remark: marked this call a tail call candidate 
> [-Rpass=tailcallelim]
>   int max = get_max();
> ^
> lib.c:13:7: remark: marked this call a tail call candidate 
> [-Rpass=tailcallelim]
>   int max = get_max();
>   ^
> lib.c:14:3: remark: marked this call a tail call candidate 
> [-Rpass=tailcallelim]
>   fprintf(stderr, "Received max %d\n", max);
>   ^
> 
> 
> so, I'm thinking this problem is a result of tail call optimization making
> an assumption that is violated when mocking the function.

The tail call stuff was a red-herring and not related. After much trial
and error I've found that it is possible to make this work by annotating
the functions with the attribute "weak". This explicitly tells the
compiler that the function is designed to be overridden by an external
source, thus preventing any of the call convention optimization clang
does. With 'weak' added to virNumaGetMaxNode() the test suite passes
on FreeBSD !

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

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


Re: [libvirt] Entering freeze for libvirt-3.5.0

2017-07-04 Thread Daniel P. Berrange
On Tue, Jul 04, 2017 at 05:32:03PM +0100, Daniel P. Berrange wrote:
> On Tue, Jul 04, 2017 at 12:21:21PM +0100, Daniel P. Berrange wrote:
> > On Tue, Jul 04, 2017 at 01:03:52PM +0200, Andrea Bolognani wrote:
> > > On Sat, 2017-07-01 at 14:18 +0400, Roman Bogorodskiy wrote:
> > > > > qemuxml2argvtest fails consistently in my FreeBSD guest.
> > > > 
> > > > I guess that's caused by clang inlining functions that are mocked
> > > > (specifically, some numa related stuff); I think that was discussed
> > > > several times already. Anyway, it should work fine with '-O0' in CFLAGS.
> > > 
> > > Well, would you look at that. It does indeed work flawlessly
> > > when compiled without optimizations! :O
> > > 
> > > I'm not sure if that would be considered a reasonable
> > > compromise to get the test suite running on FreeBSD in the
> > > context of CI, though. I think it working reliably without
> > > messing with CFLAGS would be a requirement; others might
> > > disagree.
> > 
> > Hmm, I thought I fixed that problem when I introduce this patch:
> > 
> >   commit 728cacc8abed2b8de39e7b96fa42fde6850ec23a
> >   Author: Daniel P. Berrange 
> >   Date:   Fri Apr 7 15:07:49 2017 +0100
> > 
> > annotate all mocked functions with noinline
> > 
> > 
> > This made us annotate all mocked functions with noinline, which was
> > sufficient to make CLang builds pass tests on Ubuntu VMs.
> 
> So I did some debugging and this is wierder than I can imagine possible.
> 
> I put a printf statement  in virNumaGetMaxNode in qemuxml2argvmock.c
> to print out the return value.
> 
> I also put a printf statement in virNumaNodeIsAvailable in virnuma.c
> (in the non-NUMACTL conditional block), that prints out the return
> value received from virNumaGetMaxNode
> 
> The first printf displays 7, while the second printf displays -1
> 
> So we're definitely calling our mock override, but the return
> value is getting mangled when seen by the caller, which is a
> giant wtf to me.

I wrote an isolated test case

$ cat lib.h

int get_max(void) __attribute__((noinline));

int is_ok(int i);



$ cat lib.c

#include 
#include "lib.h"

int get_max(void)
{
  fprintf(stderr, "In original max, returning 3\n");
  return 3;
}

int is_ok(int i)
{
  int max = get_max();
  fprintf(stderr, "Received max %d\n", max);
  return i > 0 && i <= max;
}



$ cat mock.c

#include 
#include "lib.h"


int get_max(void)
{
  fprintf(stderr, "In mock max, returning 7\n");
  return 7;
}



$ cat run.c

#include 
#include "lib.h"

int main(int argc, char **argv)

{
  fprintf(stderr, "Is 5 in range ? %d\n", is_ok(5));
}


$ clang -O2 -g -Wall -shared -o libdemo.so  -fPIC lib.c
$ clang -O2 -g -Wall -shared -o mock.so -fPIC  mock.c
$ clang -O2 -Wall -o run run.c -L. -ldemo


$ ./run
In original max, returning 3
Received max 3
Is 5 in range ? 0
$ LD_PRELOAD=mock.so  ./run
In mock max, returning 7
Received max 3
Is 5 in range ? 0


$ clang -O0 -g -Wall -shared -o libdemo.so  -fPIC lib.c
$ LD_PRELOAD=mock.so  ./run
In mock max, returning 7
Received max 7
Is 5 in range ? 1


So clang is definitely *not* inlining the function, *is* running out mock
function, but none the less getting the return value from the original
function.

Turning on optimizer debugging i see


$ clang -O2 -g -Wall -shared -o libdemo.so -Rpass=.* -fPIC lib.c
lib.c:7:3: remark: marked this call a tail call candidate [-Rpass=tailcallelim]
  fprintf(stderr, "In original max, returning 3\n");
  ^
lib.c:11:15: remark: marked this call a tail call candidate 
[-Rpass=tailcallelim]
int is_ok(int i)
  ^
lib.c:13:13: remark: marked this call a tail call candidate 
[-Rpass=tailcallelim]
  int max = get_max();
^
lib.c:13:7: remark: marked this call a tail call candidate [-Rpass=tailcallelim]
  int max = get_max();
  ^
lib.c:14:3: remark: marked this call a tail call candidate [-Rpass=tailcallelim]
  fprintf(stderr, "Received max %d\n", max);
  ^


so, I'm thinking this problem is a result of tail call optimization making
an assumption that is violated when mocking the function.

I'm unclear how to prevent tail call optimization without the big hammer
of -O0 

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

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

Re: [libvirt] Entering freeze for libvirt-3.5.0

2017-07-04 Thread Daniel P. Berrange
On Tue, Jul 04, 2017 at 12:21:21PM +0100, Daniel P. Berrange wrote:
> On Tue, Jul 04, 2017 at 01:03:52PM +0200, Andrea Bolognani wrote:
> > On Sat, 2017-07-01 at 14:18 +0400, Roman Bogorodskiy wrote:
> > > > qemuxml2argvtest fails consistently in my FreeBSD guest.
> > > 
> > > I guess that's caused by clang inlining functions that are mocked
> > > (specifically, some numa related stuff); I think that was discussed
> > > several times already. Anyway, it should work fine with '-O0' in CFLAGS.
> > 
> > Well, would you look at that. It does indeed work flawlessly
> > when compiled without optimizations! :O
> > 
> > I'm not sure if that would be considered a reasonable
> > compromise to get the test suite running on FreeBSD in the
> > context of CI, though. I think it working reliably without
> > messing with CFLAGS would be a requirement; others might
> > disagree.
> 
> Hmm, I thought I fixed that problem when I introduce this patch:
> 
>   commit 728cacc8abed2b8de39e7b96fa42fde6850ec23a
>   Author: Daniel P. Berrange 
>   Date:   Fri Apr 7 15:07:49 2017 +0100
> 
> annotate all mocked functions with noinline
> 
> 
> This made us annotate all mocked functions with noinline, which was
> sufficient to make CLang builds pass tests on Ubuntu VMs.

So I did some debugging and this is wierder than I can imagine possible.

I put a printf statement  in virNumaGetMaxNode in qemuxml2argvmock.c
to print out the return value.

I also put a printf statement in virNumaNodeIsAvailable in virnuma.c
(in the non-NUMACTL conditional block), that prints out the return
value received from virNumaGetMaxNode

The first printf displays 7, while the second printf displays -1

So we're definitely calling our mock override, but the return
value is getting mangled when seen by the caller, which is a
giant wtf to me.

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

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

Re: [libvirt] [PATCH v3 4/4] lxc: add possibility to define init uid/gid

2017-07-04 Thread Daniel P. Berrange
On Mon, Jun 26, 2017 at 11:41:00AM +0200, Cédric Bosdonnat wrote:
> Users may want to run the init command of a container as a special
> user / group. This is achieved by adding  and 
> elements. Note that the user can either provide a name or an ID to
> specify the user / group to be used.
> 
> This commit also fixes a side effect of being able to run the command
> as a non-root user: the user needs rights on the tty to allow shell
> job control.
> ---
>  docs/formatdomain.html.in |  7 +
>  docs/schemas/domaincommon.rng | 14 ++
>  src/conf/domain_conf.c|  9 ++
>  src/conf/domain_conf.h|  2 ++
>  src/lxc/lxc_container.c   | 52 
> +++
>  tests/lxcxml2xmldata/lxc-inituser.xml | 31 +
>  tests/lxcxml2xmltest.c|  1 +
>  7 files changed, 116 insertions(+)
>  create mode 100644 tests/lxcxml2xmldata/lxc-inituser.xml
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index e79a9d5be..f9a5177e0 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -334,6 +334,11 @@
>To set a custom work directory for the init, use the 
> initdir
>element.
>  
> +
> +  To run the init command as a given user or group, use the 
> inituser
> +  or initgroup elements respectively. Both elements can be 
> provided
> +  either a user (resp. group) id or a name.
> +

Should mention that you can prefix the user/group with a '+' to force
it to be treated as a numeric UID/GID. Without a '+' the numeric value
will first be tried as username.

If that is noted, then

Reviewed-by: Daniel P. Berrange 


Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

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

Re: [libvirt] [PATCH v3 3/4] lxc: allow user to specify command working directory

2017-07-04 Thread Daniel P. Berrange
On Mon, Jun 26, 2017 at 11:40:59AM +0200, Cédric Bosdonnat wrote:
> Some containers may want the application to run in a special directory.
> Add  element in the domain configuration to handle this case
> and use it in the lxc driver.
> ---
>  docs/formatdomain.html.in|  5 +
>  docs/schemas/domaincommon.rng|  5 +
>  src/conf/domain_conf.c   |  5 +
>  src/conf/domain_conf.h   |  1 +
>  src/lxc/lxc_container.c  |  2 ++
>  tests/lxcxml2xmldata/lxc-initdir.xml | 30 ++
>  tests/lxcxml2xmltest.c   |  1 +
>  7 files changed, 49 insertions(+)
>  create mode 100644 tests/lxcxml2xmldata/lxc-initdir.xml

Reviewed-by: Daniel P. Berrange 


Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

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

[libvirt] [PATCH] autogen.sh: tell user the correct make command

2017-07-04 Thread Daniel P. Berrange
When autogen.sh finishes it helpfully prints

  "Now type 'make' to compile libvirt."

which is fine if on a host with GNU make, but on *BSD running
'make' will end in tears. We should tell users to run 'gmake'
on these platforms. If 'gmake' doesn't exist then we should
report an error too

  "GNU make is required to build libvirt"

Signed-off-by: Daniel P. Berrange 
---
 autogen.sh | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/autogen.sh b/autogen.sh
index d5d836a..1e99ce8 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -193,4 +193,21 @@ else
 fi
 
 echo
-echo "Now type 'make' to compile libvirt."
+
+# Make sure we can find GNU make and tell the user
+# the right command to run
+make -v | grep "GNU Make" 1>/dev/null 2>&1
+if test $? = 0
+then
+MAKE=make
+else
+which gmake 1>/dev/null 2>&1
+if test $? = 0
+then
+MAKE=gmake
+else
+die "GNU make is required to build libvirt"
+fi
+fi
+
+echo "Now type '$MAKE' to compile libvirt."
-- 
2.9.4

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


Re: [libvirt] libvirt binding for DBUS

2017-07-04 Thread Daniel P. Berrange
On Tue, Jul 04, 2017 at 04:34:08PM +0200, Pavel Hrdina wrote:
> Hi,
> 
> Last week (Jun 26 - Jun 30) there was a Cockpit Hackfest and the main
> topic was integration virtualization support into Cockpit.  For that
> purpose Lars and me have started to work on a new libvirt dbus binding.
> 
> Currently the binding is written manually and only few APIs are
> supported, however the ultimate goal is to write a code generator
> and ensure that all APIs are covered by this binding (similarly to the
> python binding).
> 
> Dan, can you please setup hosting on libvirt.org?

Ok I've created the repo & imported the content from that github
repo. It is setup to mirror to github & gitlab too.

The main docs/downloads.html.in & bindings.html.in page could be
updated with an entry.

Also if you want to add a CI entry for jenkins, send a patch for the
libvirt-jenkins-ci repository jobs. If you add .travis.yml let me
know and I'll enable the travis account to run that repo too.

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

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


[libvirt] libvirt binding for DBUS

2017-07-04 Thread Pavel Hrdina
Hi,

Last week (Jun 26 - Jun 30) there was a Cockpit Hackfest and the main
topic was integration virtualization support into Cockpit.  For that
purpose Lars and me have started to work on a new libvirt dbus binding.

Currently the binding is written manually and only few APIs are
supported, however the ultimate goal is to write a code generator
and ensure that all APIs are covered by this binding (similarly to the
python binding).

Dan, can you please setup hosting on libvirt.org?

The binding is experimental and the API may and probably will change
until first official release.

Thanks,

Pavel

[1] 


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

Re: [libvirt] [PATCH v3 19/26] tests: Add tests for pSeries guests with multiple PHBs

2017-07-04 Thread Andrea Bolognani
On Fri, 2017-06-23 at 23:03 +0800, Andrea Bolognani wrote:
> Signed-off-by: Andrea Bolognani 
> ---
>  .../qemuxml2argv-pseries-phb-default-missing.args  | 22 +++
>  .../qemuxml2argv-pseries-phb-default-missing.xml   | 16 +++
>  .../qemuxml2argv-pseries-phb-simple.args   | 22 +++
>  .../qemuxml2argv-pseries-phb-simple.xml| 17 +++
>  tests/qemuxml2argvtest.c   |  8 ++
>  .../qemuxml2xmlout-pseries-phb-default-missing.xml | 33 
>++
>  .../qemuxml2xmlout-pseries-phb-simple.xml  | 33 
>++
>  tests/qemuxml2xmltest.c|  7 +
>  8 files changed, 158 insertions(+)
>  create mode 100644 
>tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-default-missing.args
>  create mode 100644 
>tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-default-missing.xml
>  create mode 100644 
>tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-simple.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-simple.xml
>  create mode 100644 
>tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-phb-default-missing.xml
>  create mode 100644 
>tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-phb-simple.xml

The attached patch should be squashed in to make sure the new
test implemented in [1] works correctly. In order for the test
case to work, [2] will need to be merged first - I plan to
squeeze it in between patches 07 and 08 before pushing.

Does that sound reasonable?


[1] https://www.redhat.com/archives/libvir-list/2017-July/msg00069.html
[2] https://www.redhat.com/archives/libvir-list/2017-July/msg00070.html
-- 
Andrea Bolognani / Red Hat / VirtualizationFrom 466421b399cc205f35848b5ec30a0061cd9100bb Mon Sep 17 00:00:00 2001
From: Andrea Bolognani 
Date: Tue, 4 Jul 2017 12:20:21 +0200
Subject: [PATCH v3 19.5/26] tests: Only the default PHB can have targetIndex=0

Signed-off-by: Andrea Bolognani 
---
 ...qemuxml2argv-pseries-phb-wrong-target-index.xml | 22 ++
 tests/qemuxml2argvtest.c   |  3 +++
 tests/qemuxml2xmltest.c|  3 +++
 3 files changed, 28 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml
new file mode 100644
index 000..48e3b1f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-phb-wrong-target-index.xml
@@ -0,0 +1,22 @@
+
+  QEMUGuest1
+  1ccfd97d-5eb4-478a-bbe6-88d254c16db7
+  524288
+  1
+  
+hvm
+  
+  
+/usr/bin/qemu-system-ppc64
+
+
+  
+
+
+
+  
+
+
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ff68884..02e3235 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1716,6 +1716,9 @@ mymain(void)
 DO_TEST("pseries-phb-default-missing",
 QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CHARDEV,
 QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
+DO_TEST_PARSE_ERROR("pseries-phb-wrong-target-index",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CHARDEV,
+QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
 
 DO_TEST("disk-ide-drive-split",
 QEMU_CAPS_NODEFCONFIG,
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index e8d08b4..2da1b70 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -712,6 +712,9 @@ mymain(void)
 DO_TEST("pseries-phb-default-missing",
 QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CHARDEV,
 QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
+DO_TEST_PARSE_ERROR("pseries-phb-wrong-target-index",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CHARDEV,
+QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
 
 DO_TEST("balloon-device-auto", NONE);
 DO_TEST("balloon-device-period", NONE);
-- 
2.7.5

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

[libvirt] [PATCH] tests: Add DO_TEST_PARSE_ERROR() to qemuxml2xml

2017-07-04 Thread Andrea Bolognani
qemuxml2argv already supports the ability to include test
cases that are known not to make it past XML parsing, and
since we want to keep qemuxml2xml in sync with it as much
as possible, we need to implement this missing feature.

Signed-off-by: Andrea Bolognani 
---
 tests/qemuxml2xmltest.c | 104 +++-
 1 file changed, 67 insertions(+), 37 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index c74614c..66729fa 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -28,6 +28,10 @@ enum {
 WHEN_BOTH = 3,
 };
 
+typedef enum {
+FLAG_EXPECT_PARSE_ERROR = 1 << 0,
+} virQemuXML2XMLTestFlags;
+
 struct testInfo {
 char *inName;
 char *outActiveName;
@@ -36,6 +40,8 @@ struct testInfo {
 virBitmapPtr activeVcpus;
 
 virQEMUCapsPtr qemuCaps;
+
+virQemuXML2XMLTestFlags flags;
 };
 
 static int
@@ -55,12 +61,15 @@ static int
 testXML2XMLActive(const void *opaque)
 {
 const struct testInfo *info = opaque;
+testCompareDomXML2XMLResult flags = 
TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS;
+
+if (info->flags & FLAG_EXPECT_PARSE_ERROR)
+flags = TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE;
 
 return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
   info->inName, info->outActiveName, true,
   qemuXML2XMLActivePreFormatCallback,
-  opaque, 0,
-  TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS);
+  opaque, 0, flags);
 }
 
 
@@ -68,11 +77,14 @@ static int
 testXML2XMLInactive(const void *opaque)
 {
 const struct testInfo *info = opaque;
+testCompareDomXML2XMLResult flags = 
TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS;
+
+if (info->flags & FLAG_EXPECT_PARSE_ERROR)
+flags = TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE;
 
 return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, info->inName,
   info->outInactiveName, false,
-  NULL, opaque, 0,
-  TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS);
+  NULL, opaque, 0, flags);
 }
 
 
@@ -195,6 +207,8 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
   VIR_DOMAIN_DEF_PARSE_STATUS |
   VIR_DOMAIN_DEF_PARSE_ACTUAL_NET |
   VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES))) {
+if (data->flags & FLAG_EXPECT_PARSE_ERROR)
+goto ok;
 VIR_TEST_DEBUG("Failed to parse domain status XML:\n%s", source);
 goto cleanup;
 }
@@ -217,6 +231,17 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
 
 ret = 0;
 
+ ok:
+if (data->flags & FLAG_EXPECT_PARSE_ERROR) {
+if (ret < 0) {
+VIR_TEST_DEBUG("Got expected error");
+ret = 0;
+} else {
+VIR_TEST_DEBUG("Error expected but there wasn't any");
+ret = -1;
+}
+}
+
  cleanup:
 xmlKeepBlanksDefault(keepBlanksDefault);
 xmlFreeDoc(xml);
@@ -249,7 +274,8 @@ static int
 testInfoSet(struct testInfo *info,
 const char *name,
 int when,
-int gic)
+int gic,
+virQemuXML2XMLTestFlags flags)
 {
 if (!(info->qemuCaps = virQEMUCapsNew()))
 goto error;
@@ -296,6 +322,8 @@ testInfoSet(struct testInfo *info,
 }
 }
 
+info->flags = flags;
+
 return 0;
 
  error:
@@ -335,9 +363,9 @@ mymain(void)
 /* TODO: test with format probing disabled too */
 driver.config->allowDiskFormatProbing = true;
 
-# define DO_TEST_FULL(name, when, gic, ...)
\
+# define DO_TEST_FULL(name, when, gic, flags, ...) 
\
 do {   
\
-if (testInfoSet(, name, when, gic) < 0) { 
\
+if (testInfoSet(, name, when, gic, flags) < 0) {  
\
 VIR_TEST_DEBUG("Failed to generate test data for '%s'", name); 
\
 return -1; 
\
 }  
\
@@ -364,8 +392,10 @@ mymain(void)
 # define NONE QEMU_CAPS_LAST
 
 # define DO_TEST(name, ...) \
-DO_TEST_FULL(name, WHEN_BOTH, GIC_NONE, __VA_ARGS__)
+DO_TEST_FULL(name, WHEN_BOTH, GIC_NONE, 0, __VA_ARGS__)
 
+# define DO_TEST_PARSE_ERROR(name, ...) \
+DO_TEST_FULL(name, WHEN_BOTH, GIC_NONE, FLAG_EXPECT_PARSE_ERROR, 
__VA_ARGS__)
 
 
 /* Unset or set all envvars here that are copied in qemudBuildCommandLine
@@ -493,7 +523,7 @@ mymain(void)
 QEMU_CAPS_SCSI_DISK_WWN);
 DO_TEST("disk-mirror-old", NONE);

Re: [libvirt] [PATCH v3 13/26] conf: Parse and format

2017-07-04 Thread Andrea Bolognani
On Fri, 2017-06-30 at 17:10 +0530, Shivaprasad bhat wrote:
> > @@ -9348,6 +9351,23 @@ virDomainControllerDefParseXML(xmlNodePtr node,
> >  goto error;
> >  }
> >  }
> > +if (idx) {
> > +if (virStrToLong_i(idx, NULL, 0,
> > +   >opts.pciopts.idx) < 0) {
> > +virReportError(VIR_ERR_XML_ERROR,
> > +   _("Invalid target index '%s' in PCI 
> > controller"),
> > +   idx);
> > +goto error;
> > +}
> > +if (def->opts.pciopts.idx < 0 ||
> > +def->opts.pciopts.idx > 31) {
> > +virReportError(VIR_ERR_XML_ERROR,
> > +   _("PCI controller target index '%s' out of "
> > + "range - must be 0-31"),
> > +   idx);
> > +goto error;
> > +}
> > +}
> 
> Better to enforce def->idx == 0 to have def->opts.pciopts.idx as 0 ? That 
> would always assure def->idx == 0 as the implicit PHB.
> 
> Qemu today allows "-device spapr-pci-host-bridge,index=X,id=pci.0" when X != 
> 0, and we will generate it for implcit phb(which we normally dont)
> when def->opts.pciopts.idx != 0 in Patch 18. Not sure what all 
> problems/confusions could come because of this inconsistency.

Agreed.

The attached patch should be squashed into this commit to
prevent such a configuration from being accepted. I'm also
working on a test case for this specific configuration.

Laine, are you okay with me squashing this in and keeping
the Reviewed-by?

-- 
Andrea Bolognani / Red Hat / VirtualizationFrom 2a796858ba76268e7ed0da6cf5dbd2f69a0e0ef6 Mon Sep 17 00:00:00 2001
From: Andrea Bolognani 
Date: Tue, 4 Jul 2017 08:04:48 +0200
Subject: [PATCH v3 13.5/26] qemu: Only the default PHB can have targetIndex=0

Signed-off-by: Andrea Bolognani 
---
 src/conf/domain_conf.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c797f9f..8a64fbc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9376,6 +9376,13 @@ virDomainControllerDefParseXML(xmlNodePtr node,
targetIndex);
 goto error;
 }
+if ((def->idx == 0 && def->opts.pciopts.targetIndex != 0) ||
+(def->idx != 0 && def->opts.pciopts.targetIndex == 0)) {
+virReportError(VIR_ERR_XML_ERROR,
+   _("Only the PCI controller with index 0 can "
+ "have target index 0, and vice versa"));
+goto error;
+}
 }
 if (numaNode >= 0)
 def->opts.pciopts.numaNode = numaNode;
-- 
2.7.5

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

Re: [libvirt] Entering freeze for libvirt-3.5.0

2017-07-04 Thread Daniel P. Berrange
On Tue, Jul 04, 2017 at 01:03:52PM +0200, Andrea Bolognani wrote:
> On Sat, 2017-07-01 at 14:18 +0400, Roman Bogorodskiy wrote:
> > > qemuxml2argvtest fails consistently in my FreeBSD guest.
> > 
> > I guess that's caused by clang inlining functions that are mocked
> > (specifically, some numa related stuff); I think that was discussed
> > several times already. Anyway, it should work fine with '-O0' in CFLAGS.
> 
> Well, would you look at that. It does indeed work flawlessly
> when compiled without optimizations! :O
> 
> I'm not sure if that would be considered a reasonable
> compromise to get the test suite running on FreeBSD in the
> context of CI, though. I think it working reliably without
> messing with CFLAGS would be a requirement; others might
> disagree.

Hmm, I thought I fixed that problem when I introduce this patch:

  commit 728cacc8abed2b8de39e7b96fa42fde6850ec23a
  Author: Daniel P. Berrange 
  Date:   Fri Apr 7 15:07:49 2017 +0100

annotate all mocked functions with noinline


This made us annotate all mocked functions with noinline, which was
sufficient to make CLang builds pass tests on Ubuntu VMs.

Perhaps my syntax-check rule is missing some functions that still
need to be marked noinline to get BSD working ?

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

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

Re: [libvirt] Entering freeze for libvirt-3.5.0

2017-07-04 Thread Andrea Bolognani
On Sat, 2017-07-01 at 14:18 +0400, Roman Bogorodskiy wrote:
> > qemuxml2argvtest fails consistently in my FreeBSD guest.
> 
> I guess that's caused by clang inlining functions that are mocked
> (specifically, some numa related stuff); I think that was discussed
> several times already. Anyway, it should work fine with '-O0' in CFLAGS.

Well, would you look at that. It does indeed work flawlessly
when compiled without optimizations! :O

I'm not sure if that would be considered a reasonable
compromise to get the test suite running on FreeBSD in the
context of CI, though. I think it working reliably without
messing with CFLAGS would be a requirement; others might
disagree.

-- 
Andrea Bolognani / Red Hat / Virtualization

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

[libvirt] [PATCH 5/5] tests: virjson: Test string escaping

2017-07-04 Thread Peter Krempa
Make sure that JSON strings can contain characters which need to be
escaped (double quotes, backslashes, tabs, etc.) and that JSON objects
formatted into strings can be nested into strings.
---
 tests/virjsontest.c | 67 +
 1 file changed, 67 insertions(+)

diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index 451275a4c..e4176af0e 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -325,6 +325,67 @@ testJSONCopy(const void *data)


 static int
+testJSONEscapeObj(const void *data ATTRIBUTE_UNUSED)
+{
+virJSONValuePtr json = NULL;
+virJSONValuePtr nestjson = NULL;
+virJSONValuePtr parsejson = NULL;
+char *neststr = NULL;
+char *result = NULL;
+const char *parsednestedstr;
+int ret = -1;
+
+if (virJSONValueObjectCreate(,
+ "s:stringkey", "stringvalue",
+ "i:numberkey", 1234,
+ "b:booleankey", false, NULL) < 0) {
+VIR_TEST_VERBOSE("failed to create nested json object");
+goto cleanup;
+}
+
+if (!(neststr = virJSONValueToString(nestjson, false))) {
+VIR_TEST_VERBOSE("failed to format nested json object");
+goto cleanup;
+}
+
+if (virJSONValueObjectCreate(, "s:test", neststr, NULL) < 0) {
+VIR_TEST_VERBOSE("Failed to create json object");
+goto cleanup;
+}
+
+if (!(result = virJSONValueToString(json, false))) {
+VIR_TEST_VERBOSE("Failed to format json object");
+goto cleanup;
+}
+
+if (!(parsejson = virJSONValueFromString(result))) {
+VIR_TEST_VERBOSE("Failed to parse JSON with nested JSON in string");
+goto cleanup;
+}
+
+if (!(parsednestedstr = virJSONValueObjectGetString(parsejson, "test"))) {
+VIR_TEST_VERBOSE("Failed to retrieve string containing nested json");
+goto cleanup;
+}
+
+if (STRNEQ(parsednestedstr, neststr)) {
+virTestDifference(stderr, neststr, parsednestedstr);
+goto cleanup;
+}
+
+ret = 0;
+
+ cleanup:
+VIR_FREE(neststr);
+VIR_FREE(result);
+virJSONValueFree(json);
+virJSONValueFree(nestjson);
+virJSONValueFree(parsejson);
+return ret;
+}
+
+
+static int
 mymain(void)
 {
 int ret = 0;
@@ -445,6 +506,10 @@ mymain(void)
 DO_TEST_PARSE("integer", "1", NULL);
 DO_TEST_PARSE("boolean", "true", NULL);
 DO_TEST_PARSE("null", "null", NULL);
+
+DO_TEST_PARSE("escaping symbols", "[\"\\\"\\t\\n\"]", NULL);
+DO_TEST_PARSE("escaped strings", "[\"{\\\"blurb\\\":\\\"test\\\"}\"]", 
NULL);
+
 DO_TEST_PARSE_FAIL("incomplete keyword", "tr");
 DO_TEST_PARSE_FAIL("overdone keyword", "[ truest ]");
 DO_TEST_PARSE_FAIL("unknown keyword", "huh");
@@ -477,6 +542,8 @@ mymain(void)
 DO_TEST_FULL("lookup with correct type", Lookup,
  "{ \"a\": {}, \"b\": 1, \"c\": \"str\", \"d\": [] }",
  NULL, true);
+DO_TEST_FULL("create object with nested json in attribute", EscapeObj,
+ NULL, NULL, true);

 return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
2.12.2

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


[libvirt] [PATCH 4/5] tests: virjson: Test formatting along with parsing of JSON objects

2017-07-04 Thread Peter Krempa
Format the parsed string back and compare it to the original (or
modified) string for back and forth comparison.
---
 tests/virjsontest.c | 58 -
 1 file changed, 44 insertions(+), 14 deletions(-)

diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index 2a6b2f44e..451275a4c 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -21,6 +21,8 @@ testJSONFromString(const void *data)
 {
 const struct testInfo *info = data;
 virJSONValuePtr json;
+const char *expectstr = info->expect ? info->expect : info->doc;
+char *formatted = NULL;
 int ret = -1;

 json = virJSONValueFromString(info->doc);
@@ -43,9 +45,20 @@ testJSONFromString(const void *data)

 VIR_TEST_DEBUG("Parsed %s\n", info->doc);

+if (!(formatted = virJSONValueToString(json, false))) {
+VIR_TEST_VERBOSE("Failed to format json data\n");
+goto cleanup;
+}
+
+if (STRNEQ(expectstr, formatted)) {
+virTestDifference(stderr, expectstr, formatted);
+goto cleanup;
+}
+
 ret = 0;

  cleanup:
+VIR_FREE(formatted);
 virJSONValueFree(json);
 return ret;
 }
@@ -323,23 +336,39 @@ mymain(void)
 ret = -1;   \
 } while (0)

-#define DO_TEST_PARSE(name, doc)\
-DO_TEST_FULL(name, FromString, doc, NULL, true)
+/**
+ * DO_TEST_PARSE:
+ * @name: test name
+ * @doc: source JSON string
+ * @expect: expected output JSON formatted from parsed @doc
+ *
+ * Parses @doc and formats it back. If @expect is NULL the result has to be
+ * identical to @doc.
+ */
+#define DO_TEST_PARSE(name, doc, expect)\
+DO_TEST_FULL(name, FromString, doc, expect, true)

 #define DO_TEST_PARSE_FAIL(name, doc)   \
 DO_TEST_FULL(name, FromString, doc, NULL, false)


-DO_TEST_PARSE("Simple", "{\"return\": {}, \"id\": \"libvirt-1\"}");
+DO_TEST_PARSE("Simple", "{\"return\": {}, \"id\": \"libvirt-1\"}",
+  "{\"return\":{},\"id\":\"libvirt-1\"}");
 DO_TEST_PARSE("NotSoSimple", "{\"QMP\": {\"version\": {\"qemu\":"
   "{\"micro\": 91, \"minor\": 13, \"major\": 0},"
-  "\"package\": \" (qemu-kvm-devel)\"}, \"capabilities\": 
[]}}");
-
+  "\"package\": \" (qemu-kvm-devel)\"}, \"capabilities\": 
[]}}",
+  "{\"QMP\":{\"version\":{\"qemu\":"
+  "{\"micro\":91,\"minor\":13,\"major\":0},"
+  "\"package\":\" (qemu-kvm-devel)\"},\"capabilities\":[]}}");

 DO_TEST_PARSE("Harder", "{\"return\": [{\"filename\": "
   
"\"unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,server\","
   "\"label\": \"charmonitor\"}, {\"filename\": 
\"pty:/dev/pts/158\","
-  "\"label\": \"charserial0\"}], \"id\": \"libvirt-3\"}");
+  "\"label\": \"charserial0\"}], \"id\": \"libvirt-3\"}",
+  "{\"return\":[{\"filename\":"
+  
"\"unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,server\","
+  
"\"label\":\"charmonitor\"},{\"filename\":\"pty:/dev/pts/158\","
+  "\"label\":\"charserial0\"}],\"id\":\"libvirt-3\"}");

 DO_TEST_PARSE("VeryHard", "{\"return\":[{\"name\":\"quit\"},{\"name\":"
   "\"eject\"},{\"name\":\"change\"},{\"name\":\"screendump\"},"
@@ -364,7 +393,7 @@ mymain(void)
   "\"query-mice\"},{\"name\":\"query-vnc\"},{\"name\":"
   "\"query-spice\"},{\"name\":\"query-name\"},{\"name\":"
   "\"query-uuid\"},{\"name\":\"query-migrate\"},{\"name\":"
-  "\"query-balloon\"}],\"id\":\"libvirt-2\"}");
+  "\"query-balloon\"}],\"id\":\"libvirt-2\"}", NULL);

 DO_TEST_FULL("add and remove", AddRemove,
  "{\"name\": \"sample\", \"value\": true}",
@@ -400,21 +429,22 @@ mymain(void)
  "\"query-balloon\"}], \"id\": \"libvirt-2\"}", NULL, true);


-DO_TEST_PARSE("almost nothing", "[]");
+DO_TEST_PARSE("almost nothing", "[]", NULL);
 DO_TEST_PARSE_FAIL("nothing", "");

-DO_TEST_PARSE("number without garbage", "[ 234545 ]");
+DO_TEST_PARSE("number without garbage", "[ 234545 ]", "[234545]");
 DO_TEST_PARSE_FAIL("number with garbage", "[ 2345b45 ]");

-DO_TEST_PARSE("float without garbage", "[ 0.0314159e+100 ]");
+DO_TEST_PARSE("float without garbage", "[ 0.0314159e+100 ]", 
"[0.0314159e+100]");
 DO_TEST_PARSE_FAIL("float with garbage", "[ 0.0314159ee+100 ]");

-DO_TEST_PARSE("string", "[ \"The meaning of life\" ]");
+DO_TEST_PARSE("string", "[ \"The meaning of life\" ]",
+  "[\"The meaning of life\"]");
 DO_TEST_PARSE_FAIL("unterminated string", "[ \"The meaning of lif ]");

-DO_TEST_PARSE("integer", "1");
-DO_TEST_PARSE("boolean", "true");
-DO_TEST_PARSE("null", "null");
+DO_TEST_PARSE("integer", "1", NULL);
+

[libvirt] [PATCH 2/5] tests: virjson: Modify logic in testJSONFromString

2017-07-04 Thread Peter Krempa
To allow better testing in case where the string was parsed, modify the
logic so that the regular code path is not included in a conditional
block.
---
 tests/virjsontest.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index b67f68ccb..9ecde680f 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -25,24 +25,24 @@ testJSONFromString(const void *data)

 json = virJSONValueFromString(info->doc);

-if (info->pass) {
-if (!json) {
+if (!json) {
+if (info->pass) {
 VIR_TEST_VERBOSE("Fail to parse %s\n", info->doc);
-ret = -1;
-goto cleanup;
-} else {
-VIR_TEST_DEBUG("Parsed %s\n", info->doc);
-}
-} else {
-if (json) {
-VIR_TEST_VERBOSE("Should not have parsed %s\n", info->doc);
-ret = -1;
 goto cleanup;
 } else {
 VIR_TEST_DEBUG("Fail to parse %s\n", info->doc);
+ret = 0;
+goto cleanup;
 }
 }

+if (!info->pass) {
+VIR_TEST_VERBOSE("Should not have parsed %s\n", info->doc);
+goto cleanup;
+}
+
+VIR_TEST_DEBUG("Parsed %s\n", info->doc);
+
 ret = 0;

  cleanup:
-- 
2.12.2

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


[libvirt] [PATCH 3/5] tests: virjson: Remove spaces from 'very-hard' parsing example

2017-07-04 Thread Peter Krempa
The example is rather long and upcomming patch will check whether the
string can be formatted back. As the formatted string lacks spaces and
adding the 'expect' string with spaces would be rather long, just drop
spaces from this test case.

There are other test cases which do contain spaces.
---
 tests/virjsontest.c | 48 
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index 9ecde680f..2a6b2f44e 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -341,30 +341,30 @@ mymain(void)
   "\"label\": \"charmonitor\"}, {\"filename\": 
\"pty:/dev/pts/158\","
   "\"label\": \"charserial0\"}], \"id\": \"libvirt-3\"}");

-DO_TEST_PARSE("VeryHard", "{\"return\": [{\"name\": \"quit\"}, {\"name\":"
-  "\"eject\"}, {\"name\": \"change\"}, {\"name\": 
\"screendump\"},"
-  "{\"name\": \"stop\"}, {\"name\": \"cont\"}, {\"name\": "
-  "\"system_reset\"}, {\"name\": \"system_powerdown\"}, "
-  "{\"name\": \"device_add\"}, {\"name\": \"device_del\"}, "
-  "{\"name\": \"cpu\"}, {\"name\": \"memsave\"}, {\"name\": "
-  "\"pmemsave\"}, {\"name\": \"migrate\"}, {\"name\": "
-  "\"migrate_cancel\"}, {\"name\": \"migrate_set_speed\"},"
-  "{\"name\": \"client_migrate_info\"}, {\"name\": "
-  "\"migrate_set_downtime\"}, {\"name\": \"netdev_add\"}, "
-  "{\"name\": \"netdev_del\"}, {\"name\": \"block_resize\"},"
-  "{\"name\": \"balloon\"}, {\"name\": \"set_link\"}, 
{\"name\":"
-  "\"getfd\"}, {\"name\": \"closefd\"}, {\"name\": 
\"block_passwd\"},"
-  "{\"name\": \"set_password\"}, {\"name\": 
\"expire_password\"},"
-  "{\"name\": \"qmp_capabilities\"}, {\"name\": "
-  "\"human-monitor-command\"}, {\"name\": \"query-version\"},"
-  "{\"name\": \"query-commands\"}, {\"name\": 
\"query-chardev\"},"
-  "{\"name\": \"query-block\"}, {\"name\": 
\"query-blockstats\"}, "
-  "{\"name\": \"query-cpus\"}, {\"name\": \"query-pci\"}, 
{\"name\":"
-  "\"query-kvm\"}, {\"name\": \"query-status\"}, {\"name\": "
-  "\"query-mice\"}, {\"name\": \"query-vnc\"}, {\"name\": "
-  "\"query-spice\"}, {\"name\": \"query-name\"}, {\"name\": "
-  "\"query-uuid\"}, {\"name\": \"query-migrate\"}, {\"name\": "
-  "\"query-balloon\"}], \"id\": \"libvirt-2\"}");
+DO_TEST_PARSE("VeryHard", "{\"return\":[{\"name\":\"quit\"},{\"name\":"
+  "\"eject\"},{\"name\":\"change\"},{\"name\":\"screendump\"},"
+  "{\"name\":\"stop\"},{\"name\":\"cont\"},{\"name\":"
+  "\"system_reset\"},{\"name\":\"system_powerdown\"},"
+  "{\"name\":\"device_add\"},{\"name\":\"device_del\"},"
+  "{\"name\":\"cpu\"},{\"name\":\"memsave\"},{\"name\":"
+  "\"pmemsave\"},{\"name\":\"migrate\"},{\"name\":"
+  "\"migrate_cancel\"},{\"name\":\"migrate_set_speed\"},"
+  "{\"name\":\"client_migrate_info\"},{\"name\":"
+  "\"migrate_set_downtime\"},{\"name\":\"netdev_add\"},"
+  "{\"name\":\"netdev_del\"},{\"name\":\"block_resize\"},"
+  "{\"name\":\"balloon\"},{\"name\":\"set_link\"},{\"name\":"
+  
"\"getfd\"},{\"name\":\"closefd\"},{\"name\":\"block_passwd\"},"
+  "{\"name\":\"set_password\"},{\"name\":\"expire_password\"},"
+  "{\"name\":\"qmp_capabilities\"},{\"name\":"
+  "\"human-monitor-command\"},{\"name\":\"query-version\"},"
+  "{\"name\":\"query-commands\"},{\"name\":\"query-chardev\"},"
+  "{\"name\":\"query-block\"},{\"name\":\"query-blockstats\"},"
+  
"{\"name\":\"query-cpus\"},{\"name\":\"query-pci\"},{\"name\":"
+  "\"query-kvm\"},{\"name\":\"query-status\"},{\"name\":"
+  "\"query-mice\"},{\"name\":\"query-vnc\"},{\"name\":"
+  "\"query-spice\"},{\"name\":\"query-name\"},{\"name\":"
+  "\"query-uuid\"},{\"name\":\"query-migrate\"},{\"name\":"
+  "\"query-balloon\"}],\"id\":\"libvirt-2\"}");

 DO_TEST_FULL("add and remove", AddRemove,
  "{\"name\": \"sample\", \"value\": true}",
-- 
2.12.2

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


[libvirt] [PATCH 1/5] tests: Rename jsontest to virjsontest

2017-07-04 Thread Peter Krempa
---
 tests/Makefile.am   | 8 
 tests/{jsontest.c => virjsontest.c} | 0
 2 files changed, 4 insertions(+), 4 deletions(-)
 rename tests/{jsontest.c => virjsontest.c} (100%)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 19986dc99..3596b5ff1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -328,7 +328,7 @@ test_programs += objectlocking
 endif WITH_CIL

 if WITH_YAJL
-test_programs += jsontest
+test_programs += virjsontest
 endif WITH_YAJL

 test_programs += \
@@ -1375,9 +1375,9 @@ virfirewalltest_SOURCES = \
 virfirewalltest_LDADD = $(LDADDS) $(DBUS_LIBS)
 virfirewalltest_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)

-jsontest_SOURCES = \
-   jsontest.c testutils.h testutils.c
-jsontest_LDADD = $(LDADDS)
+virjsontest_SOURCES = \
+   virjsontest.c testutils.h testutils.c
+virjsontest_LDADD = $(LDADDS)

 utiltest_SOURCES = \
utiltest.c testutils.h testutils.c
diff --git a/tests/jsontest.c b/tests/virjsontest.c
similarity index 100%
rename from tests/jsontest.c
rename to tests/virjsontest.c
-- 
2.12.2

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


[libvirt] [PATCH 0/5] tests: json: Improve testing of parsing and formatting

2017-07-04 Thread Peter Krempa
For an experiment I was doing I needed to nest JSON string into an attribute of
a different JSON string, so I wrote some tests for that.

The experiment failed, but the tests may make sense to have in libvirt.

Peter Krempa (5):
  tests: Rename jsontest to virjsontest
  tests: virjson: Modify logic in testJSONFromString
  tests: virjson: Remove spaces from 'very-hard' parsing example
  tests: virjson: Test formatting along with parsing of JSON objects
  tests: virjson: Test string escaping

 tests/Makefile.am   |   8 +-
 tests/{jsontest.c => virjsontest.c} | 195 +++-
 2 files changed, 150 insertions(+), 53 deletions(-)
 rename tests/{jsontest.c => virjsontest.c} (69%)

-- 
2.12.2

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


Re: [libvirt] Entering freeze for libvirt-3.5.0

2017-07-04 Thread Andrea Bolognani
On Mon, 2017-07-03 at 18:47 +0200, Guido Günther wrote:
> > > Anyway, I'll try to find a way to debug what's going on with
> > > virnetsockettest.
> > 
> > IIRC Debian disabled this test years ago.
> > 
> > Guido, have you ever discovered the cause?
> 
> No, sorry. I diabled it ages ago since it failed randomly and never got
> around to have a look.

I just ran 1 iterations of the test on a Debian guest
without running into a single failure. Maybe it's time to
revisit that decision, especially with Stretch out of the
door? Any other test cases that have been blacklisted and
might not need it anymore?

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH 1/6] lib: Remove misplaced and redundant comments

2017-07-04 Thread Peter Krempa
On Sat, Jul 01, 2017 at 10:41:24 -0400, John Ferlan wrote:
> 
> 
> On 06/23/2017 09:33 AM, Peter Krempa wrote:
> > It's obvious that unsigned long long is 64 bit and also our web page
> > generator would misplace the comment after the return value due to the
> > way it's parsing them.
> > ---
> >  src/libvirt-domain.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> 
> Reviewed-by: John Ferlan 
> 
> John
> 
> (this one's safe for freeze if you care, but the rest should wait for
> after release)

I've pushed this one so that the docs embedded in the upcomming release
are already fixed.

Thanks.


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

Re: [libvirt] [PATCH 00/12] qemu: support chardev for all machvirt config

2017-07-04 Thread Christoffer Dall
Hi Cole,

On Mon, Jun 26, 2017 at 02:01:41PM -0400, Cole Robinson wrote:
> Drew pointed out that we can use -chardev with machvirt platform
> serial devices like:
> 
>   -chardev pty,id=foo
>   -serial chardev:foo
> 
> And indeed it looks like qemu has supported this for as long as -chardev
> has been around. Wiring this up will enable all the modern -chardev
> features for every machvirt config (and some other arch/machine types).
> 
> However just enabling that change is going to cause a lot of unneeded
> test suite churn, due to the fact that some code is still checking for
> qemu -chardev support, even though our minimum qemu version always has
> chardev nowadays. So take the opportunity to exorcise QEMU_CAPS_CHARDEV

I tried with two mainline QEMU versions (the default old one packaged
with Debian and a recent upstream commit) and this series seems to work
as intended, so:

Tested-by: Christoffer Dall 

> 
> * Patch 1 reverts Christopher's recent patch, to unbreak existing configs

Sorry about that one, I realized when I came back from holiday that my
test setup was broken and I was testing using the system install of
libvirt, not the deveopment one, and I happened to have created a VM
with the same name in both instances, whoops.

Thanks a lot for picking this up and fixing it properly.

-Christoffer


> * Patch 2-3 make pci-serial work for machvirt and demonstrate it with a
>   test suite change.
> * Patch 4-10 slowly strip out QEMU_CAPS_DEVICE
> * Patch 11 adds -chardev support for platform serial devices
> * Patch 12 is a cleanup
> 
> Cole Robinson (12):
>   Revert "qemu: Support chardevs with ARM virt machines"
>   qemu: caps: Tweak arm conditional in SupportsChardev
>   tests: qemuxml2argv: Add an aarch64 pci-serial test
>   qemu: command: Remove old style -parallel building
>   qemu: command: Drop some QEMU_CAPS_CHARDEV checks
>   qemu: command: always use -chardev for monitor config
>   tests: qemuxml2argv: drop redundant serial testing
>   tests: qemuxml2argv: Drop old style serial testing
>   tests: qemuxml2argv: Add some QEMU_CAPS_CHARDEV annotations
>   qemu: caps: blacklist QEMU_CAPS_CHARDEV
>   qemu: command: support -chardev for platform devices
>   qemu: Rename SupportsChardev to IsPlatformDevice
> 
>  src/qemu/qemu_capabilities.c   |  46 +---
>  src/qemu/qemu_capabilities.h   |   6 +-
>  src/qemu/qemu_command.c| 243 
> ++---
>  src/qemu/qemu_process.c|   9 +-
>  tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml   |   1 -
>  .../caps_2.6.0-gicv2.aarch64.xml   |   1 -
>  .../caps_2.6.0-gicv3.aarch64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml  |   1 -
>  tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml|   1 -
>  tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml|   1 -
>  tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |   1 -
>  tests/qemucapabilitiesdata/caps_2.9.50.s390x.xml   |   1 -
>  tests/qemuhelptest.c   |   5 -
>  .../qemuxml2argv-aarch64-aavmf-virtio-mmio.args|   4 +-
>  .../qemuxml2argv-aarch64-acpi-uefi.args|   4 +-
>  .../qemuxml2argv-aarch64-cpu-passthrough.args  |   4 +-
>  .../qemuxml2argv-aarch64-gic-host.args |   4 +-
>  .../qemuxml2argv-aarch64-gic-none-tcg.args |   4 +-
>  .../qemuxml2argv-aarch64-gic-v2.args   |   4 +-
>  .../qemuxml2argv-aarch64-gic-v3.args   |   4 +-
>  .../qemuxml2argv-aarch64-kvm-32-on-64.args |   7 +-
>  .../qemuxml2argv-aarch64-noacpi-nouefi.args|   4 +-
>  .../qemuxml2argv-aarch64-noacpi-uefi.args  |   4 +-
>  .../qemuxml2argv-aarch64-pci-serial.args   |  26 +++
>  .../qemuxml2argv-aarch64-pci-serial.xml|  17 ++
>  ...muxml2argv-aarch64-usb-controller-nec-xhci.args |   4 +-
>  ...uxml2argv-aarch64-usb-controller-qemu-xhci.args |   4 +-
>  .../qemuxml2argv-aarch64-video-virtio-gpu-pci.args |   4 +-
>  ...l2argv-aarch64-virt-2.6-virtio-pci-default.args |   7 +-
>  .../qemuxml2argv-aarch64-virt-default-nic.args |   5 +-
>  .../qemuxml2argv-aarch64-virt-virtio.args  |   7 +-
>  .../qemuxml2argv-aarch64-virtio-pci-default.args   |   7 +-
>  

[libvirt] [PATCH go-xml] Add support for device RNG

2017-07-04 Thread Thomas Hipp
Add support for device RNG (random number generator), and add test code.

Signed-off-by: Thomas Hipp 
---
 domain.go  | 34 +++
 domain_test.go | 85 ++
 2 files changed, 119 insertions(+)

diff --git a/domain.go b/domain.go
index f9e3a80..b4f56bf 100644
--- a/domain.go
+++ b/domain.go
@@ -184,6 +184,8 @@ type DomainInterfaceSource struct {
Pathstring `xml:"path,attr,omitempty"`
Modestring `xml:"mode,attr,omitempty"`
Portuint   `xml:"port,attr,omitempty"`
+   Service string `xml:"service,attr,omitempty"`
+   Hoststring `xml:"host,attr,omitempty"`
 }
 
 type DomainInterfaceTarget struct {
@@ -384,6 +386,25 @@ type DomainSound struct {
Address *DomainAddress`xml:"address"`
 }
 
+type DomainRNGRate struct {
+   Bytes  uint `xml:"bytes,attr"`
+   Period uint `xml:"period,attr,omitempty"`
+}
+
+type DomainRNGBackend struct {
+   Backend string  `xml:",chardata"`
+   Model   string  `xml:"model,attr"`
+   Typestring  `xml:"type,attr,omitempty"`
+   Sources []DomainInterfaceSource `xml:"source"`
+}
+
+type DomainRNG struct {
+   XMLName xml.Name  `xml:"rng"`
+   Model   string`xml:"model,attr"`
+   Rate*DomainRNGRate`xml:"rate"`
+   Backend *DomainRNGBackend `xml:"backend"`
+}
+
 type DomainDeviceList struct {
Emulatorstring `xml:"emulator,omitempty"`
Controllers []DomainController `xml:"controller"`
@@ -398,6 +419,7 @@ type DomainDeviceList struct {
Channels[]DomainChannel`xml:"channel"`
MemBalloon  *DomainMemBalloon  `xml:"memballoon"`
Sounds  []DomainSound  `xml:"sound"`
+   RNGs[]DomainRNG`xml:"rng"`
 }
 
 type DomainMemory struct {
@@ -734,3 +756,15 @@ func (d *DomainSound) Marshal() (string, error) {
}
return string(doc), nil
 }
+
+func (d *DomainRNG) Unmarshal(doc string) error {
+   return xml.Unmarshal([]byte(doc), d)
+}
+
+func (d *DomainRNG) Marshal() (string, error) {
+   doc, err := xml.MarshalIndent(d, "", "  ")
+   if err != nil {
+   return "", err
+   }
+   return string(doc), nil
+}
diff --git a/domain_test.go b/domain_test.go
index 0ce908b..aac23fe 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -333,6 +333,30 @@ var domainTestData = []struct {
},
},
},
+   RNGs: []DomainRNG{
+   DomainRNG{
+   Model: "virtio",
+   Rate: {
+   Period: 2000,
+   Bytes:  1234,
+   },
+   Backend: {
+   Model: "egd",
+   Type:  "udp",
+   Sources: 
[]DomainInterfaceSource{
+   
DomainInterfaceSource{
+   Mode:   
 "bind",
+   
Service: "1234",
+   },
+   
DomainInterfaceSource{
+   Mode:   
 "connect",
+   Host:   
 "1.2.3.4",
+   
Service: "1234",
+   },
+   },
+   },
+   },
+   },
},
},
Expected: []string{
@@ -368,6 +392,13 @@ var domainTestData = []struct {
`  `,
`  `,
``,
+   ``,
+   `  `,
+   `  `,
+   ``,
+   ``,
+   `  `,
+   ``,
`  `,
``,
},
@@ -1334,6 +1365,60 @@ var domainTestData = []struct {
``,
},
},
+   {
+   Object: {
+  

Re: [libvirt] [PATCH] news: CPU add migration fix into Bug fixes

2017-07-04 Thread Andrea Bolognani
On Tue, 2017-07-04 at 09:14 +0200, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina 
> ---
>  docs/news.xml | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/docs/news.xml b/docs/news.xml
> index f38abeb91d..f590d9cdfc 100644
> --- a/docs/news.xml
> +++ b/docs/news.xml
> @@ -197,6 +197,18 @@
>QEMU releases older than 1.6.
>  
>
> +  
> +
> +  qemu: Fix migration to older libvirt/QEMU versions
> +
> +
> +  When the guest is started libvirt updates the CPU definition to

s/started/started,/

> +  reflect the actual CPU features to enforce ABI. We need to send
> +  original and updated CPU definition in order to support migration
> +  to older libvirt/QEMU versions. Only the updated CPU definition
> +  was send to destination.

s/send/sent/

> +
> +  
>  
>
>

With the above fixed,

Reviewed-by: Andrea Bolognani 

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH v3 25/26] qemu: Isolate hostdevs on pSeries guests

2017-07-04 Thread David Gibson
On Thu, 29 Jun 2017 17:37:30 +0200
Andrea Bolognani  wrote:

> On Wed, 2017-06-28 at 18:22 -0400, Laine Stump wrote:
>  [...]  
>  [...]  
> 
> Right, I hadn't considered that case. I'll make sure it is
> handled correctly.
> 
>  [...]  
> 
> Hm, that's quite a pickle.
> 
> Choosing a synthetic isolation group that is guaranteed not
> to clash with any host device or other VFs sounds like it
> might require some annoying bookkeeping.
> 
> I'm not sure isolating SR-IOV VFs is really needed, though,
> because by virtue of being subject to their own layer of
> virtualization / abstraction they might being unable to take
> advantage of EEH and similar isolation-dependent features.
> 
> David, what's your take on this?

So, I still need to talk to the IBMers some more about this, but I'm
pretty sure we want VF isolation.  I believe EEH should work on VFs,
but it will break if there is >1 VF on the vPHB (since every VF should
be in its own IOMMU group).

And, yes, things would be far nicer if EEH still worked with multiple
(host) IOMMU groups on the vPHB, but doing so is a real PITA, and
no-one is working on it.

> 
>  [...]  
>  [...]  
> 
> I don't think PCIe Root Ports provide any isolation; not of
> the kind we're talking about here, at least. So the concepts
> implemented here don't apply AFAICT.
> 
> -- 
> Andrea Bolognani / Red Hat / Virtualization


-- 
David Gibson 
Principal Software Engineer, Virtualization, Red Hat


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

[libvirt] [PATCH] news: CPU add migration fix into Bug fixes

2017-07-04 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 docs/news.xml | 12 
 1 file changed, 12 insertions(+)

diff --git a/docs/news.xml b/docs/news.xml
index f38abeb91d..f590d9cdfc 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -197,6 +197,18 @@
   QEMU releases older than 1.6.
 
   
+  
+
+  qemu: Fix migration to older libvirt/QEMU versions
+
+
+  When the guest is started libvirt updates the CPU definition to
+  reflect the actual CPU features to enforce ABI. We need to send
+  original and updated CPU definition in order to support migration
+  to older libvirt/QEMU versions. Only the updated CPU definition
+  was send to destination.
+
+  
 
   
   
-- 
2.13.2

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