]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Add support for guest CPU cache
authorJiri Denemark <jdenemar@redhat.com>
Tue, 25 Apr 2017 17:07:19 +0000 (19:07 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 27 Apr 2017 20:41:10 +0000 (22:41 +0200)
commitdf13c0b477ffda460eed259c3b8aab7255f11199
treefba61cbf01d89a704892f189cbb9cf1740b4518f
parenta646a6016a7c62688988f7cfaa22e1340c2ce761
qemu: Add support for guest CPU cache

This patch maps /domain/cpu/cache element into -cpu parameters:

- <cache mode='passthrough'/> is translated to host-cache-info=on
- <cache level='3' mode='emulate'/> is transformed into l3-cache=on
- <cache mode='disable'/> is turned in host-cache-info=off,l3-cache=off

Any other <cache> element is forbidden.

The tricky part is detecting whether QEMU supports the CPU properties.

The 'host-cache-info' property is introduced in v2.4.0-1389-ge265e3e480,
earlier QEMU releases enabled host-cache-info by default and had no way
to disable it. If the property is present, it defaults to 'off' for any
QEMU until at least 2.9.0.

The 'l3-cache' property was introduced later by v2.7.0-200-g14c985cffa.
Earlier versions worked as if l3-cache=off was passed. For any QEMU
until at least 2.9.0 l3-cache is 'off' by default.

QEMU 2.9.0 was the first release which supports probing both properties
by running device-list-properties with typename=host-x86_64-cpu. Older
QEMU releases did not support device-list-properties command for CPU
devices. Thus we can't really rely on probing them and we can just use
query-cpu-model-expansion QMP command as a witness.

Because the cache property probing is only reliable for QEMU >= 2.9.0
when both are already supported for quite a few releases, we let QEMU
report an error if a specific cache mode is explicitly requested. The
other mode (or both if a user requested CPU cache to be disabled) is
explicitly turned off for QEMU >= 2.9.0 to avoid any surprises in case
the QEMU defaults change. Any older QEMU already turns them off so not
doing so explicitly does not make any harm.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
21 files changed:
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l2.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough-l3.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough3.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c