[libvirt] [PATCH] qemu: fix operation job association when qemuCaps is NULL.

jcfaracco@gmail.com posted 1 patch 4 years, 7 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190921165522.14574-1-jcfaracco@gmail.com
src/qemu/qemu_migration_cookie.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[libvirt] [PATCH] qemu: fix operation job association when qemuCaps is NULL.
Posted by jcfaracco@gmail.com 4 years, 7 months ago
From: Julio Faracco <jcfaracco@gmail.com>

Function qemuMigrationEatCookie() calls
qemuMigrationCookieXMLParseStr(), when qemuCaps is not set, function
assumes priv as a NULL pointer. At the end, function tries to set
job info operation to the same current job. But, if priv is NULL due to
missing qemuCaps, code returns a Null Pointer Exception. This commit
adds an extra check to verify it.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 src/qemu/qemu_migration_cookie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 25d3fecd74..945b640e2c 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -1538,7 +1538,8 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
         }
     }
 
-    if (flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo)
+    if (flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo &&
+        priv && priv->job.current)
         mig->jobInfo->operation = priv->job.current->operation;
 
     return mig;
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: fix operation job association when qemuCaps is NULL.
Posted by Jiri Denemark 4 years, 7 months ago
On Sat, Sep 21, 2019 at 13:55:22 -0300, jcfaracco@gmail.com wrote:
> From: Julio Faracco <jcfaracco@gmail.com>
> 
> Function qemuMigrationEatCookie() calls
> qemuMigrationCookieXMLParseStr(), when qemuCaps is not set, function
> assumes priv as a NULL pointer. At the end, function tries to set
> job info operation to the same current job. But, if priv is NULL due to
> missing qemuCaps, code returns a Null Pointer Exception. This commit
> adds an extra check to verify it.
> 
> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  src/qemu/qemu_migration_cookie.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
> index 25d3fecd74..945b640e2c 100644
> --- a/src/qemu/qemu_migration_cookie.c
> +++ b/src/qemu/qemu_migration_cookie.c
> @@ -1538,7 +1538,8 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
>          }
>      }
>  
> -    if (flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo)
> +    if (flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo &&
> +        priv && priv->job.current)
>          mig->jobInfo->operation = priv->job.current->operation;

Did you actually hit this somehow? If so, please provide a full
backtrace as the problem lies somewhere else and it should be fixed in a
different way. This would just hide incorrect usage of
qemuMigrationEatCookie, in which case it's better to crash.

Jirka

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