Re: [libvirt] [PATCH] Return right error code for baselineCPU

2013-11-24 Thread Doug Goldstein
On Sat, Nov 23, 2013 at 3:15 PM, Don Dugger n0...@n0ano.com wrote:

 This Python interface code is returning a -1 on errors for the
 `baselineCPU' API.  Since this API is supposed to return a pointer
 the error return value should really be VIR_PY_NONE.

 NB:  I've checked all the other APIs in this file and this is the
 only pointer API that is returning -1.

 Signed-off-by: Don Dugger donald.d.dug...@intel.com
 ---
  python/libvirt-override.c |8 
  1 file changed, 4 insertions(+), 4 deletions(-)

 diff --git a/python/libvirt-override.c b/python/libvirt-override.c
 index c60747d..b471605 100644
 --- a/python/libvirt-override.c
 +++ b/python/libvirt-override.c
 @@ -4471,13 +4471,13 @@ libvirt_virConnectBaselineCPU(PyObject *self 
 ATTRIBUTE_UNUSED,

  ncpus = PyList_Size(list);
  if (VIR_ALLOC_N_QUIET(xmlcpus, ncpus)  0)
 -return VIR_PY_INT_FAIL;
 +return VIR_PY_NONE;

  for (i = 0; i  ncpus; i++) {
  xmlcpus[i] = PyString_AsString(PyList_GetItem(list, i));
  if (xmlcpus[i] == NULL) {
  VIR_FREE(xmlcpus);
 -return VIR_PY_INT_FAIL;
 +return VIR_PY_NONE;
  }
  }
  }
 @@ -4489,13 +4489,13 @@ libvirt_virConnectBaselineCPU(PyObject *self 
 ATTRIBUTE_UNUSED,
  VIR_FREE(xmlcpus);

  if (base_cpu == NULL)
 -return VIR_PY_INT_FAIL;
 +return VIR_PY_NONE;

  pybase_cpu = PyString_FromString(base_cpu);
  VIR_FREE(base_cpu);

  if (pybase_cpu == NULL)
 -return VIR_PY_INT_FAIL;
 +return VIR_PY_NONE;

  return pybase_cpu;
  }
 --
 1.7.10.4


ACK. This is correct. But it obviously changes our API so I'm not
really sure how we should handle this, (e.g. document the API as is as
note that its broken or fix it).

-- 
Doug Goldstein

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


Re: [libvirt] [PATCH 1/1] qemu: Remove default memory balloon for PPC64

2013-11-24 Thread Paul Mackerras
On Thu, Nov 21, 2013 at 11:03:46AM +, Daniel P. Berrange wrote:
 On Thu, Nov 21, 2013 at 01:52:02PM +0800, Li Zhang wrote:
  From: Li Zhang zhlci...@linux.vnet.ibm.com
  
  It doesn't need to add a default memory balloon for PPC64.
  Only if users want it, it can be added explicitly.
  
  Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
[snip]

 Unless this is actively causing failures, then NACK to this
 patch.

Both RHEL6.x and SLES11 SP3 include the virtio-balloon driver in their
ppc64 versions, though the driver was never tested on ppc64.
Unfortunately, virtio-balloon had endianness and page-size bugs prior
to kernel v3.4, with the result that on those distros, any use of the
balloon driver on ppc64 will crash the guest kernel.  So in that sense
this is actively causing failures.

Regards,
Paul.

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


Re: [libvirt] [PATCHv2] storage: allow interleave in volume XML

2013-11-24 Thread Osier Yang

On 23/11/13 03:54, Eric Blake wrote:

The RNG grammar did not allow arbitrary interleaving, which makes
it harder than necessary to create a new volume from handwritten XML.
(Compare also to commit caf516db for pools).

* docs/schemas/storagevol.rng: Support interleaving.
* tests/storagevolxml2xmlin/vol-file-backing.xml: Test it.

Signed-off-by: Eric Blake ebl...@redhat.com
---

v2: correct version (actually applies to libvirt.git, rather
than depending on unpublished intermediate commits)

reviewer's note: see bottom for easier-to-review schema change

  docs/schemas/storagevol.rng| 138 +
  tests/storagevolxml2xmlin/vol-file-backing.xml |  15 +--
  2 files changed, 82 insertions(+), 71 deletions(-)

diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 5da8e1f..e79bc35 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -13,55 +13,61 @@

define name='vol'
  element name='volume'
-  element name='name'
-ref name='volName'/
-  /element
-  optional
-element name='key'
-  text/
+  interleave
+element name='name'
+  ref name='volName'/
  /element
-  /optional
-  optional
-ref name='source'/
-  /optional
-  ref name='sizing'/
-  ref name='target'/
-  optional
-ref name='backingStore'/
-  /optional
+optional
+  element name='key'
+text/
+  /element
+/optional
+optional
+  ref name='source'/
+/optional
+ref name='sizing'/
+ref name='target'/
+optional
+  ref name='backingStore'/
+/optional
+  /interleave
  /element
/define

define name='sizing'
-optional
-  element name='capacity'
-ref name='scaledInteger'/
-  /element
-/optional
-optional
-  element name='allocation'
-ref name='scaledInteger'/
-  /element
-/optional
+interleave
+  optional
+element name='capacity'
+  ref name='scaledInteger'/
+/element
+  /optional
+  optional
+element name='allocation'
+  ref name='scaledInteger'/
+/element
+  /optional
+/interleave
/define

define name='permissions'
  optional
element name='permissions'
-element name='mode'
-  ref name='octalMode'/
-/element
-element name='owner'
-  ref name='unsignedInt'/
-/element
-element name='group'
-  ref name='unsignedInt'/
-/element
-optional
-  element name='label'
-text/
-/element
-/optional
+interleave
+  element name='mode'
+ref name='octalMode'/
+  /element
+  element name='owner'
+ref name='unsignedInt'/
+  /element
+  element name='group'
+ref name='unsignedInt'/
+  /element
+  optional
+element name='label'
+  text/
+/element
+  /optional
+/interleave
/element
  /optional
/define
@@ -103,36 +109,40 @@

define name='target'
  element name='target'
-  optional
-element name='path'
-  choice
-data type='anyURI'/
-ref name='absFilePath'/
-  /choice
-/element
-  /optional
-  ref name='format'/
-  ref name='permissions'/
-  ref name='timestamps'/
-  optional
-ref name='encryption'/
-  /optional
-  optional
-ref name='compat'/
-  /optional
-  optional
-ref name='fileFormatFeatures'/
-  /optional
+  interleave
+optional
+  element name='path'
+choice
+  data type='anyURI'/
+  ref name='absFilePath'/
+/choice
+  /element
+/optional
+ref name='format'/
+ref name='permissions'/
+ref name='timestamps'/
+optional
+  ref name='encryption'/
+/optional
+optional
+  ref name='compat'/
+/optional
+optional
+  ref name='fileFormatFeatures'/
+/optional
+  /interleave
  /element
/define

define name='backingStore'
  element name='backingStore'
-  element name='path'
-ref name='absFilePath'/
-  /element
-  ref name='format'/
-  ref name='permissions'/
+  interleave
+element name='path'
+  ref name='absFilePath'/
+/element
+ref name='format'/
+ref name='permissions'/
+  /interleave
  /element
/define

diff --git a/tests/storagevolxml2xmlin/vol-file-backing.xml 
b/tests/storagevolxml2xmlin/vol-file-backing.xml
index 73e7f28..8610ea4 100644
--- a/tests/storagevolxml2xmlin/vol-file-backing.xml
+++ b/tests/storagevolxml2xmlin/vol-file-backing.xml
@@ -1,25 

Re: [libvirt] [PATCH]lxc: don't do duplicate work when getting pagesize

2013-11-24 Thread Chen Hanxiao
ping

 -Original Message-
 From: Chen Hanxiao [mailto:chenhanx...@cn.fujitsu.com]
 Sent: Monday, November 18, 2013 4:03 PM
 To: libvir-list@redhat.com
 Cc: chenhanx...@cn.fujitsu.com
 Subject: [libvirt][PATCH]lxc: don't do duplicate work when getting
pagesize
 
 From: Chen Hanxiao chenhanx...@cn.fujitsu.com
 
 Don't do duplicate work when getting pagesize.
 With some debug logs added.
 
 Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
 ---
  src/lxc/lxc_container.c | 16 +++-
  1 file changed, 11 insertions(+), 5 deletions(-)
 
 diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
 index 255c711..e85d01c 100644
 --- a/src/lxc/lxc_container.c
 +++ b/src/lxc/lxc_container.c
 @@ -144,6 +144,7 @@ int lxcContainerHasReboot(void)
  int cmd, v;
  int status;
  char *tmp;
 +int stacksize = getpagesize() * 4;
 
  if (virFileReadAll(/proc/sys/kernel/ctrl-alt-del, 10, buf)  0)
  return -1;
 @@ -160,10 +161,12 @@ int lxcContainerHasReboot(void)
  VIR_FREE(buf);
  cmd = v ? LINUX_REBOOT_CMD_CAD_ON :
 LINUX_REBOOT_CMD_CAD_OFF;
 
 -if (VIR_ALLOC_N(stack, getpagesize() * 4)  0)
 +if (VIR_ALLOC_N(stack, stacksize)  0) {
 +VIR_DEBUG(Unable to allocate stack);
  return -1;
 +}
 
 -childStack = stack + (getpagesize() * 4);
 +childStack = stack + stacksize;
 
  cpid = clone(lxcContainerRebootChild, childStack, flags, cmd);
  VIR_FREE(stack);
 @@ -2011,8 +2014,10 @@ int lxcContainerStart(virDomainDefPtr def,
  };
 
  /* allocate a stack for the container */
 -if (VIR_ALLOC_N(stack, stacksize)  0)
 +if (VIR_ALLOC_N(stack, stacksize)  0) {
 +VIR_DEBUG(Unable to allocate stack);
  return -1;
 +}
  stacktop = stack + stacksize;
 
  cflags =
 CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|SIGCHLD
 ;
 @@ -2060,6 +2065,7 @@ int lxcContainerAvailable(int features)
  int cpid;
  char *childStack;
  char *stack;
 +int stacksize = getpagesize() * 4;
 
  if (features  LXC_CONTAINER_FEATURE_USER)
  flags |= CLONE_NEWUSER;
 @@ -2067,12 +2073,12 @@ int lxcContainerAvailable(int features)
  if (features  LXC_CONTAINER_FEATURE_NET)
  flags |= CLONE_NEWNET;
 
 -if (VIR_ALLOC_N(stack, getpagesize() * 4)  0) {
 +if (VIR_ALLOC_N(stack, stacksize)  0) {
  VIR_DEBUG(Unable to allocate stack);
  return -1;
  }
 
 -childStack = stack + (getpagesize() * 4);
 +childStack = stack + stacksize;
 
  cpid = clone(lxcContainerDummyChild, childStack, flags, NULL);
  VIR_FREE(stack);
 --
 1.8.2.1



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


Re: [libvirt] [PATCH] storage: expose volume meta-type in XML

2013-11-24 Thread Osier Yang

On 23/11/13 06:26, Eric Blake wrote:

I got annoyed at having to use both 'virsh vol-list $pool --details'
AND 'virsh vol-dumpxml $vol $pool' to learn if I had populated
the volume correctly.  Since two-thirds of the data present in
virStorageVolGetInfo() already appears in virStorageVolGetXMLDesc(),
this just adds the remaining piece of information.

* docs/formatstorage.html.in: Document new target type=


I didn't see it relates with target.


* docs/schemas/storagevol.rng (target, backingStore): Add it to
RelaxNG.


I thought (target, backingStore) means add type to both
of them.  Finally see it means between  :-)


* src/conf/storage_conf.h (virStorageVolTypeToString): Declare.
* src/conf/storage_conf.c (virStorageVolTargetDefFormat): Output
the metatype.
* tests/storagevolxml2xmlout/vol-*.xml: Update tests to match.

Signed-off-by: Eric Blake ebl...@redhat.com
---

Depends on:
https://www.redhat.com/archives/libvir-list/2013-November/msg00948.html

  docs/formatstorage.html.in |  5 +
  docs/schemas/storagevol.rng| 15 +++
  src/conf/storage_conf.c| 18 ++
  src/conf/storage_conf.h|  1 +
  tests/storagevolxml2xmlin/vol-logical-backing.xml  |  1 +
  tests/storagevolxml2xmlin/vol-logical.xml  |  1 +
  tests/storagevolxml2xmlin/vol-partition.xml|  1 +
  tests/storagevolxml2xmlin/vol-sheepdog.xml |  1 +
  tests/storagevolxml2xmlout/vol-file-backing.xml|  1 +
  tests/storagevolxml2xmlout/vol-file-naming.xml |  1 +
  tests/storagevolxml2xmlout/vol-file.xml|  1 +
  tests/storagevolxml2xmlout/vol-logical-backing.xml |  1 +
  tests/storagevolxml2xmlout/vol-logical.xml |  1 +
  tests/storagevolxml2xmlout/vol-partition.xml   |  1 +
  tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml |  1 +
  tests/storagevolxml2xmlout/vol-qcow2-1.1.xml   |  1 +
  tests/storagevolxml2xmlout/vol-qcow2-lazy.xml  |  1 +
  tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml |  1 +
  tests/storagevolxml2xmlout/vol-qcow2.xml   |  1 +
  tests/storagevolxml2xmlout/vol-sheepdog.xml|  1 +
  20 files changed, 55 insertions(+)

diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 90eeaa3..5f277b4 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -293,6 +293,7 @@
lt;volumegt;
  lt;namegt;sparse.imglt;/namegt;
  lt;keygt;/var/lib/xen/images/sparse.imglt;/keygt;
+lt;typegt;filelt;/typegt;
  lt;allocationgt;0lt;/allocationgt;
  lt;capacity unit=Tgt;1lt;/capacitygt;
  .../pre
@@ -305,6 +306,10 @@
ddProviding an identifier for the volume which is globally unique.
This cannot be set when creating a volume: it is always generated.
  span class=sinceSince 0.4.1/span/dd
+  dtcodetype/code/dt
+  ddOutput-only; provides the volume type that is also available
+from codevirStorageVolGetInfo()/code.  span class=sinceSince


I think it's better to mention virsh vol-list $pool --details instead 
of the

API name here, as we did across the documents.  I'm fine if you keep it
though.


+1.1.5/span/dd
dtcodeallocation/code/dt
ddProviding the total storage allocation for the volume. This
  may be smaller than the logical capacity if the volume is sparsely
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index e79bc35..96572c5 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -25,6 +25,9 @@
  optional
ref name='source'/
  /optional
+optional
+  ref name='voltype'/
+/optional
  ref name='sizing'/
  ref name='target'/
  optional
@@ -34,6 +37,18 @@
  /element
/define

+  define name='voltype'
+element name='type'
+  choice
+valuefile/value
+valueblock/value
+valuedir/value
+valuenetwork/value
+valuenetwork-dir/value


What's network-dir type? the type you will introduce in the glusterfs 
series?
It's not in the git head yet.  So either you will need to remove it, or 
push this

patch after the glusterfs series.


+  /choice
+/element
+  /define
+
define name='sizing'
  interleave
optional
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 8b378c2..0d2932b 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -51,6 +51,10 @@
  #define DEFAULT_POOL_PERM_MODE 0755
  #define DEFAULT_VOL_PERM_MODE  0600

+VIR_ENUM_IMPL(virStorageVol,
+  VIR_STORAGE_VOL_LAST,
+  file, block, dir, network)


Here the network-dir type is not included though. So I guess you want
to push this patch before the glusterfs series.

ACK if the network-dir is removed.

--
libvir-list mailing list
libvir-list@redhat.com

Re: [libvirt] [PATCH]lxc: don't do duplicate work when getting pagesize

2013-11-24 Thread Osier Yang

On 18/11/13 16:03, Chen Hanxiao wrote:

From: Chen Hanxiao chenhanx...@cn.fujitsu.com

Don't do duplicate work when getting pagesize.
With some debug logs added.

Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
---
  src/lxc/lxc_container.c | 16 +++-
  1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 255c711..e85d01c 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -144,6 +144,7 @@ int lxcContainerHasReboot(void)
  int cmd, v;
  int status;
  char *tmp;
+int stacksize = getpagesize() * 4;
  
  if (virFileReadAll(/proc/sys/kernel/ctrl-alt-del, 10, buf)  0)

  return -1;
@@ -160,10 +161,12 @@ int lxcContainerHasReboot(void)
  VIR_FREE(buf);
  cmd = v ? LINUX_REBOOT_CMD_CAD_ON : LINUX_REBOOT_CMD_CAD_OFF;
  
-if (VIR_ALLOC_N(stack, getpagesize() * 4)  0)

+if (VIR_ALLOC_N(stack, stacksize)  0) {
+VIR_DEBUG(Unable to allocate stack);


virAllocN already reports the out-of-memory error, why do we
need a debug log?

Osier

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


Re: [libvirt] [PATCH libvirt-python v3 00/40] Split python binding into separate repo

2013-11-24 Thread Jim Fehlig
Daniel P. Berrange wrote:
 FYI in order to test this from a compilation pov I wrote a script which
 downloaded every older libvirt release and did a client only build and
 then built the python module against it.

 I'm attaching the script I used for this

 I built on Fedora 19 successfully back to 0.9.11 with this, though I
 had to patch libvirt itself in many cases to even build. Would appreciate
 someone testing this build on other platforms too. eg RHEL and/or Ubuntu
 in particular. You might have to tweak/skip some of the patches on
 other platforms, depending on glibc/kernel versions
   

FYI, I build-tested this series against the libvirt versions I'm
currently maintaining in various SUSE distros, which included 0.9.11,
1.0.2, 1.0.5, 1.1.2, and 1.1.4 (Factory).

Regards,
Jim

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


Re: [libvirt] [PATCH]lxc: don't do duplicate work when getting pagesize

2013-11-24 Thread Chen Hanxiao


 -Original Message-
 From: Osier Yang [mailto:jy...@redhat.com]
 Sent: Monday, November 25, 2013 1:13 PM
 To: Chen Hanxiao
 Cc: libvir-list@redhat.com
 Subject: Re: [libvirt] [PATCH]lxc: don't do duplicate work when getting
pagesize
 
 On 18/11/13 16:03, Chen Hanxiao wrote:
  From: Chen Hanxiao chenhanx...@cn.fujitsu.com
 
  Don't do duplicate work when getting pagesize.
  With some debug logs added.
 
  Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
  ---
src/lxc/lxc_container.c | 16 +++-
1 file changed, 11 insertions(+), 5 deletions(-)
 
  diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
  index 255c711..e85d01c 100644
  --- a/src/lxc/lxc_container.c
  +++ b/src/lxc/lxc_container.c
  @@ -144,6 +144,7 @@ int lxcContainerHasReboot(void)
int cmd, v;
int status;
char *tmp;
  +int stacksize = getpagesize() * 4;
 
if (virFileReadAll(/proc/sys/kernel/ctrl-alt-del, 10, buf)  0)
return -1;
  @@ -160,10 +161,12 @@ int lxcContainerHasReboot(void)
VIR_FREE(buf);
cmd = v ? LINUX_REBOOT_CMD_CAD_ON :
 LINUX_REBOOT_CMD_CAD_OFF;
 
  -if (VIR_ALLOC_N(stack, getpagesize() * 4)  0)
  +if (VIR_ALLOC_N(stack, stacksize)  0) {
  +VIR_DEBUG(Unable to allocate stack);
 
 virAllocN already reports the out-of-memory error, why do we
 need a debug log?

I've already see it. I just want it to look alike the same scenario in
lxcContainerAvailable

Maybe we should also delete that code in lxcContainerAvailable.

 
 Osier


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


Re: [libvirt] [test-API][PATCH] add new patch for testing pinemulator API

2013-11-24 Thread Guannan Ren

On 2013年11月22日 14:08, Xuesong Zhang wrote:

---
  cases/pinemulator.conf  | 46 +
  repos/domain/pinemulator.py | 84 +
  2 files changed, 130 insertions(+)
  create mode 100755 cases/pinemulator.conf
  create mode 100755 repos/domain/pinemulator.py

diff --git a/cases/pinemulator.conf b/cases/pinemulator.conf
new file mode 100755
index 000..2f270f3
--- /dev/null
+++ b/cases/pinemulator.conf
@@ -0,0 +1,46 @@
+domain:install_linux_cdrom
+guestname
+$defaultname
+guestos
+$defaultos
+guestarch
+$defaultarch
+vcpu
+$defaultvcpu
+memory
+$defaultmem
+hddriver
+$defaulthd
+nicdriver
+$defaultnic
+imageformat
+qcow2
+
+domain:pinemulator
+guestname
+$defaultname
+cpulist
+0-2
+
+domain:pinemulator
+guestname
+$defaultname
+cpulist
+3
+
+domain:pinemulator
+guestname
+$defaultname
+cpulist
+0,2
+
+domain:destroy
+guestname
+$defaultname
+
+
+domain:undefine
+guestname
+$defaultname
+
+options cleanup=enable
\ No newline at end of file
diff --git a/repos/domain/pinemulator.py b/repos/domain/pinemulator.py
new file mode 100755
index 000..8d7b800
--- /dev/null
+++ b/repos/domain/pinemulator.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+ Query or change the pinning of domain's emulator threads to
+  host physical CPUs.
+
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', 'cpulist',)
+optional_params = {}
+
+def check_pinemulator(guestname, maxcpu, pininfo_after):
+check emulator status of the running virtual machine
+
+
+cmd = cat /var/run/libvirt/qemu/%s.pid % guestname
+status, pid = utils.exec_cmd(cmd, shell=True)
+if status:
+logger.error(failed to get the pid of domain %s % guestname)
+return 1
+
+cmd = grep Cpus_allowed_list /proc/%s/task/%s/status % (pid[0], pid[0])
+status, output = utils.exec_cmd(cmd, shell=True)
+if status:
+logger.error(failed to get Cpus_allowed_list)
+return 1
+
+cpu_allowed_list = output[0]
+cpulistcheck = cpu_allowed_list.split('\t')[1]
+pininfo_in_process = str(utils.param_to_tuple(cpulistcheck, maxcpu))
+
+if cmp(pininfo_in_process, pininfo_after):
+logger.error(domain emulator pin failed)
+return 1
+else:
+logger.info(domain emulator pin successed)
+return 0
+
+
+def pinemulator(params):
+Dynamically change the real CPUs which can be allocated to the
+   emulator process of a domain. This function requires privileged
+   access to the hypervisor. 
+global logger
+logger = params['logger']
+guestname = params['guestname']
+cpulist = params['cpulist']
+
+logger.info(the name of virtual machine is %s % guestname)
+logger.info(the given cpulist is %s % cpulist)
+
+maxcpu = utils.get_host_cpus()
+logger.info(%s physical cpu on host % maxcpu)
+
+cpumap = utils.param_to_tuple(cpulist, maxcpu)
+if not cpumap:
+logger.error(cpulist: Invalid format)
+return 1
+
+conn = sharedmod.libvirtobj['conn']
+
+try:
+domobj = conn.lookupByName(guestname)
+
+pininfo_original = str(domobj.emulatorPinInfo())
+logger.info(the original emulator pin of the domain is: %s % \
+pininfo_original)
+
+logger.info(pin domain emulator to host cpu %s % cpulist)
+domobj.pinEmulator(cpumap)
+
+pininfo_after = str(domobj.emulatorPinInfo())
+logger.info(the revised emulator pin of the domain is: %s % \
+pininfo_after)
+
+ret = check_pinemulator(guestname, maxcpu, pininfo_after)
+return ret
+
+except libvirtError, e:
+logger.error(libvirt call failed:  + str(e))
+return 1


ACK and pushed
Thanks

Guannan

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

Re: [libvirt] [PATCH libvirt-python v3 00/40] Split python binding into separate repo

2013-11-24 Thread Daniel Veillard
On Fri, Nov 22, 2013 at 04:22:24PM +, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 This patch series is a followup to
 
https://www.redhat.com/archives/libvir-list/2013-November/msg00712.html
 
 This series is what I consider ready to declare final, ready for the real
 GIT repo split to be done.

  I got a failure to apply the patch set:

Applying: Import LIBVIR_CHECK_VERSION macro from libvirt
Patch is empty.  Was it split wrong?
If you would prefer to skip this patch, instead run git am --skip.
To restore the original branch and stop patching run git am --abort.
thinkpad:~/libvirt-python - git am --skip
Applying: Import some virTypedParams* APIs from libvirt

Applying: VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK appeared in 1.0.0
fatal: sha1 information is lacking or useless (libvirt-override.c).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0031 VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK appeared in
1.0.0
The copy of the patch that failed is found in:
   /home/veillard/libvirt-python/.git/rebase-apply/patch

I suggest you simply push your repo to libvirt.org git as libvirt-python.git
and just send additional patches which are needed to cleanup the curent
libvirt.git,

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] [test-API][PATCH] add new patch for testing pinemulator API

2013-11-24 Thread Xuesong Zhang
Thanks for your review, pushed.

Best Regards,
Zhang Xuesong
IRC: xuzhang
internal phone: 88393

- Original Message -
 From: Guannan Ren g...@redhat.com
 To: Xuesong Zhang xuzh...@redhat.com
 Cc: libvir-list@redhat.com
 Sent: Monday, November 25, 2013 1:55:05 PM
 Subject: Re: [libvirt] [test-API][PATCH] add new patch for testing 
 pinemulator API
 
 On 2013年11月22日 14:08, Xuesong Zhang wrote:
  ---
cases/pinemulator.conf  | 46 +
repos/domain/pinemulator.py | 84
+
2 files changed, 130 insertions(+)
create mode 100755 cases/pinemulator.conf
create mode 100755 repos/domain/pinemulator.py
 
  diff --git a/cases/pinemulator.conf b/cases/pinemulator.conf
  new file mode 100755
  index 000..2f270f3
  --- /dev/null
  +++ b/cases/pinemulator.conf
  @@ -0,0 +1,46 @@
  +domain:install_linux_cdrom
  +guestname
  +$defaultname
  +guestos
  +$defaultos
  +guestarch
  +$defaultarch
  +vcpu
  +$defaultvcpu
  +memory
  +$defaultmem
  +hddriver
  +$defaulthd
  +nicdriver
  +$defaultnic
  +imageformat
  +qcow2
  +
  +domain:pinemulator
  +guestname
  +$defaultname
  +cpulist
  +0-2
  +
  +domain:pinemulator
  +guestname
  +$defaultname
  +cpulist
  +3
  +
  +domain:pinemulator
  +guestname
  +$defaultname
  +cpulist
  +0,2
  +
  +domain:destroy
  +guestname
  +$defaultname
  +
  +
  +domain:undefine
  +guestname
  +$defaultname
  +
  +options cleanup=enable
  \ No newline at end of file
  diff --git a/repos/domain/pinemulator.py b/repos/domain/pinemulator.py
  new file mode 100755
  index 000..8d7b800
  --- /dev/null
  +++ b/repos/domain/pinemulator.py
  @@ -0,0 +1,84 @@
  +#!/usr/bin/env python
  + Query or change the pinning of domain's emulator threads to
  +  host physical CPUs.
  +
  +
  +import libvirt
  +from libvirt import libvirtError
  +
  +from src import sharedmod
  +from utils import utils
  +
  +required_params = ('guestname', 'cpulist',)
  +optional_params = {}
  +
  +def check_pinemulator(guestname, maxcpu, pininfo_after):
  +check emulator status of the running virtual machine
  +
  +
  +cmd = cat /var/run/libvirt/qemu/%s.pid % guestname
  +status, pid = utils.exec_cmd(cmd, shell=True)
  +if status:
  +logger.error(failed to get the pid of domain %s % guestname)
  +return 1
  +
  +cmd = grep Cpus_allowed_list /proc/%s/task/%s/status % (pid[0],
  pid[0])
  +status, output = utils.exec_cmd(cmd, shell=True)
  +if status:
  +logger.error(failed to get Cpus_allowed_list)
  +return 1
  +
  +cpu_allowed_list = output[0]
  +cpulistcheck = cpu_allowed_list.split('\t')[1]
  +pininfo_in_process = str(utils.param_to_tuple(cpulistcheck, maxcpu))
  +
  +if cmp(pininfo_in_process, pininfo_after):
  +logger.error(domain emulator pin failed)
  +return 1
  +else:
  +logger.info(domain emulator pin successed)
  +return 0
  +
  +
  +def pinemulator(params):
  +Dynamically change the real CPUs which can be allocated to the
  +   emulator process of a domain. This function requires privileged
  +   access to the hypervisor. 
  +global logger
  +logger = params['logger']
  +guestname = params['guestname']
  +cpulist = params['cpulist']
  +
  +logger.info(the name of virtual machine is %s % guestname)
  +logger.info(the given cpulist is %s % cpulist)
  +
  +maxcpu = utils.get_host_cpus()
  +logger.info(%s physical cpu on host % maxcpu)
  +
  +cpumap = utils.param_to_tuple(cpulist, maxcpu)
  +if not cpumap:
  +logger.error(cpulist: Invalid format)
  +return 1
  +
  +conn = sharedmod.libvirtobj['conn']
  +
  +try:
  +domobj = conn.lookupByName(guestname)
  +
  +pininfo_original = str(domobj.emulatorPinInfo())
  +logger.info(the original emulator pin of the domain is: %s % \
  +pininfo_original)
  +
  +logger.info(pin domain emulator to host cpu %s % cpulist)
  +domobj.pinEmulator(cpumap)
  +
  +pininfo_after = str(domobj.emulatorPinInfo())
  +logger.info(the revised emulator pin of the domain is: %s % \
  +pininfo_after)
  +
  +ret = check_pinemulator(guestname, maxcpu, pininfo_after)
  +return ret
  +
  +except libvirtError, e:
  +logger.error(libvirt call failed:  + str(e))
  +return 1
 
 ACK and pushed
 Thanks
 
 Guannan
 

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

Re: [libvirt] [PATCHv4 2/8] storage: document gluster pool

2013-11-24 Thread Daniel Veillard
On Fri, Nov 22, 2013 at 08:20:24PM -0700, Eric Blake wrote:
 Add support for a new pool type='gluster', similar to
 RBD and Sheepdog.  Terminology wise, a gluster volume
 forms a libvirt storage pool, within the gluster volume,
 individual files are treated as libvirt storage volumes.
 
 * docs/schemas/storagepool.rng (poolgluster): New pool type.
 * docs/formatstorage.html.in: Document gluster.
 * docs/storage.html.in: Likewise, and contrast it with netfs.
 * tests/storagepoolxml2xmlin/pool-gluster.xml: New test.
 * tests/storagepoolxml2xmlout/pool-gluster.xml: Likewise.
 * tests/storagepoolxml2xmltest.c (mymain): Likewise.
 
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
  docs/formatstorage.html.in   | 15 ++--
  docs/schemas/storagepool.rng | 26 ++-
  docs/storage.html.in | 91 
 +++-
  tests/storagepoolxml2xmlin/pool-gluster-sub.xml  |  9 +++
  tests/storagepoolxml2xmlin/pool-gluster.xml  |  8 +++
  tests/storagepoolxml2xmlout/pool-gluster-sub.xml | 12 
  tests/storagepoolxml2xmlout/pool-gluster.xml | 12 
  tests/storagepoolxml2xmltest.c   |  2 +
  8 files changed, 168 insertions(+), 7 deletions(-)
  create mode 100644 tests/storagepoolxml2xmlin/pool-gluster-sub.xml
  create mode 100644 tests/storagepoolxml2xmlin/pool-gluster.xml
  create mode 100644 tests/storagepoolxml2xmlout/pool-gluster-sub.xml
  create mode 100644 tests/storagepoolxml2xmlout/pool-gluster.xml
 
 diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
 index 5f277b4..a7f3b57 100644
 --- a/docs/formatstorage.html.in
 +++ b/docs/formatstorage.html.in
 @@ -21,8 +21,10 @@
codeiscsi/code, codelogical/code, codescsi/code
(all span class=sincesince 0.4.1/span), codempath/code
(span class=sincesince 0.7.1/span), coderbd/code
 -  (span class=sincesince 0.9.13/span), or codesheepdog/code
 -  (span class=sincesince 0.10.0/span). This corresponds to the
 +  (span class=sincesince 0.9.13/span), codesheepdog/code
 +  (span class=sincesince 0.10.0/span),
 +  or codegluster/code (span class=sincesince
 +  1.1.5/span). This corresponds to the

 well 1.1.5 will become 1.2.0 actually so  just change the 2 occurences

storage backend drivers listed further along in this document.
  /p
  h3a name=StoragePoolFirstGeneral metadata/a/h3
 @@ -101,7 +103,9 @@
  path to the block device node. span class=sinceSince 
 0.4.1/span/dd
dtcodedir/code/dt
ddProvides the source for pools backed by directories (pool
 -type codedir/code). May
 +type codedir/code), or optionally to select a subdirectory
 +within a pool that resembles a filesystem (pool
 +type codegluster/code). May
  only occur once. Contains a single attribute codepath/code
  which is the fully qualified path to the backing directory.
  span class=sinceSince 0.4.1/span/dd
 @@ -129,7 +133,7 @@
dtcodehost/code/dt
ddProvides the source for pools backed by storage from a
  remote server (pool types codenetfs/code, codeiscsi/code,
 -coderbd/code, codesheepdog/code). Will be
 +coderbd/code, codesheepdog/code, codegluster/code). Will 
 be
  used in combination with a codedirectory/code
  or codedevice/code element. Contains an attribute 
 codename/code
  which is the hostname or IP address of the server. May optionally
 @@ -160,7 +164,8 @@
dtcodename/code/dt
ddProvides the source for pools backed by storage from a
  named element (pool types codelogical/code, coderbd/code,
 -codesheepdog/code).  Contains a string identifier.
 +codesheepdog/code, codegluster/code).  Contains a
 +string identifier.
  span class=sinceSince 0.4.5/span/dd
dtcodeformat/code/dt
ddProvides information about the format of the pool (pool
 diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
 index 61fa7a3..8d7a94d 100644
 --- a/docs/schemas/storagepool.rng
 +++ b/docs/schemas/storagepool.rng
 @@ -21,6 +21,7 @@
  ref name='poolmpath'/
  ref name='poolrbd'/
  ref name='poolsheepdog'/
 +ref name='poolgluster'/
/choice
  /element
/define
 @@ -145,6 +146,17 @@
  /interleave
/define
 
 +  define name='poolgluster'
 +attribute name='type'
 +  valuegluster/value
 +/attribute
 +interleave
 +  ref name='commonmetadata'/
 +  ref name='sizing'/
 +  ref name='sourcegluster'/
 +/interleave
 +  /define
 +
define name='sourceinfovendor'
  interleave
optional
 @@ -309,7 +321,7 @@
define name='sourceinfodir'
  element name='dir'
attribute name='path'
 -ref name='absFilePath'/
 +ref name='absDirPath'/
/attribute
empty/
  /element
 @@ -554,6 +566,18 @@
  /element

[libvirt] [PATCH v2]lxc: don't do duplicate work when getting pagesize

2013-11-24 Thread Chen Hanxiao
From: Chen Hanxiao chenhanx...@cn.fujitsu.com

Don't do duplicate work when getting pagesize.

Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
---
v2: remove redundant debug log

 src/lxc/lxc_container.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 2bdf957..00bbaf7 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -144,6 +144,7 @@ int lxcContainerHasReboot(void)
 int cmd, v;
 int status;
 char *tmp;
+int stacksize = getpagesize() * 4;
 
 if (virFileReadAll(/proc/sys/kernel/ctrl-alt-del, 10, buf)  0)
 return -1;
@@ -160,10 +161,10 @@ int lxcContainerHasReboot(void)
 VIR_FREE(buf);
 cmd = v ? LINUX_REBOOT_CMD_CAD_ON : LINUX_REBOOT_CMD_CAD_OFF;
 
-if (VIR_ALLOC_N(stack, getpagesize() * 4)  0)
+if (VIR_ALLOC_N(stack, stacksize)  0)
 return -1;
 
-childStack = stack + (getpagesize() * 4);
+childStack = stack + stacksize;
 
 cpid = clone(lxcContainerRebootChild, childStack, flags, cmd);
 VIR_FREE(stack);
@@ -2031,6 +2032,7 @@ int lxcContainerStart(virDomainDefPtr def,
 /* allocate a stack for the container */
 if (VIR_ALLOC_N(stack, stacksize)  0)
 return -1;
+
 stacktop = stack + stacksize;
 
 cflags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|SIGCHLD;
@@ -2078,6 +2080,7 @@ int lxcContainerAvailable(int features)
 int cpid;
 char *childStack;
 char *stack;
+int stacksize = getpagesize() * 4;
 
 if (features  LXC_CONTAINER_FEATURE_USER)
 flags |= CLONE_NEWUSER;
@@ -2085,12 +2088,10 @@ int lxcContainerAvailable(int features)
 if (features  LXC_CONTAINER_FEATURE_NET)
 flags |= CLONE_NEWNET;
 
-if (VIR_ALLOC_N(stack, getpagesize() * 4)  0) {
-VIR_DEBUG(Unable to allocate stack);
+if (VIR_ALLOC_N(stack, stacksize)  0)
 return -1;
-}
 
-childStack = stack + (getpagesize() * 4);
+childStack = stack + stacksize;
 
 cpid = clone(lxcContainerDummyChild, childStack, flags, NULL);
 VIR_FREE(stack);
-- 
1.8.2.1

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


Re: [libvirt] [PATCHv4 0/8] glusterfs storage pool

2013-11-24 Thread Osier Yang

On 23/11/13 11:20, Eric Blake wrote:

v3: https://www.redhat.com/archives/libvir-list/2013-November/msg00348.html

Depends on:
https://www.redhat.com/archives/libvir-list/2013-November/msg00955.html

Changes since then, addressing review feedback:
- rebase to other improvements in the meantime
- New patches 4-7
- pool changed to require namevolume/name to have no slash,
with subdirectory within a volume selected by dir path=.../
which must begin with slash
- documentation improved to match actual testing
- directories, symlinks are handled
- volume owner and timestamps are handled
- volume xml tests added, with several bugs in earlier version
fixed along the way
- compared gluster pool with a netfs pool to ensure both can
see the same level of detail from the same gluster storage

If you think it will help review, ask me to provide an interdiff
from v3 (although I have not done it yet).

Eric Blake (8):
   storage: initial support for linking with libgfapi
   storage: document gluster pool
   storage: implement rudimentary glusterfs pool refresh
   storage: add network-dir as new storage volume type
   storage: improve directory support in gluster pool
   storage: improve allocation stats reported on gluster files
   storage: improve handling of symlinks in gluster
   storage: probe qcow2 volumes in gluster pool

  


Looked through the whole set, except the version nit pointed out by
Daniel, I didn't see any other problem. So ACK.

/btw, I need to support the gluster pool for domain config after these
patches are pushed.

Regards,
Osier

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