提交 49d01f9e 编写于 作者: J John Ferlan

virsh: Create macros to add IOTUNE values

Rework the repetitive lines to add iotune values into easier to read macros.
One to handle the SCALED values and one to handle the non scaled values.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 2db108c7
...@@ -1300,122 +1300,43 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) ...@@ -1300,122 +1300,43 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "device", &disk) < 0) if (vshCommandOptStringReq(ctl, cmd, "device", &disk) < 0)
goto cleanup; goto cleanup;
if ((rv = vshCommandOptScaledInt(ctl, cmd, "total-bytes-sec", &value, 1, ULLONG_MAX)) < 0) { #define VSH_ADD_IOTUNE_SCALED(PARAM, CONST) \
goto interror; if ((rv = vshCommandOptScaledInt(ctl, cmd, #PARAM, &value, \
} else if (rv > 0) { 1, ULLONG_MAX)) < 0) { \
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, goto interror; \
VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC, } else if (rv > 0) { \
value) < 0) if (virTypedParamsAddULLong(&params, &nparams, &maxparams, \
goto save_error; VIR_DOMAIN_BLOCK_IOTUNE_##CONST, \
} value) < 0) \
goto save_error; \
if ((rv = vshCommandOptScaledInt(ctl, cmd, "read-bytes-sec", &value, 1, ULLONG_MAX)) < 0) { } \
goto interror;
} else if (rv > 0) { VSH_ADD_IOTUNE_SCALED(total-bytes-sec, TOTAL_BYTES_SEC);
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, VSH_ADD_IOTUNE_SCALED(read-bytes-sec, READ_BYTES_SEC);
VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC, VSH_ADD_IOTUNE_SCALED(write-bytes-sec, WRITE_BYTES_SEC);
value) < 0) VSH_ADD_IOTUNE_SCALED(total-bytes-sec-max, TOTAL_BYTES_SEC_MAX);
goto save_error; VSH_ADD_IOTUNE_SCALED(read-bytes-sec-max, READ_BYTES_SEC_MAX);
} VSH_ADD_IOTUNE_SCALED(write-bytes-sec-max, WRITE_BYTES_SEC_MAX);
#undef VSH_ADD_IOTUNE_SCALED
if ((rv = vshCommandOptScaledInt(ctl, cmd, "write-bytes-sec", &value, 1, ULLONG_MAX)) < 0) {
goto interror; #define VSH_ADD_IOTUNE(PARAM, CONST) \
} else if (rv > 0) { if ((rv = vshCommandOptULongLong(ctl, cmd, #PARAM, &value)) < 0) { \
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, goto interror; \
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC, } else if (rv > 0) { \
value) < 0) if (virTypedParamsAddULLong(&params, &nparams, &maxparams, \
goto save_error; VIR_DOMAIN_BLOCK_IOTUNE_##CONST, \
} value) < 0) \
goto save_error; \
if ((rv = vshCommandOptScaledInt(ctl, cmd, "total-bytes-sec-max", &value, 1, ULLONG_MAX)) < 0) { } \
goto interror;
} else if (rv > 0) { VSH_ADD_IOTUNE(total-iops-sec, TOTAL_IOPS_SEC);
if (virTypedParamsAddULLong(&params, &nparams, &maxparams, VSH_ADD_IOTUNE(read-iops-sec, READ_IOPS_SEC);
VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX, VSH_ADD_IOTUNE(write-iops-sec, WRITE_IOPS_SEC);
value) < 0) VSH_ADD_IOTUNE(total-iops-sec-max, TOTAL_IOPS_SEC_MAX);
goto save_error; VSH_ADD_IOTUNE(read-iops-sec-max, READ_IOPS_SEC_MAX);
} VSH_ADD_IOTUNE(write-iops-sec-max, WRITE_IOPS_SEC_MAX);
VSH_ADD_IOTUNE(size-iops-sec, SIZE_IOPS_SEC);
if ((rv = vshCommandOptScaledInt(ctl, cmd, "read-bytes-sec-max", &value, 1, ULLONG_MAX)) < 0) { #undef VSH_ADD_IOTUNE
goto interror;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX,
value) < 0)
goto save_error;
}
if ((rv = vshCommandOptScaledInt(ctl, cmd, "write-bytes-sec-max", &value, 1, ULLONG_MAX)) < 0) {
goto interror;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX,
value) < 0)
goto save_error;
}
if ((rv = vshCommandOptULongLong(ctl, cmd, "total-iops-sec", &value)) < 0) {
goto interror;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC,
value) < 0)
goto save_error;
}
if ((rv = vshCommandOptULongLong(ctl, cmd, "read-iops-sec", &value)) < 0) {
goto interror;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC,
value) < 0)
goto save_error;
}
if ((rv = vshCommandOptULongLong(ctl, cmd, "write-iops-sec", &value)) < 0) {
goto interror;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC,
value) < 0)
goto save_error;
}
if ((rv = vshCommandOptULongLong(ctl, cmd, "write-iops-sec-max", &value)) < 0) {
goto interror;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX,
value) < 0)
goto save_error;
}
if ((rv = vshCommandOptULongLong(ctl, cmd, "read-iops-sec-max", &value)) < 0) {
goto interror;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX,
value) < 0)
goto save_error;
}
if ((rv = vshCommandOptULongLong(ctl, cmd, "total-iops-sec-max", &value)) < 0) {
goto interror;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX,
value) < 0)
goto save_error;
}
if ((rv = vshCommandOptULongLong(ctl, cmd, "size-iops-sec", &value)) < 0) {
goto interror;
} else if (rv > 0) {
if (virTypedParamsAddULLong(&params, &nparams, &maxparams,
VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC,
value) < 0)
goto save_error;
}
if (nparams == 0) { if (nparams == 0) {
if (virDomainGetBlockIoTune(dom, NULL, NULL, &nparams, flags) != 0) { if (virDomainGetBlockIoTune(dom, NULL, NULL, &nparams, flags) != 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册