Re: [libvirt] [PATCH] vbox: remove unused code that causes build failures

2014-11-03 Thread Taowei Luo
Sorry for troubling. I'm checking the release note and just find I missed
this.
This state existed because it is in the middle of something (say I am
rewriting the whole network driver and storage driver for vbox.)
And I did forget to remove vbox[0-9][0-9]NetworkDriver since we don't need
it any more. So this patch just fixed it up.
What's more, the whole vboxGetDrivers is removed after rewriting the
storage driver.
Taowei

2014-10-04 2:57 GMT+08:00 Martin Kletzander mklet...@redhat.com:

 On Fri, Oct 03, 2014 at 08:50:47PM +0200, Martin Kletzander wrote:

 Since 87dea4fcffb2d1b120e7841adc0e3d8ea97ed777 vboxGetDrivers() is not
 used for getting the vbox network driver.  The only call the code does
 is using NULL as the @networkDriver_ret param , but the code still used
 vbox[0-9][0-9]NetworkDriver that didn't exist anymore.

 Signed-off-by: Martin Kletzander mklet...@redhat.com
 ---


 I didn't do 'format-patch' and 'send-email' doesn't add notes.  So I'm
 attaching them now:

 I'm not pushing this as a build-breaker because I sense there might be
 more to this.  The thing is that it doesn't fail for anyone else I
 talked to, neither does it fail for out test suite.

 I don't quite understand how it could worked (ever), since the only
 definition of vbox22NetworkDriver (and others) was extern throughout
 the whole git history.  I'm running autogen using --with-vbox even
 though I don't have any virtualbox libraries/binaries installed, but
 there is no such requirement for compiling the code.  And I don't
 think the libraries would export a virNetworkDriver data struct
 either.

 Anyway, feel free to let me know where the real problem is and I'll be
 glad to help with that either.

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

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

Re: [libvirt] [PATCH v2 2/2] qemu: avoid rare race when undefining domain

2014-11-03 Thread Michal Privoznik

On 31.10.2014 15:47, Martin Kletzander wrote:

When one domain is being undefined and at the same time started, for
example, there is a possibility of a rare problem occuring.

  - Thread 1 does virDomainUndefine(), has the lock, checks that the
domain is active and because it's not, calls
virDomainObjListRemove().

  - Thread 2 does virDomainCreate() and tries to lock the domain.

  - Thread 1 needs to lock domain list in order to remove the domain from
it, but must unlock domain first (proper order is to lock domain list
first and the domain itself second).

  - Thread 2 grabs the lock, starts the domain and releases the lock.

  - Thread 1 grabs the lock and removes the domain from list.

With this patch:

  - qemuDomainRemoveInactive() creates a QEMU_JOB_MODIFY if that's
possible, but since it must remove the domain from list either way,
it continues even when starting the job failed.

  - Because virDomainObjListRemove() removes a reference to the
virDomainObj (and it must be kept that way for other drivers), we
hack around that by acquiring one more reference that's kept until
the job is ended.

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

Signed-off-by: Martin Kletzander mklet...@redhat.com
---
  src/qemu/qemu_domain.c | 9 +
  1 file changed, 9 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 76fccce..98c4763 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2392,9 +2392,13 @@ void
  qemuDomainRemoveInactive(virQEMUDriverPtr driver,
   virDomainObjPtr vm)
  {
+bool haveJob = true;
  char *snapDir;
  virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);

+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+haveJob = false;
+
  /* Remove any snapshot metadata prior to removing the domain */
  if (qemuDomainSnapshotDiscardAllMetadata(driver, vm)  0) {
  VIR_WARN(unable to remove all snapshots for domain %s,
@@ -2409,8 +2413,13 @@ qemuDomainRemoveInactive(virQEMUDriverPtr driver,
  VIR_WARN(unable to remove snapshot directory %s, snapDir);
  VIR_FREE(snapDir);
  }
+virObjectRef(vm);
  virDomainObjListRemove(driver-domains, vm);
  virObjectUnref(cfg);
+
+if (haveJob)
+ignore_value(qemuDomainObjEndJob(driver, vm));
+virObjectUnref(vm);
  }

  void



I don't think there's a reason to do the Ref() and Unref(). Job control 
functions do that already. ACK with that removed.


Michal

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


[libvirt] Release of libvirt-python-1.2.10

2014-11-03 Thread Daniel Veillard
 I also tagged and pushed a new version of libvirt-python,
it is available at:

  ftp://libvirt.org/libvirt/python

it handle the new header split in libvirt-1.2.10 and fixes a
number of issues:

Documentation:
d Change the comment in getPyNodeCPUCount method reflecting correct called 
methods (Pradipta Kr. Banerjee)

Bug Fixes:
b virDomainBlockCopy: initialize flags to 0 (Pavel Hrdina)
b flags cannot get right value for blockCopy function (Pavel Hrdina)
b Fix rest of unsigned integer handling (Peter Krempa)
b Fix parsing of 'flags' argument for bulk stats functions (Luyao Huang)
b Fix function name when parsing arguments in libvirt_virNodeAllocPages (Peter 
Krempa)

Improvements:
i fix libvirt headers list (Dmitry Guryanov)
i Improve error output when use getTime with a nonzero flags. (Luyao Huang)
i setup.py: fix rpm build to return 1 on error (Pavel Hrdina)
i sanitytest: define long for python version = 3 (Martin Kletzander)
i sanitytest: count with the fact that large enums can be long (Martin 
Kletzander)
i sanitytest: check for exported enums (Martin Kletzander)

  Thanks everybody who contributed to this release !

Daniel

-- 
Daniel Veillard  | Open Source and Standards, Red Hat
veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH v2 2/2] qemu: avoid rare race when undefining domain

2014-11-03 Thread Martin Kletzander

On Mon, Nov 03, 2014 at 09:54:09AM +0100, Michal Privoznik wrote:

On 31.10.2014 15:47, Martin Kletzander wrote:

When one domain is being undefined and at the same time started, for
example, there is a possibility of a rare problem occuring.

  - Thread 1 does virDomainUndefine(), has the lock, checks that the
domain is active and because it's not, calls
virDomainObjListRemove().

  - Thread 2 does virDomainCreate() and tries to lock the domain.

  - Thread 1 needs to lock domain list in order to remove the domain from
it, but must unlock domain first (proper order is to lock domain list
first and the domain itself second).

  - Thread 2 grabs the lock, starts the domain and releases the lock.

  - Thread 1 grabs the lock and removes the domain from list.

With this patch:

  - qemuDomainRemoveInactive() creates a QEMU_JOB_MODIFY if that's
possible, but since it must remove the domain from list either way,
it continues even when starting the job failed.

  - Because virDomainObjListRemove() removes a reference to the
virDomainObj (and it must be kept that way for other drivers), we
hack around that by acquiring one more reference that's kept until
the job is ended.

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

Signed-off-by: Martin Kletzander mklet...@redhat.com
---
  src/qemu/qemu_domain.c | 9 +
  1 file changed, 9 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 76fccce..98c4763 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2392,9 +2392,13 @@ void
  qemuDomainRemoveInactive(virQEMUDriverPtr driver,
   virDomainObjPtr vm)
  {
+bool haveJob = true;
  char *snapDir;
  virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);

+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+haveJob = false;
+
  /* Remove any snapshot metadata prior to removing the domain */
  if (qemuDomainSnapshotDiscardAllMetadata(driver, vm)  0) {
  VIR_WARN(unable to remove all snapshots for domain %s,
@@ -2409,8 +2413,13 @@ qemuDomainRemoveInactive(virQEMUDriverPtr driver,
  VIR_WARN(unable to remove snapshot directory %s, snapDir);
  VIR_FREE(snapDir);
  }
+virObjectRef(vm);
  virDomainObjListRemove(driver-domains, vm);
  virObjectUnref(cfg);
+
+if (haveJob)
+ignore_value(qemuDomainObjEndJob(driver, vm));
+virObjectUnref(vm);
  }

  void



I don't think there's a reason to do the Ref() and Unref(). Job control
functions do that already. ACK with that removed.



Oh, they do :)  I removed those two lines and the part of commit
message as well.  And I'll push it in a while.

Martin


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

Re: [libvirt] [v5][Patch 0/4] Libvirt CPU enhancements for Power KVM

2014-11-03 Thread Michal Privoznik

On 31.10.2014 10:15, Prerna Saxena wrote:

This patch series is a collection of enhancements for PowerPC CPUs on PowerKVM.
In this iteration, I have followed Dan's suggestion on using existing cpu mode
format to describe powerPC compatibility mode.
Hope this can finally make it for 1.2.10 !

  Series Summary:
==
Patch 1/4 : Introduce a new architecture 'ppc64le' for libvirt.
Patch 2/4 : Add libvirt support for VMs running in 'compat' mode on Power KVM.
Patch 3/4 : Improve PVR handling to fall back to cpu generation.
Patch 4/4 : Add documentation describing compat mode usage for PowerPC guests.


What am I missing here is a test case. Can you please add a qemuxml2argv 
test case? Just send it as a follow up patch and I'll merge the code then.


Michal

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


Re: [libvirt] [v5][PATCH 2/4] PowerPC : Add support for launching VMs in 'compat' mode.

2014-11-03 Thread Michal Privoznik

On 31.10.2014 10:51, Prerna Saxena wrote:


From: Prerna Saxena pre...@linux.vnet.ibm.com
Date: Tue, 28 Oct 2014 15:05:59 +0530

PowerISA allows processors to run VMs in binary compatibility (compat)
mode supporting an older version of ISA. QEMU has recently added support to
explicitly denote a VM running in compatibility mode through commit 6d9412ea
 8dfa3a5e85.
Now, a compat mode VM can be run by invoking this qemu commandline on a
POWER8 host:  -cpu host,compat=power7.

This patch allows libvirt to exploit cpu mode 'host-model' to describe this
new mode for PowerKVM guests. As an example:
When a user wants to request a power7 vm to run in compatibility mode on
a Power8 host, this can be described in XML as follows :
   cpu mode='host-model'
 modelpower7/model
   /cpu


