[libvirt] [PATCH] nodeinfo: fix nodeGetFreePages when max node is zero

2014-09-23 Thread Jincheng Miao
In nodeGetFreePages, if startCell is given by '0',
and the max node number is '0' too. The for-loop
wouldn't be executed.
So convert it to while-loop.

Before:
> virsh freepages --cellno 0 --pagesize 4
error: internal error: no suitable info found

After:
> virsh freepages --cellno 0 --pagesize 4
4KiB: 472637

Signed-off-by: Jincheng Miao 
---
 src/nodeinfo.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 2459922..1fe190a 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -2042,18 +2042,19 @@ nodeGetFreePages(unsigned int npages,
 }
 
 lastCell = MIN(lastCell, startCell + cellCount);
+cell = startCell;
 
-for (cell = startCell; cell < lastCell; cell++) {
+do {
 for (i = 0; i < npages; i++) {
 unsigned int page_size = pages[i];
 unsigned int page_free;
 
-if (virNumaGetPageInfo(cell, page_size, 0, NULL, &page_free) < 0)
+if (virNumaGetPageInfo(cell++, page_size, 0, NULL, &page_free) < 0)
 goto cleanup;
 
 counts[ncounts++] = page_free;
 }
-}
+} while (cell < lastCell);
 
 if (!ncounts) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-- 
1.9.3

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


[libvirt] Is seems necessary to pass "migratable=no/yes" to qemu.

2014-09-23 Thread zhang bo
The patch
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=de0aeafe9ce3eb414c8b5d3aa8995d776a2952de
removes invtsc flag in the host-model CPU.

I'm wondering, will it be better to pass args "migratable=no/yes" to qemu, and 
let qemu complete the
remaining work? As that qemu has checked whether it's necessary to use invtsc 
or not.
--
"invtsc is available only if using: -cpu host,migratable=no,+invtsc."
http://git.qemu.org/?p=qemu.git;a=commit;h=120eee7d1fdb2eba15766cfff7b9bcdc902690b4
--

There's another problem, if we do not pass "migratable=no" to qemu.
Consider if we set host mode to pass-through
   -
  
  
   -
then the vm->def->cpu->features contains invtsc. however, qemu will 
automatically remove this cpu flag
as that "migration=no" is not passed to it. thus, the guest will not start up. 
This problem is in fact
caused by the patch:
http://libvirt.org/git/?p=libvirt.git;a=commit;h=fba6bc47cbcabbe08d42279691efb0dff3b9c997,
it forbids guest domain to start up if the host has INVTSC while the 
guest(qemu) does not.
   -
for (i = 0; def->cpu && i < def->cpu->nfeatures; i++) {
virCPUFeatureDefPtr feature = &def->cpu->features[i];

if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
continue;

if (STREQ(feature->name, "invtsc") &&
!cpuHasFeature(guestcpu, feature->name)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
   _("host doesn't support invariant TSC"));
goto cleanup;
}
}
break;
   --


In conclusion:
1 Will it better to pass args "migratable=yes/no" to qemu rather than doing the 
mask-invtsc job in libvirt?
2 If the guest has "pass-through" cpu mode, then it's unable to start up, 
because qemu removes invtsc, and
vm->def->cpu->features has it. It seems a BUG.











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


Re: [libvirt] [PATCH 2/2] numatune: move up verification codes in virNumaSetupMemoryPolicy

2014-09-23 Thread Chen, Fan
On Tue, 2014-09-23 at 14:42 +0200, Michal Privoznik wrote: 
> On 23.09.2014 11:34, Chen Fan wrote:
> > use virDomainNumatuneNodeSetIsAvailable() to verify momory.nodeset
> > whether is out of range. and move up the verification.
> >
> > Signed-off-by: Chen Fan 
> > ---
> >   src/conf/numatune_conf.c |  3 +++
> >   src/util/virnuma.c   | 15 ---
> >   2 files changed, 3 insertions(+), 15 deletions(-)
> 
> I'd expect a test case for this.
Ok, I will add it.

thanks,
Chen

> 
> >
> > diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
> > index a9b20aa..8b43167 100644
> > --- a/src/conf/numatune_conf.c
> > +++ b/src/conf/numatune_conf.c
> > @@ -278,6 +278,9 @@ virDomainNumatuneParseXML(virDomainNumatunePtr 
> > *numatunePtr,
> >nodeset) < 0)
> >   goto cleanup;
> >
> > +if (!virDomainNumatuneNodeSetIsAvailable(*numatunePtr, -1))
> > +goto cleanup;
> > +
> >   if (virDomainNumatuneNodeParseXML(numatunePtr, ncells, ctxt) < 0)
> >   goto cleanup;
> >
> > diff --git a/src/util/virnuma.c b/src/util/virnuma.c
> > index 1a34398..4766f16 100644
> > --- a/src/util/virnuma.c
> > +++ b/src/util/virnuma.c
> > @@ -95,31 +95,16 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
> >   int ret = -1;
> >   int bit = 0;
> >   size_t i;
> > -int maxnode = 0;
> >   virBitmapPtr tmp_nodemask = NULL;
> >
> >   tmp_nodemask = virDomainNumatuneGetNodeset(numatune, nodemask, -1);
> >   if (!tmp_nodemask)
> >   return 0;
> >
> > -if (numa_available() < 0) {
> > -virReportError(VIR_ERR_INTERNAL_ERROR,
> > -   "%s", _("Host kernel is not aware of NUMA."));
> > -return -1;
> > -}
> > -
> > -maxnode = numa_max_node();
> > -maxnode = maxnode < NUMA_NUM_NODES ? maxnode : NUMA_NUM_NODES;
> > -
> >   /* Convert nodemask to NUMA bitmask. */
> >   nodemask_zero(&mask);
> >   bit = -1;
> >   while ((bit = virBitmapNextSetBit(tmp_nodemask, bit)) >= 0) {
> > -if (bit > maxnode) {
> > -virReportError(VIR_ERR_INTERNAL_ERROR,
> > -   _("NUMA node %d is out of range"), bit);
> > -return -1;
> > -}
> >   nodemask_set(&mask, bit);
> >   }
> >
> >
> 
> Yet again, this suffers the same problem that 1/2 does: domain may be lost.
> 
> Michal


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


Re: [libvirt] [PATCH 1/2] numatune: add check for memnode.nodeset range

2014-09-23 Thread Chen, Fan
On Tue, 2014-09-23 at 14:41 +0200, Michal Privoznik wrote: 
> On 23.09.2014 11:34, Chen Fan wrote:
> > For memnode in numatune element, the range of attribute 'nodeset'
> > was not validated. on my host maxnodes was 1, but when setting nodeset
> > to '0-2' or more, guest also started succuss. there probably was qemu's
> > bug too.
> >
> > Signed-off-by: Chen Fan 
> > ---
> >   src/conf/numatune_conf.c | 29 +
> >   src/conf/numatune_conf.h |  4 
> >   2 files changed, 33 insertions(+)
> >
> > diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
> > index 21d9a64..a9b20aa 100644
> > --- a/src/conf/numatune_conf.c
> > +++ b/src/conf/numatune_conf.c
> > @@ -183,6 +183,9 @@ virDomainNumatuneNodeParseXML(virDomainNumatunePtr 
> > *numatunePtr,
> >  VIR_DOMAIN_CPUMASK_LEN) < 0)
> >   goto cleanup;
> >   VIR_FREE(tmp);
> > +
> > +if (!virDomainNumatuneNodeSetIsAvailable(numatune, cellid))
> > +goto cleanup;
> 
> Well, if there already exists such configuration within an existing 
> domain, this will cause a failure on XML parsing when the daemon is 
> starting and hence domain is lost.
Right, I would move this check to VM start routine.


> 
> >   }
> >
> >   ret = 0;
> > @@ -612,3 +615,29 @@ 
> > virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr numatune)
> >
> >   return false;
> >   }
> > +
> > +bool
> > +virDomainNumatuneNodeSetIsAvailable(virDomainNumatunePtr numatune,
> > +int cellid)
> > +{
> > +int maxnode;
> > +int bit = -1;
> > +virBitmapPtr nodemask = NULL;
> > +
> > +nodemask = virDomainNumatuneGetNodeset(numatune, NULL, cellid);
> > +if (!nodemask)
> > +return false;
> > +
> > +if ((maxnode = virNumaGetMaxNode()) < 0)
> > +return false;
> 
> This will work in real environment, but won't work in tests. You need to 
> mock this to get predictable max numa node.
I will add test case for this.


Thanks,
Chen 
> 
> > +
> > +while ((bit = virBitmapNextSetBit(nodemask, bit)) >= 0) {
> > +if (bit > maxnode) {
> > +virReportError(VIR_ERR_INTERNAL_ERROR,
> > +   _("NUMA node %d is out of range"), bit);
> > +return false;
> > +}
> > +}
> > +
> > +return true;
> > +}
> > diff --git a/src/conf/numatune_conf.h b/src/conf/numatune_conf.h
> > index 5254629..cab0b83 100644
> > --- a/src/conf/numatune_conf.h
> > +++ b/src/conf/numatune_conf.h
> > @@ -102,4 +102,8 @@ bool 
> > virDomainNumatuneHasPlacementAuto(virDomainNumatunePtr numatune);
> >
> >   bool virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr numatune);
> >
> > +extern int virNumaGetMaxNode(void);
> > +bool virDomainNumatuneNodeSetIsAvailable(virDomainNumatunePtr numatune,
> > + int cellid);
> > +
> >   #endif /* __NUMATUNE_CONF_H__ */
> >
> 
> Michal


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


Re: [libvirt] [PATCH] LXC: emphasis uid start of idmap only accept '0' in docs

2014-09-23 Thread Chen, Hanxiao


> -Original Message-
> From: Michal Privoznik [mailto:mpriv...@redhat.com]
> 
> On 23.09.2014 05:40, Chen Hanxiao wrote:
> > We don't accept any other values except '0'.
> >
> > Signed-off-by: Chen Hanxiao 
> > ---
> >   docs/formatdomain.html.in | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> > index eefdd5e..bb72452 100644
> > --- a/docs/formatdomain.html.in
> > +++ b/docs/formatdomain.html.in
> > @@ -315,7 +315,7 @@
> >
> >   
> > start
> > -  First user ID in container.
> > +  First user ID in container. It must be '0'.
> > target
> > The first user ID in container will be mapped to this target 
> > user
> > ID in host.
> >
> 
> This is not entirely true. Only the first id mapping must refer to root.
> And by first I mean in a sorted array of mappings. For instance:
> 
> 
>
>
>
>
> 
> 
> is okay.

I missed that part.
Thanks for clarification.

- Chen

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


Re: [libvirt] [PATCHv2 2/2] qemu: wire up virtio-net segment offloading options

2014-09-23 Thread John Ferlan


