Skip to content

Commit

Permalink
Merge pull request #114 from nathanchance/allow-custom-mem-val
Browse files Browse the repository at this point in the history
boot-qemu.py: Allow memory value to be customized
  • Loading branch information
nathanchance committed Sep 14, 2023
2 parents 7763678 + af9130e commit 2cba5d5
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions boot-qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self):
self.interactive = False
self.kernel = None
self.kernel_dir = None
self.memory = '512m'
self.supports_efi = False
# It may be tempting to use self.use_kvm during initialization of
# subclasses to set certain properties but the user can explicitly opt
Expand All @@ -70,7 +71,6 @@ def __init__(self):
'-nodefaults',
] # yapf: disable
self._qemu_path = None
self._ram = '512m'

def _find_dtb(self):
if not self._dtbs:
Expand Down Expand Up @@ -301,7 +301,7 @@ def run(self):
self._qemu_args += ['-cpu', ','.join(self._kvm_cpu), '-enable-kvm']

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

Expand Down Expand Up @@ -512,7 +512,7 @@ def __init__(self):
'-bios', bios,
'-no-reboot',
] # yapf: disable
self._ram = '2G'
self.memory = '2G'
self.smp = 2


Expand Down Expand Up @@ -555,12 +555,12 @@ def __init__(self):
super().__init__()

self.cmdline.append('console=ttyS0')
self.memory = '128m'
self._default_kernel_path = Path('arch/powerpc/boot/uImage')
self._initrd_arch = 'ppc32'
self._machine = 'bamboo'
self._qemu_arch = 'ppc'
self._qemu_args.append('-no-reboot')
self._ram = '128m'

def run(self):
self._qemu_args += ['-machine', self._machine]
Expand All @@ -582,21 +582,22 @@ class PowerPC64QEMURunner(QEMURunner):
def __init__(self):
super().__init__()

self.memory = '1G'
self._default_kernel_path = Path('vmlinux')
self._initrd_arch = self._qemu_arch = 'ppc64'
self._qemu_args += [
'-cpu', 'power8',
'-machine', 'pseries',
'-vga', 'none',
] # yapf: disable
self._ram = '1G'


class PowerPC64LEQEMURunner(QEMURunner):

def __init__(self):
super().__init__()

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


class RISCVQEMURunner(QEMURunner):
Expand Down Expand Up @@ -811,6 +811,12 @@ def parse_arguments():
'--shell',
action='store_true',
help='Instead of immediately shutting down machine, spawn a shell.')
parser.add_argument(
'-m',
'--memory',
help=
"Value for '-m' QEMU option (default: generally '512m', depends on machine)",
)
parser.add_argument(
'-s',
'--smp',
Expand Down Expand Up @@ -884,6 +890,9 @@ def parse_arguments():
if args.gh_json_file:
runner.gh_json_file = Path(args.gh_json_file).resolve()

if args.memory:
runner.memory = args.memory

if args.no_kvm:
runner.use_kvm = False

Expand Down

0 comments on commit 2cba5d5

Please sign in to comment.