Commit ae523427 missed one pair of functions that could use
the helper routine.
* src/qemu/qemu_driver.c (qemuSetSchedulerParametersFlags)
(qemuGetSchedulerParametersFlags): Simplify.
---
src/qemu/qemu_driver.c | 73 +++++++----------------------------------------
1 files changed, 11 insertions(+), 62 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ad592d6..5d50940 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6996,7 +6996,6 @@ static int qemuSetSchedulerParametersFlags(virDomainPtr dom,
virDomainObjPtr vm = NULL;
virDomainDefPtr vmdef = NULL;
int ret = -1;
- bool isActive;
int rc;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
@@ -7012,22 +7011,11 @@ static int qemuSetSchedulerParametersFlags(virDomainPtr dom,
goto cleanup;
}
- isActive = virDomainObjIsActive(vm);
-
- if (flags == VIR_DOMAIN_AFFECT_CURRENT) {
- if (isActive)
- flags = VIR_DOMAIN_AFFECT_LIVE;
- else
- flags = VIR_DOMAIN_AFFECT_CONFIG;
- }
+ if (virDomainLiveConfigHelperMethod(driver->caps, vm, &flags,
+ &vmdef) < 0)
+ goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- if (!vm->persistent) {
- qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot change persistent config of a transient
domain"));
- goto cleanup;
- }
-
/* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(driver->caps, vm);
if (!vmdef)
@@ -7035,12 +7023,6 @@ static int qemuSetSchedulerParametersFlags(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
- if (!isActive) {
- qemuReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("domain is not running"));
- goto cleanup;
- }
-
if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cgroup CPU controller is not
mounted"));
@@ -7238,9 +7220,9 @@ qemuGetSchedulerParametersFlags(virDomainPtr dom,
long long quota;
int ret = -1;
int rc;
- bool isActive;
bool cpu_bw_status = false;
int saved_nparams = 0;
+ virDomainDefPtr persistentDef;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG |
@@ -7266,52 +7248,19 @@ qemuGetSchedulerParametersFlags(virDomainPtr dom,
goto cleanup;
}
- isActive = virDomainObjIsActive(vm);
-
- if (flags == VIR_DOMAIN_AFFECT_CURRENT) {
- if (isActive)
- flags = VIR_DOMAIN_AFFECT_LIVE;
- else
- flags = VIR_DOMAIN_AFFECT_CONFIG;
- }
+ if (virDomainLiveConfigHelperMethod(driver->caps, vm, &flags,
+ &persistentDef) < 0)
+ goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- if (!vm->persistent) {
- qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot query persistent config of a transient
domain"));
- goto cleanup;
- }
-
- if (isActive) {
- virDomainDefPtr persistentDef;
-
- persistentDef = virDomainObjGetPersistentDef(driver->caps, vm);
- if (!persistentDef) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("can't get persistentDef"));
- goto cleanup;
- }
- shares = persistentDef->cputune.shares;
- if (*nparams > 1 && cpu_bw_status) {
- period = persistentDef->cputune.period;
- quota = persistentDef->cputune.quota;
- }
- } else {
- shares = vm->def->cputune.shares;
- if (*nparams > 1 && cpu_bw_status) {
- period = vm->def->cputune.period;
- quota = vm->def->cputune.quota;
- }
+ shares = persistentDef->cputune.shares;
+ if (*nparams > 1 && cpu_bw_status) {
+ period = persistentDef->cputune.period;
+ quota = persistentDef->cputune.quota;
}
goto out;
}
- if (!isActive) {
- qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("domain is not running"));
- goto cleanup;
- }
-
if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cgroup CPU controller is not
mounted"));
--
1.7.7.4
Show replies by date
On 01/02/2012 04:37 PM, Eric Blake wrote:
Commit ae523427 missed one pair of functions that could use
the helper routine.
Missed one in qemu, but I also found multiple sites to clean up in
lxc_driver.c. I guess I'll submit those as a followup.
* src/qemu/qemu_driver.c (qemuSetSchedulerParametersFlags)
(qemuGetSchedulerParametersFlags): Simplify.
---
src/qemu/qemu_driver.c | 73 +++++++----------------------------------------
1 files changed, 11 insertions(+), 62 deletions(-)
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org
On 03.01.2012 00:37, Eric Blake wrote:
Commit ae523427 missed one pair of functions that could use
the helper routine.
* src/qemu/qemu_driver.c (qemuSetSchedulerParametersFlags)
(qemuGetSchedulerParametersFlags): Simplify.
---
src/qemu/qemu_driver.c | 73 +++++++----------------------------------------
1 files changed, 11 insertions(+), 62 deletions(-)
Nice cleanup. ACK.
Michal
On 01/03/2012 03:05 AM, Michal Privoznik wrote:
On 03.01.2012 00:37, Eric Blake wrote:
> Commit ae523427 missed one pair of functions that could use
> the helper routine.
>
> * src/qemu/qemu_driver.c (qemuSetSchedulerParametersFlags)
> (qemuGetSchedulerParametersFlags): Simplify.
> ---
> src/qemu/qemu_driver.c | 73 +++++++----------------------------------------
> 1 files changed, 11 insertions(+), 62 deletions(-)
>
Nice cleanup. ACK.
Thanks; pushed. I intentionally waited until post-release, since it
wasn't fixing any bugs.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org