Re: [libvirt] [PATCH v2.1 04/21] add function bitmapFromBytemap() to convert bytemap to bitmap

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:27PM +0800, Hu Tao wrote:
 ---
  src/conf/domain_conf.c |   39 +--
  1 file changed, 25 insertions(+), 14 deletions(-)
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index c9f5a3c..4e52177 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -10893,36 +10893,47 @@ virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr 
 *def,
  return NULL;
  }
  
 -int
 -virDomainVcpuPinAdd(virDomainDefPtr def,
 -unsigned char *cpumap,
 -int maplen,
 -int vcpu)
 +char *bitmapFromBytemap(unsigned char *bytemap, int maplen)

  I had to make that function static as it is not used anywhere else and
not exported .

  {
 -virDomainVcpuPinDefPtr *vcpupin_list = NULL;
 -virDomainVcpuPinDefPtr vcpupin = NULL;
 -char *cpumask = NULL;
 +char *bitmap = NULL;
  int i;
  
 -if (VIR_ALLOC_N(cpumask, VIR_DOMAIN_CPUMASK_LEN)  0) {
 +if (VIR_ALLOC_N(bitmap, VIR_DOMAIN_CPUMASK_LEN)  0) {
  virReportOOMError();
  goto cleanup;
  }
  
 -/* Reset cpumask to all 0s. */
 +/* Reset bitmap to all 0s. */
  for (i = 0; i  VIR_DOMAIN_CPUMASK_LEN; i++)
 -cpumask[i] = 0;
 +bitmap[i] = 0;
  
 -/* Convert bitmap (cpumap) to cpumask, which is byte map? */
 +/* Convert bitmap (bytemap) to bitmap, which is byte map? */
  for (i = 0; i  maplen; i++) {
  int cur;
  
  for (cur = 0; cur  8; cur++) {
 -if (cpumap[i]  (1  cur))
 -cpumask[i * 8 + cur] = 1;
 +if (bytemap[i]  (1  cur))
 +bitmap[i * 8 + cur] = 1;
  }
  }
  
 +cleanup:
 +return bitmap;
 +}
 +
 +int
 +virDomainVcpuPinAdd(virDomainDefPtr def,
 +unsigned char *cpumap,
 +int maplen,
 +int vcpu)
 +{
 +virDomainVcpuPinDefPtr *vcpupin_list = NULL;
 +virDomainVcpuPinDefPtr vcpupin = NULL;
 +char *cpumask = NULL;
 +
 +if ((cpumask = bitmapFromBytemap(cpumap, maplen)) == NULL)
 +goto cleanup;
 +
  /* No vcpupin exists yet. */
  if (!def-cputune.nvcpupin) {
  if (VIR_ALLOC(vcpupin)  0) {

  Fine other wise, ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 05/21] refactor virDomainVcpuPinAdd()

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:28PM +0800, Hu Tao wrote:
 ---
  src/conf/domain_conf.c   |   81 
 ++
  src/conf/domain_conf.h   |3 +-
  src/libxl/libxl_driver.c |   13 +++-
  src/qemu/qemu_driver.c   |   26 +--
  src/xen/xend_internal.c  |   13 +++-
  5 files changed, 82 insertions(+), 54 deletions(-)
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index 4e52177..56ee4c9 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -10921,69 +10921,52 @@ cleanup:
  return bitmap;
  }
  
 -int
 -virDomainVcpuPinAdd(virDomainDefPtr def,
 -unsigned char *cpumap,
 -int maplen,
 -int vcpu)
 +int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr *vcpupin_list,
 +int *nvcpupin,
 +unsigned char *cpumap,
 +int maplen,
 +int vcpu)
  {
 -virDomainVcpuPinDefPtr *vcpupin_list = NULL;
  virDomainVcpuPinDefPtr vcpupin = NULL;
  char *cpumask = NULL;
  
 -if ((cpumask = bitmapFromBytemap(cpumap, maplen)) == NULL)
 -goto cleanup;
 -
 -/* No vcpupin exists yet. */
 -if (!def-cputune.nvcpupin) {
 -if (VIR_ALLOC(vcpupin)  0) {
 -virReportOOMError();
 -goto cleanup;
 -}
 +if (!vcpupin_list)
 +return -1;
  
 -if (VIR_ALLOC(vcpupin_list)  0) {
 -virReportOOMError();
 -VIR_FREE(vcpupin);
 -goto cleanup;
 -}
 +if ((cpumask = bitmapFromBytemap(cpumap, maplen)) == NULL)
 +return -1;
  
 +vcpupin = virDomainVcpuPinFindByVcpu(vcpupin_list,
 + *nvcpupin,
 + vcpu);
 +if (vcpupin) {
  vcpupin-vcpuid = vcpu;
  vcpupin-cpumask = cpumask;
 -vcpupin_list[def-cputune.nvcpupin++] = vcpupin;
  
 -def-cputune.vcpupin = vcpupin_list;
 -} else {
 -if (virDomainVcpuPinIsDuplicate(def-cputune.vcpupin,
 -def-cputune.nvcpupin,
 -vcpu)) {
 -vcpupin = virDomainVcpuPinFindByVcpu(def-cputune.vcpupin,
 - def-cputune.nvcpupin,
 - vcpu);
 -vcpupin-vcpuid = vcpu;
 -vcpupin-cpumask = cpumask;
 -} else {
 -if (VIR_ALLOC(vcpupin)  0) {
 -virReportOOMError();
 -goto cleanup;
 -}
 +return 0;
 +}
 +
 +/* No existing vcpupin matches vcpu, adding a new one */
 +
 +if (VIR_ALLOC(vcpupin)  0) {
 +virReportOOMError();
 +VIR_FREE(cpumask);
 +return -1;
 +}
 +vcpupin-vcpuid = vcpu;
 +vcpupin-cpumask = cpumask;
  
 -if (VIR_REALLOC_N(def-cputune.vcpupin, def-cputune.nvcpupin + 
 1)  0) {
 -virReportOOMError();
 -VIR_FREE(vcpupin);
 -goto cleanup;
 -}
  
 -vcpupin-vcpuid = vcpu;
 -vcpupin-cpumask = cpumask;
 -def-cputune.vcpupin[def-cputune.nvcpupin++] = vcpupin;
 -   }
 +if (VIR_REALLOC_N(vcpupin_list, *nvcpupin + 1)  0) {
 +virReportOOMError();
 +VIR_FREE(cpumask);
 +VIR_FREE(vcpupin);
 +return -1;
  }
  
 -return 0;
 +vcpupin_list[(*nvcpupin)++] = vcpupin;
  
 -cleanup:
 -VIR_FREE(cpumask);
 -return -1;
 +return 0;
  }
  
  int
 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
 index 74abe6c..30aef6b 100644
 --- a/src/conf/domain_conf.h
 +++ b/src/conf/domain_conf.h
 @@ -1968,7 +1968,8 @@ int virDomainCpuSetParse(const char *str,
  char *virDomainCpuSetFormat(char *cpuset,
  int maxcpu);
  
 -int virDomainVcpuPinAdd(virDomainDefPtr def,
 +int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr *vcpupin_list,
 +int *nvcpupin,
  unsigned char *cpumap,
  int maplen,
  int vcpu);
 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index 398a9a2..7881cd1 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -2454,7 +2454,18 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int 
 vcpu, unsigned char *cpumap,
  goto cleanup;
  }
  
 -if (virDomainVcpuPinAdd(vm-def, cpumap, maplen, vcpu)  0) {
 +if (!vm-def-cputune-vcpupin) {
 +if (VIR_ALLOC(vm-def-cputune-vcpupin)  0) {
 +virReportOOMError();
 +goto cleanup;
 +}
 +vm-def-cputune-nvcpupin = 0;
 +}
 +if (virDomainVcpuPinAdd(vm-def-cputune-vcpupin
 +vm-def-cputune-nvcpupin,
 +cpumap,
 +maplen,
 + 

Re: [libvirt] [PATCH v2.1 08/21] Change virDomainVcpuPinDefParseXML to support parsing emulatorpin

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:44:10PM +0100, Daniel P. Berrange wrote:
 On Tue, Aug 21, 2012 at 05:18:31PM +0800, Hu Tao wrote:
  ---
   src/conf/domain_conf.c |   22 +++---
   1 file changed, 15 insertions(+), 7 deletions(-)
  
  diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
  index ff27bc7..62ba9de 100644
  --- a/src/conf/domain_conf.c
  +++ b/src/conf/domain_conf.c
  @@ -7860,7 +7860,19 @@ cleanup:
   return ret;
   }
   
  -/* Parse the XML definition for a vcpupin */
  +/* Parse the XML definition for a vcpupin or emulatorpin.
  + *
  + * vcpupin has the form of
  + *
  + *   vcpupin vcpu='0' cpuset='0'/
  + *
  + * and emulatorpin has the form of
  + *
  + *   emulatorpin cpuset='0'/
  + *
  + * A vcpuid of -1 is valid and only valid for emulatorpin. So callers
  + * have to check the returned cpuid for validity.
 
 You didn't modify the existing caller to check this, nor does the
 new caller you added in the next patch check this. I'm not really
 a fan of this style of API. IMHO, you should pass in a parameter
 indicating whether 'vcpu' is allowed in the XML or not and then
 keep validation in this method.
 

  Done, i reworked that the following way

Daniel

Change virDomainVcpuPinDefParseXML to support parsing emulatorpin

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5533355..ee247f6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7902,15 +7902,28 @@ cleanup:
 return ret;
 }
 
-/* Parse the XML definition for a vcpupin */
+/* Parse the XML definition for a vcpupin or emulatorpin.
+ *
+ * vcpupin has the form of
+ *
+ *   vcpupin vcpu='0' cpuset='0'/
+ *
+ * and emulatorpin has the form of
+ *
+ *   emulatorpin cpuset='0'/
+ *
+ * A vcpuid of -1 is valid and only valid for emulatorpin. So callers
+ * have to check the returned cpuid for validity.
+ */
 static virDomainVcpuPinDefPtr
 virDomainVcpuPinDefParseXML(const xmlNodePtr node,
 xmlXPathContextPtr ctxt,
-int maxvcpus)
+int maxvcpus,
+int emulator)
 {
 virDomainVcpuPinDefPtr def;
 xmlNodePtr oldnode = ctxt-node;
-unsigned int vcpuid;
+int vcpuid;
 char *tmp = NULL;
 int ret;
 
@@ -7921,14 +7934,14 @@ virDomainVcpuPinDefParseXML(const xmlNodePtr node,
 
 ctxt-node = node;
 
-ret = virXPathUInt(string(./@vcpu), ctxt, vcpuid);
-if (ret == -2) {
+ret = virXPathInt(string(./@vcpu), ctxt, vcpuid);
+if ((ret == -2) || (vcpuid  -1)) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   %s, _(vcpu id must be an unsigned integer));
+   %s, _(vcpu id must be an unsigned integer or -1));
 goto error;
-} else if (ret == -1) {
+} else if ((vcpuid == -1)  (emulator == 0)) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   %s, _(can't parse vcpupin node));
+   %s, _(vcpu id value -1 is not allowed for vcpupin));
 goto error;
 }
 
@@ -8346,7 +8359,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
 
 for (i = 0 ; i  n ; i++) {
 virDomainVcpuPinDefPtr vcpupin = NULL;
-vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt, def-maxvcpus);
+vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt, def-maxvcpus, 
0);
 
 if (!vcpupin)
 goto error;

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 09/21] Support emulatorpin xml parse.

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:32PM +0800, Hu Tao wrote:
 From: Tang Chen tangc...@cn.fujitsu.com
 
 This patch adds a new xml element emulatorpin, which is a sibling
 to the existing vcpupin element under the cputune, to pin emulator
 threads to specified physical CPUs.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Hu Tao hu...@cn.fujitsu.com
 ---
  docs/formatdomain.html.in   |9 
  docs/schemas/domaincommon.rng   |7 
  src/conf/domain_conf.c  |   50 
 ++-
  src/conf/domain_conf.h  |1 +
  tests/qemuxml2argvdata/qemuxml2argv-cputune.xml |1 +
  5 files changed, 66 insertions(+), 2 deletions(-)
 
 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index 8e07489..81ec2cd 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -384,6 +384,7 @@
  lt;vcpupin vcpu=1 cpuset=0,1/gt;
  lt;vcpupin vcpu=2 cpuset=2,3/gt;
  lt;vcpupin vcpu=3 cpuset=0,4/gt;
 +lt;emulatorpin cpuset=1-3/%gt;
  lt;sharesgt;2048lt;/sharesgt;
  lt;periodgt;100lt;/periodgt;
  lt;quotagt;-1lt;/quotagt;
 @@ -410,6 +411,14 @@
  of element codevcpu/code. (NB: Only qemu driver support)
  span class=sinceSince 0.9.0/span
 /dd
 +   dtcodeemulatorpin/code/dt
 +   dd
 + The optional codeemulatorpin/code element specifies which of 
 host
 + physical CPUs the emulator, a subset of a domain not including 
 vcpu,
 + will be pinned to. If this is ommitted, emulator is pinned to all
 + the physical CPUs by default. It contains one required attribute
 + codecpuset/code specifying which physical CPUs to pin to.
 +   /dd
dtcodeshares/code/dt
dd
  The optional codeshares/code element specifies the proportional
 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
 index 401b76b..b02ad96 100644
 --- a/docs/schemas/domaincommon.rng
 +++ b/docs/schemas/domaincommon.rng
 @@ -591,6 +591,13 @@
/attribute
  /element
/zeroOrMore
 +  optional
 +element name=emulatorpin
 +  attribute name=cpuset
 +ref name=cpuset/
 +  /attribute
 +/element
 +  /optional
  /element
/optional
  
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index 62ba9de..94ec095 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -8330,6 +8330,34 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
 caps,
  }
  VIR_FREE(nodes);
  
 +if ((n = virXPathNodeSet(./cputune/emulatorpin, ctxt, nodes))  0) {
 +virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 +   _(cannot extract emulatorpin nodes));
 +goto error;
 +}
 +
 +if (n) {
 +if (n  1) {
 +virReportError(VIR_ERR_XML_ERROR, %s,
 +   _(only one emulatorpin is supported));
 +VIR_FREE(nodes);
 +goto error;
 +}
 +
 +if (VIR_ALLOC(def-cputune.emulatorpin)  0) {
 +goto no_memory;
 +}
 +
 +virDomainVcpuPinDefPtr emulatorpin = NULL;
 +emulatorpin = virDomainVcpuPinDefParseXML(nodes[0], ctxt, 0);
 +
 +if (!emulatorpin)
 +goto error;
 +
 +def-cputune.emulatorpin = emulatorpin;
 +}
 +VIR_FREE(nodes);
 +
  /* Extract numatune if exists. */
  if ((n = virXPathNodeSet(./numatune, ctxt, nodes))  0) {
  virReportError(VIR_ERR_INTERNAL_ERROR,
 @@ -12930,7 +12958,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
  virBufferAsprintf(buf, %u/vcpu\n, def-maxvcpus);
  
  if (def-cputune.shares || def-cputune.vcpupin ||
 -def-cputune.period || def-cputune.quota)
 +def-cputune.period || def-cputune.quota ||
 +def-cputune.emulatorpin)
  virBufferAddLit(buf,   cputune\n);
  
  if (def-cputune.shares)
 @@ -12962,8 +12991,25 @@ virDomainDefFormatInternal(virDomainDefPtr def,
  }
  }
  
 +if (def-cputune.emulatorpin) {
 +virBufferAsprintf(buf, emulatorpin );
 +
 +char *cpumask = NULL;
 +cpumask = virDomainCpuSetFormat(def-cputune.emulatorpin-cpumask,
 +VIR_DOMAIN_CPUMASK_LEN);
 +if (cpumask == NULL) {
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   %s, _(failed to format cpuset for emulator));
 +goto cleanup;
 +}
 +
 +virBufferAsprintf(buf, cpuset='%s'/\n, cpumask);
 +VIR_FREE(cpumask);
 +}
 +
  if (def-cputune.shares || def-cputune.vcpupin ||
 -def-cputune.period || def-cputune.quota)
 +def-cputune.period || def-cputune.quota ||
 +def-cputune.emulatorpin)
  virBufferAddLit(buf,   /cputune\n);
  
  if 

Re: [libvirt] [PATCH v2.1 00/21] Supports for emulator-pin and emulator-bandwidth

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:23PM +0800, Hu Tao wrote:
 This series adds support of emulator-pin to pin emulator threads on
 specified physical CPUs, and emulator-bandwidth to control physical
 CPU bandwidth for emulator threads.
 
 changes:
 
 v2.1:
   - rebase
   - include emulator-bandwidth patches
   - minor fix of virCgroupAddTaskStrController

  Okay, i have pushed patch 1-9 based on Dan reviews and mine,
I'm looking at the end of that set now,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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] atomic: mark header functions static

2012-08-22 Thread Daniel P. Berrange
On Tue, Aug 21, 2012 at 01:55:33PM -0600, Eric Blake wrote:
 When gcc atomic intrinsics are not available (such as on RHEL 5
 with gcc 4.1.2), we were getting link errors due to multiple
 definitions:
 
 ./.libs/libvirt_util.a(libvirt_util_la-virobject.o): In function 
 `virAtomicIntXor':
 /home/dummy/l,ibvirt/src/util/viratomoic.h:404: multiple definition of 
 `virAtomicIntXor'
 ./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):/home/dummy/libvirt/src/util/viratomic.h:404:
  first defined here
 
 Solve this by conditionally marking the functions static (the
 condition avoids falling foul of gcc warnings about unused
 static function declarations).
 
 * src/util/viratomic.h: When not using gcc intrinsics, use static
 functions to avoid linker errors on duplicate functions.
 ---
 
 Pushing under the build-breaker rule.  Tested on both RHEL 5
 and modern gcc of F17.
 
 Oh, and I just noticed my indentation is off, while preparing
 this email; I'll squash in the whitespace fix before pushing.
 
  src/util/viratomic.h | 75 
 
  1 file changed, 41 insertions(+), 34 deletions(-)


ACK, this looks good to me.

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

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


Re: [libvirt] [PATCH v2.1 10/21] qemu: synchronize emulatorpin info to cgroup

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:33PM +0800, Hu Tao wrote:
 From: Tang Chen tangc...@cn.fujitsu.com
 
 Introduce qemuSetupCgroupEmulatorPin() function to add emulator
 threads pin info to cpuset cgroup, the same as vcpupin.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Hu Tao hu...@cn.fujitsu.com
 ---
  src/qemu/qemu_cgroup.c |   51 
 
  src/qemu/qemu_cgroup.h |1 +
  2 files changed, 35 insertions(+), 17 deletions(-)
 
 diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
 index 37874d3..9bebfd5 100644
 --- a/src/qemu/qemu_cgroup.c
 +++ b/src/qemu/qemu_cgroup.c
 @@ -496,29 +496,40 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
 int nvcpupin,
 int vcpuid)
  {
 -int i, rc = 0;
 -char *new_cpus = NULL;
 +int i;
  
  for (i = 0; i  nvcpupin; i++) {
  if (vcpuid == vcpupin[i]-vcpuid) {
 -new_cpus = virDomainCpuSetFormat(vcpupin[i]-cpumask,
 - VIR_DOMAIN_CPUMASK_LEN);
 -if (!new_cpus) {
 -virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 -   _(failed to convert cpu mask));
 -rc = -1;
 -goto cleanup;
 -}
 -rc = virCgroupSetCpusetCpus(cgroup, new_cpus);
 -if (rc != 0) {
 -virReportSystemError(-rc,
 - %s,
 - _(Unable to set cpuset.cpus));
 -goto cleanup;
 -}
 +return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]);
  }
  }
  
 +return -1;
 +}
 +
 +int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup,
 +   virDomainVcpuPinDefPtr vcpupin)
 +{
 +int rc = 0;
 +char *new_cpus = NULL;
 +
 +new_cpus = virDomainCpuSetFormat(vcpupin-cpumask,
 + VIR_DOMAIN_CPUMASK_LEN);
 +if (!new_cpus) {
 +virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 +   _(failed to convert cpu mask));
 +rc = -1;
 +goto cleanup;
 +}
 +
 +rc = virCgroupSetCpusetCpus(cgroup, new_cpus);
 +if (rc  0) {
 +virReportSystemError(-rc,
 + %s,
 + _(Unable to set cpuset.cpus));
 +goto cleanup;
 +}
 +
  cleanup:
  VIR_FREE(new_cpus);
  return rc;
 @@ -636,6 +647,7 @@ int qemuSetupCgroupForEmulator(struct qemud_driver 
 *driver,
  {
  virCgroupPtr cgroup = NULL;
  virCgroupPtr cgroup_emulator = NULL;
 +virDomainDefPtr def = vm-def;
  int rc, i;
  
  if (driver-cgroup == NULL)
 @@ -672,6 +684,11 @@ int qemuSetupCgroupForEmulator(struct qemud_driver 
 *driver,
  }
  }
  
 +if (def-cputune.emulatorpin 
 +qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET) 
 +qemuSetupCgroupEmulatorPin(cgroup_emulator, 
 def-cputune.emulatorpin)  0)
 +goto cleanup;
 +
  virCgroupFree(cgroup_emulator);
  virCgroupFree(cgroup);
  return 0;
 diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
 index fa93cdb..04f70a1 100644
 --- a/src/qemu/qemu_cgroup.h
 +++ b/src/qemu/qemu_cgroup.h
 @@ -57,6 +57,7 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
 virDomainVcpuPinDefPtr *vcpupin,
 int nvcpupin,
 int vcpuid);
 +int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup, virDomainVcpuPinDefPtr 
 vcpupin);
  int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm);
  int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
 virDomainObjPtr vm);

  ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 11/21] Add qemuProcessSetEmulatorAffinites and set emulator threads affinities

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:34PM +0800, Hu Tao wrote:
 From: Tang Chen tangc...@cn.fujitsu.com
 
 Emulator threads should also be pinned by sched_setaffinity(), just
 the same as vcpu threads.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Hu Tao hu...@cn.fujitsu.com
 ---
  src/qemu/qemu_process.c |   54 
 +++
  1 file changed, 54 insertions(+)
 
 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
 index 762f298..90d44c4 100644
 --- a/src/qemu/qemu_process.c
 +++ b/src/qemu/qemu_process.c
 @@ -2002,6 +2002,56 @@ cleanup:
  return ret;
  }
  
 +/* Set CPU affinities for emulator threads if emulatorpin xml provided. */
 +static int
 +qemuProcessSetEmulatorAffinites(virConnectPtr conn,
 +virDomainObjPtr vm)
 +{
 +virDomainDefPtr def = vm-def;
 +pid_t pid = vm-pid;
 +unsigned char *cpumask = NULL;
 +unsigned char *cpumap = NULL;
 +virNodeInfo nodeinfo;
 +int cpumaplen, hostcpus, maxcpu, i;
 +int ret = -1;
 +
 +if (virNodeGetInfo(conn, nodeinfo) != 0)
 +return -1;
 +
 +if (!def-cputune.emulatorpin)
 +return 0;
 +
 +hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
 +cpumaplen = VIR_CPU_MAPLEN(hostcpus);
 +maxcpu = cpumaplen * CHAR_BIT;
 +
 +if (maxcpu  hostcpus)
 +maxcpu = hostcpus;
 +
 +if (VIR_ALLOC_N(cpumap, cpumaplen)  0) {
 +virReportOOMError();
 +return -1;
 +}
 +
 +cpumask = (unsigned char *)def-cputune.emulatorpin-cpumask;
 +for(i = 0; i  VIR_DOMAIN_CPUMASK_LEN; i++) {

   missing space between for and (

 +if (cpumask[i])
 +VIR_USE_CPU(cpumap, i);
 +}
 +
 +if (virProcessInfoSetAffinity(pid,
 +  cpumap,
 +  cpumaplen,
 +  maxcpu)  0) {
 +goto cleanup;
 +}
 +
 +ret = 0;
 +cleanup:
 +VIR_FREE(cpumap);
 +return ret;
 +}
 +
  static int
  qemuProcessInitPasswords(virConnectPtr conn,
   struct qemud_driver *driver,
 @@ -3764,6 +3814,10 @@ int qemuProcessStart(virConnectPtr conn,
  if (qemuProcessSetVcpuAffinites(conn, vm)  0)
  goto cleanup;
  
 +VIR_DEBUG(Setting affinity of emulator threads);
 +if (qemuProcessSetEmulatorAffinites(conn, vm)  0)
 +goto cleanup;
 +
  VIR_DEBUG(Setting any required VM passwords);
  if (qemuProcessInitPasswords(conn, driver, vm)  0)
  goto cleanup;

  Looks okay, ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 13/21] Introduce virDomainEmulatorPinAdd and virDomainEmulatorPinDel functions

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:36PM +0800, Hu Tao wrote:
 From: Tang Chen tangc...@cn.fujitsu.com
 
 Introduce 2 APIs to support emulator threads pin.
 1) virDomainEmulatorPinAdd: setup emulator threads pin with a given 
 cpumap string.
 2) virDomainEmulatorPinDel: remove all emulator threads pin.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Hu Tao hu...@cn.fujitsu.com
 ---
  src/conf/domain_conf.c   |   71 
 ++
  src/conf/domain_conf.h   |6 
  src/libvirt_private.syms |2 ++
  3 files changed, 79 insertions(+)
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index 94ec095..dab9c5d 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -11076,6 +11076,77 @@ virDomainVcpuPinDel(virDomainDefPtr def, int vcpu)
  return 0;
  }
  
 +int
 +virDomainEmulatorPinAdd(virDomainDefPtr def,
 +unsigned char *cpumap,
 +int maplen)
 +{
 +virDomainVcpuPinDefPtr emulatorpin = NULL;
 +char *cpumask = NULL;
 +int i;
 +
 +if (VIR_ALLOC_N(cpumask, VIR_DOMAIN_CPUMASK_LEN)  0) {
 +virReportOOMError();
 +goto cleanup;
 +}
 +
 +/* Convert bitmap (cpumap) to cpumask, which is byte map. */
 +for (i = 0; i  maplen; i++) {
 +int cur;
 +
 +for (cur = 0; cur  8; cur++) {
 +if (cpumap[i]  (1  cur))
 +cpumask[i * 8 + cur] = 1;
 +}
 +}
 +
 +if (!def-cputune.emulatorpin) {
 +/* No emulatorpin exists yet. */
 +if (VIR_ALLOC(emulatorpin)  0) {
 +virReportOOMError();
 +goto cleanup;
 +}
 +
 +emulatorpin-vcpuid = -1;
 +emulatorpin-cpumask = cpumask;
 +def-cputune.emulatorpin = emulatorpin;
 +} else {
 +/* Since there is only 1 emulatorpin for each vm,
 + * juest replace the old one.
 + */
 +VIR_FREE(def-cputune.emulatorpin-cpumask);
 +def-cputune.emulatorpin-cpumask = cpumask;
 +}
 +
 +return 0;
 +
 +cleanup:
 +VIR_FREE(cpumask);
 +return -1;
 +}
 +
 +int
 +virDomainEmulatorPinDel(virDomainDefPtr def)
 +{
 +virDomainVcpuPinDefPtr emulatorpin = NULL;
 +
 +/* No emulatorpin exists yet */
 +if (!def-cputune.emulatorpin) {
 +return 0;
 +}
 +
 +emulatorpin = def-cputune.emulatorpin;
 +
 +VIR_FREE(emulatorpin-cpumask);
 +VIR_FREE(emulatorpin);
 +def-cputune.emulatorpin = NULL;
 +
 +if (def-cputune.emulatorpin)
 +return -1;
 +
 +return 0;
 +}
 +
  static int
  virDomainLifecycleDefFormat(virBufferPtr buf,
  int type,
 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
 index a7b2ff6..b6bf5a8 100644
 --- a/src/conf/domain_conf.h
 +++ b/src/conf/domain_conf.h
 @@ -1982,6 +1982,12 @@ int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr 
 *vcpupin_list,
  
  int virDomainVcpuPinDel(virDomainDefPtr def, int vcpu);
  
 +int virDomainEmulatorPinAdd(virDomainDefPtr def,
 +  unsigned char *cpumap,
 +  int maplen);
 +
 +int virDomainEmulatorPinDel(virDomainDefPtr def);
 +
  int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
   bool allow_ambiguous);
  const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 80ea39a..d51a387 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -509,6 +509,8 @@ virDomainVcpuPinAdd;
  virDomainVcpuPinDefCopy;
  virDomainVcpuPinDefFree;
  virDomainVcpuPinDel;
 +virDomainEmulatorPinAdd;
 +virDomainEmulatorPinDel;
  virDomainVcpuPinFindByVcpu;
  virDomainVcpuPinIsDuplicate;
  virDomainVideoDefFree;

  Okay, very similar to the Vcpu counterparts.