On 09/18/2014 10:15 AM, Ján Tomko wrote:
> Format the segment offloading options specified by
> 
>   
>   
> 
> on virtio-net command line.
> ---
>  src/qemu/qemu_command.c| 40 
> ++
>  .../qemuxml2argv-net-virtio-disable-offloads.args  | 10 ++
>  tests/qemuxml2argvtest.c   |  2 ++
>  3 files changed, 52 insertions(+)
>  create mode 100644 
> tests/qemuxml2argvdata/qemuxml2argv-net-virtio-disable-offloads.args
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index ce320de..ee49db5 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -4438,6 +4438,46 @@ qemuBuildNicDevStr(virDomainDefPtr def,
>  virBufferAsprintf(&buf, ",event_idx=%s",
>
> virTristateSwitchTypeToString(net->driver.virtio.event_idx));
>  }
> +if (net->driver.virtio.guest.csum) {

s/guest/host

> +virBufferAsprintf(&buf, ",csum=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.guest.csum));

s/guest/host

> +}
> +if (net->driver.virtio.host.gso) {
> +virBufferAsprintf(&buf, ",gso=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.host.gso));
> +}
> +if (net->driver.virtio.host.tso4) {
> +virBufferAsprintf(&buf, ",host_tso4=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.host.tso4));
> +}
> +if (net->driver.virtio.host.tso6) {
> +virBufferAsprintf(&buf, ",host_tso6=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.host.tso6));
> +}
> +if (net->driver.virtio.host.ecn) {
> +virBufferAsprintf(&buf, ",host_ecn=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.host.ecn));
> +}
> +if (net->driver.virtio.host.ufo) {
> +virBufferAsprintf(&buf, ",host_ufo=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.host.ufo));
> +}

   if (net->driver.virtio.guest.csum) {
   virBufferAsprintf(&buf, ",guest_csum=%s",
 
virTristateSwitchTypeToString(net->driver.virtio.guest.csum));
   }

> +if (net->driver.virtio.guest.tso4) {
> +virBufferAsprintf(&buf, ",guest_tso4=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.guest.tso4));
> +}
> +if (net->driver.virtio.guest.tso6) {
> +virBufferAsprintf(&buf, ",guest_tso6=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.guest.tso6));
> +}
> +if (net->driver.virtio.guest.ecn) {
> +virBufferAsprintf(&buf, ",guest_ecn=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.guest.ecn));
> +}
> +if (net->driver.virtio.guest.ufo) {
> +virBufferAsprintf(&buf, ",guest_ufo=%s",
> +  
> virTristateSwitchTypeToString(net->driver.virtio.guest.ufo));
> +}
>  }
>  if (usingVirtio && vhostfdSize > 1) {
>  /* As advised at http://www.linux-kvm.org/page/Multiqueue
> diff --git 
> a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-disable-offloads.args 
> b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-disable-offloads.args
> new file mode 100644
> index 000..3328988
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-disable-offloads.args
> @@ -0,0 +1,10 @@
> +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test 
> QEMU_AUDIO_DRV=none \
> +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
> +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
> +-hda /dev/HostVG/QEMUGuest7 \
> +-device virtio-net-pci,csum=off,gso=off,\
> +host_tso4=off,host_tso6=off,host_ecn=off,host_ufo=off,\
> +guest_tso4=off,guest_tso6=off,guest_ecn=off,guest_ufo=off,\

This may need a "guest_csum=off,"

ACK with that

John
> +vlan=0,id=net0,mac=00:22:44:66:88:aa,bus=pci.0,addr=0x3 \
> +-net user,vlan=0,name=hostnet0 \
> +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 275e699..d3da1e9 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -965,6 +965,8 @@ mymain(void)
>  DO_TEST("net-virtio", NONE);
>  DO_TEST("net-virtio-device",
>  QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, 
> QEMU_CAPS_VIRTIO_TX_ALG);
> +DO_TEST("net-virtio-disable-offloads",
> +QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
>  DO_TEST("net-virtio-netdev",
>  QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV, QEMU_CAPS_NODEFCONFIG);
>  DO_TEST("net-virtio-s390",
> 

--
libvir-list mailing list
lib

Re: [libvirt] [PATCHv2 1/2] conf: add options for disabling segment offloading

2014-09-23 Thread John Ferlan


On 09/18/2014 10:15 AM, Ján Tomko wrote:
> Add options for tuning segment offloading:
> 
>ecn='off' ufo='off'/>
>   
> 
> which control the respective host_ and guest_ properties
> of the virtio-net device.
> ---
>  docs/formatdomain.html.in  |  24 ++-
>  docs/schemas/domaincommon.rng  |  44 -
>  src/conf/domain_conf.c | 218 
> -
>  src/conf/domain_conf.h |  15 ++
>  .../qemuxml2argv-net-virtio-disable-offloads.xml   |  35 
>  tests/qemuxml2xmltest.c|   1 +
>  6 files changed, 329 insertions(+), 8 deletions(-)
>  create mode 100644 
> tests/qemuxml2argvdata/qemuxml2argv-net-virtio-disable-offloads.xml
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index 8c03ebb..5dd70a4 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -3868,7 +3868,11 @@ qemu-kvm -net nic,model=? /dev/null
>
>
>
> -   event_idx='off' queues='5'/>
> +   event_idx='off' queues='5'>
> + ufo='off'/>
> +
> +  
> +  
>  
>
>...
> @@ -3972,6 +3976,24 @@ qemu-kvm -net nic,model=? /dev/null
>  processor, resulting in much higher throughput.
>  Since 1.0.6 (QEMU and KVM only)
>
> +  host offloading options

Should this be host offloading options?  
or host TCP options (in some way to indicate that these
are TCP level options).  Probably also want your disclaimer
use of these should be for only those that know what they
are doing...


> +  
> +The csum, gso, tso4,
> +tso6, ecn, ufo

Should read: ecn, and ufo  

Should you "spell out" what each translates to?

csum (checksums), gso (generic segmentation offload),
tso (tcp segmentation offload v4 and v6), ecn (congestion
 notification), and ufo (UDP fragment offloads)



> +attributes with possible values on
> +and off can be used to turn host offloads off.

s/turn host offloads off/turn off host TCP options/

Saying "offloads off" aloud just doesn't seem right.

> +By default, the supported offloads are enabled by QEMU.

s/the supported offloads/the TCP options/

> +Since 1.2.9 (QEMU only)
> +  
> +  guest offloading options

Similar in here...   Does the host setting override the guest value
or can the host say "tso4=off" while the guest has "tso4=on"?  Curious
mainly.

> +  
> +The csum, tso4,
> +tso6, ecn, ufo

same here with the "and" - although I suppose you could just
reference the  bits "above"... 

Another way to say it is guests can use the same options except gso

> +attributes with possible values on
> +and off can be used to turn guest offloads off.

s/turn guest offloads off/turn off guest TCP options/

> +By default, the supported offloads are enabled by QEMU.

s/the supported offloads/the TCP options/

And of course the usage disclaimer!


> +Since 1.2.9 (QEMU only)
> +  
>  
>  
>  Setting network backend-specific 
> options
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index 19dc82f..1e00afd 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -2364,7 +2364,49 @@
>
>  
>
> -  
> +  
> +
> +  
> +
> +  
> +
> +
> +  
> +
> +
> +  
> +
> +
> +  
> +
> +
> +  
> +
> +
> +  
> +
> +  
> +
> +
> +  
> +
> +  
> +
> +
> +  
> +
> +
> +  
> +
> +
> +  
> +
> +
> +  
> +
> +  
> +
> +  
>  
>
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 3ccec1c..cdaafa6 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -6897,6 +6897,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
>  char *ioeventfd = NULL;
>  char *event_idx = NULL;
>  char *queues = NULL;
> +char *str = NULL;
>  char *filter = 

Re: [libvirt] [PATCH v5 2/4] event: introduce new event for tunable values

2014-09-23 Thread Eric Blake
On 09/23/2014 03:26 PM, Pavel Hrdina wrote:

>>> +
>>> +VIR_DEBUG("Relaying domain tunable event %s %d, callback %d",
>>> +  dom->name, dom->id, callback->callbackID);
>>> +
>>
>> Might also be nice to log "%p %n", params, nparams
> 
> Yes, that would be probably nice, but since I've pushed this patch
> already I can create a following patch with this small update?
> 

Yes, a followup is fine.

>>
>>
>>> +++ b/src/remote/remote_protocol.x
>>> @@ -247,6 +247,9 @@ const REMOTE_NETWORK_DHCP_LEASES_MAX = 65536;
>>>   /* Upper limit on count of parameters returned via bulk stats API */
>>>   const REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX = 4096;
>>>
>>> +/* Upper limit of message size for tunable event. */
>>> +const REMOTE_DOMAIN_EVENT_TUNABLE_MAX = 8388608;
>>
>> That feels excessive...
>>
>>> +
>>>   /* UUID.  VIR_UUID_BUFLEN definition comes from libvirt.h */
>>>   typedef opaque remote_uuid[VIR_UUID_BUFLEN];
>>>
>>> @@ -2990,6 +2993,12 @@ struct remote_domain_event_block_job_2_msg {
>>>   int status;
>>>   };
>>>
>>> +struct remote_domain_event_callback_tunable_msg {
>>> +int callbackID;
>>> +remote_nonnull_domain dom;
>>> +remote_typed_param params;
>>
>> ...each param in the array will occupy multiple bytes.  I think that
>> something as low as 2048 for REMOTE_DOMAIN_EVENT_TUNABLE_MAX is still
>> plenty (we don't have that many tunables yet); even if each tunable
>> requires 64 bytes to transmit (mostly in the name of the parameter, but
>> also in the type and value), that's still well under a megabyte limit of
>> information passed on an instance of the event.
>>
> 
> Well, yes and no :). Let's say, that we will add in the future (and I'm
> planning to do it) blkiotune where you can update at the same time all
> of the tunables for all host's disks where all params for now will be
> only VIR_TYPED_PARAM_STRING and that could consume a lot of memory. I
> know that it will probably never be that much, but I wanted to be sure
> that we will have enough space for all possible tunable events.

Still, are you going to return 8 million separate strings?  Or just 8
million bytes but still contained within 2000 strings?  Seriously, I
think 2048 is a perfectly LARGE limit - there are not THAT many tunables
per domain.  The params is not the overall size of the command,
but the number of parameters (each of which can be quite large if they
are type string)

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



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

Re: [libvirt] [PATCH v5 2/4] event: introduce new event for tunable values

2014-09-23 Thread Pavel Hrdina

On 09/23/2014 10:08 PM, Eric Blake wrote:

On 09/23/2014 12:46 PM, Pavel Hrdina wrote:

This new event will use typedParameters to expose what has been actually
updated and the reason is that we can in the future extend any tunable
values or add new tunable values. With typedParameters we don't have to
worry about creating some other events, we will just use this universal
event to inform user about updates.

Signed-off-by: Pavel Hrdina 
---



When the event is issued, does it contain ONLY parameters for what just
changed, or does it list ALL tunables including the unchanged ones?

It feels like your API is only capable of listing the new tunable value.
  Is anyone using this event going to want to know both former and new
value at the same time?



The API returns only the new tunable values. I've inspired myself with 
other APIs that they also returns only the updated values without the 
old ones.


The only user that I know right now will be oVirt and they seems to be 
care only about new values.




+/**
+ * virConnectDomainEventTunableCallback:
+ * @conn: connection object
+ * @dom: domain on which the event occurred
+ * @params: changed tunable values stored as array of virTypedParameter
+ * @nparams: size of the array
+ * @opaque: application specified data
+ *
+ * This callback occurs when tunable values are updated. The params must not
+ * be freed in the callback handler as it's done internally after the callback
+ * handler is executed.
+ *
+ * The callback signature to use when registering for an event of type
+ * VIR_DOMAIN_EVENT_ID_TUNABLE with virConnectDomainEventRegisterAny()
+ */
+typedef void (*virConnectDomainEventTunableCallback)(virConnectPtr conn,
+ virDomainPtr dom,
+ virTypedParameterPtr 
params,
+ int nparams,
+ void *opaque);


Where do we document what names of tunables to expect?


It's documented in the 4/4 patch as I'm adding for now only cputune and 
it will be documented in the description of this callback as existing 
namespace and also there will be definitions for each tunable value that 
we will return.





+++ b/daemon/remote.c



+static int
+remoteRelayDomainEventTunable(virConnectPtr conn,
+  virDomainPtr dom,
+  virTypedParameterPtr params,
+  int nparams,
+  void *opaque)
+{
+daemonClientEventCallbackPtr callback = opaque;
+remote_domain_event_callback_tunable_msg data;
+
+if (callback->callbackID < 0 ||
+!remoteRelayDomainEventCheckACL(callback->client, conn, dom))
+return -1;
+
+VIR_DEBUG("Relaying domain tunable event %s %d, callback %d",
+  dom->name, dom->id, callback->callbackID);
+


Might also be nice to log "%p %n", params, nparams


Yes, that would be probably nice, but since I've pushed this patch 
already I can create a following patch with this small update?






+++ b/src/remote/remote_protocol.x
@@ -247,6 +247,9 @@ const REMOTE_NETWORK_DHCP_LEASES_MAX = 65536;
  /* Upper limit on count of parameters returned via bulk stats API */
  const REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX = 4096;

+/* Upper limit of message size for tunable event. */
+const REMOTE_DOMAIN_EVENT_TUNABLE_MAX = 8388608;


That feels excessive...


+
  /* UUID.  VIR_UUID_BUFLEN definition comes from libvirt.h */
  typedef opaque remote_uuid[VIR_UUID_BUFLEN];

@@ -2990,6 +2993,12 @@ struct remote_domain_event_block_job_2_msg {
  int status;
  };

+struct remote_domain_event_callback_tunable_msg {
+int callbackID;
+remote_nonnull_domain dom;
+remote_typed_param params;


...each param in the array will occupy multiple bytes.  I think that
something as low as 2048 for REMOTE_DOMAIN_EVENT_TUNABLE_MAX is still
plenty (we don't have that many tunables yet); even if each tunable
requires 64 bytes to transmit (mostly in the name of the parameter, but
also in the type and value), that's still well under a megabyte limit of
information passed on an instance of the event.



Well, yes and no :). Let's say, that we will add in the future (and I'm 
planning to do it) blkiotune where you can update at the same time all 
of the tunables for all host's disks where all params for now will be 
only VIR_TYPED_PARAM_STRING and that could consume a lot of memory. I 
know that it will probably never be that much, but I wanted to be sure 
that we will have enough space for all possible tunable events.


Pavel


The code looks okay, but I'm still a bit worried about the design.



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


Re: [libvirt] [PATCH V2] libvirt-guests: run after time-sync.target

2014-09-23 Thread Jim Fehlig
Eric Blake wrote:
> On 09/23/2014 11:53 AM, Jim Fehlig wrote:
>   
>> When libvirt-guests is configured to start guests on host
>> boot, it is possible for guests start and read the host
>> clock before it is synchronized.  Services such as
>> libvirt-guests that require correct time should use the
>> Special Passive System Unit time-sync.target
>>
>> http://www.freedesktop.org/software/systemd/man/systemd.special.html#time-sync.target
>> Signed-off-by: Jim Fehlig 
>> ---
>>
>> V2 of
>>
>> https://www.redhat.com/archives/libvir-list/2014-September/msg00426.html
>>
>> In V2: Use time-sync.target instead of ntp-wait.service
>> 
>
> ACK
>   

Thanks, pushed now.

Regards,
Jim

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


Re: [libvirt] [PATCHv2 3/4] qemu: Report better errors from broken backing chains

2014-09-23 Thread John Ferlan


On 09/18/2014 05:54 AM, Peter Krempa wrote:
> Request erroring out from the backing chain traveller and drop qemu's
> internal backing chain integrity tester.
> 
> The backin chain traveller reports errors by itself with possibly more

s/backin/backing

> detail than qemuDiskChainCheckBroken ever could.
> 
> We also need to make sure that we reconnect to existing qemu instances
> even at the cost of losing the backing chain info (this really should be
> stored in the XML rather than reloaded from disk, but that needs some
> work).
> ---
>  src/qemu/qemu_domain.c  | 29 -
>  src/qemu/qemu_domain.h  |  3 ++-
>  src/qemu/qemu_driver.c  | 10 +-
>  src/qemu/qemu_hotplug.c |  2 +-
>  src/qemu/qemu_process.c | 11 +++
>  5 files changed, 19 insertions(+), 36 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 515bcac..b93e0d5 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -2476,27 +2476,6 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr 
> driver,
>  return -1;
>  }
> 
> -static int
> -qemuDiskChainCheckBroken(virDomainDiskDefPtr disk)
> -{
> -char *brokenFile = NULL;
> -
> -if (!virDomainDiskGetSource(disk))
> -return 0;
> -
> -if (virStorageFileChainGetBroken(disk->src, &brokenFile) < 0)
> -return -1;
> -
> -if (brokenFile) {
> -virReportError(VIR_ERR_INVALID_ARG,
> -   _("Backing file '%s' of image '%s' is missing."),
> -   brokenFile, virDomainDiskGetSource(disk));
> -VIR_FREE(brokenFile);
> -return -1;
> -}
> -
> -return 0;
> -}
> 
>  int
>  qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
> @@ -2524,8 +2503,7 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
>  virFileExists(virDomainDiskGetSource(disk)))
>  continue;
> 
> -if (qemuDomainDetermineDiskChain(driver, vm, disk, false) >= 0 &&
> -qemuDiskChainCheckBroken(disk) >= 0)
> +if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) >= 0)
>  continue;
> 
>  if (disk->startupPolicy &&
> @@ -2670,7 +2648,8 @@ int
>  qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
>   virDomainObjPtr vm,
>   virDomainDiskDefPtr disk,
> - bool force_probe)
> + bool force_probe,
> + bool report_broken)
>  {
>  virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
>  int ret = 0;
> @@ -2692,7 +2671,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
>  if (virStorageFileGetMetadata(disk->src,
>uid, gid,
>cfg->allowDiskFormatProbing,
> -  false) < 0)
> +  report_broken) < 0)
>  ret = -1;
> 
>   cleanup:
> diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
> index 494e9f8..cb0115a 100644
> --- a/src/qemu/qemu_domain.h
> +++ b/src/qemu/qemu_domain.h
> @@ -366,7 +366,8 @@ int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
>  int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
>   virDomainObjPtr vm,
>   virDomainDiskDefPtr disk,
> - bool force_probe);
> + bool force_probe,
> + bool report_broken);
> 
>  int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
>virDomainObjPtr vm,
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 5fd89a3..d0aff1a 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6688,7 +6688,7 @@ qemuDomainChangeDiskMediaLive(virConnectPtr conn,
>  if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
>  goto end;
> 
> -if (qemuDomainDetermineDiskChain(driver, vm, disk, false) < 0)
> +if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
>  goto end;
> 
>  switch (disk->device) {
> @@ -13067,7 +13067,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr 
> driver,
>  for (i = 0; i < snap->def->ndisks; i++) {
>  if (snap->def->disks[i].snapshot != 
> VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
>  continue;
> -qemuDomainDetermineDiskChain(driver, vm, vm->def->disks[i], true);
> +qemuDomainDetermineDiskChain(driver, vm, vm->def->disks[i], true, 
> true);

We want to return failure immediately, but do nothing about it?  At the
very least an ignore_value()

>  }
>  if (orig_err) {
>  virSetError(orig_err);
> @@ -14875,7 +14875,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
>  oldsrc = disk->src;
>  disk->src = disk->mirror;
> 
> -if (qemuDomainDetermineDiskChain(driver, vm, disk, fa

Re: [libvirt] [PATCHv2 4/4] storage: Improve error message when traversing backing chains

2014-09-23 Thread John Ferlan


On 09/18/2014 05:54 AM, Peter Krempa wrote:
> Report also the name of the parent file and uid/gid used to access it to
> help debugging broken storage configurations.
> ---
>  src/storage/storage_driver.c | 20 +++-
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 

ACK

John

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


Re: [libvirt] [PATCHv2 2/4] qemu: Sanitize argument names and empty disk check in qemuDomainDetermineDiskChain

2014-09-23 Thread John Ferlan


On 09/18/2014 05:54 AM, Peter Krempa wrote:
> Reuse virStorageSourceIsEmpty and rename "force" argument to
> "force_probe".
> ---
>  src/qemu/qemu_domain.c | 8 +++-
>  src/qemu/qemu_domain.h | 2 +-
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 

ACK - thanks :-)

John

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


Re: [libvirt] [PATCHv2 1/4] util: storage: Allow metadata crawler to report useful errors

2014-09-23 Thread John Ferlan


On 09/18/2014 05:54 AM, Peter Krempa wrote:
> Add a new parameter to virStorageFileGetMetadata that will break the
> backing chain detection process and report useful error message rather
> than having to use virStorageFileChainGetBroken.
> 
> This patch just introduces the option, usage will be provided
> separately.
> ---
>  src/qemu/qemu_domain.c|  3 ++-
>  src/security/virt-aa-helper.c |  2 +-
>  src/storage/storage_driver.c  | 24 +---
>  src/storage/storage_driver.h  |  3 ++-
>  tests/virstoragetest.c|  2 +-
>  5 files changed, 23 insertions(+), 11 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 5859ba7..19b935d 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -2693,7 +2693,8 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
> 
>  if (virStorageFileGetMetadata(disk->src,
>uid, gid,
> -  cfg->allowDiskFormatProbing) < 0)
> +  cfg->allowDiskFormatProbing,
> +  false) < 0)
>  ret = -1;
> 
>   cleanup:
> diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
> index a06ba44..9afc8db 100644
> --- a/src/security/virt-aa-helper.c
> +++ b/src/security/virt-aa-helper.c
> @@ -932,7 +932,7 @@ get_files(vahControl * ctl)
>   */
>  if (!disk->src->backingStore) {
>  bool probe = ctl->allowDiskFormatProbing;
> -virStorageFileGetMetadata(disk->src, -1, -1, probe);
> +virStorageFileGetMetadata(disk->src, -1, -1, probe, false);
>  }
> 
>  /* XXX passing ignoreOpenFailure = true to get back to the behavior
> diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
> index 433d7b7..c3b29c4 100644
> --- a/src/storage/storage_driver.c
> +++ b/src/storage/storage_driver.c
> @@ -2783,6 +2783,7 @@ static int
>  virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
>   uid_t uid, gid_t gid,
>   bool allow_probe,
> + bool report_broken,
>   virHashTablePtr cycle)
>  {
>  int ret = -1;
> @@ -2847,9 +2848,13 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr 
> src,
>  else
>  backingStore->format = backingFormat;
> 
> -if (virStorageFileGetMetadataRecurse(backingStore,
> - uid, gid, allow_probe,
> - cycle) < 0) {
> +if ((ret = virStorageFileGetMetadataRecurse(backingStore,
> +uid, gid,
> +allow_probe, report_broken,
> +cycle)) < 0) {
> +if (report_broken)
> +goto cleanup;
> +
>  /* if we fail somewhere midway, just accept and return a
>   * broken chain */
>  ret = 0;
> @@ -2883,15 +2888,20 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr 
> src,
>   * format, since a malicious guest can turn a raw file into any
>   * other non-raw format at will.
>   *
> + * If @report_broken is true, the whole function fails with a possibly sane
> + * error instead of just returning a broken chain.
> + *
>   * Caller MUST free result after use via virStorageSourceFree.
>   */
>  int
>  virStorageFileGetMetadata(virStorageSourcePtr src,
>uid_t uid, gid_t gid,
> -  bool allow_probe)
> +  bool allow_probe,
> +  bool report_broken)
>  {
> -VIR_DEBUG("path=%s format=%d uid=%d gid=%d probe=%d",
> -  src->path, src->format, (int)uid, (int)gid, allow_probe);
> +VIR_DEBUG("path=%s format=%d uid=%d gid=%d probe=%d, report_broken=%d",
> +  src->path, src->format, (int)uid, (int)gid,
> +  allow_probe, report_broken);
> 
>  virHashTablePtr cycle = NULL;
>  int ret = -1;
> @@ -2903,7 +2913,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src,
>  src->format = allow_probe ? VIR_STORAGE_FILE_AUTO : 
> VIR_STORAGE_FILE_RAW;
> 
>  ret = virStorageFileGetMetadataRecurse(src, uid, gid,
> -   allow_probe, cycle);
> +   allow_probe, report_broken, 
> cycle);
> 
>  virHashFree(cycle);
>  return ret;
> diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h
> index e773928..54a17a3 100644
> --- a/src/storage/storage_driver.h
> +++ b/src/storage/storage_driver.h
> @@ -50,7 +50,8 @@ bool 
> virStorageFileSupportsSecurityDriver(virStorageSourcePtr src);
> 
>  int virStorageFileGetMetadata(virStorageSourcePtr src,
>uid_t uid, gid_t gid,
> -  bool allow_probe)
> + 

Re: [libvirt] [PATCH v5 2/4] event: introduce new event for tunable values

2014-09-23 Thread Eric Blake
On 09/23/2014 12:46 PM, Pavel Hrdina wrote:
> This new event will use typedParameters to expose what has been actually
> updated and the reason is that we can in the future extend any tunable
> values or add new tunable values. With typedParameters we don't have to
> worry about creating some other events, we will just use this universal
> event to inform user about updates.
> 
> Signed-off-by: Pavel Hrdina 
> ---
> 

When the event is issued, does it contain ONLY parameters for what just
changed, or does it list ALL tunables including the unchanged ones?

It feels like your API is only capable of listing the new tunable value.
 Is anyone using this event going to want to know both former and new
value at the same time?

> 
> +/**
> + * virConnectDomainEventTunableCallback:
> + * @conn: connection object
> + * @dom: domain on which the event occurred
> + * @params: changed tunable values stored as array of virTypedParameter
> + * @nparams: size of the array
> + * @opaque: application specified data
> + *
> + * This callback occurs when tunable values are updated. The params must not
> + * be freed in the callback handler as it's done internally after the 
> callback
> + * handler is executed.
> + *
> + * The callback signature to use when registering for an event of type
> + * VIR_DOMAIN_EVENT_ID_TUNABLE with virConnectDomainEventRegisterAny()
> + */
> +typedef void (*virConnectDomainEventTunableCallback)(virConnectPtr conn,
> + virDomainPtr dom,
> + virTypedParameterPtr 
> params,
> + int nparams,
> + void *opaque);

Where do we document what names of tunables to expect?

> +++ b/daemon/remote.c

> +static int
> +remoteRelayDomainEventTunable(virConnectPtr conn,
> +  virDomainPtr dom,
> +  virTypedParameterPtr params,
> +  int nparams,
> +  void *opaque)
> +{
> +daemonClientEventCallbackPtr callback = opaque;
> +remote_domain_event_callback_tunable_msg data;
> +
> +if (callback->callbackID < 0 ||
> +!remoteRelayDomainEventCheckACL(callback->client, conn, dom))
> +return -1;
> +
> +VIR_DEBUG("Relaying domain tunable event %s %d, callback %d",
> +  dom->name, dom->id, callback->callbackID);
> +

Might also be nice to log "%p %n", params, nparams


> +++ b/src/remote/remote_protocol.x
> @@ -247,6 +247,9 @@ const REMOTE_NETWORK_DHCP_LEASES_MAX = 65536;
>  /* Upper limit on count of parameters returned via bulk stats API */
>  const REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX = 4096;
>  
> +/* Upper limit of message size for tunable event. */
> +const REMOTE_DOMAIN_EVENT_TUNABLE_MAX = 8388608;

That feels excessive...

> +
>  /* UUID.  VIR_UUID_BUFLEN definition comes from libvirt.h */
>  typedef opaque remote_uuid[VIR_UUID_BUFLEN];
>  
> @@ -2990,6 +2993,12 @@ struct remote_domain_event_block_job_2_msg {
>  int status;
>  };
>  
> +struct remote_domain_event_callback_tunable_msg {
> +int callbackID;
> +remote_nonnull_domain dom;
> +remote_typed_param params;

...each param in the array will occupy multiple bytes.  I think that
something as low as 2048 for REMOTE_DOMAIN_EVENT_TUNABLE_MAX is still
plenty (we don't have that many tunables yet); even if each tunable
requires 64 bytes to transmit (mostly in the name of the parameter, but
also in the type and value), that's still well under a megabyte limit of
information passed on an instance of the event.

The code looks okay, but I'm still a bit worried about the design.

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



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

Re: [libvirt] [PATCH v5 4/4] cputune_event: queue the event for cputune updates

2014-09-23 Thread Pavel Hrdina

On 09/23/2014 09:37 PM, John Ferlan wrote:



On 09/23/2014 02:47 PM, Pavel Hrdina wrote:

Now we have universal tunable event so we can use it for reporting
changes to user. The cputune values will be prefixed with "cputune" to
distinguish it from other tunable events.

Signed-off-by: Pavel Hrdina 
---

since v4:
- added macro definitions for cputune typedParameters fileds

  include/libvirt/libvirt.h.in | 63 ++
  src/qemu/qemu_cgroup.c   | 19 ++-
  src/qemu/qemu_driver.c   | 81 
  3 files changed, 162 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 86be86f..898f8b5 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5204,6 +5204,66 @@ typedef void 
(*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
 void *opaque);

  /**
+ * VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN:
+ *
+ * Macro represents formatted pinning for one vcpu specified by id which is
+ * appended to the parameter name, for example "cputune.vcpupin1",
+ * as VIR_TYPED_PARAM_STRING.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN "cputune.vcpupin%u"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN:
+ *
+ * Macro represents formatted pinning for emulator process,
+ * as VIR_TYPED_PARAM_STRING.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN "cputune.emulatorpin"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES:
+ *
+ * Macro represents proportional weight of the scheduler used on the
+ * host cpu, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES "cputune.cpu_shares"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD:
+ *
+ * Macro represents the enforcement period for a quota, in microseconds,
+ * for vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD "cputune.vcpu_period"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA:
+ *
+ * Macro represents the maximum bandwidth to be used within a period for
+ * vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_LLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA "cputune.vcpu_quota"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD:
+ *
+ * Macro represents the enforcement period for a quota in microseconds,
+ * when using the posix scheduler, for all emulator activity not tied to
+ * vcpus, as VIR_TYPED_PARAM_ULLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD "cputune.emulator_period"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA:
+ *
+ * Macro represents the maximum bandwidth to be used within a period for
+ * all emulator activity not tied to vcpus, when using the posix scheduler,
+ * as an VIR_TYPED_PARAM_LLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA "cputune.emulator_quota"
+
+
+/**
   * virConnectDomainEventTunableCallback:
   * @conn: connection object
   * @dom: domain on which the event occurred
@@ -5215,6 +5275,9 @@ typedef void 
(*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
   * be freed in the callback handler as it's done internally after the callback
   * handler is executed.
   *
+ * Currently supported name spaces:
+ *  "cputune.*"
+ *
   * The callback signature to use when registering for an event of type
   * VIR_DOMAIN_EVENT_ID_TUNABLE with virConnectDomainEventRegisterAny()
   */
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 7c6b2c1..41d7057 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -34,6 +34,7 @@
  #include "virscsi.h"
  #include "virstring.h"
  #include "virfile.h"
+#include "virtypedparam.h"

  #define VIR_FROM_THIS VIR_FROM_QEMU

@@ -676,6 +677,10 @@ static int
  qemuSetupCpuCgroup(virDomainObjPtr vm)
  {
  qemuDomainObjPrivatePtr priv = vm->privateData;
+virObjectEventPtr event = NULL;
+virTypedParameterPtr eventParams = 0;


s/0/NULL/


ACK w/ that.


And again thanks, pushed.

Pavel



John


+int eventNparams = 0;
+int eventMaxparams = 0;

  if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
 if (vm->def->cputune.sharesSpecified) {
@@ -694,7 +699,19 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)

  if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
  return -1;
-vm->def->cputune.shares = val;
+if (vm->def->cputune.shares != val) {
+vm->def->cputune.shares = val;
+if (virTypedParamsAddULLong(&eventParams, &eventNparams,
+&eventMaxparams,
+VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES,
+val) < 0)
+return -1;
+
+event = virDomainEventTunableNewFromObj(vm, eventParams, 
eventNparams);
+}
+
+if (event)
+qemuDomainEventQueue(vm->pr

Re: [libvirt] [PATCH v5 2/4] event: introduce new event for tunable values

2014-09-23 Thread Pavel Hrdina

On 09/23/2014 09:36 PM, John Ferlan wrote:



On 09/23/2014 02:46 PM, Pavel Hrdina wrote:

This new event will use typedParameters to expose what has been actually
updated and the reason is that we can in the future extend any tunable
values or add new tunable values. With typedParameters we don't have to
worry about creating some other events, we will just use this universal
event to inform user about updates.

Signed-off-by: Pavel Hrdina 
---

since v4:
- changed cpu-tune to tunable in virsh-domain.c
- added REMOTE_DOMAIN_EVENT_TUNABLE_MAX to limit maximal length of tunable
   event msg

  daemon/remote.c  | 45 +
  include/libvirt/libvirt.h.in | 22 +++
  src/conf/domain_event.c  | 93 
  src/conf/domain_event.h  |  9 +
  src/libvirt_private.syms |  2 +
  src/remote/remote_driver.c   | 42 
  src/remote/remote_protocol.x | 17 +++-
  src/remote_protocol-structs  |  9 +
  tools/virsh-domain.c | 33 
  9 files changed, 271 insertions(+), 1 deletion(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index daa4b60..ddd510c 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -111,6 +111,13 @@ remoteDeserializeTypedParameters(remote_typed_param 
*args_params_val,
   int *nparams);

  static int
+remoteSerializeTypedParameters(virTypedParameterPtr params,
+   int nparams,
+   remote_typed_param **ret_params_val,
+   u_int *ret_params_len,
+   unsigned int flags);
+
+static int
  remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors,
  int nerrors,
  remote_domain_disk_error **ret_errors_val,
@@ -969,6 +976,43 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
  }


+static int
+remoteRelayDomainEventTunable(virConnectPtr conn,
+  virDomainPtr dom,
+  virTypedParameterPtr params,
+  int nparams,
+  void *opaque)
+{
+daemonClientEventCallbackPtr callback = opaque;
+remote_domain_event_callback_tunable_msg data;
+
+if (callback->callbackID < 0 ||
+!remoteRelayDomainEventCheckACL(callback->client, conn, dom))
+return -1;
+
+VIR_DEBUG("Relaying domain tunable event %s %d, callback %d",
+  dom->name, dom->id, callback->callbackID);
+
+/* build return data */
+memset(&data, 0, sizeof(data));
+data.callbackID = callback->callbackID;
+make_nonnull_domain(&data.dom, dom);
+
+if (remoteSerializeTypedParameters(params, nparams,
+   &data.params.params_val,
+   &data.params.params_len,
+   VIR_TYPED_PARAM_STRING_OKAY) < 0)
+return -1;
+
+remoteDispatchObjectEventSend(callback->client, remoteProgram,
+  REMOTE_PROC_DOMAIN_EVENT_CALLBACK_TUNABLE,
+  
(xdrproc_t)xdr_remote_domain_event_callback_tunable_msg,
+  &data);
+
+return 0;
+}
+
+
  static virConnectDomainEventGenericCallback domainEventCallbacks[] = {
  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventReboot),
@@ -987,6 +1031,7 @@ static virConnectDomainEventGenericCallback 
domainEventCallbacks[] = {
  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventPMSuspendDisk),
  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventDeviceRemoved),
  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBlockJob2),
+VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventTunable),
  };

  verify(ARRAY_CARDINALITY(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST);
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 6371b7b..86be86f 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5203,6 +5203,27 @@ typedef void 
(*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
 const char 
*devAlias,
 void *opaque);

+/**
+ * virConnectDomainEventTunableCallback:
+ * @conn: connection object
+ * @dom: domain on which the event occurred
+ * @params: changed tunable values stored as array of virTypedParameter
+ * @nparams: size of the array
+ * @opaque: application specified data
+ *
+ * This callback occurs when tunable values are updated. The params must not
+ * be freed in the callback handler as it's done internally after the callback
+ * handler is executed.
+ *
+ * The callback signature to use when registering for an event of type
+ * VIR_DOMAIN_EVENT_ID_TUNABLE with virConnectDomainEve

Re: [libvirt] [PATCH 1/4] Introduce virNodeAllocPages

2014-09-23 Thread Eric Blake
On 09/18/2014 02:24 AM, Michal Privoznik wrote:
> A long time ago in a galaxy far, far away it has been decided
> that libvirt will manage not only domains but host as well. And
> with my latest work on qemu driver supporting huge pages, we miss
> the cherry on top: an API to allocate huge pages on the run.
> Currently users are forced to log into the host and adjust the
> huge pages pool themselves.  However, with this API the problem
> is gone - they can both size up and size down the pool.
> 
> Signed-off-by: Michal Privoznik 
> ---

> +/**
> + * virNodeAllocPages:
> + * @conn: pointer to the hypervisor connection
> + * @npages: number of items in the @pageSizes array

I'd mention '@pageSizes and @pageCounts arrays'

> + * @pageSizes: which huge page sizes to allocate
> + * @pageCounts: how many pages should be allocated
> + * @startCell: index of first cell to allocate pages on
> + * @cellCount: number of consecutive cells to allocate pages on
> + * @flags: extra flags; binary-OR of virConnectGetAllDomainStatsFlags
> + *
> + * Sometimes, when trying to start a new domain, it may be
> + * necessary to reserve some huge pages in the system pool which
> + * can be then allocated by the domain. This API serves that
> + * purpose. On its input, @pageSizes and @pageCounts are arrays
> + * of the same cardinality of @npages. The @pageSizes contains
> + * page sizes which are to be allocated in the system (the size
> + * unit is kibibytes), and @pageCounts then contains the number
> + * of pages to reserve. Depending on @flags specified, the number
> + * of pages is either added into the pool and the pool is sized
> + * up (@flags have VIR_NODE_ALLOC_PAGES_ADD set) or the number of

Technically, VIR_NODE_ALLOC_PAGES_ADD is 0, so it can't be set :)  Do we
even need this named constant, or can we just drop it?

> + * pages is looked at the new size of pool and the pool can be
> + * both sized up or down (@flags have VIR_NODE_ALLOC_PAGES_SET

The wording is a bit awkward; maybe:

If @flags is 0 (VIR_NODE_ALLOC_PAGES_ADD), each pool corresponding to
@pageSizes grows by the number of pages specified in the corresponding
@pageCounts.  If @flags contains VIR_NODE_ALLOC_PAGES_SET, each pool
mentioned is resized to the given number of pages.

> + * set).  The pages pool can be allocated over several NUMA nodes
> + * at once, just point at @startCell and tell how many subsequent
> + * NUMA nodes should be taken in.

Is there shorthand such as @startCell==-1 for allocating across all NUMA
nodes?  Is there checking that @npages cannot exceed the number of NUMA
nodes available starting at @startCell through @cellCount?

If I understand correctly, usage is something like (pseudo-code):

virNodeAllocPages(conn, 2, (int[]){ [0]=2M, [1]=1G },
  (int[]){ [0]=1024, [1]=1 },
  1, 2, 0)

which proceeds to add 1024 pages of size 2M, and 1 page of size 1G, to
the pools associated both with NUMA node 1 and NUMA node 2 (that is, I
just allocated 6G across two nodes).

> + *
> + * Returns: the number of nodes successfully adjusted or -1 in
> + * case of an error.

Can this function partially succeed?  That is, if I pass @npages==2 and
@cellCount==2, will I ever get a non-negative result less than 4?  If
the result is 2, which allocations failed (are all allocations on the
first cell attempted before any on the second, or are all allocations to
the first pool size attempted across multiple cells before revisiting
cells to allocate in the second pool size)?

> + */
> +int
> +virNodeAllocPages(virConnectPtr conn,
> +  unsigned int npages,
> +  unsigned int *pageSizes,
> +  unsigned long long *pageCounts,
> +  int startCell,
> +  unsigned int cellCount,
> +  unsigned int flags)
> +{
> +VIR_DEBUG("conn=%p npages=%u pageSizes=%p pageCounts=%p "
> +  "startCell=%d cellCount=%u flagx=%x",
> +  conn, npages, pageSizes, pageCounts, startCell,
> +  cellCount, flags);
> +
> +virResetLastError();
> +
> +virCheckConnectReturn(conn, -1);
> +virCheckNonZeroArgGoto(npages, error);
> +virCheckNonNullArgGoto(pageSizes, error);
> +virCheckNonNullArgGoto(pageCounts, error);
> +

Where is the validation that startCell and cellCount make sense?  I'd
assume we want to ensure cellCount is positive?  Or is there a special
case of a count of 0 for visiting all NUMA cells without knowing in
advance how many there are?

> +++ b/src/libvirt_public.syms
> @@ -677,6 +677,7 @@ LIBVIRT_1.2.8 {
>  virDomainListGetStats;
>  virDomainOpenGraphicsFD;
>  virDomainStatsRecordListFree;
> +virNodeAllocPages;
>  } LIBVIRT_1.2.7;

Need a new section for 1.2.9.

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



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redha

Re: [libvirt] [PATCH v5 4/4] cputune_event: queue the event for cputune updates

2014-09-23 Thread John Ferlan


On 09/23/2014 02:47 PM, Pavel Hrdina wrote:
> Now we have universal tunable event so we can use it for reporting
> changes to user. The cputune values will be prefixed with "cputune" to
> distinguish it from other tunable events.
> 
> Signed-off-by: Pavel Hrdina 
> ---
> 
> since v4:
> - added macro definitions for cputune typedParameters fileds
> 
>  include/libvirt/libvirt.h.in | 63 ++
>  src/qemu/qemu_cgroup.c   | 19 ++-
>  src/qemu/qemu_driver.c   | 81 
> 
>  3 files changed, 162 insertions(+), 1 deletion(-)
> 
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 86be86f..898f8b5 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -5204,6 +5204,66 @@ typedef void 
> (*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
> void *opaque);
>  
>  /**
> + * VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN:
> + *
> + * Macro represents formatted pinning for one vcpu specified by id which is
> + * appended to the parameter name, for example "cputune.vcpupin1",
> + * as VIR_TYPED_PARAM_STRING.
> + */
> +#define VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN "cputune.vcpupin%u"
> +
> +/**
> + * VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN:
> + *
> + * Macro represents formatted pinning for emulator process,
> + * as VIR_TYPED_PARAM_STRING.
> + */
> +#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN "cputune.emulatorpin"
> +
> +/**
> + * VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES:
> + *
> + * Macro represents proportional weight of the scheduler used on the
> + * host cpu, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
> + */
> +#define VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES "cputune.cpu_shares"
> +
> +/**
> + * VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD:
> + *
> + * Macro represents the enforcement period for a quota, in microseconds,
> + * for vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
> + */
> +#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD "cputune.vcpu_period"
> +
> +/**
> + * VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA:
> + *
> + * Macro represents the maximum bandwidth to be used within a period for
> + * vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_LLONG.
> + */
> +#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA "cputune.vcpu_quota"
> +
> +/**
> + * VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD:
> + *
> + * Macro represents the enforcement period for a quota in microseconds,
> + * when using the posix scheduler, for all emulator activity not tied to
> + * vcpus, as VIR_TYPED_PARAM_ULLONG.
> + */
> +#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD "cputune.emulator_period"
> +
> +/**
> + * VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA:
> + *
> + * Macro represents the maximum bandwidth to be used within a period for
> + * all emulator activity not tied to vcpus, when using the posix scheduler,
> + * as an VIR_TYPED_PARAM_LLONG.
> + */
> +#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA "cputune.emulator_quota"
> +
> +
> +/**
>   * virConnectDomainEventTunableCallback:
>   * @conn: connection object
>   * @dom: domain on which the event occurred
> @@ -5215,6 +5275,9 @@ typedef void 
> (*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
>   * be freed in the callback handler as it's done internally after the 
> callback
>   * handler is executed.
>   *
> + * Currently supported name spaces:
> + *  "cputune.*"
> + *
>   * The callback signature to use when registering for an event of type
>   * VIR_DOMAIN_EVENT_ID_TUNABLE with virConnectDomainEventRegisterAny()
>   */
> diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
> index 7c6b2c1..41d7057 100644
> --- a/src/qemu/qemu_cgroup.c
> +++ b/src/qemu/qemu_cgroup.c
> @@ -34,6 +34,7 @@
>  #include "virscsi.h"
>  #include "virstring.h"
>  #include "virfile.h"
> +#include "virtypedparam.h"
>  
>  #define VIR_FROM_THIS VIR_FROM_QEMU
>  
> @@ -676,6 +677,10 @@ static int
>  qemuSetupCpuCgroup(virDomainObjPtr vm)
>  {
>  qemuDomainObjPrivatePtr priv = vm->privateData;
> +virObjectEventPtr event = NULL;
> +virTypedParameterPtr eventParams = 0;

s/0/NULL/


ACK w/ that.

John

> +int eventNparams = 0;
> +int eventMaxparams = 0;
>  
>  if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
> if (vm->def->cputune.sharesSpecified) {
> @@ -694,7 +699,19 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
>  
>  if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
>  return -1;
> -vm->def->cputune.shares = val;
> +if (vm->def->cputune.shares != val) {
> +vm->def->cputune.shares = val;
> +if (virTypedParamsAddULLong(&eventParams, &eventNparams,
> +&eventMaxparams,
> +VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES,
> +val) < 0)
> +return

Re: [libvirt] [PATCH v5 2/4] event: introduce new event for tunable values

2014-09-23 Thread John Ferlan


On 09/23/2014 02:46 PM, Pavel Hrdina wrote:
> This new event will use typedParameters to expose what has been actually
> updated and the reason is that we can in the future extend any tunable
> values or add new tunable values. With typedParameters we don't have to
> worry about creating some other events, we will just use this universal
> event to inform user about updates.
> 
> Signed-off-by: Pavel Hrdina 
> ---
> 
> since v4:
> - changed cpu-tune to tunable in virsh-domain.c
> - added REMOTE_DOMAIN_EVENT_TUNABLE_MAX to limit maximal length of tunable
>   event msg
> 
>  daemon/remote.c  | 45 +
>  include/libvirt/libvirt.h.in | 22 +++
>  src/conf/domain_event.c  | 93 
> 
>  src/conf/domain_event.h  |  9 +
>  src/libvirt_private.syms |  2 +
>  src/remote/remote_driver.c   | 42 
>  src/remote/remote_protocol.x | 17 +++-
>  src/remote_protocol-structs  |  9 +
>  tools/virsh-domain.c | 33 
>  9 files changed, 271 insertions(+), 1 deletion(-)
> 
> diff --git a/daemon/remote.c b/daemon/remote.c
> index daa4b60..ddd510c 100644
> --- a/daemon/remote.c
> +++ b/daemon/remote.c
> @@ -111,6 +111,13 @@ remoteDeserializeTypedParameters(remote_typed_param 
> *args_params_val,
>   int *nparams);
>  
>  static int
> +remoteSerializeTypedParameters(virTypedParameterPtr params,
> +   int nparams,
> +   remote_typed_param **ret_params_val,
> +   u_int *ret_params_len,
> +   unsigned int flags);
> +
> +static int
>  remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors,
>  int nerrors,
>  remote_domain_disk_error **ret_errors_val,
> @@ -969,6 +976,43 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
>  }
>  
>  
> +static int
> +remoteRelayDomainEventTunable(virConnectPtr conn,
> +  virDomainPtr dom,
> +  virTypedParameterPtr params,
> +  int nparams,
> +  void *opaque)
> +{
> +daemonClientEventCallbackPtr callback = opaque;
> +remote_domain_event_callback_tunable_msg data;
> +
> +if (callback->callbackID < 0 ||
> +!remoteRelayDomainEventCheckACL(callback->client, conn, dom))
> +return -1;
> +
> +VIR_DEBUG("Relaying domain tunable event %s %d, callback %d",
> +  dom->name, dom->id, callback->callbackID);
> +
> +/* build return data */
> +memset(&data, 0, sizeof(data));
> +data.callbackID = callback->callbackID;
> +make_nonnull_domain(&data.dom, dom);
> +
> +if (remoteSerializeTypedParameters(params, nparams,
> +   &data.params.params_val,
> +   &data.params.params_len,
> +   VIR_TYPED_PARAM_STRING_OKAY) < 0)
> +return -1;
> +
> +remoteDispatchObjectEventSend(callback->client, remoteProgram,
> +  REMOTE_PROC_DOMAIN_EVENT_CALLBACK_TUNABLE,
> +  
> (xdrproc_t)xdr_remote_domain_event_callback_tunable_msg,
> +  &data);
> +
> +return 0;
> +}
> +
> +
>  static virConnectDomainEventGenericCallback domainEventCallbacks[] = {
>  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
>  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventReboot),
> @@ -987,6 +1031,7 @@ static virConnectDomainEventGenericCallback 
> domainEventCallbacks[] = {
>  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventPMSuspendDisk),
>  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventDeviceRemoved),
>  VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBlockJob2),
> +VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventTunable),
>  };
>  
>  verify(ARRAY_CARDINALITY(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST);
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 6371b7b..86be86f 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -5203,6 +5203,27 @@ typedef void 
> (*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
> const char 
> *devAlias,
> void *opaque);
>  
> +/**
> + * virConnectDomainEventTunableCallback:
> + * @conn: connection object
> + * @dom: domain on which the event occurred
> + * @params: changed tunable values stored as array of virTypedParameter
> + * @nparams: size of the array
> + * @opaque: application specified data
> + *
> + * This callback occurs when tunable values are updated. The params must not
> + * be freed in the callback handler as it's done internally after

Re: [libvirt] [PATCH V2] libvirt-guests: run after time-sync.target

2014-09-23 Thread Eric Blake
On 09/23/2014 11:53 AM, Jim Fehlig wrote:
> When libvirt-guests is configured to start guests on host
> boot, it is possible for guests start and read the host
> clock before it is synchronized.  Services such as
> libvirt-guests that require correct time should use the
> Special Passive System Unit time-sync.target
> 
> http://www.freedesktop.org/software/systemd/man/systemd.special.html#time-sync.target
> Signed-off-by: Jim Fehlig 
> ---
> 
> V2 of
> 
> https://www.redhat.com/archives/libvir-list/2014-September/msg00426.html
> 
> In V2: Use time-sync.target instead of ntp-wait.service

ACK

> 
>  tools/libvirt-guests.service.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in
> index d8d7adf..cc04b6d 100644
> --- a/tools/libvirt-guests.service.in
> +++ b/tools/libvirt-guests.service.in
> @@ -1,6 +1,6 @@
>  [Unit]
>  Description=Suspend Active Libvirt Guests
> -After=network.target libvirtd.service
> +After=network.target libvirtd.service time-sync.target
>  Documentation=man:libvirtd(8)
>  Documentation=http://libvirt.org
>  
> 

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



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

[libvirt] [PATCH v5 2/4] event: introduce new event for tunable values

2014-09-23 Thread Pavel Hrdina
This new event will use typedParameters to expose what has been actually
updated and the reason is that we can in the future extend any tunable
values or add new tunable values. With typedParameters we don't have to
worry about creating some other events, we will just use this universal
event to inform user about updates.

Signed-off-by: Pavel Hrdina 
---

since v4:
- changed cpu-tune to tunable in virsh-domain.c
- added REMOTE_DOMAIN_EVENT_TUNABLE_MAX to limit maximal length of tunable
  event msg

 daemon/remote.c  | 45 +
 include/libvirt/libvirt.h.in | 22 +++
 src/conf/domain_event.c  | 93 
 src/conf/domain_event.h  |  9 +
 src/libvirt_private.syms |  2 +
 src/remote/remote_driver.c   | 42 
 src/remote/remote_protocol.x | 17 +++-
 src/remote_protocol-structs  |  9 +
 tools/virsh-domain.c | 33 
 9 files changed, 271 insertions(+), 1 deletion(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index daa4b60..ddd510c 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -111,6 +111,13 @@ remoteDeserializeTypedParameters(remote_typed_param 
*args_params_val,
  int *nparams);
 
 static int
+remoteSerializeTypedParameters(virTypedParameterPtr params,
+   int nparams,
+   remote_typed_param **ret_params_val,
+   u_int *ret_params_len,
+   unsigned int flags);
+
+static int
 remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors,
 int nerrors,
 remote_domain_disk_error **ret_errors_val,
@@ -969,6 +976,43 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
 }
 
 
+static int
+remoteRelayDomainEventTunable(virConnectPtr conn,
+  virDomainPtr dom,
+  virTypedParameterPtr params,
+  int nparams,
+  void *opaque)
+{
+daemonClientEventCallbackPtr callback = opaque;
+remote_domain_event_callback_tunable_msg data;
+
+if (callback->callbackID < 0 ||
+!remoteRelayDomainEventCheckACL(callback->client, conn, dom))
+return -1;
+
+VIR_DEBUG("Relaying domain tunable event %s %d, callback %d",
+  dom->name, dom->id, callback->callbackID);
+
+/* build return data */
+memset(&data, 0, sizeof(data));
+data.callbackID = callback->callbackID;
+make_nonnull_domain(&data.dom, dom);
+
+if (remoteSerializeTypedParameters(params, nparams,
+   &data.params.params_val,
+   &data.params.params_len,
+   VIR_TYPED_PARAM_STRING_OKAY) < 0)
+return -1;
+
+remoteDispatchObjectEventSend(callback->client, remoteProgram,
+  REMOTE_PROC_DOMAIN_EVENT_CALLBACK_TUNABLE,
+  
(xdrproc_t)xdr_remote_domain_event_callback_tunable_msg,
+  &data);
+
+return 0;
+}
+
+
 static virConnectDomainEventGenericCallback domainEventCallbacks[] = {
 VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle),
 VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventReboot),
@@ -987,6 +1031,7 @@ static virConnectDomainEventGenericCallback 
domainEventCallbacks[] = {
 VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventPMSuspendDisk),
 VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventDeviceRemoved),
 VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBlockJob2),
+VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventTunable),
 };
 
 verify(ARRAY_CARDINALITY(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST);
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 6371b7b..86be86f 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5203,6 +5203,27 @@ typedef void 
(*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
const char 
*devAlias,
void *opaque);
 
+/**
+ * virConnectDomainEventTunableCallback:
+ * @conn: connection object
+ * @dom: domain on which the event occurred
+ * @params: changed tunable values stored as array of virTypedParameter
+ * @nparams: size of the array
+ * @opaque: application specified data
+ *
+ * This callback occurs when tunable values are updated. The params must not
+ * be freed in the callback handler as it's done internally after the callback
+ * handler is executed.
+ *
+ * The callback signature to use when registering for an event of type
+ * VIR_DOMAIN_EVENT_ID_TUNABLE with virConnectDomainEventRegisterAny()
+ */
+typedef void (*virConnectDomainEventTunableCallback)(virConnectPtr conn,
+  

[libvirt] [PATCH v5 4/4] cputune_event: queue the event for cputune updates

2014-09-23 Thread Pavel Hrdina
Now we have universal tunable event so we can use it for reporting
changes to user. The cputune values will be prefixed with "cputune" to
distinguish it from other tunable events.

Signed-off-by: Pavel Hrdina 
---

since v4:
- added macro definitions for cputune typedParameters fileds

 include/libvirt/libvirt.h.in | 63 ++
 src/qemu/qemu_cgroup.c   | 19 ++-
 src/qemu/qemu_driver.c   | 81 
 3 files changed, 162 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 86be86f..898f8b5 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5204,6 +5204,66 @@ typedef void 
(*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
void *opaque);
 
 /**
+ * VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN:
+ *
+ * Macro represents formatted pinning for one vcpu specified by id which is
+ * appended to the parameter name, for example "cputune.vcpupin1",
+ * as VIR_TYPED_PARAM_STRING.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN "cputune.vcpupin%u"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN:
+ *
+ * Macro represents formatted pinning for emulator process,
+ * as VIR_TYPED_PARAM_STRING.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATORIN "cputune.emulatorpin"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES:
+ *
+ * Macro represents proportional weight of the scheduler used on the
+ * host cpu, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES "cputune.cpu_shares"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD:
+ *
+ * Macro represents the enforcement period for a quota, in microseconds,
+ * for vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_PERIOD "cputune.vcpu_period"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA:
+ *
+ * Macro represents the maximum bandwidth to be used within a period for
+ * vcpus only, when using the posix scheduler, as VIR_TYPED_PARAM_LLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_VCPU_QUOTA "cputune.vcpu_quota"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD:
+ *
+ * Macro represents the enforcement period for a quota in microseconds,
+ * when using the posix scheduler, for all emulator activity not tied to
+ * vcpus, as VIR_TYPED_PARAM_ULLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_PERIOD "cputune.emulator_period"
+
+/**
+ * VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA:
+ *
+ * Macro represents the maximum bandwidth to be used within a period for
+ * all emulator activity not tied to vcpus, when using the posix scheduler,
+ * as an VIR_TYPED_PARAM_LLONG.
+ */
+#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATOR_QUOTA "cputune.emulator_quota"
+
+
+/**
  * virConnectDomainEventTunableCallback:
  * @conn: connection object
  * @dom: domain on which the event occurred
@@ -5215,6 +5275,9 @@ typedef void 
(*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
  * be freed in the callback handler as it's done internally after the callback
  * handler is executed.
  *
+ * Currently supported name spaces:
+ *  "cputune.*"
+ *
  * The callback signature to use when registering for an event of type
  * VIR_DOMAIN_EVENT_ID_TUNABLE with virConnectDomainEventRegisterAny()
  */
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 7c6b2c1..41d7057 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -34,6 +34,7 @@
 #include "virscsi.h"
 #include "virstring.h"
 #include "virfile.h"
+#include "virtypedparam.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -676,6 +677,10 @@ static int
 qemuSetupCpuCgroup(virDomainObjPtr vm)
 {
 qemuDomainObjPrivatePtr priv = vm->privateData;
+virObjectEventPtr event = NULL;
+virTypedParameterPtr eventParams = 0;
+int eventNparams = 0;
+int eventMaxparams = 0;
 
 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
if (vm->def->cputune.sharesSpecified) {
@@ -694,7 +699,19 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
 
 if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
 return -1;
-vm->def->cputune.shares = val;
+if (vm->def->cputune.shares != val) {
+vm->def->cputune.shares = val;
+if (virTypedParamsAddULLong(&eventParams, &eventNparams,
+&eventMaxparams,
+VIR_DOMAIN_EVENT_CPUTUNE_CPU_SHARES,
+val) < 0)
+return -1;
+
+event = virDomainEventTunableNewFromObj(vm, eventParams, 
eventNparams);
+}
+
+if (event)
+qemuDomainEventQueue(vm->privateData, event);
 }
 
 return 0;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e73d4f9..d1a0657 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_dr

[libvirt] [PATCH V2] libvirt-guests: run after time-sync.target

2014-09-23 Thread Jim Fehlig
When libvirt-guests is configured to start guests on host
boot, it is possible for guests start and read the host
clock before it is synchronized.  Services such as
libvirt-guests that require correct time should use the
Special Passive System Unit time-sync.target

http://www.freedesktop.org/software/systemd/man/systemd.special.html#time-sync.target
Signed-off-by: Jim Fehlig 
---

V2 of

https://www.redhat.com/archives/libvir-list/2014-September/msg00426.html

In V2: Use time-sync.target instead of ntp-wait.service

 tools/libvirt-guests.service.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in
index d8d7adf..cc04b6d 100644
--- a/tools/libvirt-guests.service.in
+++ b/tools/libvirt-guests.service.in
@@ -1,6 +1,6 @@
 [Unit]
 Description=Suspend Active Libvirt Guests
-After=network.target libvirtd.service
+After=network.target libvirtd.service time-sync.target
 Documentation=man:libvirtd(8)
 Documentation=http://libvirt.org
 
-- 
1.8.4.5

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


Re: [libvirt] [PATCH] libvirt-guests: wait for ntp service

2014-09-23 Thread Jim Fehlig
Michal Privoznik wrote:
> On 23.09.2014 08:06, Martin Kletzander wrote:
>> On Mon, Sep 22, 2014 at 04:50:33PM -0600, Jim Fehlig wrote:
>>> Michal Privoznik wrote:
 On 20.09.2014 01:36, Jim Fehlig wrote:
> Martin Kletzander wrote:
>> Unfortunately I'm not very familiar with systemd files, but my guess
>> is that After=ntp-wait.service means it should be started after the
>> time is synchronized if and only if the ntp-wait.service unit is
>> enabled, otherwise it doesn't require it.
>
> Yes, this is my understanding too.

 And so is mine. The only concern I have is that syncing time on cold
 boot of the host may take ages.
>>>
>>> Yep, I have this concern too.  So I dug a bit further and see that
>>> ntp-wait (a perl script) scrapes the output of `ntpq -c "rv 0`, waiting
>>> for leap_alarm to change to leap_none, leap_add_sec, or leap_del_sec.
>>> On my test system, this took ~16min on cold boot :-(.  ntp-wait.service
>>> failed in the meantime, since it by default calls /usr/sbin/ntp-wait
>>> with options to only wait 10min.
>>>
 But on the other hand, it's better to start domains later and with
 correct time than start asap with inaccurate time. ACK then,
>>>
>>> Given the above observations, I'll wait to see if you change your mind.
>>>
>>
>> What would you say to changing it to After=ntpdate.service?  That way
>> it won't wait until the clock is synchronized, but it will be started
>> with proper time if ntpdate.service is set up to start in the default
>> runlevel (or is it target in systemd?).  I think that's a compromise
>> that has no negative side-effects.
>
> I wonder if we should be this specific or use time-sync.target:
>
> time-sync.target
>
> Services responsible for synchronizing the system clock from a
> remote source (such as NTP client implementations) should pull in this
> target and order themselves before it. All services where correct time
> is essential should be ordered after this unit, but not pull it in.
> systemd automatically adds dependencies of type After= for this target
> unit to all SysV init script service units with an LSB header
> referring to the "$time" facility.
>
> http://www.freedesktop.org/software/systemd/man/systemd.special.html#time-sync.target
>

Cool, thanks for finding that!

>
> So I'd say: After=time-sync.target is what we are looking for.

Agreed.  I'll send a V2.

Regards,
Jim

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


Re: [libvirt] [PATCH] libvirt-guests: wait for ntp service

2014-09-23 Thread Jim Fehlig
Martin Kletzander wrote:
> On Mon, Sep 22, 2014 at 04:50:33PM -0600, Jim Fehlig wrote:
>> Michal Privoznik wrote:
>>> On 20.09.2014 01:36, Jim Fehlig wrote:
 Martin Kletzander wrote:
> Unfortunately I'm not very familiar with systemd files, but my guess
> is that After=ntp-wait.service means it should be started after the
> time is synchronized if and only if the ntp-wait.service unit is
> enabled, otherwise it doesn't require it.

 Yes, this is my understanding too.
>>>
>>> And so is mine. The only concern I have is that syncing time on cold
>>> boot of the host may take ages.
>>
>> Yep, I have this concern too.  So I dug a bit further and see that
>> ntp-wait (a perl script) scrapes the output of `ntpq -c "rv 0`, waiting
>> for leap_alarm to change to leap_none, leap_add_sec, or leap_del_sec.
>> On my test system, this took ~16min on cold boot :-(.  ntp-wait.service
>> failed in the meantime, since it by default calls /usr/sbin/ntp-wait
>> with options to only wait 10min.
>>
>>> But on the other hand, it's better to start domains later and with
>>> correct time than start asap with inaccurate time. ACK then,
>>
>> Given the above observations, I'll wait to see if you change your mind.
>>
>
> What would you say to changing it to After=ntpdate.service?

It appears ntpdate is deprecated

https://support.ntp.org/bin/view/Dev/DeprecatingNtpdate

Like ifconfig, it is having a very slow death.

Regards,
Jim

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


[libvirt] [PATCH 1/2] qemu_command: Split qemuBuildCpuArgStr

2014-09-23 Thread Cole Robinson
Move the CPU mode/model handling to its own function. This is just
code movement and re-indentation.
---
 src/qemu/qemu_command.c | 226 ++--
 1 file changed, 122 insertions(+), 104 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 65864d2..7c43604 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6096,139 +6096,162 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
 return NULL;
 }
 
-
 static int
-qemuBuildCpuArgStr(virQEMUDriverPtr driver,
-   const virDomainDef *def,
-   const char *emulator,
-   virQEMUCapsPtr qemuCaps,
-   virArch hostarch,
-   char **opt,
-   bool *hasHwVirt,
-   bool migrating)
+qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
+const virDomainDef *def,
+virBufferPtr buf,
+virQEMUCapsPtr qemuCaps,
+bool *hasHwVirt,
+bool migrating)
 {
+int ret = -1;
+size_t i;
 virCPUDefPtr host = NULL;
 virCPUDefPtr guest = NULL;
 virCPUDefPtr cpu = NULL;
 size_t ncpus = 0;
 char **cpus = NULL;
-const char *default_model;
 virCPUDataPtr data = NULL;
-bool have_cpu = false;
 char *compare_msg = NULL;
-int ret = -1;
-virBuffer buf = VIR_BUFFER_INITIALIZER;
-size_t i;
+virCPUCompareResult cmp;
+const char *preferred;
 virCapsPtr caps = NULL;
 
-*hasHwVirt = false;
-
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
 goto cleanup;
 
 host = caps->host.cpu;
 
-if (def->os.arch == VIR_ARCH_I686)
-default_model = "qemu32";
-else
-default_model = "qemu64";
+if (!host ||
+!host->model ||
+(ncpus = virQEMUCapsGetCPUDefinitions(qemuCaps, &cpus)) == 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("CPU specification not supported by hypervisor"));
+goto cleanup;
+}
 
-if (def->cpu &&
-(def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) {
-virCPUCompareResult cmp;
-const char *preferred;
+if (!(cpu = virCPUDefCopy(def->cpu)))
+goto cleanup;
+
+if (cpu->mode != VIR_CPU_MODE_CUSTOM &&
+!migrating &&
+cpuUpdate(cpu, host) < 0)
+goto cleanup;
 
-if (!host ||
-!host->model ||
-(ncpus = virQEMUCapsGetCPUDefinitions(qemuCaps, &cpus)) == 0) {
+cmp = cpuGuestData(host, cpu, &data, &compare_msg);
+switch (cmp) {
+case VIR_CPU_COMPARE_INCOMPATIBLE:
+if (compare_msg) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("guest and host CPU are not compatible: %s"),
+   compare_msg);
+} else {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-   _("CPU specification not supported by hypervisor"));
-goto cleanup;
+   _("guest CPU is not compatible with host CPU"));
 }
+/* fall through */
+case VIR_CPU_COMPARE_ERROR:
+goto cleanup;
 
-if (!(cpu = virCPUDefCopy(def->cpu)))
+default:
+break;
+}
+
+/* Only 'svm' requires --enable-nesting. The nested
+ * 'vmx' patches now simply hook off the CPU features
+ */
+if (def->os.arch == VIR_ARCH_X86_64 ||
+def->os.arch == VIR_ARCH_I686) {
+int hasSVM = cpuHasFeature(data, "svm");
+if (hasSVM < 0)
 goto cleanup;
+*hasHwVirt = hasSVM > 0 ? true : false;
+}
 
-if (cpu->mode != VIR_CPU_MODE_CUSTOM &&
-!migrating &&
-cpuUpdate(cpu, host) < 0)
+if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) {
+const char *mode = virCPUModeTypeToString(cpu->mode);
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_HOST)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("CPU mode '%s' is not supported by QEMU"
+ " binary"), mode);
+goto cleanup;
+}
+if (def->virtType != VIR_DOMAIN_VIRT_KVM) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("CPU mode '%s' is only supported with kvm"),
+   mode);
+goto cleanup;
+}
+virBufferAddLit(buf, "host");
+} else {
+if (VIR_ALLOC(guest) < 0)
+goto cleanup;
+if (VIR_STRDUP(guest->vendor_id, cpu->vendor_id) < 0)
 goto cleanup;
 
-cmp = cpuGuestData(host, cpu, &data, &compare_msg);
-switch (cmp) {
-case VIR_CPU_COMPARE_INCOMPATIBLE:
-if (compare_msg) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _("guest and host CPU are not compati

[libvirt] [PATCH 6/6] virsh: added migrate --postcopy-after

2014-09-23 Thread Cristian Klein
Added a new parameter to the `virsh migrate` command to switch to
post-copy migration after a given timeout.

Signed-off-by: Cristian Klein 
---
 tools/virsh-domain.c | 72 ++--
 tools/virsh.pod  |  5 
 2 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index a6ced5f..1bba710 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9250,6 +9250,10 @@ static const vshCmdOptDef opts_migrate[] = {
  .type = VSH_OT_INT,
  .help = N_("force guest to suspend if live migration exceeds timeout (in 
seconds)")
 },
+{.name = "postcopy-after",
+ .type = VSH_OT_INT,
+ .help = N_("switch to post-copy migration if live migration exceeds 
timeout (in seconds)")
+},
 {.name = "xml",
  .type = VSH_OT_STRING,
  .help = N_("filename containing updated XML for the target")
@@ -9331,6 +9335,8 @@ doMigrate(void *opaque)
 VIR_FREE(xml);
 }
 
+if (vshCommandOptBool(cmd, "postcopy-after")) /* actually an int */
+flags |= VIR_MIGRATE_POSTCOPY;
 if (vshCommandOptBool(cmd, "live"))
 flags |= VIR_MIGRATE_LIVE;
 if (vshCommandOptBool(cmd, "p2p"))
@@ -9422,6 +9428,50 @@ vshMigrationTimeout(vshControl *ctl,
 virDomainSuspend(dom);
 }
 
+static void
+vshMigrationPostCopyAfter(vshControl *ctl,
+virDomainPtr dom,
+void *opaque ATTRIBUTE_UNUSED)
+{
+vshDebug(ctl, VSH_ERR_DEBUG, "starting post-copy\n");
+int rv = virDomainMigrateStartPostCopy(dom);
+if (rv < 0) {
+vshError(ctl, "%s", _("start post-copy command failed"));
+} else {
+vshDebug(ctl, VSH_ERR_INFO, "switched to post-copy\n");
+}
+}
+
+/* Parse the --postcopy-after parameter in seconds, but store its
+ * value in milliseconds. Return -1 on error, 0 if
+ * no timeout was requested, and 1 if timeout was set.
+ * Copy-paste-adapted from vshCommandOptTimeoutToMs.
+ */
+static int
+vshCommandOptPostCopyAfterToMs(vshControl *ctl, const vshCmd *cmd, int 
*postCopyAfter)
+{
+int rv = vshCommandOptInt(cmd, "postcopy-after", postCopyAfter);
+
+if (rv < 0 || (rv > 0 && *postCopyAfter < 0)) {
+vshError(ctl, "%s", _("invalid postcopy-after parameter"));
+return -1;
+}
+if (rv > 0) {
+/* Ensure that we can multiply by 1000 without overflowing. */
+if (*postCopyAfter > INT_MAX / 1000) {
+vshError(ctl, "%s", _("post-copy after parameter is too big"));
+return -1;
+}
+*postCopyAfter *= 1000;
+/* 0 is a special value inside virsh, which means no timeout, so
+ * use 1ms instead for "start post-copy immediately"
+ */
+if (*postCopyAfter == 0)
+*postCopyAfter = 1;
+}
+return rv;
+}
+
 static bool
 cmdMigrate(vshControl *ctl, const vshCmd *cmd)
 {
@@ -9431,6 +9481,7 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
 bool verbose = false;
 bool functionReturn = false;
 int timeout = 0;
+int postCopyAfter = 0;
 bool live_flag = false;
 vshCtrlData data = { .dconn = NULL };
 
@@ -9450,6 +9501,18 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
 goto cleanup;
 }
 
+if (vshCommandOptPostCopyAfterToMs(ctl, cmd, &postCopyAfter) < 0) {
+goto cleanup;
+} else if (postCopyAfter > 0 && !live_flag) {
+vshError(ctl, "%s",
+ _("migrate: Unexpected postcopy-after for offline 
migration"));
+goto cleanup;
+} else if (postCopyAfter > 0 && timeout > 0) {
+vshError(ctl, "%s",
+ _("migrate: --postcopy-after is incompatible with 
--timeout"));
+goto cleanup;
+}
+
 if (pipe(p) < 0)
 goto cleanup;
 
@@ -9479,8 +9542,13 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
 doMigrate,
 &data) < 0)
 goto cleanup;
-functionReturn = vshWatchJob(ctl, dom, verbose, p[0], timeout,
- vshMigrationTimeout, NULL, _("Migration"));
+if (postCopyAfter != 0) {
+functionReturn = vshWatchJob(ctl, dom, verbose, p[0], postCopyAfter,
+ vshMigrationPostCopyAfter, NULL, 
_("Migration"));
+} else {
+functionReturn = vshWatchJob(ctl, dom, verbose, p[0], timeout,
+ vshMigrationTimeout, NULL, 
_("Migration"));
+}
 
 virThreadJoin(&workerThread);
 
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 9919f92..3947720 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1392,6 +1392,7 @@ to the I namespace is displayed instead of being 
modified.
 [I<--compressed>] [I<--abort-on-error>] [I<--auto-converge>]
 I I [I] [I] [I]
 [I] [I<--timeout> B] [I<--xml> B]
+[I<--postcopy-after> B]
 
 Migrate domain to another host.  Add I<--live> for live migration; <--p2p>
 for peer-2-peer migration; I<--direct> for direct migratio

[libvirt] [PATCH 2/2] qemu: Don't compare CPU against host for TCG

2014-09-23 Thread Cole Robinson
Right now when building the qemu command line, we try to do various
unconditional validations of the guest CPU against the host CPU. However
this checks are overly applied. The only time we should use the checks
are:

- The user requests host-model/host-passthrough, or

- When KVM is requsted. CPU features requested in TCG mode are always
  emulated by qemu and are independent of the host CPU, so no host CPU
  checks should be performed.

Right now if trying to specify a CPU for arm on an x86 host, it attempts
to do non-sensical validation and falls over.

Switch all the test cases that were intending to test CPU validation to
use KVM, so they continue to test the intended code.

Amend some aarch64 XML tests with a CPU model, to ensure things work
correctly.
---
 src/qemu/qemu_command.c| 68 +-
 .../qemuxml2argv-aarch64-virt-default-nic.args |  3 +-
 .../qemuxml2argv-aarch64-virt-default-nic.xml  |  3 +
 .../qemuxml2argv-aarch64-virt-virtio.args  |  3 +-
 .../qemuxml2argv-aarch64-virt-virtio.xml   |  3 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact1.args  |  2 +-
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml |  4 +-
 .../qemuxml2argv-cpu-exact2-nofallback.args|  2 +-
 .../qemuxml2argv-cpu-exact2-nofallback.xml |  4 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact2.args  |  2 +-
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml |  4 +-
 .../qemuxml2argv-cpu-fallback.args |  2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-fallback.xml |  4 +-
 .../qemuxml2argv-cpu-minimum1.args |  2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml |  4 +-
 .../qemuxml2argv-cpu-minimum2.args |  2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml |  4 +-
 .../qemuxml2argv-cpu-nofallback.xml|  2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.args |  2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml  |  4 +-
 .../qemuxml2argv-graphics-spice-timeout.args   |  2 +-
 .../qemuxml2argv-graphics-spice-timeout.xml|  4 +-
 .../qemuxml2argv-pseries-cpu-exact.args|  4 +-
 tests/qemuxml2argvtest.c   | 21 +++
 .../qemuxml2xmlout-graphics-spice-timeout.xml  |  4 +-
 25 files changed, 90 insertions(+), 69 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7c43604..a84676a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6116,6 +6116,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
 virCPUCompareResult cmp;
 const char *preferred;
 virCapsPtr caps = NULL;
+bool compareAgainstHost = (def->virtType == VIR_DOMAIN_VIRT_KVM ||
+def->cpu->mode != VIR_CPU_MODE_CUSTOM);
 
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
 goto cleanup;
@@ -6138,30 +6140,33 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
 cpuUpdate(cpu, host) < 0)
 goto cleanup;
 
-cmp = cpuGuestData(host, cpu, &data, &compare_msg);
-switch (cmp) {
-case VIR_CPU_COMPARE_INCOMPATIBLE:
-if (compare_msg) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _("guest and host CPU are not compatible: %s"),
-   compare_msg);
-} else {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-   _("guest CPU is not compatible with host CPU"));
-}
-/* fall through */
-case VIR_CPU_COMPARE_ERROR:
-goto cleanup;
+/* For non-KVM, CPU features are emulated, so host compat doesn't matter */
+if (compareAgainstHost) {
+cmp = cpuGuestData(host, cpu, &data, &compare_msg);
+switch (cmp) {
+case VIR_CPU_COMPARE_INCOMPATIBLE:
+if (compare_msg) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("guest and host CPU are not compatible: %s"),
+   compare_msg);
+} else {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("guest CPU is not compatible with host CPU"));
+}
+/* fall through */
+case VIR_CPU_COMPARE_ERROR:
+goto cleanup;
 
-default:
-break;
+default:
+break;
+}
 }
 
 /* Only 'svm' requires --enable-nesting. The nested
  * 'vmx' patches now simply hook off the CPU features
  */
