[libvirt] [PATCH] qemu: Don't try to update undefined guest CPU

Jiri Denemark posted 1 patch 7 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/c74207cb182f0af7ea626579f5be3be48fc9c2d4.1489997553.git.jdenemar@redhat.com
src/qemu/qemu_process.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
[libvirt] [PATCH] qemu: Don't try to update undefined guest CPU
Posted by Jiri Denemark 7 years, 1 month ago
Calling virCPUUpdateLive on a domain with no guest CPU configuration
does not make sense. Especially when doing so would crash libvirtd.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_process.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 780f9587a..ec0e36d2e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3815,11 +3815,6 @@ qemuProcessVerifyCPUFeatures(virDomainDefPtr def,
 {
     int rc;
 
-    if (!def->cpu ||
-        (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
-         !def->cpu->model))
-        return 0;
-
     rc = virCPUCheckFeature(def->os.arch, def->cpu, "invtsc");
 
     if (rc < 0) {
@@ -3870,6 +3865,13 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
             qemuProcessVerifyHypervFeatures(def, cpu) < 0)
             goto cleanup;
 
+        if (!def->cpu ||
+            (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
+             !def->cpu->model)) {
+            ret = 0;
+            goto cleanup;
+        }
+
         if (qemuProcessVerifyCPUFeatures(def, cpu) < 0)
             goto cleanup;
 
-- 
2.12.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Don't try to update undefined guest CPU
Posted by Laine Stump 7 years, 1 month ago
On 03/20/2017 04:12 AM, Jiri Denemark wrote:
> Calling virCPUUpdateLive on a domain with no guest CPU configuration
> does not make sense. Especially when doing so would crash libvirtd.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_process.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)

ACK. This fixed the crash for me.
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index 780f9587a..ec0e36d2e 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -3815,11 +3815,6 @@ qemuProcessVerifyCPUFeatures(virDomainDefPtr def,
>  {
>      int rc;
>  
> -    if (!def->cpu ||
> -        (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
> -         !def->cpu->model))
> -        return 0;
> -
>      rc = virCPUCheckFeature(def->os.arch, def->cpu, "invtsc");
>  
>      if (rc < 0) {
> @@ -3870,6 +3865,13 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
>              qemuProcessVerifyHypervFeatures(def, cpu) < 0)
>              goto cleanup;
>  
> +        if (!def->cpu ||
> +            (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
> +             !def->cpu->model)) {
> +            ret = 0;
> +            goto cleanup;
> +        }
> +
>          if (qemuProcessVerifyCPUFeatures(def, cpu) < 0)
>              goto cleanup;
>  
> 

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