Re: [PATCH 4/6 v3] qemu: Implement blkio tunable XML configuration and parsing.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/07/2011 11:59 PM, Gui Jianfeng wrote:
> Implement blkio tunable XML configuration and parsing.
> 
> Reviewed-by: "Nikunj A. Dadhania" <nikunj@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Gui Jianfeng <guijianfeng@xxxxxxxxxxxxxx>
> ---
>  src/conf/domain_conf.c |   13 +++++++++++++
>  src/conf/domain_conf.h |    4 ++++
>  src/qemu/qemu_cgroup.c |   16 +++++++++++++++-
>  src/qemu/qemu_conf.c   |    3 ++-
>  4 files changed, 34 insertions(+), 2 deletions(-)
> 

> +    /* Extract blkio cgroup tunables */
> +    if (virXPathULong("string(./blkiotune/weight)", ctxt,
> +                     &def->blkio.weight) < 0)
> +        def->blkio.weight = 0;

No range validation here.  But since it fails down the road if it is
outside [100,1000], use of a ULong is overkill (wastes four bytes);
technically, a short would work, but we don't have helper functions for
short, so I'm swapping this to unsigned int.

>  
>      struct {
> +        unsigned long weight;
> +    } blkio;
> +
> +++ b/src/qemu/qemu_cgroup.c
> @@ -54,7 +54,6 @@ int qemuCgroupControllerActive(struct qemud_driver *driver,
>      return 0;
>  }
>  
> -
>  int qemuSetupDiskPathAllow(virDomainDiskDefPtr disk ATTRIBUTE_UNUSED,

Spurious whitespace change.

>                             const char *path,
>                             size_t depth ATTRIBUTE_UNUSED,
> @@ -270,6 +269,21 @@ int qemuSetupCgroup(struct qemud_driver *driver,
>          }
>      }
>  
> +    if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) {
> +        if (vm->def->blkio.weight != 0) {
> +            rc = virCgroupSetBlkioWeight(cgroup, vm->def->blkio.weight);

Oh, if I change types, that means that virCgroupSetBlkioWeight in patch
2/6 needs to handle unsigned int, not unsigned long.

ACK with this squashed in (part of it into patch 2):

diff --git c/src/conf/domain_conf.c w/src/conf/domain_conf.c
index 94369e2..c299c03 100644
--- c/src/conf/domain_conf.c
+++ w/src/conf/domain_conf.c
@@ -5150,7 +5150,7 @@ static virDomainDefPtr
virDomainDefParseXML(virCapsPtr caps,
         def->mem.hugepage_backed = 1;

     /* Extract blkio cgroup tunables */
-    if (virXPathULong("string(./blkiotune/weight)", ctxt,
+    if (virXPathUInt("string(./blkiotune/weight)", ctxt,
                      &def->blkio.weight) < 0)
         def->blkio.weight = 0;

@@ -7690,7 +7690,7 @@ char *virDomainDefFormat(virDomainDefPtr def,
     /* add blkiotune only if there are any */
     if (def->blkio.weight) {
         virBufferVSprintf(&buf, "  <blkiotune>\n");
-        virBufferVSprintf(&buf, "    <weight>%lu</weight>\n",
+        virBufferVSprintf(&buf, "    <weight>%u</weight>\n",
                           def->blkio.weight);
         virBufferVSprintf(&buf, "  </blkiotune>\n");
     }
diff --git c/src/conf/domain_conf.h w/src/conf/domain_conf.h
index 80d58a0..491301f 100644
--- c/src/conf/domain_conf.h
+++ w/src/conf/domain_conf.h
@@ -1029,7 +1029,7 @@ struct _virDomainDef {
     char *description;

     struct {
-        unsigned long weight;
+        unsigned int weight;
     } blkio;

     struct {
diff --git c/src/qemu/qemu_cgroup.c w/src/qemu/qemu_cgroup.c
index 0622c9e..8cd6ce9 100644
--- c/src/qemu/qemu_cgroup.c
+++ w/src/qemu/qemu_cgroup.c
@@ -54,6 +54,7 @@ int qemuCgroupControllerActive(struct qemud_driver
*driver,
     return 0;
 }

+
 int qemuSetupDiskPathAllow(virDomainDiskDefPtr disk ATTRIBUTE_UNUSED,
                            const char *path,
                            size_t depth ATTRIBUTE_UNUSED,
diff --git c/src/util/cgroup.c w/src/util/cgroup.c
index 9cdfc6e..de1fd8e 100644
--- c/src/util/cgroup.c
+++ w/src/util/cgroup.c
@@ -858,7 +858,7 @@ int virCgroupForDomain(virCgroupPtr driver
ATTRIBUTE_UNUSED,
  *
  * Returns: 0 on success
  */
-int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned long weight)
+int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight)
 {
     if (weight > 1000 || weight < 100)
         return -EINVAL;
@@ -877,9 +877,9 @@ int virCgroupSetBlkioWeight(virCgroupPtr group,
unsigned long weight)
  *
  * Returns: 0 on success
  */
-int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned long *weight)
+int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight)
 {
-    long long unsigned int tmp;
+    unsigned long long tmp;
     int ret;
     ret = virCgroupGetValueU64(group,
                                VIR_CGROUP_CONTROLLER_BLKIO,
diff --git c/src/util/cgroup.h w/src/util/cgroup.h
index f1a47dc..f1bdd0f 100644
--- c/src/util/cgroup.h
+++ w/src/util/cgroup.h
@@ -1,6 +1,7 @@
 /*
  * cgroup.h: Interface to tools for managing cgroups
  *
+ * Copyright (C) 2011 Red Hat, Inc.
  * Copyright IBM Corp. 2008
  *
  * See COPYING.LIB for the License of this software
@@ -41,8 +42,8 @@ int virCgroupForDomain(virCgroupPtr driver,

 int virCgroupAddTask(virCgroupPtr group, pid_t pid);

-int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned long weight);
-int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned long *weight);
+int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
+int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);

 int virCgroupSetMemory(virCgroupPtr group, unsigned long long kb);
 int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb);

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]