提交 8bbf1133 编写于 作者: G Gao feng

virsh: add setting throttle blkio cgroup option to blkiotune

With this patch, user can setup the throttle blkio cgorup
for domain through the virsh cmd, such as:

virsh blkiotune domain1 --device-read-bytes-sec /dev/sda1,1000000,/dev/sda2,2000000
--device-write-bytes-sec /dev/sda1,1000000 --device-read-iops-sec /dev/sda1,10000
--device-write-iops-sec /dev/sda1,10000,/dev/sda2,0

This patch also add manpage for these new options.
Signed-off-by: NGuan Qiang <hzguanqiang@corp.netease.com>
Signed-off-by: NGao feng <gaofeng@cn.fujitsu.com>
上级 3b431929
......@@ -1806,6 +1806,51 @@ char * virDomainGetSchedulerType(virDomainPtr domain,
#define VIR_DOMAIN_BLKIO_DEVICE_WEIGHT "device_weight"
/**
* VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS:
*
* Macro for the blkio tunable throttle.read_iops_device: it represents
* the number of reading the block device per second, as a string. The
* string is parsed as a series of /path/to/device, read_iops elements,
* separated by ','.
*/
#define VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS "device_read_iops_sec"
/**
* VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS:
*
* Macro for the blkio tunable throttle.write_iops_device: it represents
* the number of writing the block device per second, as a string. The
* string is parsed as a series of /path/to/device, write_iops elements,
* separated by ','.
*/
#define VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS "device_write_iops_sec"
/**
* VIR_DOMAIN_BLKIO_DEVICE_READ_BPS:
*
* Macro for the blkio tunable throttle.read_iops_device: it represents
* the bytes of reading the block device per second, as a string. The
* string is parsed as a series of /path/to/device, read_bps elements,
* separated by ','.
*/
#define VIR_DOMAIN_BLKIO_DEVICE_READ_BPS "device_read_bytes_sec"
/**
* VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS:
*
* Macro for the blkio tunable throttle.read_iops_device: it represents
* the number of reading the block device per second, as a string. The
* string is parsed as a series of /path/to/device, write_bps elements,
* separated by ','.
*/
#define VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS "device_write_bytes_sec"
/* Set Blkio tunables for the domain*/
int virDomainSetBlkioParameters(virDomainPtr domain,
virTypedParameterPtr params,
......
......@@ -1250,6 +1250,22 @@ static const vshCmdOptDef opts_blkiotune[] = {
.type = VSH_OT_STRING,
.help = N_("per-device IO Weights, in the form of /path/to/device,weight,...")
},
{.name = "device-read-iops-sec",
.type = VSH_OT_STRING,
.help = N_("per-device read I/O limit per second, in the form of /path/to/device,read_iops_sec,...")
},
{.name = "device-write-iops-sec",
.type = VSH_OT_STRING,
.help = N_("per-device write I/O limit per second, in the form of /path/to/device,write_iops_sec,...")
},
{.name = "device-read-bytes-sec",
.type = VSH_OT_STRING,
.help = N_("per-device bytes read per second, in the form of /path/to/device,read_bytes_sec,...")
},
{.name = "device-write-bytes-sec",
.type = VSH_OT_STRING,
.help = N_("per-device bytes wrote per second, in the form of /path/to/device,write_bytes_sec,...")
},
{.name = "config",
.type = VSH_OT_BOOL,
.help = N_("affect next boot")
......@@ -1270,6 +1286,10 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
{
virDomainPtr dom;
const char *device_weight = NULL;
const char *device_riops = NULL;
const char *device_wiops = NULL;
const char *device_rbps = NULL;
const char *device_wbps = NULL;
int weight = 0;
int nparams = 0;
int maxparams = 0;
......@@ -1317,6 +1337,50 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
goto save_error;
}
rv = vshCommandOptString(cmd, "device-read-iops-sec", &device_riops);
if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup;
} else if (rv > 0) {
if (virTypedParamsAddString(&params, &nparams, &maxparams,
VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS,
device_riops) < 0)
goto save_error;
}
rv = vshCommandOptString(cmd, "device-write-iops-sec", &device_wiops);
if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup;
} else if (rv > 0) {
if (virTypedParamsAddString(&params, &nparams, &maxparams,
VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS,
device_wiops) < 0)
goto save_error;
}
rv = vshCommandOptString(cmd, "device-read-bytes-sec", &device_rbps);
if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup;
} else if (rv > 0) {
if (virTypedParamsAddString(&params, &nparams, &maxparams,
VIR_DOMAIN_BLKIO_DEVICE_READ_BPS,
device_rbps) < 0)
goto save_error;
}
rv = vshCommandOptString(cmd, "device-write-bytes-sec", &device_wbps);
if (rv < 0) {
vshError(ctl, "%s", _("Unable to parse string parameter"));
goto cleanup;
} else if (rv > 0) {
if (virTypedParamsAddString(&params, &nparams, &maxparams,
VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS,
device_wbps) < 0)
goto save_error;
}
if (nparams == 0) {
/* get the number of blkio parameters */
if (virDomainGetBlkioParameters(dom, NULL, &nparams, flags) != 0) {
......
......@@ -1625,8 +1625,12 @@ The guaranteed minimum memory allocation for the guest.
Specifying -1 as a value for these limits is interpreted as unlimited.
=item B<blkiotune> I<domain> [I<--weight> B<weight>]
[I<--device-weights> B<device-weights>] [[I<--config>]
[I<--live>] | [I<--current>]]
[I<--device-weights> B<device-weights>]
[I<--device-read-iops-sec> B<device-read-iops-sec>]
[I<--device-write-iops-sec> B<device-write-iops-sec>]
[I<--device-read-bytes-sec> B<device-read-bytes-sec>]
[I<--device-write-bytes-sec> B<device-write-bytes-sec>]
[[I<--config>] [I<--live>] | [I<--current>]]
Display or set the blkio parameters. QEMU/KVM supports I<--weight>.
I<--weight> is in range [100, 1000]. After kernel 2.6.39, the value
......@@ -1639,6 +1643,34 @@ or the value 0 to remove that device from per-device listings.
Only the devices listed in the string are modified;
any existing per-device weights for other devices remain unchanged.
B<device-read-iops-sec> is a single string listing one or more device/read_iops_sec
pairs, int the format of /path/to/device,read_iops_sec,/path/to/device,read_iops_sec.
Each read_iops_sec is a number which type is unsigned int, value 0 to remove that
device from per-decice listing.
Only the devices listed in the string are modified;
any existing per-device read_iops_sec for other devices remain unchanged.
B<device-write-iops-sec> is a single string listing one or more device/write_iops_sec
pairs, int the format of /path/to/device,write_iops_sec,/path/to/device,write_iops_sec.
Each write_iops_sec is a number which type is unsigned int, value 0 to remove that
device from per-decice listing.
Only the devices listed in the string are modified;
any existing per-device write_iops_sec for other devices remain unchanged.
B<device-read-bytes-sec> is a single string listing one or more device/read_bytes_sec
pairs, int the format of /path/to/device,read_bytes_sec,/path/to/device,read_bytes_sec.
Each read_bytes_sec is a number which type is unsigned long long, value 0 to remove
that device from per-decice listing.
Only the devices listed in the string are modified;
any existing per-device read_bytes_sec for other devices remain unchanged.
B<device-write-bytes-sec> is a single string listing one or more device/write_bytes_sec
pairs, int the format of /path/to/device,write_bytes_sec,/path/to/device,write_bytes_sec.
Each write_bytes_sec is a number which type is unsigned long long, value 0 to remove
that device from per-decice listing.
Only the devices listed in the string are modified;
any existing per-device write_bytes_sec for other devices remain unchanged.
If I<--live> is specified, affect a running guest.
If I<--config> is specified, affect the next boot of a persistent guest.
If I<--current> is specified, affect the current guest state.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册