[PATCH v3 5/7] qemu: Add bps_max and friends "text" support

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

 



Detect if the the qemu binary currently in use suport the bps_max option and thy firends,
If yes add it to the command, if not, just ignore the options.

Signed-off-by: Matthias Gatto <matthias.gatto@xxxxxxxxxxxx>
---
 src/qemu/qemu_monitor_text.c | 76 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 69 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 2858247..ffc67d7 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -2994,13 +2994,27 @@ int qemuMonitorTextSetBlockIoThrottle(qemuMonitorPtr mon,
     const char *cmd_name = NULL;
 
     /* For the not specified fields, 0 by default */
-    (void)supportMaxOptions;
     cmd_name = "block_set_io_throttle";
-    if (virAsprintf(&cmd, "%s %s %llu %llu %llu %llu %llu %llu", cmd_name,
-                    device, info->total_bytes_sec, info->read_bytes_sec,
-                    info->write_bytes_sec, info->total_iops_sec,
-                    info->read_iops_sec, info->write_iops_sec) < 0)
-        goto cleanup;
+    if (supportMaxOptions)
+    {
+        if (virAsprintf(&cmd, "%s %s %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu", cmd_name,
+                        device, info->total_bytes_sec, info->read_bytes_sec,
+                        info->write_bytes_sec, info->total_iops_sec,
+                        info->read_iops_sec, info->write_iops_sec,
+                        info->total_bytes_sec_max, info->read_bytes_sec_max,
+                        info->write_bytes_sec_max, info->total_iops_sec_max,
+                        info->read_iops_sec_max, info->write_iops_sec_max,
+                        info->size_iops_sec) < 0)
+            goto cleanup;
+    }
+    else
+    {
+        if (virAsprintf(&cmd, "%s %s %llu %llu %llu %llu %llu %llu", cmd_name,
+                        device, info->total_bytes_sec, info->read_bytes_sec,
+                        info->write_bytes_sec, info->total_iops_sec,
+                        info->read_iops_sec, info->write_iops_sec) < 0)
+            goto cleanup;
+    }
 
     if (qemuMonitorHMPCommand(mon, cmd, &result) < 0)
         goto cleanup;
@@ -3028,6 +3042,7 @@ qemuMonitorTextParseBlockIoThrottle(const char *result,
     int ret = -1;
     const char *p, *eol;
     int devnamelen = strlen(device);
+    bool checkBlockInfo;
 
     (void)supportMaxOptions;
     p = result;
@@ -3043,31 +3058,78 @@ qemuMonitorTextParseBlockIoThrottle(const char *result,
             p += devnamelen + 2; /* Skip to first label. */
 
             while (*p) {
+                checkBlockInfo = false;
                 if (STRPREFIX(p, "bps=")) {
                     p += strlen("bps=");
+                    checkBlockInfo = true;
                     if (virStrToLong_ull(p, &dummy, 10, &reply->total_bytes_sec) == -1)
                         VIR_DEBUG("error reading total_bytes_sec: %s", p);
                 } else if (STRPREFIX(p, "bps_rd=")) {
+                    checkBlockInfo = true;
                     p += strlen("bps_rd=");
                     if (virStrToLong_ull(p, &dummy, 10, &reply->read_bytes_sec)  == -1)
                         VIR_DEBUG("error reading read_bytes_sec: %s", p);
                 } else if (STRPREFIX(p, "bps_wr=")) {
+                    checkBlockInfo = true;
                     p += strlen("bps_wr=");
                     if (virStrToLong_ull(p, &dummy, 10, &reply->write_bytes_sec) == -1)
                         VIR_DEBUG("error reading write_bytes_sec: %s", p);
                 } else if (STRPREFIX(p, "iops=")) {
+                    checkBlockInfo = true;
                     p += strlen("iops=");
                     if (virStrToLong_ull(p, &dummy, 10, &reply->total_iops_sec) == -1)
                         VIR_DEBUG("error reading total_iops_sec: %s", p);
                 } else if (STRPREFIX(p, "iops_rd=")) {
+                    checkBlockInfo = true;
                     p += strlen("iops_rd=");
                     if (virStrToLong_ull(p, &dummy, 10, &reply->read_iops_sec) == -1)
                         VIR_DEBUG("error reading read_iops_sec: %s", p);
                 } else if (STRPREFIX(p, "iops_wr=")) {
+                    checkBlockInfo = true;
                     p += strlen("iops_wr=");
                     if (virStrToLong_ull(p, &dummy, 10, &reply->write_iops_sec) == -1)
                         VIR_DEBUG("error reading write_iops_sec: %s", p);
-                } else {
+                }
+                if (supportMaxOptions)
+                {
+                    if (STRPREFIX(p, "bps_max=")) {
+                        checkBlockInfo = true;
+                        p += strlen("bps_max=");
+                        if (virStrToLong_ull(p, &dummy, 10, &reply->total_bytes_sec_max)  == -1)
+                            VIR_DEBUG("error reading total_bytes_sec_max: %s", p);
+                    } else if (STRPREFIX(p, "bps_wr_max=")) {
+                        checkBlockInfo = true;
+                        p += strlen("bps_wr_max=");
+                        if (virStrToLong_ull(p, &dummy, 10, &reply->write_bytes_sec_max) == -1)
+                            VIR_DEBUG("error reading write_bytes_sec_max: %s", p);
+                    } else if (STRPREFIX(p, "bps_rd_max=")) {
+                        checkBlockInfo = true;
+                        p += strlen("bps_rd_max=");
+                        if (virStrToLong_ull(p, &dummy, 10, &reply->read_bytes_sec_max)  == -1)
+                            VIR_DEBUG("error reading read_bytes_sec_max: %s", p);
+                    } else if (STRPREFIX(p, "iops_max=")) {
+                        checkBlockInfo = true;
+                        p += strlen("iops_max=");
+                        if (virStrToLong_ull(p, &dummy, 10, &reply->total_iops_sec_max) == -1)
+                            VIR_DEBUG("error reading total_iops_sec_max: %s", p);
+                    } else if (STRPREFIX(p, "iops_rd_max=")) {
+                        checkBlockInfo = true;
+                        p += strlen("iops_rd_max=");
+                        if (virStrToLong_ull(p, &dummy, 10, &reply->read_iops_sec_max) == -1)
+                            VIR_DEBUG("error reading read_iops_sec_max: %s", p);
+                    } else if (STRPREFIX(p, "iops_wr_max=")) {
+                        checkBlockInfo = true;
+                        p += strlen("iops_wr_max=");
+                        if (virStrToLong_ull(p, &dummy, 10, &reply->write_iops_sec_max) == -1)
+                            VIR_DEBUG("error reading write_iops_sec_max: %s", p);
+                    } else if (STRPREFIX(p, "size_iops=")) {
+                        checkBlockInfo = true;
+                        p += strlen("size_iops=");
+                        if (virStrToLong_ull(p, &dummy, 10, &reply->size_iops_sec) == -1)
+                            VIR_DEBUG("error reading size_iops_sec: %s", p);
+                    }
+                }
+                if (!checkBlockInfo) {
                     VIR_DEBUG(" unknown block info %s", p);
                 }
 
-- 
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]