qemu: Always assume support for QEMU_CAPS_CPU_CACHE

All supported qemu versions have this feature and it can't be compiled
out. The logic is a bit more complex in this instance as the flag is
asserted if:

    if (ARCH_IS_X86(qemuCaps->arch) &&
        virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) {
        virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE);
    }

Now QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION is available since qemu-2.8 but
only on certain architectures, thus we need to keep the flag itself, but
x86_64 is one of them.

The flag can be also assumed as qemuValidateDomainDefCpu rejects any
cache config on non-x86 arches.

Remove any use of the capability and drop the impossible test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-09-04 16:24:52 +02:00
parent 3ea514ee30
commit 917cf3e164
6 changed files with 6 additions and 114 deletions

View File

@ -6560,12 +6560,10 @@ qemuBuildCpuCommandLine(virCommand *cmd,
if (hostOff &&
(def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH ||
def->cpu->mode == VIR_CPU_MODE_MAXIMUM) &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_CACHE))
def->cpu->mode == VIR_CPU_MODE_MAXIMUM))
virBufferAddLit(&buf, ",host-cache-info=off");
if (l3Off &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_CACHE))
if (l3Off)
virBufferAddLit(&buf, ",l3-cache=off");
}

View File

@ -1,32 +0,0 @@
LC_ALL=C \
PATH=/bin \
HOME=/var/lib/libvirt/qemu/domain--1-foo \
USER=test \
LOGNAME=test \
XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-foo/.local/share \
XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-foo/.cache \
XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-foo/.config \
/usr/bin/qemu-system-x86_64 \
-name guest=foo,debug-threads=on \
-S \
-object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain--1-foo/master-key.aes \
-machine pc,usb=off,dump-guest-core=off \
-accel kvm \
-cpu host \
-m size=219136k \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-display none \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc \
-no-shutdown \
-no-acpi \
-boot strict=on \
-usb \
-audiodev '{"id":"audio1","driver":"none"}' \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on

View File

@ -1,20 +0,0 @@
<domain type='kvm'>
<name>foo</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<cpu mode='host-passthrough'>
<cache mode='disable'/>
</cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
</devices>
</domain>

View File

@ -1,32 +0,0 @@
LC_ALL=C \
PATH=/bin \
HOME=/var/lib/libvirt/qemu/domain--1-foo \
USER=test \
LOGNAME=test \
XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-foo/.local/share \
XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-foo/.cache \
XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-foo/.config \
/usr/bin/qemu-system-x86_64 \
-name guest=foo,debug-threads=on \
-S \
-object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain--1-foo/master-key.aes \
-machine pc,usb=off,dump-guest-core=off \
-accel kvm \
-cpu host,host-cache-info=on \
-m size=219136k \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-display none \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc \
-no-shutdown \
-no-acpi \
-boot strict=on \
-usb \
-audiodev '{"id":"audio1","driver":"none"}' \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on

View File

@ -1,20 +0,0 @@
<domain type='kvm'>
<name>foo</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<cpu mode='host-passthrough'>
<cache mode='passthrough'/>
</cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
</devices>
</domain>

View File

@ -2521,12 +2521,10 @@ mymain(void)
DO_TEST("cpu-check-default-partial", QEMU_CAPS_KVM);
DO_TEST("cpu-check-default-partial2", QEMU_CAPS_KVM);
DO_TEST("cpu-cache-disable", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
DO_TEST("cpu-cache-disable2", QEMU_CAPS_KVM);
DO_TEST("cpu-cache-disable3", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
DO_TEST("cpu-cache-passthrough", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
DO_TEST("cpu-cache-passthrough2", QEMU_CAPS_KVM);
DO_TEST("cpu-cache-emulate-l3", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE);
DO_TEST("cpu-cache-disable", QEMU_CAPS_KVM);
DO_TEST("cpu-cache-disable3", QEMU_CAPS_KVM);
DO_TEST("cpu-cache-passthrough", QEMU_CAPS_KVM);
DO_TEST("cpu-cache-emulate-l3", QEMU_CAPS_KVM);
DO_TEST_PARSE_ERROR("cpu-cache-emulate-l2", QEMU_CAPS_KVM);
DO_TEST_PARSE_ERROR("cpu-cache-passthrough3", QEMU_CAPS_KVM);
DO_TEST_PARSE_ERROR("cpu-cache-passthrough-l3", QEMU_CAPS_KVM);