-if (def->os.arch == VIR_ARCH_X86_64 ||
-def->os.arch == VIR_ARCH_I686) {
+if ((def->os.arch == VIR_ARCH_X86_64 || def->os.arch == VIR_ARCH_I686) &&
+ compareAgainstHost) {
 int hasSVM = cpuHasFeature(data, "svm");
 if (hasSVM < 0)
 goto cleanup;
@@ -6189,16 +6194,23 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
 if (VIR_STRDUP(guest->vendor_id, cpu->vendor_id) < 0)
 goto cleanup;
 
- 

[libvirt] [PATCH 1/6] Added qemu postcopy-active migration status

2014-09-23 Thread Cristian Klein
Signed-off-by: Cristian Klein 
---
 src/qemu/qemu_migration.c| 1 +
 src/qemu/qemu_monitor.c  | 2 +-
 src/qemu/qemu_monitor.h  | 1 +
 src/qemu/qemu_monitor_json.c | 3 ++-
 src/qemu/qemu_monitor_text.c | 3 ++-
 5 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 44cb826..a5bd825 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1991,6 +1991,7 @@ qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver,
 /* fall through */
 case QEMU_MONITOR_MIGRATION_STATUS_SETUP:
 case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE:
+case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_ACTIVE:
 ret = 0;
 break;
 
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index e2013be..14688bf 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -117,7 +117,7 @@ VIR_ONCE_GLOBAL_INIT(qemuMonitor)
 
 VIR_ENUM_IMPL(qemuMonitorMigrationStatus,
   QEMU_MONITOR_MIGRATION_STATUS_LAST,
-  "inactive", "active", "completed", "failed", "cancelled", 
"setup")
+  "inactive", "active", "completed", "failed", "cancelled", 
"setup", "postcopy-active")
 
 VIR_ENUM_IMPL(qemuMonitorMigrationCaps,
   QEMU_MONITOR_MIGRATION_CAPS_LAST,
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 9a72b59..587f779 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -429,6 +429,7 @@ enum {
 QEMU_MONITOR_MIGRATION_STATUS_ERROR,
 QEMU_MONITOR_MIGRATION_STATUS_CANCELLED,
 QEMU_MONITOR_MIGRATION_STATUS_SETUP,
+QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_ACTIVE,
 
 QEMU_MONITOR_MIGRATION_STATUS_LAST
 };
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a3d7c2c..e98962b 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2557,7 +2557,8 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr 
reply,
 status->setup_time_set = true;
 
 if (status->status == QEMU_MONITOR_MIGRATION_STATUS_ACTIVE ||
-status->status == QEMU_MONITOR_MIGRATION_STATUS_COMPLETED) {
+status->status == QEMU_MONITOR_MIGRATION_STATUS_COMPLETED ||
+status->status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_ACTIVE)  {
 virJSONValuePtr ram = virJSONValueObjectGet(ret, "ram");
 if (!ram) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 46d2782..a3c8aa5 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1458,7 +1458,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
 goto cleanup;
 }
 
-if (status->status == QEMU_MONITOR_MIGRATION_STATUS_ACTIVE) {
+if (status->status == QEMU_MONITOR_MIGRATION_STATUS_ACTIVE ||
+status->status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_ACTIVE) {
 tmp = end + 1;
 
 if (!(tmp = strstr(tmp, MIGRATION_TRANSFER_PREFIX)))
-- 
1.9.1

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


[libvirt] [PATCH 3/6] Added new public API virDomainMigrateStartPostCopy

2014-09-23 Thread Cristian Klein
The user first start migration using the `VIR_MIGRATE_POSTCOPY` flag,
then calls `virDomainMigrateStartPostCopy` asynchronously to switch from
pre-copy to post-copy.

Signed-off-by: Cristian Klein 
---
 include/libvirt/libvirt.h.in |  2 ++
 src/driver.h |  4 
 src/libvirt.c| 37 +
 src/libvirt_public.syms  |  5 +
 4 files changed, 48 insertions(+)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index bdc33c6..eabedfa 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1346,6 +1346,8 @@ int virDomainMigrateToURI3(virDomainPtr domain,
unsigned int nparams,
unsigned int flags);
 
+int virDomainMigrateStartPostCopy (virDomainPtr domain);
+
 int virDomainMigrateSetMaxDowntime (virDomainPtr domain,
 unsigned long long downtime,
 unsigned int flags);
diff --git a/src/driver.h b/src/driver.h
index bb748c4..6866ccd 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1212,6 +1212,9 @@ typedef int
   virDomainStatsRecordPtr **retStats,
   unsigned int flags);
 
+typedef int
+(*virDrvDomainMigrateStartPostCopy)(virDomainPtr domain);
+
 typedef struct _virDriver virDriver;
 typedef virDriver *virDriverPtr;
 
@@ -1435,6 +1438,7 @@ struct _virDriver {
 virDrvNodeGetFreePages nodeGetFreePages;
 virDrvConnectGetDomainCapabilities connectGetDomainCapabilities;
 virDrvConnectGetAllDomainStats connectGetAllDomainStats;
+virDrvDomainMigrateStartPostCopy domainMigrateStartPostCopy;
 };
 
 
diff --git a/src/libvirt.c b/src/libvirt.c
index 33aeafa..e685da2 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -17803,6 +17803,43 @@ virDomainMigrateSetCompressionCache(virDomainPtr 
domain,
 
 
 /**
+ * virDomainMigrateStartPostCopy:
+ * @domain: a domain object
+ *
+ * Starts post-copy migration. This function has to be called while
+ * migration (initially pre-copy) is in progress. The migration operation
+ * must be called with the VIR_MIGRATE_POSTCOPY flag.
+ *
+ * Returns 0 in case of success, -1 otherwise.
+ */
+int
+virDomainMigrateStartPostCopy(virDomainPtr domain)
+{
+virConnectPtr conn;
+
+VIR_DOMAIN_DEBUG(domain);
+
+virResetLastError();
+
+virCheckDomainReturn(domain, -1);
+conn = domain->conn;
+
+virCheckReadOnlyGoto(conn->flags, error);
+
+if (conn->driver->domainMigrateStartPostCopy) {
+if (conn->driver->domainMigrateStartPostCopy(domain) < 0)
+goto error;
+return 0;
+}
+
+virReportUnsupportedError();
+ error:
+virDispatchError(conn);
+return -1;
+}
+
+
+/**
  * virDomainMigrateSetMaxSpeed:
  * @domain: a domain object
  * @bandwidth: migration bandwidth limit in MiB/s
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index e1f013f..ea17a07 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -679,4 +679,9 @@ LIBVIRT_1.2.8 {
 virDomainStatsRecordListFree;
 } LIBVIRT_1.2.7;
 
+LIBVIRT_1.2.9 {
+global:
+virDomainMigrateStartPostCopy;
+} LIBVIRT_1.2.8;
+
 #  define new API here using predicted next version number 
-- 
1.9.1

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


[libvirt] [PATCH 4/6] Added domainMigrateStartPostCopy in qemu driver

2014-09-23 Thread Cristian Klein
Signed-off-by: Cristian Klein 
---
 src/qemu/qemu_driver.c   | 44 
 src/qemu/qemu_monitor.c  | 19 +++
 src/qemu/qemu_monitor.h  |  2 ++
 src/qemu/qemu_monitor_json.c | 18 ++
 src/qemu/qemu_monitor_json.h |  1 +
 src/qemu/qemu_monitor_text.c | 11 +++
 src/qemu/qemu_monitor_text.h |  2 ++
 7 files changed, 97 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e73d4f9..02c9a3b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11861,6 +11861,49 @@ qemuDomainGetJobStats(virDomainPtr dom,
 }
 
 
+static int qemuMigrateStartPostCopy(virDomainPtr dom)
+{
+virQEMUDriverPtr driver = dom->conn->privateData;
+virDomainObjPtr vm;
+int ret = -1;
+qemuDomainObjPrivatePtr priv;
+
+if (!(vm = qemuDomObjFromDomain(dom)))
+goto cleanup;
+
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0)
+goto cleanup;
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   "%s", _("domain is not running"));
+goto endjob;
+}
+
+priv = vm->privateData;
+
+if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) {
+virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+   _("post-copy can only be started "
+"while migration is in progress"));
+goto cleanup;
+}
+
+VIR_DEBUG("Starting post-copy");
+qemuDomainObjEnterMonitor(driver, vm);
+ret = qemuMonitorMigrateStartPostCopy(priv->mon);
+qemuDomainObjExitMonitor(driver, vm);
+
+ endjob:
+if (!qemuDomainObjEndJob(driver, vm))
+vm = NULL;
+
+ cleanup:
+if (vm)
+virObjectUnlock(vm);
+return ret;
+}
+
 static int qemuDomainAbortJob(virDomainPtr dom)
 {
 virQEMUDriverPtr driver = dom->conn->privateData;
@@ -18259,6 +18302,7 @@ static virDriver qemuDriver = {
 .nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
 .connectGetDomainCapabilities = qemuConnectGetDomainCapabilities, /* 1.2.7 
*/
 .connectGetAllDomainStats = qemuConnectGetAllDomainStats, /* 1.2.8 */
+.domainMigrateStartPostCopy = qemuMigrateStartPostCopy, /* 1.2.9 */
 };
 
 
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 14688bf..0b230cc 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2384,6 +2384,25 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
 return ret;
 }
 
+int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon)
+{
+int ret;
+VIR_DEBUG("mon=%p", mon);
+
+if (!mon) {
+virReportError(VIR_ERR_INVALID_ARG, "%s",
+   _("monitor must not be NULL"));
+return -1;
+}
+
+if (mon->json)
+ret = qemuMonitorJSONMigrateStartPostCopy(mon);
+else
+ret = qemuMonitorTextMigrateStartPostCopy(mon);
+return ret;
+}
+
+
 int qemuMonitorMigrateCancel(qemuMonitorPtr mon)
 {
 int ret;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 587f779..97d980d 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -539,6 +539,8 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
  unsigned int flags,
  const char *unixfile);
 
+int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon);
+
 int qemuMonitorMigrateCancel(qemuMonitorPtr mon);
 
 int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e98962b..14e7f84 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2798,6 +2798,24 @@ int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
 return ret;
 }
 