However the symbols file should be kept sorted so added that fix

Daniel


diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6af099b..8962de2 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -345,6 +345,8 @@ virDomainDiskSnapshotTypeFromString;
 virDomainDiskSnapshotTypeToString;
 virDomainDiskTypeFromString;
 virDomainDiskTypeToString;
+virDomainEmulatorPinAdd;
+virDomainEmulatorPinDel;
 virDomainFSDefFree;
 virDomainFSIndexByName;
 virDomainFSTypeFromString;
@@ -511,8 +513,6 @@ virDomainVcpuPinAdd;
 virDomainVcpuPinDefCopy;
 virDomainVcpuPinDefFree;
 virDomainVcpuPinDel;
-virDomainEmulatorPinAdd;
-virDomainEmulatorPinDel;
 virDomainVcpuPinFindByVcpu;
 virDomainVcpuPinIsDuplicate;
 virDomainVideoDefFree;

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 12/21] Introduce virDomainPinEmulator and virDomainGetEmulatorPinInfo functions.

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:35PM +0800, Hu Tao wrote:
 From: Tang Chen tangc...@cn.fujitsu.com
 
 Introduce 2 APIs to set/get physical cpu pinning info of emulator threads.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Hu Tao hu...@cn.fujitsu.com
 ---
  include/libvirt/libvirt.h.in |   10 +++
  src/driver.h |   12 
  src/libvirt.c|  147 
 ++
  src/libvirt_public.syms  |2 +
  4 files changed, 171 insertions(+)
 
 diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
 index 77a061e..43774eb 100644
 --- a/include/libvirt/libvirt.h.in
 +++ b/include/libvirt/libvirt.h.in
 @@ -1916,6 +1916,16 @@ int virDomainGetVcpuPinInfo 
 (virDomainPtr domain,
   int maplen,
   unsigned int flags);
  
 +int virDomainPinEmulator   (virDomainPtr domain,
 +unsigned char *cpumap,
 +int maplen,
 +unsigned int flags);
 +
 +int virDomainGetEmulatorPinInfo (virDomainPtr domain,
 + unsigned char *cpumaps,
 + int maplen,
 + unsigned int flags);
 +

  okay, based on existing APIs like virDomainPinVcpuFlags that is
  consistent,

  /**
   * VIR_USE_CPU:
   * @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN/OUT)
 diff --git a/src/driver.h b/src/driver.h
 index 203497d..5fa2d36 100644
 --- a/src/driver.h
 +++ b/src/driver.h
 @@ -306,6 +306,16 @@ typedef int
   unsigned char *cpumaps,
   int maplen,
   unsigned int flags);
 + typedef int
 +(*virDrvDomainPinEmulator) (virDomainPtr domain,
 +unsigned char *cpumap,
 +int maplen,
 +unsigned int flags);
 +typedef int
 +(*virDrvDomainGetEmulatorPinInfo)   (virDomainPtr domain,
 + unsigned char *cpumaps,
 + int maplen,
 + unsigned int flags);
  
  typedef int
  (*virDrvDomainGetVcpus) (virDomainPtr domain,
 @@ -941,6 +951,8 @@ struct _virDriver {
  virDrvDomainPinVcpu domainPinVcpu;
  virDrvDomainPinVcpuFlagsdomainPinVcpuFlags;
  virDrvDomainGetVcpuPinInfo  domainGetVcpuPinInfo;
 +virDrvDomainPinEmulator domainPinEmulator;
 +virDrvDomainGetEmulatorPinInfo  domainGetEmulatorPinInfo;
  virDrvDomainGetVcpusdomainGetVcpus;
  virDrvDomainGetMaxVcpus domainGetMaxVcpus;
  virDrvDomainGetSecurityLabeldomainGetSecurityLabel;
 diff --git a/src/libvirt.c b/src/libvirt.c
 index b3fc8a8..60ce6d1 100644
 --- a/src/libvirt.c
 +++ b/src/libvirt.c
 @@ -8858,6 +8858,153 @@ error:
  }
  
  /**
 + * virDomainPinEmulator:
 + * @domain: pointer to domain object, or NULL for Domain0
 + * @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN)
 + *  Each bit set to 1 means that corresponding CPU is usable.
 + *  Bytes are stored in little-endian order: CPU0-7, 8-15...
 + *  In each byte, lowest CPU number is least significant bit.
 + * @maplen: number of bytes in cpumap, from 1 up to size of CPU map in
 + *  underlying virtualization system (Xen...).
 + *  If maplen  size, missing bytes are set to zero.
 + *  If maplen  size, failure code is returned.
 + * @flags: bitwise-OR of virDomainModificationImpact
 + *
 + * Dynamically change the real CPUs which can be allocated to all emulator
 + * threads. This function may require privileged access to the hypervisor.
 + *
 + * @flags may include VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG.
 + * Both flags may be set.
 + * If VIR_DOMAIN_AFFECT_LIVE is set, the change affects a running domain
 + * and may fail if domain is not alive.
 + * If VIR_DOMAIN_AFFECT_CONFIG is set, the change affects persistent state,
 + * and will fail for transient domains. If neither flag is specified (that 
 is,
 + * @flags is VIR_DOMAIN_AFFECT_CURRENT), then an inactive domain modifies
 + * persistent setup, while an active domain is hypervisor-dependent on 
 whether
 + * just live or both live and persistent state is changed.
 + * Not all hypervisors can support all flag combinations.
 + *
 + * See also virDomainGetEmulatorPinInfo for querying this information.
 + *
 + * Returns 0 in case of success, -1 in case of failure.
 + *
 + */
 +int
 

Re: [libvirt] [PATCH v2.1 14/21] qemu: support emulator pinning

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:37PM +0800, Hu Tao wrote:
 Introduce 2 APIs to support emulator threads pin in qemu driver.
 
 1) qemudDomainPinEmulator: setup emulator threads pin info.
 2) qemudDomainGetEmulatorPinInfo: get all emulator threads pin info.
 
 They are similar to qemudDomainPinVcpuFlags and qemudDomainGetVcpuPinInfo.
 And also, remoteDispatchDomainPinEmulatorFlags and 
 remoteDispatchDomainGetEmulatorPinInfo
 functions are introduced.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Hu Tao hu...@cn.fujitsu.com
 ---
  src/qemu/qemu_driver.c |  241 
 
  1 file changed, 241 insertions(+)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 4552172..3c8bbb7 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -3984,6 +3984,245 @@ cleanup:
  }
  
  static int
 +qemudDomainPinEmulator(virDomainPtr dom,
 +   unsigned char *cpumap,
 +   int maplen,
 +   unsigned int flags)
 +{
 +struct qemud_driver *driver = dom-conn-privateData;
 +virDomainObjPtr vm;
 +virCgroupPtr cgroup_dom = NULL;
 +virCgroupPtr cgroup_emulator = NULL;
 +pid_t pid;
 +virDomainDefPtr persistentDef = NULL;
 +int maxcpu, hostcpus;
 +virNodeInfo nodeinfo;
 +int ret = -1;
 +qemuDomainObjPrivatePtr priv;
 +bool canResetting = true;
 +int pcpu;
 +int newVcpuPinNum = 0;
 +virDomainVcpuPinDefPtr *newVcpuPin = NULL;
 +
 +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
 +  VIR_DOMAIN_AFFECT_CONFIG, -1);
 +
 +qemuDriverLock(driver);
 +vm = virDomainFindByUUID(driver-domains, dom-uuid);
 +qemuDriverUnlock(driver);
 +
 +if (!vm) {
 +char uuidstr[VIR_UUID_STRING_BUFLEN];
 +virUUIDFormat(dom-uuid, uuidstr);
 +virReportError(VIR_ERR_NO_DOMAIN,
 +   _(no domain with matching uuid '%s'), uuidstr);
 +goto cleanup;
 +}
 +
 +if (virDomainLiveConfigHelperMethod(driver-caps, vm, flags,
 +persistentDef)  0)
 +goto cleanup;
 +
 +priv = vm-privateData;
 +
 +if (nodeGetInfo(dom-conn, nodeinfo)  0)
 +goto cleanup;
 +hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
 +maxcpu = maplen * 8;
 +if (maxcpu  hostcpus)
 +maxcpu = hostcpus;
 +/* pinning to all physical cpus means resetting,
 + * so check if we can reset setting.
 + */
 +for (pcpu = 0; pcpu  hostcpus; pcpu++) {
 +if ((cpumap[pcpu/8]  (1  (pcpu % 8))) == 0) {
 +canResetting = false;
 +break;
 +}
 +}
 +
 +pid = vm-pid;
 +
 +if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 +
 +if (priv-vcpupids != NULL) {
 +if (VIR_ALLOC(newVcpuPin)  0) {
 +virReportOOMError();
 +goto cleanup;
 +newVcpuPinNum = 0;
 +}
 +
 +if (virDomainVcpuPinAdd(newVcpuPin, newVcpuPinNum, cpumap, 
 maplen, -1)  0) {
 +virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 +   _(failed to update vcpupin));
 +virDomainVcpuPinDefFree(newVcpuPin, newVcpuPinNum);
 +goto cleanup;
 +}
 +
 +if (qemuCgroupControllerActive(driver,
 +   VIR_CGROUP_CONTROLLER_CPUSET)) {
 +/*
 + * Configure the corresponding cpuset cgroup.
 + * If no cgroup for domain or hypervisor exists, do nothing.
 + */
 +if (virCgroupForDomain(driver-cgroup, vm-def-name,
 +   cgroup_dom, 0) == 0) {
 +if (virCgroupForEmulator(cgroup_dom, cgroup_emulator, 
 0) == 0) {
 +if (qemuSetupCgroupEmulatorPin(cgroup_emulator, 
 newVcpuPin[0])  0) {
 +virReportError(VIR_ERR_OPERATION_INVALID, %s,
 +   _(failed to set cpuset.cpus in 
 cgroup
 +  for emulator threads));
 +goto cleanup;
 +}
 +}
 +}
 +} else {
 +if (virProcessInfoSetAffinity(pid, cpumap, maplen, maxcpu)  
 0) {
 +virReportError(VIR_ERR_SYSTEM_ERROR, %s,
 +   _(failed to set cpu affinity for 
 + emulator threads));
 +goto cleanup;
 +}
 +}
 +
 +if (canResetting) {
 +if (virDomainEmulatorPinDel(vm-def)  0) {
 +virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 +   _(failed to delete emulatorpin xml of 
 + a running domain));
 +goto 

Re: [libvirt] [PATCH v2.1 15/21] remote: introduce emulator pinning RPCs

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:38PM +0800, Hu Tao wrote:
 From: Tang Chen tangc...@cn.fujitsu.com
 
 Introduce 2 APIs to support emulator threads in remote driver.
 1) remoteDomainPinEmulator: call driver api, such as 
 qemudDomainPinEmulator.
 2) remoteDomainGetEmulatorPinInfo: call driver api, such as 
 qemudDomainGetEmulatorPinInfo.
 They are similar to remoteDomainPinVcpuFlags and remoteDomainGetVcpuPinInfo.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Hu Tao hu...@cn.fujitsu.com
 ---
  daemon/remote.c  |   91 ++
  src/remote/remote_driver.c   |   99 
 ++
  src/remote/remote_protocol.x |   21 -
  src/remote_protocol-structs  |   22 ++
  4 files changed, 232 insertions(+), 1 deletion(-)
 
 diff --git a/daemon/remote.c b/daemon/remote.c
 index f82af86..24928f4 100644
 --- a/daemon/remote.c
 +++ b/daemon/remote.c
 @@ -1593,6 +1593,97 @@ no_memory:
  }
  
  static int
 +remoteDispatchDomainPinEmulator(virNetServerPtr server ATTRIBUTE_UNUSED,
 +virNetServerClientPtr client,
 +virNetMessagePtr msg ATTRIBUTE_UNUSED,
 +virNetMessageErrorPtr rerr,
 +remote_domain_pin_emulator_args *args)
 +{
 +int rv = -1;
 +virDomainPtr dom = NULL;
 +struct daemonClientPrivate *priv =
 +virNetServerClientGetPrivateData(client);
 +
 +if (!priv-conn) {
 +virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(connection not 
 open));
 +goto cleanup;
 +}
 +
 +if (!(dom = get_nonnull_domain(priv-conn, args-dom)))
 +goto cleanup;
 +
 +if (virDomainPinEmulator(dom,
 + (unsigned char *) args-cpumap.cpumap_val,
 + args-cpumap.cpumap_len,
 + args-flags)  0)
 +goto cleanup;
 +
 +rv = 0;
 +
 +cleanup:
 +if (rv  0)
 +virNetMessageSaveError(rerr);
 +if (dom)
 +virDomainFree(dom);
 +return rv;
 +}
 +
 +
 +static int
 +remoteDispatchDomainGetEmulatorPinInfo(virNetServerPtr server 
 ATTRIBUTE_UNUSED,
 +   virNetServerClientPtr client 
 ATTRIBUTE_UNUSED,
 +   virNetMessagePtr msg ATTRIBUTE_UNUSED,
 +   virNetMessageErrorPtr rerr,
 +   
 remote_domain_get_emulator_pin_info_args *args,
 +   
 remote_domain_get_emulator_pin_info_ret *ret)
 +{
 +virDomainPtr dom = NULL;
 +unsigned char *cpumaps = NULL;
 +int r;
 +int rv = -1;
 +struct daemonClientPrivate *priv =
 +virNetServerClientGetPrivateData(client);
 +
 +if (!priv-conn) {
 +virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(connection not 
 open));
 +goto cleanup;
 +}
 +
 +if (!(dom = get_nonnull_domain(priv-conn, args-dom)))
 +goto cleanup;
 +
 +/* Allocate buffers to take the results */
 +if (args-maplen  0 
 +VIR_ALLOC_N(cpumaps, args-maplen)  0)
 +goto no_memory;
 +
 +if ((r = virDomainGetEmulatorPinInfo(dom,
 + cpumaps,
 + args-maplen,
 + args-flags))  0)
 +goto cleanup;
 +
 +ret-ret = r;
 +ret-cpumaps.cpumaps_len = args-maplen;
 +ret-cpumaps.cpumaps_val = (char *) cpumaps;
 +cpumaps = NULL;
 +
 +rv = 0;
 +
 +cleanup:
 +if (rv  0)
 +virNetMessageSaveError(rerr);
 +VIR_FREE(cpumaps);
 +if (dom)
 +virDomainFree(dom);
 +return rv;
 +
 +no_memory:
 +virReportOOMError();
 +goto cleanup;
 +}
 +
 +static int
  remoteDispatchDomainGetVcpus(virNetServerPtr server ATTRIBUTE_UNUSED,
   virNetServerClientPtr client ATTRIBUTE_UNUSED,
   virNetMessagePtr msg ATTRIBUTE_UNUSED,
 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
 index 977d139..841f9a3 100644
 --- a/src/remote/remote_driver.c
 +++ b/src/remote/remote_driver.c
 @@ -1843,6 +1843,103 @@ done:
  }
  
  static int
 +remoteDomainPinEmulator (virDomainPtr dom,
 + unsigned char *cpumap,
 + int cpumaplen,
 + unsigned int flags)
 +{
 +int rv = -1;
 +struct private_data *priv = dom-conn-privateData;
 +remote_domain_pin_emulator_args args;
 +
 +remoteDriverLock(priv);
 +
 +if (cpumaplen  REMOTE_CPUMAP_MAX) {
 +virReportError(VIR_ERR_RPC,
 +   _(%s length greater than maximum: %d  %d),
 +   cpumap, cpumaplen, REMOTE_CPUMAP_MAX);
 +goto done;
 +}
 +
 +make_nonnull_domain(args.dom, dom);
 +args.cpumap.cpumap_val = (char *)cpumap;
 +

Re: [libvirt] [PATCHv6 2/2] qemu: Disk Geometry Override Support

2012-08-22 Thread Viktor Mihajlovski

On 08/21/2012 11:36 PM, Eric Blake wrote:

Pushed with this squashed in:

diff --git i/src/qemu/qemu_command.c w/src/qemu/qemu_command.c
index cdc8e55..ca62f0c 100644
--- i/src/qemu/qemu_command.c
+++ w/src/qemu/qemu_command.c
@@ -2281,7 +2281,7 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
  qemuCapsGet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT))
  virBufferAsprintf(opt, ,format=%s, disk-driverType);

