Skip to content

Commit 32c90a8

Browse files
committed
qemu: Enable spapr-rng on pseries
Annoyingly the spapr-rng has to be explicitly enabled.
1 parent a39579e commit 32c90a8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/qemu.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def get_qemu_version(emulator):
4747

4848
def qemu_command(qemu='qemu-system-ppc64', machine='pseries,cap-htm=off', cpu=None,
4949
mem='1G', smp=1, vmlinux=None, initrd=None, drive=None,
50-
host_mount=None, cmdline='', accel='tcg', net='-nic user', gdb=None):
50+
host_mount=None, cmdline='', accel='tcg', net='-nic user', gdb=None,
51+
extra_args=[]):
5152

5253
qemu_path = get_qemu(qemu)
5354
logging.info('Using qemu version %s.%s' % get_qemu_version(qemu_path))
@@ -103,6 +104,8 @@ def qemu_command(qemu='qemu-system-ppc64', machine='pseries,cap-htm=off', cpu=No
103104
if gdb:
104105
l.append(gdb)
105106

107+
l.extend(extra_args)
108+
106109
logging.debug(l)
107110

108111
return ' '.join(l)
@@ -170,6 +173,13 @@ def qemu_main(qemu_machine, cpuinfo_platform, cpu, net, args):
170173
else:
171174
drive = None
172175

176+
extra_args = []
177+
if 'pseries' in qemu_machine:
178+
if accel == 'kvm':
179+
extra_args = ['-device spapr-rng,use-kvm=true']
180+
else:
181+
extra_args = ['-device spapr-rng,rng=rng0 -object rng-random,filename=/dev/urandom,id=rng0']
182+
173183
host_mount = os.environ.get('QEMU_HOST_MOUNT', '')
174184
if host_mount and not os.path.isdir(host_mount):
175185
logging.error('QEMU_HOST_MOUNT must point to a directory')
@@ -187,7 +197,7 @@ def qemu_main(qemu_machine, cpuinfo_platform, cpu, net, args):
187197

188198
cmd = qemu_command(machine=qemu_machine, cpu=cpu, mem='4G', smp=smp, vmlinux=vmlinux,
189199
drive=drive, host_mount=host_mount, cmdline=cmdline, accel=accel,
190-
net=net, gdb=gdb)
200+
net=net, gdb=gdb, extra_args=extra_args)
191201

192202
if '--interactive' in args:
193203
logging.info("Running interactively ...")

0 commit comments

Comments
 (0)