+int qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon)
+{
+int ret;
+virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("migrate-start-postcopy", 
NULL);
+virJSONValuePtr reply = NULL;
+if (!cmd)
+return -1;
+
+ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+if (ret == 0)
+ret = qemuMonitorJSONCheckError(cmd, reply);
+
+virJSONValueFree(cmd);
+virJSONValueFree(reply);
+return ret;
+}
+
 int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon)
 {
 int ret;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index d366179..54beb7f 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -151,6 +151,7 @@ int qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitorPtr 
mon,
bool *spice_migrated);
 
 
+int qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon);
 int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon);
 
 int qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index a3c8aa5..1354651 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@

[libvirt] [PATCH 0/2] qemu: Fix specifying CPU model with arm on x86

2014-09-23 Thread Cole Robinson
Patch 1 is a cleanup, just code movement.
Patch 2 has the goods, details in the commit message

Cole Robinson (2):
  qemu_command: Split qemuBuildCpuArgStr
  qemu: Don't compare CPU against host for TCG

 src/qemu/qemu_command.c| 202 -
 .../qemuxml2argv-aarch64-virt-default-nic.args |   3 +-
 .../qemuxml2argv-aarch64-virt-default-nic.xml  |   3 +
 .../qemuxml2argv-aarch64-virt-virtio.args  |   3 +-
 .../qemuxml2argv-aarch64-virt-virtio.xml   |   3 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact1.args  |   2 +-
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml |   4 +-
 .../qemuxml2argv-cpu-exact2-nofallback.args|   2 +-
 .../qemuxml2argv-cpu-exact2-nofallback.xml |   4 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact2.args  |   2 +-
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml |   4 +-
 .../qemuxml2argv-cpu-fallback.args |   2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-fallback.xml |   4 +-
 .../qemuxml2argv-cpu-minimum1.args |   2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml |   4 +-
 .../qemuxml2argv-cpu-minimum2.args |   2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml |   4 +-
 .../qemuxml2argv-cpu-nofallback.xml|   2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.args |   2 +-
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml  |   4 +-
 .../qemuxml2argv-graphics-spice-timeout.args   |   2 +-
 .../qemuxml2argv-graphics-spice-timeout.xml|   4 +-
 .../qemuxml2argv-pseries-cpu-exact.args|   4 +-
 tests/qemuxml2argvtest.c   |  21 ++-
 .../qemuxml2xmlout-graphics-spice-timeout.xml  |   4 +-
 25 files changed, 166 insertions(+), 127 deletions(-)

-- 
2.1.0

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


[libvirt] [PATCH 5/6] Added domainMigrateStartPostCopy in remote driver

