aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/test_mem_addr_space.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/test_mem_addr_space.py')
-rwxr-xr-xtests/functional/test_mem_addr_space.py97
1 files changed, 66 insertions, 31 deletions
diff --git a/tests/functional/test_mem_addr_space.py b/tests/functional/test_mem_addr_space.py
index bb0cf06..61b4a19 100755
--- a/tests/functional/test_mem_addr_space.py
+++ b/tests/functional/test_mem_addr_space.py
@@ -20,6 +20,25 @@ class MemAddrCheck(QemuSystemTest):
# this reason.
DELAY_Q35_BOOT_SEQUENCE = 1
+ # This helper can go away when the 32-bit host deprecation
+ # turns into full & final removal of support.
+ def ensure_64bit_binary(self):
+ with open(self.qemu_bin, "rb") as fh:
+ ident = fh.read(4)
+
+ # "\x7fELF"
+ if ident != bytes([0x7f, 0x45, 0x4C, 0x46]):
+ # Non-ELF file implies macOS or Windows which
+ # we already assume to be 64-bit only
+ return
+
+ # bits == 1 -> 32-bit; bits == 2 -> 64-bit
+ bits = int.from_bytes(fh.read(1), byteorder='little')
+ if bits != 2:
+ # 32-bit ELF builds won't be able to address sufficient
+ # RAM to run the tests
+ self.skipTest("64-bit build host is required")
+
# first, lets test some 32-bit processors.
# for all 32-bit cases, pci64_hole_size is 0.
def test_phybits_low_pse36(self):
@@ -38,8 +57,9 @@ class MemAddrCheck(QemuSystemTest):
If maxmem is set to 59.5G with all other QEMU parameters identical, QEMU
should start fine.
"""
- self.vm.add_args('-S', '-machine', 'q35', '-m',
- '512,slots=1,maxmem=59.6G',
+ self.ensure_64bit_binary()
+ self.set_machine('q35')
+ self.vm.add_args('-S', '-m', '512,slots=1,maxmem=59.6G',
'-cpu', 'pentium,pse36=on', '-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -55,8 +75,9 @@ class MemAddrCheck(QemuSystemTest):
access up to a maximum of 64GiB of memory. Rest is the same as the case
with pse36 above.
"""
- self.vm.add_args('-S', '-machine', 'q35', '-m',
- '512,slots=1,maxmem=59.6G',
+ self.ensure_64bit_binary()
+ self.set_machine('q35')
+ self.vm.add_args('-S', '-m', '512,slots=1,maxmem=59.6G',
'-cpu', 'pentium,pae=on', '-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -71,8 +92,9 @@ class MemAddrCheck(QemuSystemTest):
Setting maxmem to 59.5G and making sure that QEMU can start with the
same options as the failing case above with pse36 cpu feature.
"""
- self.vm.add_args('-machine', 'q35', '-m',
- '512,slots=1,maxmem=59.5G',
+ self.ensure_64bit_binary()
+ self.set_machine('q35')
+ self.vm.add_args('-m', '512,slots=1,maxmem=59.5G',
'-cpu', 'pentium,pse36=on', '-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -88,8 +110,9 @@ class MemAddrCheck(QemuSystemTest):
Setting maxmem to 59.5G and making sure that QEMU can start fine
with the same options as the case above.
"""
- self.vm.add_args('-machine', 'q35', '-m',
- '512,slots=1,maxmem=59.5G',
+ self.ensure_64bit_binary()
+ self.set_machine('q35')
+ self.vm.add_args('-m', '512,slots=1,maxmem=59.5G',
'-cpu', 'pentium,pae=on', '-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -104,8 +127,9 @@ class MemAddrCheck(QemuSystemTest):
Pentium2 has 36 bits of addressing, so its same as pentium
with pse36 ON.
"""
- self.vm.add_args('-machine', 'q35', '-m',
- '512,slots=1,maxmem=59.5G',
+ self.ensure_64bit_binary()
+ self.set_machine('q35')
+ self.vm.add_args('-m', '512,slots=1,maxmem=59.5G',
'-cpu', 'pentium2', '-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -123,8 +147,9 @@ class MemAddrCheck(QemuSystemTest):
message because the region for memory hotplug is always placed
above 4 GiB due to the PCI hole and simplicity.
"""
- self.vm.add_args('-S', '-machine', 'q35', '-m',
- '512,slots=1,maxmem=4G',
+ self.ensure_64bit_binary()
+ self.set_machine('q35')
+ self.vm.add_args('-S', '-m', '512,slots=1,maxmem=4G',
'-cpu', 'pentium', '-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -150,8 +175,9 @@ class MemAddrCheck(QemuSystemTest):
which is equal to 987.5 GiB. Setting the value to 988 GiB should
make QEMU fail with the error message.
"""
- self.vm.add_args('-S', '-machine', 'pc-q35-7.0', '-m',
- '512,slots=1,maxmem=988G',
+ self.ensure_64bit_binary()
+ self.set_machine('pc-q35-7.0')
+ self.vm.add_args('-S', '-m', '512,slots=1,maxmem=988G',
'-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -170,8 +196,9 @@ class MemAddrCheck(QemuSystemTest):
Make sure QEMU fails when maxmem size is 976 GiB (12 GiB less
than 988 GiB).
"""
- self.vm.add_args('-S', '-machine', 'pc-q35-7.1', '-m',
- '512,slots=1,maxmem=976G',
+ self.ensure_64bit_binary()
+ self.set_machine('pc-q35-7.1')
+ self.vm.add_args('-S', '-m', '512,slots=1,maxmem=976G',
'-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -186,8 +213,9 @@ class MemAddrCheck(QemuSystemTest):
Same as q35-7.0 AMD case except that here we check that QEMU can
successfully start when maxmem is < 988G.
"""
- self.vm.add_args('-S', '-machine', 'pc-q35-7.0', '-m',
- '512,slots=1,maxmem=987.5G',
+ self.ensure_64bit_binary()
+ self.set_machine('pc-q35-7.0')
+ self.vm.add_args('-S', '-m', '512,slots=1,maxmem=987.5G',
'-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -202,8 +230,9 @@ class MemAddrCheck(QemuSystemTest):
Same as q35-7.1 AMD case except that here we check that QEMU can
successfully start when maxmem is < 976G.
"""
- self.vm.add_args('-S', '-machine', 'pc-q35-7.1', '-m',
- '512,slots=1,maxmem=975.5G',
+ self.ensure_64bit_binary()
+ self.set_machine('pc-q35-7.1')
+ self.vm.add_args('-S', '-m', '512,slots=1,maxmem=975.5G',
'-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -219,9 +248,10 @@ class MemAddrCheck(QemuSystemTest):
Intel cpu instead. QEMU should start fine in this case as
"above_4G" memory starts at 4G.
"""
+ self.ensure_64bit_binary()
+ self.set_machine('pc-q35-7.1')
self.vm.add_args('-S', '-cpu', 'Skylake-Server',
- '-machine', 'pc-q35-7.1', '-m',
- '512,slots=1,maxmem=976G',
+ '-m', '512,slots=1,maxmem=976G',
'-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -243,9 +273,10 @@ class MemAddrCheck(QemuSystemTest):
memory for the VM (1024 - 32 - 1 + 0.5). With 992 GiB, QEMU should
fail to start.
"""
+ self.ensure_64bit_binary()
+ self.set_machine('pc-q35-7.1')
self.vm.add_args('-S', '-cpu', 'EPYC-v4,phys-bits=41',
- '-machine', 'pc-q35-7.1', '-m',
- '512,slots=1,maxmem=992G',
+ '-m', '512,slots=1,maxmem=992G',
'-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -261,9 +292,10 @@ class MemAddrCheck(QemuSystemTest):
Same as above but by setting maxram between 976 GiB and 992 Gib,
QEMU should start fine.
"""
+ self.ensure_64bit_binary()
+ self.set_machine('pc-q35-7.1')
self.vm.add_args('-S', '-cpu', 'EPYC-v4,phys-bits=41',
- '-machine', 'pc-q35-7.1', '-m',
- '512,slots=1,maxmem=990G',
+ '-m', '512,slots=1,maxmem=990G',
'-display', 'none',
'-object', 'memory-backend-ram,id=mem1,size=1G',
'-device', 'pc-dimm,id=vm0,memdev=mem1')
@@ -281,12 +313,13 @@ class MemAddrCheck(QemuSystemTest):
So maxmem here should be at most 986 GiB considering all memory boundary
alignment constraints with 40 bits (1 TiB) of processor physical bits.
"""
+ self.ensure_64bit_binary()
+ self.set_machine('q35')
self.vm.add_args('-S', '-cpu', 'Skylake-Server,phys-bits=40',
- '-machine', 'q35,cxl=on', '-m',
- '512,slots=1,maxmem=987G',
+ '-m', '512,slots=1,maxmem=987G',
'-display', 'none',
'-device', 'pxb-cxl,bus_nr=12,bus=pcie.0,id=cxl.1',
- '-M', 'cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.size=1G')
+ '-M', 'cxl=on,cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.size=1G')
self.vm.set_qmp_monitor(enabled=False)
self.vm.launch()
self.vm.wait()
@@ -299,9 +332,11 @@ class MemAddrCheck(QemuSystemTest):
with the exact same parameters as above, QEMU should start fine even
with cxl enabled.
"""
+ self.ensure_64bit_binary()
+ self.set_machine('q35')
self.vm.add_args('-S', '-cpu', 'Skylake-Server,phys-bits=40',
- '-machine', 'q35,cxl=on', '-m',
- '512,slots=1,maxmem=987G',
+ '-machine', 'cxl=on',
+ '-m', '512,slots=1,maxmem=987G',
'-display', 'none',
'-device', 'pxb-cxl,bus_nr=12,bus=pcie.0,id=cxl.1')
self.vm.set_qmp_monitor(enabled=False)