libvirt/src/cpu
Jim Fehlig 541e9ae6d4 cpu_x86: fix libvirtd crash when host cpu vendor is not available
When starting a guest and copying host vendor cpuid to the guest
cpu, libvirtd would crash if the host cpu contained a NULL vendor
field. Avoid the crash by checking for a valid vendor in the host
cpu before copying the cpuid to the guest cpu.

For completeness, here is a backtrace from the crash

(gdb) bt
f0  0x00007ffff739bf33 in x86DataCpuid (cpuid=0x8, cpuid=0x8,
    data=data@entry=0x7fffb800ee78) at cpu/cpu_x86.c:287
f1  virCPUx86DataAddCPUID (data=data@entry=0x7fffb800ee78, cpuid=0x8)
    at cpu/cpu_x86.c:355
f2  0x00007ffff739ef47 in x86Compute (host=<optimized out>, cpu=0x7fffb8000cc0,
    guest=0x7fffecca7348, message=<optimized out>) at cpu/cpu_x86.c:1580
f3  0x00007fffd2b38e53 in qemuBuildCpuModelArgStr (migrating=false,
    hasHwVirt=<synthetic pointer>, qemuCaps=0x7fffb8001040, buf=0x7fffecca7360,
    def=0x7fffc400ce20, driver=0x1c) at qemu/qemu_command.c:6283
f4  qemuBuildCpuCommandLine (cmd=cmd@entry=0x7fffb8002f60,
    driver=driver@entry=0x7fffc80882c0, def=def@entry=0x7fffc400ce20,
    qemuCaps=qemuCaps@entry=0x7fffb8001040, migrating=<optimized out>)
    at qemu/qemu_command.c:6445
(gdb) f2
(gdb) p *host_model
$23 = {name = 0x7fffb800ec50 "qemu64", vendor = 0x0, signature = 0, data = {
    len = 2, data = 0x7fffb800e720}}
2016-08-12 18:47:53 -06:00
..
cpu_arm.c cpu: Consolidate ARM drivers 2016-06-25 00:02:30 +02:00
cpu_arm.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
cpu_map.c cpu: Rework CPU map loading 2016-05-20 09:18:56 +02:00
cpu_map.h cpu: Rework CPU map loading 2016-05-20 09:18:56 +02:00
cpu_map.xml cpu_map.xml: add cmt/mbm feature to x86 2016-06-25 00:23:58 +02:00
cpu_ppc64_data.h cpu_ppc64: Avoid unnecessary pointer to virCPUppc64Data 2016-06-09 09:47:56 +02:00
cpu_ppc64.c cpu_ppc64: Avoid unnecessary pointer to virCPUppc64Data 2016-06-09 09:47:56 +02:00
cpu_ppc64.h cpu: Rename {powerpc,ppc} => ppc64 (exported symbols) 2015-08-05 13:30:16 +02:00
cpu_s390.c cpu: Bugfix for s390 CPU driver to return a host CPU model 2015-01-12 15:08:29 +01:00
cpu_s390.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
cpu_x86_data.h cpu_x86: Prepare for ecx_in CPUID parameter 2016-06-09 10:03:38 +02:00
cpu_x86.c cpu_x86: fix libvirtd crash when host cpu vendor is not available 2016-08-12 18:47:53 -06:00
cpu_x86.h cpu_x86: Avoid unnecessary pointers to virCPUx86Data 2016-06-09 09:47:56 +02:00
cpu.c cpu: Drop NR_DRIVERS macro 2016-07-01 12:20:54 +02:00
cpu.h cpu_ppc64: Avoid unnecessary pointer to virCPUppc64Data 2016-06-09 09:47:56 +02:00