-/* generate geometry command string*/
+/* generate geometry command string */
  if (disk-geometry.cylinders  0 
  disk-geometry.heads  0 
  disk-geometry.sectors  0) {
diff --git i/tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args
w/tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args
index 7cd6650..c0de2ed 100644
--- i/tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args
+++ w/tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args
@@ -1,4 +1,5 @@
  LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu
-S -M \
  pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
--no-acpi -boot c -drive
file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,cyls=16383,heads=16,secs=63,trans=lba
\
+-no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,\
+cyls=16383,heads=16,secs=63,trans=lba \
  -net none -serial none -parallel none -usb



Thanks Eric.

--

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

IBM Deutschland Research  Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

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


Re: [libvirt] [PATCH v2.1 16/21] Add a new function vshPrintPinInfo.

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:39PM +0800, Hu Tao wrote:
 This is a helper function to print vcpu pin info.
 ---
  tools/virsh-domain.c |   65 
 --
  1 file changed, 42 insertions(+), 23 deletions(-)
 
 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
 index 94ac1aa..047d374 100644
 --- a/tools/virsh-domain.c
 +++ b/tools/virsh-domain.c
 @@ -4525,6 +4525,45 @@ static const vshCmdOptDef opts_vcpupin[] = {
  {NULL, 0, 0, NULL}
  };
  
 +/*
 + * Helper function to print vcpupin info.
 + */
 +static bool
 +vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen,
 +int maxcpu, int vcpuindex)
 +{
 +int cpu, lastcpu;
 +bool bit, lastbit, isInvert;
 +
 +if (!cpumaps || cpumaplen = 0 || maxcpu = 0 || vcpuindex  0) {
 +return false;
 +}
 +
 +bit = lastbit = isInvert = false;
 +lastcpu = -1;
 +
 +for (cpu = 0; cpu  maxcpu; cpu++) {
 +bit = VIR_CPU_USABLE(cpumaps, cpumaplen, vcpuindex, cpu);
 +
 +isInvert = (bit ^ lastbit);
 +if (bit  isInvert) {
 +if (lastcpu == -1)
 +vshPrint(ctl, %d, cpu);
 +else
 +vshPrint(ctl, ,%d, cpu);
 +lastcpu = cpu;
 +}
 +if (!bit  isInvert  lastcpu != cpu - 1)
 +vshPrint(ctl, -%d, cpu - 1);
 +lastbit = bit;
 +}
 +if (bit  !isInvert) {
 +vshPrint(ctl, -%d, maxcpu - 1);
 +}
 +
 +return true;
 +}
 +
  static bool
  cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
  {
 @@ -4537,7 +4576,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
  unsigned char *cpumap = NULL;
  unsigned char *cpumaps = NULL;
  size_t cpumaplen;
 -bool bit, lastbit, isInvert;
  int i, cpu, lastcpu, maxcpu, ncpus;
  bool unuse = false;
  const char *cur;
 @@ -4622,30 +4660,11 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
 if (vcpu != -1  i != vcpu)
 continue;
  
 -   bit = lastbit = isInvert = false;
 -   lastcpu = -1;
 -
 vshPrint(ctl, %4d: , i);
 -   for (cpu = 0; cpu  maxcpu; cpu++) {
 -
 -   bit = VIR_CPU_USABLE(cpumaps, cpumaplen, i, cpu);
 -
 -   isInvert = (bit ^ lastbit);
 -   if (bit  isInvert) {
 -   if (lastcpu == -1)
 -   vshPrint(ctl, %d, cpu);
 -   else
 -   vshPrint(ctl, ,%d, cpu);
 -   lastcpu = cpu;
 -   }
 -   if (!bit  isInvert  lastcpu != cpu - 1)
 -   vshPrint(ctl, -%d, cpu - 1);
 -   lastbit = bit;
 -   }
 -   if (bit  !isInvert) {
 -  vshPrint(ctl, -%d, maxcpu - 1);
 -   }
 +   ret = vshPrintPinInfo(cpumaps, cpumaplen, maxcpu, i);
 vshPrint(ctl, \n);
 +   if (!ret)
 +   break;
  }
  
  } else {

  Okay, just a bit of refactoring, ACK

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 17/21] new command emulatorpin

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:40PM +0800, Hu Tao wrote:
 ---
  tools/virsh-domain.c |  188 
 ++
  tools/virsh.pod  |   16 +
  2 files changed, 204 insertions(+)
 
 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
 index 047d374..95015ad 100644
 --- a/tools/virsh-domain.c
 +++ b/tools/virsh-domain.c
 @@ -4769,6 +4769,193 @@ parse_error:
  }
  
  /*
 + * emulatorpin command
 + */
 +static const vshCmdInfo info_emulatorpin[] = {
 +{help, N_(control or query domain emulator affinity)},
 +{desc, N_(Pin domain emulator threads to host physical CPUs.)},
 +{NULL, NULL}
 +};
 +
 +static const vshCmdOptDef opts_emulatorpin[] = {
 +{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
 +{cpulist, VSH_OT_DATA, VSH_OFLAG_EMPTY_OK,
 + N_(host cpu number(s) to set, or omit option to query)},
 +{config, VSH_OT_BOOL, 0, N_(affect next boot)},
 +{live, VSH_OT_BOOL, 0, N_(affect running domain)},
 +{current, VSH_OT_BOOL, 0, N_(affect current domain)},
 +{NULL, 0, 0, NULL}
 +};
 +
 +static bool
 +cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
 +{
 +virDomainPtr dom;
 +virNodeInfo nodeinfo;
 +const char *cpulist = NULL;
 +bool ret = true;
 +unsigned char *cpumap = NULL;
 +unsigned char *cpumaps = NULL;
 +size_t cpumaplen;
 +int i, cpu, lastcpu, maxcpu;
 +bool unuse = false;
 +const char *cur;
 +bool config = vshCommandOptBool(cmd, config);
 +bool live = vshCommandOptBool(cmd, live);
 +bool current = vshCommandOptBool(cmd, current);
 +bool query = false; /* Query mode if no cpulist */
 +unsigned int flags = 0;
 +
 +if (current) {
 +if (live || config) {
 +vshError(ctl, %s, _(--current must be specified 
 exclusively));
 +return false;
 +}
 +flags = VIR_DOMAIN_AFFECT_CURRENT;
 +} else {
 +if (config)
 +flags |= VIR_DOMAIN_AFFECT_CONFIG;
 +if (live)
 +flags |= VIR_DOMAIN_AFFECT_LIVE;
 +/* neither option is specified */
 +if (!live  !config)
 +flags = -1;
 +}
 +
 +if (!vshConnectionUsability(ctl, ctl-conn))
 +return false;
 +
 +if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
 +return false;
 +
 +if (vshCommandOptString(cmd, cpulist, cpulist)  0) {
 +vshError(ctl, %s, _(emulatorpin: Missing cpulist.));
 +virDomainFree(dom);
 +return false;
 +}
 +query = !cpulist;
 +
 +if (virNodeGetInfo(ctl-conn, nodeinfo) != 0) {
 +virDomainFree(dom);
 +return false;
 +}
 +
 +maxcpu = VIR_NODEINFO_MAXCPUS(nodeinfo);
 +cpumaplen = VIR_CPU_MAPLEN(maxcpu);
 +
 +/* Query mode: show CPU affinity information then exit.*/
 +if (query) {
 +/* When query mode and neither live, config nor current
 + * is specified, set VIR_DOMAIN_AFFECT_CURRENT as flags */
 +if (flags == -1)
 +flags = VIR_DOMAIN_AFFECT_CURRENT;
 +
 +cpumaps = vshMalloc(ctl, cpumaplen);
 +if (virDomainGetEmulatorPinInfo(dom, cpumaps,
 +cpumaplen, flags) = 0) {
 +vshPrint(ctl, %s %s\n, _(emulator:), _(CPU Affinity));
 +vshPrint(ctl, --\n);
 +vshPrint(ctl,*: );
 +ret = vshPrintPinInfo(cpumaps, cpumaplen, maxcpu, 0);
 +vshPrint(ctl, \n);
 +} else {
 +ret = false;
 +}
 +VIR_FREE(cpumaps);
 +goto cleanup;
 +}
 +
 +/* Pin mode: pinning emulator threads to specified physical cpus*/
 +
 +cpumap = vshCalloc(ctl, cpumaplen, sizeof(cpumap));
 +/* Parse cpulist */
 +cur = cpulist;
 +if (*cur == 0) {
 +goto parse_error;
 +} else if (*cur == 'r') {
 +for (cpu = 0; cpu  maxcpu; cpu++)
 +VIR_USE_CPU(cpumap, cpu);
 +cur = ;
 +}
 +
 +while (*cur != 0) {
 +
 +/* the char '^' denotes exclusive */
 +if (*cur == '^') {
 +cur++;
 +unuse = true;
 +}
 +
 +/* parse physical CPU number */
 +if (!c_isdigit(*cur))
 +goto parse_error;

   That test looks redundant to me as virParseNumber will do that check
and return -1 if it fails. I think we can remove those 2 lines and just
trust virParseNumber() , but since that check is done in cmdVcpuPin()
I will let that as a later cleanup for both

 +cpu  = virParseNumber(cur);
 +if (cpu  0) {
 +goto parse_error;
 +}
 +if (cpu = maxcpu) {
 +vshError(ctl, _(Physical CPU %d doesn't exist.), cpu);
 +goto parse_error;
 +}
 +virSkipSpaces(cur);
 +
 +if (*cur == ',' || *cur == 0) {
 +if (unuse) {
 +VIR_UNUSE_CPU(cpumap, cpu);
 +} else {
 +VIR_USE_CPU(cpumap, 

[libvirt] [PATCH] virsh: don't print error info when snapshot xml is not changed

2012-08-22 Thread Guannan Ren
If xml is not changed, error message is printed.
So check ret value instead of edit variable for error message.
---
 tools/virsh-snapshot.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index aff91d3..5d84f7a 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -449,7 +449,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
  _(Snapshot %s XML configuration not changed.\n), \
  name); \
 ret = true; \
-goto cleanup;   \
+goto edit_cleanup;  \
 }
 #define EDIT_DEFINE \
 (strstr(doc, statedisk-snapshot/state) ? \
@@ -487,10 +487,10 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
 ret = true;
 
 cleanup:
+if (!ret)
+vshError(ctl, _(Failed to update %s), name);
 if (edited)
 virDomainSnapshotFree(edited);
-else
-vshError(ctl, _(Failed to update %s), name);
 if (snapshot)
 virDomainSnapshotFree(snapshot);
 if (dom)
-- 
1.7.10.1

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


Re: [libvirt] [PATCH v2.1 18/21] limit cpu bandwidth only for vcpus

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:41PM +0800, Hu Tao wrote:
 This patch changes the behaviour of xml element cputune.period
 and cputune.quota to limit cpu bandwidth only for vcpus, and no
 longer limit cpu bandwidth for the whole guest.
 
 The reasons to do this are:
 
   - This matches docs of cputune.period and cputune.quota.
   - The other parts excepting vcpus are treated as emulator,
 and there are separate period/quota settings for emulator
 in the subsequent patches

  The real question is if this is actualy a change of behaviour.
I think it is, but without doing this this gets quite hard to
effectively control separately the usage for the hypervisor threads
versus those of the guests.
  This is also the point of that large patch set ... so ACK based
on the fact that people saw that coming and won't disagree with that
possible small change in the control.

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 19/21] qemu: introduce period/quota tuning for emulator

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:42PM +0800, Hu Tao wrote:
 This patch introduces support of setting emulator's period and
 quota to limit cpu bandwidth when the vm starts.  Also updates
 XML Schema for new entries and docs.
 ---
  docs/formatdomain.html.in |   24 
  docs/schemas/domaincommon.rng |   10 ++
  src/conf/domain_conf.c|   25 +++--
  src/conf/domain_conf.h|2 ++
  src/qemu/qemu_cgroup.c|   11 ++-
  5 files changed, 69 insertions(+), 3 deletions(-)
 
 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index 81ec2cd..6142f4b 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -388,6 +388,8 @@
  lt;sharesgt;2048lt;/sharesgt;
  lt;periodgt;100lt;/periodgt;
  lt;quotagt;-1lt;/quotagt;
 +lt;emulator_periodgt;100lt;/periodgt;
 +lt;emulator_quotagt;-1lt;/quotagt;
lt;/cputunegt;
...
  lt;/domaingt;
 @@ -451,6 +453,28 @@
  span class=sinceOnly QEMU driver support since 0.9.4, LXC since
  0.9.10/span
/dd
 +
 +  dtcodeemulator_period/code/dt
 +  dd
 +The optional codeemulator_period/code element specifies the 
 enforcement
 +interval(unit: microseconds). Within codeemulator_period/code, 
 emulator
 +threads(those excluding vcpus) of the domain will not be allowed to 
 consume
 +more than codeemulator_quota/code worth of runtime. The value 
 should be
 +in range [1000, 100]. A period with value 0 means no value.
 +span class=sinceOnly QEMU driver support since 0.10.0/span
 +  /dd
 +  dtcodeemulator_quota/code/dt
 +  dd
 +The optional codeemulator_quota/code element specifies the 
 maximum
 +allowed bandwidth(unit: microseconds) for domain's emulator 
 threads(those
 +excluding vcpus). A domain with codeemulator_quota/code as any 
 negative
 +value indicates that the domain has infinite bandwidth for emulator 
 threads
 +(those excluding vcpus), which means that it is not bandwidth 
 controlled.
 +The value should be in range [1000, 18446744073709551] or less than 
 0. A
 +quota with value 0 means no value.
 +span class=sinceOnly QEMU driver support since 0.10.0/span
 +  /dd
 +
  /dl
  
  
 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
 index b02ad96..7aa6e47 100644
 --- a/docs/schemas/domaincommon.rng
 +++ b/docs/schemas/domaincommon.rng
 @@ -581,6 +581,16 @@
ref name=cpuquota/
  /element
/optional
 +  optional
 +element name=emulator_period
 +  ref name=cpuperiod/
 +/element
 +  /optional
 +  optional
 +element name=emulator_quota
 +  ref name=cpuquota/
 +/element
 +  /optional
zeroOrMore
  element name=vcpupin
attribute name=vcpu
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index dab9c5d..7bb07b4 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -8297,6 +8297,14 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
 caps,
   def-cputune.quota)  0)
  def-cputune.quota = 0;
  
 +if (virXPathULongLong(string(./cputune/emulator_period[1]), ctxt,
 +  def-cputune.emulator_period)  0)
 +def-cputune.emulator_period = 0;
 +
 +if (virXPathLongLong(string(./cputune/emulator_quota[1]), ctxt,
 + def-cputune.emulator_quota)  0)
 +def-cputune.emulator_quota = 0;
 +
  if ((n = virXPathNodeSet(./cputune/vcpupin, ctxt, nodes))  0) {
  goto error;
  }
 @@ -13030,7 +13038,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
  
  if (def-cputune.shares || def-cputune.vcpupin ||
  def-cputune.period || def-cputune.quota ||
 -def-cputune.emulatorpin)
 +def-cputune.emulatorpin ||
 +def-cputune.emulator_period || def-cputune.emulator_quota)
  virBufferAddLit(buf,   cputune\n);
  
  if (def-cputune.shares)
 @@ -13042,6 +13051,17 @@ virDomainDefFormatInternal(virDomainDefPtr def,
  if (def-cputune.quota)
  virBufferAsprintf(buf, quota%lld/quota\n,
def-cputune.quota);
 +
 +if (def-cputune.emulator_period)
 +virBufferAsprintf(buf, emulator_period%llu
 +  /emulator_period\n,
 +  def-cputune.emulator_period);
 +
 +if (def-cputune.emulator_quota)
 +virBufferAsprintf(buf, emulator_quota%lld
 +  /emulator_quota\n,
 +  def-cputune.emulator_quota);
 +
  if (def-cputune.vcpupin) {
  for (i = 0; i  def-cputune.nvcpupin; i++) {
  virBufferAsprintf(buf, vcpupin vcpu='%u' ,
 @@ -13080,7 +13100,8 @@ 

Re: [libvirt] [PATCH v2.1 20/21] new interface to control emulator_period/emulator_quota

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:43PM +0800, Hu Tao wrote:
 This patch adds two macros: VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD,
 VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA for controlling cpu bandwidth
 for emulator activities not tied to vcpus
 ---
  include/libvirt/libvirt.h.in |   24 +---
  tools/virsh.pod  |   11 ++-
  2 files changed, 27 insertions(+), 8 deletions(-)
 
 diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
 index 43774eb..cfe5047 100644
 --- a/include/libvirt/libvirt.h.in
 +++ b/include/libvirt/libvirt.h.in
 @@ -679,19 +679,37 @@ typedef virTypedParameter *virTypedParameterPtr;
   * VIR_DOMAIN_SCHEDULER_VCPU_PERIOD:
   *
   * Macro represents the enforcement period for a quota, in microseconds,
 - * when using the posix scheduler, as a ullong.
 + * for vcpus only, when using the posix scheduler, as a ullong.
   */
  #define VIR_DOMAIN_SCHEDULER_VCPU_PERIOD vcpu_period
  
  /**
   * VIR_DOMAIN_SCHEDULER_VCPU_QUOTA:
   *
 - * Macro represents the maximum bandwidth to be used within a period,
 - * when using the posix scheduler, as an llong.
 + * Macro represents the maximum bandwidth to be used within a period for
 + * vcpus only, when using the posix scheduler, as an llong.
   */
  #define VIR_DOMAIN_SCHEDULER_VCPU_QUOTA vcpu_quota
  
  /**
 + * VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD:
 + *
 + * Macro represents the enforcement period for a quota in microseconds,
 + * when using the posix scheduler, for all emulator activity not tied to
 + * vcpus, as a ullong.
 + */
 +#define VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD emulator_period
 +
 +/**
 + * VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA:
 + *
 + * Macro represents the maximum bandwidth to be used within a period for
 + * all emulator activity not tied to vcpus, when using the posix scheduler,
 + * as an llong.
 + */
 +#define VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA emulator_quota
 +
 +/**
   * VIR_DOMAIN_SCHEDULER_WEIGHT:
   *
   * Macro represents the relative weight,  when using the credit
 diff --git a/tools/virsh.pod b/tools/virsh.pod
 index ec3c331..e932d7c 100644
 --- a/tools/virsh.pod
 +++ b/tools/virsh.pod
 @@ -1202,7 +1202,8 @@ available for each hypervisor are:
  
  LXC (posix scheduler) : cpu_shares
  
 -QEMU/KVM (posix scheduler): cpu_shares, vcpu_period, vcpu_quota
 +QEMU/KVM (posix scheduler): cpu_shares, vcpu_period, vcpu_quota,
 +emulator_period, emulator_quota
  
  Xen (credit scheduler): weight, cap
  
 @@ -1220,10 +1221,10 @@ values 0 and 1 are automatically converted to a 
 minimal value of 2.
  BNote: The weight and cap parameters are defined only for the
  XEN_CREDIT scheduler and are now IDEPRECATED.
  
 -BNote: The vcpu_period parameter has a valid value range of 1000-100 or
 -0, and the vcpu_quota parameter has a valid value range of
 -1000-18446744073709551 or less than 0. The value 0 for either parameter is
 -the same as not specifying that parameter.
 +BNote: The vcpu_period/emulator_period parameters have a valid value range
 +of 1000-100 or 0, and the vcpu_quota/emulator_quota parameters have a
 +valid value range of 1000-18446744073709551 or less than 0. The value 0 for
 +either parameter is the same as not specifying that parameter.
  
  =item Bscreenshot Idomain [Iimagefilepath] [I--screen BscreenID]

  ACK, normal to expose and document those at the API level.

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 21/21] qemu: support of emulator_period and emulator_quota's modification

2012-08-22 Thread Daniel Veillard
On Tue, Aug 21, 2012 at 05:18:44PM +0800, Hu Tao wrote:
 From: Wen Congyang we...@cn.fujitsu.com
 
 allow the user change/get emulator's period and quota when the vm is running.
 ---
  src/qemu/qemu_driver.c |  133 
 +++-
  1 file changed, 132 insertions(+), 1 deletion(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 8314375..0e7dc32 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -6603,7 +6603,7 @@ static char *qemuGetSchedulerType(virDomainPtr dom,
  else if (rc == 0)
  *nparams = 1;
  else
 -*nparams = 3;
 +*nparams = 5;
  }
  
  ret = strdup(posix);
 @@ -7734,6 +7734,40 @@ cleanup:
  }
  
  static int
 +qemuSetEmulatorBandwidthLive(virDomainObjPtr vm, virCgroupPtr cgroup,
 + unsigned long long period, long long quota)
 +{
 +qemuDomainObjPrivatePtr priv = vm-privateData;
 +virCgroupPtr cgroup_emulator = NULL;
 +int rc;
 +
 +if (period == 0  quota == 0)
 +return 0;
 +
 +if (priv-nvcpupids == 0 || priv-vcpupids[0] == vm-pid) {
 +return 0;
 +}
 +
 +rc = virCgroupForEmulator(cgroup, cgroup_emulator, 0);
 +if (rc  0) {
 +virReportSystemError(-rc,
 + _(Unable to find emulator cgroup for %s),
 + vm-def-name);
 +goto cleanup;
 +}
 +
 +if (qemuSetupCgroupVcpuBW(cgroup_emulator, period, quota)  0)
 +goto cleanup;
 +
 +virCgroupFree(cgroup_emulator);
 +return 0;
 +
 +cleanup:
 +virCgroupFree(cgroup_emulator);
 +return -1;
 +}
 +
 +static int
  qemuSetSchedulerParametersFlags(virDomainPtr dom,
  virTypedParameterPtr params,
  int nparams,
 @@ -7756,6 +7790,10 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
 VIR_TYPED_PARAM_ULLONG,
 VIR_DOMAIN_SCHEDULER_VCPU_QUOTA,
 VIR_TYPED_PARAM_LLONG,
 +   VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD,
 +   VIR_TYPED_PARAM_ULLONG,
 +   VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA,
 +   VIR_TYPED_PARAM_LLONG,
 NULL)  0)
  return -1;
  
 @@ -7838,6 +7876,32 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
  if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
  vmdef-cputune.quota = params[i].value.l;
  }
 +} else if (STREQ(param-field, 
 VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD)) {
 +if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 +rc = qemuSetEmulatorBandwidthLive(vm, group, 
 params[i].value.ul, 0);
 +if (rc != 0)
 +goto cleanup;
 +
 +if (params[i].value.ul)
 +vm-def-cputune.emulator_period = params[i].value.ul;
 +}
 +
 +if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
 +vmdef-cputune.emulator_period = params[i].value.ul;
 +}
 +} else if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA)) 
 {
 +if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 +rc = qemuSetEmulatorBandwidthLive(vm, group, 0, 
 params[i].value.l);
 +if (rc != 0)
 +goto cleanup;
 +
 +if (params[i].value.l)
 +vm-def-cputune.emulator_quota = params[i].value.l;
 +}
 +
 +if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
 +vmdef-cputune.emulator_quota = params[i].value.l;
 +}
  }
  }
  
 @@ -7942,6 +8006,43 @@ cleanup:
  }
  
  static int
 +qemuGetEmulatorBandwidthLive(virDomainObjPtr vm, virCgroupPtr cgroup,
 + unsigned long long *period, long long *quota)
 +{
 +virCgroupPtr cgroup_emulator = NULL;
 +qemuDomainObjPrivatePtr priv = NULL;
 +int rc;
 +int ret = -1;
 +
 +priv = vm-privateData;
 +if (priv-nvcpupids == 0 || priv-vcpupids[0] == vm-pid) {
 +/* We don't create sub dir for each vcpu */
 +*period = 0;
 +*quota = 0;
 +return 0;
 +}
 +
 +/* get period and quota for emulator */
 +rc = virCgroupForEmulator(cgroup, cgroup_emulator, 0);
 +if (!cgroup_emulator) {
 +virReportSystemError(-rc,
 + _(Unable to find emulator cgroup for %s),
 + vm-def-name);
 +goto cleanup;
 +}
 +
 +rc = qemuGetVcpuBWLive(cgroup_emulator, period, quota);
 +if (rc  0)
 +goto cleanup;
 +
 +ret = 0;
 +
 +cleanup:
 +virCgroupFree(cgroup_emulator);
 +return ret;
 +}
 +
 +static int
  qemuGetSchedulerParametersFlags(virDomainPtr dom,
 

Re: [libvirt] [PATCH v2.1 00/21] Supports for emulator-pin and emulator-bandwidth

2012-08-22 Thread Daniel Veillard
On Wed, Aug 22, 2012 at 03:55:48PM +0800, Daniel Veillard wrote:
 On Tue, Aug 21, 2012 at 05:18:23PM +0800, Hu Tao wrote:
  This series adds support of emulator-pin to pin emulator threads on
  specified physical CPUs, and emulator-bandwidth to control physical
  CPU bandwidth for emulator threads.
  
  changes:
  
  v2.1:
- rebase
- include emulator-bandwidth patches
- minor fix of virCgroupAddTaskStrController
 
   Okay, i have pushed patch 1-9 based on Dan reviews and mine,
 I'm looking at the end of that set now,

  okay, done the whole set is in, but please answer my last question
on patch 21 review,

  thanks,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 21/21] qemu: support of emulator_period and emulator_quota's modification

2012-08-22 Thread Hu Tao
On Wed, Aug 22, 2012 at 05:04:57PM +0800, Daniel Veillard wrote:
 On Tue, Aug 21, 2012 at 05:18:44PM +0800, Hu Tao wrote:
  From: Wen Congyang we...@cn.fujitsu.com
  
  allow the user change/get emulator's period and quota when the vm is 
  running.
  ---
   src/qemu/qemu_driver.c |  133 
  +++-
   1 file changed, 132 insertions(+), 1 deletion(-)
  
  diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
  index 8314375..0e7dc32 100644
  --- a/src/qemu/qemu_driver.c
  +++ b/src/qemu/qemu_driver.c
  @@ -6603,7 +6603,7 @@ static char *qemuGetSchedulerType(virDomainPtr dom,
   else if (rc == 0)
   *nparams = 1;
   else
  -*nparams = 3;
  +*nparams = 5;
   }
   
   ret = strdup(posix);
  @@ -7734,6 +7734,40 @@ cleanup:
   }
   
   static int
  +qemuSetEmulatorBandwidthLive(virDomainObjPtr vm, virCgroupPtr cgroup,
  + unsigned long long period, long long quota)
  +{
  +qemuDomainObjPrivatePtr priv = vm-privateData;
  +virCgroupPtr cgroup_emulator = NULL;
  +int rc;
  +
  +if (period == 0  quota == 0)
  +return 0;
  +
  +if (priv-nvcpupids == 0 || priv-vcpupids[0] == vm-pid) {
  +return 0;
  +}
  +
  +rc = virCgroupForEmulator(cgroup, cgroup_emulator, 0);
  +if (rc  0) {
  +virReportSystemError(-rc,
  + _(Unable to find emulator cgroup for %s),
  + vm-def-name);
  +goto cleanup;
  +}
  +
  +if (qemuSetupCgroupVcpuBW(cgroup_emulator, period, quota)  0)
  +goto cleanup;
  +
  +virCgroupFree(cgroup_emulator);
  +return 0;
  +
  +cleanup:
  +virCgroupFree(cgroup_emulator);
  +return -1;
  +}
  +
  +static int
   qemuSetSchedulerParametersFlags(virDomainPtr dom,
   virTypedParameterPtr params,
   int nparams,
  @@ -7756,6 +7790,10 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
  VIR_TYPED_PARAM_ULLONG,
  VIR_DOMAIN_SCHEDULER_VCPU_QUOTA,
  VIR_TYPED_PARAM_LLONG,
  +   
  VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD,
  +   VIR_TYPED_PARAM_ULLONG,
  +   VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA,
  +   VIR_TYPED_PARAM_LLONG,
  NULL)  0)
   return -1;
   
  @@ -7838,6 +7876,32 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
   if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
   vmdef-cputune.quota = params[i].value.l;
   }
  +} else if (STREQ(param-field, 
  VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD)) {
  +if (flags  VIR_DOMAIN_AFFECT_LIVE) {
  +rc = qemuSetEmulatorBandwidthLive(vm, group, 
  params[i].value.ul, 0);
  +if (rc != 0)
  +goto cleanup;
  +
  +if (params[i].value.ul)
  +vm-def-cputune.emulator_period = params[i].value.ul;
  +}
  +
  +if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
  +vmdef-cputune.emulator_period = params[i].value.ul;
  +}
  +} else if (STREQ(param-field, 
  VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA)) {
  +if (flags  VIR_DOMAIN_AFFECT_LIVE) {
  +rc = qemuSetEmulatorBandwidthLive(vm, group, 0, 
  params[i].value.l);
  +if (rc != 0)
  +goto cleanup;
  +
  +if (params[i].value.l)
  +vm-def-cputune.emulator_quota = params[i].value.l;
  +}
  +
  +if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
  +vmdef-cputune.emulator_quota = params[i].value.l;
  +}
   }
   }
   
  @@ -7942,6 +8006,43 @@ cleanup:
   }
   
   static int
  +qemuGetEmulatorBandwidthLive(virDomainObjPtr vm, virCgroupPtr cgroup,
  + unsigned long long *period, long long *quota)
  +{
  +virCgroupPtr cgroup_emulator = NULL;
  +qemuDomainObjPrivatePtr priv = NULL;
  +int rc;
  +int ret = -1;
  +
  +priv = vm-privateData;
  +if (priv-nvcpupids == 0 || priv-vcpupids[0] == vm-pid) {
  +/* We don't create sub dir for each vcpu */
  +*period = 0;
  +*quota = 0;
  +return 0;
  +}
  +
  +/* get period and quota for emulator */
  +rc = virCgroupForEmulator(cgroup, cgroup_emulator, 0);
  +if (!cgroup_emulator) {
  +virReportSystemError(-rc,
  + _(Unable to find emulator cgroup for %s),
  + vm-def-name);
  +goto cleanup;
  +}
  +
  +rc = qemuGetVcpuBWLive(cgroup_emulator, period, quota);
  +   

Re: [libvirt] [PATCH v2.1 00/21] Supports for emulator-pin and emulator-bandwidth

2012-08-22 Thread Hu Tao
On Wed, Aug 22, 2012 at 05:06:03PM +0800, Daniel Veillard wrote:
 On Wed, Aug 22, 2012 at 03:55:48PM +0800, Daniel Veillard wrote:
  On Tue, Aug 21, 2012 at 05:18:23PM +0800, Hu Tao wrote:
   This series adds support of emulator-pin to pin emulator threads on
   specified physical CPUs, and emulator-bandwidth to control physical
   CPU bandwidth for emulator threads.
   
   changes:
   
   v2.1:
 - rebase
 - include emulator-bandwidth patches
 - minor fix of virCgroupAddTaskStrController
  
Okay, i have pushed patch 1-9 based on Dan reviews and mine,
  I'm looking at the end of that set now,
 
   okay, done the whole set is in, but please answer my last question
 on patch 21 review,

Thank you for reviewing the series!

-- 
Thanks,
Hu Tao

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


Re: [libvirt] [PATCH] virsh: don't print error info when snapshot xml is not changed

2012-08-22 Thread Michal Privoznik
On 21.08.2012 22:54, Guannan Ren wrote:
 If xml is not changed, error message is printed.
 So check ret value instead of edit variable for error message.
 ---
  tools/virsh-snapshot.c |6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
 index aff91d3..5d84f7a 100644
 --- a/tools/virsh-snapshot.c
 +++ b/tools/virsh-snapshot.c
 @@ -449,7 +449,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
   _(Snapshot %s XML configuration not changed.\n), \
   name); \
  ret = true; \
 -goto cleanup;   \
 +goto edit_cleanup;  \

