Skip to content

Commit d941cdd

Browse files
committed
Fixed QEMU record/replay script and manual
1 parent 3337111 commit d941cdd

File tree

2 files changed

+28
-44
lines changed

2 files changed

+28
-44
lines changed

README.adoc

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11013,62 +11013,33 @@ By comparing the terminal output of both runs, we can see that they are the exac
1101311013
* timestamps of dmesg output
1101411014
* <<rand-check-out>> output
1101511015

11016-
The record and replay feature was revived around QEMU v3.0.0. It existed earlier but it rot completely. As of v3.0.0 it is still flaky: sometimes we get deadlocks, and only a limited number of command line arguments are supported.
11016+
The record and replay feature was revived around QEMU v3.0.0. In v5.2.0 it is quite usable, almost all peripherals and vCPUs are supported.
1101711017

11018-
Documented at: https://github.com/qemu/qemu/blob/v2.12.0/docs/replay.txt
11018+
Documented at: https://github.com/qemu/qemu/blob/v5.2.0/docs/replay.txt
1101911019

11020-
TODO: using `-r` as above leads to a kernel warning:
11021-
11022-
....
11023-
rcu_sched detected stalls on CPUs/tasks
11024-
....
11025-
11026-
TODO: replay deadlocks intermittently at disk operations, last kernel message:
11027-
11028-
....
11029-
EXT4-fs (sda): re-mounted. Opts: block_validity,barrier,user_xattr
11030-
....
11031-
11032-
TODO replay with network gets stuck:
11020+
replay may be used with with network:
1103311021

1103411022
....
1103511023
./qemu-rr --eval-after 'ifup -a;wget -S google.com;./linux/poweroff.out;'
1103611024
....
1103711025

11038-
after the message:
11026+
`arm` and `aarch64` targets can also be used with rr:
1103911027

1104011028
....
11041-
adding dns 10.0.2.3
11029+
./qemu-rr --arch aarch64 --eval-after './linux/rand_check.out;./linux/poweroff.out;'
11030+
./qemu-rr --arch aarch64 --eval-after 'ifup -a;wget -S google.com;./linux/poweroff.out;'
1104211031
....
1104311032

11044-
There is explicit network support on the QEMU patches, but either it is buggy or we are not using the correct magic options.
11045-
11046-
Solved on unmerged c42634d8e3428cfa60672c3ba89cabefc720cde9 from https://github.com/ispras/qemu/tree/rr-180725
11047-
11048-
TODO `arm` and `aarch64` only seem to work with initrd since I cannot plug a working IDE disk device? See also: https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg05245.html
11049-
11050-
Then, when I tried with <<initrd>> and no disk:
11033+
Replay also supports <<initrd>> and no disk:
1105111034

1105211035
....
1105311036
./build-buildroot --arch aarch64 --initrd
1105411037
./qemu-rr --arch aarch64 --eval-after './linux/rand_check.out;./linux/poweroff.out;' --initrd
1105511038
....
1105611039

11057-
QEMU crashes with:
11058-
11059-
....
11060-
ERROR:replay/replay-time.c:49:replay_read_clock: assertion failed: (replay_file && replay_mutex_locked())
11061-
....
11062-
11063-
I had the same error previously on x86-64, but it was fixed: https://bugs.launchpad.net/qemu/+bug/1762179 so maybe the forgot to fix it for `aarch64`?
11064-
11065-
Solved on unmerged c42634d8e3428cfa60672c3ba89cabefc720cde9 from https://github.com/ispras/qemu/tree/rr-180725
11066-
1106711040
===== QEMU reverse debugging
1106811041

11069-
TODO get working.
11070-
11071-
QEMU replays support checkpointing, and this allows for a simplistic "reverse debugging" implementation proposed at https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg00478.html on the unmerged https://github.com/ispras/qemu/tree/rr-180725[]:
11042+
QEMU replays support checkpointing, and this allows for a simplistic "reverse debugging" implementation since v5.2.0:
1107211043

1107311044
....
1107411045
./run --eval-after './linux/rand_check.out;./linux/poweroff.out;' --record
@@ -11093,6 +11064,8 @@ reverse-continue
1109311064

1109411065
and we are back at `start_kernel`
1109511066

11067+
`reverse-continue` proceeds to the latest of the earlier breakpoints or to the very beginning if there were no breakpoints before.
11068+
1109611069
==== QEMU trace multicore
1109711070

1109811071
TODO: is there any way to distinguish which instruction runs on each core? Doing:

run

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -817,23 +817,20 @@ Extra options to append at the end of the emulator command line.
817817
if rr:
818818
driveif = 'none'
819819
rrid = ',id=img-direct'
820+
rrid2 = ',id=img-direct2'
820821
root = 'root=/dev/sda'
821-
snapshot = ''
822+
snapshot = ',snapshot'
822823
else:
823824
driveif = 'virtio'
824825
root = 'root=/dev/vda'
825826
rrid = ''
827+
rrid2 = ''
826828
snapshot = ',snapshot'
827829
if not self.env['baremetal']:
828830
if not os.path.exists(self.env['qcow2_file']):
829831
if not os.path.exists(self.env['rootfs_raw_file']):
830832
raise_rootfs_not_found()
831833
self.raw_to_qcow2(qemu_which=self.env['qemu_which'])
832-
if rr:
833-
extra_emulator_args.extend([
834-
'-drive', 'driver=blkreplay,if=none,image=img-direct,id=img-blkreplay', LF,
835-
'-device', 'ide-hd,drive=img-blkreplay', LF,
836-
])
837834
if use_disk_image:
838835
if os.path.splitext(self.env['disk_image'])[1] == '.qcow2':
839836
disk_format = 'qcow2'
@@ -850,6 +847,15 @@ Extra options to append at the end of the emulator command line.
850847
),
851848
LF,
852849
])
850+
hd_dev = 'ide-hd'
851+
if self.env['is_arm']:
852+
hd_dev = 'virtio-blk-device'
853+
root = 'root=/dev/vda'
854+
if rr:
855+
extra_emulator_args.extend([
856+
'-drive', 'driver=blkreplay,if=none,image=img-direct,id=img-blkreplay', LF,
857+
'-device', '{},drive=img-blkreplay'.format(hd_dev), LF,
858+
])
853859
if os.path.exists(self.env['disk_image_2']):
854860
extra_emulator_args.extend([
855861
'-drive',
@@ -858,10 +864,15 @@ Extra options to append at the end of the emulator command line.
858864
'raw',
859865
driveif,
860866
snapshot,
861-
rrid
867+
rrid2
862868
),
863869
LF,
864870
])
871+
if rr:
872+
extra_emulator_args.extend([
873+
'-drive', 'driver=blkreplay,if=none,image=img-direct2,id=img-blkreplay', LF,
874+
'-device', '{},drive=img-blkreplay2'.format(hd_dev), LF,
875+
])
865876
if rr:
866877
extra_emulator_args.extend([
867878
'-object', 'filter-replay,id=replay,netdev=net0', LF,

0 commit comments

Comments
 (0)