So I guess we've agreement on this.



Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
Signed-off-by: Pradipta Kr. Banerjee bpra...@in.ibm.com
---
  src/conf/cpu_conf.c |  1 +
  src/cpu/cpu_powerpc.c   | 11 ++-
  src/qemu/qemu_command.c | 10 +-
  3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 9b7fbb0..0e7a979 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -619,6 +619,7 @@ virCPUDefFormatBuf(virBufferPtr buf,
  return 0;

  formatModel = (def-mode == VIR_CPU_MODE_CUSTOM ||
+   def-mode == VIR_CPU_MODE_HOST_MODEL ||
 (flags  VIR_DOMAIN_XML_UPDATE_CPU));
  formatFallback = (def-type == VIR_CPU_TYPE_GUEST 
(def-mode == VIR_CPU_MODE_HOST_MODEL ||
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index d591c18..4ea1835 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -562,8 +562,8 @@ ppcUpdate(virCPUDefPtr guest,
  static virCPUDefPtr
  ppcBaseline(virCPUDefPtr *cpus,
  unsigned int ncpus,
-const char **models,
-unsigned int nmodels,
+const char **models ATTRIBUTE_UNUSED,
+unsigned int nmodels ATTRIBUTE_UNUSED,
  unsigned int flags)
  {
  struct ppc_map *map = NULL;
@@ -583,13 +583,6 @@ ppcBaseline(virCPUDefPtr *cpus,
  goto error;
  }

-if (!cpuModelIsAllowed(model-name, models, nmodels)) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-_(CPU model %s is not supported by hypervisor),
-model-name);
-goto error;
-}
-
  for (i = 0; i  ncpus; i++) {
  const struct ppc_vendor *vnd;

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d60f274..34f6535 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6221,7 +6221,9 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
  *hasHwVirt = hasSVM  0 ? true : false;
  }

-if (cpu-mode == VIR_CPU_MODE_HOST_PASSTHROUGH) {
+if ((cpu-mode == VIR_CPU_MODE_HOST_PASSTHROUGH) ||
+((cpu-mode == VIR_CPU_MODE_HOST_MODEL) 
+  ARCH_IS_PPC64(def-os.arch))) {
  const char *mode = virCPUModeTypeToString(cpu-mode);
  if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_HOST)) {
  virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -6236,6 +6238,12 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
  goto cleanup;
  }
  virBufferAddLit(buf, host);
+
+if (ARCH_IS_PPC64(def-os.arch) 
+cpu-mode == VIR_CPU_MODE_HOST_MODEL) {
+virBufferAsprintf(buf, ,compat=%s, def-cpu-model);
+}
+
  } else {
  if (VIR_ALLOC(guest)  0)
  goto cleanup;



ACK then.

Michal

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


Re: [libvirt] [v5][PATCH 4/4] docs: Add documentation for compat mode.

2014-11-03 Thread Michal Privoznik

On 31.10.2014 10:54, Prerna Saxena wrote:



From dd917ef27269bc3a9af2294212b088f838792315 Mon Sep 17 00:00:00 2001

From: Prerna Saxena pre...@linux.vnet.ibm.com
Date: Fri, 31 Oct 2014 15:13:16 +0530
Subject: [PATCH 4/4] docs: Add documentation for compat mode.

Add documentation to explain how compat-mode can be invoked with libvirt
running on PowerPC architecture.

Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
---
  docs/formatdomain.html.in | 15 ++-
  1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0099ce7..ded9b90 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1047,7 +1047,20 @@
(such as CPUID level) that don't work. Until these issues are fixed,
it's a good idea to avoid using codehost-model/code and use
codecustom/code mode with just the CPU model from host
-  capabilities XML./dd
+  capabilities XML.
+  span class=since(Since 1.2.10)/span.PowerISA allows


s/\./. /


+  processors to run VMs in binary compatibility mode supporting an
+  older version of ISA.  Libvirt on PowerPC architecture uses the
+  codehost-model/code to signify a guest mode CPU running in
+  binary compatibility mode. Example:
+  When a user needs a power7 VM to run in compatibility mode
+  on a Power8 host, this can be described in XML as follows :
+pre
+  lt;cpu mode='host-model'gt;
+lt;modelgt;power7lt;/modelgt;
+  lt;/cpugt;
+  .../pre
+  /dd
dtcodehost-passthrough/code/dt
ddWith this mode, the CPU visible to the guest should be exactly
the same as the host CPU even in the aspects that libvirt does not



Michal

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


Re: [libvirt] [PATCH] mingw: fix build failure

2014-11-03 Thread Martin Kletzander

On Sat, Nov 01, 2014 at 01:36:24AM +0100, Pavel Hrdina wrote:

On 10/31/2014 11:50 PM, Eric Blake wrote:

On 10/31/2014 12:13 PM, Pavel Hrdina wrote:

This macro seems to be defined only on linux/unix and it fails during
mingw build. Its value is '16' (taken from net/if.h) so define it if
it's not defined.

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---

For now just define it for mingw but we should review all daemon related
code and not build it for mingw at all to save is those kind of failures.


Yeah, a better solution is probably worth the effort, but as we are
close to the release, and this is a reasonable bandage, I'm okay with
giving it ACK to go in for the release.



Thanks, pushed now.

Pavel



  src/util/virnetdev.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 6da3371..3831009 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -52,6 +52,10 @@
  # include net/if_dl.h
  #endue

+#offender's IFNAMSIZ


Good things it's pushed without this spell fix :-D


+# define IFNAMSIZ 16
+#endif
+
  #define VIR_FROM_THIS VIR_FROM_NONE

  VIR_LOG_INIT(util.netdev);





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


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

Re: [libvirt] [PATCH] network: Add bandwidth support to ethernet interface

2014-11-03 Thread Michal Privoznik

On 30.10.2014 00:56, Anirban Chakraborty wrote:

Ethernet interfaces in libvirt currently do not support bandwidth setting.
For example, following xml file for an interface will not apply these
settings to corresponding qdiscs.

 interface type=ethernet
   mac address=02:36:1d:18:2a:e4/
   model type=virtio/
   script path=/
   target dev=tap361d182a-e4/
   bandwidth
 inbound average=984 peak=1024 burst=64/
 outbound average=2000 peak=2048 burst=128/
   /bandwidth
 /interface

Signed-off-by: Anirban Chakraborty abc...@juniper.net
---
  src/conf/domain_conf.h  | 21 +
  src/lxc/lxc_driver.c|  3 +++
  src/lxc/lxc_process.c   | 18 +-
  src/qemu/qemu_command.c | 25 +++--
  src/qemu/qemu_command.h |  2 ++
  src/qemu/qemu_driver.c  |  3 +++
  src/qemu/qemu_hotplug.c | 12 
  src/qemu/qemu_process.c |  3 +++
  src/util/virnetdevmacvlan.c | 10 --
  src/util/virnetdevmacvlan.h |  1 -
  10 files changed, 72 insertions(+), 26 deletions(-)

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9908d88..40e85d9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2848,4 +2848,25 @@ int virDomainObjSetMetadata(virDomainObjPtr vm,
  bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
  ATTRIBUTE_NONNULL(1);

+static inline bool virNetDevSupportBandwidth(virDomainNetType type)
+{
+switch (type) {
+case VIR_DOMAIN_NET_TYPE_BRIDGE:
+case VIR_DOMAIN_NET_TYPE_NETWORK:
+case VIR_DOMAIN_NET_TYPE_DIRECT:
+case VIR_DOMAIN_NET_TYPE_ETHERNET:
+return true;
+case VIR_DOMAIN_NET_TYPE_USER:
+case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+case VIR_DOMAIN_NET_TYPE_SERVER:
+case VIR_DOMAIN_NET_TYPE_CLIENT:
+case VIR_DOMAIN_NET_TYPE_MCAST:
+case VIR_DOMAIN_NET_TYPE_INTERNAL:
+case VIR_DOMAIN_NET_TYPE_HOSTDEV:
+case VIR_DOMAIN_NET_TYPE_LAST:
+break;
+}
+return false;
+}
+


I've got a feeling that this should go to src/util/virnetdevbandwidth* 
among with the rest of virNetDevBandwitdh functions.



  #endif /* __DOMAIN_CONF_H */
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 979382b..8a21af4 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -72,6 +72,7 @@
  #include viraccessapicheck.h
  #include viraccessapichecklxc.h
  #include virhostdev.h
+#include qemu/qemu_command.h


This is not allowed. In case somebody is building with LXC but without 
QEMU ..




  #define VIR_FROM_THIS VIR_FROM_LXC

@@ -4634,6 +4635,8 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm,

  detach = vm-def-nets[detachidx];

+qemuDomainClearNetBandwidth(vm);
+


.. this is going to be an undefined reference.


  switch (virDomainNetGetActualType(detach)) {
  case VIR_DOMAIN_NET_TYPE_BRIDGE:
  case VIR_DOMAIN_NET_TYPE_NETWORK:
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index ed30c37..3192011 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -274,11 +274,6 @@ char *virLXCProcessSetupInterfaceBridged(virConnectPtr 
conn,
  if (virNetDevSetOnline(parentVeth, true)  0)
  goto cleanup;

-if (virNetDevBandwidthSet(net-ifname,
-  virDomainNetGetActualBandwidth(net),
-  false)  0)
-goto cleanup;
-



No, this function is called from two places:
1) when domain is starting up
2) on NIC hotplug

you are covering 1) but removing already working 2). We can't lose that 
functionality.



  if (net-filter 
  virDomainConfNWFilterInstantiate(conn, vm-uuid, net)  0)
  goto cleanup;
@@ -300,6 +295,7 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
  virNetDevBandwidthPtr bw;
  virNetDevVPortProfilePtr prof;
  virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
+const char *linkdev = virDomainNetGetActualDirectDev(net);

  /* XXX how todo bandwidth controls ?
   * Since the 'net-ifname' is about to be moved to a different
@@ -329,14 +325,13 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr 
conn,

  if (virNetDevMacVLanCreateWithVPortProfile(
  net-ifname, net-mac,
-virDomainNetGetActualDirectDev(net),
+linkdev,
  virDomainNetGetActualDirectMode(net),
  false, def-uuid,
-virDomainNetGetActualVirtPortProfile(net),
+prof,
  res_ifname,
  VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
-cfg-stateDir,
-virDomainNetGetActualBandwidth(net), 0)  0)
+cfg-stateDir, 0)  0)
  goto cleanup;



Same comment applies here.


  ret = res_ifname;
@@ -450,6 +445,11 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
  goto cleanup;
  }

+/* set network bandwidth */
+if (virNetDevBandwidthSet(def-nets[i]-ifname,
+

Re: [libvirt] [PATCH 2/2] qemu: migration: Ignore null ptr in qemuMigrationStopNBDServer

2014-11-03 Thread Ján Tomko
On 11/03/2014 05:22 AM, weiwei li wrote:
 mig-nbd is initialized by qemuMigrationCookieXMLParse(called
 by qemuMigrationEatCookie),with a condition that
 the nbd infomation contained in Cookie string. I found in debug info
 that qemuMigrationStartNBDServer had been called in 
 qemuMigrationPrepareAny(mig-nbd not null), but at
 in qemuMigrationFinish qemuMigrationStopNBDServer can not really
 stop nbd server bucause mig-nbd is not initialized(that is because cookie
 string does not contain nbd information ).
 
 so ,there are two solutions:
 1 qemuMigrationStopNBDServer  ignore mig-nbd null ptr
 2 add cookie info for nbd same stage (that is lost in which stage i am not 
 sure~ )
 
 I choose an easy way solution 1 with least code changing, maybe is not google
 way :)
 
 cookie log is like this:
 2014-10-30 08:38:14.106+: 15078: debug : qemuMigrationRun:3254 :
 driver=0x7f936413cd40, vm=0x7f934400b850, cookiein=qemu-migration
   name3cd4c349-e058-4a1a-8b3d-cc988efd11e2/name
   uuid3cd4c349-e058-4a1a-8b3d-cc988efd11e2/uuid
   hostname50e54929-059c---_10.180.39.36/hostname
   hostuuid50e54929-059c---/hostuuid
  nbd port='49153'/
 /qemu-migration
 
 2014-10-30 08:39:12.527+: 15076: debug : virObjectRef:296 : OBJECT_REF:
 obj=0x7f9364138880
 2014-10-30 08:39:12.527+: 15076: debug : qemuMigrationFinish:4507 :
 driver=0x7f936413cd40, dconn=0x7f9358002720, vm=0x7f935c002da0,
 cookiein=qemu-migration
   name3cd4c349-e058-4a1a-8b3d-cc988efd11e2/name
   uuid3cd4c349-e058-4a1a-8b3d-cc988efd11e2/uuid
   hostname50e54929-059c---_10.180.39.36/hostname
   hostuuid50e54929-059c---/hostuuid
   feature name='persistent'/

...

   memballoon model='virtio'
 address type='pci' domain='0x' bus='0x00' slot='0x06'
 function='0x0'/
   /memballoon
 /devices
   /domain

   nbd/

So the nbd/ element is there, we just don't parse it because
qemuMigrationFinish calls qemuMigrationEatCookie without the
QEMU_MIGRATION_COOKIE_NBD flag.

I believe the proper fix is to add this flag there.

Jan

 /qemu-migration
 , cookieinlen=2567, cookieout=0x7f93722eab08, cookieoutlen=0x7f93722eab14,
 flags=289, retcode=0
 



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

[libvirt] [PATCH] qemu: Update fsfreeze status on domain state transitions

2014-11-03 Thread Michal Privoznik
As of b6d4dad1 (1.2.5) libvirt keeps track if domain disks have been
frozen. However, this falls into that set of information which don't
survive domain restart. Therefore, we need to clear the flag upon some
state transitions. Moreover, once we clear the flag we must update the
status file too.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 src/qemu/qemu_driver.c  | 10 +-
 src/qemu/qemu_process.c | 10 ++
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2eaf77d..03c04ce 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4040,11 +4040,6 @@ processGuestPanicEvent(virQEMUDriverPtr driver,
 VIR_WARN(Unable to release lease on %s, vm-def-name);
 VIR_DEBUG(Preserving lock state '%s', NULLSTR(priv-lockState));
 
-if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0) {
-VIR_WARN(Unable to save status on vm %s after state change,
- vm-def-name);
- }
-
 switch (action) {
 case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY:
 if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY)  0) {
@@ -4102,6 +4097,11 @@ processGuestPanicEvent(virQEMUDriverPtr driver,
 }
 
  cleanup:
+if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0) {
+VIR_WARN(Unable to save status on vm %s after state change,
+ vm-def-name);
+ }
+
 virObjectUnref(cfg);
 }
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ba8ba82..0df375c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -529,6 +529,7 @@ qemuProcessHandleReset(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
 virQEMUDriverPtr driver = opaque;
 virObjectEventPtr event;
 qemuDomainObjPrivatePtr priv;
+virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
 
 virObjectLock(vm);
 
@@ -536,12 +537,20 @@ qemuProcessHandleReset(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
 priv = vm-privateData;
 if (priv-agent)
 qemuAgentNotifyEvent(priv-agent, QEMU_AGENT_EVENT_RESET);
+/* Clear some domain runtime information. For instance,
+ * fsfreeze won't survive domain reset. This, however,
+ * required the domain status file to be rewritten onto disk. */
+priv-quiesced = false;
 
 virObjectUnlock(vm);
 
+if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
+VIR_WARN(Failed to save status on vm %s, vm-def-name);
+
 if (event)
 qemuDomainEventQueue(driver, event);
 
+virObjectUnref(cfg);
 return 0;
 }
 
@@ -4841,6 +4850,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
 
 virPortAllocatorRelease(driver-migrationPorts, priv-nbdPort);
 priv-nbdPort = 0;
+priv-quiesced = false;
 
 if (priv-agent) {
 qemuAgentClose(priv-agent);
-- 
2.0.4

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


Re: [libvirt] [[PATCH libvirt-java]] Implement Connect.listAllDomains

2014-11-03 Thread Cedric Bosdonnat
Hello Claudio,

On Fri, 2014-10-31 at 23:40 +0100, Claudio Bley wrote:
 At Sat, 25 Oct 2014 16:25:48 -0700,
 Cédric Bosdonnat wrote:
 I'd prefer an enum instead of these (ugly) constants.
 
 As a side node, these constants are useless since the
 ListAllDomainsFlags is not public.

Ok, I mimicked similar code in the Domain class... Just changed it to
use an enum.

   /**
* Get the version of a connection.
*
  @@ -758,6 +781,29 @@ public class Connect {
   }
   
   /**
  + * Lists a possibly filtered list of all the domains.
  + * 
  + * @param flags bitwise-OR of ListAllDomainsFlags
  + *
  + * @return and array of the IDs of the active domains
  + * @throws LibvirtException
  + */
  +public Domain[] listAllDomains(int flags) throws LibvirtException {
  +PointerByReference domainsRef = new PointerByReference();
  +int ret = libvirt.virConnectListAllDomains(VCP, domainsRef, flags);
  +processError(ret);
  +
  +Pointer[] pointers  = domainsRef.getValue().getPointerArray(0);
  +Domain[] domains = new Domain[ret];
  +for (int i = 0; i  ret; i++) {
  +DomainPointer domainPtr = new DomainPointer();
  +domainPtr.setPointer(pointers[i]);
  +domains[i] = new Domain(this, domainPtr);
  +}
  +return domains;
  +}
 
 You leak the memory of the array here.

Arf, with all those Java things, I forgot about the hidden C pointers
behind. I guess a

Library.free(domainsRef.getValue());

inside a finally block would do the trick.

In your other mail you mention freeing the domains pointers, but the
only method that could throw an exception is virConnectListAllDomains...
unless we need to catch also any other exception like those thrown by a
new.

--
Cedric

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

[libvirt] [PATCH 1/4] video: cleanup usage of vram attribute and update documentation

2014-11-03 Thread Pavel Hrdina
The vram attribute was introduced to set the video memory but it is
usable only for few hypervisors excluding QEMU/KVM. QEMU/KVM has
different attribute for this purpose vgamem_mb and it will be
introduced lately.

The correct usage of vram is to set the video memory for other
hypervisors or to set secondary bar size for QXL video device for
QEMU/KVM.

This patch updates the documentation to reflect current code in libvirt
and also changes the cases when we will set the default vram attribute.
It's pointless to set it for QEMU/KVM if you aren't using QXL as it
won't be used.

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

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---
 docs/formatdomain.html.in | 61 +--
 src/conf/domain_conf.c| 19 +++
 src/conf/domain_conf.h|  3 ++-
 src/qemu/qemu_command.c   |  4 ++--
 4 files changed, 57 insertions(+), 30 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0099ce7..24be21c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4615,33 +4615,48 @@ qemu-kvm -net nic,model=? /dev/null
 dl
   dtcodevideo/code/dt
   dd
-The codevideo/code element is the container for describing
-video devices. For backwards compatibility, if no codevideo/code
-is set but there is a codegraphics/code in domain xml, then libvirt
-will add a default codevideo/code according to the guest type.
-For a guest of type kvm, the default codevideo/code for it is:
-codetype/code with value cirrus, codevram/code with value
-9216, and codeheads/code with value 1. By default, the first
-video device in domain xml is the primary one, but the optional
-attribute codeprimary/code (span class=sincesince 1.0.2/span)
-with value 'yes' can be used to mark the primary in cases of multiple
-video device. The non-primary must be type of qxl. The optional
-attribute coderam/code (span class=sincesince
-1.0.2/span) is allowed for qxl type only and specifies
-the size of the primary bar, while codevram/code specifies the
-secondary bar size.  If ram or vram are not supplied a default
-value is used.
+p
+  The codevideo/code element is the container for describing
+  video devices. For backwards compatibility, if no codevideo/code
+  is set but there is a codegraphics/code in domain xml, then
+  libvirt will add a default codevideo/code according to the guest
+  type.
+/p
+p
+  For a guest of type kvm, the default codevideo/code is:
+  codetype/code with value cirrus and codeheads/code with
+  value 1. By default, the first video device in domain xml is
+  the primary one, but the optional attribute codeprimary/code
+  (span class=sincesince 1.0.2/span) with value 'yes' can be used
+  to mark the primary in cases of multiple video device. The 
non-primary
+  must be type of qxl.
+/p
   /dd
 
   dtcodemodel/code/dt
   dd
-The codemodel/code element has a mandatory codetype/code
-attribute which takes the value vga, cirrus, vmvga, xen,
-vbox, or qxl (span class=sincesince 0.8.6/span)
-depending on the hypervisor features available.
-You can also provide the amount of video memory in kibibytes
-(blocks of 1024 bytes) using
-codevram/code and the number of screen with codeheads/code.
+p
+  The codemodel/code element has a mandatory codetype/code
+  attribute which takes the value vga, cirrus, vmvga, xen,
+  vbox, or qxl (span class=sincesince 0.8.6/span) depending
+  on the hypervisor features available.
+/p
+p
+  You can provide the amount of video memory in kibibytes (blocks of
+  1024 bytes) using codevram/code. This is supported only for guest
+  type of libxl, parallels, vbox, vmx and xen.
+/p
+p
+  The number of screen can be set using codeheads/code. This is
+  supported only for guests type of parallels, kvm, vbox and 
vmx.
+/p
+p
+  For guest type of kvm the optional attribute coderam/code
+  (span class=sincesince 1.0.2/span) is allowed for qxl type
+  only and specifies the size of the primary bar, while the optional
+  attribute codevram/code specifies the secondary bar size.
+  If ram or vram are not supplied a default value is used.
+/p
   /dd
 
   dtcodeacceleration/code/dt
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1b8efb1..042364a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9995,9 +9995,9 @@ virSysinfoParseXML(xmlNodePtr node,
 goto cleanup;
 }
 
-int
+unsigned int
 virDomainVideoDefaultRAM(const virDomainDef 

[libvirt] [PATCH 3/4] caps: introduce new qemu capability for vgamem_mb device property

2014-11-03 Thread Pavel Hrdina
Allow setting vgamem size for video devices.

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

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---
 src/qemu/qemu_capabilities.c |  41 
 src/qemu/qemu_capabilities.h |   5 +
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps |   4 +
 tests/qemucapabilitiesdata/caps_1.2.2-1.replies  | 232 -
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps |   5 +
 tests/qemucapabilitiesdata/caps_1.3.1-1.replies  | 248 ++-
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps |   5 +
 tests/qemucapabilitiesdata/caps_1.4.2-1.replies  | 248 ++-
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps |   5 +
 tests/qemucapabilitiesdata/caps_1.5.3-1.replies  | 248 ++-
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps |   5 +
 tests/qemucapabilitiesdata/caps_1.6.0-1.replies  | 248 ++-
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps|   5 +
 tests/qemucapabilitiesdata/caps_1.6.50-1.replies | 248 ++-
 tests/qemucapabilitiesdata/caps_2.1.1-1.caps |   5 +
 tests/qemucapabilitiesdata/caps_2.1.1-1.replies  | 248 ++-
 16 files changed, 1751 insertions(+), 49 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b6c0f1b..b241ecc 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -271,6 +271,12 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   iothread,
   migrate-rdma,
   ivshmem,
+  cirrus-vga.vgamem_mb,
+
+  qxl.vgamem_mb, /* 180 */
+  qxl-vga.vgamem_mb,
+  VGA.vgamem_mb,
+  vmware-svga.vgamem_mb,
 );
 
 
@@ -1571,6 +1577,26 @@ static struct virQEMUCapsStringFlags 
virQEMUCapsObjectPropsKVMPit[] = {
 { lost_tick_policy, QEMU_CAPS_KVM_PIT_TICK_POLICY },
 };
 
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsCirrusVga[] = {
+{ vgamem_mb, QEMU_CAPS_CIRRUS_VGA_VGAMEM },
+};
+
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxl[] = {
+{ vgamem_mb, QEMU_CAPS_QXL_VGAMEM },
+};
+
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxlVga[] = {
+{ vgamem_mb, QEMU_CAPS_QXL_VGA_VGAMEM },
+};
+
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVGA[] = {
+{ vgamem_mb, QEMU_CAPS_VGA_VGAMEM },
+};
+
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVmwareSvga[] = {
+{ vgamem_mb, QEMU_CAPS_VMWARE_SVGA_VGAMEM },
+};
+
 struct virQEMUCapsObjectTypeProps {
 const char *type;
 struct virQEMUCapsStringFlags *props;
@@ -1616,6 +1642,16 @@ static struct virQEMUCapsObjectTypeProps 
virQEMUCapsObjectProps[] = {
   ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBStorage) },
 { kvm-pit, virQEMUCapsObjectPropsKVMPit,
   ARRAY_CARDINALITY(virQEMUCapsObjectPropsKVMPit) },
+{ cirrus-vga, virQEMUCapsObjectPropsCirrusVga,
+  ARRAY_CARDINALITY(virQEMUCapsObjectPropsCirrusVga) },
+{ qxl, virQEMUCapsObjectPropsQxl,
+  ARRAY_CARDINALITY(virQEMUCapsObjectPropsQxl) },
+{ qxl-vga, virQEMUCapsObjectPropsQxlVga,
+  ARRAY_CARDINALITY(virQEMUCapsObjectPropsQxlVga) },
+{ VGA, virQEMUCapsObjectPropsVGA,
+  ARRAY_CARDINALITY(virQEMUCapsObjectPropsVGA) },
+{ vmware-svga, virQEMUCapsObjectPropsVmwareSvga,
+  ARRAY_CARDINALITY(virQEMUCapsObjectPropsVmwareSvga) },
 };
 
 
@@ -1807,6 +1843,11 @@ virQEMUCapsExtractDeviceStr(const char *qemu,
  -device, usb-host,?,
  -device, scsi-generic,?,
  -device, usb-storage,?,
+ -device, cirrus-vga,?,
+ -device, qxl,?,
+ -device, qxl-vga,?,
+ -device, VGA,?,
+ -device, vmware-svga,?,
  NULL);
 /* qemu -help goes to stdout, but qemu -device ? goes to stderr.  */
 virCommandSetErrorBuffer(cmd, output);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index c0e2172..334f844 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -218,6 +218,11 @@ typedef enum {
 QEMU_CAPS_OBJECT_IOTHREAD= 176, /* -object iothread */
 QEMU_CAPS_MIGRATE_RDMA   = 177, /* have rdma migration */
 QEMU_CAPS_DEVICE_IVSHMEM = 178, /* -device ivshmem */
+QEMU_CAPS_CIRRUS_VGA_VGAMEM  = 179, /* -device cirrus-vga.vgamem_mb */
+QEMU_CAPS_QXL_VGAMEM = 180, /* -device qxl.vgamem_mb */
+QEMU_CAPS_QXL_VGA_VGAMEM = 181, /* -device qxl-vga.vgamem_mb */
+QEMU_CAPS_VGA_VGAMEM = 182, /* -device VGA.vgamem_mb */
+QEMU_CAPS_VMWARE_SVGA_VGAMEM = 183, /* -device vmware-svga.vgamem_mb */
 
 QEMU_CAPS_LAST,   /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git 

[libvirt] [PATCH 2/4] qxl: fix setting ram and vram values for qemu qxl device

2014-11-03 Thread Pavel Hrdina
QEMU has two different type of QXL display device. The first qxl-vga
is for primary video device and second qxl is for secondary video
device.

There are also two different ways how to specify those devices on qemu
command line, the first one and obsolete is using -vga option and the
current new one is using -device option. The -vga could be used only
to setup primary video device, so the -vga qxl equal to
-device qxl-vga. Unfortunately the -vga qxl doesn't support setting
additional parameters for the device and -global option must be used
for this purpose. It's mandatory to use -global qxl-vga to set the
parameters of primary video device previously defined with -vga qxl.

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

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---
 src/qemu/qemu_command.c | 4 ++--
 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args | 2 +-
 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.args| 4 ++--
 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args | 4 ++--
 tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args  | 2 +-
 tests/qemuxml2argvdata/qemuxml2argv-q35.args| 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a271997..92d6a8f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9267,11 +9267,11 @@ qemuBuildCommandLine(virConnectPtr conn,
 
 virCommandAddArgList(cmd, -vga, vgastr, NULL);
 
+const char *dev = 
qemuDeviceVideoTypeToString(primaryVideoType);
+
 if (def-videos[0]-type == VIR_DOMAIN_VIDEO_TYPE_QXL 
 (def-videos[0]-vram || def-videos[0]-ram) 
 virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-const char *dev = (virQEMUCapsGet(qemuCaps, 
QEMU_CAPS_DEVICE_QXL_VGA)
-   ? qxl-vga : qxl);
 unsigned int ram = def-videos[0]-ram;
 unsigned int vram = def-videos[0]-vram;
 
diff --git 
a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args 
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
index 59f064b..ac8e316 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
@@ -6,6 +6,6 @@ x509-dir=/etc/pki/libvirt-spice,\
 image-compression=auto_glz,jpeg-wan-compression=auto,\
 zlib-glz-wan-compression=auto,\
 playback-compression=on,streaming-video=filter -vga \
-qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368 \
+qxl -global qxl-vga.ram_size=67108864 -global qxl-vga.vram_size=18874368 \
 -device qxl,id=video1,ram_size=67108864,vram_size=33554432,bus=pci.0,addr=0x4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.args 
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.args
index 8847bce..3a73588 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.args
@@ -5,5 +5,5 @@ SASL_CONF_PATH=/root/.sasl2 QEMU_AUDIO_DRV=spice \
 /dev/HostVG/QEMUGuest1 \
 -spice port=5903,tls-port=5904,sasl,addr=127.0.0.1,\
 x509-dir=/etc/pki/libvirt-spice,tls-channel=default \
--vga qxl -global qxl.ram_size=67108864 -global \
-qxl.vram_size=18874368 -device 
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-vga qxl -global qxl-vga.ram_size=67108864 -global qxl-vga.vram_size=18874368 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args 
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
index 8430d9c..f2c2dcc 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
@@ -7,7 +7,7 @@ plaintext-channel=inputs,\
 image-compression=auto_glz,jpeg-wan-compression=auto,\
 zlib-glz-wan-compression=auto,\
 playback-compression=on,streaming-video=filter,disable-copy-paste,\
-disable-agent-file-xfer -vga qxl -global qxl.ram_size=67108864 \
--global qxl.vram_size=18874368 \
+disable-agent-file-xfer -vga qxl -global qxl-vga.ram_size=67108864 \
+-global qxl-vga.vram_size=18874368 \
 -device qxl,id=video1,ram_size=67108864,vram_size=33554432,bus=pci.0,addr=0x4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args 
b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args
index 6855cd2..ad72d15 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args
@@ -6,4 +6,4 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test 
QEMU_AUDIO_DRV=none \
 -device 

[libvirt] [PATCH 4/4] qemu-command: introduce new vgamem attribute for video devices

2014-11-03 Thread Pavel Hrdina
So far we hadn't any option to set video memory size for qemu video
devices. There were only vram (ram for QXL) attribute but it was valid
only for QXL video device, but it didn't set video memory only pci bar
memory.

To provide this feature to users qemu has dedicated device attribute
called 'vgamem_mb' to set the video memory size. We will export this
attribute as 'vgamem' and it will be in KiB (internally converted to MiB
to pass the value in correct format for QEMU). It's only supported by
those video devices: cirrus, qxl, vga and vmvga.

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

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---
 docs/formatdomain.html.in  |  7 +++-
 docs/schemas/domaincommon.rng  |  5 +++
 src/conf/domain_conf.c | 47 ++
 src/conf/domain_conf.h |  2 +
 src/libvirt_private.syms   |  1 +
 src/qemu/qemu_command.c| 45 +
 ...qemuhotplug-console-compat-2+console-virtio.xml |  2 +-
 .../qemuxml2argv-console-compat-2.xml  |  2 +-
 .../qemuxml2argv-graphics-listen-network.xml   |  2 +-
 .../qemuxml2argv-graphics-sdl-fullscreen.xml   |  2 +-
 .../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml |  2 +-
 .../qemuxml2argv-graphics-spice-compression.xml|  4 +-
 .../qemuxml2argv-graphics-spice-qxl-vga.xml|  4 +-
 .../qemuxml2argv-graphics-spice.xml|  4 +-
 .../qemuxml2argv-graphics-vnc-policy.xml   |  2 +-
 .../qemuxml2argv-graphics-vnc-sasl.xml |  2 +-
 .../qemuxml2argv-graphics-vnc-socket.xml   |  2 +-
 .../qemuxml2argv-graphics-vnc-tls.xml  |  2 +-
 .../qemuxml2argv-graphics-vnc-websocket.xml|  2 +-
 .../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml |  2 +-
 .../qemuxml2argv-net-bandwidth.xml |  2 +-
 tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml |  2 +-
 .../qemuxml2argv-pcihole64-q35.xml |  2 +-
 .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml |  2 +-
 .../qemuxml2argv-serial-spiceport.xml  |  2 +-
 .../qemuxml2argv-video-qxl-device-vgamem.args  |  6 +++
 .../qemuxml2argv-video-qxl-device-vgamem.xml   | 29 +
 .../qemuxml2argv-video-qxl-device.args |  6 +++
 .../qemuxml2argv-video-qxl-device.xml  | 29 +
 .../qemuxml2argv-video-qxl-nodevice.args   |  5 +++
 .../qemuxml2argv-video-qxl-nodevice.xml| 29 +
 .../qemuxml2argv-video-qxl-sec-device-vgamem.args  |  8 
 .../qemuxml2argv-video-qxl-sec-device-vgamem.xml   | 32 +++
 .../qemuxml2argv-video-qxl-sec-device.args |  7 
 .../qemuxml2argv-video-qxl-sec-device.xml  | 32 +++
 .../qemuxml2argv-video-qxl-sec-nodevice.xml| 32 +++
 .../qemuxml2argv-video-vga-device-vgamem.args  |  6 +++
 .../qemuxml2argv-video-vga-device-vgamem.xml   | 29 +
 .../qemuxml2argv-video-vga-device.args |  6 +++
 .../qemuxml2argv-video-vga-device.xml  | 29 +
 .../qemuxml2argv-video-vga-nodevice.args   |  5 +++
 .../qemuxml2argv-video-vga-nodevice.xml| 29 +
 tests/qemuxml2argvtest.c   | 18 +
 .../qemuxml2xmlout-graphics-listen-network2.xml|  2 +-
 .../qemuxml2xmlout-graphics-spice-timeout.xml  |  2 +-
 .../qemuxml2xmlout-pci-autoadd-addr.xml|  2 +-
 .../qemuxml2xmlout-pci-autoadd-idx.xml |  2 +-
 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml|  2 +-
 ...emuxml2xmlout-seclabel-dynamic-none-relabel.xml |  2 +-
 49 files changed, 471 insertions(+), 29 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-nodevice.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.args
 create mode 

[libvirt] [PATCH 0/4] [RFE] introduce new vgamem attribute for video devices

2014-11-03 Thread Pavel Hrdina
This patch series fixes few issues with vram and ram attributes for video
devices and introduces new vgamem attribute to allow setting up video memory
size for QEMU video devices.

Pavel Hrdina (4):
  video: cleanup usage of vram attribute and update documentation
  qxl: fix setting ram and vram values for qemu qxl device
  caps: introduce new qemu capability for vgamem_mb device property
  qemu-command: introduce new vgamem attribute for video devices

 docs/formatdomain.html.in  |  68 --
 docs/schemas/domaincommon.rng  |   5 +
 src/conf/domain_conf.c |  66 +-
 src/conf/domain_conf.h |   5 +-
 src/libvirt_private.syms   |   1 +
 src/qemu/qemu_capabilities.c   |  41 
 src/qemu/qemu_capabilities.h   |   5 +
 src/qemu/qemu_command.c|  53 -
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps   |   4 +
 tests/qemucapabilitiesdata/caps_1.2.2-1.replies| 232 ++-
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps   |   5 +
 tests/qemucapabilitiesdata/caps_1.3.1-1.replies| 248 -
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps   |   5 +
 tests/qemucapabilitiesdata/caps_1.4.2-1.replies| 248 -
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps   |   5 +
 tests/qemucapabilitiesdata/caps_1.5.3-1.replies| 248 -
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps   |   5 +
 tests/qemucapabilitiesdata/caps_1.6.0-1.replies| 248 -
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps  |   5 +
 tests/qemucapabilitiesdata/caps_1.6.50-1.replies   | 248 -
 tests/qemucapabilitiesdata/caps_2.1.1-1.caps   |   5 +
 tests/qemucapabilitiesdata/caps_2.1.1-1.replies| 248 -
 ...qemuhotplug-console-compat-2+console-virtio.xml |   2 +-
 .../qemuxml2argv-console-compat-2.xml  |   2 +-
 .../qemuxml2argv-graphics-listen-network.xml   |   2 +-
 .../qemuxml2argv-graphics-sdl-fullscreen.xml   |   2 +-
 .../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml |   2 +-
 .../qemuxml2argv-graphics-spice-compression.args   |   2 +-
 .../qemuxml2argv-graphics-spice-compression.xml|   4 +-
 .../qemuxml2argv-graphics-spice-qxl-vga.xml|   4 +-
 .../qemuxml2argv-graphics-spice-sasl.args  |   4 +-
 .../qemuxml2argv-graphics-spice.args   |   4 +-
 .../qemuxml2argv-graphics-spice.xml|   4 +-
 .../qemuxml2argv-graphics-vnc-policy.xml   |   2 +-
 .../qemuxml2argv-graphics-vnc-sasl.xml |   2 +-
 .../qemuxml2argv-graphics-vnc-socket.xml   |   2 +-
 .../qemuxml2argv-graphics-vnc-tls.xml  |   2 +-
 .../qemuxml2argv-graphics-vnc-websocket.xml|   2 +-
 .../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml |   2 +-
 .../qemuxml2argv-net-bandwidth.xml |   2 +-
 tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml |   2 +-
 .../qemuxml2argv-pcihole64-q35.args|   2 +-
 .../qemuxml2argv-pcihole64-q35.xml |   2 +-
 .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml |   2 +-
 tests/qemuxml2argvdata/qemuxml2argv-q35.args   |   2 +-
 .../qemuxml2argv-serial-spiceport.xml  |   2 +-
 .../qemuxml2argv-video-qxl-device-vgamem.args  |   6 +
 .../qemuxml2argv-video-qxl-device-vgamem.xml   |  29 +++
 .../qemuxml2argv-video-qxl-device.args |   6 +
 .../qemuxml2argv-video-qxl-device.xml  |  29 +++
 .../qemuxml2argv-video-qxl-nodevice.args   |   5 +
 .../qemuxml2argv-video-qxl-nodevice.xml|  29 +++
 .../qemuxml2argv-video-qxl-sec-device-vgamem.args  |   8 +
 .../qemuxml2argv-video-qxl-sec-device-vgamem.xml   |  32 +++
 .../qemuxml2argv-video-qxl-sec-device.args |   7 +
 .../qemuxml2argv-video-qxl-sec-device.xml  |  32 +++
 .../qemuxml2argv-video-qxl-sec-nodevice.xml|  32 +++
 .../qemuxml2argv-video-vga-device-vgamem.args  |   6 +
 .../qemuxml2argv-video-vga-device-vgamem.xml   |  29 +++
 .../qemuxml2argv-video-vga-device.args |   6 +
 .../qemuxml2argv-video-vga-device.xml  |  29 +++
 .../qemuxml2argv-video-vga-nodevice.args   |   5 +
 .../qemuxml2argv-video-vga-nodevice.xml|  29 +++
 tests/qemuxml2argvtest.c   |  18 ++
 .../qemuxml2xmlout-graphics-listen-network2.xml|   2 +-
 .../qemuxml2xmlout-graphics-spice-timeout.xml  |   2 +-
 .../qemuxml2xmlout-pci-autoadd-addr.xml|   2 +-
 .../qemuxml2xmlout-pci-autoadd-idx.xml |   2 +-
 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml|   2 +-
 ...emuxml2xmlout-seclabel-dynamic-none-relabel.xml |   2 +-
 70 files changed, 2288 insertions(+), 117 deletions(-)
 create mode 100644 

Re: [libvirt] [PATCH v4 1/3] bitmap: add virBitmapLastSetBit for finding the last bit position of bitmap

2014-11-03 Thread Martin Kletzander

On Thu, Oct 30, 2014 at 01:44:17PM +0800, Chen Fan wrote:

Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
src/libvirt_private.syms |  1 +
src/util/virbitmap.c | 45 +
src/util/virbitmap.h |  3 +++
tests/virbitmaptest.c| 13 -
4 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d63a8f0..1e2bc0a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1011,6 +1011,7 @@ virBitmapFree;
virBitmapGetBit;
virBitmapIsAllClear;
virBitmapIsAllSet;
+virBitmapLastSetBit;
virBitmapNew;
virBitmapNewCopy;
virBitmapNewData;
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index b6bd074..3e7269e 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -651,6 +651,51 @@ virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos)
}

/**
+ * virBitmapLastSetBit:
+ * @bitmap: the bitmap
+ *
+ * Search for the last set bit in bitmap @bitmap.
+ *
+ * Returns the position of the found bit, or -1 if no bit found.


s/found/is set/


+ */
+ssize_t
+virBitmapLastSetBit(virBitmapPtr bitmap)
+{
+ssize_t i;
+int unusedBits;
+ssize_t sz;
+unsigned long bits;
+
+unusedBits = bitmap-map_len * VIR_BITMAP_BITS_PER_UNIT - bitmap-max_bit;
+
+sz = bitmap-map_len - 1;
+if (unusedBits  0) {
+bits = bitmap-map[sz]  (VIR_BITMAP_BIT(VIR_BITMAP_BITS_PER_UNIT - 
unusedBits) - 1);
+if (bits != 0)
+goto found;
+
+sz--;
+}
+
+for (; sz = 0; sz--) {
+bits = bitmap-map[sz];
+if (bits != 0)
+goto found;
+}
+
+if (bits == 0)
+return -1;
+
+found:


Missing space before label.  make syntax-check would tell you that
instead of me ;)


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

Re: [libvirt] [PATCH v4 0/3] add nodeset check in numatune

2014-11-03 Thread Martin Kletzander

On Thu, Oct 30, 2014 at 01:44:16PM +0800, Chen Fan wrote:

when setting elements memnode and nodeset in attribute numatune more
than the host nodes in XML file, VM boot should fail. so add check for
that.



You should run make syntax-check and make check on those patches,
it would find at least two things ;)

Anyway, ACK series with the changes I mentioned.  If you're OK with
them, I'll push the series.

Martin


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

Re: [libvirt] [PATCH v4 3/3] virnuma: use virNumaNodesetIsAvailable checking nodeset in virNumaSetupMemoryPolicy

2014-11-03 Thread Martin Kletzander

On Thu, Oct 30, 2014 at 01:44:19PM +0800, Chen Fan wrote:

Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
src/util/virnuma.c | 23 ---
1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 4188ef5..613a43c 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -95,31 +95,19 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
int ret = -1;
int bit = 0;
size_t i;
-int maxnode = 0;
virBitmapPtr tmp_nodemask = NULL;

+if (!virNumaNodesetIsAvailable(numatune))
+return -1;
+
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);
}



