Re: [libvirt] [PATCHv4 3/4] blkiotune: add interface for blkiotune.device_weight
On Mon, Nov 14, 2011 at 09:30:01PM -0700, Eric Blake wrote: > From: Hu Tao > > This adds per-device weights to . 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 > / entries: > > > > > /path/to/block > 1000 > > > .. > > 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 entries under > 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
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, " \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, "\n"); > virBufferEscapeString(buf, " %s\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
Re: [libvirt] [PATCHv4 3/4] blkiotune: add interface for blkiotune.device_weight
On Mon, Nov 14, 2011 at 09:30:01PM -0700, Eric Blake wrote: > From: Hu Tao > > This adds per-device weights to . 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 > / entries: > > > > > /path/to/block > 1000 > > > .. > > 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 entries under > are concatenated into a single string attribute under > virDomain{Get,Set}BlkioParameters, named "device_weight". > > Signed-off-by: Hu Tao > Signed-off-by: Eric Blake > --- > 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 @@ >... >> >... > > @@ -514,10 +522,25 @@ >blkiotune > The optional blkiotune element provides the ability > to tune Blkio cgroup tunable parameters for the domain. If this is > -omitted, it defaults to the OS provided defaults. > +omitted, it defaults to the OS provided > +defaults. Since 0.8.8 >weight > - The optional weight element is the I/O weight of the > -guest. The value should be in range [100, 1000]. > + The optional weight element is the overall I/O > +weight of the guest. The value should be in the range [100, > +1000]. > + device > + The domain may have multiple device elements > +that further tune the weights for each host block device in > +use by the domain. Note that > +multiple guest disks 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 device element has two > +mandatory sub-elements, path describing the > +absolute path of the device, and weight giving > +the relative weight of that device, in the range [100, > +1000]. Since 0.9.8 > > > > 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 @@ > > > > - > - > - > - > - > - > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > > > > 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" > > +/** > + * VIR_DOMAIN_BLKIO_DEVICE_WEIGHT: > + * > + * Macro for the blkio tunable weight_device: it represents the > + * per-device weight, as a string. The string is parsed as a > + * series of /path/to/device,weight elements, separated by ','. > + */ > + > +#define VIR_DOMAIN_BLKIO_DEVICE_WEIGHT "device_weight" > + > /* Set Blkio tunables for the domain*/ > int virDomainSetBlkioParameters(virDomainPtr domain, > virTypedParameterPtr params, > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index 58f4d0f..b35c83c 100644 >800 > +> + > +/dev/sda > +1000 > +> + >/dev/sdb > +500 > +
[libvirt] [PATCHv4 3/4] blkiotune: add interface for blkiotune.device_weight
From: Hu Tao This adds per-device weights to . 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 / entries: /path/to/block 1000 .. 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 entries under are concatenated into a single string attribute under virDomain{Get,Set}BlkioParameters, named "device_weight". Signed-off-by: Hu Tao Signed-off-by: Eric Blake --- 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 @@ ...... @@ -514,10 +522,25 @@ blkiotune The optional blkiotune element provides the ability to tune Blkio cgroup tunable parameters for the domain. If this is -omitted, it defaults to the OS provided defaults. +omitted, it defaults to the OS provided +defaults. Since 0.8.8 weight - The optional weight element is the I/O weight of the -guest. The value should be in range [100, 1000]. + The optional weight element is the overall I/O +weight of the guest. The value should be in the range [100, +1000]. + device + The domain may have multiple device elements +that further tune the weights for each host block device in +use by the domain. Note that +multiple guest disks 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 device element has two +mandatory sub-elements, path describing the +absolute path of the device, and weight giving +the relative weight of that device, in the range [100, +1000]. Since 0.9.8 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 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + 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" +/** + * VIR_DOMAIN_BLKIO_DEVICE_WEIGHT: + * + * Macro for the blkio tunable weight_device: it represents the + * per-device weight, as a string. The string is parsed as a + * series of /path/to/device,weight elements, separated by ','. + */ + +#define VIR_DOMAIN_BLKIO_DEVICE_WEIGHT "device_weight" + /* Set Blkio tunables for the domain*/ int virDomainSetBlkioParameters(virDomainPtr domain, virTypedParameterPtr params, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 58f4d0f..b35c83c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -603,6 +603,67 @@ VIR_ENUM_IMPL(virDomainStartupPolicy, VIR_DOMAIN_STARTUP_POLICY_LAST, #define VIR_DOMAIN_XML_WRITE_FLAGS VIR_DOMAIN_XML_SECURE #define VIR_DOMAIN_XML_READ_FLAGS VIR_DOMAIN_XML_INACTIVE + +void +virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights, + 800 ++ +/dev/sda +1000 ++ /dev/sdb +500 +