Skip to content

Commit d4f3387

Browse files
committed
memory: Increase guest memory to 4G
The previous guest memory setting was 2G, but the half memory test would fail because 1G was not enough to maintain the normal operation of the guest. Signed-off-by: Hu Shuai <[email protected]>
1 parent 887bdd9 commit d4f3387

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

libvirt/tests/cfg/virsh_cmd/domain/virsh_setmem.cfg renamed to libvirt/tests/cfg/memory/virsh_setmem.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# expected to fail on older libvirt.
1818
setmem_old_libvirt_fail = "no"
1919
take_regular_screendumps = no
20+
vm_attrs = {'memory': 4, 'memory_unit': 'GiB', 'current_mem': 4, 'current_mem_unit': 'GiB'}
2021
variants:
2122
- valid_options:
2223
# These should not fail

libvirt/tests/src/virsh_cmd/domain/virsh_setmem.py renamed to libvirt/tests/src/memory/virsh_setmem.py

+18
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
from virttest import libvirt_version
1111
from virttest.utils_test import libvirt
1212
from virttest.libvirt_xml import vm_xml
13+
from virttest.staging import utils_memory
14+
15+
from provider.memory import memory_base
1316

1417

1518
# 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,
251254
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
252255
backup_xml = vmxml.copy()
253256

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+
254272
if with_packed and not libvirt_version.version_compare(6, 3, 0):
255273
test.cancel("The virtio packed attribute is not supported in"
256274
" current libvirt version.")

0 commit comments

Comments
 (0)