提交 d24835f2 编写于 作者: J John Ferlan

qemu: Create a macro to handle setting bytes/iops iotune values

Create a macros to hide all the comparisons for each of the fields.

Add a 'continue;' for a compiler hint that we only need to find one
this should be similar enough to the if - elseif - elseif logic.
上级 1b93def2
...@@ -17377,6 +17377,18 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -17377,6 +17377,18 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
VIR_DOMAIN_TUNABLE_BLKDEV_DISK, path) < 0) VIR_DOMAIN_TUNABLE_BLKDEV_DISK, path) < 0)
goto endjob; goto endjob;
#define SET_IOTUNE_FIELD(FIELD, BOOL, CONST) \
if (STREQ(param->field, VIR_DOMAIN_BLOCK_IOTUNE_##CONST)) { \
info.FIELD = param->value.ul; \
BOOL = true; \
if (virTypedParamsAddULLong(&eventParams, &eventNparams, \
&eventMaxparams, \
VIR_DOMAIN_TUNABLE_BLKDEV_##CONST, \
param->value.ul) < 0) \
goto endjob; \
continue; \
}
for (i = 0; i < nparams; i++) { for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = &params[i]; virTypedParameterPtr param = &params[i];
...@@ -17387,125 +17399,30 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -17387,125 +17399,30 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto endjob; goto endjob;
} }
if (STREQ(param->field, VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC)) { SET_IOTUNE_FIELD(total_bytes_sec, set_bytes, TOTAL_BYTES_SEC);
info.total_bytes_sec = param->value.ul; SET_IOTUNE_FIELD(read_bytes_sec, set_bytes, READ_BYTES_SEC);
set_bytes = true; SET_IOTUNE_FIELD(write_bytes_sec, set_bytes, WRITE_BYTES_SEC);
if (virTypedParamsAddULLong(&eventParams, &eventNparams, SET_IOTUNE_FIELD(total_iops_sec, set_iops, TOTAL_IOPS_SEC);
&eventMaxparams, SET_IOTUNE_FIELD(read_iops_sec, set_iops, READ_IOPS_SEC);
VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC, SET_IOTUNE_FIELD(write_iops_sec, set_iops, WRITE_IOPS_SEC);
param->value.ul) < 0)
goto endjob; SET_IOTUNE_FIELD(total_bytes_sec_max, set_bytes_max,
} else if (STREQ(param->field, TOTAL_BYTES_SEC_MAX);
VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC)) { SET_IOTUNE_FIELD(read_bytes_sec_max, set_bytes_max,
info.read_bytes_sec = param->value.ul; READ_BYTES_SEC_MAX);
set_bytes = true; SET_IOTUNE_FIELD(write_bytes_sec_max, set_bytes_max,
if (virTypedParamsAddULLong(&eventParams, &eventNparams, WRITE_BYTES_SEC_MAX);
&eventMaxparams, SET_IOTUNE_FIELD(total_iops_sec_max, set_iops_max,
VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC, TOTAL_IOPS_SEC_MAX);
param->value.ul) < 0) SET_IOTUNE_FIELD(read_iops_sec_max, set_iops_max,
goto endjob; READ_IOPS_SEC_MAX);
} else if (STREQ(param->field, SET_IOTUNE_FIELD(write_iops_sec_max, set_iops_max,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC)) { WRITE_IOPS_SEC_MAX);
info.write_bytes_sec = param->value.ul; SET_IOTUNE_FIELD(size_iops_sec, set_size_iops, SIZE_IOPS_SEC);
set_bytes = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC)) {
info.total_iops_sec = param->value.ul;
set_iops = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC)) {
info.read_iops_sec = param->value.ul;
set_iops = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC)) {
info.write_iops_sec = param->value.ul;
set_iops = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX)) {
info.total_bytes_sec_max = param->value.ul;
set_bytes_max = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC_MAX,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX)) {
info.read_bytes_sec_max = param->value.ul;
set_bytes_max = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC_MAX,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX)) {
info.write_bytes_sec_max = param->value.ul;
set_bytes_max = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC_MAX,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX)) {
info.total_iops_sec_max = param->value.ul;
set_iops_max = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC_MAX,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX)) {
info.read_iops_sec_max = param->value.ul;
set_iops_max = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC_MAX,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX)) {
info.write_iops_sec_max = param->value.ul;
set_iops_max = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC_MAX,
param->value.ul) < 0)
goto endjob;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC)) {
info.size_iops_sec = param->value.ul;
set_size_iops = true;
if (virTypedParamsAddULLong(&eventParams, &eventNparams,
&eventMaxparams,
VIR_DOMAIN_TUNABLE_BLKDEV_SIZE_IOPS_SEC,
param->value.ul) < 0)
goto endjob;
}
} }
#undef SET_IOTUNE_FIELD
if ((info.total_bytes_sec && info.read_bytes_sec) || if ((info.total_bytes_sec && info.read_bytes_sec) ||
(info.total_bytes_sec && info.write_bytes_sec)) { (info.total_bytes_sec && info.write_bytes_sec)) {
virReportError(VIR_ERR_INVALID_ARG, "%s", virReportError(VIR_ERR_INVALID_ARG, "%s",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册