Add support for a duration/length for the bps/iops and friends.
Modify the API in order to add the "blkdeviotune." specific definitions
for the iotune throttling duration/length options
total_bytes_sec_max_length
write_bytes_sec_max_length
read_bytes_sec_max_length
total_iops_sec_max_length
write_iops_sec_max_length
read_iops_sec_max_length
*/
# define VIR_DOMAIN_TUNABLE_BLKDEV_SIZE_IOPS_SEC "blkdeviotune.size_iops_sec"
+/**
+ * VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC_MAX_LENGTH:
+ *
+ * Macro represents the length in seconds allowed for a burst period
+ * for the blkdeviotune.total_bytes_sec_max,
+ * as VIR_TYPED_PARAM_ULLONG.
+ */
+# define VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC_MAX_LENGTH "blkdeviotune.total_bytes_sec_max_length"
+
+/**
+ * VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC_MAX_LENGTH:
+ *
+ * Macro represents the length in seconds allowed for a burst period
+ * for the blkdeviotune.read_bytes_sec_max
+ * as VIR_TYPED_PARAM_ULLONG.
+ */
+# define VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC_MAX_LENGTH "blkdeviotune.read_bytes_sec_max_length"
+
+/**
+ * VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC_MAX_LENGTH:
+ *
+ * Macro represents the length in seconds allowed for a burst period
+ * for the blkdeviotune.write_bytes_sec_max
+ * as VIR_TYPED_PARAM_ULLONG.
+ */
+# define VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC_MAX_LENGTH "blkdeviotune.write_bytes_sec_max_length"
+
+/**
+ * VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC_MAX_LENGTH:
+ *
+ * Macro represents the length in seconds allowed for a burst period
+ * for the blkdeviotune.total_iops_sec_max
+ * as VIR_TYPED_PARAM_ULLONG.
+ */
+# define VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC_MAX_LENGTH "blkdeviotune.total_iops_sec_max_length"
+
+/**
+ * VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC_MAX_LENGTH:
+ *
+ * Macro represents the length in seconds allowed for a burst period
+ * for the blkdeviotune.read_iops_sec_max
+ * as VIR_TYPED_PARAM_ULLONG.
+ */
+# define VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC_MAX_LENGTH "blkdeviotune.read_iops_sec_max_length"
+
+/**
+ * VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC_MAX_LENGTH:
+ *
+ * Macro represents the length in seconds allowed for a burst period
+ * for the blkdeviotune.write_iops_sec_max
+ * as VIR_TYPED_PARAM_ULLONG.
+ */
+# define VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC_MAX_LENGTH "blkdeviotune.write_iops_sec_max_length"
+
/**
* virConnectDomainEventTunableCallback:
* @conn: connection object
unsigned long long read_iops_sec_max;
unsigned long long write_iops_sec_max;
unsigned long long size_iops_sec;
+ unsigned long long total_bytes_sec_max_length;
+ unsigned long long read_bytes_sec_max_length;
+ unsigned long long write_bytes_sec_max_length;
+ unsigned long long total_iops_sec_max_length;
+ unsigned long long read_iops_sec_max_length;
+ unsigned long long write_iops_sec_max_length;
};
typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;
#define QEMU_NB_BLOCK_IO_TUNE_PARAM 6
#define QEMU_NB_BLOCK_IO_TUNE_PARAM_MAX 13
+#define QEMU_NB_BLOCK_IO_TUNE_PARAM_MAX_LENGTH 19
#define QEMU_NB_NUMA_PARAM 2
bool set_iops,
bool set_bytes_max,
bool set_iops_max,
- bool set_size_iops)
+ bool set_size_iops,
+ bool set_bytes_max_length,
+ bool set_iops_max_length)
{
#define SET_IOTUNE_DEFAULTS(BOOL, FIELD) \
if (!BOOL) { \
if (!set_size_iops)
newinfo->size_iops_sec = oldinfo->size_iops_sec;
+
+ /* The length field is handled a bit differently. If not defined/set,
+ * QEMU will default these to 0 or 1 depending on whether something in
+ * the same family is set or not.
+ *
+ * Similar to other values, if nothing in the family is defined/set,
+ * then take whatever is in the oldinfo.
+ *
+ * To clear an existing limit, a 0 is provided; however, passing that
+ * 0 onto QEMU if there's a family value defined/set (or defaulted)
+ * will cause an error. So, to mimic that, if our oldinfo was set and
+ * our newinfo is clearing, then set max_length based on whether we
+ * have a value in the family set/defined. */
+#define SET_MAX_LENGTH(BOOL, FIELD) \
+ if (!BOOL) \
+ newinfo->FIELD##_max_length = oldinfo->FIELD##_max_length; \
+ else if (BOOL && oldinfo->FIELD##_max_length && \
+ !newinfo->FIELD##_max_length) \
+ newinfo->FIELD##_max_length = (newinfo->FIELD || \
+ newinfo->FIELD##_max) ? 1 : 0;
+
+ SET_MAX_LENGTH(set_bytes_max_length, total_bytes_sec);
+ SET_MAX_LENGTH(set_bytes_max_length, read_bytes_sec);
+ SET_MAX_LENGTH(set_bytes_max_length, write_bytes_sec);
+ SET_MAX_LENGTH(set_iops_max_length, total_iops_sec);
+ SET_MAX_LENGTH(set_iops_max_length, read_iops_sec);
+ SET_MAX_LENGTH(set_iops_max_length, write_iops_sec);
+
+#undef SET_MAX_LENGTH
+
}
bool set_bytes_max = false;
bool set_iops_max = false;
bool set_size_iops = false;
+ bool set_bytes_max_length = false;
+ bool set_iops_max_length = false;
bool supportMaxOptions = true;
+ bool supportMaxLengthOptions = true;
virQEMUDriverConfigPtr cfg = NULL;
virObjectEventPtr event = NULL;
virTypedParameterPtr eventParams = NULL;
VIR_TYPED_PARAM_ULLONG,
VIR_DOMAIN_BLOCK_IOTUNE_SIZE_IOPS_SEC,
VIR_TYPED_PARAM_ULLONG,
+ VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC_MAX_LENGTH,
+ VIR_TYPED_PARAM_ULLONG,
+ VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC_MAX_LENGTH,
+ VIR_TYPED_PARAM_ULLONG,
+ VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC_MAX_LENGTH,
+ VIR_TYPED_PARAM_ULLONG,
+ VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC_MAX_LENGTH,
+ VIR_TYPED_PARAM_ULLONG,
+ VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC_MAX_LENGTH,
+ VIR_TYPED_PARAM_ULLONG,
+ VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC_MAX_LENGTH,
+ VIR_TYPED_PARAM_ULLONG,
NULL) < 0)
return -1;
SET_IOTUNE_FIELD(write_iops_sec_max, set_iops_max,
WRITE_IOPS_SEC_MAX);
SET_IOTUNE_FIELD(size_iops_sec, set_size_iops, SIZE_IOPS_SEC);
+
+ SET_IOTUNE_FIELD(total_bytes_sec_max_length, set_bytes_max_length,
+ TOTAL_BYTES_SEC_MAX_LENGTH);
+ SET_IOTUNE_FIELD(read_bytes_sec_max_length, set_bytes_max_length,
+ READ_BYTES_SEC_MAX_LENGTH);
+ SET_IOTUNE_FIELD(write_bytes_sec_max_length, set_bytes_max_length,
+ WRITE_BYTES_SEC_MAX_LENGTH);
+ SET_IOTUNE_FIELD(total_iops_sec_max_length, set_iops_max_length,
+ TOTAL_IOPS_SEC_MAX_LENGTH);
+ SET_IOTUNE_FIELD(read_iops_sec_max_length, set_iops_max_length,
+ READ_IOPS_SEC_MAX_LENGTH);
+ SET_IOTUNE_FIELD(write_iops_sec_max_length, set_iops_max_length,
+ WRITE_IOPS_SEC_MAX_LENGTH);
}
#undef SET_IOTUNE_FIELD
if (def) {
supportMaxOptions = virQEMUCapsGet(priv->qemuCaps,
QEMU_CAPS_DRIVE_IOTUNE_MAX);
+ supportMaxLengthOptions =
+ virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH);
+
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("block I/O throttling not supported with this "
goto endjob;
}
+ if (!supportMaxLengthOptions &&
+ (set_iops_max_length || set_bytes_max_length)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("a block I/O throttling length parameter is not "
+ "supported with this QEMU binary"));
+ goto endjob;
+ }
+
if (!(disk = qemuDomainDiskByName(def, path)))
goto endjob;
qemuDomainSetBlockIoTuneDefaults(&info, &disk->blkdeviotune,
set_bytes, set_iops, set_bytes_max,
- set_iops_max, set_size_iops);
+ set_iops_max, set_size_iops,
+ set_bytes_max_length,
+ set_iops_max_length);
#define CHECK_MAX(val) \
do { \
#undef CHECK_MAX
+ /* NB: Let's let QEMU decide how to handle issues with _length
+ * via the JSON error code from the block_set_io_throttle call */
+
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSetBlockIoThrottle(priv->mon, device,
- &info, supportMaxOptions);
+ &info, supportMaxOptions,
+ supportMaxLengthOptions);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
if (ret < 0)
}
qemuDomainSetBlockIoTuneDefaults(&info, &conf_disk->blkdeviotune,
set_bytes, set_iops, set_bytes_max,
- set_iops_max, set_size_iops);
+ set_iops_max, set_size_iops,
+ set_bytes_max_length,
+ set_iops_max_length);
conf_disk->blkdeviotune = info;
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
if (ret < 0)
virDomainBlockIoTuneInfo reply;
char *device = NULL;
int ret = -1;
- int maxparams = QEMU_NB_BLOCK_IO_TUNE_PARAM_MAX;
+ int maxparams = QEMU_NB_BLOCK_IO_TUNE_PARAM_MAX_LENGTH;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG |
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DRIVE_IOTUNE_MAX))
maxparams = QEMU_NB_BLOCK_IO_TUNE_PARAM;
+ else if (!virQEMUCapsGet(priv->qemuCaps,
+ QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH))
+ maxparams = QEMU_NB_BLOCK_IO_TUNE_PARAM_MAX;
}
if (*nparams == 0) {
BLOCK_IOTUNE_ASSIGN(SIZE_IOPS_SEC, size_iops_sec);
+ BLOCK_IOTUNE_ASSIGN(TOTAL_BYTES_SEC_MAX_LENGTH, total_bytes_sec_max_length);
+ BLOCK_IOTUNE_ASSIGN(READ_BYTES_SEC_MAX_LENGTH, read_bytes_sec_max_length);
+ BLOCK_IOTUNE_ASSIGN(WRITE_BYTES_SEC_MAX_LENGTH, write_bytes_sec_max_length);
+
+ BLOCK_IOTUNE_ASSIGN(TOTAL_IOPS_SEC_MAX_LENGTH, total_iops_sec_max_length);
+ BLOCK_IOTUNE_ASSIGN(READ_IOPS_SEC_MAX_LENGTH, read_iops_sec_max_length);
+ BLOCK_IOTUNE_ASSIGN(WRITE_IOPS_SEC_MAX_LENGTH, write_iops_sec_max_length);
#undef BLOCK_IOTUNE_ASSIGN
ret = 0;
qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
const char *device,
virDomainBlockIoTuneInfoPtr info,
- bool supportMaxOptions)
+ bool supportMaxOptions,
+ bool supportMaxLengthOptions)
{
VIR_DEBUG("device=%p, info=%p", device, info);
QEMU_CHECK_MONITOR(mon);
if (mon->json)
- return qemuMonitorJSONSetBlockIoThrottle(mon, device, info, supportMaxOptions);
+ return qemuMonitorJSONSetBlockIoThrottle(mon, device, info,
+ supportMaxOptions,
+ supportMaxLengthOptions);
else
return qemuMonitorTextSetBlockIoThrottle(mon, device, info);
}
int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
const char *device,
virDomainBlockIoTuneInfoPtr info,
- bool supportMaxOptions);
+ bool supportMaxOptions,
+ bool supportMaxLengthOptions);
int qemuMonitorGetBlockIoThrottle(qemuMonitorPtr mon,
const char *device,
GET_THROTTLE_STATS_OPTIONAL("iops_rd_max", read_iops_sec_max);
GET_THROTTLE_STATS_OPTIONAL("iops_wr_max", write_iops_sec_max);
GET_THROTTLE_STATS_OPTIONAL("iops_size", size_iops_sec);
+ GET_THROTTLE_STATS_OPTIONAL("bps_max_length", total_bytes_sec_max_length);
+ GET_THROTTLE_STATS_OPTIONAL("bps_rd_max_length", read_bytes_sec_max_length);
+ GET_THROTTLE_STATS_OPTIONAL("bps_wr_max_length", write_bytes_sec_max_length);
+ GET_THROTTLE_STATS_OPTIONAL("iops_max_length", total_iops_sec_max_length);
+ GET_THROTTLE_STATS_OPTIONAL("iops_rd_max_length", read_iops_sec_max_length);
+ GET_THROTTLE_STATS_OPTIONAL("iops_wr_max_length", write_iops_sec_max_length);
break;
}
int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
const char *device,
virDomainBlockIoTuneInfoPtr info,
- bool supportMaxOptions)
+ bool supportMaxOptions,
+ bool supportMaxLengthOptions)
{
int ret = -1;
virJSONValuePtr cmd = NULL;
/* The qemu capability check has already been made in
* qemuDomainSetBlockIoTune. NB, once a NULL is found in
* the sequence, qemuMonitorJSONMakeCommand will stop. So
- * let's make use of that when !supportMaxOptions */
+ * let's make use of that when !supportMaxOptions and
+ * similarly when !supportMaxLengthOptions */
cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle",
"s:device", device,
"U:bps", info->total_bytes_sec,
"U:iops_rd_max", info->read_iops_sec_max,
"U:iops_wr_max", info->write_iops_sec_max,
"U:iops_size", info->size_iops_sec,
+ !supportMaxLengthOptions ? NULL :
+ "P:bps_max_length",
+ info->total_bytes_sec_max_length,
+ "P:bps_rd_max_length",
+ info->read_bytes_sec_max_length,
+ "P:bps_wr_max_length",
+ info->write_bytes_sec_max_length,
+ "P:iops_max_length",
+ info->total_iops_sec_max_length,
+ "P:iops_rd_max_length",
+ info->read_iops_sec_max_length,
+ "P:iops_wr_max_length",
+ info->write_iops_sec_max_length,
NULL);
if (!cmd)
return -1;
int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
const char *device,
virDomainBlockIoTuneInfoPtr info,
- bool supportMaxOptions);
+ bool supportMaxOptions,
+ bool supportMaxLengthOptions);
int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon,
const char *device,
" \"iops_rd_max\": 11,"
" \"iops_wr_max\": 12,"
" \"iops_size\": 13,"
+" \"bps_max_length\": 14,"
+" \"bps_rd_max_length\": 15,"
+" \"bps_wr_max_length\": 16,"
+" \"iops_max_length\": 17,"
+" \"iops_rd_max_length\": 18,"
+" \"iops_wr_max_length\": 19,"
" \"file\": \"/home/zippy/work/tmp/gentoo.qcow2\","
" \"encryption_key_missing\": false"
" },"
if (!test)
return -1;
- expectedInfo = (virDomainBlockIoTuneInfo) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
+ expectedInfo = (virDomainBlockIoTuneInfo) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
if (qemuMonitorTestAddItem(test, "query-block", queryBlockReply) < 0 ||
qemuMonitorTestAddItemParams(test, "block_set_io_throttle",
"bps_wr_max", "9",
"iops_max", "10", "iops_rd_max", "11",
"iops_wr_max", "12", "iops_size", "13",
+ "bps_max_length", "14",
+ "bps_rd_max_length", "15",
+ "bps_wr_max_length", "16",
+ "iops_max_length", "17",
+ "iops_rd_max_length", "18",
+ "iops_wr_max_length", "19",
NULL, NULL) < 0)
goto cleanup;
}
if (qemuMonitorJSONSetBlockIoThrottle(qemuMonitorTestGetMonitor(test),
- "drive-virtio-disk1", &info, true) < 0)
+ "drive-virtio-disk1", &info, true,
+ true) < 0)
goto cleanup;
ret = 0;