mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: domain: Simplify return values of qemuDomainRefreshVcpuInfo
Call the vcpu thread info validation separately to decrease complexity of returned values by qemuDomainRefreshVcpuInfo. This function now returns 0 on success and -1 on error. Certain failures of qemu to report data are still considered as success. Any error reported now is fatal.
This commit is contained in:
parent
2bdc300a34
commit
041f35340b
@ -5671,10 +5671,10 @@ qemuDomainValidateVcpuInfo(virDomainObjPtr vm)
|
|||||||
* @vm: domain object
|
* @vm: domain object
|
||||||
* @asyncJob: current asynchronous job type
|
* @asyncJob: current asynchronous job type
|
||||||
*
|
*
|
||||||
* Updates vCPU information private data of @vm.
|
* Updates vCPU information private data of @vm. Due to historical reasons this
|
||||||
|
* function returns success even if some data were not reported by qemu.
|
||||||
*
|
*
|
||||||
* Returns number of detected vCPU threads on success, -1 on error and reports
|
* Returns 0 on success and -1 on fatal error.
|
||||||
* an appropriate error, -2 if the domain doesn't exist any more.
|
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
||||||
@ -5722,10 +5722,8 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
|||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
ncpupids = qemuMonitorGetCPUInfo(qemuDomainGetMonitor(vm), &cpupids);
|
ncpupids = qemuMonitorGetCPUInfo(qemuDomainGetMonitor(vm), &cpupids);
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -2;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* failure to get the VCPU <-> PID mapping or to execute the query
|
/* failure to get the VCPU <-> PID mapping or to execute the query
|
||||||
* command will not be treated fatal as some versions of qemu don't
|
* command will not be treated fatal as some versions of qemu don't
|
||||||
@ -5745,10 +5743,7 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
|||||||
QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->tid = 0;
|
QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->tid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainValidateVcpuInfo(vm) < 0)
|
ret = 0;
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = ncpupids;
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(cpupids);
|
VIR_FREE(cpupids);
|
||||||
|
@ -4615,6 +4615,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu);
|
virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu);
|
||||||
|
qemuDomainVcpuPrivatePtr vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpuinfo);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int rc;
|
int rc;
|
||||||
int oldvcpus = virDomainDefGetVcpus(vm->def);
|
int oldvcpus = virDomainDefGetVcpus(vm->def);
|
||||||
@ -4639,15 +4640,14 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
vcpuinfo->online = true;
|
vcpuinfo->online = true;
|
||||||
|
|
||||||
if ((rc = qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE)) <= 0) {
|
if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
/* vcpu pids were not detected, skip setting of affinity */
|
|
||||||
if (rc == 0)
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuProcessSetupVcpu(vm, vcpu) < 0)
|
if (qemuDomainValidateVcpuInfo(vm) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (vcpupriv->tid > 0 &&
|
||||||
|
qemuProcessSetupVcpu(vm, vcpu) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -4689,11 +4689,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE)) < 0) {
|
if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
/* rollback only if domain didn't exit */
|
goto cleanup;
|
||||||
if (rc == -2)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
|
if (qemuDomainValidateVcpuInfo(vm) < 0) {
|
||||||
|
/* rollback vcpu count if the setting has failed */
|
||||||
virDomainAuditVcpu(vm, oldvcpus, oldvcpus - 1, "update", false);
|
virDomainAuditVcpu(vm, oldvcpus, oldvcpus - 1, "update", false);
|
||||||
vcpuinfo->online = true;
|
vcpuinfo->online = true;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -5193,6 +5193,9 @@ qemuProcessLaunch(virConnectPtr conn,
|
|||||||
if (qemuDomainRefreshVcpuInfo(driver, vm, asyncJob) < 0)
|
if (qemuDomainRefreshVcpuInfo(driver, vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuDomainValidateVcpuInfo(vm) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
VIR_DEBUG("Detecting IOThread PIDs");
|
VIR_DEBUG("Detecting IOThread PIDs");
|
||||||
if (qemuProcessDetectIOThreadPIDs(driver, vm, asyncJob) < 0)
|
if (qemuProcessDetectIOThreadPIDs(driver, vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -5985,6 +5988,9 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (qemuDomainValidateVcpuInfo(vm) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
VIR_DEBUG("Detecting IOThread PIDs");
|
VIR_DEBUG("Detecting IOThread PIDs");
|
||||||
if (qemuProcessDetectIOThreadPIDs(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
if (qemuProcessDetectIOThreadPIDs(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user