Re: [libvirt] [PATCHv4 3/4] blkiotune: add interface for blkiotune.device_weight

2011-11-29 Thread Daniel P. Berrange
On Mon, Nov 14, 2011 at 09:30:01PM -0700, Eric Blake wrote:
 From: Hu Tao hu...@cn.fujitsu.com
 
 This adds per-device weights to blkiotune.  Note that the
 cgroups implementation only supports weights per block device,
 and not per-file within the device; hence this option must be
 global to the domain definition rather than tied to individual
 devices/disk entries:
 
 domain ...
   blkiotune
 device
   path/path/to/block/path
   weight1000/weight
 /device
   /blkiotune
 ..
 
 This patch also adds a parameter --device-weights to virsh command
 blkiotune for setting/getting blkiotune.weight_device for any
 hypervisor that supports it.  All device entries under
 blkiotune are concatenated into a single string attribute under
 virDomain{Get,Set}BlkioParameters, named device_weight.

I don't entirely like the concatenation of devices
into device_weight, but I don't see a good alternative
given the API design.

ACK

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] [PATCHv4 3/4] blkiotune: add interface for blkiotune.device_weight

2011-11-15 Thread Eric Blake
On 11/15/2011 12:15 AM, Hu Tao wrote:

 We can filter out 0-weight here:
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index b35c83c..5160003 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -10893,6 +10893,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
  char uuidstr[VIR_UUID_STRING_BUFLEN];
  const char *type = NULL;
  int n, allones = 1;
 +int blkio = 0;

