mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
qemu: blockjob: Refuse to register blockjob if disk already has one
Most code paths prevent starting a blockjob if we already have one but the job registering function does not do this check. While this isn't a problem for regular cases we had a bad test case where we registered two jobs for a single disk which leaked one of the jobs. Prevent this in the registering function until we allow having multiple jobs per disk. Signed-off-by: Peter Krempa <pkrempa@redhat.com> ACKed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
8b2798e395
commit
87c8e7dbf5
@ -143,6 +143,12 @@ qemuBlockJobRegister(qemuBlockJobDataPtr job,
|
|||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
|
||||||
|
if (disk && QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("disk '%s' has a blockjob assigned"), disk->dst);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (virHashAddEntry(priv->blockjobs, job->name, virObjectRef(job)) < 0) {
|
if (virHashAddEntry(priv->blockjobs, job->name, virObjectRef(job)) < 0) {
|
||||||
virObjectUnref(job);
|
virObjectUnref(job);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user