cpuCompare: Fix crash on unexpected CPU XML

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

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

libvirt would happily crash without warning.
This commit is contained in:
Jiri Denemark 2010-07-12 17:30:23 +02:00
parent 517aba9fac
commit f5055f2310

View File

@ -90,6 +90,12 @@ cpuCompareXML(virCPUDefPtr host,
if (cpu == NULL) if (cpu == NULL)
goto cleanup; goto cleanup;
if (!cpu->model) {
virCPUReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("no CPU model specified"));
goto cleanup;
}
ret = cpuCompare(host, cpu); ret = cpuCompare(host, cpu);
cleanup: cleanup: