提交 133be0a9 编写于 作者: P Peter Krempa

qemu: domain: Prepare for VCPUs vanishing while libvirt is not running

Similarly to devices the guest may allow unplug of the VCPU if libvirt
is down. To avoid problems, refresh the vcpu state on reconnect. Don't
mess with the vcpu state otherwise.
上级 6b4a23ff
...@@ -5764,16 +5764,20 @@ qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm) ...@@ -5764,16 +5764,20 @@ qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm)
* @driver: qemu driver data * @driver: qemu driver data
* @vm: domain object * @vm: domain object
* @asyncJob: current asynchronous job type * @asyncJob: current asynchronous job type
* @state: refresh vcpu state
* *
* Updates vCPU information private data of @vm. Due to historical reasons this * Updates vCPU information private data of @vm. Due to historical reasons this
* function returns success even if some data were not reported by qemu. * function returns success even if some data were not reported by qemu.
* *
* If @state is true, the vcpu state is refreshed as reported by the monitor.
*
* Returns 0 on success and -1 on fatal error. * Returns 0 on success and -1 on fatal error.
*/ */
int int
qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver, qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
int asyncJob) int asyncJob,
bool state)
{ {
virDomainVcpuDefPtr vcpu; virDomainVcpuDefPtr vcpu;
qemuDomainVcpuPrivatePtr vcpupriv; qemuDomainVcpuPrivatePtr vcpupriv;
...@@ -5841,6 +5845,9 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver, ...@@ -5841,6 +5845,9 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
VIR_FREE(vcpupriv->alias); VIR_FREE(vcpupriv->alias);
VIR_STEAL_PTR(vcpupriv->alias, info[i].alias); VIR_STEAL_PTR(vcpupriv->alias, info[i].alias);
vcpupriv->enable_id = info[i].id; vcpupriv->enable_id = info[i].id;
if (hotplug && state)
vcpu->online = !!info[i].qom_path;
} }
ret = 0; ret = 0;
......
...@@ -660,7 +660,8 @@ pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid); ...@@ -660,7 +660,8 @@ pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid);
int qemuDomainValidateVcpuInfo(virDomainObjPtr vm); int qemuDomainValidateVcpuInfo(virDomainObjPtr vm);
int qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver, int qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
int asyncJob); int asyncJob,
bool state);
bool qemuDomainSupportsNicdev(virDomainDefPtr def, bool qemuDomainSupportsNicdev(virDomainDefPtr def,
virDomainNetDefPtr net); virDomainNetDefPtr net);
......
...@@ -4640,7 +4640,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, ...@@ -4640,7 +4640,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
vcpuinfo->online = true; vcpuinfo->online = true;
if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE, false) < 0)
goto cleanup; goto cleanup;
if (qemuDomainValidateVcpuInfo(vm) < 0) if (qemuDomainValidateVcpuInfo(vm) < 0)
...@@ -4689,7 +4689,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, ...@@ -4689,7 +4689,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
} }
if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE, false) < 0)
goto cleanup; goto cleanup;
if (qemuDomainValidateVcpuInfo(vm) < 0) { if (qemuDomainValidateVcpuInfo(vm) < 0) {
......
...@@ -3354,6 +3354,9 @@ qemuProcessReconnect(void *opaque) ...@@ -3354,6 +3354,9 @@ qemuProcessReconnect(void *opaque)
ignore_value(virSecurityManagerCheckAllLabel(driver->securityManager, ignore_value(virSecurityManagerCheckAllLabel(driver->securityManager,
obj->def)); obj->def));
if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) < 0)
goto error;
if (virSecurityManagerReserveLabel(driver->securityManager, obj->def, obj->pid) < 0) if (virSecurityManagerReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
goto error; goto error;
...@@ -5234,7 +5237,7 @@ qemuProcessLaunch(virConnectPtr conn, ...@@ -5234,7 +5237,7 @@ qemuProcessLaunch(virConnectPtr conn,
goto cleanup; goto cleanup;
VIR_DEBUG("Refreshing VCPU info"); VIR_DEBUG("Refreshing VCPU info");
if (qemuDomainRefreshVcpuInfo(driver, vm, asyncJob) < 0) if (qemuDomainRefreshVcpuInfo(driver, vm, asyncJob, false) < 0)
goto cleanup; goto cleanup;
if (qemuDomainValidateVcpuInfo(vm) < 0) if (qemuDomainValidateVcpuInfo(vm) < 0)
...@@ -6029,7 +6032,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -6029,7 +6032,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
} }
VIR_DEBUG("Detecting VCPU PIDs"); VIR_DEBUG("Detecting VCPU PIDs");
if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE, false) < 0)
goto error; goto error;
if (qemuDomainValidateVcpuInfo(vm) < 0) if (qemuDomainValidateVcpuInfo(vm) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册