replay: do not build if TCG is not available
Subsystems (3)
PATCH v5 1/1 replay: do not build if TCG is not available
From: Claudio Fontana <[email protected]>
this fixes non-TCG builds broken recently by replay reverse debugging.
Stub the needed functions in stub/, splitting roughly between functions needed only by system emulation, by system emulation and tools, and by everyone. This includes duplicating some code in replay/, and puts the logic for non-replay related events in the replay/ module (+ the stubs), so this should be revisited in the future.
Surprisingly, only _one_ qtest was affected by this, ide-test.c, which resulted in a buzz as the bh events were never delivered, and the bh never executed.
Many other subsystems _should_ have been affected.
This fixes the immediate issue, however a better way to group replay functionality to TCG-only code could be developed in the long term.
Message-Id: <[email protected]>
--- block/meson.build | 3 +- net/meson.build | 3 +- replay/meson.build | 4 +- replay/stubs-system.c | 96 ++++++++++++++++++++++++++++++++++++++ stubs/meson.build | 4 +- stubs/replay-tools.c | 83 ++++++++++++++++++++++++++++++++ stubs/replay-user.c | 9 ---- stubs/replay.c | 78 ------------------------------- tests/ptimer-test-stubs.c | 5 -- tests/qtest/qmp-cmd-test.c | 3 ++ 10 files changed, 191 insertions(+), 97 deletions(-) create mode 100644 replay/stubs-system.c create mode 100644 stubs/replay-tools.c delete mode 100644 stubs/replay-user.c
block/meson.build +2 -1
@@ -7,7 +7,6 @@ block_ss.add(files( 'backup-top.c', 'blkdebug.c', 'blklogwrites.c', - 'blkreplay.c', 'blkverify.c', 'block-backend.c', 'block-copy.c',
@@ -42,6 +41,8 @@ block_ss.add(files( 'write-threshold.c', ), zstd, zlib) +softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c')) + block_ss.add(when: 'CONFIG_QCOW1', if_true: files('qcow.c')) block_ss.add(when: 'CONFIG_VDI', if_true: files('vdi.c')) block_ss.add(when: 'CONFIG_CLOOP', if_true: files('cloop.c'))
net/meson.build +2 -1
@@ -7,7 +7,6 @@ softmmu_ss.add(files( 'eth.c', 'filter-buffer.c', 'filter-mirror.c', - 'filter-replay.c', 'filter-rewriter.c', 'filter.c', 'hub.c',
@@ -17,6 +16,8 @@ softmmu_ss.add(files( 'util.c', )) +softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('filter-replay.c')) + softmmu_ss.add(when: 'CONFIG_L2TPV3', if_true: files('l2tpv3.c')) softmmu_ss.add(when: slirp, if_true: files('slirp.c')) softmmu_ss.add(when: ['CONFIG_VDE', vde], if_true: files('vde.c'))
replay/meson.build +2 -2
@@ -1,4 +1,4 @@ -softmmu_ss.add(files( +softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( 'replay.c', 'replay-internal.c', 'replay-events.c',
@@ -10,4 +10,4 @@ softmmu_ss.add(files( 'replay-audio.c', 'replay-random.c', 'replay-debugging.c', -)) +), if_false: files('stubs-system.c'))
replay/stubs-system.c new file +96 -0
96 lines not on this page · raw message
stubs/meson.build +3 -1
@@ -32,7 +32,6 @@ stub_ss.add(files('qtest.c')) stub_ss.add(files('ram-block.c')) stub_ss.add(files('ramfb.c')) stub_ss.add(files('replay.c')) -stub_ss.add(files('replay-user.c')) stub_ss.add(files('runstate-check.c')) stub_ss.add(files('set-fd-handler.c')) stub_ss.add(files('sysbus.c'))
@@ -46,6 +45,9 @@ stub_ss.add(files('vmstate.c')) stub_ss.add(files('vm-stop.c')) stub_ss.add(files('win32-kbd-hook.c')) stub_ss.add(files('cpu-synchronize-state.c')) +if have_block + stub_ss.add(files('replay-tools.c')) +endif if have_system stub_ss.add(files('semihost.c')) stub_ss.add(files('xen-hw-stub.c'))
stubs/replay-tools.c new file +83 -0
83 lines not on this page · raw message
stubs/replay-user.c deleted +0 -9
@@ -1,9 +0,0 @@ -#include "qemu/osdep.h" -#include "sysemu/replay.h" -#include "sysemu/sysemu.h" - -void replay_bh_schedule_oneshot_event (AioContext *ctx, -QEMUBHFunc *cb,void *opaque) -{ -aio_bh_schedule_oneshot (ctx, cb, opaque); -}
stubs/replay.c +0 -78
94 lines not on this page · raw message
tests/ptimer-test-stubs.c +0 -5
@@ -122,8 +122,3 @@ void qemu_bh_delete(QEMUBH *bh) {g_free (bh); } - -void replay_bh_schedule_event (QEMUBH *bh) -{ - bh->cb (bh->opaque); -}
tests/qtest/qmp-cmd-test.c +3 -0
@@ -31,6 +31,9 @@ static int query_error_class(const char *cmd) #ifndef CONFIG_SPICE { "query-spice", ERROR_CLASS_COMMAND_NOT_FOUND }, #endif +#ifndef CONFIG_TCG + { "query-replay", ERROR_CLASS_COMMAND_NOT_FOUND }, +#endif #ifndef CONFIG_VNC { "query-vnc", ERROR_CLASS_GENERIC_ERROR }, { "query-vnc-servers", ERROR_CLASS_GENERIC_ERROR },
Signature · 1 line
2.26.2
Hi Paolo,
Quoted 14 lines · Paolo Bonzini
From: Claudio Fontana <[email protected]>
this fixes non-TCG builds broken recently by replay reverse debugging.
Stub the needed functions in stub/, splitting roughly between functions needed only by system emulation, by system emulation and tools, and by everyone. This includes duplicating some code in replay/, and puts the logic for non-replay related events in the replay/ module (+ the stubs), so this should be revisited in the future.
Surprisingly, only _one_ qtest was affected by this,
ide-test.c, which resulted in a buzz as the bh events were never delivered, and the bh never executed.
Quoted 8 lines
Many other subsystems _should_ have been affected.
This fixes the immediate issue, however a better way to group replay functionality to TCG-only code could be developed in the long term.
Signed-off-by Claudio Fontana <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>
one issue is with the snapshot,
in your respin you have not included my change which surrounds
if (replay_can_snapshot())
around a
if (tcg_enabled()) {
}
therefore leading to failure of all attempts to snapshot under --disable-tcg.
Alternatively, you can change the stub to return "true" (replay_can_snapshot()), although its meaning can be quite surprising for the reader under --disable-tcg.
Ciao,
Claudio
Quoted 430 lines
--- block/meson.build | 3 +- net/meson.build | 3 +- replay/meson.build | 4 +- replay/stubs-system.c | 96 ++++++++++++++++++++++++++++++++++++++ stubs/meson.build | 4 +- stubs/replay-tools.c | 83 ++++++++++++++++++++++++++++++++ stubs/replay-user.c | 9 ---- stubs/replay.c | 78 ------------------------------- tests/ptimer-test-stubs.c | 5 -- tests/qtest/qmp-cmd-test.c | 3 ++ 10 files changed, 191 insertions(+), 97 deletions(-) create mode 100644 replay/stubs-system.c create mode 100644 stubs/replay-tools.c delete mode 100644 stubs/replay-user.cblock/meson.build +2
-1@@ -7,7 +7,6 @@ block_ss.add(files( 'backup-top.c', 'blkdebug.c', 'blklogwrites.c', - 'blkreplay.c', 'blkverify.c', 'block-backend.c', 'block-copy.c',@@ -42,6 +41,8 @@ block_ss.add(files( 'write-threshold.c', ), zstd, zlib) +softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c')) + block_ss.add(when: 'CONFIG_QCOW1', if_true: files('qcow.c')) block_ss.add(when: 'CONFIG_VDI', if_true: files('vdi.c')) block_ss.add(when: 'CONFIG_CLOOP', if_true: files('cloop.c'))net/meson.build +2
-1@@ -7,7 +7,6 @@ softmmu_ss.add(files( 'eth.c', 'filter-buffer.c', 'filter-mirror.c', - 'filter-replay.c', 'filter-rewriter.c', 'filter.c', 'hub.c',@@ -17,6 +16,8 @@ softmmu_ss.add(files( 'util.c', )) +softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('filter-replay.c')) + softmmu_ss.add(when: 'CONFIG_L2TPV3', if_true: files('l2tpv3.c')) softmmu_ss.add(when: slirp, if_true: files('slirp.c')) softmmu_ss.add(when: ['CONFIG_VDE', vde], if_true: files('vde.c'))replay/meson.build +2
-2@@ -1,4 +1,4 @@ -softmmu_ss.add(files( +softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( 'replay.c', 'replay-internal.c', 'replay-events.c',@@ -10,4 +10,4 @@ softmmu_ss.add(files( 'replay-audio.c', 'replay-random.c', 'replay-debugging.c', -)) +), if_false: files('stubs-system.c'))replay/stubs-system.c new file +96
-0@@ -0,0 +1,96 @@ +#include "qemu/osdep.h" +#include "sysemu/replay.h" +#include "ui/input.h" + +void replay_input_event (QemuConsole *src,InputEvent *evt) +{ +qemu_input_event_send_impl (src, evt); +} + +void replay_input_sync_event (void ) +{ +qemu_input_event_sync_impl (); +} + +void replay_add_blocker (Error *reason) +{ +} +void replay_audio_in (size_t *recorded,void *samples,size_t *wpos,size_t size) +{ +} +void replay_audio_out (size_t *played) +{ +} +void replay_breakpoint (void ) +{ +} +bool replay_can_snapshot (void ) +{ +return false; +} +void replay_configure (struct QemuOpts *opts) +{ +} +void replay_flush_events (void ) +{ +} +void replay_gdb_attached (void ) +{ +} +bool replay_running_debug (void ) +{ +return false; +} +void replay_shutdown_request (ShutdownCause cause) +{ +} +void replay_start (void ) +{ +} +void replay_vmstate_init (void ) +{ +} + +#include "monitor/monitor.h" +#include "monitor/hmp.h" +#include "qapi/qapi-commands-replay.h" +#include "qapi/error.h" +#include "qemu/error-report.h" + +void hmp_info_replay (Monitor *mon,const QDict *qdict) +{ +error_report ("replay support not available" ); +} +void hmp_replay_break (Monitor *mon,const QDict *qdict) +{ +error_report ("replay support not available" ); +} +void hmp_replay_delete_break (Monitor *mon,const QDict *qdict) +{ +error_report ("replay support not available" ); +} +void hmp_replay_seek (Monitor *mon,const QDict *qdict) +{ +error_report ("replay support not available" ); +} +ReplayInfo *qmp_query_replay (Error **errp) +{ +error_set (errp,ERROR_CLASS_COMMAND_NOT_FOUND , +"replay support not available" ); +return NULL ; +} +void qmp_replay_break (int64_t icount,Error **errp) +{ +error_set (errp,ERROR_CLASS_COMMAND_NOT_FOUND , +"replay support not available" ); +} +void qmp_replay_delete_break (Error **errp) +{ +error_set (errp,ERROR_CLASS_COMMAND_NOT_FOUND , +"replay support not available" ); +} +void qmp_replay_seek (int64_t icount,Error **errp) +{ +error_set (errp,ERROR_CLASS_COMMAND_NOT_FOUND , +"replay support not available" ); +}stubs/meson.build +3
-1@@ -32,7 +32,6 @@ stub_ss.add(files('qtest.c')) stub_ss.add(files('ram-block.c')) stub_ss.add(files('ramfb.c')) stub_ss.add(files('replay.c')) -stub_ss.add(files('replay-user.c')) stub_ss.add(files('runstate-check.c')) stub_ss.add(files('set-fd-handler.c')) stub_ss.add(files('sysbus.c'))@@ -46,6 +45,9 @@ stub_ss.add(files('vmstate.c')) stub_ss.add(files('vm-stop.c')) stub_ss.add(files('win32-kbd-hook.c')) stub_ss.add(files('cpu-synchronize-state.c')) +if have_block + stub_ss.add(files('replay-tools.c')) +endif if have_system stub_ss.add(files('semihost.c')) stub_ss.add(files('xen-hw-stub.c'))stubs/replay-tools.c new file +83
-0@@ -0,0 +1,83 @@ +#include "qemu/osdep.h" +#include "sysemu/replay.h" +#include "block/aio.h" + +bool replay_events_enabled (void ) +{ +return false; +} + +int64_t replay_save_clock (unsigned int kind,int64_t clock,int64_t raw_icount) +{ +abort (); +return 0 ; +} + +int64_t replay_read_clock (unsigned int kind) +{ +abort (); +return 0 ; +} + +uint64_t replay_get_current_icount (void ) +{ +return 0 ; +} + +void replay_bh_schedule_event (QEMUBH *bh) +{ +qemu_bh_schedule (bh); +} + +void replay_bh_schedule_oneshot_event (AioContext *ctx, +QEMUBHFunc *cb,void *opaque) +{ +aio_bh_schedule_oneshot (ctx, cb, opaque); +} + +bool replay_checkpoint (ReplayCheckpoint checkpoint) +{ +return true; +} + +void replay_mutex_lock (void ) +{ +} + +void replay_mutex_unlock (void ) +{ +} + +void replay_register_char_driver (Chardev *chr) +{ +} + +void replay_chr_be_write (Chardev *s,uint8_t *buf,int len) +{ +abort (); +} + +void replay_char_write_event_save (int res,int offset) +{ +abort (); +} + +void replay_char_write_event_load (int *res,int *offset) +{ +abort (); +} + +int replay_char_read_all_load (uint8_t *buf) +{ +abort (); +} + +void replay_char_read_all_save_error (int res) +{ +abort (); +} + +void replay_char_read_all_save_buf (uint8_t *buf,int offset) +{ +abort (); +}stubs/replay-user.c deleted +0
-9@@ -1,9 +0,0 @@ -#include "qemu/osdep.h" -#include "sysemu/replay.h" -#include "sysemu/sysemu.h" - -void replay_bh_schedule_oneshot_event (AioContext *ctx, -QEMUBHFunc *cb,void *opaque) -{ -aio_bh_schedule_oneshot (ctx, cb, opaque); -}stubs/replay.c +0
-78@@ -3,83 +3,10 @@ReplayMode replay_mode; -int64_t replay_save_clock (unsigned int kind,int64_t clock,int64_t raw_icount) -{ -abort (); -return 0 ; -} - -int64_t replay_read_clock (unsigned int kind) -{ -abort (); -return 0 ; -} - -bool replay_checkpoint (ReplayCheckpoint checkpoint) -{ -return true; -} - -bool replay_events_enabled (void ) -{ -return false; -} -void replay_finish (void ) { } -void replay_register_char_driver (Chardev *chr) -{ -} - -void replay_chr_be_write (Chardev *s,uint8_t *buf,int len) -{ -abort (); -} - -void replay_char_write_event_save (int res,int offset) -{ -abort (); -} - -void replay_char_write_event_load (int *res,int *offset) -{ -abort (); -} - -int replay_char_read_all_load (uint8_t *buf) -{ -abort (); -} - -void replay_char_read_all_save_error (int res) -{ -abort (); -} - -void replay_char_read_all_save_buf (uint8_t *buf,int offset) -{ -abort (); -} - -void replay_block_event (QEMUBH *bh,uint64_t id) -{ -} - -uint64_t blkreplay_next_id (void ) -{ -return 0 ; -} - -void replay_mutex_lock (void ) -{ -} - -void replay_mutex_unlock (void ) -{ -} -void replay_save_random (int ret,void *buf,size_t len) { }@@ -89,11 +16,6 @@ int replay_read_random(void *buf, size_t len)return 0 ; } -uint64_t replay_get_current_icount (void ) -{ -return 0 ; -} -bool replay_reverse_step (void ) {return false;tests/ptimer-test-stubs.c +0
-5@@ -122,8 +122,3 @@ void qemu_bh_delete(QEMUBH *bh) {g_free (bh); } - -void replay_bh_schedule_event (QEMUBH *bh) -{ - bh->cb (bh->opaque); -}tests/qtest/qmp-cmd-test.c +3
-0@@ -31,6 +31,9 @@ static int query_error_class(const char *cmd) #ifndef CONFIG_SPICE { "query-spice", ERROR_CLASS_COMMAND_NOT_FOUND }, #endif +#ifndef CONFIG_TCG + { "query-replay", ERROR_CLASS_COMMAND_NOT_FOUND }, +#endif #ifndef CONFIG_VNC { "query-vnc", ERROR_CLASS_GENERIC_ERROR }, { "query-vnc-servers", ERROR_CLASS_GENERIC_ERROR },
Quoted 6 lines · Claudio Fontana
in your respin you have not included my change which surrounds
if (
replay_can_snapshot())around a
Quoted 7 lines
if (
tcg_enabled()) {
}therefore leading to failure of all attempts to snapshot under --disable-tcg.
Alternatively, you can change the stub to return "true" (
replay_can_snapshot()), although its meaning can be quite surprising for the reader under --disable-tcg.
Yeah, and it actually makes sense since
return replay_mode == REPLAY_MODE_NONE
|| !replay_has_events();would always be true.
Paolo