[PATCH v4 1/6] qemu: Add defines for the news throttle options and modify the structure _virDomainBlockIoTuneInfo.

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

 



Add defines for the news options total_bytes_sec_max, write_bytes_sec_max, read_bytes_sec_max
total_iops_sec_max, write_iops_sec_max, read_iops_sec_max, size_iops_sec.

Modify the structure _virDomainBlockIoTuneInfo to support these options.

Change the initialization of the variable expectedInfo in qemumonitorjsontest.c
to avoid compiling problem.

Allow libvirt to save the configuration.

Signed-off-by: Matthias Gatto <matthias.gatto@xxxxxxxxxxxx>
---
 include/libvirt/libvirt.h.in |  54 +++++++++++++++++++++
 src/conf/domain_conf.c       | 110 ++++++++++++++++++++++++++++++++++++++++++-
 src/conf/domain_conf.h       |   7 +++
 tests/qemumonitorjsontest.c  |   2 +-
 4 files changed, 171 insertions(+), 2 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 5217ab3..4eab987 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2800,6 +2800,60 @@ int virDomainBlockCommit(virDomainPtr dom, const char *disk, const char *base,
  */
 #define VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC "write_iops_sec"
 
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum total
+ * bytes per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX "total_bytes_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum read
+ * bytes per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX "read_bytes_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum write
+ * bytes per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX "write_bytes_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum
+ * I/O operations per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX "total_iops_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX:
+ *
+ * Macro for the BlockIoTune tunable weight: it represents the maximum read
+ * I/O operations per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX "read_iops_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX:
+ * Macro for the BlockIoTune tunable weight: it represents the maximum write
+ * I/O operations per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX "write_iops_sec_max"
+
+/**
+ * VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC:
+ * Macro for the BlockIoTune tunable weight: it represents the size
+ * I/O operations per second permitted through a block device, as a ullong.
+ */
+#define VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC "size_iops_sec"
+
 int
 virDomainSetBlockIoTune(virDomainPtr dom,
                         const char *disk,
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b114737..e629e22 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5787,6 +5787,49 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
                     def->blkdeviotune.write_iops_sec = 0;
                 }
 
+                if (virXPathULongLong("string(./iotune/total_bytes_sec_max)",
+                                      ctxt,
+                                      &def->blkdeviotune.total_bytes_sec_max) < 0) {
+                    def->blkdeviotune.total_bytes_sec_max = 0;
+                }
+
+                if (virXPathULongLong("string(./iotune/read_bytes_sec_max)",
+                                      ctxt,
+                                      &def->blkdeviotune.read_bytes_sec_max) < 0) {
+                    def->blkdeviotune.read_bytes_sec_max = 0;
+                }
+
+                if (virXPathULongLong("string(./iotune/write_bytes_sec_max)",
+                                      ctxt,
+                                      &def->blkdeviotune.write_bytes_sec_max) < 0) {
+                    def->blkdeviotune.write_bytes_sec_max = 0;
+                }
+
+                if (virXPathULongLong("string(./iotune/total_iops_sec_max)",
+                                      ctxt,
+                                      &def->blkdeviotune.total_iops_sec_max) < 0) {
+                    def->blkdeviotune.total_iops_sec_max = 0;
+                }
+
+                if (virXPathULongLong("string(./iotune/read_iops_sec_max)",
+                                      ctxt,
+                                      &def->blkdeviotune.read_iops_sec_max) < 0) {
+                    def->blkdeviotune.read_iops_sec_max = 0;
+                }
+
+                if (virXPathULongLong("string(./iotune/write_iops_sec_max)",
+                                      ctxt,
+                                      &def->blkdeviotune.write_iops_sec_max) < 0) {
+                    def->blkdeviotune.write_iops_sec_max = 0;
+                }
+
+                if (virXPathULongLong("string(./iotune/size_iops_sec)",
+                                      ctxt,
+                                      &def->blkdeviotune.size_iops_sec) < 0) {
+                    def->blkdeviotune.size_iops_sec = 0;
+                }
+
+
                 if ((def->blkdeviotune.total_bytes_sec &&
                      def->blkdeviotune.read_bytes_sec) ||
                     (def->blkdeviotune.total_bytes_sec &&
@@ -5806,6 +5849,27 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
                                      "cannot be set at the same time"));
                     goto error;
                 }