Mea culpa - even though I've specifically stressed in how-to that we
have to jump to edit_cleanup in EDIT_NOT_CHANGED somehow I ignored this.

  }
  #define EDIT_DEFINE \
  (strstr(doc, statedisk-snapshot/state) ? \
 @@ -487,10 +487,10 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
  ret = true;
  
  cleanup:
 +if (!ret)
 +vshError(ctl, _(Failed to update %s), name);
  if (edited)
  virDomainSnapshotFree(edited);
 -else
 -vshError(ctl, _(Failed to update %s), name);
  if (snapshot)
  virDomainSnapshotFree(snapshot);
  if (dom)
 

ACK

Michal

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


Re: [libvirt] [PATCH] virsh: don't print error info when snapshot xml is not changed

2012-08-22 Thread Guannan Ren

On 08/22/2012 05:43 PM, Michal Privoznik wrote:

On 21.08.2012 22:54, Guannan Ren wrote:

If xml is not changed, error message is printed.
So check ret value instead of edit variable for error message.
---
  tools/virsh-snapshot.c |6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index aff91d3..5d84f7a 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -449,7 +449,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
   _(Snapshot %s XML configuration not changed.\n), \
   name); \
  ret = true; \
-goto cleanup;   \
+goto edit_cleanup;  \

Mea culpa - even though I've specifically stressed in how-to that we
have to jump to edit_cleanup in EDIT_NOT_CHANGED somehow I ignored this.


  }
  #define EDIT_DEFINE \
  (strstr(doc, statedisk-snapshot/state) ? \
@@ -487,10 +487,10 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
  ret = true;
  
  cleanup:

+if (!ret)
+vshError(ctl, _(Failed to update %s), name);
  if (edited)
  virDomainSnapshotFree(edited);
-else
-vshError(ctl, _(Failed to update %s), name);
  if (snapshot)
  virDomainSnapshotFree(snapshot);
  if (dom)


ACK

Michal


  Thanks for the review. :)
  pushed.

  Guannan Ren


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


Re: [libvirt] [PATCH 2/2] client: Change default location of known_hosts file for libssh2 layer

2012-08-22 Thread Peter Krempa

On 08/21/12 19:23, Eric Blake wrote:

On 08/21/2012 10:48 AM, Peter Krempa wrote:

Unfortunately libssh2 doesn't support all types of host keys that can be
saved in the known_hosts file. Also it does not report that parsing of
the file failed. This results into truncated known_hosts files where the
standard client stores keys also in other formats (eg.
ecdsa-sha2-nistp256).

This patch changes the default location of the known_hosts file into the
libvirt private configuration directory, where it will be only written
by the libssh2 layer itself. This prevents thrashing user's files.


s/thrashing/trashing/


---
  src/rpc/virnetclient.c |   17 ++---
  1 files changed, 10 insertions(+), 7 deletions(-)


ACK.


Series pushed. Thanks!

Peter

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


Re: [libvirt] [PATCH V3 2/3] Introduce virNetlinkEventServiceStopAll() to stop all netlink services.

2012-08-22 Thread Daniel Veillard
On Wed, Aug 22, 2012 at 12:10:24PM +0800, Tang Chen wrote:
 This patch introduce virNetlinkEventServiceStopAll() to stop
 all the monitors to receive netlink messages for libvirtd.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 ---
  daemon/libvirtd.c|2 +-
  src/libvirt_private.syms |1 +
  src/util/virnetlink.c|   50 
 ++
  src/util/virnetlink.h|5 +
  4 files changed, 57 insertions(+), 1 deletion(-)
 
 diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
 index e2e4fbd..922c5b5 100644
 --- a/daemon/libvirtd.c
 +++ b/daemon/libvirtd.c
 @@ -1325,7 +1325,7 @@ int main(int argc, char **argv) {
  0, shutdown, NULL, NULL);
  
  cleanup:
 -virNetlinkEventServiceStop(NETLINK_ROUTE);
 +virNetlinkEventServiceStopAll();
  virObjectUnref(remoteProgram);
  virObjectUnref(qemuProgram);
  virNetServerClose(srv);
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index a55fb73..af1a22a 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1470,6 +1470,7 @@ virNetlinkEventRemoveClient;
  virNetlinkEventServiceIsRunning;
  virNetlinkEventServiceLocalPid;
  virNetlinkEventServiceStop;
 +virNetlinkEventServiceStopAll;
  virNetlinkEventServiceStart;

  that's not kept in order but not really your fault ;-)

  virNetlinkShutdown;
  virNetlinkStartup;
 diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
 index 64bd47d..944ebe1 100644
 --- a/src/util/virnetlink.c
 +++ b/src/util/virnetlink.c
 @@ -404,6 +404,46 @@ virNetlinkEventServiceStop(unsigned int protocol)
  }
  
  /**
 + * virNetlinkEventServiceStopAll:
 + *
 + * Stop all the monitors to receive netlink messages for libvirtd.
 + *
 + * Returns -1 if any monitor cannot be unregistered, 0 upon success
 + */
 +int
 +virNetlinkEventServiceStopAll(void)
 +{
 +unsigned int i, j;
 +
 +VIR_INFO(stopping all netlink event services);
 +
 +virNetlinkEventSrvPrivatePtr srv = NULL;

  aestetic, we usually define variables before code in the function
  block

 +for (i = 0; i  MAX_LINKS; i++) {
 +srv = server[i];
 +if (!srv)
 +continue;
 +
 +virNetlinkEventServerLock(srv);
 +nl_close(srv-netlinknh);
 +virNetlinkFree(srv-netlinknh);
 +virEventRemoveHandle(srv-eventwatch);
 +
 +for (j = 0; j  srv-handlesCount; j++) {
 +if (srv-handles[j].deleted == VIR_NETLINK_HANDLE_VALID)
 +virNetlinkEventRemoveClientPrimitive(j, i);
 +}
 +
 +server[i] = NULL;
 +virNetlinkEventServerUnlock(srv);
 +
 +virMutexDestroy(srv-lock);
 +VIR_FREE(srv);
 +}
 +
 +return 0;
 +}
 +
 +/**
   * virNetlinkEventServiceIsRunning:
   *
   * Returns if the netlink event service is running.
 @@ -731,6 +771,16 @@ int virNetlinkEventServiceStop(unsigned int protocol 
 ATTRIBUTE_UNUSED)
  }
  
  /**
 + * stopNetlinkEventServerAll: stop all the monitors to receive netlink
 + * messages for libvirtd
 + */
 +int virNetlinkEventServiceStopAll(void)
 +{
 +VIR_DEBUG(%s, _(unsupported));
 +return 0;
 +}
 +
 +/**
   * startNetlinkEventServer: start a monitor to receive netlink
   * messages for libvirtd
   */
 diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h
 index 2e18af4..1982dae 100644
 --- a/src/util/virnetlink.h
 +++ b/src/util/virnetlink.h
 @@ -54,6 +54,11 @@ typedef void (*virNetlinkEventRemoveCallback)(int watch, 
 const virMacAddrPtr mac
  int virNetlinkEventServiceStop(unsigned int protocol);
  
  /**
 + * stopNetlinkEventServerAll: stop all the monitors to receive netlink 
 messages for libvirtd
 + */
 +int virNetlinkEventServiceStopAll(void);
 +
 +/**
   * startNetlinkEventServer: start a monitor to receive netlink messages for 
 libvirtd
   */
  int virNetlinkEventServiceStart(unsigned int protocol, unsigned int groups);
 -- 

  Okay, ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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 V3 1/3] Improve netlink to support all protocol.

2012-08-22 Thread Daniel Veillard
On Wed, Aug 22, 2012 at 12:10:23PM +0800, Tang Chen wrote:
 This patch improve all the API in virnetlink.c to support
 all kinds of netlink protocols, and make all netlink sockets
 be able to join in groups.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 ---
  daemon/libvirtd.c|6 +-
  src/util/virnetdev.c |6 +-
  src/util/virnetdevmacvlan.c  |   12 +--
  src/util/virnetdevvportprofile.c |7 +-
  src/util/virnetlink.c|  170 
 --
  src/util/virnetlink.h|   17 ++--
  6 files changed, 156 insertions(+), 62 deletions(-)
 
 diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
 index f0b0a3c..e2e4fbd 100644
 --- a/daemon/libvirtd.c
 +++ b/daemon/libvirtd.c
 @@ -1310,8 +1310,8 @@ int main(int argc, char **argv) {
  goto cleanup;
  }
  
 -/* Register the netlink event service */
 -if (virNetlinkEventServiceStart()  0) {
 +/* Register the netlink event service for NETLINK_ROUTE */
 +if (virNetlinkEventServiceStart(NETLINK_ROUTE, 0)  0) {
  ret = VIR_DAEMON_ERR_NETWORK;
  goto cleanup;
  }
 @@ -1325,7 +1325,7 @@ int main(int argc, char **argv) {
  0, shutdown, NULL, NULL);
  
  cleanup:
 -virNetlinkEventServiceStop();
 +virNetlinkEventServiceStop(NETLINK_ROUTE);
  virObjectUnref(remoteProgram);
  virObjectUnref(qemuProgram);
  virNetServerClose(srv);
 diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
 index f9eba1a..d97820e 100644
 --- a/src/util/virnetdev.c
 +++ b/src/util/virnetdev.c
 @@ -1277,7 +1277,8 @@ virNetDevLinkDump(const char *ifname, int ifindex,
  goto buffer_too_small;
  }
  
 -if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, src_pid, dst_pid)  
 0)
 +if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen,
 +  src_pid, dst_pid, NETLINK_ROUTE, 0)  0)
  goto cleanup;
  
  if (recvbuflen  NLMSG_LENGTH(0) || *recvbuf == NULL)
 @@ -1405,7 +1406,8 @@ virNetDevSetVfConfig(const char *ifname, int ifindex, 
 int vf,
  }
  }
  
 -if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, 0, pid)  0)
 +if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, 0, pid,
 +  NETLINK_ROUTE, 0)  0)
  goto cleanup;
  
  if (recvbuflen  NLMSG_LENGTH(0) || recvbuf == NULL)
 diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
 index cfad2de..74c56e0 100644
 --- a/src/util/virnetdevmacvlan.c
 +++ b/src/util/virnetdevmacvlan.c
 @@ -149,7 +149,8 @@ virNetDevMacVLanCreate(const char *ifname,
  
  nla_nest_end(nl_msg, linkinfo);
  
 -if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, 0, 0)  0) {
 +if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, 0, 0,
 +  NETLINK_ROUTE, 0)  0) {
  goto cleanup;
  }
  
 @@ -237,7 +238,8 @@ int virNetDevMacVLanDelete(const char *ifname)
  if (nla_put(nl_msg, IFLA_IFNAME, strlen(ifname)+1, ifname)  0)
  goto buffer_too_small;
  
 -if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, 0, 0)  0) {
 +if (virNetlinkCommand(nl_msg, recvbuf, recvbuflen, 0, 0,
 +  NETLINK_ROUTE, 0)  0) {
  goto cleanup;
  }
  
 @@ -757,7 +759,7 @@ virNetDevMacVLanVPortProfileRegisterCallback(const char 
 *ifname,
  {
  virNetlinkCallbackDataPtr calld = NULL;
  
 -if (virtPortProfile  virNetlinkEventServiceIsRunning()) {
 +if (virtPortProfile  virNetlinkEventServiceIsRunning(NETLINK_ROUTE)) {
  if (VIR_ALLOC(calld)  0)
  goto memory_error;
  if ((calld-cr_ifname = strdup(ifname)) == NULL)
 @@ -774,7 +776,7 @@ virNetDevMacVLanVPortProfileRegisterCallback(const char 
 *ifname,
  
  if (virNetlinkEventAddClient(virNetDevMacVLanVPortProfileCallback,
   
 virNetDevMacVLanVPortProfileDestroyCallback,
 - calld, macaddress)  0)
 + calld, macaddress, NETLINK_ROUTE)  0)
  goto error;
  }
  
 @@ -1000,7 +1002,7 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char 
 *ifname,
  ret = -1;
  }
  
 -virNetlinkEventRemoveClient(0, macaddr);
 +virNetlinkEventRemoveClient(0, macaddr, NETLINK_ROUTE);
  
  return ret;
  }
 diff --git a/src/util/virnetdevvportprofile.c 
 b/src/util/virnetdevvportprofile.c
 index f3f53c9..5213378 100644
 --- a/src/util/virnetdevvportprofile.c
 +++ b/src/util/virnetdevvportprofile.c
 @@ -705,13 +705,14 @@ virNetDevVPortProfileOpSetLink(const char *ifname, int 
 ifindex,
  }
  
  if (!nltarget_kernel) {
 -if ((src_pid = virNetlinkEventServiceLocalPid())  0)
 +if ((src_pid = virNetlinkEventServiceLocalPid(NETLINK_ROUTE))  0)
  goto cleanup;
  if ((dst_pid = virNetDevVPortProfileGetLldpadPid()) == 0)
  goto cleanup;
  }
  
 -if 

Re: [libvirt] [PATCH V3 3/3] Add uevent netlink service.

2012-08-22 Thread Daniel Veillard
On Wed, Aug 22, 2012 at 12:10:25PM +0800, Tang Chen wrote:
 This patch adds a new netlink service with NETLINK_KOBJECT_UEVENT
 protocol hotplug event.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 ---
  daemon/libvirtd.c |6 ++
  1 file changed, 6 insertions(+)
 
 diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
 index 922c5b5..c0a2f03 100644
 --- a/daemon/libvirtd.c
 +++ b/daemon/libvirtd.c
 @@ -1316,6 +1316,12 @@ int main(int argc, char **argv) {
  goto cleanup;
  }
  
 +/* Register the netlink event service for NETLINK_KOBJECT_UEVENT */
 +if (virNetlinkEventServiceStart(NETLINK_KOBJECT_UEVENT, 1)  0) {
 +ret = VIR_DAEMON_ERR_NETWORK;
 +goto cleanup;
 +}
 +
  /* Run event loop. */
  virNetServerRun(srv);
  

ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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.1 21/21] qemu: support of emulator_period and emulator_quota's modification

2012-08-22 Thread Daniel Veillard
On Wed, Aug 22, 2012 at 05:19:32PM +0800, Hu Tao wrote:
 On Wed, Aug 22, 2012 at 05:04:57PM +0800, Daniel Veillard wrote:
  On Tue, Aug 21, 2012 at 05:18:44PM +0800, Hu Tao wrote:
[...]
Okay, we now have 5 parameters instead of 3. that looks fine, ACK,
  
the question I have is if virsh is actually able to display the 5
  parameters by default now, if yes the patch set seems complete !
 
 Indeed. The virsh output here is:
 
 virsh schedinfo example-domain
 Scheduler  : posix
 cpu_shares : 1024
 vcpu_period: 10
 vcpu_quota : -1
 emulator_period: 40
 emulator_quota : 10

  okay, cool, all set then I think,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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] additional parameter needed for dnsmasq

2012-08-22 Thread Gene Czarcinski

On 08/21/2012 11:04 AM, Daniel P. Berrange wrote:

On Tue, Aug 21, 2012 at 10:43:44AM -0400, Gene Czarcinski wrote:

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

As currently configured, dnsmasq for a virtual network will pass
some queries upstream toward the Internet.  This includes  and
MX queries as well a A queries when dnsmasq cannot answer for that
name.  This is occurring whether a domain name is specified or not.
The problem is that dnsmasq will, by default, forward all queries
unless local= is specified.  I cannot envision a situation where
such queries should be forwarded.

See the bugzilla report for more info.  While I did a lot of testing
to figure out the problem and what needed to be done to fix it, I am
unable to actually rebuild the libvirt rpm in my environment.

The solution is the following patch:

diff -uNr libvirt-0.9.11.4.orig/src/network/bridge_driver.c
libvirt-0.9.11.4/src/network/bridge_driver.c
--- libvirt-0.9.11.4.orig/src/network/bridge_driver.c2012-06-15
14:23:21.0 -0400
+++ libvirt-0.9.11.4/src/network/bridge_driver.c2012-08-21
09:03:17.387602485 -0400
@@ -491,7 +491,13 @@
  virCommandAddArgList(cmd, --strict-order,
--bind-interfaces, NULL);

  if (network-def-domain)
-virCommandAddArgList(cmd, --domain, network-def-domain, NULL);
+//virCommandAddArgList(cmd, --domain,
network-def-domain, NULL);
+virCommandAddArgFormat(cmd,
+--domain %s --local=/%s/,
+network-def-domain,
+network-def-domain);
+else
+virCommandAddArg(cmd, --local=);

  if (pidfile)
  virCommandAddArgPair(cmd, --pid-file, pidfile);


Since this changes the code that generates dnsmasq args, you'll
also need to update the tests/networkxml2argvdata/ data files
to take account of your new additions.


And here I thought it was just a tiny patch.  When I get thinks 
finalized, there will be an update to the tests also.


But, the patch itself is not good.  For example, for no domain 
specified, instead of --local=, it should be --local-//.  And then 
with the domain specified, this just does not work for some reason 
dnsmasq has errors starting.


I must say that I believe that whoever chose to use dnsmasq definitely 
made the right choice.  However, I wich it was easier to change and test 
new parameter seetings for dnsmasq rather than having it in the code.


So that I do not have to go through a lot of code changes, I am testing 
with two virtual guests.  The first has two NICs one connected to the 
default network and a second to a private network with dnsmasq (dns and 
dhcp) for the private network.  The second guest is on the private 
network and tests the various setups for dnsmasq.


My initial simplified test used the /etc/dnsmasq.conf and supplied some 
additional parameters that I had not realized.  My testing is not 
attempting to create a situation similar to that for libvirtd which has 
everything specified on the command-line.


Any comments, suggestions will be appreciated.

Gene

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


Re: [libvirt] [PATCH] output status information during guest shutdown again

2012-08-22 Thread Gerd v. Egidy
Hi Eric,

 Beyond that, you met my comments on v1, and I didn't spot anything else, so:
 
 ACK and pushed.

Thanks.

  This is version 2 of the patch and includes fixes as suggested by Eric
  Blake.
 This last sentence can go...
 
  ---
 
 after the ---, so that git doesn't store it in the log (it's informative
 for the email review, but not relevant to the long-term history).

ok, will move it below the --- next time.

Kind regards,

Gerd


-- 
Address (better: trap) for people I really don't want to get mail from:
jo...@cactusamerica.com

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