I think this is safe, numad returning nodeset that's not on the host
would be weird error and it is easy to find in the logs.


@@ -347,10 +335,7 @@ int
virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
 virBitmapPtr nodemask ATTRIBUTE_UNUSED)
{
-if (virDomainNumatuneGetNodeset(numatune, NULL, -1)) {
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(libvirt is compiled without NUMA tuning support));
-
+if (!virNumaNodesetIsAvailable(numatune)) {
return -1;
}


This makes the square brackets obsolete.


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

Re: [libvirt] [PATCH v4 2/3] numatune: add check for numatune nodeset range

2014-11-03 Thread Martin Kletzander

On Thu, Oct 30, 2014 at 01:44:18PM +0800, Chen Fan wrote:

There was no check for 'nodeset' attribute in numatune-related
elements.  This patch adds validation that any nodeset specified does
not exceed maximum host node.

Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
src/conf/numatune_conf.c   | 28 
src/conf/numatune_conf.h   |  1 +
src/libvirt_private.syms   |  1 +
src/qemu/qemu_command.c|  4 +++
src/util/virnuma.c | 38 ++
src/util/virnuma.h |  1 +
...rgv-numatune-static-nodeset-exceed-hostnode.xml | 36 
tests/qemuxml2argvmock.c   |  9 +
tests/qemuxml2argvtest.c   |  1 +
9 files changed, 119 insertions(+)
create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-numatune-static-nodeset-exceed-hostnode.xml

diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
index 21d9a64..6986739 100644
--- a/src/conf/numatune_conf.c
+++ b/src/conf/numatune_conf.c
@@ -612,3 +612,31 @@ virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr 
numatune)

