提交 c2c43912 编写于 作者: J Jiri Denemark

qemu: Fix crash in qemucapsprobe

The qemucapsprobe helper calls virQEMUCapsNewForBinaryInternal with
caps == NULL, causing the following crash:

    Program received signal SIGSEGV, Segmentation fault.
    #0  0x00007ffff788775f in virQEMUCapsInitHostCPUModel
        (qemuCaps=qemuCaps@entry=0x649680, host=host@entry=0x10) at
        src/qemu/qemu_capabilities.c:2969
    #1  0x00007ffff7889dbf in virQEMUCapsNewForBinaryInternal
        (caps=caps@entry=0x0, binary=<optimized out>,
        libDir=libDir@entry=0x4033f6 "/tmp", cacheDir=cacheDir@entry=0x0,
        runUid=runUid@entry=4294967295, runGid=runGid@entry=4294967295,
        qmpOnly=true) at src/qemu/qemu_capabilities.c:4039
    #2  0x0000000000401702 in main (argc=2, argv=0x7fffffffd968) at
        tests/qemucapsprobe.c:73

Caused by v2.2.0-182-g68c70118.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 3193a594
......@@ -2962,14 +2962,17 @@ virQEMUCapsCPUFilterFeatures(const char *name,
void
virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
virCapsHostPtr host)
virCapsPtr caps)
{
virCPUDefPtr cpu = NULL;
if (!virQEMUCapsGuestIsNative(host->arch, qemuCaps->arch))
if (!caps)
return;
if (!virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch))
goto error;
if (host->cpu && host->cpu->model) {
if (caps->host.cpu && caps->host.cpu->model) {
if (VIR_ALLOC(cpu) < 0)
goto error;
......@@ -2978,7 +2981,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
cpu->mode = VIR_CPU_MODE_CUSTOM;
cpu->match = VIR_CPU_MATCH_EXACT;
if (virCPUDefCopyModelFilter(cpu, host->cpu, true,
if (virCPUDefCopyModelFilter(cpu, caps->host.cpu, true,
virQEMUCapsCPUFilterFeatures, NULL) < 0)
goto error;
}
......@@ -3248,7 +3251,7 @@ virQEMUCapsLoadCache(virCapsPtr caps,
}
VIR_FREE(nodes);
virQEMUCapsInitHostCPUModel(qemuCaps, &caps->host);
virQEMUCapsInitHostCPUModel(qemuCaps, caps);
ret = 0;
cleanup:
......@@ -4036,7 +4039,7 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
virQEMUCapsRememberCached(qemuCaps, cacheDir) < 0)
goto error;
virQEMUCapsInitHostCPUModel(qemuCaps, &caps->host);
virQEMUCapsInitHostCPUModel(qemuCaps, caps);
}
cleanup:
......
......@@ -64,5 +64,5 @@ virQEMUCapsSetArch(virQEMUCapsPtr qemuCaps,
void
virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
virCapsHostPtr host);
virCapsPtr caps);
#endif
......@@ -357,7 +357,7 @@ testUpdateQEMUCaps(const struct testInfo *info,
if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
goto cleanup;
virQEMUCapsInitHostCPUModel(info->qemuCaps, &caps->host);
virQEMUCapsInitHostCPUModel(info->qemuCaps, caps);
virQEMUCapsFilterByMachineType(info->qemuCaps, vm->def->os.machine);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册