[libvirt] Entering freeze for libvirt-0.10.0

2012-08-22 Thread Daniel Veillard
  As planned, I just tagged 0.10.0 release candidate 1 in git and
pushed a tarball and rpms to the usual place:
   ftp://libvirt.org/libvirt/

 I gave it a try locally and things seems to work as expected, but
that's far from an extensive testing :-)

  So please try it, try to compile it on various platforms and
send feedback to the list. My schedule is to make an rc2 probably for
the week-end and ideally a final release a week from now,

  thanks in advance !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
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 v3 1/4] Add per-guest S3/S4 state configuration

2012-08-22 Thread Michal Privoznik
On 09.08.2012 10:26, Martin Kletzander wrote:
 There is a new pm/ element implemented that can control what ACPI
 sleeping states will be advertised by BIOS and allowed to be switched
 to by libvirt. The default keeps defaults on hypervisor, otherwise
 forces chosen setting.
 ---
  docs/schemas/domaincommon.rng |   33 ++
  src/conf/domain_conf.c|   44 
 +
  src/conf/domain_conf.h|   15 ++
  src/libvirt_private.syms  |2 +
  4 files changed, 94 insertions(+), 0 deletions(-)

As I've mentioned in one of previous series - I'd like to see
documentation and XML extension in one patch as it's advised here:

   http://libvirt.org/api_extension.html

But then again, having a separate patch within set is okay too.

 
 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
 index c85d763..d0c6d47 100644
 --- a/docs/schemas/domaincommon.rng
 +++ b/docs/schemas/domaincommon.rng
 @@ -53,6 +53,9 @@
  ref name=features/
  ref name=termination/
  optional
 +  ref name=pm/
 +/optional
 +optional
ref name=devices/
  /optional
  optional
 @@ -2192,6 +2195,36 @@
  /choice
/define
!--
 +  Control ACPI sleep states (dis)allowed for the domain
 +  For each of the states the following rules apply:
 +  on: the state will be forcefully enabled
 +  off: the state will be forcefully disabled
 +  not specified: hypervisor will be left to decide its defaults
 +  --
 +  define name=pm
 +element name=pm
 +  interleave
 +optional
 +  attribute name=suspend-to-mem
 +ref name=suspendChoices/
 +  /attribute
 +/optional
 +optional
 +  attribute name=suspend-to-disk
 +ref name=suspendChoices/
 +  /attribute
 +/optional
 +  /interleave
 +  empty/
 +/element
 +  /define
 +  define name=suspendChoices
 +choice
 +  valueon/value
 +  valueoff/value
 +/choice
 +  /define
 +  !--

Let's hope we won't need any other configurable knobs for s3/s4;
otherwise we should move from attributes to elements:
  pm
 s3 enabled='yes'/
 s4 enabled='no'/
  /pm

Specific setup for a qemu emulated character device.  Note: this
definition doesn't fully specify the constraints on this node.
  --
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index d8c0969..04e0be5 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -124,6 +124,11 @@ VIR_ENUM_IMPL(virDomainLifecycleCrash, 
 VIR_DOMAIN_LIFECYCLE_CRASH_LAST,
coredump-destroy,
coredump-restart)
 
 +VIR_ENUM_IMPL(virDomainPMState, VIR_DOMAIN_PM_STATE_LAST,
 +  default,
 +  on,
 +  off)
 +
  VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
none,
disk,
 @@ -8413,6 +8418,19 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
 caps,
 virDomainLifecycleCrashTypeFromString)  
 0)
  goto error;
 
 +if (virXPathNode(./pm, ctxt)) {
 +tmp = virXPathString(string(./pm/@suspend-to-mem), ctxt);
 +if (tmp) {
 +def-pm.s3 = virDomainPMStateTypeFromString(tmp);
 +VIR_FREE(tmp);
 +}
 +tmp = virXPathString(string(./pm/@suspend-to-disk), ctxt);
 +if (tmp) {
 +def-pm.s4 = virDomainPMStateTypeFromString(tmp);
 +VIR_FREE(tmp);
 +}
 +}
 +