return false;
}
+
+int
+virDomainNumatuneSpecifiedMaxNode(virDomainNumatunePtr numatune)
+{
+int ret = -1;
+virBitmapPtr nodemask = NULL;
+size_t i;
+int bit;
+
+if (!numatune)
+return ret;
+
+nodemask = virDomainNumatuneGetNodeset(numatune, NULL, -1);
+if (nodemask)
+ret = virBitmapLastSetBit(nodemask);
+
+for (i = 0; i  numatune-nmem_nodes; i++) {
+nodemask = numatune-mem_nodes[i].nodeset;
+if (!nodemask)
+continue;
+
+bit = virBitmapLastSetBit(nodemask);
+if (bit  ret)
+ret = bit;
+}
+
+return ret;
+}
diff --git a/src/conf/numatune_conf.h b/src/conf/numatune_conf.h
index 5254629..15dc0d6 100644
--- a/src/conf/numatune_conf.h
+++ b/src/conf/numatune_conf.h
@@ -102,4 +102,5 @@ bool virDomainNumatuneHasPlacementAuto(virDomainNumatunePtr 
numatune);

bool virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr numatune);

+int virDomainNumatuneSpecifiedMaxNode(virDomainNumatunePtr numatune);
#endif /* __NUMATUNE_CONF_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1e2bc0a..4a30ad7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1729,6 +1729,7 @@ virNumaGetPageInfo;
virNumaGetPages;
virNumaIsAvailable;
virNumaNodeIsAvailable;
+virNumaNodesetIsAvailable;
virNumaSetPagePoolSize;
virNumaSetupMemoryPolicy;

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2e5af4f..d2c5f0c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -53,6 +53,7 @@
#include virstoragefile.h
#include virtpm.h
#include virscsi.h
+#include virnuma.h
#if defined(__linux__)
# include linux/capability.h
#endif
@@ -6663,6 +6664,9 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
goto cleanup;
}

