On 03/20/2015 10:39 PM, Pavel Hrdina wrote:
> From: Luyao Huang <lhuang(a)redhat.com>
>
> Commit e105dc9 fix setting vcpus for offline domain, but forget check
> if vm is active when pass VIR_DOMAIN_AFFECT_LIVE flags.
>
> # virsh setvcpus test3 4 --live
> error: Failed to create controller cpu for group: No such file or directory
>
> Add a check if we pass VIR_DOMAIN_AFFECT_LIVE flags.
>
> Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1204006
>
> Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
> Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
> ---
> src/qemu/qemu_driver.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 4942712..c4d96bd 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -4881,6 +4881,14 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int
nvcpus,
> if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
> goto cleanup;
>
> + if (flags & VIR_DOMAIN_AFFECT_LIVE) {
> + if (!virDomainObjIsActive(vm)) {
> + virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> + _("domain is not running"));
> + goto endjob;
> + }
> + }
> +
> if (flags & VIR_DOMAIN_AFFECT_LIVE && !(flags &
VIR_DOMAIN_VCPU_GUEST)) {
> if (virCgroupNewEmulator(priv->cgroup, false, &cgroup_temp) <
0)
> goto endjob;
> @@ -4947,12 +4955,6 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int
nvcpus,
> if (ncpuinfo < 0)
> goto endjob;
>
> - if (!virDomainObjIsActive(vm)) {
> - virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> - _("domain is not running"));
> - goto endjob;
> - }
> -
> if (qemuAgentUpdateCPUInfo(nvcpus, cpuinfo, ncpuinfo) < 0)
> goto endjob;
Sorry, i forgot there is a function virDomainLiveConfigHelperMethod(),
move this function just after qemuDomainObjBeginJob() maybe a good way
to fix this issue. Also virDomainLiveConfigHelperMethod() may change
flags, so it should be done more early (as soon as possible after set a
lock to vm).
I've already sent a patch 7/6 to move that function. I realized that right
after I've sent this series to mailing list.
Pavel