提交 b3880bbe 编写于 作者: M Martin Kletzander

lxc: improve error message for invalid blkiotune settings

Before:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: unable to parse blkio device
  'device_read_bytes_sec' '/dev/sda,-1'

After:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: invalid value '-1' for parameter
  'device_read_bytes_sec' of device '/dev/sda'

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131306Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 278bf0ac
...@@ -2158,7 +2158,7 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type, ...@@ -2158,7 +2158,7 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
/* A valid string must have even number of fields, hence an odd /* A valid string must have even number of fields, hence an odd
* number of commas. */ * number of commas. */
if (!(nsep & 1)) if (!(nsep & 1))
goto error; goto parse_error;
ndevices = (nsep + 1) / 2; ndevices = (nsep + 1) / 2;
...@@ -2173,7 +2173,7 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type, ...@@ -2173,7 +2173,7 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
/* device path */ /* device path */
p = strchr(p, ','); p = strchr(p, ',');
if (!p) if (!p)
goto error; goto parse_error;
if (VIR_STRNDUP(result[i].path, temp, p - temp) < 0) if (VIR_STRNDUP(result[i].path, temp, p - temp) < 0)
goto cleanup; goto cleanup;
...@@ -2183,21 +2183,23 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type, ...@@ -2183,21 +2183,23 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) { if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
if (virStrToLong_uip(temp, &p, 10, &result[i].weight) < 0) if (virStrToLong_uip(temp, &p, 10, &result[i].weight) < 0)
goto error; goto number_error;
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) { } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
if (virStrToLong_uip(temp, &p, 10, &result[i].riops) < 0) if (virStrToLong_uip(temp, &p, 10, &result[i].riops) < 0)
goto error; goto number_error;
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) { } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
if (virStrToLong_uip(temp, &p, 10, &result[i].wiops) < 0) if (virStrToLong_uip(temp, &p, 10, &result[i].wiops) < 0)
goto error; goto number_error;
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) { } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
if (virStrToLong_ullp(temp, &p, 10, &result[i].rbps) < 0) if (virStrToLong_ullp(temp, &p, 10, &result[i].rbps) < 0)
goto error; goto number_error;
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) { } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
if (virStrToLong_ullp(temp, &p, 10, &result[i].wbps) < 0) if (virStrToLong_ullp(temp, &p, 10, &result[i].wbps) < 0)
goto error; goto number_error;
} else { } else {
goto error; virReportError(VIR_ERR_INVALID_ARG,
_("unknown parameter '%s'"), type);
goto cleanup;
} }
i++; i++;
...@@ -2205,7 +2207,7 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type, ...@@ -2205,7 +2207,7 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
if (*p == '\0') if (*p == '\0')
break; break;
else if (*p != ',') else if (*p != ',')
goto error; goto parse_error;
temp = p + 1; temp = p + 1;
} }
...@@ -2217,10 +2219,17 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type, ...@@ -2217,10 +2219,17 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
return 0; return 0;
error: parse_error:
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("unable to parse blkio device '%s' '%s'"), _("unable to parse blkio device '%s' '%s'"),
type, blkioDeviceStr); type, blkioDeviceStr);
goto cleanup;
number_error:
virReportError(VIR_ERR_INVALID_ARG,
_("invalid value '%s' for parameter '%s' of device '%s'"),
temp, type, result[i].path);
cleanup: cleanup:
if (result) { if (result) {
virBlkioDeviceArrayClear(result, ndevices); virBlkioDeviceArrayClear(result, ndevices);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册