[libvirt] [PATCH] qemuDomainNestedJobAllowed: Allow QEMU_JOB_NONE

Michal Privoznik posted 1 patch 5 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/e32d68123a42e98291d09158781b62f7c307fbb0.1530702541.git.mprivozn@redhat.com
Test syntax-check passed
src/qemu/qemu_domain.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[libvirt] [PATCH] qemuDomainNestedJobAllowed: Allow QEMU_JOB_NONE
Posted by Michal Privoznik 5 years, 9 months ago
https://bugzilla.redhat.com/show_bug.cgi?id=1598084

When creating a snapshot with --quiesce an async job is grabbed
and just before executing guest fs-freeze command an agent job is
grabbed. This is achieved by calling

  qemuDomainObjBeginJobInternal(job = QEMU_JOB_NONE,
                                agentJob = QEMU_AGENT_JOB_MODIFY);

Since there already is an async job set on the domain (by the
same thread) qemuDomainNestedJobAllowed(priv, job) is consulted
if @job is allowed by job mask. But this function returns false
(meaning sync @job is not allowed) which leads to a deadlock.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_domain.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a60bca29ca..1b8fb71ba8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6414,7 +6414,9 @@ qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj)
 static bool
 qemuDomainNestedJobAllowed(qemuDomainObjPrivatePtr priv, qemuDomainJob job)
 {
-    return !priv->job.asyncJob || (priv->job.mask & JOB_MASK(job)) != 0;
+    return !priv->job.asyncJob ||
+        job == QEMU_JOB_NONE ||
+        (priv->job.mask & JOB_MASK(job)) != 0;
 }
 
 bool
-- 
2.16.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemuDomainNestedJobAllowed: Allow QEMU_JOB_NONE
Posted by Jiri Denemark 5 years, 9 months ago
On Wed, Jul 04, 2018 at 13:09:01 +0200, Michal Privoznik wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1598084
> 
> When creating a snapshot with --quiesce an async job is grabbed
> and just before executing guest fs-freeze command an agent job is
> grabbed. This is achieved by calling
> 
>   qemuDomainObjBeginJobInternal(job = QEMU_JOB_NONE,
>                                 agentJob = QEMU_AGENT_JOB_MODIFY);
> 
> Since there already is an async job set on the domain (by the
> same thread) qemuDomainNestedJobAllowed(priv, job) is consulted
> if @job is allowed by job mask. But this function returns false
> (meaning sync @job is not allowed) which leads to a deadlock.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_domain.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index a60bca29ca..1b8fb71ba8 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -6414,7 +6414,9 @@ qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj)
>  static bool
>  qemuDomainNestedJobAllowed(qemuDomainObjPrivatePtr priv, qemuDomainJob job)
>  {
> -    return !priv->job.asyncJob || (priv->job.mask & JOB_MASK(job)) != 0;
> +    return !priv->job.asyncJob ||
> +        job == QEMU_JOB_NONE ||
> +        (priv->job.mask & JOB_MASK(job)) != 0;

I think the following alignment would be a bit better:

        return !priv->job.asyncJob ||
               job == QEMU_JOB_NONE ||
               (priv->job.mask & JOB_MASK(job)) != 0;

And I would probably put the job == QEMU_JOB_NONE check first, but it
doesn't make any functional difference.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list