2014-09-23 Thread Cristian Klein
Signed-off-by: Cristian Klein 
---
 src/remote/remote_driver.c   |  1 +
 src/remote/remote_protocol.x | 12 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 75a3a7b..9a6a974 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8152,6 +8152,7 @@ static virDriver remote_driver = {
 .nodeGetFreePages = remoteNodeGetFreePages, /* 1.2.6 */
 .connectGetDomainCapabilities = remoteConnectGetDomainCapabilities, /* 
1.2.7 */
 .connectGetAllDomainStats = remoteConnectGetAllDomainStats, /* 1.2.8 */
+.domainMigrateStartPostCopy = remoteDomainMigrateStartPostCopy, /* 1.2.9 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index a4ca0c3..c443636 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -3090,6 +3090,10 @@ struct remote_connect_get_all_domain_stats_args {
 struct remote_connect_get_all_domain_stats_ret {
 remote_domain_stats_record retStats;
 };
+
+struct remote_domain_migrate_start_post_copy_args {
+remote_nonnull_domain dom;
+};
 /*- Protocol. -*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -5472,5 +5476,11 @@ enum remote_procedure {
  * @generate: both
  * @acl: domain:block_write
  */
-REMOTE_PROC_DOMAIN_BLOCK_COPY = 345
+REMOTE_PROC_DOMAIN_BLOCK_COPY = 345,
+
+/**
+ * @generate: both
+ * @acl: domain:migrate
+ */
+REMOTE_PROC_DOMAIN_MIGRATE_START_POST_COPY = 346
 };
-- 
1.9.1

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


[libvirt] [PATCH 2/6] Added public API to enable post-copy migration

2014-09-23 Thread Cristian Klein
Added a new `libvirt` migration flag `VIR_MIGRATE_POSTCOPY` and the
necessary code to pass this flag to qemu as migration capability.

Signed-off-by: Cristian Klein 
---
 include/libvirt/libvirt.h.in |  1 +
 src/libvirt.c|  7 +++
 src/qemu/qemu_migration.c| 43 +++
 src/qemu/qemu_migration.h|  3 ++-
 4 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 6371b7b..bdc33c6 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1225,6 +1225,7 @@ typedef enum {
 VIR_MIGRATE_ABORT_ON_ERROR= (1 << 12), /* abort migration on I/O 
errors happened during migration */
 VIR_MIGRATE_AUTO_CONVERGE = (1 << 13), /* force convergence */
 VIR_MIGRATE_RDMA_PIN_ALL  = (1 << 14), /* RDMA memory pinning */
+VIR_MIGRATE_POSTCOPY  = (1 << 15), /* enable (but don't start) 
post-copy */
 } virDomainMigrateFlags;
 
 
diff --git a/src/libvirt.c b/src/libvirt.c
index 1a285ca..33aeafa 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -5265,6 +5265,7 @@ virDomainMigrateDirect(virDomainPtr domain,
  * automatically when supported).
  *   VIR_MIGRATE_UNSAFEForce migration even if it is considered unsafe.
  *   VIR_MIGRATE_OFFLINE Migrate offline
+ *   VIR_MIGRATE_POSTCOPY Enable (but don't start) post-copy
  *
  * VIR_MIGRATE_TUNNELLED requires that VIR_MIGRATE_PEER2PEER be set.
  * Applications using the VIR_MIGRATE_PEER2PEER flag will probably
@@ -5291,6 +5292,12 @@ virDomainMigrateDirect(virDomainPtr domain,
  * can use either VIR_MIGRATE_NON_SHARED_DISK or
  * VIR_MIGRATE_NON_SHARED_INC as they are mutually exclusive.
  *
+ * If you want to enable post-copy migration you must set the
+ * VIR_MIGRATE_POSTCOPY flag. Once migration is active, you may
+ * start post-copy by calling virDomainMigrateStartPostCopy.
+ * When to start post-copy is entirely left to the user, libvirt
+ * only implements the necessary mechanism.
+ *
  * In either case it is typically only necessary to specify a
  * URI if the destination host has multiple interfaces and a
  * specific interface is required to transmit migration data.
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index a5bd825..bd1f2d6 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1799,6 +1799,45 @@ qemuMigrationSetOffline(virQEMUDriverPtr driver,
 
 
 static int
+qemuMigrationSetPostCopy(virQEMUDriverPtr driver,
+virDomainObjPtr vm,
+qemuDomainAsyncJob job)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+int ret;
+
+if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
+return -1;
+
+ret = qemuMonitorGetMigrationCapability(
+priv->mon,
+QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY);
+
+if (ret < 0) {
+goto cleanup;
+} else if (ret == 0) {
+if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
+virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+   _("Post-copy migration is not supported by "
+ "target QEMU binary"));
+} else {
+virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+   _("Post-copy migration is not supported by "
+ "source QEMU binary"));
+}
+ret = -1;
+goto cleanup;
+}
+
+ret = qemuMonitorSetMigrationCapability(
+priv->mon,
+QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY);
+
+ cleanup:
+qemuDomainObjExitMonitor(driver, vm);
+return ret;
+}
+static int
 qemuMigrationSetCompression(virQEMUDriverPtr driver,
 virDomainObjPtr vm,
 qemuDomainAsyncJob job)
@@ -3580,6 +3619,10 @@ qemuMigrationRun(virQEMUDriverPtr driver,
 if (flags & VIR_MIGRATE_RDMA_PIN_ALL &&
 qemuMigrationSetPinAll(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
+
+if (flags & VIR_MIGRATE_POSTCOPY &&
+qemuMigrationSetPostCopy(driver, vm,
+ QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
 goto cleanup;
 
 if (qemuDomainObjEnterMonitorAsync(driver, vm,
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index e7a90c3..349c9c4 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -41,7 +41,8 @@
  VIR_MIGRATE_COMPRESSED |   \
  VIR_MIGRATE_ABORT_ON_ERROR |   \
  VIR_MIGRATE_AUTO_CONVERGE |\
- VIR_MIGRATE_RDMA_PIN_ALL)
+ VIR_MIGRATE_RDMA_PIN_ALL | \
+ VIR_MIGRATE_POSTCOPY)
 
 /* All supported migration parameters and their types. */
 # define QEMU_MIGRATION_PARAMETERS  \
-- 
1.9.1

--
libvir-list mailing list
libvir-list@redhat.com
https://ww

[libvirt] [PATCH 0/6] Post-copy live migration support

2014-09-23 Thread Cristian Klein
Qemu currently implements pre-copy live migration. VM memory pages are
first copied from the source hypervisor to the destination, potentially
multiple times as pages get dirtied during transfer, then VCPU state
is migrated. Unfortunately, if the VM dirties memory faster than the
network bandwidth, then pre-copy cannot finish. `virsh` currently
includes an option to suspend a VM after a timeout, so that migration
may finish, but at the expense of downtime.

A future version of qemu will implement post-copy live migration. The
VCPU state is first migrated to the destination hypervisor, then
memory pages are pulled from the source hypervisor. Post-copy has the
potential to do migration with zero-downtime, despite the VM dirtying
pages fast, with minimum performance impact. On the other hand, one
post-copy is in progress, any network failure would render the VM
unusable, as its memory is partitioned between the source and
destination hypervisor. Therefore, post-copy should only be used when
necessary.

Post-copy migration in qemu will work as follows:
(1) The `x-postcopy-ram` migration capability needs to be set.
(2) Migration is started.
(3) When the user decides so, post-copy migration is activated by
sending the `migrate-start-postcopy` command. Qemu acknowledges by
setting migration status to `postcopy-active`.

Cristian Klein (6):
  Added qemu postcopy-active migration status
  Added public API to enable post-copy migration
  Added new public API virDomainMigrateStartPostCopy
  Added domainMigrateStartPostCopy in qemu driver
  Added domainMigrateStartPostCopy in remote driver
  virsh: added migrate --postcopy-after

 include/libvirt/libvirt.h.in |  3 ++
 src/driver.h |  4 +++
 src/libvirt.c| 44 +++
 src/libvirt_public.syms  |  5 +++
 src/qemu/qemu_driver.c   | 44 +++
 src/qemu/qemu_migration.c| 44 +++
 src/qemu/qemu_migration.h|  3 +-
 src/qemu/qemu_monitor.c  | 21 -
 src/qemu/qemu_monitor.h  |  3 ++
 src/qemu/qemu_monitor_json.c | 21 -
 src/qemu/qemu_monitor_json.h |  1 +
 src/qemu/qemu_monitor_text.c | 14 -
 src/qemu/qemu_monitor_text.h |  2 ++
 src/remote/remote_driver.c   |  1 +
 src/remote/remote_protocol.x | 12 +++-
 tools/virsh-domain.c | 72 ++--
 tools/virsh.pod  |  5 +++
 17 files changed, 292 insertions(+), 7 deletions(-)

-- 
1.9.1

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


[libvirt] Running the test fails virnetmessagetest with libvirt 1.2.8

2014-09-23 Thread Stefano Ricci
Hello
I apologize in advance for my English.
I compiled the new version of libvirt 1.2.8 on an environment Development
Linux from Scratch with the following configure:

configure: Configuration summary
configure: =
configure:
configure: Drivers
configure:
configure:   Xen: no
configure:  QEMU: yes
configure:   UML: yes
configure:OpenVZ: no
configure:VMware: no
configure:  VBox: yes
configure:XenAPI: no
configure:  xenlight: no
configure:   LXC: no
configure:  PHYP: yes
configure:   ESX: no
configure:   Hyper-V: no
configure: Parallels: no
configure: Bhyve: no
configure:  Test: yes
configure:Remote: yes
configure:   Network: yes
configure:  Libvirtd: yes
configure: Interface: yes
configure:   macvtap: yes
configure:  virtport: yes
configure:
configure: Storage Drivers
configure:
configure:  Dir: yes
configure:   FS: no
configure:NetFS: no
configure:  LVM: yes
configure:iSCSI: yes
configure: SCSI: yes
configure:mpath: yes
configure: Disk: no
configure:  RBD: no
configure: Sheepdog: no
configure:  Gluster: no
configure:  ZFS: no
configure:
configure: Security Drivers
configure:
configure:  SELinux: yes (/sys/fs/selinux)
configure: AppArmor: no (install profiles: no)
configure:
configure: Driver Loadable Modules
configure:
configure:   dlopen:  -ldl
configure:
configure: Libraries
configure:
configure:   apparmor: no
configure:   attr: yes (CFLAGS='' LIBS='-lattr')
configure:  audit: no
configure:  avahi: no
configure:  blkid: yes (CFLAGS='-I/install/include/blkid
-I/install/include/uuid ' LIBS='-L/install/lib -lblkid ')
configure:  capng: no
configure:   curl: no
configure:   dbus: yes (CFLAGS='-I/usr/include/dbus-1.0
-I/usr/lib/dbus-1.0/include ' LIBS='-ldbus-1 ')
configure:   fuse: yes (CFLAGS='-D_FILE_OFFSET_BITS=64
-I/usr/include/fuse ' LIBS='-lfuse -pthread ')
configure:  glusterfs: no
configure:hal: no
configure:  netcf: no
configure:numactl: no
configure:  openwsman: no
configure:  pciaccess: yes (CFLAGS='' LIBS='-lpciaccess ')
configure:   readline: yes (CFLAGS='' LIBS='-lreadline')
configure:sanlock: no
configure:   sasl: yes (CFLAGS='' LIBS='-lsasl2')
configure:selinux: yes (CFLAGS='' LIBS='-lselinux')
configure:   ssh2: yes (CFLAGS='' LIBS='-lssh2 ')
configure: systemd_daemon: no
configure:   udev: yes (CFLAGS='' LIBS='-ludev ')
configure:   yajl: yes (CFLAGS='' LIBS='-lyajl')
configure:   libxml: -I/usr/include/libxml2  -lxml2
configure:   dlopen: -ldl
configure: openwsman: no
configure:   gnutls:  -lgnutls
configure: firewalld: no
configure:   polkit: no
configure:  xen: no
configure:   xenapi: no
configure: xenlight: no
configure: pcap: -I/usr/include -L/usr/lib  -lpcap
configure:   nl: -I/usr/include/libnl3  -I/usr/include/libnl3  -lnl-3
 -lnl-route-3 -lnl-3
configure:mscom: no
configure:  xdr:
configure:  rbd: no
configure: pm-utils: yes
configure:
configure: Test suite
configure:
configure:Coverage: no
configure:   Alloc OOM: no
configure:
configure: Miscellaneous
configure:
configure: Debug: yes
configure:   Use -Werror: no
configure: Warning Flags:  -W -Waddress -Waggressive-loop-optimizations
-Wall -Warray-bounds -Wattributes -Wbad-function-cast
-Wbuiltin-macro-redefined -Wcast-align -Wchar-subscripts -Wclobbered
-Wcomment -Wcomments -Wcoverage-mismatch -Wcpp -Wdeprecated-declarations
-Wdisabled-optimization -Wdiv-by-zero -Wdouble-promotion -Wempty-body
-Wendif-labels -Wextra -Wformat-contains-nul -Wformat-extra-args
-Wformat-security -Wformat-y2k -Wformat-zero-length -Wfree-nonheap-object
-Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration
-Wimplicit-int -Winit-self -Winline -Wint-to-pointer-cast
-Winvalid-memory-model -Winvalid-pch -Wjump-misses-init -Wlogical-op -Wmain
-Wmaybe-uninitialized -Wmissing-braces -Wmissing-declarations
-Wmissing-field-initializers -Wmissing-include-dirs
-Wmissing-parameter-type -Wmissing-prototypes -Wmultichar -Wnarrowing
-Wnested-externs -Wnonnull -Wnormalized=nfc -Wold-style-declaration
-Wold-style-definition -Woverflow -Woverride-init -Wpacked-bitfield-compat
-Wparentheses -Wpointer-arith -Wpointer-sign -Wpointer-to-int-cast
-Wpragmas -Wreturn-local-addr -Wreturn-type -Wsequence-point -Wshadow
-Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-prototypes
-Wsuggest-attribute=const -Wsuggest-attribute=format
-Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wswitch -Wsync-nand
-Wtrampolines -Wtrigraphs -Wtype-limits -Wuninitialized -Wunknown-pragmas
-Wunused -Wunused-but-set-parameter -Wunused-but-set-variable
-Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-parameter
-Wunused-result -Wunused-value -Wunused-variable -Wvarargs
-Wvariadic-macros -Wvector-operation-performance -Wvolatile-register-var
-Wwrite-strings -fdiagnostics-show-option -funit-at-a-time
-Wno-sign-compare -Wjump-misses-init -W

Re: [libvirt] [PATCH 1/4] Introduce virNodeAllocPages

2014-09-23 Thread Ján Tomko
On 09/18/2014 10:24 AM, Michal Privoznik wrote:
> A long time ago in a galaxy far, far away it has been decided
> that libvirt will manage not only domains but host as well. And
> with my latest work on qemu driver supporting huge pages, we miss
> the cherry on top: an API to allocate huge pages on the run.
> Currently users are forced to log into the host and adjust the
> huge pages pool themselves.  However, with this API the problem
> is gone - they can both size up and size down the pool.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  daemon/remote.c  | 37 
>  include/libvirt/libvirt.h.in | 16 +++
>  src/driver.h | 10 +++
>  src/libvirt.c| 67 
> 
>  src/libvirt_public.syms  |  1 +
>  src/remote/remote_driver.c   | 47 +++
>  src/remote/remote_protocol.x | 20 -
>  src/remote_protocol-structs  | 17 +++
>  8 files changed, 214 insertions(+), 1 deletion(-)
> 

> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 724314e..1a47bae 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -5505,6 +5505,22 @@ int virNodeGetFreePages(virConnectPtr conn,
>  unsigned int cellcount,
>  unsigned long long *counts,
>  unsigned int flags);
> +
> +typedef enum {
> +VIR_NODE_ALLOC_PAGES_ADD = 0, /* Add @pageCounts to the pages pool. This
> + can be used only to size up the pool. */
> +VIR_NODE_ALLOC_PAGES_SET = (1 << 0), /* Don't add @pageCounts, instead 
> set
> +passed number of pages. This can 
> be
> +used to free allocated pages. */

> +} virNodeAllocPagesFlags;
> +
> +int virNodeAllocPages(virConnectPtr conn,
> +  unsigned int npages,
> +  unsigned int *pageSizes,
> +  unsigned long long *pageCounts,
> +  int startCell,
> +  unsigned int cellCount,
> +  unsigned int flags);
>  /**
>   * virSchedParameterType:
>   *
> diff --git a/src/driver.h b/src/driver.h
> index bb748c4..dc62a8e 100644
> --- a/src/driver.h
> +++ b/src/driver.h
> @@ -1212,6 +1212,15 @@ typedef int
>virDomainStatsRecordPtr **retStats,
>unsigned int flags);
>  
> +typedef int
> +(*virDrvNodeAllocPages)(virConnectPtr conn,
> +unsigned int npages,
> +unsigned int *pageSizes,
> +unsigned long long *pageCounts,
> +int startCell,
> +unsigned int cellCount,
> +unsigned int flags);
> +
>  typedef struct _virDriver virDriver;
>  typedef virDriver *virDriverPtr;
>  
> @@ -1435,6 +1444,7 @@ struct _virDriver {
>  virDrvNodeGetFreePages nodeGetFreePages;
>  virDrvConnectGetDomainCapabilities connectGetDomainCapabilities;
>  virDrvConnectGetAllDomainStats connectGetAllDomainStats;
> +virDrvNodeAllocPages nodeAllocPages;
>  };
>  
>  
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 7c63825..27445e5 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -21841,3 +21841,70 @@ virDomainStatsRecordListFree(virDomainStatsRecordPtr 
> *stats)
>  
>  VIR_FREE(stats);
>  }
> +
> +
> +/**
> + * virNodeAllocPages:
> + * @conn: pointer to the hypervisor connection
> + * @npages: number of items in the @pageSizes array
> + * @pageSizes: which huge page sizes to allocate
> + * @pageCounts: how many pages should be allocated
> + * @startCell: index of first cell to allocate pages on
> + * @cellCount: number of consecutive cells to allocate pages on
> + * @flags: extra flags; binary-OR of virConnectGetAllDomainStatsFlags

virNodeAllocPagesFlags

> + *
> + * Sometimes, when trying to start a new domain, it may be
> + * necessary to reserve some huge pages in the system pool which
> + * can be then allocated by the domain. This API serves that
> + * purpose. On its input, @pageSizes and @pageCounts are arrays
> + * of the same cardinality of @npages. The @pageSizes contains
> + * page sizes which are to be allocated in the system (the size
> + * unit is kibibytes), and @pageCounts then contains the number
> + * of pages to reserve. Depending on @flags specified, the number
> + * of pages is either added into the pool and the pool is sized
> + * up (@flags have VIR_NODE_ALLOC_PAGES_ADD set) or the number of
> + * pages is looked at the new size of pool and the pool can be
> + * both sized up or down (@flags have VIR_NODE_ALLOC_PAGES_SET
> + * set).  The pages pool can be allocated over several NUMA nodes
> + * at once, just point at @startCell and tell how many subsequent
> + * NUMA nodes shou

Re: [libvirt] [PATCH] qemu: Fix memory leak in RDMA migration code

2014-09-23 Thread Jiri Denemark
On Tue, Sep 23, 2014 at 09:35:56 -0400, John Ferlan wrote:
> 
> 
> On 09/23/2014 09:32 AM, Jiri Denemark wrote:
> > Signed-off-by: Jiri Denemark 
> > ---
> >  src/qemu/qemu_migration.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> 
> ACK

Pushed, thanks.

Jirka

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


Re: [libvirt] [PATCH] qemu: Fix memory leak in RDMA migration code

2014-09-23 Thread John Ferlan


On 09/23/2014 09:32 AM, Jiri Denemark wrote:
> Signed-off-by: Jiri Denemark 
> ---
>  src/qemu/qemu_migration.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 

ACK

John

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


[libvirt] [PATCH] qemu: Fix memory leak in RDMA migration code

2014-09-23 Thread Jiri Denemark
Signed-off-by: Jiri Denemark 
---
 src/qemu/qemu_migration.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 44cb826..6b38592 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3792,13 +3792,13 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
 virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("outgoing RDMA migration is not supported "
  "with this QEMU binary"));
-return -1;
+goto cleanup;
 }
 if (!vm->def->mem.hard_limit) {
 virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot start RDMA migration with no memory hard "
  "limit set"));
-return -1;
+goto cleanup;
 }
 }
 
@@ -3819,6 +3819,7 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
 if (spec.destType == MIGRATION_DEST_FD)
 VIR_FORCE_CLOSE(spec.dest.fd.qemu);
 
+ cleanup:
 virURIFree(uribits);
 
 return ret;
-- 
2.1.0

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


Re: [libvirt] [PATCH] LXC: emphasis uid start of idmap only accept '0' in docs

2014-09-23 Thread Michal Privoznik

On 23.09.2014 05:40, Chen Hanxiao wrote:

We don't accept any other values except '0'.

Signed-off-by: Chen Hanxiao 
---
  docs/formatdomain.html.in | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index eefdd5e..bb72452 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -315,7 +315,7 @@

  
start
-  First user ID in container.
+  First user ID in container. It must be '0'.
target
The first user ID in container will be mapped to this target user
ID in host.



This is not entirely true. Only the first id mapping must refer to root. 
And by first I mean in a sorted array of mappings. For instance:



  
  
  
  


is okay.

Michal

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


Re: [libvirt] [PATCH 1/2] numatune: add check for memnode.nodeset range

2014-09-23 Thread Michal Privoznik

On 23.09.2014 11:34, Chen Fan wrote:

For memnode in numatune element, the range of attribute 'nodeset'
was not validated. on my host maxnodes was 1, but when setting nodeset
to '0-2' or more, guest also started succuss. there probably was qemu's
bug too.

Signed-off-by: Chen Fan 
---
  src/conf/numatune_conf.c | 29 +
  src/conf/numatune_conf.h |  4 
  2 files changed, 33 insertions(+)

diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
index 21d9a64..a9b20aa 100644
--- a/src/conf/numatune_conf.c
+++ b/src/conf/numatune_conf.c
@@ -183,6 +183,9 @@ virDomainNumatuneNodeParseXML(virDomainNumatunePtr 
*numatunePtr,
 VIR_DOMAIN_CPUMASK_LEN) < 0)
  goto cleanup;
  VIR_FREE(tmp);
+
+if (!virDomainNumatuneNodeSetIsAvailable(numatune, cellid))
+goto cleanup;


Well, if there already exists such configuration within an existing 
domain, this will cause a failure on XML parsing when the daemon is 
starting and hence domain is lost.



  }

  ret = 0;
@@ -612,3 +615,29 @@ virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr 
numatune)

  return false;
  }
+
+bool
+virDomainNumatuneNodeSetIsAvailable(virDomainNumatunePtr numatune,
+int cellid)
+{
+int maxnode;
+int bit = -1;
+virBitmapPtr nodemask = NULL;
+
+nodemask = virDomainNumatuneGetNodeset(numatune, NULL, cellid);
+if (!nodemask)
+return false;
+
+if ((maxnode = virNumaGetMaxNode()) < 0)
+return false;


This will work in real environment, but won't work in tests. You need to 
mock this to get predictable max numa node.



+
+while ((bit = virBitmapNextSetBit(nodemask, bit)) >= 0) {
+if (bit > maxnode) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("NUMA node %d is out of range"), bit);
+return false;
+}
+}
+
+return true;
+}
diff --git a/src/conf/numatune_conf.h b/src/conf/numatune_conf.h
index 5254629..cab0b83 100644
--- a/src/conf/numatune_conf.h
+++ b/src/conf/numatune_conf.h
@@ -102,4 +102,8 @@ bool virDomainNumatuneHasPlacementAuto(virDomainNumatunePtr 
numatune);

  bool virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr numatune);

+extern int virNumaGetMaxNode(void);
+bool virDomainNumatuneNodeSetIsAvailable(virDomainNumatunePtr numatune,
+ int cellid);
+
  #endif /* __NUMATUNE_CONF_H__ */



Michal

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


Re: [libvirt] [PATCH 2/2] numatune: move up verification codes in virNumaSetupMemoryPolicy

2014-09-23 Thread Michal Privoznik

On 23.09.2014 11:34, Chen Fan wrote:

use virDomainNumatuneNodeSetIsAvailable() to verify momory.nodeset
whether is out of range. and move up the verification.

Signed-off-by: Chen Fan 
---
  src/conf/numatune_conf.c |  3 +++
  src/util/virnuma.c   | 15 ---
  2 files changed, 3 insertions(+), 15 deletions(-)


I'd expect a test case for this.



diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
index a9b20aa..8b43167 100644
--- a/src/conf/numatune_conf.c
+++ b/src/conf/numatune_conf.c
@@ -278,6 +278,9 @@ virDomainNumatuneParseXML(virDomainNumatunePtr *numatunePtr,
   nodeset) < 0)
  goto cleanup;

+if (!virDomainNumatuneNodeSetIsAvailable(*numatunePtr, -1))
+goto cleanup;
+
  if (virDomainNumatuneNodeParseXML(numatunePtr, ncells, ctxt) < 0)
  goto cleanup;

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 1a34398..4766f16 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -95,31 +95,16 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
  int ret = -1;
  int bit = 0;
  size_t i;
-int maxnode = 0;
  virBitmapPtr tmp_nodemask = NULL;

  tmp_nodemask = virDomainNumatuneGetNodeset(numatune, nodemask, -1);
  if (!tmp_nodemask)
  return 0;

-if (numa_available() < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   "%s", _("Host kernel is not aware of NUMA."));
-return -1;
-}
-
-maxnode = numa_max_node();
-maxnode = maxnode < NUMA_NUM_NODES ? maxnode : NUMA_NUM_NODES;
-
  /* Convert nodemask to NUMA bitmask. */
  nodemask_zero(&mask);
  bit = -1;
  while ((bit = virBitmapNextSetBit(tmp_nodemask, bit)) >= 0) {
-if (bit > maxnode) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("NUMA node %d is out of range"), bit);
-return -1;
-}
  nodemask_set(&mask, bit);
  }




Yet again, this suffers the same problem that 1/2 does: domain may be lost.

Michal

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


[libvirt] [PATCH v3 5/7] qemu: Add bps_max and friends "text" support

2014-09-23 Thread Matthias Gatto
Detect if the the qemu binary currently in use suport the bps_max option and 
thy firends,
If yes add it to the command, if not, just ignore the options.

Signed-off-by: Matthias Gatto 
---
 src/qemu/qemu_monitor_text.c | 76 
 1 file changed, 69 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 2858247..ffc67d7 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -2994,13 +2994,27 @@ int qemuMonitorTextSetBlockIoThrottle(qemuMonitorPtr 
mon,
 const char *cmd_name = NULL;
 
 /* For the not specified fields, 0 by default */
-(void)supportMaxOptions;
 cmd_name = "block_set_io_throttle";
-if (virAsprintf(&cmd, "%s %s %llu %llu %llu %llu %llu %llu", cmd_name,
-device, info->total_bytes_sec, info->read_bytes_sec,
-info->write_bytes_sec, info->total_iops_sec,
-info->read_iops_sec, info->write_iops_sec) < 0)
-goto cleanup;
+if (supportMaxOptions)
+{
+if (virAsprintf(&cmd, "%s %s %llu %llu %llu %llu %llu %llu %llu %llu 
%llu %llu %llu %llu %llu", cmd_name,
+device, info->total_bytes_sec, info->read_bytes_sec,
+info->write_bytes_sec, info->total_iops_sec,
+info->read_iops_sec, info->write_iops_sec,
+info->total_bytes_sec_max, info->read_bytes_sec_max,
+info->write_bytes_sec_max, info->total_iops_sec_max,
+info->read_iops_sec_max, info->write_iops_sec_max,
+info->size_iops_sec) < 0)
+goto cleanup;
+}
+else
+{
+if (virAsprintf(&cmd, "%s %s %llu %llu %llu %llu %llu %llu", cmd_name,
+device, info->total_bytes_sec, info->read_bytes_sec,
+info->write_bytes_sec, info->total_iops_sec,
+info->read_iops_sec, info->write_iops_sec) < 0)
+goto cleanup;
+}
 
 if (qemuMonitorHMPCommand(mon, cmd, &result) < 0)
 goto cleanup;
@@ -3028,6 +3042,7 @@ qemuMonitorTextParseBlockIoThrottle(const char *result,
 int ret = -1;
 const char *p, *eol;
 int devnamelen = strlen(device);
+bool checkBlockInfo;
 
 (void)supportMaxOptions;
 p = result;
@@ -3043,31 +3058,78 @@ qemuMonitorTextParseBlockIoThrottle(const char *result,
 p += devnamelen + 2; /* Skip to first label. */
 
 while (*p) {
+checkBlockInfo = false;
 if (STRPREFIX(p, "bps=")) {
 p += strlen("bps=");
+checkBlockInfo = true;
 if (virStrToLong_ull(p, &dummy, 10, 
&reply->total_bytes_sec) == -1)
 VIR_DEBUG("error reading total_bytes_sec: %s", p);
 } else if (STRPREFIX(p, "bps_rd=")) {
+checkBlockInfo = true;
 p += strlen("bps_rd=");
 if (virStrToLong_ull(p, &dummy, 10, 
&reply->read_bytes_sec)  == -1)
 VIR_DEBUG("error reading read_bytes_sec: %s", p);
 } else if (STRPREFIX(p, "bps_wr=")) {
+checkBlockInfo = true;
 p += strlen("bps_wr=");
 if (virStrToLong_ull(p, &dummy, 10, 
&reply->write_bytes_sec) == -1)
 VIR_DEBUG("error reading write_bytes_sec: %s", p);
 } else if (STRPREFIX(p, "iops=")) {
+checkBlockInfo = true;
 p += strlen("iops=");
 if (virStrToLong_ull(p, &dummy, 10, 
&reply->total_iops_sec) == -1)
 VIR_DEBUG("error reading total_iops_sec: %s", p);
 } else if (STRPREFIX(p, "iops_rd=")) {
+checkBlockInfo = true;
 p += strlen("iops_rd=");
 if (virStrToLong_ull(p, &dummy, 10, &reply->read_iops_sec) 
== -1)
 VIR_DEBUG("error reading read_iops_sec: %s", p);
 } else if (STRPREFIX(p, "iops_wr=")) {
+checkBlockInfo = true;
 p += strlen("iops_wr=");
 if (virStrToLong_ull(p, &dummy, 10, 
&reply->write_iops_sec) == -1)
 VIR_DEBUG("error reading write_iops_sec: %s", p);
-} else {
+}
+if (supportMaxOptions)
+{
+if (STRPREFIX(p, "bps_max=")) {
+checkBlockInfo = true;
+p += strlen("bps_max=");
+if (virStrToLong_ull(p, &dummy, 10, 
&reply->total_bytes_sec_max)  == -1)
+VIR_DEBUG("error reading total_bytes_sec_max: %s", 
p);
+} else if (STRPREFIX(p, "bps_wr_max=")) {
+checkBlockInfo = true;
+  

[libvirt] [PATCH v3 7/7] virsh: Add bps_max and friends to virsh

2014-09-23 Thread Matthias Gatto
Add the new throttle options to virsh, and send them to libvirt.

Signed-off-by: Matthias Gatto 
---
 tools/virsh-domain.c | 119 +++
 tools/virsh.pod  |  11 -
 2 files changed, 129 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f7193cb..cf7884f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1082,6 +1082,62 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
  .type = VSH_OT_INT,
  .help = N_("write I/O operations limit per second")
 },
+{.name = "total_bytes_sec_max",
+ .type = VSH_OT_ALIAS,
+ .help = "total-bytes-sec-max"
+},
+{.name = "total-bytes-sec-max",
+ .type = VSH_OT_INT,
+ .help = N_("total max in bytes")
+},
+{.name = "read_bytes_sec_max",
+ .type = VSH_OT_ALIAS,
+ .help = "read-bytes-sec-max"
+},
+{.name = "read-bytes-sec-max",
+ .type = VSH_OT_INT,
+ .help = N_("read max in bytes")
+},
+{.name = "write_bytes_sec_max",
+ .type = VSH_OT_ALIAS,
+ .help = "write-bytes-sec-max"
+},
+{.name = "write-bytes-sec-max",
+ .type = VSH_OT_INT,
+ .help = N_("write max in bytes")
+},
+{.name = "total_iops_sec_max",
+ .type = VSH_OT_ALIAS,
+ .help = "total-iops-sec-max"
+},
+{.name = "total-iops-sec-max",
+ .type = VSH_OT_INT,
+ .help = N_("total I/O operations max")
+},
+{.name = "read_iops_sec_max",
+ .type = VSH_OT_ALIAS,
+ .help = "read-iops-sec-max"
+},
+{.name = "read-iops-sec-max",
+ .type = VSH_OT_INT,
+ .help = N_("read I/O operations max")
+},
+{.name = "write_iops_sec_max",
+ .type = VSH_OT_ALIAS,
+ .help = "write-iops-sec-max"
+},
+{.name = "write-iops-sec-max",
+ .type = VSH_OT_INT,
+ .help = N_("write I/O operations max")
+},
+{.name = "size_iops_sec",
+ .type = VSH_OT_ALIAS,
+ .help = "size-iops-sec"
+},
+{.name = "size-iops-sec",
+ .type = VSH_OT_INT,
+ .help = N_("I/O size in bytes")
+},
 {.name = "config",
  .type = VSH_OT_BOOL,
  .help = N_("affect next boot")
@@ -1155,6 +1211,33 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
 goto save_error;
 }
 
+if ((rv = vshCommandOptULongLong(cmd, "total-bytes-sec-max", &value)) < 0) 
{
+goto interror;
+} else if (rv > 0) {
+if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams,
+
VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX,
+value) < 0)
+goto save_error;
+}
+
+if ((rv = vshCommandOptULongLong(cmd, "read-bytes-sec-max", &value)) < 0) {
+goto interror;
+} else if (rv > 0) {
+if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams,
+VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX,
+value) < 0)
+goto save_error;
+}
+
+if ((rv = vshCommandOptULongLong(cmd, "write-bytes-sec-max", &value)) < 0) 
{
+goto interror;
+} else if (rv > 0) {
+if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams,
+
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX,
+value) < 0)
+goto save_error;
+}
+
 if ((rv = vshCommandOptULongLong(cmd, "total-iops-sec", &value)) < 0) {
 goto interror;
 } else if (rv > 0) {
@@ -1182,6 +1265,42 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
 goto save_error;
 }
 
+if ((rv = vshCommandOptULongLong(cmd, "write-iops-sec-max", &value)) < 0) {
+goto interror;
+} else if (rv > 0) {
+if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams,
+VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX,
+value) < 0)
+goto save_error;
+}
+
+if ((rv = vshCommandOptULongLong(cmd, "read-iops-sec-max", &value)) < 0) {
+goto interror;
+} else if (rv > 0) {
+if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams,
+VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX,
+value) < 0)
+goto save_error;
+}
+
+if ((rv = vshCommandOptULongLong(cmd, "total-iops-sec-max", &value)) < 0) {
+goto interror;
+} else if (rv > 0) {
+if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams,
+VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX,
+value) < 0)
+goto save_error;
+}
+
+if ((rv = vshCommandOptULongLong(cmd, "size-iops-sec", &value)) < 0) {
+goto interror;
+} else if (rv > 0) {
+if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams,
+VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC,
+   

[libvirt] [PATCH v3 1/7] qemu: Add defines for the news throttle options and modify the structure _virDomainBlockIoTuneInfo.

2014-09-23 Thread Matthias Gatto
Add defines for the news options total_bytes_sec_max, write_bytes_sec_max, 
read_bytes_sec_max
total_iops_sec_max, write_iops_sec_max, read_iops_sec_max, size_iops_sec.

Modify the structure _virDomainBlockIoTuneInfo to support these options.

Change the initialization of the variable expectedInfo in qemumonitorjsontest.c
to avoid compiling problem.

Allow libvirt to save the configuration.

Signed-off-by: Matthias Gatto 
---
 include/libvirt/libvirt.h.in | 54 +++
 src/conf/domain_conf.c   | 89 +++-
 src/conf/domain_conf.h   |  7 
 tests/qemumonitorjsontest.c  |  2 +-
 4 files changed, 150 insertions(+), 2 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index ad6785f..4094103 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2668,6 +2668,60 @@ int virDomainBlockCommit(virDomainPtr dom, const char 
*disk, const char *base,
  */
 #define VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC "write_iops_sec"
 
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum total
+ * bytes per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX "total_bytes_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum read
+ * bytes per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX "read_bytes_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum write
+ * bytes per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX "write_bytes_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum
+ * I/O operations per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX "total_iops_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum read
+ * I/O operations per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX "read_iops_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX:
+ * Macro for the BlockIoTune tunable weight: it represents the maximum write
+ * I/O operations per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX "write_iops_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC:
+ * Macro for the BlockIoTune tunable weight: it represents the size
+ * I/O operations per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC "size_iops_sec"
+
 int
 virDomainSetBlockIoTune(virDomainPtr dom,
 const char *disk,
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c7016f3..57b9e7f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5680,6 +5680,49 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
 def->blkdeviotune.write_iops_sec = 0;
 }
 
+if (virXPathULongLong("string(./iotune/total_bytes_sec_max)",
+  ctxt,
+  &def->blkdeviotune.total_bytes_sec_max) 
< 0) {
+def->blkdeviotune.total_bytes_sec_max = 0;
+}
+
+if (virXPathULongLong("string(./iotune/read_bytes_sec_max)",
+  ctxt,
+  &def->blkdeviotune.read_bytes_sec_max) < 
0) {
+def->blkdeviotune.read_bytes_sec_max = 0;
+}
+
+if (virXPathULongLong("string(./iotune/write_bytes_sec_max)",
+  ctxt,
+  &def->blkdeviotune.write_bytes_sec_max) 
< 0) {
+def->blkdeviotune.write_bytes_sec_max = 0;
+}
+
+if (virXPathULongLong("string(./iotune/total_iops_sec_max)",
+  ctxt,
+  &def->blkdeviotune.total_iops_sec_max) < 
0) {
+def->blkdeviotune.total_iops_sec_max = 0;
+}
+
+if (virXPathULongLong("string(./iotune/read_iops_sec_max)",
+  ctxt,
+  &def->blkdeviotune.read_iops_sec_max) < 
0) {
+def->blkdeviotune.read_iops_sec_max = 0;
+}
+
+if (virXPathULongLong("string(./iotune/write_iops_sec_max)",
+  

[libvirt] [PATCH v3 6/7] qemu: add bps_max and friends to qemu command generation

2014-09-23 Thread Matthias Gatto
Check the arability of the options with the current qemu binary, add them in 
the varable opt if yes,
print a message if not.

Signed-off-by: Matthias Gatto 
---
 src/qemu/qemu_command.c | 49 +
 1 file changed, 49 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8a69976..9e84e98 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3598,6 +3598,55 @@ qemuBuildDriveStr(virConnectPtr conn,
   disk->blkdeviotune.write_iops_sec);
 }
 
+/* block I/O throttling 1.7 */
+if ((disk->blkdeviotune.total_bytes_sec_max ||
+ disk->blkdeviotune.read_bytes_sec_max ||
+ disk->blkdeviotune.write_bytes_sec_max ||
+ disk->blkdeviotune.total_iops_sec_max ||
+ disk->blkdeviotune.read_iops_sec_max ||
+ disk->blkdeviotune.write_iops_sec_max) &&
+!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("there is some block I/O throttling paramater that 
are not supported with this "
+ "QEMU binary(need QEMU 1.7 or superior)"));
+goto error;
+}
+
+if (disk->blkdeviotune.total_bytes_sec_max) {
+virBufferAsprintf(&opt, ",bps_max=%llu",
+  disk->blkdeviotune.total_bytes_sec_max);
+}
+
+if (disk->blkdeviotune.read_bytes_sec_max) {
+virBufferAsprintf(&opt, ",bps_rd_max=%llu",
+  disk->blkdeviotune.read_bytes_sec_max);
+}
+
+if (disk->blkdeviotune.write_bytes_sec_max) {
+virBufferAsprintf(&opt, ",bps_wr_max=%llu",
+  disk->blkdeviotune.write_bytes_sec_max);
+}
+
+if (disk->blkdeviotune.total_iops_sec_max) {
+virBufferAsprintf(&opt, ",iops_max=%llu",
+  disk->blkdeviotune.total_iops_sec_max);
+}
+
+if (disk->blkdeviotune.read_iops_sec_max) {
+virBufferAsprintf(&opt, ",iops_rd_max=%llu",
+  disk->blkdeviotune.read_iops_sec_max);
+}
+
+if (disk->blkdeviotune.write_iops_sec_max) {
+virBufferAsprintf(&opt, ",iops_wr_max=%llu",
+  disk->blkdeviotune.write_iops_sec_max);
+}
+
+if (disk->blkdeviotune.write_iops_sec_max) {
+virBufferAsprintf(&opt, ",iops_size=%llu",
+  disk->blkdeviotune.size_iops_sec);
+}
+
 if (virBufferCheckError(&opt) < 0)
 goto error;
 
-- 
1.8.3.1

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


[libvirt] [PATCH v3 3/7] qemu: Add bps_max and friends qemu driver

2014-09-23 Thread Matthias Gatto
Add support for bps_max and friends in the driver part.
In the part checking if a qemu is running, check if the running binary support 
bps_max,
if not print an error message, if yes add it to "info" variable

Signed-off-by: Matthias Gatto 
---
 src/qemu/qemu_driver.c   | 162 ---
 src/qemu/qemu_monitor.c  |  14 ++--
 src/qemu/qemu_monitor.h  |   6 +-
 src/qemu/qemu_monitor_json.c |  13 ++--
 src/qemu/qemu_monitor_json.h |   6 +-
 src/qemu/qemu_monitor_text.c |  15 ++--
 src/qemu/qemu_monitor_text.h |   6 +-
 tests/qemumonitorjsontest.c  |   4 +-
 8 files changed, 195 insertions(+), 31 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2c3f179..cc4fc69 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -104,6 +104,7 @@ VIR_LOG_INIT("qemu.qemu_driver");
 #define QEMU_NB_MEM_PARAM  3
 
 #define QEMU_NB_BLOCK_IO_TUNE_PARAM  6
+#define QEMU_NB_BLOCK_IO_TUNE_PARAM_MAX  13
 
 #define QEMU_NB_NUMA_PARAM 2
 
@@ -15818,6 +15819,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
 int idx = -1;
 bool set_bytes = false;
 bool set_iops = false;
+bool set_bytes_max = false;
+bool set_iops_max = false;
+bool set_size_iops = false;
 virQEMUDriverConfigPtr cfg = NULL;
 virCapsPtr caps = NULL;
 
@@ -15836,6 +15840,20 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
VIR_TYPED_PARAM_ULLONG,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC,
VIR_TYPED_PARAM_ULLONG,
+   VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX,
+   VIR_TYPED_PARAM_ULLONG,
+   VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX,
+   VIR_TYPED_PARAM_ULLONG,
+   VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX,
+   VIR_TYPED_PARAM_ULLONG,
+   VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX,
+   VIR_TYPED_PARAM_ULLONG,
+   VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX,
+   VIR_TYPED_PARAM_ULLONG,
+   VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX,
+   VIR_TYPED_PARAM_ULLONG,
+   VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC,
+   VIR_TYPED_PARAM_ULLONG,
NULL) < 0)
 return -1;
 
