mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Fix vmdef usage while in monitor in qemuDomainHotplugVcpus
Exit the monitor right after we've done with it to get the virDomainObjPtr lock back, otherwise we might be accessing vm->def while it's being cleaned up by qemuProcessStop. If the domain crashed while we were in the monitor, exit early instead of changing vm->def which is now the persistent definition.
This commit is contained in:
parent
a5e5996b91
commit
051add2ff9
@ -4366,7 +4366,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
|||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
goto unsupported;
|
goto unsupported;
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
goto exit_monitor;
|
||||||
|
|
||||||
vcpus++;
|
vcpus++;
|
||||||
}
|
}
|
||||||
@ -4377,7 +4377,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
|||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
goto unsupported;
|
goto unsupported;
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
goto exit_monitor;
|
||||||
|
|
||||||
vcpus--;
|
vcpus--;
|
||||||
}
|
}
|
||||||
@ -4394,6 +4394,10 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
|||||||
* fatal */
|
* fatal */
|
||||||
if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) <= 0) {
|
if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) <= 0) {
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
|
goto exit_monitor;
|
||||||
|
}
|
||||||
|
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
||||||
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4514,10 +4518,10 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
|||||||
cpupids = NULL;
|
cpupids = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
|
||||||
vm->def->vcpus = vcpus;
|
|
||||||
VIR_FREE(cpupids);
|
VIR_FREE(cpupids);
|
||||||
VIR_FREE(mem_mask);
|
VIR_FREE(mem_mask);
|
||||||
|
if (virDomainObjIsActive(vm))
|
||||||
|
vm->def->vcpus = vcpus;
|
||||||
virDomainAuditVcpu(vm, oldvcpus, nvcpus, "update", rc == 1);
|
virDomainAuditVcpu(vm, oldvcpus, nvcpus, "update", rc == 1);
|
||||||
if (cgroup_vcpu)
|
if (cgroup_vcpu)
|
||||||
virCgroupFree(&cgroup_vcpu);
|
virCgroupFree(&cgroup_vcpu);
|
||||||
@ -4526,6 +4530,8 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
|
|||||||
unsupported:
|
unsupported:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot change vcpu count of this domain"));
|
_("cannot change vcpu count of this domain"));
|
||||||
|
exit_monitor:
|
||||||
|
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user