Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
libvirt.29155
1c1a7cdd-qemu-Add-support-for-max-physical-addr...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1c1a7cdd-qemu-Add-support-for-max-physical-address-size.patch of Package libvirt.29155
From a3deb2aa7ac655c8449b15c7f0e3c3f3c937d986 Mon Sep 17 00:00:00 2001 From: Dario Faggioli <dfaggioli@suse.com> Date: Fri, 29 Jul 2022 13:34:35 -0600 Subject: [PATCH 4/9] qemu: Add support for max physical address size This patch maps /domain/cpu/maxphysaddr into -cpu parameters: - <maxphysaddr mode='passthrough'/> becomes host-phys-bits=on - <maxphysaddr mode='emualte' bits='42'/> becomes phys-bits=42 Passthrough mode can only be used if the chosen CPU model is 'host-passthrough'. Also validate that an explicitly specified bits value does not exceed the physical address bits on the host. The feature is available since QEMU 2.7.0. Signed-off-by: Dario Faggioli <dfaggioli@suse.com> Signed-off-by: Jim Fehlig <jfehlig@suse.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> (cherry picked from commit 1c1a7cdd4096c59fb0c374529e1e5aea8d43ee9c) Conflicts: tests/qemuxml2argvtest.c --- src/qemu/qemu_command.c | 17 ++++++++++ src/qemu/qemu_validate.c | 8 +++++ .../cpu-phys-bits-emulate.args | 32 +++++++++++++++++++ .../cpu-phys-bits-emulate.xml | 20 ++++++++++++ .../cpu-phys-bits-emulate2.args | 32 +++++++++++++++++++ .../cpu-phys-bits-emulate2.xml | 20 ++++++++++++ .../cpu-phys-bits-emulate3.err | 1 + .../cpu-phys-bits-emulate3.xml | 20 ++++++++++++ .../cpu-phys-bits-passthrough.args | 32 +++++++++++++++++++ .../cpu-phys-bits-passthrough.xml | 20 ++++++++++++ .../cpu-phys-bits-passthrough2.err | 1 + .../cpu-phys-bits-passthrough2.xml | 20 ++++++++++++ .../cpu-phys-bits-passthrough3.err | 1 + .../cpu-phys-bits-passthrough3.xml | 20 ++++++++++++ tests/qemuxml2argvtest.c | 7 ++++ 15 files changed, 251 insertions(+) create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate.args create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate.xml create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate2.args create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate2.xml create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-passthrough.args create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-passthrough.xml create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-passthrough2.err create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-passthrough2.xml create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-passthrough3.err create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-passthrough3.xml Index: libvirt-8.0.0/src/qemu/qemu_command.c =================================================================== --- libvirt-8.0.0.orig/src/qemu/qemu_command.c +++ libvirt-8.0.0/src/qemu/qemu_command.c @@ -6844,6 +6844,23 @@ qemuBuildCpuCommandLine(virCommand *cmd, virBufferAddLit(&buf, ",l3-cache=off"); } + if (def->cpu && def->cpu->addr) { + virCPUMaxPhysAddrDef *addr = def->cpu->addr; + + switch (addr->mode) { + case VIR_CPU_MAX_PHYS_ADDR_MODE_PASSTHROUGH: + virBufferAddLit(&buf, ",host-phys-bits=on"); + break; + + case VIR_CPU_MAX_PHYS_ADDR_MODE_EMULATE: + virBufferAsprintf(&buf, ",phys-bits=%d", addr->bits); + break; + + case VIR_CPU_MAX_PHYS_ADDR_MODE_LAST: + break; + } + } + cpu = virBufferContentAndReset(&cpu_buf); cpu_flags = virBufferContentAndReset(&buf); Index: libvirt-8.0.0/src/qemu/qemu_validate.c =================================================================== --- libvirt-8.0.0.orig/src/qemu/qemu_validate.c +++ libvirt-8.0.0/src/qemu/qemu_validate.c @@ -374,6 +374,14 @@ qemuValidateDomainDefCpu(virQEMUDriver * virCPUMaxPhysAddrModeTypeToString(VIR_CPU_MAX_PHYS_ADDR_MODE_EMULATE)); return -1; } + + if (driver->hostcpu && + driver->hostcpu->addr && + cpu->addr->bits > driver->hostcpu->addr->bits) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("The number of virtual CPU address bits cannot exceed the number supported by the host CPU")); + return -1; + } break; case VIR_CPU_MAX_PHYS_ADDR_MODE_LAST: Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate.args =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-foo \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-foo/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-foo/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-foo/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=foo,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-foo/master-key.aes \ +-machine pc,usb=off,dump-guest-core=off \ +-accel kvm \ +-cpu host,phys-bits=42 \ +-m 214 \ +-realtime mlock=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,path=/tmp/lib/domain--1-foo/monitor.sock,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-usb \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-msg timestamp=on Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate.xml =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate.xml @@ -0,0 +1,20 @@ +<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'> + <maxphysaddr mode='emulate' bits='42'/> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + </devices> +</domain> Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate2.args =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate2.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-foo \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-foo/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-foo/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-foo/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=foo,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-foo/master-key.aes \ +-machine pc,usb=off,dump-guest-core=off \ +-accel kvm \ +-cpu core2duo,ds=on,acpi=on,ss=on,ht=on,tm=on,pbe=on,ds-cpl=on,vmx=on,est=on,tm2=on,cx16=on,xtpr=on,lahf-lm=on,phys-bits=42 \ +-m 214 \ +-realtime mlock=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,path=/tmp/lib/domain--1-foo/monitor.sock,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-usb \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-msg timestamp=on Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate2.xml =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate2.xml @@ -0,0 +1,20 @@ +<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-model'> + <maxphysaddr bits='42' mode='emulate'/> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + </devices> +</domain> Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.err @@ -0,0 +1 @@ +unsupported configuration: if using CPU maximum physical address mode='emulate', bits= must be specified too Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-emulate3.xml @@ -0,0 +1,20 @@ +<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'> + <maxphysaddr mode='emulate'/> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + </devices> +</domain> Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough.args =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-foo \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-foo/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-foo/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-foo/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=foo,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-foo/master-key.aes \ +-machine pc,usb=off,dump-guest-core=off \ +-accel kvm \ +-cpu host,host-phys-bits=on \ +-m 214 \ +-realtime mlock=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,path=/tmp/lib/domain--1-foo/monitor.sock,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-usb \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-msg timestamp=on Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough.xml =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough.xml @@ -0,0 +1,20 @@ +<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'> + <maxphysaddr mode='passthrough'/> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + </devices> +</domain> Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough2.err =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough2.err @@ -0,0 +1 @@ +unsupported configuration: CPU maximum physical address bits mode 'passthrough' can only be used with 'host-passthrough' CPUs Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough2.xml =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough2.xml @@ -0,0 +1,20 @@ +<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-model'> + <maxphysaddr mode='passthrough'/> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + </devices> +</domain> Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough3.err =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough3.err @@ -0,0 +1 @@ +unsupported configuration: CPU maximum physical address bits number specification cannot be used with mode='passthrough' Index: libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough3.xml =================================================================== --- /dev/null +++ libvirt-8.0.0/tests/qemuxml2argvdata/cpu-phys-bits-passthrough3.xml @@ -0,0 +1,20 @@ +<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'> + <maxphysaddr mode='passthrough' bits='42'/> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + </devices> +</domain> Index: libvirt-8.0.0/tests/qemuxml2argvtest.c =================================================================== --- libvirt-8.0.0.orig/tests/qemuxml2argvtest.c +++ libvirt-8.0.0/tests/qemuxml2argvtest.c @@ -3489,6 +3489,13 @@ mymain(void) DO_TEST_CAPS_LATEST("devices-acpi-index"); + DO_TEST("cpu-phys-bits-passthrough", QEMU_CAPS_KVM); + DO_TEST("cpu-phys-bits-emulate", QEMU_CAPS_KVM); + DO_TEST("cpu-phys-bits-emulate2", QEMU_CAPS_KVM); + DO_TEST_PARSE_ERROR("cpu-phys-bits-emulate3", QEMU_CAPS_KVM); + DO_TEST_PARSE_ERROR("cpu-phys-bits-passthrough2", QEMU_CAPS_KVM); + DO_TEST_PARSE_ERROR("cpu-phys-bits-passthrough3", QEMU_CAPS_KVM); + if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor