render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
9119d9
From d53999b3390985bb623c568206f50c85a63cdc25 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <d53999b3390985bb623c568206f50c85a63cdc25@dist-git>
9119d9
From: Martin Kletzander <mkletzan@redhat.com>
9119d9
Date: Tue, 4 Nov 2014 11:00:51 +0100
9119d9
Subject: [PATCH] qemu: improve error message for invalid blkiotune settings
9119d9
9119d9
Before:
9119d9
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
9119d9
  error: Unable to change blkio parameters
9119d9
  error: invalid argument: unable to parse blkio device
9119d9
  'device_read_bytes_sec' '/dev/sda,-1'
9119d9
9119d9
After:
9119d9
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
9119d9
  error: Unable to change blkio parameters
9119d9
  error: invalid argument: invalid value '-1' for parameter
9119d9
  'device_read_bytes_sec' of device '/dev/sda'
9119d9
9119d9
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131306
9119d9
9119d9
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9119d9
(cherry picked from commit 278bf0acbfe9d468dceafde580ecce97ba9cc4e5)
9119d9
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_driver.c | 29 +++++++++++++++++++----------
9119d9
 1 file changed, 19 insertions(+), 10 deletions(-)
9119d9
9119d9
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
9119d9
index 3812615..0f68abc 100644
9119d9
--- a/src/qemu/qemu_driver.c
9119d9
+++ b/src/qemu/qemu_driver.c
9119d9
@@ -7997,7 +7997,7 @@ qemuDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
9119d9
     /* A valid string must have even number of fields, hence an odd
9119d9
      * number of commas.  */
9119d9
     if (!(nsep & 1))
9119d9
-        goto error;
9119d9
+        goto parse_error;
9119d9
 
9119d9
     ndevices = (nsep + 1) / 2;
9119d9
 
9119d9
@@ -8012,7 +8012,7 @@ qemuDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
9119d9
         /* device path */
9119d9
         p = strchr(p, ',');
9119d9
         if (!p)
9119d9
-            goto error;
9119d9
+            goto parse_error;
9119d9
 
9119d9
         if (VIR_STRNDUP(result[i].path, temp, p - temp) < 0)
9119d9
             goto cleanup;
9119d9
@@ -8022,21 +8022,23 @@ qemuDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
9119d9
 
9119d9
         if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
9119d9
             if (virStrToLong_uip(temp, &p, 10, &result[i].weight) < 0)
9119d9
-                goto error;
9119d9
+                goto number_error;
9119d9
         } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
9119d9
             if (virStrToLong_uip(temp, &p, 10, &result[i].riops) < 0)
9119d9
-                goto error;
9119d9
+                goto number_error;
9119d9
         } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
9119d9
             if (virStrToLong_uip(temp, &p, 10, &result[i].wiops) < 0)
9119d9
-                goto error;
9119d9
+                goto number_error;
9119d9
         } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
9119d9
             if (virStrToLong_ullp(temp, &p, 10, &result[i].rbps) < 0)
9119d9
-                goto error;
9119d9
+                goto number_error;
9119d9
         } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
9119d9
             if (virStrToLong_ullp(temp, &p, 10, &result[i].wbps) < 0)
9119d9
-                goto error;
9119d9
+                goto number_error;
9119d9
         } else {
9119d9
-            goto error;
9119d9
+            virReportError(VIR_ERR_INVALID_ARG,
9119d9
+                           _("unknown parameter '%s'"), type);
9119d9
+            goto cleanup;
9119d9
         }
9119d9
 
9119d9
         i++;
9119d9
@@ -8044,7 +8046,7 @@ qemuDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
9119d9
         if (*p == '\0')
9119d9
             break;
9119d9
         else if (*p != ',')
9119d9
-            goto error;
9119d9
+            goto parse_error;
9119d9
         temp = p + 1;
9119d9
     }
9119d9
 
9119d9
@@ -8056,10 +8058,17 @@ qemuDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
9119d9
 
9119d9
     return 0;
9119d9
 
9119d9
- error:
9119d9
+ parse_error:
9119d9
     virReportError(VIR_ERR_INVALID_ARG,
9119d9
                    _("unable to parse blkio device '%s' '%s'"),
9119d9
                    type, blkioDeviceStr);
9119d9
+    goto cleanup;
9119d9
+
9119d9
+ number_error:
9119d9
+    virReportError(VIR_ERR_INVALID_ARG,
9119d9
+                   _("invalid value '%s' for parameter '%s' of device '%s'"),
9119d9
+                   temp, type, result[i].path);
9119d9
+
9119d9
  cleanup:
9119d9
     if (result) {
9119d9
         virBlkioDeviceArrayClear(result, ndevices);
9119d9
-- 
9119d9
2.1.3
9119d9