TCG Plugins: "Code should not be reached" error after resetting plugin from vcpu_tb_trans callback
Host environment
- Operating system: Ubuntu 22.04
- OS/kernel version:
Linux andrew 5.15.0-119-generic #129-Ubuntu SMP Fri Aug 2 19:25:20 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
- Architecture: x86_64
- QEMU flavor: qemu-system-x86_64
- QEMU version: QEMU emulator version 9.1.50 (v9.1.0-210-g4b7ea33074)
- QEMU command line:
./qemu-system-x86_64 -m 1G -plugin contrib/plugins/libmin.so bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2 -nographic -d plugin
Emulated/Virtualized environment
- Operating system: Ubuntu 18.04
- OS/kernel version:
Linux ubuntu 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
- Architecture: x86_64
Description of problem
In a TCG plugin, using the qemu_plugin_reset
method from within a vcpu_tb_trans
callback produces the following error. If this isn't a supported use case, it should probably be described in the documentation. If this is supposed to work, it doesn't seem to.
**
ERROR:/home/user/git/qemu/tcg/i386/tcg-target.c.inc:3018:tcg_out_op: code should not be reached
Bail out! ERROR:/home/user/git/qemu/tcg/i386/tcg-target.c.inc:3018:tcg_out_op: code should not be reached
Aborted (core dumped)
Steps to reproduce
- Build the current head of master (4b7ea330) with the below
min
plugin (i.e., add to contrib/plugins and update contrib/plugins/Makefile so it is built) ../configure --enable-plugins --target-list=x86_64-softmmu --disable-docs
make && make plugins
- Get a qcow, e.g., the Ubuntu Bionic qcow from here.
./qemu-system-x86_64 -plugin contrib/plugins/libmin.so bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2 -nographic
The first three lines are output by the plugin as expected, the error after that and the abort are unexpected:
Translating basic block
Reset request issued
Reset finished
**
ERROR:/home/user/git/qemu/tcg/i386/tcg-target.c.inc:3018:tcg_out_op: code should not be reached
Bail out! ERROR:/home/user/git/qemu/tcg/i386/tcg-target.c.inc:3018:tcg_out_op: code should not be reached
Aborted (core dumped)
Additional information
contrib/plugins/min.c
#include <stdio.h>
#include <qemu-plugin.h>
QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
qemu_plugin_id_t plugin_id = {0};
static void post_reset(qemu_plugin_id_t id) {
printf("Reset finished\n");
}
static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) {
printf("Translating basic block\n");
qemu_plugin_reset(plugin_id, post_reset);
printf("Reset request issued\n");
}
QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
const qemu_info_t *info, int argc, char **argv) {
qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
plugin_id = id;
return 0;
}
Edited by Andrew Fasano