If we go this route, then this should be bool, not int.

  
  virCheckFlags(DUMPXML_FLAGS |
VIR_DOMAIN_XML_INTERNAL_STATUS |
 @@ -10930,7 +10931,15 @@ virDomainDefFormatInternal(virDomainDefPtr def,
def-mem.cur_balloon);
  
  /* add blkiotune only if there are any */
 -if (def-blkio.weight || def-blkio.devices) {
 +
 +if (def-blkio.weight)
 +blkio = 1;
 +for (n = 0; n  def-blkio.ndevices; n++) {
 +if (def-blkio.devices[n].weight)
 +blkio = 1;

and once you set the flag, you can break to shorten the loop.

 +}
 +
 +if (blkio) {
  virBufferAddLit(buf,   blkiotune\n);
  
  if (def-blkio.weight)
 @@ -10938,6 +10947,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
def-blkio.weight);
  
  for (n = 0; n  def-blkio.ndevices; n++) {
 +if (def-blkio.devices[n].weight == 0)
 +continue;
  virBufferAddLit(buf, device\n);
  virBufferEscapeString(buf,   path%s/path\n,
def-blkio.devices[n].path);
 

-- 
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] [PATCHv4 3/4] blkiotune: add interface for blkiotune.device_weight

2011-11-14 Thread Eric Blake
From: Hu Tao hu...@cn.fujitsu.com

This adds per-device weights to blkiotune.  Note that the
cgroups implementation only supports weights per block device,
and not per-file within the device; hence this option must be
global to the domain definition rather than tied to individual
devices/disk entries:

domain ...
  blkiotune
device
  path/path/to/block/path
  weight1000/weight
/device
  /blkiotune
..

This patch also adds a parameter --device-weights to virsh command
blkiotune for setting/getting blkiotune.weight_device for any
hypervisor that supports it.  All device entries under
blkiotune are concatenated into a single string attribute under
virDomain{Get,Set}BlkioParameters, named device_weight.

Signed-off-by: Hu Tao hu...@cn.fujitsu.com
Signed-off-by: Eric Blake ebl...@redhat.com
---
 docs/formatdomain.html.in  |   29 +-
 docs/schemas/domaincommon.rng  |   26 -
 include/libvirt/libvirt.h.in   |   10 ++
 src/conf/domain_conf.c |   99 +++-
 src/conf/domain_conf.h |   14 +++
 src/libvirt_private.syms   |1 +
 .../qemuxml2argv-blkiotune-device.xml  |   36 +++
 tools/virsh.c  |   43 +++--
 tools/virsh.pod|8 ++-
 9 files changed, 245 insertions(+), 21 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-blkiotune-device.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index cbad196..99c5add 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -505,6 +505,14 @@
   ...
   lt;blkiotunegt;
 lt;weightgt;800lt;/weightgt;
+lt;devicegt;
+  lt;pathgt;/dev/sdalt;/pathgt;
+  lt;weightgt;1000lt;/weightgt;
+lt;/devicegt;
+lt;devicegt;
+  lt;pathgt;/dev/sdblt;/pathgt;
+  lt;weightgt;500lt;/weightgt;
+lt;/devicegt;
   lt;/blkiotunegt;
   ...
 lt;/domaingt;
@@ -514,10 +522,25 @@
   dtcodeblkiotune/code/dt
   dd The optional codeblkiotune/code element provides the ability
 to tune Blkio cgroup tunable parameters for the domain. If this is
-omitted, it defaults to the OS provided defaults./dd
+omitted, it defaults to the OS provided
+defaults. span class=sinceSince 0.8.8/span/dd
   dtcodeweight/code/dt
-  dd The optional codeweight/code element is the I/O weight of the
-guest. The value should be in range [100, 1000]./dd
+  dd The optional codeweight/code element is the overall I/O
+weight of the guest. The value should be in the range [100,
+1000]./dd
+  dtcodedevice/code/dt
+  ddThe domain may have multiple codedevice/code elements
+that further tune the weights for each host block device in
+use by the domain.  Note that
+multiple a href=#elementsDisksguest disks/a can share a
+single host block device, if they are backed by files within
+the same host file system, which is why this tuning parameter
+is at the global domain level rather than associated with each
+guest disk device.  Each codedevice/code element has two
+mandatory sub-elements, codepath/code describing the
+absolute path of the device, and codeweight/code giving
+the relative weight of that device, in the range [100,
+1000].  span class=sinceSince 0.9.8/span/dd
 /dl


diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index b6f858e..f776a51 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -322,12 +322,26 @@
   !-- The Blkio cgroup related tunables would go in the blkiotune --
   optional
 element name=blkiotune
-  !-- I/O weight the VM can use --
-  optional
-element name=weight
-  ref name=weight/
-/element
-  /optional
+  interleave
+!-- I/O weight the VM can use --
+optional
+  element name=weight
+ref name=weight/
+  /element
+/optional
+zeroOrMore
+  element name=device
+interleave
+  element name=path
+ref name=absFilePath/
+  /element
+  element name=weight
+ref name=weight/
+  /element
+/interleave
+  /element
+/zeroOrMore
+  /interleave
 /element
   /optional

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 2ab89f5..ff4f51b 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1236,6 +1236,16 @@ char *  
virDomainGetSchedulerType(virDomainPtr domain,

 #define VIR_DOMAIN_BLKIO_WEIGHT weight

+/**
+ * 

Re: [libvirt] [PATCHv4 3/4] blkiotune: add interface for blkiotune.device_weight

2011-11-14 Thread Hu Tao
On Mon, Nov 14, 2011 at 09:30:01PM -0700, Eric Blake wrote:
 From: Hu Tao hu...@cn.fujitsu.com
 
 This adds per-device weights to blkiotune.  Note that the
 cgroups implementation only supports weights per block device,
 and not per-file within the device; hence this option must be
 global to the domain definition rather than tied to individual
 devices/disk entries:
 
 domain ...
   blkiotune
 device
   path/path/to/block/path
   weight1000/weight
 /device
   /blkiotune
 ..
 
 This patch also adds a parameter --device-weights to virsh command
 blkiotune for setting/getting blkiotune.weight_device for any
 hypervisor that supports it.  All device entries under
 blkiotune are concatenated into a single string attribute under
 virDomain{Get,Set}BlkioParameters, named device_weight.
 
 Signed-off-by: Hu Tao hu...@cn.fujitsu.com
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
  docs/formatdomain.html.in  |   29 +-
  docs/schemas/domaincommon.rng  |   26 -
  include/libvirt/libvirt.h.in   |   10 ++
  src/conf/domain_conf.c |   99 
 +++-
  src/conf/domain_conf.h |   14 +++
  src/libvirt_private.syms   |1 +
  .../qemuxml2argv-blkiotune-device.xml  |   36 +++
  tools/virsh.c  |   43 +++--
  tools/virsh.pod|8 ++-
  9 files changed, 245 insertions(+), 21 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-blkiotune-device.xml
 
 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index cbad196..99c5add 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -505,6 +505,14 @@
...
lt;blkiotunegt;
  lt;weightgt;800lt;/weightgt;
 +lt;devicegt;
 +  lt;pathgt;/dev/sdalt;/pathgt;
 +  lt;weightgt;1000lt;/weightgt;
 +lt;/devicegt;
 +lt;devicegt;
 +  lt;pathgt;/dev/sdblt;/pathgt;
 +  lt;weightgt;500lt;/weightgt;
 +lt;/devicegt;
lt;/blkiotunegt;
...
  lt;/domaingt;
 @@ -514,10 +522,25 @@
dtcodeblkiotune/code/dt
dd The optional codeblkiotune/code element provides the ability
  to tune Blkio cgroup tunable parameters for the domain. If this is
 -omitted, it defaults to the OS provided defaults./dd
 +omitted, it defaults to the OS provided
 +defaults. span class=sinceSince 0.8.8/span/dd
dtcodeweight/code/dt
 -  dd The optional codeweight/code element is the I/O weight of the
 -guest. The value should be in range [100, 1000]./dd
 +  dd The optional codeweight/code element is the overall I/O
 +weight of the guest. The value should be in the range [100,
 +1000]./dd
 +  dtcodedevice/code/dt
 +  ddThe domain may have multiple codedevice/code elements
 +that further tune the weights for each host block device in
 +use by the domain.  Note that
 +multiple a href=#elementsDisksguest disks/a can share a
 +single host block device, if they are backed by files within
 +the same host file system, which is why this tuning parameter
 +is at the global domain level rather than associated with each
 +guest disk device.  Each codedevice/code element has two
 +mandatory sub-elements, codepath/code describing the
 +absolute path of the device, and codeweight/code giving
 +the relative weight of that device, in the range [100,
 +1000].  span class=sinceSince 0.9.8/span/dd
  /dl
 
 
 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
 index b6f858e..f776a51 100644
 --- a/docs/schemas/domaincommon.rng
 +++ b/docs/schemas/domaincommon.rng
 @@ -322,12 +322,26 @@
!-- The Blkio cgroup related tunables would go in the blkiotune --
optional
  element name=blkiotune
 -  !-- I/O weight the VM can use --
 -  optional
 -element name=weight
 -  ref name=weight/
 -/element
 -  /optional
 +  interleave
 +!-- I/O weight the VM can use --
 +optional
 +  element name=weight
 +ref name=weight/
 +  /element
 +/optional
 +zeroOrMore
 +  element name=device
 +interleave
 +  element name=path
 +ref name=absFilePath/
 +  /element
 +  element name=weight
 +ref name=weight/
 +  /element
 +/interleave
 +  /element
 +/zeroOrMore
 +  /interleave
  /element
/optional
 
 diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
 index 2ab89f5..ff4f51b 100644
 --- a/include/libvirt/libvirt.h.in
 +++