|
|
9119d9 |
From 0ccf240a71f05f4eed9335d960a0026e607747ea Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <0ccf240a71f05f4eed9335d960a0026e607747ea@dist-git>
|
|
|
9119d9 |
From: Martin Kletzander <mkletzan@redhat.com>
|
|
|
9119d9 |
Date: Tue, 4 Nov 2014 11:00:50 +0100
|
|
|
9119d9 |
Subject: [PATCH] lxc: 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 b3880bbe97bd0881d7860cff25c1409e74f2e9ab)
|
|
|
9119d9 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/lxc/lxc_driver.c | 29 +++++++++++++++++++----------
|
|
|
9119d9 |
1 file changed, 19 insertions(+), 10 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
|
|
|
9119d9 |
index bdfad9e..cd8f828 100644
|
|
|
9119d9 |
--- a/src/lxc/lxc_driver.c
|
|
|
9119d9 |
+++ b/src/lxc/lxc_driver.c
|
|
|
9119d9 |
@@ -2158,7 +2158,7 @@ lxcDomainParseBlkioDeviceStr(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 |
@@ -2173,7 +2173,7 @@ lxcDomainParseBlkioDeviceStr(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 |
@@ -2183,21 +2183,23 @@ lxcDomainParseBlkioDeviceStr(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 |
@@ -2205,7 +2207,7 @@ lxcDomainParseBlkioDeviceStr(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 |
@@ -2217,10 +2219,17 @@ lxcDomainParseBlkioDeviceStr(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 |
|