+if (!virNumaNodesetIsAvailable(def-numatune))
+goto cleanup;
+
for (i = 0; i  def-mem.nhugepages; i++) {
ssize_t next_bit, pos = 0;

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 690615f..4188ef5 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -165,6 +165,33 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
return ret;
}

+bool
+virNumaNodesetIsAvailable(virDomainNumatunePtr numatune)
+{
+int maxnode;
+int bit;
+
+if (!numatune)
+return true;
+
+bit = virDomainNumatuneSpecifiedMaxNode(numatune);
+if (bit == -1)


(bit  0) would go with the rest of the code, the functions can be
then modified to report various kinds of errors more easily.


+return true;
+
+if ((maxnode = virNumaGetMaxNode())  0)
+return false;
+
+maxnode = maxnode  NUMA_NUM_NODES ? maxnode : NUMA_NUM_NODES;
+if (bit  maxnode)
+goto error;
+
+return true;
+
+ error:
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(NUMA node %d is out of range), bit);
+return false;
+}

bool
virNumaIsAvailable(void)
@@ -330,6 +357,17 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
return 0;
}

+bool
+virNumaNodesetIsAvailable(virDomainNumatunePtr numatune)
+{
+if (virDomainNumatuneSpecifiedMaxNode(numatune) != -1) {


similarly  = 0 here.


+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(libvirt is compiled without NUMA tuning support));
+return false;
+}
+
+return true;
+}