@@ -15902,6 +15920,34 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
  VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC)) {
 info.write_iops_sec = param->value.ul;
 set_iops = true;
+} else if (STREQ(param->field,
+ VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX)) {
+info.total_bytes_sec_max = param->value.ul;
+set_bytes_max = true;
+} else if (STREQ(param->field,
+ VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX)) {
+info.read_bytes_sec_max = param->value.ul;
+set_bytes_max = true;
+} else if (STREQ(param->field,
+ VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX)) {
+info.write_bytes_sec_max = param->value.ul;
+set_bytes_max = true;
+} else if (STREQ(param->field,
+ VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX)) {
+info.total_iops_sec_max = param->value.ul;
+set_iops_max = true;
+} else if (STREQ(param->field,
+ VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX)) {
+info.read_iops_sec_max = param->value.ul;
+set_iops_max = true;
+} else if (STREQ(param->field,
+ VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX)) {
+info.write_iops_sec_max = param->value.ul;
+set_iops_max = true;
+} else if (STREQ(param->field,
+ VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC)) {
+info.size_iops_sec = param->value.ul;
+set_size_iops = true;
 }
 }
 
@@ -15919,11 +15965,32 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
 goto endjob;
 }
 
+if ((info.total_bytes_sec_max && info.read_bytes_sec_max) ||
+(info.total_bytes_sec_max && info.write_bytes_sec_max)) {
+virReportError(VIR_ERR_INVALID_ARG, "%s",
+   _("total and read/write of bytes_sec_max cannot be set 
at the same time"));
+goto endjob;
+}
+
+if ((info.total_iops_sec_max && info.read_iops_sec_max) ||
+(info.total_iops_sec_max && info.write_iops_sec_max)) {
+virReportError(VIR_ERR_INVALID_ARG, "%s",
+   _("total and read/write of iops_sec_max cannot be set 
at the same time"));
+goto endjob;
+}
+
 if (flags & VIR_DOMAIN_AFFECT_LIVE) {
 if 

[libvirt] [PATCH v3 0/7] qemu: Introduce support for new the block_set_io_throttle parameters add in the version 1.7 of qemu.

2014-09-23 Thread Matthias Gatto
This series of patches add support for bps_max, bps_rd_max, bps_wr_max, 
bps_max, bps_rd_max, bps_wr_max, and iops_size in the functions 
qemuDomainSetBlockIoTune and qemuDomainGetBlockIoTune.
The last patch add support for these parameters to the virsh blkdeviotune 
command.

v2: spellfix

v3: Merge patch 1/9,2/9,5/9 together.
Change the capability detection.(patch 2/7 and 3/7).
Try to make the usage of QEMU_NB_BLOCK_IO_TUNE_PARAM_MAX more 
explicit(patch 3/7).

Matthias Gatto (7):
  qemu: Add defines for the news throttle options and modify the
structure _virDomainBlockIoTuneInfo.
  qemu: Add the capability to detect if the qemu binary have the
capability to use bps_max and friends
  qemu: Add bps_max and friends qemu driver
  qemu: Add bps_max and friends QMP suport
  qemu: Add bps_max and friends "text" support
  qemu: add bps_max and friends to qemu command generation
  virsh: Add bps_max and friends to virsh

 include/libvirt/libvirt.h.in |  54 +++
 src/conf/domain_conf.c   |  89 +++-
 src/conf/domain_conf.h   |   7 ++
 src/qemu/qemu_capabilities.c |   4 ++
 src/qemu/qemu_capabilities.h |   1 +
 src/qemu/qemu_command.c  |  49 +
 src/qemu/qemu_driver.c   | 162 ---
 src/qemu/qemu_monitor.c  |  14 ++--
 src/qemu/qemu_monitor.h  |   6 +-
 src/qemu/qemu_monitor_json.c |  70 +++
 src/qemu/qemu_monitor_json.h |   6 +-
 src/qemu/qemu_monitor_text.c |  89 +---
 src/qemu/qemu_monitor_text.h |   6 +-
 tests/qemumonitorjsontest.c  |   6 +-
 tools/virsh-domain.c | 119 +++
 tools/virsh.pod  |  11 ++-
 16 files changed, 643 insertions(+), 50 deletions(-)

-- 
1.8.3.1

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


[libvirt] [PATCH v3 2/7] qemu: Add the capability to detect if the qemu binary have the capability to use bps_max and friends

2014-09-23 Thread Matthias Gatto
Add a value in the enum virQEMUCapsFlags for the qemu capability.
Set it with virQEMUCapsSet if the binary suport bps_max and they friends.

Signed-off-by: Matthias Gatto 
---
 src/qemu/qemu_capabilities.c | 4 
 src/qemu/qemu_capabilities.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 360cc67..17a168d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -265,6 +265,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   "numa",
   "memory-backend-file",
   "usb-audio",
+  "drive-iotune-max",
 );
 
 
@@ -1063,6 +1064,8 @@ virQEMUCapsComputeCmdFlags(const char *help,
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_COPY_ON_READ);
 if (strstr(help, "bps="))
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE);
+if (strstr(help, "bps_max="))
+virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX);
 }
 if ((p = strstr(help, "-vga")) && !strstr(help, "-std-vga")) {
 const char *nl = strstr(p, "\n");
@@ -2432,6 +2435,7 @@ static struct virQEMUCapsCommandLineProps 
virQEMUCapsCommandLine[] = {
 { "spice", "disable-agent-file-xfer", QEMU_CAPS_SPICE_FILE_XFER_DISABLE },
 { "msg", "timestamp", QEMU_CAPS_MSG_TIMESTAMP },
 { "numa", NULL, QEMU_CAPS_NUMA },
+{ "drive", "throttling.bps-total-max", QEMU_CAPS_DRIVE_IOTUNE_MAX},
 };
 
 static int
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 2911759..394a836 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -213,6 +213,7 @@ typedef enum {
 QEMU_CAPS_NUMA   = 171, /* newer -numa handling with disjoint 
cpu ranges */
 QEMU_CAPS_OBJECT_MEMORY_FILE = 172, /* -object memory-backend-file */
 QEMU_CAPS_OBJECT_USB_AUDIO   = 173, /* usb-audio device support */
+QEMU_CAPS_DRIVE_IOTUNE_MAX   = 174, /* -drive bps_max= and friends */
 
 QEMU_CAPS_LAST,   /* this must always be the last item */
 } virQEMUCapsFlags;
-- 
1.8.3.1

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


[libvirt] [PATCH v3 4/7] qemu: Add bps_max and friends QMP suport

2014-09-23 Thread Matthias Gatto
Detect if the the qemu binary currently in use suport the bps_max option,
If yes add it to the command, if not, just ignore the options.

Signed-off-by: Matthias Gatto 
---
 src/qemu/qemu_monitor_json.c | 59 +++-
 1 file changed, 48 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index c2e6c5c..8bd506f 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3924,6 +3924,12 @@ int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon,
 }
 
 
+#define GET_THROTTLE_STATS_OPTIONAL(FIELD, STORE) \
+if (virJSONValueObjectGetNumberUlong(inserted,\
+ FIELD,   \
+ &reply->STORE) < 0) {\
+reply->STORE = 0; \
+}
 #define GET_THROTTLE_STATS(FIELD, STORE)  \
 if (virJSONValueObjectGetNumberUlong(inserted,\
  FIELD,   \
@@ -3991,7 +3997,16 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr 
result,
 GET_THROTTLE_STATS("iops", total_iops_sec);
 GET_THROTTLE_STATS("iops_rd", read_iops_sec);
 GET_THROTTLE_STATS("iops_wr", write_iops_sec);
-
+if (supportMaxOptions)
+{
+GET_THROTTLE_STATS_OPTIONAL("bps_max", total_bytes_sec_max);
+GET_THROTTLE_STATS_OPTIONAL("bps_rd_max", read_bytes_sec_max);
+GET_THROTTLE_STATS_OPTIONAL("bps_wr_max", write_bytes_sec_max);
+GET_THROTTLE_STATS_OPTIONAL("iops_max", total_iops_sec_max);
+GET_THROTTLE_STATS_OPTIONAL("iops_rd_max", read_iops_sec_max);
+GET_THROTTLE_STATS_OPTIONAL("iops_wr_max", write_iops_sec_max);
+GET_THROTTLE_STATS_OPTIONAL("iops_size", size_iops_sec);
+}
 break;
 }
 
@@ -4007,6 +4022,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result,
 return ret;
 }
 #undef GET_THROTTLE_STATS
+#undef GET_THROTTLE_STATS_OPTIONAL
 
 int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
   const char *device,
@@ -4017,16 +4033,37 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr 
mon,
 virJSONValuePtr cmd = NULL;
 virJSONValuePtr result = NULL;
 
-(void)supportMaxOptions;
-cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle",
- "s:device", device,
- "U:bps", info->total_bytes_sec,
- "U:bps_rd", info->read_bytes_sec,
- "U:bps_wr", info->write_bytes_sec,
- "U:iops", info->total_iops_sec,
- "U:iops_rd", info->read_iops_sec,
- "U:iops_wr", info->write_iops_sec,
- NULL);
+if (supportMaxOptions)
+{
+cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle",
+ "s:device", device,
+ "U:bps", info->total_bytes_sec,
+ "U:bps_rd", info->read_bytes_sec,
+ "U:bps_wr", info->write_bytes_sec,
+ "U:iops", info->total_iops_sec,
+ "U:iops_rd", info->read_iops_sec,
+ "U:iops_wr", info->write_iops_sec,
+ "U:bps_max", 
info->total_bytes_sec_max,
+ "U:bps_rd_max", 
info->read_bytes_sec_max,
+ "U:bps_wr_max", 
info->write_bytes_sec_max,
+ "U:iops_max", 
info->total_iops_sec_max,
+ "U:iops_rd_max", 
info->read_iops_sec_max,
+ "U:iops_wr_max", 
info->write_iops_sec_max,
+ "U:iops_size", info->size_iops_sec,
+ NULL);
+}
+else
+{
+cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle",
+ "s:device", device,
+ "U:bps", info->total_bytes_sec,
+ "U:bps_rd", info->read_bytes_sec,
+ "U:bps_wr", info->write_bytes_sec,
+ "U:iops", info->total_iops_sec,
+ "U:iops_rd", info->read_iops_sec,
+ "U:iops_wr", info->write_iops_sec,
+   

Re: [libvirt] [PATCH 1/1] lxc: allow fallback to no apparmor.

2014-09-23 Thread Michal Privoznik

On 19.09.2014 18:14, Serge Hallyn wrote:

The security_driver line in /etc/libvirt/qemu.conf is best-effort - if
selinux is not available on the host, then 'none' will be used.

The security_driver line in /etc/libvirt/lxc.conf doesn't behave the
same way - if apparmor is specified but policies are not available
on the host, then container creation fails.

This patch always tries to fall back to 'none' if the requested
driver is not available.  A better patch would allow an option list
like qemu.conf allows, but this patch doesn't do that.

Signed-off-by: Serge Hallyn 
---
  src/lxc/lxc_driver.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c3cd62c..233e558 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1541,6 +1541,11 @@ lxcSecurityInit(virLXCDriverConfigPtr cfg)

cfg->securityDefaultConfined,

cfg->securityRequireConfined);
  if (!mgr)
