mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
qemu: Add KVM CPUs into cache only if KVM is present
virQEMUCapsFormatCache/virQEMUCapsLoadCache adds/reads KVM CPUs to/from capabilities cache regardless of QEMU_CAPS_KVM. That can cause undesired side-effects when KVM CPUs are present in the cache on a platform that doesn't support it, e.g. macOS or Linux without KVM support. Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com> Signed-off-by: Andrea Bolognani <abologna@redhat.com> Tested-by: Brad Laue <brad@brad-x.com> Tested-by: Christophe Fergeau <cfergeau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
8885cd9a76
commit
4794458c8d
@ -4411,8 +4411,11 @@ virQEMUCapsLoadCache(virArch hostArch,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 ||
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
|
||||||
virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0)
|
virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virQEMUCapsParseGIC(qemuCaps, ctxt) < 0)
|
if (virQEMUCapsParseGIC(qemuCaps, ctxt) < 0)
|
||||||
@ -4421,7 +4424,8 @@ virQEMUCapsLoadCache(virArch hostArch,
|
|||||||
if (virQEMUCapsParseSEVInfo(qemuCaps, ctxt) < 0)
|
if (virQEMUCapsParseSEVInfo(qemuCaps, ctxt) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||||
|
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
|
||||||
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
|
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
|
||||||
|
|
||||||
if (virXPathBoolean("boolean(./kvmSupportsNesting)", ctxt) > 0)
|
if (virXPathBoolean("boolean(./kvmSupportsNesting)", ctxt) > 0)
|
||||||
@ -4654,7 +4658,8 @@ virQEMUCapsFormatCache(virQEMUCaps *qemuCaps)
|
|||||||
virBufferAsprintf(&buf, "<arch>%s</arch>\n",
|
virBufferAsprintf(&buf, "<arch>%s</arch>\n",
|
||||||
virArchToString(qemuCaps->arch));
|
virArchToString(qemuCaps->arch));
|
||||||
|
|
||||||
virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM);
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||||
|
virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM);
|
||||||
virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU);
|
virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU);
|
||||||
|
|
||||||
for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
|
for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
|
||||||
@ -5508,7 +5513,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
|
|||||||
qemuCaps->libvirtCtime = virGetSelfLastChanged();
|
qemuCaps->libvirtCtime = virGetSelfLastChanged();
|
||||||
qemuCaps->libvirtVersion = LIBVIR_VERSION_NUMBER;
|
qemuCaps->libvirtVersion = LIBVIR_VERSION_NUMBER;
|
||||||
|
|
||||||
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||||
|
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
|
||||||
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
|
virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
|
||||||
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user