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

qemu: Add better message for some invalid block I/O settings

For example when both total_bytes_sec and total_bytes_sec_max are set,
but the former gets cleaned due to new call setting, let's say,
read_bytes_sec, we end up with this weird message for the command:

 $ virsh blkdeviotune fedora vda --read-bytes-sec 3000
 error: Unable to change block I/O throttle
 error: unsupported configuration: value 'total_bytes_sec_max' cannot be set if 'total_bytes_sec' is not set

So let's make it more descriptive.  This is how it looks after the change:

 $ virsh blkdeviotune fedora vda --read-bytes-sec 3000
 error: Unable to change block I/O throttle
 error: unsupported configuration: cannot reset 'total_bytes_sec' when 'total_bytes_sec_max' is set

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1344897Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 862bea96
......@@ -17480,23 +17480,39 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
qemuDomainSetBlockIoTuneDefaults(&info, &disk->blkdeviotune,
set_fields);
#define CHECK_MAX(val) \
#define CHECK_MAX(val, _bool) \
do { \
if (info.val##_max && !info.val) { \
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
_("value '%s' cannot be set if " \
"'%s' is not set"), \
#val "_max", #val); \
goto endjob; \
if (info.val##_max) { \
if (!info.val) { \
if (QEMU_BLOCK_IOTUNE_SET_##_bool) { \
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
_("cannot reset '%s' when " \
"'%s' is set"), \
#val, #val "_max"); \
} else { \
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
_("value '%s' cannot be set if " \
"'%s' is not set"), \
#val "_max", #val); \
} \
goto endjob; \
} \
if (info.val##_max < info.val) { \
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
_("value '%s' cannot be " \
"smaller than '%s'"), \
#val "_max", #val); \
goto endjob; \
} \
} \
} while (false);
CHECK_MAX(total_bytes_sec);
CHECK_MAX(read_bytes_sec);
CHECK_MAX(write_bytes_sec);
CHECK_MAX(total_iops_sec);
CHECK_MAX(read_iops_sec);
CHECK_MAX(write_iops_sec);
} while (false)
CHECK_MAX(total_bytes_sec, BYTES);
CHECK_MAX(read_bytes_sec, BYTES);
CHECK_MAX(write_bytes_sec, BYTES);
CHECK_MAX(total_iops_sec, IOPS);
CHECK_MAX(read_iops_sec, IOPS);
CHECK_MAX(write_iops_sec, IOPS);
#undef CHECK_MAX
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册