+mgr = virSecurityManagerNew(NULL, LXC_DRIVER_NAME, false,
+  
cfg->securityDefaultConfined,
+  
cfg->securityRequireConfined);
+
+if (!mgr)
  goto error;

  return mgr;



IIUC the code, the new sec manager is created from 
cfg->securityDriverName which has no default value. It contains only 
what user specified in lxc.conf. Well, if user sets apparmor there but 
it's not available for whatever reason, we must fail and not workaround it.


Michal

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


Re: [libvirt] [PATCH] conf: sanitize tap and vhost paths

2014-09-23 Thread Michal Privoznik

On 22.09.2014 16:34, Martin Kletzander wrote:

Signed-off-by: Martin Kletzander 
---
  src/conf/domain_conf.c | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bb4a4cb..9cc118c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7065,8 +7065,15 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
  if (virNetDevVlanParse(cur, ctxt, &def->vlan) < 0)
  goto error;
  } else if (xmlStrEqual(cur->name, BAD_CAST "backend")) {
-def->backend.tap = virXMLPropString(cur, "tap");
-def->backend.vhost = virXMLPropString(cur, "vhost");
+char *tmp = NULL;
+
+if ((tmp = virXMLPropString(cur, "tap")))
+def->backend.tap = virFileSanitizePath(tmp);
+VIR_FREE(tmp);
+
+if ((tmp = virXMLPropString(cur, "vhost")))
+def->backend.vhost = virFileSanitizePath(tmp);
+VIR_FREE(tmp);
  }
  }
  cur = cur->next;



ACK. Although I've identified more places that need fixing, e.g. rom in 
virDomainDeviceInfoParseXML(). But that's not a show stopper for this one.


Michal

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


Re: [libvirt] [PATCH] qemuBuildNumaArgStr: Discard def->cpu check

2014-09-23 Thread John Ferlan


On 09/23/2014 07:12 AM, Michal Privoznik wrote:
> In the function at one place we check if def->cpu is NULL prior
> to accessing def->cpu->ncells. Then, later in the code,
> def->cpu->ncells is accessed directly, without the check. This
> makes coverity unhappy, because the first check makes it think
> def->cpu can be NULL. However, the function is not called if
> def->cpu is NULL. Therefore, remove the first check and hopefully
> make coverity cheer again.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  src/qemu/qemu_command.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

It did... ACK

Tks -

John

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


Re: [libvirt] [PATCH v4 2/4] event: introduce new event for tunable values

2014-09-23 Thread John Ferlan


On 09/23/2014 05:13 AM, Pavel Hrdina wrote:
> On 09/22/2014 05:50 PM, John Ferlan wrote:
>>
>>
>> On 09/18/2014 04:39 AM, Pavel Hrdina wrote:
>>> This new event will use typedParameters to expose what has been actually
>>> updated and the reason is that we can in the future extend any tunable
>>> values or add new tunable values. With typedParameters we don't have to
>>> worry about creating some other events, we will just use this universal
>>> event to inform user about updates.
>>>
>>> Signed-off-by: Pavel Hrdina 
>>> ---
>>>   daemon/remote.c  | 45 +
>>>   include/libvirt/libvirt.h.in | 22 +++
>>>   src/conf/domain_event.c  | 93 
>>> 
>>>   src/conf/domain_event.h  |  9 +
>>>   src/libvirt_private.syms |  2 +
>>>   src/remote/remote_driver.c   | 42 
>>>   src/remote/remote_protocol.x | 14 ++-
>>>   src/remote_protocol-structs  |  9 +
>>>   tools/virsh-domain.c | 33 
>>>   9 files changed, 268 insertions(+), 1 deletion(-)
>>>
>>
>> Seems you covered previous code review comments just fine, although I
>> have a couple of questions
>>
>> #1. Is virsh-domain.c relative here or perhaps later?  Or should the
>> verb/action be changed from "cpu-tune" to something more generic?
>> "tunable"?
>>
> 
> That should be definitely changed to "tunable". Thanks for catching it.
> 
>> #2. Should the REMOTE_CPUMAPS_MAX be replaced by something more name
>> (and size) relative to these events?  And secondarily, since event max
>> params is relevant to the size of the params buffer allocated for each
>> event series shouldn't that be passed along and eventually used as the
>> limit for the remoteDeserializeTypedParameters?  Although I'm not quite
>> clear/sure how that works with the protocol definition file.
>>
> 
> And this one is also wrong and should definitely be 
> REMOTE_DOMAIN_EVENT_TUNABLE_MAX and that means create a new const. About 
> the size of the rpc message I should extend the size as in the future 
> there could be some tunable staff that will require more memory than the 
> cputune event.
> 
> Currently maximal size of any rpc message is 16MiB and I think that 8MiB 
> should by more than enough limit for the tunable event, what do you think?

The "right size" is always a bit tough to judge on these generic events.
I'm fine with the 8MiB value - just seems large though.  I see why
cpumaps max is large since it's a text mapping of the 'arbitrary' number
of cpus (on different archs)... Given the recent add of the all domain
stats, my mind went to how much more data than that could be necessary,
but in this case I guess substance also matters.

John

> 
> Pavel
> 
>> I think this is ACK-able - just want to make sure of the above - #1
>> should be 'simple' right?  #2 is just one of those size things - the
>> current usage goes on a byte max, but is that relative to how this has
>> changed/evolved.
>>
>> John
>>
> 
> [...]
> 

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


[libvirt] [PATCH] qemuBuildNumaArgStr: Discard def->cpu check

2014-09-23 Thread Michal Privoznik
In the function at one place we check if def->cpu is NULL prior
to accessing def->cpu->ncells. Then, later in the code,
def->cpu->ncells is accessed directly, without the check. This
makes coverity unhappy, because the first check makes it think
def->cpu can be NULL. However, the function is not called if
def->cpu is NULL. Therefore, remove the first check and hopefully
make coverity cheer again.

Signed-off-by: Michal Privoznik 
---
 src/qemu/qemu_command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d470b1b..65864d2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6594,7 +6594,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
 continue;
 }
 
-if (def->cpu && def->cpu->ncells) {
+if (def->cpu->ncells) {
 /* Fortunately, we allow only guest NUMA nodes to be continuous
  * starting from zero. */
 pos = def->cpu->ncells - 1;
-- 
1.8.5.5

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


Re: [libvirt] [PATCH 5/6] qemu: RDMA migration support

2014-09-23 Thread John Ferlan


On 09/17/2014 10:53 AM, Jiri Denemark wrote:
> From: "Michael R. Hines" 
> 
> This patch adds support for RDMA protocol in migration URIs.
> 
> USAGE: $ virsh migrate --live --migrateuri rdma://hostname domain 
> qemu+ssh://hostname/system
> 
> Since libvirt runs QEMU in a pretty restricted environment, several
> files needs to be added to cgroup_device_acl (in qemu.conf) for QEMU to
> be able to access the host's infiniband hardware. Full documenation of
> the feature can be found on QEMU wiki:
> http://wiki.qemu.org/Features/RDMALiveMigration
> 
> Signed-off-by: Michael R. Hines 
> Signed-off-by: Jiri Denemark 
> ---
> 
> Notes:
> The question is whether the IB devices should be added to
> cgroup_device_acl by default or not...
> 
> Version 3:
> - moved capabilities code into a separate patch
> - got rid of migration URI hacks
> - removed hacks that disabled IPv6 with RDMA
> - moved refactoring into a dedicated patch
> - documented IB devices which need to be added to cgroup acl in
>   qemu.conf
> - forbid RDMA migrations unless memory hard limit is set until we
>   have a better plan for setting limits for mlock
> - set QEMU's RLIMIT_MEMLOCK to memory hard_limit before starting
>   RDMA migration
> - check if RDMA migration is supported by source QEMU before trying
>   to migrate
> 
>  src/qemu/qemu.conf|  8 
>  src/qemu/qemu_command.c   |  8 
>  src/qemu/qemu_migration.c | 39 +--
>  3 files changed, 53 insertions(+), 2 deletions(-)
> 

My morning Coverity run found a memory leak...

> diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
> index 79bba36..92ca715 100644
> --- a/src/qemu/qemu.conf
> +++ b/src/qemu/qemu.conf
> @@ -274,6 +274,14 @@
>  #"/dev/ptmx", "/dev/kvm", "/dev/kqemu",
>  #"/dev/rtc","/dev/hpet", "/dev/vfio/vfio"
>  #]
> +#
> +# RDMA migration requires the following extra files to be added to the list:
> +#   "/dev/infiniband/rdma_cm",
> +#   "/dev/infiniband/issm0",
> +#   "/dev/infiniband/issm1",
> +#   "/dev/infiniband/umad0",
> +#   "/dev/infiniband/umad1",
> +#   "/dev/infiniband/uverbs0"
>  
>  
>  # The default format for Qemu/KVM guest save images is raw; that is, the
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index a892d99..fceed62 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -9399,6 +9399,14 @@ qemuBuildCommandLine(virConnectPtr conn,
>  goto error;
>  }
>  virCommandAddArg(cmd, migrateFrom);
> +} else if (STRPREFIX(migrateFrom, "rdma")) {
> +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_RDMA)) {
> +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
> +   _("incoming RDMA migration is not supported "
> + "with this QEMU binary"));
> +goto error;
> +}
> +virCommandAddArg(cmd, migrateFrom);
>  } else if (STREQ(migrateFrom, "stdio")) {
>  if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD)) {
>  virCommandAddArgFormat(cmd, "fd:%d", migrateFd);
> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
> index d0e2653..b59e94d 100644
> --- a/src/qemu/qemu_migration.c
> +++ b/src/qemu/qemu_migration.c
> @@ -56,6 +56,7 @@
>  #include "virhook.h"
>  #include "virstring.h"
>  #include "virtypedparam.h"
> +#include "virprocess.h"
>  
>  #define VIR_FROM_THIS VIR_FROM_QEMU
>  
> @@ -2653,6 +2654,13 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
> QEMU_MIGRATION_COOKIE_NBD)))
>  goto cleanup;
>  
> +if (STREQ(protocol, "rdma") && !vm->def->mem.hard_limit) {
> +virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +   _("cannot start RDMA migration with no memory hard "
> + "limit set"));
> +goto cleanup;
> +}
> +
>  if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
>  goto cleanup;
>  qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_PREPARE);
> @@ -2696,6 +2704,11 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
>  QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
>  goto stop;
>  
> +if (STREQ(protocol, "rdma") &&
> +virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) 
> {
> +goto stop;
> +}
> +
>  if (mig->lockState) {
>  VIR_DEBUG("Received lockstate %s", mig->lockState);
>  VIR_FREE(priv->lockState);
> @@ -2926,7 +2939,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
>  if (!(uri = qemuMigrationParseURI(uri_in, &well_formed_uri)))
>  goto cleanup;
>  
> -if (STRNEQ(uri->scheme, "tcp")) {
> +if (STRNEQ(uri->scheme, "tcp") &&
> +STRNEQ(uri->scheme, "rdma")) {
>

Re: [libvirt] [PATCH v4 4/4] cputune_event: queue the event for cputune updates

2014-09-23 Thread Pavel Hrdina

On 09/22/2014 05:54 PM, John Ferlan wrote:



On 09/18/2014 04:39 AM, Pavel Hrdina wrote:

Now we have universal tunable event so we can use it for reporting
changes to user. The cputune values will be prefixed with "cputune" to
distinguish it from other tunable events.

Signed-off-by: Pavel Hrdina 
---
  src/qemu/qemu_cgroup.c | 18 +++-
  src/qemu/qemu_driver.c | 76 ++
  2 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 9d39370..27dcba3 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -34,6 +34,7 @@
  #include "virscsi.h"
  #include "virstring.h"
  #include "virfile.h"
+#include "virtypedparam.h"

  #define VIR_FROM_THIS VIR_FROM_QEMU

@@ -676,6 +677,10 @@ static int
  qemuSetupCpuCgroup(virDomainObjPtr vm)
  {
  qemuDomainObjPrivatePtr priv = vm->privateData;
+virObjectEventPtr event = NULL;
+virTypedParameterPtr eventParams;


Consistency with other defs "eventParams = NULL".


Will fix that, thanks.




+int eventNparams = 0;
+int eventMaxparams = 0;

  if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
 if (vm->def->cputune.sharesSpecified) {
@@ -694,7 +699,18 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)

  if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
  return -1;
-vm->def->cputune.shares = val;
+if (vm->def->cputune.shares != val) {
+vm->def->cputune.shares = val;
+if (virTypedParamsAddULLong(&eventParams, &eventNparams,
+&eventMaxparams, "cputune.shares",


Perhaps this name space ('cputune.*') should be what goes into libvirt.h
(mentioned in the v2 3/5 review).

That is define and use

#define VIR_DOMAIN_EVENT_CPUTUNE_SHARES "cputune.shares"


+val) < 0)
+return -1;
+
+event = virDomainEventTunableNewFromObj(vm, eventParams, 
eventNparams);
+}
+
+if (event)
+qemuDomainEventQueue(vm->privateData, event);
  }

  return 0;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5fd89a3..22c6e55 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4538,6 +4538,12 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
  virBitmapPtr pcpumap = NULL;
  virQEMUDriverConfigPtr cfg = NULL;
  virCapsPtr caps = NULL;
+virObjectEventPtr event = NULL;
+char paramField[VIR_TYPED_PARAM_FIELD_LENGTH] = "";
+char *str = NULL;
+virTypedParameterPtr eventParams = NULL;
+int eventNparams = 0;
+int eventMaxparams = 0;

  virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -4645,6 +4651,18 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,

  if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
  goto cleanup;
+
+if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "cputune.vcpupin%d", vcpu) < 0) {


#define VIR_DOMAIN_EVENT_CPUTUNE_VCPUPIN "cputune.vcpupin%u"

BTW: vcpu is an unsigned...  Somehow have to comment that the event will
*start with* this string with the postfix being the vCPU number as
defined by the guest.


+goto cleanup;
+}
+
+str = virBitmapFormat(pcpumap);
+if (virTypedParamsAddString(&eventParams, &eventNparams,
+&eventMaxparams, paramField, str) < 0)
+goto cleanup;
+
+event = virDomainEventTunableNewFromDom(dom, eventParams, 
eventNparams);
  }

  if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
@@ -4680,6 +4698,9 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
  virCgroupFree(&cgroup_vcpu);
  if (vm)
  virObjectUnlock(vm);
+if (event)
+qemuDomainEventQueue(driver, event);
+VIR_FREE(str);
  virBitmapFree(pcpumap);
  virObjectUnref(caps);
  virObjectUnref(cfg);
@@ -4804,6 +4825,12 @@ qemuDomainPinEmulator(virDomainPtr dom,
  virBitmapPtr pcpumap = NULL;
  virQEMUDriverConfigPtr cfg = NULL;
  virCapsPtr caps = NULL;
+virObjectEventPtr event = NULL;
+char * str = NULL;
+virTypedParameterPtr eventParams = NULL;
+int eventNparams = 0;
+int eventMaxparams = 0;
+

  virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -4909,6 +4936,13 @@ qemuDomainPinEmulator(virDomainPtr dom,

  if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
  goto cleanup;
+
+str = virBitmapFormat(pcpumap);
+if (virTypedParamsAddString(&eventParams, &eventNparams,
+&eventMaxparams, "cputune.emulatorpin", str) 
< 0)


#define VIR_DOMAIN_EVENT_CPUTUNE_EMULATORPIN "cputune.emulatorpin"



+goto cleanup;
+
+event = virDomainEventTunableNewFromDom(dom, eventParams, 
eventNparams);

[libvirt] [PATCH] nodeinfo: Prefer MIN in nodeGetFreePages

2014-09-23 Thread Michal Privoznik
It's better to use a macro instead of if-else construct.

Signed-off-by: Michal Privoznik 
---

Pushed under trivial rule.

 src/nodeinfo.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 1b4a8d7..2459922 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -2041,9 +2041,7 @@ nodeGetFreePages(unsigned int npages,
 goto cleanup;
 }
 
-lastCell = startCell + cellCount;
-if (startCell + cellCount < lastCell)
-lastCell = startCell + cellCount;
+lastCell = MIN(lastCell, startCell + cellCount);
 
 for (cell = startCell; cell < lastCell; cell++) {
 for (i = 0; i < npages; i++) {
-- 
1.8.5.5

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


[libvirt] [PATCH 0/2] add nodeset check in numatune

2014-09-23 Thread Chen Fan
for memnode.nodeset in numatune, when setting it more
than the host nodes, it should fail.

Chen Fan (2):
  numatune: add check for memnode.nodeset range
  numatune: move up verification codes in virNumaSetupMemoryPolicy

 src/conf/numatune_conf.c | 32 
 src/conf/numatune_conf.h |  4 
 src/util/virnuma.c   | 15 ---
 3 files changed, 36 insertions(+), 15 deletions(-)

-- 
1.9.3

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


[libvirt] [PATCH 2/2] numatune: move up verification codes in virNumaSetupMemoryPolicy

2014-09-23 Thread Chen Fan
use virDomainNumatuneNodeSetIsAvailable() to verify momory.nodeset
whether is out of range. and move up the verification.

Signed-off-by: Chen Fan 
---
 src/conf/numatune_conf.c |  3 +++
 src/util/virnuma.c   | 15 ---
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
index a9b20aa..8b43167 100644
--- a/src/conf/numatune_conf.c
+++ b/src/conf/numatune_conf.c
@@ -278,6 +278,9 @@ virDomainNumatuneParseXML(virDomainNumatunePtr *numatunePtr,
  nodeset) < 0)
 goto cleanup;
 
+if (!virDomainNumatuneNodeSetIsAvailable(*numatunePtr, -1))
+goto cleanup;
+
 if (virDomainNumatuneNodeParseXML(numatunePtr, ncells, ctxt) < 0)
 goto cleanup;
 
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 1a34398..4766f16 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -95,31 +95,16 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
 int ret = -1;
 int bit = 0;
 size_t i;
-int maxnode = 0;
 virBitmapPtr tmp_nodemask = NULL;
 
 tmp_nodemask = virDomainNumatuneGetNodeset(numatune, nodemask, -1);
 if (!tmp_nodemask)
 return 0;
 
-if (numa_available() < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   "%s", _("Host kernel is not aware of NUMA."));
-return -1;
-}
-
-maxnode = numa_max_node();
-maxnode = maxnode < NUMA_NUM_NODES ? maxnode : NUMA_NUM_NODES;
-
 /* Convert nodemask to NUMA bitmask. */
 nodemask_zero(&mask);
 bit = -1;
 while ((bit = virBitmapNextSetBit(tmp_nodemask, bit)) >= 0) {
-if (bit > maxnode) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("NUMA node %d is out of range"), bit);
-return -1;
-}
 nodemask_set(&mask, bit);
 }
 
-- 
1.9.3

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


[libvirt] [PATCH 1/2] numatune: add check for memnode.nodeset range

2014-09-23 Thread Chen Fan
For memnode in numatune element, the range of attribute 'nodeset'
was not validated. on my host maxnodes was 1, but when setting nodeset
to '0-2' or more, guest also started succuss. there probably was qemu's
bug too.

Signed-off-by: Chen Fan 
---
 src/conf/numatune_conf.c | 29 +
 src/conf/numatune_conf.h |  4 
 2 files changed, 33 insertions(+)

diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
index 21d9a64..a9b20aa 100644
--- a/src/conf/numatune_conf.c
+++ b/src/conf/numatune_conf.c
@@ -183,6 +183,9 @@ virDomainNumatuneNodeParseXML(virDomainNumatunePtr 
*numatunePtr,
VIR_DOMAIN_CPUMASK_LEN) < 0)
 goto cleanup;
 VIR_FREE(tmp);
+
+if (!virDomainNumatuneNodeSetIsAvailable(numatune, cellid))
+goto cleanup;
 }
 
 ret = 0;
@@ -612,3 +615,29 @@ virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr 
numatune)
 
 return false;
 }
+
+bool
+virDomainNumatuneNodeSetIsAvailable(virDomainNumatunePtr numatune,
+int cellid)
+{
+int maxnode;
+int bit = -1;
+virBitmapPtr nodemask = NULL;
+
+nodemask = virDomainNumatuneGetNodeset(numatune, NULL, cellid);
+if (!nodemask)
+return false;
+
+if ((maxnode = virNumaGetMaxNode()) < 0)
+return false;
+
+while ((bit = virBitmapNextSetBit(nodemask, bit)) >= 0) {
+if (bit > maxnode) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("NUMA node %d is out of range"), bit);
+return false;
+}
+}
+
+return true;
+}
diff --git a/src/conf/numatune_conf.h b/src/conf/numatune_conf.h
index 5254629..cab0b83 100644
--- a/src/conf/numatune_conf.h
+++ b/src/conf/numatune_conf.h
@@ -102,4 +102,8 @@ bool virDomainNumatuneHasPlacementAuto(virDomainNumatunePtr 
numatune);
 
 bool virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr numatune);
 
+extern int virNumaGetMaxNode(void);
+bool virDomainNumatuneNodeSetIsAvailable(virDomainNumatunePtr numatune,
+ int cellid);
+
 #endif /* __NUMATUNE_CONF_H__ */
-- 
1.9.3

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


Re: [libvirt] [PATCH v4 2/4] event: introduce new event for tunable values

2014-09-23 Thread Pavel Hrdina

On 09/22/2014 05:50 PM, John Ferlan wrote:



On 09/18/2014 04:39 AM, Pavel Hrdina wrote:

This new event will use typedParameters to expose what has been actually
updated and the reason is that we can in the future extend any tunable
values or add new tunable values. With typedParameters we don't have to
worry about creating some other events, we will just use this universal
event to inform user about updates.

