Skip to content

Commit b3d7334

Browse files
committed
qemu: Make callbacks a list
Continuing the trend of making things lists :) Also pass the qconf to the callback.
1 parent 1111aef commit b3d7334

5 files changed

Lines changed: 14 additions & 12 deletions

File tree

lib/qemu.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, machine):
3434
self.compat_rootfs = False
3535
self.boot_func = None
3636
self.shutdown = None
37-
self.callback = None
37+
self.callbacks = []
3838
self.extra_args = []
3939
self.qemu_path = None
4040
self.qemu_cmd = None
@@ -547,9 +547,11 @@ def qemu_main(qconf):
547547
p.send(f'[ -x /mnt/host{i}/{qconf.host_command} ] && (cd /mnt/host{i} && ./{qconf.host_command})')
548548
p.expect_prompt(timeout=None) # no timeout
549549

550-
if qconf.callback and qconf.callback(p) is False:
551-
logging.error("Callback failed")
552-
return False
550+
for callback in qconf.callbacks:
551+
logging.info("Running callback ...")
552+
if callback(qconf, p) is False:
553+
logging.error("Callback failed")
554+
return False
553555

554556
if qconf.shutdown:
555557
qconf.shutdown(p)

scripts/test/qemu-cpu-hotplug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test(name, cpu, machine):
2222
if os.environ.get('QEMU_QUIET', None) is None:
2323
qconf.quiet = True
2424

25-
qconf.callback = test_cpuhotplug
25+
qconf.callbacks.append(test_cpuhotplug)
2626
qconf.apply_defaults()
2727

2828
if cpu == 'POWER10' and not qemu_supports_p10(qconf.qemu_cmd):
@@ -31,7 +31,7 @@ def test(name, cpu, machine):
3131
return qemu_main(qconf)
3232

3333

34-
def test_cpuhotplug(p):
34+
def test_cpuhotplug(qconf, p):
3535
# Check we have 2 CPUs online
3636
p.send('grep -H . /sys/devices/system/cpu/cpu*/online')
3737
p.expect('/sys/devices/system/cpu/cpu0/online:1')

scripts/test/qemu-lkdtm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ def test(name, cpu, machine):
3838
qconf.cpu = cpu
3939
qconf.accel = kvm_or_tcg(machine, cpu)
4040

41-
def test(p):
41+
def test(qconf, p):
4242
p.cmd('mount -t debugfs none /sys/kernel/debug')
4343

4444
for trigger in triggers:
4545
p.send(f"sh -c 'echo {trigger} > /sys/kernel/debug/provoke-crash/DIRECT'")
4646
p.expect(p.prompt, bug_patterns=[])
4747

48-
qconf.callback = test
48+
qconf.callbacks.append(test)
4949
qconf.apply_defaults()
5050

5151
if cpu.upper() == 'POWER10' and not qemu_supports_p10(qconf.qemu_cmd):

scripts/test/qemu-ptdump

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test(name, cpu, machine):
3333
return False
3434

3535

36-
def test(p):
36+
def test(qconf, p):
3737
p.cmd('mount -t debugfs none /sys/kernel/debug')
3838
p.send('cat /sys/kernel/debug/kernel_page_tables')
3939
i = p.expect(["can't open '/sys/kernel/debug/kernel_page_tables': No such file or directory",
@@ -56,7 +56,7 @@ def test(name, cpu, machine):
5656

5757
p.expect_prompt()
5858

59-
qconf.callback = test
59+
qconf.callbacks.append(test)
6060
qconf.apply_defaults()
6161

6262
return qemu_main(qconf)

scripts/test/qemu-xmon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test(name, cpu, machine):
2222
if os.environ.get('QEMU_QUIET', None) is None:
2323
qconf.quiet = True
2424

25-
def test_xmon(p):
25+
def test_xmon(qconf, p):
2626
xmon_enter(p)
2727

2828
p.send('e')
@@ -55,7 +55,7 @@ def test(name, cpu, machine):
5555

5656
xmon_exit(p)
5757

58-
qconf.callback = test_xmon
58+
qconf.callbacks.append(test_xmon)
5959
qconf.apply_defaults()
6060

6161
if cpu == 'POWER10' and not qemu_supports_p10(qconf.qemu_cmd):

0 commit comments

Comments
 (0)