bool
virNumaIsAvailable(void)
diff --git a/src/util/virnuma.h b/src/util/virnuma.h
index 04b6b8c..5bb37b8 100644
--- a/src/util/virnuma.h
+++ b/src/util/virnuma.h
@@ -34,6 +34,7 @@ char *virNumaGetAutoPlacementAdvice(unsigned short vcups,
int virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
 virBitmapPtr nodemask);

+bool 

Re: [libvirt] [Nbd] [Qemu-devel] spec, RFC: TLS support for NBDµ

2014-11-03 Thread Stefan Hajnoczi
On Fri, Oct 31, 2014 at 07:15:08PM +0100, Wouter Verhelst wrote:
 On Thu, Oct 30, 2014 at 10:40:56AM +, Stefan Hajnoczi wrote:
  Also, I suggest at least developing a prototype before releasing the
  specification changes.  Issues that were unknown ahead of time might be
  discovered during development.
 
 Yeah, that's fair enough.
 
  Why the rush to release specification changes?
 
 Not really a rush, I just thought it might be useful. But I suppose
 you're right.
 
 Note that I'm not likely to be implementing this soon. I haven't got
 much time right now, and it would be my first time to implement
 something which uses TLS; so I would need to do some research in that
 area first.

Hi Wouter,
That's fine, thanks for putting together the draft spec.

If someone I work with starts implementing NBD TLS we'll follow your
spec and continue developing/discussing on the mailing list.

Thanks,
Stefan


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

Re: [libvirt] [PATCH] examples: add systemtap script to ease lock debugging

2014-11-03 Thread Michal Privoznik

On 29.10.2014 14:44, Martin Kletzander wrote:

As discussed before, this simple script should help with debugging
deadlocks, although there are still some caveats.  RWLocks are not
handled by this and if your deadlock if very racy, it may not lock
up when running with this script due to the slowdown.

Signed-off-by: Martin Kletzander mklet...@redhat.com
---
  examples/systemtap/lock-debug.stp | 118 ++
  1 file changed, 118 insertions(+)
  create mode 100644 examples/systemtap/lock-debug.stp


ACK. Cool idea.

Michal

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


[libvirt] [PATCH] vbox: Prevent from registering storage driver with NULL

2014-11-03 Thread Taowei Luo
Since 5892944fc853 the virRegisterStorageDriver may be called with
a NULL storageDriver if it failed on vboxGetStorageDriver.
So make sure the storageDriver is not NULL before register.

---
 src/vbox/vbox_driver.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index c64d2d6..b2e35e9 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -74,7 +74,7 @@ int vboxStorageRegister(void)
 if (VBoxCGlueInit(uVersion) == 0)
 storageDriver = vboxGetStorageDriver(uVersion);
 
-if (virRegisterStorageDriver(storageDriver)  0)
+if (storageDriver  virRegisterStorageDriver(storageDriver)  0)
 return -1;
 return 0;
 }
-- 
1.7.9.5

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


Re: [libvirt] [PATCH] vbox: Prevent from registering storage driver with NULL

2014-11-03 Thread Martin Kletzander

On Mon, Nov 03, 2014 at 11:32:41PM +0800, Taowei Luo wrote:

Since 5892944fc853 the virRegisterStorageDriver may be called with
a NULL storageDriver if it failed on vboxGetStorageDriver.
So make sure the storageDriver is not NULL before register.

---
src/vbox/vbox_driver.c |2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



Already in as commit v1.2.10-3-g55bbc34 that was waiting post release:

commit 55bbc342183a721170be641efac6166bb0cf65d9
Author: Martin Kletzander mklet...@redhat.com
Date:   Thu Oct 30 09:56:26 2014 +0100

   vbox: don't register NULL driver


diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index c64d2d6..b2e35e9 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -74,7 +74,7 @@ int vboxStorageRegister(void)
if (VBoxCGlueInit(uVersion) == 0)
storageDriver = vboxGetStorageDriver(uVersion);

-if (virRegisterStorageDriver(storageDriver)  0)
+if (storageDriver  virRegisterStorageDriver(storageDriver)  0)
return -1;
return 0;
}
--
1.7.9.5

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


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

Re: [libvirt] [PATCH v4 1/3] bitmap: add virBitmapLastSetBit for finding the last bit position of bitmap

2014-11-03 Thread Chen, Fan
On Mon, 2014-11-03 at 14:18 +0100, Martin Kletzander wrote: 
 On Thu, Oct 30, 2014 at 01:44:17PM +0800, Chen Fan wrote:
 Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
 ---
  src/libvirt_private.syms |  1 +
  src/util/virbitmap.c | 45 +
  src/util/virbitmap.h |  3 +++
  tests/virbitmaptest.c| 13 -
  4 files changed, 61 insertions(+), 1 deletion(-)
 
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index d63a8f0..1e2bc0a 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1011,6 +1011,7 @@ virBitmapFree;
  virBitmapGetBit;
  virBitmapIsAllClear;
  virBitmapIsAllSet;
 +virBitmapLastSetBit;
  virBitmapNew;
  virBitmapNewCopy;
  virBitmapNewData;
 diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
 index b6bd074..3e7269e 100644
 --- a/src/util/virbitmap.c
 +++ b/src/util/virbitmap.c
 @@ -651,6 +651,51 @@ virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos)
  }
 
  /**
 + * virBitmapLastSetBit:
 + * @bitmap: the bitmap
 + *
 + * Search for the last set bit in bitmap @bitmap.
 + *
 + * Returns the position of the found bit, or -1 if no bit found.
 
 s/found/is set/
 
 + */
 +ssize_t
 +virBitmapLastSetBit(virBitmapPtr bitmap)
 +{
 +ssize_t i;
 +int unusedBits;
 +ssize_t sz;
 +unsigned long bits;
 +
 +unusedBits = bitmap-map_len * VIR_BITMAP_BITS_PER_UNIT - 
 bitmap-max_bit;
 +
 +sz = bitmap-map_len - 1;
 +if (unusedBits  0) {
 +bits = bitmap-map[sz]  (VIR_BITMAP_BIT(VIR_BITMAP_BITS_PER_UNIT - 
 unusedBits) - 1);
 +if (bits != 0)
 +goto found;
 +
 +sz--;
 +}
 +
 +for (; sz = 0; sz--) {
 +bits = bitmap-map[sz];
 +if (bits != 0)
 +goto found;
 +}
 +
 +if (bits == 0)
 +return -1;
 +
 +found:
 
 Missing space before label.  make syntax-check would tell you that
 instead of me ;)

Thanks for your remind. I will do that.

Chen


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


Re: [libvirt] [PATCH v4 2/3] numatune: add check for numatune nodeset range

2014-11-03 Thread Chen, Fan
On Mon, 2014-11-03 at 14:18 +0100, Martin Kletzander wrote: 
 On Thu, Oct 30, 2014 at 01:44:18PM +0800, Chen Fan wrote:
 There was no check for 'nodeset' attribute in numatune-related
 elements.  This patch adds validation that any nodeset specified does
 not exceed maximum host node.
 
 Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
 ---
  src/conf/numatune_conf.c   | 28 
  src/conf/numatune_conf.h   |  1 +
  src/libvirt_private.syms   |  1 +
  src/qemu/qemu_command.c|  4 +++
  src/util/virnuma.c | 38 
  ++
  src/util/virnuma.h |  1 +
  ...rgv-numatune-static-nodeset-exceed-hostnode.xml | 36 
  tests/qemuxml2argvmock.c   |  9 +
  tests/qemuxml2argvtest.c   |  1 +
  9 files changed, 119 insertions(+)
  create mode 100644 
  tests/qemuxml2argvdata/qemuxml2argv-numatune-static-nodeset-exceed-hostnode.xml
 
 diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
 index 21d9a64..6986739 100644
 --- a/src/conf/numatune_conf.c
 +++ b/src/conf/numatune_conf.c
 @@ -612,3 +612,31 @@ virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr 
 numatune)
 
  return false;
  }
 +
 +int
 +virDomainNumatuneSpecifiedMaxNode(virDomainNumatunePtr numatune)
 +{
 +int ret = -1;
 +virBitmapPtr nodemask = NULL;
 +size_t i;
 +int bit;
 +
 +if (!numatune)
 +return ret;
 +
 +nodemask = virDomainNumatuneGetNodeset(numatune, NULL, -1);
 +if (nodemask)
 +ret = virBitmapLastSetBit(nodemask);
 +
 +for (i = 0; i  numatune-nmem_nodes; i++) {
 +nodemask = numatune-mem_nodes[i].nodeset;
 +if (!nodemask)
 +continue;
 +
 +bit = virBitmapLastSetBit(nodemask);
 +if (bit  ret)
 +ret = bit;
 +}
 +
 +return ret;
 +}
 diff --git a/src/conf/numatune_conf.h b/src/conf/numatune_conf.h
 index 5254629..15dc0d6 100644
 --- a/src/conf/numatune_conf.h
 +++ b/src/conf/numatune_conf.h
 @@ -102,4 +102,5 @@ bool 
 virDomainNumatuneHasPlacementAuto(virDomainNumatunePtr numatune);
 
  bool virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr numatune);
 
 +int virDomainNumatuneSpecifiedMaxNode(virDomainNumatunePtr numatune);
  #endif /* __NUMATUNE_CONF_H__ */
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 1e2bc0a..4a30ad7 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1729,6 +1729,7 @@ virNumaGetPageInfo;
  virNumaGetPages;
  virNumaIsAvailable;
  virNumaNodeIsAvailable;
 +virNumaNodesetIsAvailable;
  virNumaSetPagePoolSize;
  virNumaSetupMemoryPolicy;
 
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index 2e5af4f..d2c5f0c 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -53,6 +53,7 @@
  #include virstoragefile.h
  #include virtpm.h
  #include virscsi.h
 +#include virnuma.h
  #if defined(__linux__)
  # include linux/capability.h
  #endif
 @@ -6663,6 +6664,9 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
  goto cleanup;
  }
 
 +if (!virNumaNodesetIsAvailable(def-numatune))
 +goto cleanup;
 +
  for (i = 0; i  def-mem.nhugepages; i++) {
  ssize_t next_bit, pos = 0;
 
 diff --git a/src/util/virnuma.c b/src/util/virnuma.c
 index 690615f..4188ef5 100644
 --- a/src/util/virnuma.c
 +++ b/src/util/virnuma.c
 @@ -165,6 +165,33 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
  return ret;
  }
 
 +bool
 +virNumaNodesetIsAvailable(virDomainNumatunePtr numatune)
 +{
 +int maxnode;
 +int bit;
 +
 +if (!numatune)
 +return true;
 +
 +bit = virDomainNumatuneSpecifiedMaxNode(numatune);
 +if (bit == -1)
 
 (bit  0) would go with the rest of the code, the functions can be
 then modified to report various kinds of errors more easily.
 
 +return true;
 +
 +if ((maxnode = virNumaGetMaxNode())  0)
 +return false;
 +
 +maxnode = maxnode  NUMA_NUM_NODES ? maxnode : NUMA_NUM_NODES;
 +if (bit  maxnode)
 +goto error;
 +
 +return true;
 +
 + error:
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(NUMA node %d is out of range), bit);
 +return false;
 +}
 
  bool
  virNumaIsAvailable(void)
 @@ -330,6 +357,17 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
  return 0;
  }
 
 +bool
 +virNumaNodesetIsAvailable(virDomainNumatunePtr numatune)
 +{
 +if (virDomainNumatuneSpecifiedMaxNode(numatune) != -1) {
 
 similarly  = 0 here.
 
 +virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 +   _(libvirt is compiled without NUMA tuning 
 support));
 +return false;
 +}
 +
 +return true;
 +}
 
  bool
  virNumaIsAvailable(void)
 diff --git a/src/util/virnuma.h b/src/util/virnuma.h
 index 04b6b8c..5bb37b8 100644
 --- 