Signed-off-by: Pavel Hrdina 
---
  daemon/remote.c  | 45 +
  include/libvirt/libvirt.h.in | 22 +++
  src/conf/domain_event.c  | 93 
  src/conf/domain_event.h  |  9 +
  src/libvirt_private.syms |  2 +
  src/remote/remote_driver.c   | 42 
  src/remote/remote_protocol.x | 14 ++-
  src/remote_protocol-structs  |  9 +
  tools/virsh-domain.c | 33 
  9 files changed, 268 insertions(+), 1 deletion(-)



Seems you covered previous code review comments just fine, although I
have a couple of questions

#1. Is virsh-domain.c relative here or perhaps later?  Or should the
verb/action be changed from "cpu-tune" to something more generic?
"tunable"?



That should be definitely changed to "tunable". Thanks for catching it.


#2. Should the REMOTE_CPUMAPS_MAX be replaced by something more name
(and size) relative to these events?  And secondarily, since event max
params is relevant to the size of the params buffer allocated for each
event series shouldn't that be passed along and eventually used as the
limit for the remoteDeserializeTypedParameters?  Although I'm not quite
clear/sure how that works with the protocol definition file.



And this one is also wrong and should definitely be 
REMOTE_DOMAIN_EVENT_TUNABLE_MAX and that means create a new const. About 
the size of the rpc message I should extend the size as in the future 
there could be some tunable staff that will require more memory than the 
cputune event.


Currently maximal size of any rpc message is 16MiB and I think that 8MiB 
should by more than enough limit for the tunable event, what do you think?


Pavel


I think this is ACK-able - just want to make sure of the above - #1
should be 'simple' right?  #2 is just one of those size things - the
current usage goes on a byte max, but is that relative to how this has
changed/evolved.

John



[...]

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


Re: [libvirt] Bug 993411 - Compilation fails on lxc/lxc_monitor_protocol.c 31: undefined reference to xdr_uinit64_t [NEEDINFO]

2014-09-23 Thread Michal Privoznik

On 22.09.2014 16:02, Gerald Palmer wrote:

Description of problem: Fail to compile


Version-Release number of selected component (if applicable):
Version 1.0.3 through 1.1.1


How reproducible:


Steps to Reproduce:
1./configure  --prefix=/usr --localstatedir=/var --sysconfdir=/etc
2.make

Actual results:
libvirt_lxc-lxc_monitor_protocol.o: In function
`xdr_virLXCMonitorInitEventMsg':
/usr/local/src/libvirt/libvirt-1.1.1/src/./lxc/lxc_monitor_protocol.c:31: 
undefined
reference to `xdr_uint64_t'


Expected results:
Successful Compilation

Additional info: patch resolving compilation issue
--- lxc_monitor_protocol.h  2013-08-05 20:22:23.96300 +
+++ libvirt-1.1.1/src/lxc/lxc_monitor_protocol.h 2013-08-05
20:22:46.22600 +
@@ -5,6 +5,8 @@

#ifndef _LXC_MONITOR_PROTOCOL_H_RPCGEN
#define _LXC_MONITOR_PROTOCOL_H_RPCGEN
+# define xdr_uint64_t xdr_u_int64_t
+


A few lines above this part is a notice, that this file is generated and 
you should not edit this file. I'm proposing a patch that fixes the file 
from which lxc_monitor_protocol.h is generated.


https://www.redhat.com/archives/libvir-list/2014-September/msg01360.html

Michal

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


[libvirt] [PATCH] lxc_monitor_protocol: Redefine xdr_uint64_t if needed

2014-09-23 Thread Michal Privoznik
On some systems (using libtirpc instead of glibc's
implementation), xdr_uint64_t exists rather under different name:
xdr_u_int64_t. This makes compilation fail then:

libvirt_lxc-lxc_monitor_protocol.o: In function `xdr_virLXCMonitorInitEventMsg':
/usr/local/src/libvirt/libvirt-1.1.1/src/./lxc/lxc_monitor_protocol.c:31: 
undefined reference to `xdr_uint64_t'

Therefore we rather mirror the d707c866 commit and redefine
xdr_uint64_t if needed.

Signed-off-by: Michal Privoznik 
---
 src/lxc/lxc_monitor_protocol.x | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/src/lxc/lxc_monitor_protocol.x b/src/lxc/lxc_monitor_protocol.x
index 0926e26..3b66af5 100644
--- a/src/lxc/lxc_monitor_protocol.x
+++ b/src/lxc/lxc_monitor_protocol.x
@@ -4,6 +4,25 @@
  * the libvirt_lxc helper program.
  */
 
+/* cygwin's xdr implementation defines xdr_u_int64_t instead of xdr_uint64_t
+ * and lacks IXDR_PUT_INT32 and IXDR_GET_INT32
+ */
+%#ifdef HAVE_XDR_U_INT64_T
+%# define xdr_uint64_t xdr_u_int64_t
+%#endif
+%#ifndef IXDR_PUT_INT32
+%# define IXDR_PUT_INT32 IXDR_PUT_LONG
+%#endif
+%#ifndef IXDR_GET_INT32
+%# define IXDR_GET_INT32 IXDR_GET_LONG
+%#endif
+%#ifndef IXDR_PUT_U_INT32
+%# define IXDR_PUT_U_INT32 IXDR_PUT_U_LONG
+%#endif
+%#ifndef IXDR_GET_U_INT32
+%# define IXDR_GET_U_INT32 IXDR_GET_U_LONG
+%#endif
+
 enum virLXCMonitorExitStatus {
 VIR_LXC_MONITOR_EXIT_STATUS_ERROR,
 VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN,
-- 
1.8.5.5

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


Re: [libvirt] [PATCH v4 1/4] domain_conf: separate structures from virDomainDef

2014-09-23 Thread Pavel Hrdina

On 09/22/2014 05:47 PM, John Ferlan wrote:



On 09/18/2014 04:39 AM, Pavel Hrdina wrote:

Cleanup virDomanDef structure from other nested structure and create
separate type definition for them.

Fix a typo in virDomainHugePage.

Signed-off-by: Pavel Hrdina 
---
  src/conf/domain_conf.h | 102 +
  1 file changed, 61 insertions(+), 41 deletions(-)



ACK

John



Thanks, pushed.

Pavel

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


[libvirt] [RFC PATCH] qcow2: Fix race in cache invalidation

2014-09-23 Thread Alexey Kardashevskiy
On 09/19/2014 06:47 PM, Kevin Wolf wrote:> Am 16.09.2014 um 14:59 hat Paolo 
Bonzini geschrieben:
>> Il 16/09/2014 14:52, Kevin Wolf ha scritto:
>>> Yes, that's true. We can't fix this problem in qcow2, though, because
>>> it's a more general one.  I think we must make sure that
>>> bdrv_invalidate_cache() doesn't yield.
>>>
>>> Either by forbidding to run bdrv_invalidate_cache() in a coroutine and
>>> moving the problem to the caller (where and why is it even called from a
>>> coroutine?), or possibly by creating a new coroutine for the driver
>>> callback and running that in a nested event loop that only handles
>>> bdrv_invalidate_cache() callbacks, so that the NBD server doesn't get a
>>> chance to process new requests in this thread.
>>
>> Incoming migration runs in a coroutine (the coroutine entry point is
>> process_incoming_migration_co).  But everything after qemu_fclose() can
>> probably be moved into a separate bottom half, so that it gets out of
>> coroutine context.
> 
> Alexey, you should probably rather try this (and add a bdrv_drain_all()
> in bdrv_invalidate_cache) than messing around with qcow2 locks. This
> isn't a problem that can be completely fixed in qcow2.


Ok. Tried :) Not very successful though. The patch is below.

Is that the correct bottom half? When I did it, I started getting crashes
in various sport on accesses to s->l1_cache which is NULL after qcow2_close.
Normally the code would check s->l1_size and then use but they are out of sync.

So I clear it in qcow2_close(). This allowed migrated guest to work and not
to crash until I shut it down when it aborted at "HERE IT FAILS ON SHUTDOWN".

Here I realized I am missing something in this picture again, what is it?
Thanks!


---
 block.c |  2 ++
 block/qcow2-cache.c |  2 +-
 block/qcow2.c   | 50 --
 block/qcow2.h   |  4 
 4 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/block.c b/block.c
index d06dd51..1e6dfd1 100644
--- a/block.c
+++ b/block.c
@@ -5044,6 +5044,8 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error 
**errp)
 error_setg_errno(errp, -ret, "Could not refresh total sector count");
 return;
 }
+
+bdrv_drain_all();
 }
 
 void bdrv_invalidate_cache_all(Error **errp)
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
index 904f6b1..59ff48c 100644
--- a/block/qcow2-cache.c
+++ b/block/qcow2-cache.c
@@ -259,7 +259,7 @@ static int qcow2_cache_find_entry_to_replace(Qcow2Cache *c)
 if (min_index == -1) {
 /* This can't happen in current synchronous code, but leave the check
  * here as a reminder for whoever starts using AIO with the cache */
-abort();
+abort(); // < HERE IT FAILS ON SHUTDOWN
 }
 return min_index;
 }
diff --git a/block/qcow2.c b/block/qcow2.c
index f9e045f..2b84562 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1399,6 +1399,7 @@ static void qcow2_close(BlockDriverState *bs)
 qemu_vfree(s->l1_table);
 /* else pre-write overlap checks in cache_destroy may crash */
 s->l1_table = NULL;
+s->l1_size = 0;
 
 if (!(bs->open_flags & BDRV_O_INCOMING)) {
 qcow2_cache_flush(bs, s->l2_table_cache);
@@ -1419,16 +1420,11 @@ static void qcow2_close(BlockDriverState *bs)
 qcow2_free_snapshots(bs);
 }
 
+static void qcow2_invalidate_cache_bh_cb(void *opaque);
+
 static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp)
 {
 BDRVQcowState *s = bs->opaque;
-int flags = s->flags;
-AES_KEY aes_encrypt_key;
-AES_KEY aes_decrypt_key;
-uint32_t crypt_method = 0;
-QDict *options;
-Error *local_err = NULL;
-int ret;
 
 /*
  * Backing files are read-only which makes all of their metadata immutable,
@@ -1436,13 +1432,28 @@ static void qcow2_invalidate_cache(BlockDriverState 
*bs, Error **errp)
  */
 
 if (s->crypt_method) {
-crypt_method = s->crypt_method;
-memcpy(&aes_encrypt_key, &s->aes_encrypt_key, sizeof(aes_encrypt_key));
-memcpy(&aes_decrypt_key, &s->aes_decrypt_key, sizeof(aes_decrypt_key));
+s->bh_crypt_method = s->crypt_method;
+memcpy(&s->bh_aes_encrypt_key, &s->aes_encrypt_key, 
sizeof(s->bh_aes_encrypt_key));
+memcpy(&s->bh_aes_decrypt_key, &s->aes_decrypt_key, 
sizeof(s->bh_aes_decrypt_key));
+} else {
+s->bh_crypt_method = 0;
 }
 
 qcow2_close(bs);
 
+s->cache_inv_bh = aio_bh_new(bdrv_get_aio_context(bs),
+ qcow2_invalidate_cache_bh_cb,
+ bs);
+}
+
+static void qcow2_invalidate_cache_bh(BlockDriverState *bs, Error **errp)
+{
+BDRVQcowState *s = bs->opaque;
+int flags = s->flags;
+QDict *options;
+Error *local_err = NULL;
+int ret;
+
 bdrv_invalidate_cache(bs->file, &local_err);
 if (local_err) {
 error_propagate(errp, local_err);
@@ -1464,11 +1475,22 @@ static void qcow2_invalidate_cache(Bl

Re: [libvirt] [PATCH 0/3] enhance freepages related

2014-09-23 Thread Michal Privoznik

On 22.09.2014 12:14, Jincheng Miao wrote:


Jincheng Miao (3):
   virsh-host: fix pagesize unit of freepages
   nodeinfo: report error when given node is out of range
   Fix typo of virNodeGetFreePages comment

  src/libvirt.c  |  2 +-
  src/nodeinfo.c | 24 +---
  tools/virsh-host.c | 27 ++-
  3 files changed, 40 insertions(+), 13 deletions(-)



Basically ACK to all three patches. I'm changing 1/3 and 2/3 according 
to my comments and pushing. Good job.


Michal

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


Re: [libvirt] [PATCH 3/3] Fix typo of virNodeGetFreePages comment

2014-09-23 Thread Michal Privoznik

On 22.09.2014 12:14, Jincheng Miao wrote:

Signed-off-by: Jincheng Miao 
---
  src/libvirt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 7c63825..aa83365 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -21307,7 +21307,7 @@ virDomainSetTime(virDomainPtr dom,
   * @flags: extra flags; not used yet, so callers should always pass 0
   *
   * This calls queries the host system on free pages of
- * specified size. Ont the input, @pages is expected to be
+ * specified size. For the input, @pages is expected to be
   * filled with pages that caller is interested in (the size
   * unit is kibibytes, so e.g. pass 2048 for 2MB), then @startcell
   * refers to the first NUMA node that info should be collected



ACK

Michal

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


Re: [libvirt] [PATCH 1/3] virsh-host: fix pagesize unit of freepages

2014-09-23 Thread Michal Privoznik

On 22.09.2014 12:14, Jincheng Miao wrote:

The unit of '--pagesize' of freepages is kibibytes.

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

Signed-off-by: Jincheng Miao 
---
  tools/virsh-host.c | 27 ++-
  1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 7fc2120..6dcf77e 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -293,7 +293,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
  bool ret = false;
  unsigned int npages;
  unsigned int *pagesize = NULL;
-unsigned long long tmp = 0;
+unsigned int tmp = 0;
  int cell;
  unsigned long long *counts = NULL;
  size_t i, j;
@@ -304,9 +304,20 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
  xmlXPathContextPtr ctxt = NULL;
  bool all = vshCommandOptBool(cmd, "all");
  bool cellno = vshCommandOptBool(cmd, "cellno");
+bool pagesz = vshCommandOptBool(cmd, "pagesize");

  VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);

+if (vshCommandOptUInt(cmd, "pagesize", &tmp) < 0) {
+vshError(ctl, "%s", _("Invalid pagesize argument"));
+goto cleanup;
+}
+


No, previously we accepted something like '--pagesize 2M'. This undo 
this feature.



+if ((pagesz || cellno) && tmp < 1) {
+vshError(ctl, "%s", _("page size must be at least 1KiB"));
+goto cleanup;
+}
+
  if (all) {
  if (!(cap_xml = virConnectGetCapabilities(ctl->conn))) {
  vshError(ctl, "%s", _("unable to get node capabilities"));
@@ -363,6 +374,8 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)

  vshPrint(ctl, _("Node %d:\n"), cell);
  for (j = 0; j < npages; j++) {
+if (pagesz && tmp != pagesize[j])
+continue;


Instead of this, I'd honor --pagesize when creating @pagesize array to 
call viNodeGetFreePages() a few lines above.



  vshPrint(ctl, "%uKiB: %lld\n", pagesize[j], counts[j]);
  }
  vshPrint(ctl, "%c", '\n');
@@ -380,20 +393,16 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
  }

  if (cell < -1) {
-vshError(ctl, "%s", _("cell number must be non-negative integer or 
-1"));
+vshError(ctl, "%s",
+ _("cell number must be non-negative integer or -1"));
  goto cleanup;
  }

-if (vshCommandOptScaledInt(cmd, "pagesize", &tmp, 1, UINT_MAX) < 0) {


In fact this is the bit that's buggy here. It should have been 1024 
instead of 1.



-vshError(ctl, "%s", _("page size has to be a number"));
-goto cleanup;
-}
  /* page size is expected in kibibytes */
  pagesize = vshMalloc(ctl, sizeof(*pagesize));
-*pagesize = tmp / 1024;

-if (!pagesize[0]) {
-vshError(ctl, "%s", _("page size must be at least 1KiB"));
+if (vshCommandOptUInt(cmd, "pagesize", pagesize) < 0) {
+vshError(ctl, "%s", _("Invalid cellno argument"));
  goto cleanup;
  }




Michal

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


Re: [libvirt] [PATCH 2/3] nodeinfo: report error when given node is out of range

2014-09-23 Thread Michal Privoznik

On 22.09.2014 12:14, Jincheng Miao wrote:

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

Signed-off-by: Jincheng Miao 
---
  src/nodeinfo.c | 24 +---
  1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index af23b8b..1728891 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -2028,16 +2028,34 @@ nodeGetFreePages(unsigned int npages,
   unsigned long long *counts)
  {
  int ret = -1;
-int cell;
+int cell, lastCell;
  size_t i, ncounts = 0;

-for (cell = startCell; cell < (int) (startCell + cellCount); cell++) {
+if ((lastCell = virNumaGetMaxNode()) < 0)
+return 0;
+
+if (startCell > lastCell) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("start cell %d out of range (0-%d)"),
+   startCell, lastCell);
+goto cleanup;
+}
+
+lastCell = startCell + cellCount;
+if (startCell + cellCount < lastCell)
+lastCell = startCell + cellCount;
+
+for (cell = startCell; cell < lastCell; cell++) {
  for (i = 0; i < npages; i++) {
  unsigned int page_size = pages[i];
  unsigned int page_free;

-if (virNumaGetPageInfo(cell, page_size, 0, NULL, &page_free) < 0)
+if (virNumaGetPageInfo(cell, page_size, 0, NULL, &page_free) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Failed to get %dKib page info of cell %d"),
+   page_size, cell);


Noo. This overwrites any error reported by virNumaGetPageInfo (which 
usually is much more helpful than this generic one).



  goto cleanup;
+}

  counts[ncounts++] = page_free;
  }



ACK with that discarded.

Michal

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


Re: [libvirt] [Qemu-devel] [PATCH v3 2/2] Add configure option --enable-pc-1-0-qemu-kvm

2014-09-23 Thread Michael S. Tsirkin
On Tue, Sep 23, 2014 at 09:59:17AM +0200, Markus Armbruster wrote:
> "Michael S. Tsirkin"  writes:
> 
> > On Mon, Sep 22, 2014 at 05:32:16PM +0200, Markus Armbruster wrote:
> >> "Michael S. Tsirkin"  writes:
> >> 
> >> > On Sun, Sep 21, 2014 at 03:38:59PM +0100, Alex Bligh wrote:
> >> >> Add a configure option --enable-pc-1-0-qemu-kvm and the
> >> >> corresponding --disable-pc-1-0-qemu-kvm, defaulting
> >> >> to disabled.
> >> >> 
> >> >> Rename machine type pc-1.0 to pc-1.0-qemu-git.
> >> >> 
> >> >> Make pc-1.0 machine type an alias of either pc-1.0-qemu-kvm
> >> >> or pc-1.0-qemu-git depending on the value of the config
> >> >> option.
> >> >> 
> >> >> Signed-off-by: Alex Bligh 
> >> >
> >> > I have to say, this one bothers me.
> >> > We end up not being able to predict what does pc-1.0
> >> > reference.
> >> >
> >> > Users also don't get qemu from git so I don't see
> >> > why does git make sense in the name?
> >> >
> >> > Legacy management applications invoked qemu as qemu-kvm -
> >> > how about detecting that name and switching
> >> > the machine types?
> >> 
> >> Ugh!  I like that even less than a configure option.
> >
> > configure options are tested even less than runtime ones:
> > each distro has to pick up a set of options and all
> > users are stuck with it.
> > So let's assume Ubuntu sets this and something is broken.  How is a
> > Fedora user to test this? Find out configure flags that Ubuntu uses
> > and rebuild from source? It's hard to get people to triage bugs as it
> > is.
> > That's why changing behaviour in subtle ways depending on
> > configure options is a very bad idea.
> 
> All it changes is a default machine type.  I wouldn't classify that as
> "very bad".  Fortunately, our difference of opinion doesn't matter,
> because the conclusion of the thread is "leave it to the distros".
> 
> > So a flag might be better, but if we want to be compatible
> > with qemu-kvm, poking at argv[0] still better than configure.
> 
> That I do consider a genuinely bad idea.
> 
> Example of usage messed up by it: I symlink from my ~/bin to executables
> in various build trees.  If one of these programs changed behavior
> depending on what it finds in argv[0], I'd have to know *exactly* how it
> matches argv[0] to choose suitable names for my symlinks.
> 
> The name "qemu-kvm" is not a useful indicator of compatibility with the
> qemu-kvm fork of QEMU anyway.  There are programs out there calling
> themselves qemu-kvm that aren't compatible with the qemu-kvm fork.  And
> there are programs out there that are compatible, but call themselves
> something else.

I think the approach v4 takes is reasonable, though.
I didn't look at the implementation yet.

-- 
MST

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


Re: [libvirt] [Qemu-devel] [PATCH v3 2/2] Add configure option --enable-pc-1-0-qemu-kvm

2014-09-23 Thread Markus Armbruster
"Michael S. Tsirkin"  writes:

> On Mon, Sep 22, 2014 at 05:32:16PM +0200, Markus Armbruster wrote:
>> "Michael S. Tsirkin"  writes:
>> 
>> > On Sun, Sep 21, 2014 at 03:38:59PM +0100, Alex Bligh wrote:
>> >> Add a configure option --enable-pc-1-0-qemu-kvm and the
>> >> corresponding --disable-pc-1-0-qemu-kvm, defaulting
>> >> to disabled.
>> >> 
>> >> Rename machine type pc-1.0 to pc-1.0-qemu-git.
>> >> 
>> >> Make pc-1.0 machine type an alias of either pc-1.0-qemu-kvm
>> >> or pc-1.0-qemu-git depending on the value of the config
>> >> option.
>> >> 
>> >> Signed-off-by: Alex Bligh 
>> >
>> > I have to say, this one bothers me.
>> > We end up not being able to predict what does pc-1.0
>> > reference.
>> >
>> > Users also don't get qemu from git so I don't see
>> > why does git make sense in the name?
>> >
>> > Legacy management applications invoked qemu as qemu-kvm -
>> > how about detecting that name and switching
>> > the machine types?
>> 
>> Ugh!  I like that even less than a configure option.
>
> configure options are tested even less than runtime ones:
> each distro has to pick up a set of options and all
> users are stuck with it.
> So let's assume Ubuntu sets this and something is broken.  How is a
> Fedora user to test this? Find out configure flags that Ubuntu uses
> and rebuild from source? It's hard to get people to triage bugs as it
> is.
> That's why changing behaviour in subtle ways depending on
> configure options is a very bad idea.

All it changes is a default machine type.  I wouldn't classify that as
"very bad".  Fortunately, our difference of opinion doesn't matter,
because the conclusion of the thread is "leave it to the distros".

> So a flag might be better, but if we want to be compatible
> with qemu-kvm, poking at argv[0] still better than configure.

That I do consider a genuinely bad idea.

Example of usage messed up by it: I symlink from my ~/bin to executables
in various build trees.  If one of these programs changed behavior
depending on what it finds in argv[0], I'd have to know *exactly* how it
matches argv[0] to choose suitable names for my symlinks.

The name "qemu-kvm" is not a useful indicator of compatibility with the
qemu-kvm fork of QEMU anyway.  There are programs out there calling
themselves qemu-kvm that aren't compatible with the qemu-kvm fork.  And
there are programs out there that are compatible, but call themselves
something else.

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


Re: [libvirt] [PATCH] libvirt-guests: wait for ntp service

2014-09-23 Thread Michal Privoznik

On 23.09.2014 08:06, Martin Kletzander wrote:

On Mon, Sep 22, 2014 at 04:50:33PM -0600, Jim Fehlig wrote:

Michal Privoznik wrote:

On 20.09.2014 01:36, Jim Fehlig wrote:

Martin Kletzander wrote:

Unfortunately I'm not very familiar with systemd files, but my guess
is that After=ntp-wait.service means it should be started after the
time is synchronized if and only if the ntp-wait.service unit is
enabled, otherwise it doesn't require it.


Yes, this is my understanding too.


And so is mine. The only concern I have is that syncing time on cold
boot of the host may take ages.


Yep, I have this concern too.  So I dug a bit further and see that
ntp-wait (a perl script) scrapes the output of `ntpq -c "rv 0`, waiting
for leap_alarm to change to leap_none, leap_add_sec, or leap_del_sec.
On my test system, this took ~16min on cold boot :-(.  ntp-wait.service
failed in the meantime, since it by default calls /usr/sbin/ntp-wait
with options to only wait 10min.


But on the other hand, it's better to start domains later and with
correct time than start asap with inaccurate time. ACK then,


Given the above observations, I'll wait to see if you change your mind.



What would you say to changing it to After=ntpdate.service?  That way
it won't wait until the clock is synchronized, but it will be started
with proper time if ntpdate.service is set up to start in the default
runlevel (or is it target in systemd?).  I think that's a compromise
that has no negative side-effects.


I wonder if we should be this specific or use time-sync.target:

time-sync.target

Services responsible for synchronizing the system clock from a 
remote source (such as NTP client implementations) should pull in this 
target and order themselves before it. All services where correct time 
is essential should be ordered after this unit, but not pull it in. 
systemd automatically adds dependencies of type After= for this target 
unit to all SysV init script service units with an LSB header referring 
to the "$time" facility.


http://www.freedesktop.org/software/systemd/man/systemd.special.html#time-sync.target

So I'd say: After=time-sync.target is what we are looking for.

Michal

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