|
10 | 10 | from virttest import libvirt_version
|
11 | 11 | from virttest.utils_test import libvirt
|
12 | 12 | from virttest.libvirt_xml import vm_xml
|
| 13 | +from virttest.staging import utils_memory |
| 14 | + |
| 15 | +from provider.memory import memory_base |
13 | 16 |
|
14 | 17 |
|
15 | 18 | # Using as lower capital is not the best way to do, but this is just a
|
@@ -251,6 +254,21 @@ def print_debug_stats(original_inside_mem, original_outside_mem,
|
251 | 254 | vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
|
252 | 255 | backup_xml = vmxml.copy()
|
253 | 256 |
|
| 257 | + vm_attrs = eval(params.get('vm_attrs')) |
| 258 | + memory_size = vm_attrs['memory'] |
| 259 | + memory_unit = vm_attrs['memory_unit'] |
| 260 | + guest_memory = memory_base.convert_data_size( |
| 261 | + str(memory_size) + memory_unit, dest_unit='KiB') |
| 262 | + host_free_mem = utils_memory.freememtotal() |
| 263 | + logging.debug("The allocation memory for guest is %sKiB," |
| 264 | + " the total free memory of host is %sKiB.", |
| 265 | + guest_memory, host_free_mem) |
| 266 | + if host_free_mem < guest_memory: |
| 267 | + test.cancel("There is not enough memory for guest.") |
| 268 | + |
| 269 | + vmxml.setup_attrs(**vm_attrs) |
| 270 | + vmxml.sync() |
| 271 | + |
254 | 272 | if with_packed and not libvirt_version.version_compare(6, 3, 0):
|
255 | 273 | test.cancel("The virtio packed attribute is not supported in"
|
256 | 274 | " current libvirt version.")
|
|
0 commit comments