This patch introduces new xml elements under ,
we use these new elements to setup the throttle blkio
cgroup for domain. The new blkiotune node looks like this:
/path/to/block
1000
1
1
100
100
Signed-off-by: Guan Qiang
Signed-off-by: Gao feng
---
docs/schemas/domaincommon.rng | 28 --
src/conf/domain_conf.c| 85 +--
src/conf/domain_conf.h| 4 ++
3 files changed, 103 insertions(+), 14 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 38c6801..bc8ed5d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -621,9 +621,31 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 26242b6..c4d51b4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -899,15 +899,19 @@ virBlkioDeviceArrayClear(virBlkioDevicePtr devices,
*
* /fully/qualified/device/path
* weight
+ * bps
+ * bps
+ * iops
+ * iops
*
*
- * and fills a virBlkioDeviceTune struct.
+ * and fills a virBlkioDevicePtr struct.
*/
static int
virDomainBlkioDeviceParseXML(xmlNodePtr root,
virBlkioDevicePtr dev)
{
-char *c;
+char *c = NULL;
xmlNodePtr node;
node = root->children;
@@ -921,9 +925,43 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("could not parse weight %s"),
c);
-VIR_FREE(c);
-VIR_FREE(dev->path);
-return -1;
+goto error;
+}
+VIR_FREE(c);
+} else if (xmlStrEqual(node->name, BAD_CAST "read_bytes_sec")) {
+c = (char *)xmlNodeGetContent(node);
+if (virStrToLong_ull(c, NULL, 10, &dev->rbps) < 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("could not parse read bytes sec %s"),
+ c);
+goto error;
+}
+VIR_FREE(c);
+} else if (xmlStrEqual(node->name, BAD_CAST "write_bytes_sec")) {
+c = (char *)xmlNodeGetContent(node);
+if (virStrToLong_ull(c, NULL, 10, &dev->wbps) < 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("could not parse write bytes sec %s"),
+ c);
+goto error;
+}
+VIR_FREE(c);
+} else if (xmlStrEqual(node->name, BAD_CAST "read_iops_sec")) {
+c = (char *)xmlNodeGetContent(node);
+if (virStrToLong_ui(c, NULL, 10, &dev->riops) < 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("could not parse read iops sec %s"),
+ c);
+goto error;
+}
+VIR_FREE(c);
+} else if (xmlStrEqual(node->name, BAD_CAST "write_iops_sec")) {
+c = (char *)xmlNodeGetContent(node);
+if (virStrToLong_ui(c, NULL, 10, &dev->wiops) < 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("could not parse write iops sec %s"),
+ c);
+goto error;
}
VIR_FREE(c);
}
@@ -937,6 +975,11 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root,
}
return 0;
+
+error:
+VIR_FREE(c);
+VIR_FREE(dev->path);
+return -1;
}
@@ -11105,7 +11148,7 @@ virDomainDefParseXML(xmlDocPtr xml,
if (STREQ(def->blkio.devices[j].path,
def->blkio.devices[i].path)) {
virReportError(VIR_ERR_XML_ERROR,
- _("duplicate device weight path '%s'"),
+ _("duplicate blkio device path '%s'"),
def->blkio.devices[i].path);
goto error;
}
@@ -16614,7 +16657,11 @@ virDomainDefFormatInternal(virDomainDefPtr def,
blkio = true;
} else {
for (n = 0; n