mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 14:35:25 +00:00
qemu_agent: Rework domain object locking when opening agent
Just like qemuMonitorOpen(), hold the domain object locked throughout the whole time of qemuConnectAgent() and unlock it only for a brief time of actual connect() (because this is the only part that has a potential of blocking). The reason is that qemuAgentOpen() does access domain object (well, its privateData) AND also at least one argument (@context) depends on domain object. Accessing these without the lock is potentially dangerous. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1845468#c12 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
831f541582
commit
108e131a3d
@ -682,7 +682,10 @@ qemuAgentOpen(virDomainObj *vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virObjectUnlock(vm);
|
||||||
agent->fd = qemuAgentOpenUnix(config->data.nix.path);
|
agent->fd = qemuAgentOpenUnix(config->data.nix.path);
|
||||||
|
virObjectLock(vm);
|
||||||
|
|
||||||
if (agent->fd == -1)
|
if (agent->fd == -1)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -238,16 +238,12 @@ qemuConnectAgent(virQEMUDriver *driver, virDomainObj *vm)
|
|||||||
* deleted while the agent is active */
|
* deleted while the agent is active */
|
||||||
virObjectRef(vm);
|
virObjectRef(vm);
|
||||||
|
|
||||||
virObjectUnlock(vm);
|
|
||||||
|
|
||||||
agent = qemuAgentOpen(vm,
|
agent = qemuAgentOpen(vm,
|
||||||
config->source,
|
config->source,
|
||||||
virEventThreadGetContext(priv->eventThread),
|
virEventThreadGetContext(priv->eventThread),
|
||||||
&agentCallbacks,
|
&agentCallbacks,
|
||||||
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VSERPORT_CHANGE));
|
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VSERPORT_CHANGE));
|
||||||
|
|
||||||
virObjectLock(vm);
|
|
||||||
|
|
||||||
if (agent == NULL)
|
if (agent == NULL)
|
||||||
virObjectUnref(vm);
|
virObjectUnref(vm);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user