render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From d0a2e30fb26302eaaa5efa0f2d1d1fbe7853934a Mon Sep 17 00:00:00 2001
Message-Id: <d0a2e30fb26302eaaa5efa0f2d1d1fbe7853934a@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Wed, 2 Jul 2014 10:35:31 +0200
Subject: [PATCH] Fix segfault when starting a domain with no cpu definition

My commit fba6bc4 iterated over the features in cpu definition
without checking if there is one.

(cherry picked from commit 1cd8f500ee133653ecb9d1b7f72b2b2e9870a1c3)
https://bugzilla.redhat.com/show_bug.cgi?id=1185458
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_migration.c | 2 +-
 src/qemu/qemu_process.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index d979d50..2e495a8 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1506,7 +1506,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
         return false;
     }
 
-    for (i = 0; i < def->cpu->nfeatures; i++) {
+    for (i = 0; def->cpu && i < def->cpu->nfeatures; i++) {
         virCPUFeatureDefPtr feature = &def->cpu->features[i];
 
         if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 8c07397..11d5af5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3540,7 +3540,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm)
             }
         }
 
-        for (i = 0; i < def->cpu->nfeatures; i++) {
+        for (i = 0; def->cpu && i < def->cpu->nfeatures; i++) {
             virCPUFeatureDefPtr feature = &def->cpu->features[i];
 
             if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
-- 
2.2.2