vir*TypeFromString() may fail and return  0 value. We should not
silently ignore not allowed values here. NB please don't use
VIR_ERR_INTERNAL_ERROR as it is not an internal error but
VIR_ERR_CONFIG_UNSUPPORTED.

  tmp = virXPathString(string(./clock/@offset), ctxt);
  if (tmp) {
  if ((def-clock.offset = virDomainClockOffsetTypeFromString(tmp))  
 0) {
 @@ -13092,6 +13110,32 @@ virDomainDefFormatInternal(virDomainDefPtr def,
  virDomainLifecycleCrashTypeToString)  0)
  goto cleanup;
 
 +if (def-pm.s3 || def-pm.s4) {
 +virBufferAddLit(buf,   pm);
 +
 +if (def-pm.s3) {
 +const char *tmp = virDomainPMStateTypeToString(def-pm.s3);
 +if (!tmp) {

This is useless. Libvirt must validate its inputs (esp. those from
user). Outputs are believed to be trusted - that is - once we validate
input and set def-pm.s3 to one of allowed values, nobody will hop into
our address space and change it. It he will anyway, it's problem.

 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(unexpected PM state %d), def-pm.s3);
 +goto cleanup;
 +}
 +virBufferAsprintf(buf,  suspend-to-mem='%s', tmp);
 +}
 +
 +if (def-pm.s4) {
 +const char *tmp = 

Re: [libvirt] [PATCH v3 2/4] qemu: Add support for S3/S4 state configuration

2012-08-22 Thread Michal Privoznik
On 09.08.2012 10:26, Martin Kletzander wrote:
 This patch adds support for running qemu guests with the required
 parameters to forcefully enable or disable BIOS advertising of S3 and
 S4 states.  The support for this is added to capabilities and there is
 also a qemu command parameter parsing implemented.
 ---
  src/qemu/qemu_capabilities.c |7 +++
  src/qemu/qemu_capabilities.h |2 +
  src/qemu/qemu_command.c  |  103 
 ++
  src/qemu/qemu_driver.c   |   17 +++
  4 files changed, 129 insertions(+), 0 deletions(-)
 
 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
 index 5472267..b8160b6 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
 @@ -172,6 +172,8 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
bridge, /* 100 */
lsi,
virtio-scsi-pci,
 +  disable-s3,
 +  disable-s4,
 
  );
 
 @@ -1403,6 +1405,7 @@ qemuCapsExtractDeviceStr(const char *qemu,
   -device, virtio-blk-pci,?,
   -device, virtio-net-pci,?,
   -device, scsi-disk,?,
 + -device, PIIX4_PM,?,
   NULL);
  /* qemu -help goes to stdout, but qemu -device ? goes to stderr.  */
  virCommandSetErrorBuffer(cmd, output);
 @@ -1499,6 +1502,10 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr 
 flags)
  qemuCapsSet(flags, QEMU_CAPS_SCSI_CD);
  if (strstr(str, ide-cd))
  qemuCapsSet(flags, QEMU_CAPS_IDE_CD);
 +if (strstr(str, PIIX4_PM.disable_s3=))
 +qemuCapsSet(flags, QEMU_CAPS_DISABLE_S3);
 +if (strstr(str, PIIX4_PM.disable_s4=))
 +qemuCapsSet(flags, QEMU_CAPS_DISABLE_S4);
 
  return 0;
  }
 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
 index d606890..e49424a 100644
 --- a/src/qemu/qemu_capabilities.h
 +++ b/src/qemu/qemu_capabilities.h
 @@ -138,6 +138,8 @@ enum qemuCapsFlags {
  QEMU_CAPS_NETDEV_BRIDGE  = 100, /* bridge helper support */
  QEMU_CAPS_SCSI_LSI   = 101, /* -device lsi */
  QEMU_CAPS_VIRTIO_SCSI_PCI= 102, /* -device virtio-scsi-pci */
 +QEMU_CAPS_DISABLE_S3 = 103, /* S3 BIOS Advertisement on/off */
 +QEMU_CAPS_DISABLE_S4 = 104, /* S4 BIOS Advertisement on/off */
 
  QEMU_CAPS_LAST,   /* this must always be the last item */
  };
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index 9383530..34ee00e 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -4761,6 +4761,48 @@ qemuBuildCommandLine(virConnectPtr conn,
  virCommandAddArg(cmd, -no-acpi);
  }
 
 +if (def-pm.s3) {
 +if (qemuCapsGet(qemuCaps, QEMU_CAPS_DISABLE_S3)) {
 +if (def-pm.s3 == VIR_DOMAIN_PM_STATE_ON)
 +virCommandAddArgList(cmd,
 + -global,
 + PIIX4_PM.disable_s3=0,
 + NULL);
 +
 +else if (def-pm.s3 == VIR_DOMAIN_PM_STATE_OFF)

Redundant if. After the first condition def-pm.s3 can be either _ON or
_OFF. Nothing else.

 +virCommandAddArgList(cmd,
 + -global,
 + PIIX4_PM.disable_s3=1,
 + NULL);
 +
 +} else {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 +   %s, _(setting ACPI S3 not supported));
 +goto error;
 +}
 +}
 +
 +if (def-pm.s4) {
 +if (qemuCapsGet(qemuCaps, QEMU_CAPS_DISABLE_S4)) {
 +if (def-pm.s4 == VIR_DOMAIN_PM_STATE_ON)
 +virCommandAddArgList(cmd,
 + -global,
 + PIIX4_PM.disable_s4=0,
 + NULL);
 +
 +else if (def-pm.s4 == VIR_DOMAIN_PM_STATE_OFF)

ditto

 +virCommandAddArgList(cmd,
 + -global,
 + PIIX4_PM.disable_s4=1,
 + NULL);
 +
 +} else {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 +   %s, _(setting ACPI S4 not supported));
 +goto error;
 +}
 +}
 +
  if (!def-os.bootloader) {
  /*
   * We prefer using explicit bootindex=N parameters for predictable
 @@ -8279,6 +8321,67 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
 
  *monConfig = chr;
  }
 +} else if (STREQ(arg, -global) 
 +   STRPREFIX(progargv[i + 1], PIIX4_PM.disable_s3=)) {
 +/* We want to parse only the known -global parameters,
 + * so the ones that we don't know are still added to the
 + * 

Re: [libvirt] [PATCH v3 3/4] tests: Add tests for qemu S3/S4 state configuration

2012-08-22 Thread Michal Privoznik
On 09.08.2012 10:26, Martin Kletzander wrote:
 Few tests were added which are checking whether the parsing of the xml
 and command-line arguments is working and compatible with each other.
 ---
  tests/qemuargv2xmltest.c   |3 ++
  .../qemuxml2argv-misc-disable-s3.args  |4 +++
  .../qemuxml2argv-misc-disable-s3.xml   |   27 
 
  .../qemuxml2argv-misc-disable-suspends.args|4 +++
  .../qemuxml2argv-misc-disable-suspends.xml |   27 
 
  .../qemuxml2argv-misc-enable-s4.args   |4 +++
  .../qemuxml2argv-misc-enable-s4.xml|   27 
 
  tests/qemuxml2argvtest.c   |4 +++
  tests/qemuxml2xmltest.c|3 ++
  9 files changed, 103 insertions(+), 0 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.args
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.xml
 

ACK

Michal

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


Re: [libvirt] [PATCH v3 4/4] docs: Add pm element into documentation

2012-08-22 Thread Michal Privoznik
On 09.08.2012 10:26, Martin Kletzander wrote:
 ---
  docs/formatdomain.html.in |   21 +
  1 files changed, 21 insertions(+), 0 deletions(-)
 
 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index f97c630..50c4783 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -922,6 +922,27 @@
  domain will be restarted with the same configuration/dd
  /dl
 
 +h3a name=elementsPowerManagementPower Management/a/h3
 +
 +p
 +  span class=sinceSince 0.10.1/span it is possible to
 +  forcibly enable or disable BIOS advertisements to the guest
 +  OS. (NB: Only qemu driver support)
 +/p
 +
 +pre
 +  ...
 +  lt;pm suspend-to-disk='off' suspend-to-ram='on' /gt;
 +  .../pre
 +
 +dl
 +  dtcodepm/code/dt
 +  ddThis element enables ('on') or disables ('off') BIOS support
 +for S3 (suspend-to-disk) and S4 (suspend-to-mem) ACPI sleep
 +states. If no value is specified, then the hypervison will be

s/hypervison/hypervisor/

 +left with its default value./dd
 +/dl
 +
  h3a name=elementsFeaturesHypervisor features/a/h3
 
  p
 

ACK

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


[libvirt] [PATCH libvirt-virshcmdref] Add blockpull and blockjob commands

2012-08-22 Thread Stefan Hajnoczi
The blockpull and blockjob commands have been present since 0.9.4.  This
patch adds basic usage examples and command syntax.

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
---
 common.sh|8 ++--
 source/blockjob.xml  |   79 +++
 source/blockpull.xml |  101 ++
 3 files changed, 184 insertions(+), 4 deletions(-)
 create mode 100644 source/blockjob.xml
 create mode 100644 source/blockpull.xml

diff --git a/common.sh b/common.sh
index 9da1b13..7e3a3a0 100755
--- a/common.sh
+++ b/common.sh
@@ -1,9 +1,9 @@
 # List of source files
 DOMAIN_COMMANDS=attach-device attach-disk attach-interface autostart
-  blkiotune console cpu-baseline cpu-compare create define destroy
-  detach-device detach-disk detach-interface domid domjobabort domjobinfo
-  domname domuuid domxml-from-native domxml-to-native dump dumpxml echo
-  edit freecell hostname inject-nmi managedsave managedsave-remove
+  blkiotune blockjob blockpull console cpu-baseline cpu-compare create define
+  destroy detach-device detach-disk detach-interface domid domjobabort
+  domjobinfo domname domuuid domxml-from-native domxml-to-native dump dumpxml
+  echo edit freecell hostname inject-nmi managedsave managedsave-remove
   maxvcpus memtune migrate migrate-setmaxdowntime migrate-getspeed
   migrate-setspeed reboot restore resume save schedinfo send-key
   setmaxmem setmem setvcpus shutdown start suspend ttyconsole undefine
diff --git a/source/blockjob.xml b/source/blockjob.xml
new file mode 100644
index 000..0c34bae
--- /dev/null
+++ b/source/blockjob.xml
@@ -0,0 +1,79 @@
+?xml version='1.0' encoding='utf-8' ?
+
+command
+  nameblockjob/name
+
+  description
+text
+  Manage active block operations
+/text
+  /description
+
+  options
+parameter requirement=required
+  value type=string requirement=requireddomain/value
+  description
+The name of the domain on which to act.
+  /description
+/parameter
+parameter requirement=required
+  value type=string requirement=requiredpath/value
+  description
+The fully-qualified path of the disk.  See domblklist for listing 
these names.
+  /description
+/parameter
+parameter requirement=optional
+  keyword requirement=required--abort/keyword
+  description
+Abort the active job on the specified disk.
+  /description
+/parameter
+parameter requirement=optional
+  keyword requirement=required--async/keyword
+  description
+Return immediately instead of waiting for cancelation to complete, 
when specified together with --abort.
+  /description
+/parameter
+parameter requirement=optional
+  keyword requirement=required--pivot/keyword
+/parameter
+parameter requirement=optional
+  keyword requirement=required--info/keyword
+  description
+Print information about any active block operation.
+  /description
+/parameter
+  /options
+
+  availability from=0.9.4 /
+
+  notes /
+
+  examples type=usage
+example
+  terminalvirsh # boldblockjob/bold valueexample-domain/value 
valuevda/value italic--info/italic/terminal
+  text
+Prints information about any active block operation on 
valuevda/value from valueexample-domain/value.
+  /text
+/example
+example
+  terminalvirsh # boldblockjob/bold valueexample-domain/value 
valuevda/value italic--abort/italic/terminal
+  text
+Cancels the active block operation on valuevda/value from 
valueexample-domain/value.
+  /text
+/example
+  /examples
+
+  examples type=fullcontext /
+
+  reference type=seealso
+item
+  link type=internal href=blockpull /
+  nameblockpull/name
+  description
+populate a disk from its backing image chain
+  /description
+/item
+  /reference
+
+/command
diff --git a/source/blockpull.xml b/source/blockpull.xml
new file mode 100644
index 000..81b58da
--- /dev/null
+++ b/source/blockpull.xml
@@ -0,0 +1,101 @@
+?xml version='1.0' encoding='utf-8' ?
+
+command
+  nameblockpull/name
+
+  description
+text
+  Populate a disk from its backing image chain
+/text
+  /description
+
+  options
+parameter requirement=required
+  value type=string requirement=requireddomain/value
+  description
+The name of the domain on which to act.
+  /description
+/parameter
+parameter requirement=required
+  value type=string requirement=requiredpath/value
+  description
+The fully-qualified path of the disk.  See domblklist for listing 
these names.
+  /description
+/parameter
+parameter requirement=optional
+  value type=number requirement=requiredbandwidth/value
+  description
+Copying bandwidth limit in MiB/s.
+  /description
+/parameter
+parameter requirement=optional
+  value type=string 

Re: [libvirt] [PATCH libvirt-virshcmdref] Add blockpull and blockjob commands

2012-08-22 Thread Stefan Hajnoczi
On Wed, Aug 22, 2012 at 02:40:57PM +0100, Stefan Hajnoczi wrote:
 The blockpull and blockjob commands have been present since 0.9.4.  This
 patch adds basic usage examples and command syntax.
 
 Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 ---
  common.sh|8 ++--
  source/blockjob.xml  |   79 +++
  source/blockpull.xml |  101 
 ++
  3 files changed, 184 insertions(+), 4 deletions(-)
  create mode 100644 source/blockjob.xml
  create mode 100644 source/blockpull.xml

Convenience links for easy reviewing:
http://vmsplice.net/~stefan/blockpull.html
http://vmsplice.net/~stefan/blockjob.html

Stefan

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


Re: [libvirt] [PATCH 0/4] Preparation for external live snapshot

2012-08-22 Thread Michal Privoznik
On 18.08.2012 04:08, Eric Blake wrote:
 I've determined that it is possible to mix migration to file
 with disk snapshots on existing qemu 1.1 in such a way to
 take a live system checkpoint snapshot of a system without
 the downtime of either 'virsh snapshot-create' or 'virsh save';
 without the loss in disk state of 'virsh save'; and without
 the fsck penalties of 'virsh snapshot-create --disk-only';
 basically by combining the best of those three approaches.
 
 I'm also quite tired of 'virsh snapshot-create --disk-only'
 failing for an offline domain, and have upcoming patches to
 drive qemu-img to do that for an offline image.
 
 Unfortunately, qemu 1.2 missed out on adding the 'drive-mirror'
 or 'block-commit' commands, so I still can't do quite everything
 I want with snapshots (in particular, I can't preserve the
 original filename; although you can do a snapshot/blockpull/snapshot
 to get back to the original filename with twice the work).  But
 I think this series still leaves room for future enhancements
 as future qemu provides the means.
 
 Although I'm still in the middle of polishing the src/qemu patches,
 I'd at least like to post this series of prep-work to document
 how I plan to expose it all, and to make sure my design
 decisions are on track.  The first three can be applied now,
 the fourth should probably not be applied until I actually have
 later patches using the new XML, hopefully still in time for 0.10.0.
 
 Eric Blake (4):
   snapshot: make virDomainSnapshotObjList opaque
   snapshot: split snapshot conf code into own file
   snapshot: rename an enum
   snapshot: new XML for external system checkpoint
 
  docs/formatsnapshot.html.in|   11 +
  docs/schemas/domainsnapshot.rng|   23 +
  po/POTFILES.in |1 +
  src/Makefile.am|3 +-
  src/conf/domain_conf.c |  933 +-
  src/conf/domain_conf.h |  143 +--
  src/conf/snapshot_conf.c   | 1021 
 
  src/conf/snapshot_conf.h   |  160 +++
  src/esx/esx_driver.c   |1 +
  src/libvirt_private.syms   |5 +-
  src/qemu/qemu_command.c|1 +
  src/qemu/qemu_domain.c |7 +-
  src/qemu/qemu_domain.h |3 +-
  src/qemu/qemu_driver.c |   69 +-
  src/qemu/qemu_migration.c  |2 +-
  src/vbox/vbox_tmpl.c   |1 +
  tests/domainsnapshotxml2xmlin/external_vm.xml  |   10 +
  tests/domainsnapshotxml2xmlin/noparent.xml |9 +
  tests/domainsnapshotxml2xmlout/all_parameters.xml  |1 +
  tests/domainsnapshotxml2xmlout/disk_snapshot.xml   |1 +
  tests/domainsnapshotxml2xmlout/external_vm.xml |   43 +
  tests/domainsnapshotxml2xmlout/full_domain.xml |1 +
  tests/domainsnapshotxml2xmlout/metadata.xml|1 +
  tests/domainsnapshotxml2xmlout/noparent.xml|1 +
  .../noparent_nodescription.xml |1 +
  .../noparent_nodescription_noactive.xml|1 +
  tests/domainsnapshotxml2xmltest.c  |1 +
  27 files changed, 1365 insertions(+), 1089 deletions(-)
  create mode 100644 src/conf/snapshot_conf.c
  create mode 100644 src/conf/snapshot_conf.h
  create mode 100644 tests/domainsnapshotxml2xmlin/external_vm.xml
  create mode 100644 tests/domainsnapshotxml2xmlin/noparent.xml
  create mode 100644 tests/domainsnapshotxml2xmlout/external_vm.xml
 

Eric,

I could apply the first patch (however using 3-way merge) but cannot the
second. Can you please (rebase? and) resend? Or is this intended to be
applied on the top of another patchset:

Applying: snapshot: split snapshot conf code into own file
fatal: sha1 information is lacking or useless (src/conf/domain_conf.c).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 snapshot: split snapshot conf code into own file
When you have resolved this problem run git am --resolved.
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.

Michal

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


[libvirt] [PATCH] docs: fix blockpull/blockcopy bandwidth Mbps - MiB/s

2012-08-22 Thread Stefan Hajnoczi
The bandwidth units for blockpull and blockcopy are in Megabytes per
Second, not Megabits per Second.

Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
---
 src/libvirt.c   |   10 +-
 tools/virsh.pod |4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 60ce6d1..e0ac391 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -18344,7 +18344,7 @@ error:
  * virDomainBlockJobSetSpeed:
  * @dom: pointer to domain object
  * @disk: path to the block device, or device shorthand
- * @bandwidth: specify bandwidth limit in Mbps
+ * @bandwidth: specify bandwidth limit in MiB/s
  * @flags: extra flags; not used yet, so callers should always pass 0
  *
  * Set the maximimum allowable bandwidth that a block job may consume.  If
@@ -18402,7 +18402,7 @@ error:
  * virDomainBlockPull:
  * @dom: pointer to domain object
  * @disk: path to the block device, or device shorthand
- * @bandwidth: (optional) specify copy bandwidth limit in Mbps
+ * @bandwidth: (optional) specify copy bandwidth limit in MiB/s
  * @flags: extra flags; not used yet, so callers should always pass 0
  *
  * Populate a disk image with data from its backing image.  Once all data from
@@ -18419,7 +18419,7 @@ error:
  * can be found by calling virDomainGetXMLDesc() and inspecting
  * elements within //domain/devices/disk.
  *
- * The maximum bandwidth (in Mbps) that will be used to do the copy can be
+ * The maximum bandwidth (in MiB/s) that will be used to do the copy can be
  * specified with the bandwidth parameter.  If set to 0, libvirt will choose a
  * suitable default.  Some hypervisors do not support this feature and will
  * return an error if bandwidth is not 0; in this case, it might still be
@@ -18475,7 +18475,7 @@ error:
  * @dom: pointer to domain object
  * @disk: path to the block device, or device shorthand
  * @base: path to backing file to keep, or NULL for no backing file
- * @bandwidth: (optional) specify copy bandwidth limit in Mbps
+ * @bandwidth: (optional) specify copy bandwidth limit in MiB/s
  * @flags: bitwise-OR of virDomainBlockRebaseFlags
  *
  * Populate a disk image with data from its backing image chain, and
@@ -18535,7 +18535,7 @@ error:
  * can be found by calling virDomainGetXMLDesc() and inspecting
  * elements within //domain/devices/disk.
  *
- * The maximum bandwidth (in Mbps) that will be used to do the copy can be
+ * The maximum bandwidth (in MiB/s) that will be used to do the copy can be
  * specified with the bandwidth parameter.  If set to 0, libvirt will choose a
  * suitable default.  Some hypervisors do not support this feature and will
  * return an error if bandwidth is not 0; in this case, it might still be
diff --git a/tools/virsh.pod b/tools/virsh.pod
index e932d7c..424f1d9 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -723,7 +723,7 @@ the command may continue to block a little while longer 
until the job
 is done cleaning up.
 
 Ipath specifies fully-qualified path of the disk.
-Ibandwidth specifies copying bandwidth limit in Mbps.
+Ibandwidth specifies copying bandwidth limit in MiB/s.
 
 =item Bblockpull Idomain Ipath [Ibandwidth] [Ibase]
 [I--wait [I--verbose] [I--timeout Bseconds] [I--async]]
@@ -750,7 +750,7 @@ Ipath specifies fully-qualified path of the disk; it 
corresponds
 to a unique target name (target dev='name'/) or source file (source
 file='name'/) for one of the disk devices attached to Idomain (see
 also Bdomblklist for listing these names).
-Ibandwidth specifies copying bandwidth limit in Mbps.
+Ibandwidth specifies copying bandwidth limit in MiB/s.
 
 =item Bblkdeviotune Idomain Idevice
 [[I--config] [I--live] | [I--current]]
-- 
1.7.10.4

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


Re: [libvirt] [PATCH] additional parameter needed for dnsmasq

2012-08-22 Thread Gene Czarcinski

On 08/22/2012 06:51 AM, Gene Czarcinski wrote:

On 08/21/2012 11:04 AM, Daniel P. Berrange wrote:

On Tue, Aug 21, 2012 at 10:43:44AM -0400, Gene Czarcinski wrote:

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

As currently configured, dnsmasq for a virtual network will pass
some queries upstream toward the Internet.  This includes  and
MX queries as well a A queries when dnsmasq cannot answer for that
name.  This is occurring whether a domain name is specified or not.
The problem is that dnsmasq will, by default, forward all queries
unless local= is specified.  I cannot envision a situation where
such queries should be forwarded.

See the bugzilla report for more info.  While I did a lot of testing
to figure out the problem and what needed to be done to fix it, I am
unable to actually rebuild the libvirt rpm in my environment.

The solution is the following patch:

diff -uNr libvirt-0.9.11.4.orig/src/network/bridge_driver.c
libvirt-0.9.11.4/src/network/bridge_driver.c
--- libvirt-0.9.11.4.orig/src/network/bridge_driver.c 2012-06-15
14:23:21.0 -0400
+++ libvirt-0.9.11.4/src/network/bridge_driver.c2012-08-21
09:03:17.387602485 -0400
@@ -491,7 +491,13 @@
  virCommandAddArgList(cmd, --strict-order,
--bind-interfaces, NULL);

  if (network-def-domain)
-virCommandAddArgList(cmd, --domain, network-def-domain, 
NULL);

+//virCommandAddArgList(cmd, --domain,
network-def-domain, NULL);
+virCommandAddArgFormat(cmd,
+--domain %s --local=/%s/,
+network-def-domain,
+network-def-domain);
+else
+virCommandAddArg(cmd, --local=);

  if (pidfile)
  virCommandAddArgPair(cmd, --pid-file, pidfile);


Since this changes the code that generates dnsmasq args, you'll
also need to update the tests/networkxml2argvdata/ data files
to take account of your new additions.


And here I thought it was just a tiny patch.  When I get thinks 
finalized, there will be an update to the tests also.


But, the patch itself is not good.  For example, for no domain 
specified, instead of --local=, it should be --local-//.  And then 
with the domain specified, this just does not work for some reason 
dnsmasq has errors starting.


I must say that I believe that whoever chose to use dnsmasq definitely 
made the right choice.  However, I wich it was easier to change and 
test new parameter seetings for dnsmasq rather than having it in the 
code.


So that I do not have to go through a lot of code changes, I am 
testing with two virtual guests.  The first has two NICs one connected 
to the default network and a second to a private network with dnsmasq 
(dns and dhcp) for the private network.  The second guest is on the 
private network and tests the various setups for dnsmasq.


My initial simplified test used the /etc/dnsmasq.conf and supplied 
some additional parameters that I had not realized.  My testing is not 
attempting to create a situation similar to that for libvirtd which 
has everything specified on the command-line.


Any comments, suggestions will be appreciated.


OK, I am going to need a little help here.

First, is there any documentation on things that need to be done in test 
when changes are made?  Right now there is a lot of stuff there and I am 
not sure what needs to be added where.


Second, I have since the rpm will compile with my patch and goes through 
enough of -bi --short-circuit to create 
BUILDROOT/libvirt.../usr/sbin/libvirtd I am copying this over to a real 
system and installing it replacing the original /usr/sbin/libvirtd


With my patch installed, when libvirtd attempts to start a network, it 
errors out with something like the follow:


internal error Child process (/sbin/dnsmasq --strict-order 
--bind-interfaces --domain virt123 --local=/virt123/ --domain-needed 
--filterwin2k --pid-file=/var/run/libvirt/network/net123.pid 
--conf-file= --except-interface lo --listen-address 192.168.123.1 
--dhcp-range 192.168.123.128,192.168.123.254 
--dhcp-leasefile=/var/lib/libvirt/dnsmasq/net123.leases 
--dhcp-lease-max=127 --dhcp-no-override --expand-hosts) status 
unexpected: exit status 1



About the only version that does not have a problem is replacing 
--domain virt123 --local=/virt123/ --domain-needed --filterwin2k with 
--local=


OK, something is wrong.

However, is I kill -9 the running instance or dnsmasq and then, as 
root, manually start dnsmasq with all of the above parameters, it runs 
and works find on the virtual network!


Obviously, I am missing something!  Can someone point me in the right 
direction?


Gene

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


Re: [libvirt] [PATCH] additional parameter needed for dnsmasq

2012-08-22 Thread Claudio Bley
At Wed, 22 Aug 2012 10:23:44 -0400,
Gene Czarcinski wrote:
 Second, I have since the rpm will compile with my patch and goes
 through enough of -bi --short-circuit to create
 BUILDROOT/libvirt.../usr/sbin/libvirtd I am copying this over to a
 real system and installing it replacing the original
 /usr/sbin/libvirtd
 
 With my patch installed, when libvirtd attempts to start a network, it
 errors out with something like the follow:
 
 internal error Child process (/sbin/dnsmasq --strict-order
 --bind-interfaces --domain virt123 --local=/virt123/ --domain-needed
 --filterwin2k --pid-file=/var/run/libvirt/network/net123.pid
 --conf-file= --except-interface lo --listen-address 192.168.123.1
 --dhcp-range 192.168.123.128,192.168.123.254
 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/net123.leases
 --dhcp-lease-max=127 --dhcp-no-override --expand-hosts) status
 unexpected: exit status 1
 
 
  +virCommandAddArgFormat(cmd,
  +--domain %s --local=/%s/,
  +network-def-domain,
  +network-def-domain);

Here, you're adding --domain D --local=/D/ as a *single* argument to
the dnsmasq call.

You need to provide --domain, network-def-domain, --local=/D/ as
3 arguments to the call, ie. first use
virCommandAddArgPair(cmd, --domain, D), then use virCommandAddArgFormat
for the --local part.

Claudio
-- 
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:http://www.av-test.org

Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

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

Re: [libvirt] [PATCH 0/4] Preparation for external live snapshot

2012-08-22 Thread Eric Blake
On 08/22/2012 07:46 AM, Michal Privoznik wrote:
 Although I'm still in the middle of polishing the src/qemu patches,
 I'd at least like to post this series of prep-work to document
 how I plan to expose it all, and to make sure my design
 decisions are on track.  The first three can be applied now,
 the fourth should probably not be applied until I actually have
 later patches using the new XML, hopefully still in time for 0.10.0.

Looks like I missed rc1, so while the first three patches might still be
okay for 0.10.0, the new XML is now 0.10.1 material.

 
 I could apply the first patch (however using 3-way merge) but cannot the
 second. Can you please (rebase? and) resend? Or is this intended to be
 applied on the top of another patchset:

Yes, I'll rebase and resend (file splits tend to be hairy if not applied
right away).

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



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

Re: [libvirt] [PATCH] docs: fix blockpull/blockcopy bandwidth Mbps - MiB/s

2012-08-22 Thread Eric Blake
On 08/22/2012 07:59 AM, Stefan Hajnoczi wrote:
 The bandwidth units for blockpull and blockcopy are in Megabytes per
 Second, not Megabits per Second.
 
 Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 ---
  src/libvirt.c   |   10 +-
  tools/virsh.pod |4 ++--
  2 files changed, 7 insertions(+), 7 deletions(-)

ACK.

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



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

Re: [libvirt] [PATCH v3 4/4] docs: Add pm element into documentation

2012-08-22 Thread Eric Blake
On 08/22/2012 07:37 AM, Michal Privoznik wrote:
 On 09.08.2012 10:26, Martin Kletzander wrote:
 ---
  docs/formatdomain.html.in |   21 +
  1 files changed, 21 insertions(+), 0 deletions(-)

 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index f97c630..50c4783 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -922,6 +922,27 @@
  domain will be restarted with the same configuration/dd
  /dl

 +h3a name=elementsPowerManagementPower Management/a/h3
 +
 +p
 +  span class=sinceSince 0.10.1/span it is possible to
 +  forcibly enable or disable BIOS advertisements to the guest
 +  OS. (NB: Only qemu driver support)

Are we trying to get this into 0.10.0 (even though it missed RC1 freeze)
or deferring it to 0.10.1?

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



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

Re: [libvirt] [PATCH v3 4/4] docs: Add pm element into documentation

2012-08-22 Thread Martin Kletzander
On 08/22/2012 05:08 PM, Eric Blake wrote:
 On 08/22/2012 07:37 AM, Michal Privoznik wrote:
 On 09.08.2012 10:26, Martin Kletzander wrote:
 ---
  docs/formatdomain.html.in |   21 +
  1 files changed, 21 insertions(+), 0 deletions(-)

 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index f97c630..50c4783 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -922,6 +922,27 @@
  domain will be restarted with the same configuration/dd
  /dl

 +h3a name=elementsPowerManagementPower Management/a/h3
 +
 +p
 +  span class=sinceSince 0.10.1/span it is possible to
 +  forcibly enable or disable BIOS advertisements to the guest
 +  OS. (NB: Only qemu driver support)
 
 Are we trying to get this into 0.10.0 (even though it missed RC1 freeze)
 or deferring it to 0.10.1?
 

Nope, we didn't make it = it has to wait, no point in rushing it. I've
missed the version number, so at least one thing I don't have to fix ;)

I'll fix the other things Michal pointed out and it can wait till the
next one. Thanks for considering it, though.

Martin

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


Re: [libvirt] [PATCH] docs: fix blockpull/blockcopy bandwidth Mbps - MiB/s

2012-08-22 Thread Michal Privoznik
On 22.08.2012 17:12, Eric Blake wrote:
 On 08/22/2012 07:59 AM, Stefan Hajnoczi wrote:
 The bandwidth units for blockpull and blockcopy are in Megabytes per
 Second, not Megabits per Second.

 Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 ---
  src/libvirt.c   |   10 +-
  tools/virsh.pod |4 ++--
  2 files changed, 7 insertions(+), 7 deletions(-)
 
 ACK.
 

And pushed now. I've also added you to the AUTHORS file. Please let us
know if you prefer any other spelling (the file is in UTF-8).

Michal

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


Re: [libvirt] [PATCH] additional parameter needed for dnsmasq

2012-08-22 Thread Gene Czarcinski

On 08/22/2012 10:48 AM, Claudio Bley wrote:

+virCommandAddArgFormat(cmd,
 +--domain %s --local=/%s/,
 +network-def-domain,
 +network-def-domain);

Here, you're adding --domain D --local=/D/ as a*single*  argument to
the dnsmasq call.

You need to provide --domain, network-def-domain, --local=/D/ as
3 arguments to the call, ie. first use
virCommandAddArgPair(cmd, --domain, D), then use virCommandAddArgFormat
for the --local part.

Much thanks.  That did the trick.

I also now see what the tests are doing ... going to need to change the 
file pairs for all nine test.  Oh well, it cannot be that much work.


BTW, even if a domain name is not specified, the --local=// is needed 
so that most stuff is not forwarded.  For some reason, dnsmasq wants to 
forward and MX queries.  I am going to take that issue up with the 
dnsmasq folks directly.


I will re-post the patches when I complete and test them.

Gene

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


Re: [libvirt] [PATCH 0/5] add usb redirection filter support

2012-08-22 Thread Guannan Ren

On 08/19/2012 11:42 PM, Guannan Ren wrote:

BZ RFE https://bugzilla.redhat.com/show_bug.cgi?id=795929
qemu support:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=6af165892cf900291046f1d25f95416f379504c2

Since qemu has have the code to support USB redirection filter. This set of
patches try to support it from libvirt.
The XML format is like this:
  devices
...
redirdev bus='usb' type='spicevmc'
  address type='usb' bus='0' port='4'/
/redirdev
redirfilter
  usbdev class='0x08' vendor='0x1234' product='0xbeef' \
  version='2.00' allow='yes'/
  usbdev class='-1' vendor='-1' product='-1' version='-1' allow='no'/
/redirfilter
...
  /devices

Multiple usbdev element as one of filter rule could be added into parent
element redirfilter, only no more than redirfilter element could exists.
There is no 1:1 mapping between ports and redirected devices and qemu and
spicy client couldn't decide into which usbredir ports the client can 'plug'
redirected devices. So it make sense to apply all of filter rules global to
all existing usb redirection devices. class attribute is USB Class codes.
version is bcdDevice value of USB device. vendor and product is USB vendorId
and productId.
-1 can be used to allow any value for a field. Except allow attribute
the other four are optional, default value is -1.

The above XML will be converted to the following qemu command line:
If there are multiple usb-redir device, all of them have the same filter rules.
-device usb-redir,chardev=charredir0,id=redir0,\
filter=0x08:0x1234:0xBEEF:0x2000:1|-1:-1:-1:-1:0,bus=usb.0,port=4

Guannan Ren(0/5)
   qemu: add usb-redir.filter qemu capability flag
   qemu: define and parse USB redirection filter XML
   qemu: build USB redirection filter qemu command line
   test: add xml2argvtest for usb-redir filter and update
   doc: update usb redirection filter infomation on

  docs/formatdomain.html.in  |   38 ++-
  docs/schemas/domaincommon.rng  |   66 
  src/conf/domain_conf.c |  346 
  src/conf/domain_conf.h |   21 ++
  src/qemu/qemu_capabilities.c   |4 +
  src/qemu/qemu_capabilities.h   |1 +
  src/qemu/qemu_command.c|   45 +++-
  src/qemu/qemu_command.h|5 +-
  src/qemu/qemu_hotplug.c|3 +-
  .../qemuxml2argv-usb-redir-filter.args |   10 +
  .../qemuxml2argv-usb-redir-filter.xml  |   45 +++
  tests/qemuxml2argvtest.c   |6 +
  12 files changed, 571 insertions(+), 19 deletions(-)

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


   ping :)

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


[libvirt] [PATCH] (updated) additional parameters needed for dnsmasq

2012-08-22 Thread Gene Czarcinski
As I said in a previous message, dnsmasq is forwarding a number of 
queries upstream that should not be done.  There still remains an MX 
query for a plain name with no domain specified that will be forwarded 
is dnsmasq has --domain=xxx  --local=/xxx/ specified. This does not 
happen with no domain name and --local=// ... not a libvirt problem.


BTW, thanks again to Claudio Bley!


diff -uNr libvirt-0.9.11.4.orig/src/network/bridge_driver.c 
libvirt-0.9.11.4/src/network/bridge_driver.c
--- libvirt-0.9.11.4.orig/src/network/bridge_driver.c2012-06-15 
14:23:21.0 -0400
+++ libvirt-0.9.11.4/src/network/bridge_driver.c2012-08-22 
12:16:45.263488789 -0400

@@ -490,8 +490,15 @@
  */
 virCommandAddArgList(cmd, --strict-order, --bind-interfaces, 
NULL);


-if (network-def-domain)
+if (network-def-domain) {
 virCommandAddArgList(cmd, --domain, network-def-domain, NULL);
+virCommandAddArgFormat(cmd, --local=/%s/, network-def-domain);
+virCommandAddArgList(cmd, --domain-needed, --filterwin2k, 
NULL);

+}
+else { /* need to specify local even if no domain specified */
+virCommandAddArg(cmd, --local=//);
+virCommandAddArgList(cmd, --domain-needed, --filterwin2k, 
NULL);

+}

 if (pidfile)
 virCommandAddArgPair(cmd, --pid-file, pidfile);
diff -uNr 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/isolated-network.argv 
libvirt-0.9.11.4/tests/networkxml2argvdata/isolated-network.argv
--- 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/isolated-network.argv 
2012-06-15 14:21:54.0 -0400
+++ libvirt-0.9.11.4/tests/networkxml2argvdata/isolated-network.argv 
2012-08-22 12:20:37.700995728 -0400

@@ -1,4 +1,5 @@
-@DNSMASQ@ --strict-order --bind-interfaces --conf-file= \
+@DNSMASQ@ --strict-order --bind-interfaces \
+--local=// --domain-needed --filterwin2k --conf-file= \
 --except-interface lo --dhcp-option=3 --no-resolv \
 --listen-address 192.168.152.1 \
 --dhcp-range 192.168.152.2,192.168.152.254 \
diff -uNr 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/nat-network.argv 
libvirt-0.9.11.4/tests/networkxml2argvdata/nat-network.argv
--- libvirt-0.9.11.4.orig/tests/networkxml2argvdata/nat-network.argv 
2012-06-15 14:21:54.0 -0400
+++ libvirt-0.9.11.4/tests/networkxml2argvdata/nat-network.argv 
2012-08-22 12:21:24.481703184 -0400

@@ -1,4 +1,5 @@
-@DNSMASQ@ --strict-order --bind-interfaces --conf-file= \
+@DNSMASQ@ --strict-order --bind-interfaces \
+--local=// --domain-needed --filterwin2k --conf-file= \
 --except-interface lo --listen-address 192.168.122.1 \
 --listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 \
 --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 \
diff -uNr 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/nat-network-dns-hosts.argv 
libvirt-0.9.11.4/tests/networkxml2argvdata/nat-network-dns-hosts.argv
--- 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/nat-network-dns-hosts.argv 
2012-06-15 14:21:54.0 -0400
+++ 
libvirt-0.9.11.4/tests/networkxml2argvdata/nat-network-dns-hosts.argv 
2012-08-22 12:25:30.378218203 -0400

@@ -1,3 +1,4 @@
 @DNSMASQ@ --strict-order --bind-interfaces --domain example.com \
+--local=/example.com/ --domain-needed --filterwin2k \
 --conf-file= --except-interface lo --listen-address 192.168.122.1 \
 --expand-hosts --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts\
diff -uNr 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/nat-network-dns-srv-record.argv 
libvirt-0.9.11.4/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
--- 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/nat-network-dns-srv-record.argv 
2012-06-15 14:21:54.0 -0400
+++ 
libvirt-0.9.11.4/tests/networkxml2argvdata/nat-network-dns-srv-record.argv 
2012-08-22 12:22:35.471268869 -0400

@@ -1,7 +1,7 @@
 @DNSMASQ@ \
 --strict-order \
 --bind-interfaces \
---conf-file= \
+--local=// --domain-needed --filterwin2k --conf-file= \
 --except-interface lo \
 --srv-host=name.tcp.test-domain-name,.,1024,10,10 \
 --listen-address 192.168.122.1 \
diff -uNr 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv 
libvirt-0.9.11.4/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
--- 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv 
2012-06-15 14:21:54.0 -0400
+++ 
libvirt-0.9.11.4/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv 
2012-08-22 12:22:48.422191468 -0400

@@ -1,7 +1,7 @@
 @DNSMASQ@ \
 --strict-order \
 --bind-interfaces \
---conf-file= \
+--local=// --domain-needed --filterwin2k --conf-file= \
 --except-interface lo \
 --srv-host=name.tcp. \
 --listen-address 192.168.122.1 \
diff -uNr 
libvirt-0.9.11.4.orig/tests/networkxml2argvdata/nat-network-dns-txt-record.argv 
libvirt-0.9.11.4/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
--- 

Re: [libvirt] [PATCH] (updated) additional parameters needed for dnsmasq

2012-08-22 Thread Eric Blake
On 08/22/2012 10:59 AM, Gene Czarcinski wrote:
 As I said in a previous message, dnsmasq is forwarding a number of
 queries upstream that should not be done.  There still remains an MX
 query for a plain name with no domain specified that will be forwarded
 is dnsmasq has --domain=xxx  --local=/xxx/ specified. This does not
 happen with no domain name and --local=// ... not a libvirt problem.
 

This message needs adjustment before it is appropriate for libvirt.git
(a year from now, someone reading 'git log' will have no idea what it
was '(updated)' from, nor know the URL to the 'previous message').

 -if (network-def-domain)
 +if (network-def-domain) {
  virCommandAddArgList(cmd, --domain, network-def-domain, NULL);
 +virCommandAddArgFormat(cmd, --local=/%s/, network-def-domain);
 +virCommandAddArgList(cmd, --domain-needed, --filterwin2k,
 NULL);
 +}
 +else { /* need to specify local even if no domain specified */
 +virCommandAddArg(cmd, --local=//);
 +virCommandAddArgList(cmd, --domain-needed, --filterwin2k,
 NULL);
 +}

Simpler as:

if (network-def-domain)
virCommandArgPair(cmd, --domain, network-def-domain);
virCommandAddArgFormat(cmd, --local=/%s/,
network-def-domain ? network-def-domain : );
virCommandAddArgList(cmd, --domain-needed, --filterwin2k, NULL);

with a corresponding tweak in the testsuite to recognize
'--domain=example.com' as a result.

 
 Just in case, I also attached the patch.

Thanks, that helped.  Your mail failed to make it through 'git am', but
your attachment made it through 'git apply' so I was still able to piece
the two together to form the commit message using the headers from your
email for correct attribution.  But using 'git send-email' in the future
would make it easier to apply your patches; we have some hints on that
in our HACKING file.

ACK and pushed with the above tweak, and with adding you to AUTHORS (let
us know if you prefer any other spelling or email address; the file is
in UTF-8).

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



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

Re: [libvirt] [PATCH] (updated) additional parameters needed for dnsmasq

2012-08-22 Thread Eric Blake
On 08/22/2012 11:39 AM, Eric Blake wrote:
 On 08/22/2012 10:59 AM, Gene Czarcinski wrote:
 As I said in a previous message, dnsmasq is forwarding a number of
 queries upstream that should not be done.  There still remains an MX
 query for a plain name with no domain specified that will be forwarded
 is dnsmasq has --domain=xxx  --local=/xxx/ specified. This does not
 happen with no domain name and --local=// ... not a libvirt problem.

 
 ACK and pushed with the above tweak, and with adding you to AUTHORS (let
 us know if you prefer any other spelling or email address; the file is
 in UTF-8).

Oh, and now that I've already pushed, I have a high-level question: what
is the minimum version of 'dnsmasq' that supports the command-line
syntax that this patch introduces?

+--local=// --domain-needed --filterwin2k \

If older dnsmasq doesn't recognize --local=// or the new --domain-needed
or --filterwin2k options, then we either need to make this code
conditional based on probing 'dnsmasq --help' at startup, or else change
the spec file to require a larger minimum version of dnsmasq (we already
require 2.41 for other reasons).

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



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

[libvirt] [gluster]try to add gluster protocol in libvirt, but has qemuMonitorIO error

2012-08-22 Thread Yin Yin
Hi, all:
   after test the qemu gluster V5 patch:
http://lists.nongnu.org/archive/html/qemu-devel/2012-08/msg01023.html
   I had write a patch in libvirt to support gluster protocol, but has
qemuMonitorIO error:
   2012-08-22 17:17:47.600+: 29121: error : qemuMonitorIORead:490 :
Unable to read from monitor: Connection reset by peer
2012-08-22 17:17:47.600+: 29121: error : qemuMonitorIO:546 : 内部错误 event
from unexpected fd -1!=27 / watch 15!=15

the vm libvirt config file like this:
domain type='kvm'
namegluster-vm/name
vcpu1/vcpu
cpu
topology sockets='1' cores='1' threads='1'/
/cpu
on_poweroffdestroy/on_poweroff
on_rebootrestart/on_reboot
on_crashrestart/on_crash
memory524288/memory
devices
emulator/usr/libexec/qemu-kvm/emulator
disk type='network' device='disk'
source protocol='gluster' name='volname/windowsxp.img'
host name='10.1.0.1' port='24007'/
/source
target dev='vda' bus='virtio'/
driver name='qemu' type='qcow2' io='native' cache='none'/
/disk
controller type='virtio-serial' index='0'/

/devices
features
pae/
acpi/
apic/
/features
/domain

my questions:
1. what's the function of qemuMonitorIO?
2. why the qemu-gluster patch caused qemuMonitorIO error?
I could boot vm in qemu command without monitor, like this:
/usr/libexec/qemu-kvm -drive file=gluster://
10.1.0.1/volname/windowsxp.img,format=qcow2

Best Regards,
Yin Yin
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH libvirt-virshcmdref] Add blockpull and blockjob commands

2012-08-22 Thread Eric Blake
On 08/22/2012 07:40 AM, Stefan Hajnoczi wrote:
 The blockpull and blockjob commands have been present since 0.9.4.  This
 patch adds basic usage examples and command syntax.

Thanks for tackling this.

 
 Signed-off-by: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 ---
  common.sh|8 ++--
  source/blockjob.xml  |   79 +++
  source/blockpull.xml |  101 
 ++
  3 files changed, 184 insertions(+), 4 deletions(-)
  create mode 100644 source/blockjob.xml
  create mode 100644 source/blockpull.xml
 

 +++ b/source/blockjob.xml
 +parameter requirement=required
 +  value type=string requirement=requiredpath/value
 +  description
 +The fully-qualified path of the disk.  See domblklist for listing 
 these names.

Maybe mention that you can give either the path (/path/to/disk) or the
devname (vda).

 +parameter requirement=optional
 +  keyword requirement=required--async/keyword
 +  description
 +Return immediately instead of waiting for cancelation to complete, 
 when specified together with --abort.

s/cancelation/cancellation/

 +  /description
 +/parameter
 +parameter requirement=optional
 +  keyword requirement=required--pivot/keyword
 +/parameter

What a shame that qemu 1.2 still doesn't support block copy, and
therefore --pivot is still a no-op (it only makes sense when ending a
copy job).

 +parameter requirement=optional
 +  keyword requirement=required--info/keyword
 +  description
 +Print information about any active block operation.
 +  /description
 +/parameter
 +  /options
 +
 +  availability from=0.9.4 /

Should we start listing which version of virsh added various options?
For example, --pivot wasn't present until 0.9.12 (commit 1f06c00), but
still has no backend that supports it (except RHEL 6.3, via
RHEL-specific patches).

 +++ b/source/blockpull.xml

 +parameter requirement=required
 +  value type=string requirement=requiredpath/value
 +  description
 +The fully-qualified path of the disk.  See domblklist for listing 
 these names.

Same story about accepting full path or devname.


 +example
 +  terminalvirsh # boldblockpull/bold valueexample-domain/value 
 valuevda/value value0/value 
 value/path/to/backing.img/value/terminal
 +  text
 +Start populating valuevda/value from its backing image chain up 
 to value/path/to/backing.img/value and return immediately.  
 value/path/to/backing.img/value and its backing images will not be 
 flattened.  Note that the value0/value means unlimited bandwidth and is 
 necessary because valuebandwidth/value and valuebase/value are 
 positional arguments.

Long line (here and elsewhere, but this one stood out to me).  Can you
please wrap things to fit in 80 columns?

Your comment is not quite true; this is an equivalent command line that
omits the bandwidth:

blockpull example-domain vda --base /path/to/backing.img

by instead using an explicit '--base'.

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



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

[libvirt] [PATCH] Fix some typos in messages, docs and comments

2012-08-22 Thread Yuri Chornoivan
 

0001-Fix-some-typos-in-messages-docs-and-comments.patch
Description: Binary data
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] (updated) additional parameters needed for dnsmasq

2012-08-22 Thread Gene Czarcinski

On 08/22/2012 01:47 PM, Eric Blake wrote:

On 08/22/2012 11:39 AM, Eric Blake wrote:

On 08/22/2012 10:59 AM, Gene Czarcinski wrote:

As I said in a previous message, dnsmasq is forwarding a number of
queries upstream that should not be done.  There still remains an MX
query for a plain name with no domain specified that will be forwarded
is dnsmasq has --domain=xxx  --local=/xxx/ specified. This does not
happen with no domain name and --local=// ... not a libvirt problem.


ACK and pushed with the above tweak, and with adding you to AUTHORS (let
us know if you prefer any other spelling or email address; the file is
in UTF-8).

Oh, and now that I've already pushed, I have a high-level question: what
is the minimum version of 'dnsmasq' that supports the command-line
syntax that this patch introduces?

+--local=// --domain-needed --filterwin2k \
I honestly do not know for sure ... I am running dnsmasq-2.59 and 
checking the dnsmasq website shows that the latest is 2.63.  The oldest 
active tarball is 2.45 and the example dnsmasq.conf it it has local= 
domain-needed and filterwin2k


I believe these have been around for some time and no version that 
libvirt would support will not support them.


BTW, I believe that you folks are making the right choice in using the 
long-names form of the options ... the single character versions can 
just be too confusing: -s and -S mean two very different things.  
-s is the same as --domain and -S is the same as --server which 
is also the same as --local.


I am not absolutely sure that --filterwin2k is needed to get rid of 
the bad/undesired forwarding but it sounded like an option that should 
be used in any case.




If older dnsmasq doesn't recognize --local=// or the new --domain-needed
or --filterwin2k options, then we either need to make this code
conditional based on probing 'dnsmasq --help' at startup, or else change
the spec file to require a larger minimum version of dnsmasq (we already
require 2.41 for other reasons).

I went back and checked some of the  older versions of dnsmasq (2.41 and 
2.37).  local=//, --domain-needed, and --filterwin2k are all present in 
the example dnsmasq.conf files.  This is not to say the the dnsmasq 
software does exactly the same thing in all versions. According the the 
CHANGELOG, there was some code tweaking for domain-needed in 2.58.


I am truly sorry that my patch and email made life a bit difficult for 
you.  I have not delved into any of the virtualization code and your 
setup  convensions are all reasonable but I just did not know.  The 
last package I hacked around with was NetworkManager and libvirt is a 
lot different.


As far as the code change you made to my patch, both versions work but 
yours is a bit more eligant.


Gene

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


[libvirt] [PATCH] util: eliminate erroneous VIR_WARNs in (eb|ip)tables.c

2012-08-22 Thread Laine Stump
Several VIR_DEBUG()'s were changed to VIR_WARN() while I was testing
the firewalld support patch, and I neglected to change them back
before I pushed.

In the meantime I've decided that it would be useful to have them be
VIR_INFO(), just so there will be logged evidence of which method is
being used (firewall-cmd vs. (eb|ip)tables) without needing to crank
logging to 11. (at most this adds 2 lines to libvirtd's logs per
libvirtd start).
---
 src/util/ebtables.c | 8 
 src/util/iptables.c | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/util/ebtables.c b/src/util/ebtables.c
index 1a78f89..3170ab0 100644
--- a/src/util/ebtables.c
+++ b/src/util/ebtables.c
@@ -55,19 +55,19 @@ virEbTablesOnceInit(void)
 {
 firewall_cmd_path = virFindFileInPath(firewall-cmd);
 if (!firewall_cmd_path) {
-VIR_WARN(firewall-cmd not found on system. 
- firewalld support disabled for ebtables.);
+VIR_INFO(firewall-cmd not found on system. 
+  firewalld support disabled for ebtables.);
 } else {
 virCommandPtr cmd = virCommandNew(firewall_cmd_path);
 int status;
 
 virCommandAddArgList(cmd, --state, NULL);
 if (virCommandRun(cmd, status)  0 || status != 0) {
-VIR_WARN(firewall-cmd found but disabled for ebtables);
+VIR_INFO(firewall-cmd found but disabled for ebtables);
 VIR_FREE(firewall_cmd_path);
 firewall_cmd_path = NULL;
 } else {
-VIR_WARN(using firewalld for ebtables commands);
+VIR_INFO(using firewalld for ebtables commands);
 }
 virCommandFree(cmd);
 }
diff --git a/src/util/iptables.c b/src/util/iptables.c
index d8fdd3b..8a575c2 100644
--- a/src/util/iptables.c
+++ b/src/util/iptables.c
@@ -53,19 +53,19 @@ virIpTablesOnceInit(void)
 {
 firewall_cmd_path = virFindFileInPath(firewall-cmd);
 if (!firewall_cmd_path) {
-VIR_WARN(firewall-cmd not found on system. 
- firewalld support disabled for iptables.);
+VIR_INFO(firewall-cmd not found on system. 
+  firewalld support disabled for iptables.);
 } else {
 virCommandPtr cmd = virCommandNew(firewall_cmd_path);
 int status;
 
 virCommandAddArgList(cmd, --state, NULL);
 if (virCommandRun(cmd, status)  0 || status != 0) {
-VIR_WARN(firewall-cmd found but disabled for iptables);
+VIR_INFO(firewall-cmd found but disabled for iptables);
 VIR_FREE(firewall_cmd_path);
 firewall_cmd_path = NULL;
 } else {
-VIR_WARN(using firewalld for iptables commands);
+VIR_INFO(using firewalld for iptables commands);
 }
 virCommandFree(cmd);
 }
-- 
1.7.11.4

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


Re: [libvirt] [PATCH] (updated) additional parameters needed for dnsmasq

2012-08-22 Thread Eric Blake
On 08/22/2012 01:36 PM, Gene Czarcinski wrote:

 Oh, and now that I've already pushed, I have a high-level question: what
 is the minimum version of 'dnsmasq' that supports the command-line
 syntax that this patch introduces?

 I went back and checked some of the  older versions of dnsmasq (2.41 and
 2.37).  local=//, --domain-needed, and --filterwin2k are all present in

That should be good enough.  Thanks for the research!

 the example dnsmasq.conf files.  This is not to say the the dnsmasq
 software does exactly the same thing in all versions. According the the
 CHANGELOG, there was some code tweaking for domain-needed in 2.58.

May be true, but hopefully we'll get a decent report if someone runs
into subtleties caused by this; but at least we know we won't hit anyone
complaining that dnsmasq no longer starts due to unknown options.

 
 I am truly sorry that my patch and email made life a bit difficult for
 you.  I have not delved into any of the virtualization code and your
 setup  convensions are all reasonable but I just did not know.  The
 last package I hacked around with was NetworkManager and libvirt is a
 lot different.

No problem - we're used to helping out first-time contributors.  Open
source is successful when you give people the benefit of a doubt, and
encourage their contribution in spite of difficulties.  On the converse
side, touching up every single patch doesn't scale well, which is why we
write HACKING documents, and why we try to be friendly even when asking
for a re-submission, and why we aren't quite so lenient on HACKING
violations from repeated contributors.

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



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

Re: [libvirt] [PATCH] util: eliminate erroneous VIR_WARNs in (eb|ip)tables.c

2012-08-22 Thread Eric Blake
On 08/22/2012 02:07 PM, Laine Stump wrote:
 Several VIR_DEBUG()'s were changed to VIR_WARN() while I was testing
 the firewalld support patch, and I neglected to change them back
 before I pushed.
 
 In the meantime I've decided that it would be useful to have them be
 VIR_INFO(), just so there will be logged evidence of which method is
 being used (firewall-cmd vs. (eb|ip)tables) without needing to crank
 logging to 11. (at most this adds 2 lines to libvirtd's logs per
 libvirtd start).
 ---
  src/util/ebtables.c | 8 
  src/util/iptables.c | 8 
  2 files changed, 8 insertions(+), 8 deletions(-)

ACK.

 
 diff --git a/src/util/ebtables.c b/src/util/ebtables.c
 index 1a78f89..3170ab0 100644
 --- a/src/util/ebtables.c
 +++ b/src/util/ebtables.c
 @@ -55,19 +55,19 @@ virEbTablesOnceInit(void)
  {
  firewall_cmd_path = virFindFileInPath(firewall-cmd);
  if (!firewall_cmd_path) {
 -VIR_WARN(firewall-cmd not found on system. 
 - firewalld support disabled for ebtables.);
 +VIR_INFO(firewall-cmd not found on system. 
 +  firewalld support disabled for ebtables.);

Indentation looks off.

 +++ b/src/util/iptables.c
 @@ -53,19 +53,19 @@ virIpTablesOnceInit(void)
  {
  firewall_cmd_path = virFindFileInPath(firewall-cmd);
  if (!firewall_cmd_path) {
 -VIR_WARN(firewall-cmd not found on system. 
 - firewalld support disabled for iptables.);
 +VIR_INFO(firewall-cmd not found on system. 
 +  firewalld support disabled for iptables.);

and again.

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



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

Re: [libvirt] [PATCH] Fix some typos in messages, docs and comments

2012-08-22 Thread Eric Blake
On 08/22/2012 12:32 PM, Yuri Chornoivan wrote:
 
 0001-Fix-some-typos-in-messages-docs-and-comments.patch
 
 
 From 18c3b2ada7fbc5c2ec7563a1e97f55e627b544f1 Mon Sep 17 00:00:00 2001
 From: Yuri Chornoivan yurc...@ukr.net
 Date: Wed, 22 Aug 2012 21:29:18 +0300
 Subject: [PATCH] Fix some typos in messages, docs and comments.
 
 ---
  docs/api.html.in|2 +-
  docs/bugs.html.in   |2 +-
  docs/drivers.html.in|2 +-
  docs/drvqemu.html.in|4 ++--
  docs/drvtest.html.in|2 +-
  docs/drvxen.html.in |2 +-
  docs/formatdomain.html.in   |8 
  docs/formatnode.html.in |4 ++--
  docs/formatnwfilter.html.in |   12 ++--
  docs/locking.html.in|2 +-
  docs/news.html.in   |8 
  src/network/bridge_driver.c |2 +-
  src/rpc/virnetsshsession.c  |4 ++--
  src/util/virhash.c  |4 ++--
  14 files changed, 29 insertions(+), 29 deletions(-)

Quite a list.  Thanks; ACK and pushed.

 +++ b/docs/drvtest.html.in
 @@ -8,7 +8,7 @@
  The libvirt Test driver is a per-process fake hypervisor driver,
  with a driver name of 'test'. The driver maintains all its state
  in memory. It can start with a pre-configured default config, or
 -be given a path to a alternate config. Some example conection URIs
 +be given a path to a alternate config. Some example connection URIs

while here, s/a alternate/an alternate/

 +++ b/docs/news.html.in
 @@ -255,7 +255,7 @@ and check the a 
 href=http://libvirt.org/git/?p=libvirt.git;a=log;GIT log/a
Fix mistakes in augeas lens (Daniel P. Berrange),br/
Standardize whitespace used in example config files (Daniel P. 
 Berrange),br/
Remove uid param from directory lookup APIs (Daniel P. Berrange),br/
 -  Fix check for socket existance / daemon spawn (Daniel P. 
 Berrange),br/
 +  Fix check for socket existence / daemon spawn (Daniel P. 
 Berrange),br/

We can fix these now, but I'm not sure whether they will pop up again
the next time we regenerate NEWS items (I guess that depends on how DV
adds items to news.html.in).

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



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

[libvirt] [PATCH] fix check of vcpuid in virDomainVcpuPinDefParseXML

2012-08-22 Thread Hu Tao
For emulator, the vcpuid field is always set to -1, instead of parsing
XML for the value of it.

---
 src/conf/domain_conf.c |   22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7242205..419088c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7923,7 +7923,7 @@ virDomainVcpuPinDefParseXML(const xmlNodePtr node,
 {
 virDomainVcpuPinDefPtr def;
 xmlNodePtr oldnode = ctxt-node;
-int vcpuid;
+int vcpuid = -1;
 char *tmp = NULL;
 int ret;
 
@@ -7934,15 +7934,17 @@ virDomainVcpuPinDefParseXML(const xmlNodePtr node,
 
 ctxt-node = node;
 
-ret = virXPathInt(string(./@vcpu), ctxt, vcpuid);
-if ((ret == -2) || (vcpuid  -1)) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   %s, _(vcpu id must be an unsigned integer or -1));
-goto error;
-} else if ((vcpuid == -1)  (emulator == 0)) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   %s, _(vcpu id value -1 is not allowed for vcpupin));
-goto error;
+if (emulator == 0) {
+ret = virXPathInt(string(./@vcpu), ctxt, vcpuid);
+if ((ret == -2) || (vcpuid  -1)) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   %s, _(vcpu id must be an unsigned integer or 
-1));
+goto error;
+} else if (vcpuid == -1) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   %s, _(vcpu id value -1 is not allowed for 
vcpupin));
+goto error;
+}
 }
 
 if (vcpuid = maxvcpus) {
-- 
1.7.10.2

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


Re: [libvirt] [PATCH] util: eliminate erroneous VIR_WARNs in (eb|ip)tables.c

2012-08-22 Thread Laine Stump
On 08/22/2012 05:18 PM, Eric Blake wrote:
 On 08/22/2012 02:07 PM, Laine Stump wrote:
 Several VIR_DEBUG()'s were changed to VIR_WARN() while I was testing
 the firewalld support patch, and I neglected to change them back
 before I pushed.

 In the meantime I've decided that it would be useful to have them be
 VIR_INFO(), just so there will be logged evidence of which method is
 being used (firewall-cmd vs. (eb|ip)tables) without needing to crank
 logging to 11. (at most this adds 2 lines to libvirtd's logs per
 libvirtd start).
 ---
  src/util/ebtables.c | 8 
  src/util/iptables.c | 8 
  2 files changed, 8 insertions(+), 8 deletions(-)
 ACK.

 diff --git a/src/util/ebtables.c b/src/util/ebtables.c
 index 1a78f89..3170ab0 100644
 --- a/src/util/ebtables.c
 +++ b/src/util/ebtables.c
 @@ -55,19 +55,19 @@ virEbTablesOnceInit(void)
  {
  firewall_cmd_path = virFindFileInPath(firewall-cmd);
  if (!firewall_cmd_path) {
 -VIR_WARN(firewall-cmd not found on system. 
 - firewalld support disabled for ebtables.);
 +VIR_INFO(firewall-cmd not found on system. 
 +  firewalld support disabled for ebtables.);
 Indentation looks off.

Right. Fixed and pushed. Thanks!

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


[libvirt] [PATCH v4 0/7] support guest agent general command

2012-08-22 Thread MATSUDA, Daiki
Hi. All.

I rewrote the patched for git head tree, adding some code.

And @timeout must be following
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK(-2) : does not block and wait forever.
VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT(-1) : use default time for waiting
VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWIAT(0) : does not wait and out soon
positive value : wait for pointed seconds.
And I also add VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN for not writing static value.

In addition, I added the some options for virsh command qemu-agent-command
--block : it means taht @timeout is VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK.
--async : it means taht @timeout is VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWIAT.
--timeout @seconds : @seconds must be positive value and it means that @timeout 
is positive value case.
These upper options are exclusive.
If no options are given, it means taht @timeout is 
IR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT.

virsh # help qemu-agent-command
  NAME
qemu-agent-command - QEMU Guest Agent Command

  SYNOPSIS
qemu-agent-command domain [--timeout number] [--async] [--block] 
{[--cmd] string}...

  DESCRIPTION
Run an arbitrary qemu guest agent command; use at your own risk

  OPTIONS
[--domain] string  domain name, id or uuid
--timeout number  timeout seconds. must be positive.
--async  execute command without waiting for timeout
--block  execute command without timeout
[--cmd] string  command

virsh # qemu-agent-command RHEL58_64 '{execute:guest-info}'
{return:{version:1.1.50,supported_commands:[{enabled:true,name:guest-network-get-interfaces},{enabled:true,name:guest-suspend-hybrid},{enabled:true,name:guest-suspend-ram},{enabled:true,name:guest-suspend-disk},{enabled:true,name:guest-fsfreeze-thaw},{enabled:true,name:guest-fsfreeze-freeze},{enabled:true,name:guest-fsfreeze-status},{enabled:true,name:guest-file-flush},{enabled:true,name:guest-file-seek},{enabled:true,name:guest-file-write},{enabled:true,name:guest-file-read},{enabled:true,name:guest-file-close},{enabled:true,name:guest-file-open},{enabled:true,name:guest-shutdown},{enabled:true,name:guest-info},{enabled:true,name:guest-ping},{enabled:true,name:guest-sync},{enabled:true,name:guest-sync-delimited}]}}

virsh # qemu-agent-command --block RHEL58_64 
'{execute:guest-sync,arguments:{id:123}}'
{return:123}

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


[libvirt] [PATCH v4 5/7] add remote driver support Add qemuDomainAgentCommand() which is generated automatically, for .qemuDomainArbitraryAgentCommand to remote driver.

2012-08-22 Thread MATSUDA Daiki

Signed-off-by: MATSUDA Daiki matsuda...@intellilink.co.jp
---
 src/qemu_protocol-structs  |   10 ++
 src/remote/qemu_protocol.x |   14 +-
 src/remote/remote_driver.c |1 +
 3 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/qemu_protocol-structs b/src/qemu_protocol-structs
index 67968eb..e6cde60 100644
--- a/src/qemu_protocol-structs
+++ b/src/qemu_protocol-structs
@@ -19,7 +19,17 @@ struct qemu_domain_attach_args {
 struct qemu_domain_attach_ret {
 remote_nonnull_domain  dom;
 };
+struct qemu_domain_agent_command_args {
+remote_nonnull_domain  dom;
+remote_nonnull_string  cmd;
+inttimeout;
+u_int  flags;
+};
+struct qemu_domain_agent_command_ret {
+remote_string  result;
+};
 enum qemu_procedure {
 QEMU_PROC_MONITOR_COMMAND = 1,
 QEMU_PROC_DOMAIN_ATTACH = 2,
+QEMU_PROC_DOMAIN_AGENT_COMMAND = 3,
 };
diff --git a/src/remote/qemu_protocol.x b/src/remote/qemu_protocol.x
index c06339c..914caed 100644
--- a/src/remote/qemu_protocol.x
+++ b/src/remote/qemu_protocol.x
@@ -47,6 +47,17 @@ struct qemu_domain_attach_ret {
 remote_nonnull_domain dom;
 };
 
+struct qemu_domain_agent_command_args {
+remote_nonnull_domain dom;
+remote_nonnull_string cmd;
+int timeout;
+unsigned int flags;
+};
+
+struct qemu_domain_agent_command_ret {
+remote_string result;
+};
+
 /* Define the program number, protocol version and procedure numbers here. */
 const QEMU_PROGRAM = 0x20008087;
 const QEMU_PROTOCOL_VERSION = 1;
@@ -61,5 +72,6 @@ enum qemu_procedure {
  * are some exceptions to this rule, e.g. domainDestroy. Other APIs MAY
  * be marked as high priority. If in doubt, it's safe to choose low. */
 QEMU_PROC_MONITOR_COMMAND = 1, /* skipgen skipgen priority:low */
-QEMU_PROC_DOMAIN_ATTACH = 2 /* autogen autogen priority:low */
+QEMU_PROC_DOMAIN_ATTACH = 2, /* autogen autogen priority:low */
+QEMU_PROC_DOMAIN_AGENT_COMMAND = 3 /* autogen autogen priority:low */
 };
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 977d139..aa234b3 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5416,6 +5416,7 @@ static virDriver remote_driver = {
 .domainSetMetadata = remoteDomainSetMetadata, /* 0.9.10 */
 .domainGetMetadata = remoteDomainGetMetadata, /* 0.9.10 */
 .domainGetHostname = remoteDomainGetHostname, /* 0.10.0 */
+.qemuDomainArbitraryAgentCommand = qemuDomainAgentCommand, /* 0.10.1 */
 };
 
 static virNetworkDriver network_driver = {
-- 
1.7.1

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


[libvirt] [PATCH v4 3/7] Add virDrvDomainQemuAgentCommand prototype for drivers. Add virDrvDomainQemuAgentCommand prototype for drivers. Add virDomainQemuAgentCommand() for virDrvDomainQemuAgentComman

2012-08-22 Thread MATSUDA Daiki

Signed-off-by: MATSUDA Daiki matsuda...@intellilink.co.jp
---
 include/libvirt/libvirt-qemu.h |3 ++
 python/generator.py|1 +
 src/driver.h   |4 +++
 src/libvirt-qemu.c |   54 
 src/libvirt_qemu.syms  |5 +++
 5 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
index 93386ca..d7f8703 100644
--- a/include/libvirt/libvirt-qemu.h
+++ b/include/libvirt/libvirt-qemu.h
@@ -51,6 +51,9 @@ typedef enum {
 VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT = 0,
 } virDomainQemuAgentCommandTimeoutValues;
 
+char *virDomainQemuAgentCommand(virDomainPtr domain, const char *cmd,
+int timeout, unsigned int flags);
+
 # ifdef __cplusplus
 }
 # endif
diff --git a/python/generator.py b/python/generator.py
index 1f87195..7beb361 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -431,6 +431,7 @@ skip_impl = (
 
 qemu_skip_impl = (
 'virDomainQemuMonitorCommand',
+'virDomainQemuAgentCommand',
 )
 
 
diff --git a/src/driver.h b/src/driver.h
index 203497d..7ee103e 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -691,6 +691,9 @@ typedef int
 typedef int
 (*virDrvDomainQemuMonitorCommand)(virDomainPtr domain, const char *cmd,
   char **result, unsigned int flags);
+typedef char *
+(*virDrvDomainQemuAgentCommand)(virDomainPtr domain, const char *cmd,
+int timeout, unsigned int flags);
 
 /* Choice of unsigned int rather than pid_t is intentional.  */
 typedef virDomainPtr
@@ -1052,6 +1055,7 @@ struct _virDriver {
 virDrvDomainGetDiskErrors   domainGetDiskErrors;
 virDrvDomainSetMetadata domainSetMetadata;
 virDrvDomainGetMetadata domainGetMetadata;
+virDrvDomainQemuAgentCommandqemuDomainArbitraryAgentCommand;
 };
 
 typedef int
diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c
index 78480bb..7a45242 100644
--- a/src/libvirt-qemu.c
+++ b/src/libvirt-qemu.c
@@ -185,3 +185,57 @@ error:
 virDispatchError(conn);
 return NULL;
 }
+
+/**
+ * virDomainQemuAgentCommand:
+ * @domain: a domain object
+ * @cmd: the guest agent command string
+ * @timeout: timeout seconds
+ * @flags: execution flags
+ *
+ * Execute an arbitrary Guest Agent command.
+ *
+ * Issue @cmd to the guest agent running in @domain.
+ * @timeout must be -2, -1, 0 or positive.
+ * VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK(-2): meaning to block forever waiting 
for
+ * a result.
+ * VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT(-1): use default timeout value.
+ * VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT(0): does not wait.
+ * positive value: wait for @timeout seconds
+ *
+ * Returns strings if success, NULL in failure.
+ */
+char *
+virDomainQemuAgentCommand(virDomainPtr domain,
+  const char *cmd,
+  int timeout,
+  unsigned int flags)
+{
+virConnectPtr conn;
+
+VIR_DEBUG(domain=%p, cmd=%s, timeout=%d, flags=%x,
+  domain, cmd, timeout, flags);
+
+if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+virDispatchError(NULL);
+return NULL;
+}
+if (domain-conn-flags  VIR_CONNECT_RO) {
+virLibDomainError(NULL, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+return NULL;
+}
+
+conn = domain-conn;
+
+if (conn-driver-qemuDomainArbitraryAgentCommand) {
+return conn-driver-qemuDomainArbitraryAgentCommand(domain, cmd,
+ timeout, flags);
+}
+
+virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+/* Copy to connection error object for back compatibility */
+virDispatchError(conn);
+return NULL;
+}
diff --git a/src/libvirt_qemu.syms b/src/libvirt_qemu.syms
index 8447730..6e11509 100644
--- a/src/libvirt_qemu.syms
+++ b/src/libvirt_qemu.syms
@@ -19,3 +19,8 @@ LIBVIRT_QEMU_0.9.4 {
 global:
 virDomainQemuAttach;
 } LIBVIRT_QEMU_0.8.3;
+
+LIBVIRT_QEMU_0.10.1 {
+global:
+virDomainQemuAgentCommand;
+} LIBVIRT_QEMU_0.9.4;
-- 
1.7.1

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


[libvirt] [PATCH v4 4/7] add qemu driver support Add qemuDrvDomainAgentCommand() for .qemuDomainArbitraryAgentCommand to qemu driver.

2012-08-22 Thread MATSUDA Daiki

Signed-off-by: MATSUDA Daiki matsuda...@intellilink.co.jp
---
 src/qemu/qemu_driver.c |   71 
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 109d18d..a62d1bb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13437,6 +13437,76 @@ qemuListAllDomains(virConnectPtr conn,
 return ret;
 }
 
+static char *
+qemuDrvDomainAgentCommand(virDomainPtr domain,
+   const char *cmd,
+   int timeout,
+   unsigned int flags)
+{
+struct qemud_driver *driver = domain-conn-privateData;
+virDomainObjPtr vm;
+int ret = -1;
+char *result = NULL;
+qemuDomainObjPrivatePtr priv;
+
+virCheckFlags(0, NULL);
+
+qemuDriverLock(driver);
+vm = virDomainFindByUUID(driver-domains, domain-uuid);
+qemuDriverUnlock(driver);
+
+if (!vm) {
+char uuidstr[VIR_UUID_STRING_BUFLEN];
+virUUIDFormat(domain-uuid, uuidstr);
+virReportError(VIR_ERR_NO_DOMAIN,
+_(no domain with matching uuid '%s'), uuidstr);
+goto cleanup;
+}
+
+priv = vm-privateData;
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   %s, _(domain is not running));
+goto cleanup;
+}
+
+if (priv-agentError) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(QEMU guest agent is not available due to an error));
+goto cleanup;
+}
+
+if (!priv-agent) {
+virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
+   _(QEMU guest agent is not configured));
+goto cleanup;
+}
+
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+goto cleanup;
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   %s, _(domain is not running));
+goto endjob;
+}
+
+qemuDomainObjEnterAgent(driver, vm);
+ret = qemuAgentArbitraryCommand(priv-agent, cmd, result, timeout);
+qemuDomainObjExitAgent(driver, vm);
+
+endjob:
+if (qemuDomainObjEndJob(driver, vm) == 0) {
+vm = NULL;
+}
+
+cleanup:
+if (vm)
+virDomainObjUnlock(vm);
+return result;
+}
+
 static virDriver qemuDriver = {
 .no = VIR_DRV_QEMU,
 .name = QEMU_DRIVER_NAME,
@@ -13603,6 +13673,7 @@ static virDriver qemuDriver = {
 .domainPMSuspendForDuration = qemuDomainPMSuspendForDuration, /* 0.9.11 */
 .domainPMWakeup = qemuDomainPMWakeup, /* 0.9.11 */
 .domainGetCPUStats = qemuDomainGetCPUStats, /* 0.9.11 */
+.qemuDomainArbitraryAgentCommand = qemuDrvDomainAgentCommand, /* 0.10.1 */
 };
 
 
-- 
1.7.1

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


[libvirt] [PATCH v4 1/7] Add @seconds variable to qemuAgentSend(). Add @seconds variable to qemuAgentSend(). When @tiemout is true, @seconds controls how long to wait for a response (if @seconds is VI

2012-08-22 Thread MATSUDA Daiki

Signed-off-by: MATSUDA Daiki matsuda...@intellilink.co.jp
---
 include/libvirt/libvirt-qemu.h |7 +++
 src/qemu/qemu_agent.c  |   32 ++--
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
index a37f897..93386ca 100644
--- a/include/libvirt/libvirt-qemu.h
+++ b/include/libvirt/libvirt-qemu.h
@@ -44,6 +44,13 @@ virDomainPtr virDomainQemuAttach(virConnectPtr domain,
  unsigned int pid_value,
  unsigned int flags);
 
+typedef enum {
+VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN = -2,
+VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK = -2,
+VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT = -1,
+VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT = 0,
+} virDomainQemuAgentCommandTimeoutValues;
+
 # ifdef __cplusplus
 }
 # endif
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 513f1d5..61f070c 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -837,6 +837,8 @@ void qemuAgentClose(qemuAgentPtr mon)
  * @mon: Monitor
  * @msg: Message
  * @timeout: use timeout?
+ * @seconds: timeout seconds. if VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT and
+ *   @timeout is true, use default value.
  *
  * Send @msg to agent @mon.
  * Wait max QEMU_AGENT_WAIT_TIME for agent
@@ -848,7 +850,8 @@ void qemuAgentClose(qemuAgentPtr mon)
  */
 static int qemuAgentSend(qemuAgentPtr mon,
  qemuAgentMessagePtr msg,
- bool timeout)
+ bool timeout,
+ int seconds)
 {
 int ret = -1;
 unsigned long long now, then = 0;
@@ -864,7 +867,10 @@ static int qemuAgentSend(qemuAgentPtr mon,
 if (timeout) {
 if (virTimeMillisNow(now)  0)
 return -1;
-then = now + QEMU_AGENT_WAIT_TIME;
+if (!(seconds = 0 || seconds == 
VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT))
+return -1;
+then = now + (seconds == VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT ?
+  QEMU_AGENT_WAIT_TIME : seconds * 1000ull);
 }
 
 mon-msg = msg;
@@ -937,7 +943,8 @@ qemuAgentGuestSync(qemuAgentPtr mon)
 
 VIR_DEBUG(Sending guest-sync command with ID: %llu, id);
 
-send_ret = qemuAgentSend(mon, sync_msg, true);
+send_ret = qemuAgentSend(mon, sync_msg, true,
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT);
 
 VIR_DEBUG(qemuAgentSend returned: %d, send_ret);
 
@@ -977,7 +984,8 @@ cleanup:
 static int
 qemuAgentCommand(qemuAgentPtr mon,
  virJSONValuePtr cmd,
- virJSONValuePtr *reply)
+ virJSONValuePtr *reply,
+ int seconds)
 {
 int ret = -1;
 qemuAgentMessage msg;
@@ -1003,9 +1011,9 @@ qemuAgentCommand(qemuAgentPtr mon,
 }
 msg.txLength = strlen(msg.txBuffer);
 
-VIR_DEBUG(Send command '%s' for write, cmdstr);
+VIR_DEBUG(Send command '%s' for write, seconds = %d, cmdstr, seconds);
 
-ret = qemuAgentSend(mon, msg, false);
+ret = qemuAgentSend(mon, msg, seconds  -1 ? false : true, seconds);
 
 VIR_DEBUG(Receive command reply ret=%d rxObject=%p,
   ret, msg.rxObject);
@@ -1283,7 +1291,8 @@ int qemuAgentShutdown(qemuAgentPtr mon,
 return -1;
 
 mon-await_event = QEMU_AGENT_EVENT_SHUTDOWN;
-ret = qemuAgentCommand(mon, cmd, reply);
+ret = qemuAgentCommand(mon, cmd, reply,
+   VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT);
 
 if (reply  ret == 0)
 ret = qemuAgentCheckError(cmd, reply);
@@ -1315,7 +1324,8 @@ int qemuAgentFSFreeze(qemuAgentPtr mon)
 if (!cmd)
 return -1;
 
-if (qemuAgentCommand(mon, cmd, reply)  0 ||
+if (qemuAgentCommand(mon, cmd, reply,
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT)  0 ||
 qemuAgentCheckError(cmd, reply)  0)
 goto cleanup;
 
@@ -1352,7 +1362,8 @@ int qemuAgentFSThaw(qemuAgentPtr mon)
 if (!cmd)
 return -1;
 
-if (qemuAgentCommand(mon, cmd, reply)  0 ||
+if (qemuAgentCommand(mon, cmd, reply,
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT)  0 ||
 qemuAgentCheckError(cmd, reply)  0)
 goto cleanup;
 
@@ -1389,7 +1400,8 @@ qemuAgentSuspend(qemuAgentPtr mon,
 return -1;
 
 mon-await_event = QEMU_AGENT_EVENT_SUSPEND;
-ret = qemuAgentCommand(mon, cmd, reply);
+ret = qemuAgentCommand(mon, cmd, reply,
+   VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT);
 
 if (reply  ret == 0)
 ret = qemuAgentCheckError(cmd, reply);
-- 
1.7.1

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


[libvirt] [PATCH v4 6/7] add python module support Add virDomainQemuAgentCommand() support function to python module.

2012-08-22 Thread MATSUDA Daiki

Signed-off-by: MATSUDA Daiki matsuda...@intellilink.co.jp
---
 python/libvirt-qemu-override-api.xml |8 
 python/libvirt-qemu-override.c   |   29 +
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/python/libvirt-qemu-override-api.xml 
b/python/libvirt-qemu-override-api.xml
index d69acea..ca0dae9 100644
--- a/python/libvirt-qemu-override-api.xml
+++ b/python/libvirt-qemu-override-api.xml
@@ -8,5 +8,13 @@
 arg name='cmd' type='const char *' info='the command which will be 
passed to QEMU monitor'/
 arg name='flags' type='unsigned int' info='an ORapos;ed set of 
virDomainQemuMonitorCommandFlags'/
   /function
+  function name='virDomainQemuAgentCommand' file='python-qemu'
+infoSend a Guest Agent command to domain/info
+return type='str *' info='the command output'/
+arg name='domain' type='virDomainPtr' info='pointer to the domain'/
+arg name='cmd' type='const char *' info='guest agent command on 
domain'/
+arg name='timeout' type='int' info='timeout seconds'/
+arg name='flags' type='unsigned int' info='execution flags'/
+  /function
   /symbols
 /api
diff --git a/python/libvirt-qemu-override.c b/python/libvirt-qemu-override.c
index e532416..243692a 100644
--- a/python/libvirt-qemu-override.c
+++ b/python/libvirt-qemu-override.c
@@ -82,6 +82,34 @@ libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self 
ATTRIBUTE_UNUSED,
 return py_retval;
 }
 
+static PyObject *
+libvirt_qemu_virDomainQemuAgentCommand(PyObject *self ATTRIBUTE_UNUSED, 
PyObject *args)
+{
+PyObject *py_retval;
+char *result = NULL;
+virDomainPtr domain;
+PyObject *pyobj_domain;
+int timeout;
+unsigned int flags;
+char *cmd;
+
+if (!PyArg_ParseTuple(args, (char *)Ozii:virDomainQemuAgentCommand,
+  pyobj_domain, cmd, timeout, flags))
+return NULL;
+domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+if (domain == NULL)
+return VIR_PY_NONE;
+LIBVIRT_BEGIN_ALLOW_THREADS;
+result = virDomainQemuAgentCommand(domain, cmd, timeout, flags);
+LIBVIRT_END_ALLOW_THREADS;
+
+if (!result)
+return VIR_PY_NONE;
+
+py_retval = PyString_FromString(result);
+return py_retval;
+}
 /
  * *
  * The registration stuff  *
@@ -90,6 +118,7 @@ libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self 
ATTRIBUTE_UNUSED,
 static PyMethodDef libvirtQemuMethods[] = {
 #include libvirt-qemu-export.c
 {(char *) virDomainQemuMonitorCommand, 
libvirt_qemu_virDomainQemuMonitorCommand, METH_VARARGS, NULL},
+{(char *) virDomainQemuAgentCommand, 
libvirt_qemu_virDomainQemuAgentCommand, METH_VARARGS, NULL},
 {NULL, NULL, 0, NULL}
 };
 
-- 
1.7.1

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


[libvirt] [PATCH v4 7/7] add qemu-agent-command to virsh Add qemu-agent-command to virsh to support virDomainQemuAgentCommand().

2012-08-22 Thread MATSUDA Daiki

Signed-off-by: MATSUDA Daiki matsuda...@intellilink.co.jp
---
 tools/virsh-host.c |   89 
 tools/virsh.pod|   13 +++
 2 files changed, 102 insertions(+), 0 deletions(-)

diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index b09d9f9..682d374 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -633,6 +633,93 @@ cleanup:
 }
 
 /*
+ * qemu-agent-command command
+ */
+static const vshCmdInfo info_qemu_agent_command[] = {
+{help, N_(QEMU Guest Agent Command)},
+{desc, N_(Run an arbitrary qemu guest agent command; use at your own 
risk)},
+{NULL, NULL}
+};
+
+static const vshCmdOptDef opts_qemu_agent_command[] = {
+{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
+{timeout, VSH_OT_INT, VSH_OFLAG_REQ_OPT, N_(timeout seconds. must be 
positive.)},
+{async, VSH_OT_BOOL, 0, N_(execute command without waiting for 
timeout)},
+{block, VSH_OT_BOOL, 0, N_(execute command without timeout)},
+{cmd, VSH_OT_ARGV, VSH_OFLAG_REQ, N_(command)},
+{NULL, 0, 0, NULL}
+};
+
+static bool
+cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
+{
+virDomainPtr dom = NULL;
+bool ret = false;
+char *guest_agent_cmd = NULL;
+char *result = NULL;
+int timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT;
+int judge = 0;
+unsigned int flags = 0;
+const vshCmdOpt *opt = NULL;
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+bool pad = false;
+
+if (!vshConnectionUsability(ctl, ctl-conn))
+goto cleanup;
+
+dom = vshCommandOptDomain(ctl, cmd, NULL);
+if (dom == NULL)
+goto cleanup;
+
+while ((opt = vshCommandOptArgv(cmd, opt))) {
+if (pad)
+virBufferAddChar(buf, ' ');
+pad = true;
+virBufferAdd(buf, opt-data, -1);
+}
+if (virBufferError(buf)) {
+vshPrint(ctl, %s, _(Failed to collect command));
+goto cleanup;
+}
+guest_agent_cmd = virBufferContentAndReset(buf);
+
+judge = vshCommandOptInt(cmd, timeout, timeout);
+if (judge  0) {
+vshError(ctl, %s, _(timeout number has to be a number));
+} else if (judge  0) {
+judge = 1;
+}
+if (judge  timeout  1) {
+vshError(ctl, %s, _(timeout must be positive));
+}
+
+if (vshCommandOptBool(cmd, async)) {
+timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT;
+judge++;
+}
+if (vshCommandOptBool(cmd, block)) {
+timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK;
+judge++;
+}
+
+if (judge  1) {
+vshError(ctl, %s, _(timeout, async and block options are 
exclusive));
+}
+result = virDomainQemuAgentCommand(dom, guest_agent_cmd, timeout, flags);
+
+if (result) printf(%s\n, result);
+
+ret = true;
+
+cleanup:
+VIR_FREE(result);
+VIR_FREE(guest_agent_cmd);
+if (dom)
+virDomainFree(dom);
+
+return ret;
+}
+/*
  * sysinfo command
  */
 static const vshCmdInfo info_sysinfo[] = {
@@ -832,6 +919,8 @@ static const vshCmdDef hostAndHypervisorCmds[] = {
 {qemu-attach, cmdQemuAttach, opts_qemu_attach, info_qemu_attach, 0},
 {qemu-monitor-command, cmdQemuMonitorCommand, opts_qemu_monitor_command,
  info_qemu_monitor_command, 0},
+{qemu-agent-command, cmdQemuAgentCommand, opts_qemu_agent_command,
+ info_qemu_agent_command, 0},
 {sysinfo, cmdSysinfo, NULL, info_sysinfo, 0},
 {uri, cmdURI, NULL, info_uri, 0},
 {version, cmdVersion, opts_version, info_version, 0},
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 35613c4..f997cb4 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -164,6 +164,7 @@ group as an option.  For example:
  hostname   print the hypervisor hostname
  qemu-attachAttach to existing QEMU process
  qemu-monitor-command   QEMU Monitor Command
+ qemu-agent-command QEMU Guest Agent Command
  sysinfoprint the hypervisor sysinfo
  uriprint the hypervisor canonical URI
 
@@ -2780,6 +2781,18 @@ before passing the single command to the monitor.
 
 =back
 
+=item Bqemu-agent-command Idomain [I--timeout Iseconds | I--async | 
I--block] Icommand...
+
+Send an arbitrary guest agent command Icommand to domain Idomain through
+qemu agent.
+I--timeout, I--async and I--block options are exclusive.
+I--timeout requires timeout seconds Iseconds and it must be positive.
+When I--aysnc is given, the command waits for timeout whether success or
+failed. And when I--block is given, the command waits forever with blocking
+timeout.
+
+=back
+
 =head1 ENVIRONMENT
 
 The following environment variables can be set to alter the behaviour
-- 
1.7.1

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


[libvirt] [PATCH v4 2/7] add qemuAgentArbitraryCommand() for general qemu agent command. add qemuAgentArbitraryCommand() for general qemu agent command.

2012-08-22 Thread MATSUDA Daiki

Signed-off-by: MATSUDA Daiki matsuda...@intellilink.co.jp
---
 src/qemu/qemu_agent.c |   30 ++
 src/qemu/qemu_agent.h |5 +
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 61f070c..c658bf8 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1410,3 +1410,33 @@ qemuAgentSuspend(qemuAgentPtr mon,
 virJSONValueFree(reply);
 return ret;
 }
+
+int
+qemuAgentArbitraryCommand(qemuAgentPtr mon,
+  const char *cmd_str,
+  char **result,
+  int timeout)
+{
+int ret = -1;
+virJSONValuePtr cmd;
+virJSONValuePtr reply = NULL;
+
+*result = NULL;
+if (timeout  VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN)
+return ret;
+
+cmd = virJSONValueFromString(cmd_str);
+if (!cmd)
+return ret;
+
+ret = qemuAgentCommand(mon, cmd, reply, timeout);
+
+if (ret == 0) {
+ret = qemuAgentCheckError(cmd, reply);
+*result = virJSONValueToString(reply, false);
+}
+
+virJSONValueFree(cmd);
+virJSONValueFree(reply);
+return ret;
+}
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index 2fdebb2..528fee1 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -77,4 +77,9 @@ int qemuAgentFSThaw(qemuAgentPtr mon);
 
 int qemuAgentSuspend(qemuAgentPtr mon,
  unsigned int target);
+
+int qemuAgentArbitraryCommand(qemuAgentPtr mon,
+  const char *cmd,
+  char **result,
+  int timeout);
 #endif /* __QEMU_AGENT_H__ */
-- 
1.7.1

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