8000 boot-qemu.py: Allow memory value to be customized · ClangBuiltLinux/boot-utils@af9130e · GitHub
[go: up one dir, main page]

Skip to content

Commit af9130e

Browse files
committed
boot-qemu.py: Allow memory value to be customized
The default memory value for most machines is 512 MB, which is generally sufficient for most use cases, as these machines are usually quick to start up and shutdown. Unfortunately, there are times where the machine may run out of memory when percpu memory allocations are involved along with a large number of cores, which can happen when booting under KVM due to the script's heuristics for selecting a good default for '-smp', which depends on the number of cores on the host machine. Rather than try to adjust the existing heuristics further, allow users to specify a memory value that may be better suited for their machine, just like '-smp'. Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent 7763678 commit af9130e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

boot-qemu.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(self):
4949
self.interactive = False
5050
self.kernel = None
5151
self.kernel_dir = None
52+
self.memory = '512m'
5253
self.supports_efi = False
5354
# It may be tempting to use self.use_kvm during initialization of
5455
# subclasses to set certain properties but the user can explicitly opt
@@ -70,7 +71,6 @@ def __init__(self):
7071
'-nodefaults',
7172
] # yapf: disable
7273
self._qemu_path = None
73-
self._ram = '512m'
7474

7575
def _find_dtb(self):
7676
if not self._dtbs:
@@ -301,7 +301,7 @@ def run(self):
301301
self._qemu_args += ['-cpu', ','.join(self._kvm_cpu), '-enable-kvm']
302302

303303
# Machine specs
304-
self._qemu_args += ['-m', self._ram]
304+
self._qemu_args += ['-m', self.memory]
305305
if self.smp:
306306
self._qemu_args += ['-smp', str(self.smp)]
307307

@@ -512,7 +512,7 @@ def __init__(self):
512512
'-bios', bios,
513513
'-no-reboot',
514514
] # yapf: disable
515-
self._ram = '2G'
515+
self.memory = '2G'
516516
self.smp = 2
517517

518518

@@ -555,12 +555,12 @@ def __init__(self):
555555
super().__init__()
556556

557557
self.cmdline.append('console=ttyS0')
558+
self.memory = '128m'
558559
self._default_kernel_path = Path('arch/powerpc/boot/uImage')
559560
self._initrd_arch = 'ppc32'
560561
self._machine = 'bamboo'
561562
self._qemu_arch = 'ppc'
562563
self._qemu_args.append('-no-reboot')
563-
self._ram = '128m'
564564

565565
def run(self):
566566
self._qemu_args += ['-machine', self._machine]
@@ -582,21 +582,22 @@ class PowerPC64QEMURunner(QEMURunner):
582582
def __init__(self):
583583
super().__init__()
584584

585+
self.memory = '1G'
585586
self._default_kernel_path = Path('vmlinux')
586587
self._initrd_arch = self._qemu_arch = 'ppc64'
587588
self._qemu_args += [
588589
'-cpu', 'power8',
589590
'-machine', 'pseries',
590591
'-vga', 'none',
591592
] # yapf: disable
592-
self._ram = '1G'
593593

594594

595595
class PowerPC64LEQEMURunner(QEMURunner):
596596

597597
def __init__(self):
598598
super().__init__()
599599

600+
self.memory = '2G'
600601
self._default_kernel_path = Path('arch/powerpc/boot/zImage.epapr')
601602
self._initrd_arch = 'ppc64le'
602603
self._qemu_arch = 'ppc64'
@@ -605,7 +606,6 @@ def __init__(self):
605606
'-device', 'isa-ipmi-bt,bmc=bmc0,irq=10',
606607
'-machine', 'powernv',
607608
] # yapf: disable
608-
self._ram = '2G'
609609

610610

611611
class RISCVQEMURunner(QEMURunner):
@@ -811,6 +811,12 @@ def parse_arguments():
811811
'--shell',
812812
action='store_true',
813813
help='Instead of immediately shutting down machine, spawn a shell.')
814+
parser.add_argument(
815+
'-m',
816+
'--memory',
817+
help=
818+
"Value for '-m' QEMU option (default: generally '512m', depends on machine)",
819+
)
814820
parser.add_argument(
815821
'-s',
816822
'--smp',
@@ -884,6 +890,9 @@ def parse_arguments():
884890
if args.gh_json_file:
885891
runner.gh_json_file = Path(args.gh_json_file).resolve()
886892

893+
if args.memory:
894+
runner.memory = args.memory
895+
887896
if args.no_kvm:
888897
runner.use_kvm = False
889898

0 commit comments

Comments
 (0)
0