+
+                if ((def->blkdeviotune.total_bytes_sec_max &&
+                     def->blkdeviotune.read_bytes_sec_max) ||
+                    (def->blkdeviotune.total_bytes_sec_max &&
+                     def->blkdeviotune.write_bytes_sec_max)) {
+                    virReportError(VIR_ERR_XML_ERROR, "%s",
+                                   _("total and read/write bytes_sec_max "
+                                     "cannot be set at the same time"));
+                    goto error;
+                }
+
+                if ((def->blkdeviotune.total_iops_sec_max &&
+                     def->blkdeviotune.read_iops_sec_max) ||
+                    (def->blkdeviotune.total_iops_sec_max &&
+                     def->blkdeviotune.write_iops_sec_max)) {
+                    virReportError(VIR_ERR_XML_ERROR, "%s",
+                                   _("total and read/write iops_sec_max "
+                                     "cannot be set at the same time"));
+                    goto error;
+                }
+
             } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
                 def->src->readonly = true;
             } else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) {
@@ -16089,7 +16153,14 @@ virDomainDiskDefFormat(virBufferPtr buf,
         def->blkdeviotune.write_bytes_sec ||
         def->blkdeviotune.total_iops_sec ||
         def->blkdeviotune.read_iops_sec ||
-        def->blkdeviotune.write_iops_sec) {
+        def->blkdeviotune.write_iops_sec ||
+        def->blkdeviotune.total_bytes_sec_max ||
+        def->blkdeviotune.read_bytes_sec_max ||
+        def->blkdeviotune.write_bytes_sec_max ||
+        def->blkdeviotune.total_iops_sec_max ||
+        def->blkdeviotune.read_iops_sec_max ||
+        def->blkdeviotune.write_iops_sec_max ||
+        def->blkdeviotune.size_iops_sec) {
         virBufferAddLit(buf, "<iotune>\n");
         virBufferAdjustIndent(buf, 2);
         if (def->blkdeviotune.total_bytes_sec) {
@@ -16122,6 +16193,43 @@ virDomainDiskDefFormat(virBufferPtr buf,
             virBufferAsprintf(buf, "<write_iops_sec>%llu</write_iops_sec>\n",
                               def->blkdeviotune.write_iops_sec);
         }
+
+        if (def->blkdeviotune.total_bytes_sec_max) {
+            virBufferAsprintf(buf, "<total_bytes_sec_max>%llu</total_bytes_sec_max>\n",
+                              def->blkdeviotune.total_bytes_sec_max);
+        }
+
+        if (def->blkdeviotune.read_bytes_sec_max) {
+            virBufferAsprintf(buf, "<read_bytes_sec_max>%llu</read_bytes_sec_max>\n",
+                              def->blkdeviotune.read_bytes_sec_max);
+
+        }
+
+        if (def->blkdeviotune.write_bytes_sec_max) {
+            virBufferAsprintf(buf, "<write_bytes_sec_max>%llu</write_bytes_sec_max>\n",
+                              def->blkdeviotune.write_bytes_sec_max);
+        }
+
+        if (def->blkdeviotune.total_iops_sec_max) {
+            virBufferAsprintf(buf, "<total_iops_sec_max>%llu</total_iops_sec_max>\n",
+                              def->blkdeviotune.total_iops_sec_max);
+        }
+
+        if (def->blkdeviotune.read_iops_sec_max) {
+            virBufferAsprintf(buf, "<read_iops_sec_max>%llu</read_iops_sec_max>\n",
+                              def->blkdeviotune.read_iops_sec_max);
+        }
+
+        if (def->blkdeviotune.write_iops_sec_max) {
+            virBufferAsprintf(buf, "<write_iops_sec_max>%llu</write_iops_sec_max>\n",
+                              def->blkdeviotune.write_iops_sec_max);
+        }
+
+        if (def->blkdeviotune.size_iops_sec) {
+            virBufferAsprintf(buf, "<size_iops_sec>%llu</size_iops_sec>\n",
+                              def->blkdeviotune.size_iops_sec);
+        }
+
         virBufferAdjustIndent(buf, -2);
         virBufferAddLit(buf, "</iotune>\n");
     }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ea201b3..d2e7c6b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -607,6 +607,13 @@ struct _virDomainBlockIoTuneInfo {
     unsigned long long total_iops_sec;
     unsigned long long read_iops_sec;
     unsigned long long write_iops_sec;
+    unsigned long long total_bytes_sec_max;
+    unsigned long long read_bytes_sec_max;
+    unsigned long long write_bytes_sec_max;
+    unsigned long long total_iops_sec_max;
+    unsigned long long read_iops_sec_max;
+    unsigned long long write_iops_sec_max;
+    unsigned long long size_iops_sec;
 };
 typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;
 
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index b8177c0..ad33c10 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1835,7 +1835,7 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *data)
     if (!test)
         return -1;
 
-    expectedInfo = (virDomainBlockIoTuneInfo) {1, 2, 3, 4, 5, 6};
+    expectedInfo = (virDomainBlockIoTuneInfo) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
 
     if (qemuMonitorTestAddItem(test, "query-block", queryBlockReply) < 0 ||
         qemuMonitorTestAddItemParams(test, "block_set_io_throttle",
-- 
1.8.3.1

--
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]