Re: [libvirt] [PATCH] qemu: fix setting of VM CPU affinity with TCG

2015-02-11 Thread Daniel P. Berrange
On Wed, Feb 11, 2015 at 10:00:36AM +, Daniel P. Berrange wrote:
 On Wed, Feb 11, 2015 at 10:18:43AM +0100, Ján Tomko wrote:
  On Tue, Feb 10, 2015 at 04:25:51PM +, Daniel P. Berrange wrote:
   If a previous commit I fixed the incorrect handling of vcpu pids
   for TCG mode QEMU:
   
  
  ...
  
   
   To fix this we must update qemuProcessSetVcpuAffinities so that it
   only reports a fatal error if the per-VCPU cpu mask is different
   from the VM level cpu mask.
   
   Signed-off-by: Daniel P. Berrange berra...@redhat.com
   ---
src/qemu/qemu_process.c | 15 ---
1 file changed, 12 insertions(+), 3 deletions(-)
   
  
  ACK
  
  virBitmapEqual works on NULL bitmaps since commit 20448c2, so the v2
  is not needed.
 
 Hmm, I got a crash of libvirtd before i added the NULL check. So I'll
 have to double check that again.

I guess I must have had a bad build, as it doesn't crash now and the
virBitmapEqual function clearly checks for NULL

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

Re: [libvirt] [PATCH] qemu: fix setting of VM CPU affinity with TCG

2015-02-11 Thread Daniel P. Berrange
On Wed, Feb 11, 2015 at 10:18:43AM +0100, Ján Tomko wrote:
 On Tue, Feb 10, 2015 at 04:25:51PM +, Daniel P. Berrange wrote:
  If a previous commit I fixed the incorrect handling of vcpu pids
  for TCG mode QEMU:
  
 
 ...
 
  
  To fix this we must update qemuProcessSetVcpuAffinities so that it
  only reports a fatal error if the per-VCPU cpu mask is different
  from the VM level cpu mask.
  
  Signed-off-by: Daniel P. Berrange berra...@redhat.com
  ---
   src/qemu/qemu_process.c | 15 ---
   1 file changed, 12 insertions(+), 3 deletions(-)
  
 
 ACK
 
 virBitmapEqual works on NULL bitmaps since commit 20448c2, so the v2
 is not needed.

Hmm, I got a crash of libvirtd before i added the NULL check. So I'll
have to double check that again.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

Re: [libvirt] [PATCH] qemu: fix setting of VM CPU affinity with TCG

2015-02-11 Thread Ján Tomko
On Tue, Feb 10, 2015 at 04:25:51PM +, Daniel P. Berrange wrote:
 If a previous commit I fixed the incorrect handling of vcpu pids
 for TCG mode QEMU:
 

...

 
 To fix this we must update qemuProcessSetVcpuAffinities so that it
 only reports a fatal error if the per-VCPU cpu mask is different
 from the VM level cpu mask.
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 ---
  src/qemu/qemu_process.c | 15 ---
  1 file changed, 12 insertions(+), 3 deletions(-)
 

ACK

virBitmapEqual works on NULL bitmaps since commit 20448c2, so the v2
is not needed.

Jan


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

Re: [libvirt] [PATCH] qemu: fix setting of VM CPU affinity with TCG

2015-02-10 Thread Serge Hallyn
Quoting Daniel P. Berrange (berra...@redhat.com):
 If a previous commit I fixed the incorrect handling of vcpu pids
 for TCG mode QEMU:
 
   commit b07f3d821dfb11a118ee75ea275fd6ab737d9500
   Author: Daniel P. Berrange berra...@redhat.com
   Date:   Thu Dec 18 16:34:39 2014 +
 
 Don't setup fake CPU pids for old QEMU
 
 The code assumes that def-vcpus == nvcpupids, so when we setup
 fake CPU pids for old QEMU with nvcpupids == 1, we cause the
 later code to read off the end of the array. This has fun results
 like sche_setaffinity(0, ...) which changes libvirtd's own CPU
 affinity, or even better sched_setaffinity($RANDOM, ...) which
 changes the affinity of a random OS process.
 
 The intent was that this would merely disable the ability to set
 per-vCPU affinity. It should still have been possible to set VM
 level host CPU affinity.
 
 Unfortunately, when you set  vcpu cpuset='0-1'4/vcpu, the XML
 parser will internally take this  initialize an entry in the
 def-cputune.vcpupin array for every VCPU. IOW this is implicitly
 being treated as
 
   cputune
 vcpupin cpuset='0-1' vcpu='0'/
 vcpupin cpuset='0-1' vcpu='1'/
 vcpupin cpuset='0-1' vcpu='2'/
 vcpupin cpuset='0-1' vcpu='3'/
   /cputune
 
 Even more fun, the faked cputune elements are hidden from view when
 querying the live XML, because their cpuset mask is the same as the
 VM default cpumask.
 
 The upshot was that it was impossible to set VM level CPU affinity.
 
 To fix this we must update qemuProcessSetVcpuAffinities so that it
 only reports a fatal error if the per-VCPU cpu mask is different
 from the VM level cpu mask.
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com

Thanks, confirmed this let's me place qemu in a cpuset.  (Noting that
'virsh edit' always ends up squashing the cputune section when the 
cpusets are identical, but that should all be reasonable)

Acked-by: Serge E. Hallyn serge.hal...@ubuntu.com
Tested-by: Serge E. Hallyn serge.hal...@ubuntu.com

 ---
  src/qemu/qemu_process.c | 15 ---
  1 file changed, 12 insertions(+), 3 deletions(-)
 
 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
 index d5df60d..e8c532f 100644
 --- a/src/qemu/qemu_process.c
 +++ b/src/qemu/qemu_process.c
 @@ -2497,9 +2497,18 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
  return 0;
  
  if (priv-vcpupids == NULL) {
 -virReportError(VIR_ERR_OPERATION_INVALID,
 -   %s, _(cpu affinity is not supported));
 -return -1;
 +/* If any CPU has custom affinity that differs from the
 + * VM default affinity, we must reject it
 + */
 +for (n = 0; n  def-vcpus; n++) {
 +if (!virBitmapEqual(def-cpumask,
 +def-cputune.vcpupin[n]-cpumask)) {
 +virReportError(VIR_ERR_OPERATION_INVALID,
 +   %s, _(cpu affinity is not supported));
 +return -1;
 +}
 +}
 +return 0;
  }
  
  for (n = 0; n  def-vcpus; n++) {
 -- 
 2.1.0
 

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