Re: [libvirt] [PATCH v4 3/3] virnuma: use virNumaNodesetIsAvailable checking nodeset in virNumaSetupMemoryPolicy

2014-11-03 Thread Chen, Fan
On Mon, 2014-11-03 at 14:18 +0100, Martin Kletzander wrote: 
 On Thu, Oct 30, 2014 at 01:44:19PM +0800, Chen Fan wrote:
 Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
 ---
  src/util/virnuma.c | 23 ---
  1 file changed, 4 insertions(+), 19 deletions(-)
 
 diff --git a/src/util/virnuma.c b/src/util/virnuma.c
 index 4188ef5..613a43c 100644
 --- a/src/util/virnuma.c
 +++ b/src/util/virnuma.c
 @@ -95,31 +95,19 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
  int ret = -1;
  int bit = 0;
  size_t i;
 -int maxnode = 0;
  virBitmapPtr tmp_nodemask = NULL;
 
 +if (!virNumaNodesetIsAvailable(numatune))
 +return -1;
 +
  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);
  }
 
 
 I think this is safe, numad returning nodeset that's not on the host
 would be weird error and it is easy to find in the logs.
I think virNumaNodesetIsAvailable() has checked the case, but retain it 
here is ok.

 
 @@ -347,10 +335,7 @@ int
  virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
   virBitmapPtr nodemask ATTRIBUTE_UNUSED)
  {
 -if (virDomainNumatuneGetNodeset(numatune, NULL, -1)) {
 -virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 -   _(libvirt is compiled without NUMA tuning 
 support));
 -
 +if (!virNumaNodesetIsAvailable(numatune)) {
  return -1;
  }
 
 This makes the square brackets obsolete.


Thanks,
Chen


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


Re: [libvirt] [PATCH v4 0/3] add nodeset check in numatune

2014-11-03 Thread Chen, Fan
On Mon, 2014-11-03 at 14:18 +0100, Martin Kletzander wrote: 
 On Thu, Oct 30, 2014 at 01:44:16PM +0800, Chen Fan wrote:
 when setting elements memnode and nodeset in attribute numatune more
 than the host nodes in XML file, VM boot should fail. so add check for
 that.
 
 
 You should run make syntax-check and make check on those patches,
 it would find at least two things ;)
 
 Anyway, ACK series with the changes I mentioned.  If you're OK with
 them, I'll push the series.

I will send a new series after change them.
and Thanks for your review.

Chen


 
 Martin


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


[libvirt] [PATCH v5 2/3] numatune: add check for numatune nodeset range

2014-11-03 Thread Chen Fan
There was no check for 'nodeset' attribute in numatune-related
elements.  This patch adds validation that any nodeset specified does
not exceed maximum host node.

Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
 src/conf/numatune_conf.c   | 28 
 src/conf/numatune_conf.h   |  1 +
 src/libvirt_private.syms   |  1 +
 src/qemu/qemu_command.c|  4 +++
 src/util/virnuma.c | 38 ++
 src/util/virnuma.h |  1 +
 ...rgv-numatune-static-nodeset-exceed-hostnode.xml | 35 
 tests/qemuxml2argvmock.c   |  9 +
 tests/qemuxml2argvtest.c   |  2 ++
 9 files changed, 119 insertions(+)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-numatune-static-nodeset-exceed-hostnode.xml

diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
index 21d9a64..6986739 100644
--- a/src/conf/numatune_conf.c
+++ b/src/conf/numatune_conf.c
@@ -612,3 +612,31 @@ virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr 
numatune)
 
 return false;
 }
+
+int
+virDomainNumatuneSpecifiedMaxNode(virDomainNumatunePtr numatune)
+{
+int ret = -1;
+virBitmapPtr nodemask = NULL;
+size_t i;
+int bit;
+
+if (!numatune)
+return ret;
+
+nodemask = virDomainNumatuneGetNodeset(numatune, NULL, -1);
+if (nodemask)
+ret = virBitmapLastSetBit(nodemask);
+
+for (i = 0; i  numatune-nmem_nodes; i++) {
+nodemask = numatune-mem_nodes[i].nodeset;
+if (!nodemask)
+continue;
+
+bit = virBitmapLastSetBit(nodemask);
+if (bit  ret)
+ret = bit;
+}
+
+return ret;
+}
diff --git a/src/conf/numatune_conf.h b/src/conf/numatune_conf.h
index 5254629..15dc0d6 100644
--- a/src/conf/numatune_conf.h
+++ b/src/conf/numatune_conf.h
@@ -102,4 +102,5 @@ bool virDomainNumatuneHasPlacementAuto(virDomainNumatunePtr 
numatune);
 
 bool virDomainNumatuneHasPerNodeBinding(virDomainNumatunePtr numatune);
 
+int virDomainNumatuneSpecifiedMaxNode(virDomainNumatunePtr numatune);
 #endif /* __NUMATUNE_CONF_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1e2bc0a..4a30ad7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1729,6 +1729,7 @@ virNumaGetPageInfo;
 virNumaGetPages;
 virNumaIsAvailable;
 virNumaNodeIsAvailable;
+virNumaNodesetIsAvailable;
 virNumaSetPagePoolSize;
 virNumaSetupMemoryPolicy;
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2e5af4f..d2c5f0c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -53,6 +53,7 @@
 #include virstoragefile.h
 #include virtpm.h
 #include virscsi.h
+#include virnuma.h
 #if defined(__linux__)
 # include linux/capability.h
 #endif
@@ -6663,6 +6664,9 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
 goto cleanup;
 }
 
+if (!virNumaNodesetIsAvailable(def-numatune))
+goto cleanup;
+
 for (i = 0; i  def-mem.nhugepages; i++) {
 ssize_t next_bit, pos = 0;
 
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 690615f..2540bd2 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -165,6 +165,33 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
 return ret;
 }
 
+bool
+virNumaNodesetIsAvailable(virDomainNumatunePtr numatune)
+{
+int maxnode;
+int bit;
+
+if (!numatune)
+return true;
+
+bit = virDomainNumatuneSpecifiedMaxNode(numatune);
+if (bit  0)
+return true;
+
+if ((maxnode = virNumaGetMaxNode())  0)
+return false;
+
+maxnode = maxnode  NUMA_NUM_NODES ? maxnode : NUMA_NUM_NODES;
+if (bit  maxnode)
+goto error;
+
+return true;
+
+ error:
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(NUMA node %d is out of range), bit);
+return false;
+}
 
 bool
 virNumaIsAvailable(void)
@@ -330,6 +357,17 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
 return 0;
 }
 
+bool
+virNumaNodesetIsAvailable(virDomainNumatunePtr numatune)
+{
+if (virDomainNumatuneSpecifiedMaxNode(numatune) = 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(libvirt is compiled without NUMA tuning support));
+return false;
+}
+
+return true;
+}
 
 bool
 virNumaIsAvailable(void)
diff --git a/src/util/virnuma.h b/src/util/virnuma.h
index 04b6b8c..5bb37b8 100644
--- a/src/util/virnuma.h
+++ b/src/util/virnuma.h
@@ -34,6 +34,7 @@ char *virNumaGetAutoPlacementAdvice(unsigned short vcups,
 int virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
  virBitmapPtr nodemask);
 
+bool virNumaNodesetIsAvailable(virDomainNumatunePtr numatune);
 bool virNumaIsAvailable(void);
 int virNumaGetMaxNode(void);
 bool virNumaNodeIsAvailable(int node);
diff --git 

[libvirt] [PATCH v5 0/3] add nodeset check in numatune

2014-11-03 Thread Chen Fan
when setting elements memnode and nodeset in attribute numatune more
than the host nodes in XML file, VM boot should fail. so add check for
that.

Chen Fan (3):
  bitmap: add virBitmapLastSetBit for finding the last bit position of
bitmap
  numatune: add check for numatune nodeset range
  virnuma: use virNumaNodesetIsAvailable checking nodeset in
virNumaSetupMemoryPolicy

 src/conf/numatune_conf.c   | 28 
 src/conf/numatune_conf.h   |  1 +
 src/libvirt_private.syms   |  2 +
 src/qemu/qemu_command.c|  4 ++
 src/util/virbitmap.c   | 45 ++
 src/util/virbitmap.h   |  3 ++
 src/util/virnuma.c | 53 +-
 src/util/virnuma.h |  1 +
 ...rgv-numatune-static-nodeset-exceed-hostnode.xml | 35 ++
 tests/qemuxml2argvmock.c   |  9 
 tests/qemuxml2argvtest.c   |  2 +
 tests/virbitmaptest.c  | 13 +-
 12 files changed, 184 insertions(+), 12 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-numatune-static-nodeset-exceed-hostnode.xml

-- 
1.9.3

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


[libvirt] [PATCH v5 1/3] bitmap: add virBitmapLastSetBit for finding the last bit position of bitmap

2014-11-03 Thread Chen Fan
Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
 src/libvirt_private.syms |  1 +
 src/util/virbitmap.c | 45 +
 src/util/virbitmap.h |  3 +++
 tests/virbitmaptest.c| 13 -
 4 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d63a8f0..1e2bc0a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1011,6 +1011,7 @@ virBitmapFree;
 virBitmapGetBit;
 virBitmapIsAllClear;
 virBitmapIsAllSet;
