Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > ebe084c140192657f9094e135a84202c > files > 75

libvirt-0.8.2-29.el5.src.rpm

From 2b4e71ffb2783b891b738d4840460a01922c929c Mon Sep 17 00:00:00 2001
Message-Id: <2b4e71ffb2783b891b738d4840460a01922c929c.1284409900.git.jdenemar@redhat.com>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Mon, 12 Jul 2010 17:30:23 +0200
Subject: [PATCH] cpuCompare: Fix crash on unexpected CPU XML

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=630618

When comparing a CPU without <model> element, such as

    <cpu>
        <topology sockets='1' cores='1' threads='1'/>
    </cpu>

libvirt would happily crash without warning.
(cherry picked from commit f5055f2310950633510dd808d1b67123e13d6f03)
---
 src/cpu/cpu.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 8d6c22b..5895a90 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -90,6 +90,12 @@ cpuCompareXML(virCPUDefPtr host,
     if (cpu == NULL)
         goto cleanup;
 
+    if (!cpu->model) {
+        virCPUReportError(VIR_ERR_OPERATION_INVALID,
+                "%s", _("no CPU model specified"));
+        goto cleanup;
+    }
+
     ret = cpuCompare(host, cpu);
 
 cleanup:
-- 
1.7.2.2