898951
From d0a2e30fb26302eaaa5efa0f2d1d1fbe7853934a Mon Sep 17 00:00:00 2001
898951
Message-Id: <d0a2e30fb26302eaaa5efa0f2d1d1fbe7853934a@dist-git>
898951
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
898951
Date: Wed, 2 Jul 2014 10:35:31 +0200
898951
Subject: [PATCH] Fix segfault when starting a domain with no cpu definition
898951
898951
My commit fba6bc4 iterated over the features in cpu definition
898951
without checking if there is one.
898951
898951
(cherry picked from commit 1cd8f500ee133653ecb9d1b7f72b2b2e9870a1c3)
898951
https://bugzilla.redhat.com/show_bug.cgi?id=1185458
898951
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
898951
---
898951
 src/qemu/qemu_migration.c | 2 +-
898951
 src/qemu/qemu_process.c   | 2 +-
898951
 2 files changed, 2 insertions(+), 2 deletions(-)
898951
898951
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
898951
index d979d50..2e495a8 100644
898951
--- a/src/qemu/qemu_migration.c
898951
+++ b/src/qemu/qemu_migration.c
898951
@@ -1506,7 +1506,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
898951
         return false;
898951
     }
898951
 
898951
-    for (i = 0; i < def->cpu->nfeatures; i++) {
898951
+    for (i = 0; def->cpu && i < def->cpu->nfeatures; i++) {
898951
         virCPUFeatureDefPtr feature = &def->cpu->features[i];
898951
 
898951
         if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
898951
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
898951
index 8c07397..11d5af5 100644
898951
--- a/src/qemu/qemu_process.c
898951
+++ b/src/qemu/qemu_process.c
898951
@@ -3540,7 +3540,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm)
898951
             }
898951
         }
898951
 
898951
-        for (i = 0; i < def->cpu->nfeatures; i++) {
898951
+        for (i = 0; def->cpu && i < def->cpu->nfeatures; i++) {
898951
             virCPUFeatureDefPtr feature = &def->cpu->features[i];
898951
 
898951
             if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
898951
-- 
898951
2.2.2
898951