+virBitmapLastSetBit;
 virBitmapNew;
 virBitmapNewCopy;
 virBitmapNewData;
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index b6bd074..04a2388 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -651,6 +651,51 @@ virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos)
 }
 
 /**
+ * virBitmapLastSetBit:
+ * @bitmap: the bitmap
+ *
+ * Search for the last set bit in bitmap @bitmap.
+ *
+ * Returns the position of the found bit, or -1 if no bit is set.
+ */
+ssize_t
+virBitmapLastSetBit(virBitmapPtr bitmap)
+{
+ssize_t i;
+int unusedBits;
+ssize_t sz;
+unsigned long bits;
+
+unusedBits = bitmap-map_len * VIR_BITMAP_BITS_PER_UNIT - bitmap-max_bit;
+
+sz = bitmap-map_len - 1;
+if (unusedBits  0) {
+bits = bitmap-map[sz]  (VIR_BITMAP_BIT(VIR_BITMAP_BITS_PER_UNIT - 
unusedBits) - 1);
+if (bits != 0)
+goto found;
+
+sz--;
+}
+
+for (; sz = 0; sz--) {
+bits = bitmap-map[sz];
+if (bits != 0)
+goto found;
+}
+
+if (bits == 0)
+return -1;
+
+ found:
+for (i = VIR_BITMAP_BITS_PER_UNIT - 1; i = 0; i--) {
+if (bits  1UL  i)
+return i + sz * VIR_BITMAP_BITS_PER_UNIT;
+}
+
+return -1;
+}
+
+/**
  * virBitmapNextClearBit:
  * @bitmap: the bitmap
  * @pos: the position after which to search for a clear bit
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
index 4493cc9..565264c 100644
--- a/src/util/virbitmap.h
+++ b/src/util/virbitmap.h
@@ -105,6 +105,9 @@ bool virBitmapIsAllClear(virBitmapPtr bitmap)
 ssize_t virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos)
 ATTRIBUTE_NONNULL(1);
 
+ssize_t virBitmapLastSetBit(virBitmapPtr bitmap)
+ATTRIBUTE_NONNULL(1);
+
 ssize_t virBitmapNextClearBit(virBitmapPtr bitmap, ssize_t pos)
 ATTRIBUTE_NONNULL(1);
 
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index ea832ad..ac5f298 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -171,7 +171,7 @@ test3(const void *data ATTRIBUTE_UNUSED)
 return ret;
 }
 
-/* test for virBitmapNextSetBit, virBitmapNextClearBit */
+/* test for virBitmapNextSetBit, virBitmapLastSetBit, virBitmapNextClearBit */
 static int
 test4(const void *data ATTRIBUTE_UNUSED)
 {
@@ -200,6 +200,9 @@ test4(const void *data ATTRIBUTE_UNUSED)
 if (virBitmapNextSetBit(bitmap, -1) != -1)
 goto error;
 
+if (virBitmapLastSetBit(bitmap) != -1)
+goto error;
+
 for (i = 0; i  size; i++) {
 if (virBitmapNextClearBit(bitmap, i - 1) != i)
 goto error;
@@ -232,6 +235,11 @@ test4(const void *data ATTRIBUTE_UNUSED)
 if (virBitmapNextSetBit(bitmap, i) != -1)
 goto error;
 
+j = sizeof(bitsPos)/sizeof(int) - 1;
+
+if (virBitmapLastSetBit(bitmap) != bitsPos[j])
+goto error;
+
 j = 0;
 i = -1;
 
@@ -255,6 +263,9 @@ test4(const void *data ATTRIBUTE_UNUSED)
 if (virBitmapNextSetBit(bitmap, i) != -1)
 goto error;
 
+if (virBitmapLastSetBit(bitmap) != size - 1)
+goto error;
+
 if (virBitmapNextClearBit(bitmap, -1) != -1)
 goto error;
 
-- 
1.9.3

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


[libvirt] [PATCH v5 3/3] virnuma: use virNumaNodesetIsAvailable checking nodeset in virNumaSetupMemoryPolicy

2014-11-03 Thread Chen Fan
Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
 src/util/virnuma.c | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 2540bd2..89435de 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -98,16 +98,13 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
 int maxnode = 0;
 virBitmapPtr tmp_nodemask = NULL;
 
+if (!virNumaNodesetIsAvailable(numatune))
+return -1;
+
 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;
 
@@ -347,12 +344,8 @@ int
 virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
  virBitmapPtr nodemask ATTRIBUTE_UNUSED)
 {
-if (virDomainNumatuneGetNodeset(numatune, NULL, -1)) {
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(libvirt is compiled without NUMA tuning support));
-
+if (!virNumaNodesetIsAvailable(numatune))
 return -1;
-}
 
 return 0;
 }
-- 
1.9.3

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


Re: [libvirt] [PATCH 2/2] qemu: migration: Ignore null ptr in qemuMigrationStopNBDServer

2014-11-03 Thread weiwei li
agree,I have tested the flag and it works well, i will post another patch
later.

Thanks very much!

2014-11-03 20:03 GMT+08:00 Ján Tomko jto...@redhat.com:

 On 11/03/2014 05:22 AM, weiwei li wrote:
  mig-nbd is initialized by qemuMigrationCookieXMLParse(called
  by qemuMigrationEatCookie),with a condition that
  the nbd infomation contained in Cookie string. I found in debug info
  that qemuMigrationStartNBDServer had been called in
  qemuMigrationPrepareAny(mig-nbd not null), but at
  in qemuMigrationFinish qemuMigrationStopNBDServer can not really
  stop nbd server bucause mig-nbd is not initialized(that is because
 cookie
  string does not contain nbd information ).
 
  so ,there are two solutions:
  1 qemuMigrationStopNBDServer  ignore mig-nbd null ptr
  2 add cookie info for nbd same stage (that is lost in which stage i am
 not sure~ )
 
  I choose an easy way solution 1 with least code changing, maybe is not
 google
  way :)
 
  cookie log is like this:
  2014-10-30 08:38:14.106+: 15078: debug : qemuMigrationRun:3254 :
  driver=0x7f936413cd40, vm=0x7f934400b850, cookiein=qemu-migration
name3cd4c349-e058-4a1a-8b3d-cc988efd11e2/name
uuid3cd4c349-e058-4a1a-8b3d-cc988efd11e2/uuid
hostname50e54929-059c---_10.180.39.36/hostname
hostuuid50e54929-059c---/hostuuid
   nbd port='49153'/
  /qemu-migration
 
  2014-10-30 08:39:12.527+: 15076: debug : virObjectRef:296 :
 OBJECT_REF:
  obj=0x7f9364138880
  2014-10-30 08:39:12.527+: 15076: debug : qemuMigrationFinish:4507 :
  driver=0x7f936413cd40, dconn=0x7f9358002720, vm=0x7f935c002da0,
  cookiein=qemu-migration
name3cd4c349-e058-4a1a-8b3d-cc988efd11e2/name
uuid3cd4c349-e058-4a1a-8b3d-cc988efd11e2/uuid
hostname50e54929-059c---_10.180.39.36/hostname
hostuuid50e54929-059c---/hostuuid
feature name='persistent'/

 ...

memballoon model='virtio'
  address type='pci' domain='0x' bus='0x00' slot='0x06'
  function='0x0'/
/memballoon
  /devices
/domain

nbd/

 So the nbd/ element is there, we just don't parse it because
 qemuMigrationFinish calls qemuMigrationEatCookie without the
 QEMU_MIGRATION_COOKIE_NBD flag.

 I believe the proper fix is to add this flag there.

 Jan

  /qemu-migration
  , cookieinlen=2567, cookieout=0x7f93722eab08,
 cookieoutlen=0x7f93722eab14,
  flags=289, retcode=0
 


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

[libvirt] [PATCH] qemu: fix up NBD Server can not be stopped properly

2014-11-03 Thread weiwei li
In qemuMigrationFinish mig-nbd can not be initialized by
qemuMigrationEatCookie without a flag QEMU_MIGRATION_COOKIE_NBD.
That cause qemuMigrationStopNBDServer return and the NBD server
can not be stopped properly.

Signed-off-by: Weiwei Li nuonu...@tencent.com
Signed-off-by: Ján Tomko jto...@redhat.com
---
 src/qemu/qemu_migration.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 13239eb..9cb2a06 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4822,7 +4822,8 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
 VIR_FREE(priv-job.completed);

 cookie_flags = QEMU_MIGRATION_COOKIE_NETWORK |
-   QEMU_MIGRATION_COOKIE_STATS;
+   QEMU_MIGRATION_COOKIE_STATS |
+   QEMU_MIGRATION_COOKIE_NBD;
 if (flags  VIR_MIGRATE_PERSIST_DEST)
 cookie_flags |= QEMU_MIGRATION_COOKIE_PERSISTENT;

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

Re: [libvirt] [PATCH v4 3/3] virnuma: use virNumaNodesetIsAvailable checking nodeset in virNumaSetupMemoryPolicy

2014-11-03 Thread Martin Kletzander

On Tue, Nov 04, 2014 at 02:05:16AM +, Chen, Fan wrote:

On Mon, 2014-11-03 at 14:18 +0100, Martin Kletzander wrote:

On Thu, Oct 30, 2014 at 01:44:19PM +0800, Chen Fan wrote:
Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
 src/util/virnuma.c | 23 ---
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 4188ef5..613a43c 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -95,31 +95,19 @@ virNumaSetupMemoryPolicy(virDomainNumatunePtr numatune,
 int ret = -1;
 int bit = 0;
 size_t i;
-int maxnode = 0;
 virBitmapPtr tmp_nodemask = NULL;

+if (!virNumaNodesetIsAvailable(numatune))


Here you call virNumaNodesetIsAvailable() with @numatune, but ...


+return -1;
+
 tmp_nodemask = virDomainNumatuneGetNodeset(numatune, nodemask, -1);


... here you can get the automatic one ...


I think this is safe, numad returning nodeset that's not on the host
would be weird error and it is easy to find in the logs.

I think virNumaNodesetIsAvailable() has checked the case, but retain it
here is ok.



... and that's what I meant here that it might be missed.  I would be
OK with the check removed though, since that should create no new
problems, but since you added it in the next version, I'll keep it
there ;)


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

Re: [libvirt] [PATCH v4 2/3] numatune: add check for numatune nodeset range

2014-11-03 Thread Martin Kletzander

On Tue, Nov 04, 2014 at 01:57:52AM +, Chen, Fan wrote:

On Mon, 2014-11-03 at 14:18 +0100, Martin Kletzander wrote:

On Thu, Oct 30, 2014 at 01:44:18PM +0800, Chen Fan wrote:
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index bff3b0f..7218747 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -21,6 +21,7 @@
 #include config.h

 #include internal.h
+#include virnuma.h
 #include time.h

 time_t time(time_t *t)
@@ -30,3 +31,11 @@ time_t time(time_t *t)
 *t = ret;
 return ret;
 }
+
+int
+virNumaGetMaxNode(void)
+{
+   const int maxnodesNum = 7;
+
+   return maxnodesNum;
+}

Why not just return 7; ???


I just think magic number may be not proper.



Probably a matter of taste, I'd use a comment in that case, but proper
compiler should optimize it even without that const, so no problem
here ;)

Martin


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

Re: [libvirt] [PATCH v5 0/3] add nodeset check in numatune

2014-11-03 Thread Martin Kletzander

On Tue, Nov 04, 2014 at 10:44:38AM +0800, Chen Fan wrote:

when setting elements memnode and nodeset in attribute numatune more
than the host nodes in XML file, VM boot should fail. so add check for
that.



ACK  Pushed, thank you for the patches.

Martin


Chen Fan (3):
 bitmap: add virBitmapLastSetBit for finding the last bit position of
   bitmap
 numatune: add check for numatune nodeset range
 virnuma: use virNumaNodesetIsAvailable checking nodeset in
   virNumaSetupMemoryPolicy

src/conf/numatune_conf.c   | 28 
src/conf/numatune_conf.h   |  1 +
src/libvirt_private.syms   |  2 +
src/qemu/qemu_command.c|  4 ++
src/util/virbitmap.c   | 45 ++
src/util/virbitmap.h   |  3 ++
src/util/virnuma.c | 53 +-
src/util/virnuma.h |  1 +
...rgv-numatune-static-nodeset-exceed-hostnode.xml | 35 ++
tests/qemuxml2argvmock.c   |  9 
tests/qemuxml2argvtest.c   |  2 +
tests/virbitmaptest.c  | 13 +-
12 files changed, 184 insertions(+), 12 deletions(-)
create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-numatune-static-nodeset-exceed-hostnode.xml

--
1.9.3



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

[libvirt] [PATCH] domain: Improve error output for virDomainListGetStats

2014-11-03 Thread Luyao Huang
When pass flags --domain and --list-* to cmdDomstats,
a unsupport error will output from qemuConnectGetAllDomainStats.

error: unsupported flags (0x1) in function qemuConnectGetAllDomainStats

From manual of virsh: The approaches can't be combined.

Improve error to:

error: --domain and --list-* flags are mutually exclusive

Signed-off-by: Luyao Huang lhu...@redhat.com
---
 src/libvirt-domain.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 7dc3146..6ae6dd2 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11053,6 +11053,19 @@ virDomainListGetStats(virDomainPtr *doms,
 goto cleanup;
 }
 
+if (flags  (VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_PERSISTENT |
+ VIR_CONNECT_LIST_DOMAINS_TRANSIENT |
+ VIR_CONNECT_LIST_DOMAINS_RUNNING |
+ VIR_CONNECT_LIST_DOMAINS_SHUTOFF |
+ VIR_CONNECT_LIST_DOMAINS_PAUSED |
+ VIR_CONNECT_LIST_DOMAINS_OTHER)) {
+virReportInvalidArg(flags, %s,
+_(--domain and --list-* flags are mutually exclusive));
+goto cleanup;
+}
+
 conn = doms[0]-conn;
 virCheckConnectReturn(conn, -1);
 
-- 
1.8.3.1

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