提交 144947ce 编写于 作者: J John Ferlan

qemu: Introduce qemuDomainSetBlockIoTuneDefaults

Create a helper to set the bytes/iops iotune default values based on
the current qemu setting for both the live and persistent definitions.
NB: This also fixes an unreported bug where the persistent values for
*_max and size_iops_sec would be set back to 0 if unrelated persistent
values were set.
上级 1f89039d
...@@ -17292,6 +17292,36 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom, ...@@ -17292,6 +17292,36 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom,
return ret; return ret;
} }
/* If the user didn't specify bytes limits, inherit previous values;
* likewise if the user didn't specify iops limits. */
static void
qemuDomainSetBlockIoTuneDefaults(virDomainBlockIoTuneInfoPtr newinfo,
virDomainBlockIoTuneInfoPtr oldinfo,
bool set_bytes,
bool set_iops,
bool set_bytes_max,
bool set_iops_max,
bool set_size_iops)
{
#define SET_IOTUNE_DEFAULTS(BOOL, FIELD) \
if (!BOOL) { \
newinfo->total_##FIELD = oldinfo->total_##FIELD; \
newinfo->read_##FIELD = oldinfo->read_##FIELD; \
newinfo->write_##FIELD = oldinfo->write_##FIELD; \
}
SET_IOTUNE_DEFAULTS(set_bytes, bytes_sec);
SET_IOTUNE_DEFAULTS(set_bytes_max, bytes_sec_max);
SET_IOTUNE_DEFAULTS(set_iops, iops_sec);
SET_IOTUNE_DEFAULTS(set_iops_max, iops_sec_max);
#undef SET_IOTUNE_DEFAULTS
if (!set_size_iops)
newinfo->size_iops_sec = oldinfo->size_iops_sec;
}
static int static int
qemuDomainSetBlockIoTune(virDomainPtr dom, qemuDomainSetBlockIoTune(virDomainPtr dom,
const char *path, const char *path,
...@@ -17305,7 +17335,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -17305,7 +17335,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
virDomainDefPtr persistentDef = NULL; virDomainDefPtr persistentDef = NULL;
virDomainBlockIoTuneInfo info; virDomainBlockIoTuneInfo info;
virDomainBlockIoTuneInfo *oldinfo;
char *device = NULL; char *device = NULL;
int ret = -1; int ret = -1;
size_t i; size_t i;
...@@ -17479,32 +17508,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -17479,32 +17508,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (!(device = qemuAliasFromDisk(disk))) if (!(device = qemuAliasFromDisk(disk)))
goto endjob; goto endjob;
/* If the user didn't specify bytes limits, inherit previous qemuDomainSetBlockIoTuneDefaults(&info, &disk->blkdeviotune,
* values; likewise if the user didn't specify iops set_bytes, set_iops, set_bytes_max,
* limits. */ set_iops_max, set_size_iops);
oldinfo = &disk->blkdeviotune;
if (!set_bytes) {
info.total_bytes_sec = oldinfo->total_bytes_sec;
info.read_bytes_sec = oldinfo->read_bytes_sec;
info.write_bytes_sec = oldinfo->write_bytes_sec;
}
if (!set_bytes_max) {
info.total_bytes_sec_max = oldinfo->total_bytes_sec_max;
info.read_bytes_sec_max = oldinfo->read_bytes_sec_max;
info.write_bytes_sec_max = oldinfo->write_bytes_sec_max;
}
if (!set_iops) {
info.total_iops_sec = oldinfo->total_iops_sec;
info.read_iops_sec = oldinfo->read_iops_sec;
info.write_iops_sec = oldinfo->write_iops_sec;
}
if (!set_iops_max) {
info.total_iops_sec_max = oldinfo->total_iops_sec_max;
info.read_iops_sec_max = oldinfo->read_iops_sec_max;
info.write_iops_sec_max = oldinfo->write_iops_sec_max;
}
if (!set_size_iops)
info.size_iops_sec = oldinfo->size_iops_sec;
#define CHECK_MAX(val) \ #define CHECK_MAX(val) \
do { \ do { \
...@@ -17553,17 +17559,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ...@@ -17553,17 +17559,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
path); path);
goto endjob; goto endjob;
} }
oldinfo = &conf_disk->blkdeviotune; qemuDomainSetBlockIoTuneDefaults(&info, &conf_disk->blkdeviotune,
if (!set_bytes) { set_bytes, set_iops, set_bytes_max,
info.total_bytes_sec = oldinfo->total_bytes_sec; set_iops_max, set_size_iops);
info.read_bytes_sec = oldinfo->read_bytes_sec;
info.write_bytes_sec = oldinfo->write_bytes_sec;
}
if (!set_iops) {
info.total_iops_sec = oldinfo->total_iops_sec;
info.read_iops_sec = oldinfo->read_iops_sec;
info.write_iops_sec = oldinfo->write_iops_sec;
}
conf_disk->blkdeviotune = info; conf_disk->blkdeviotune = info;
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef); ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册