@@ -356,6 +356,15 @@ int mcd_handle_packet(const char *line_buf);
*/
void mcd_put_strbuf(void);
+/**
+ * mcd_exit() - Terminates QEMU.
+ *
+ * If the mcdserver_state has not been initialized the function exits before
+ * terminating QEMU. Terminting is done with the qemu_chr_fe_deinit function.
+ * @code: An exitcode, which can be used in the future.
+ */
+void mcd_exit(int code);
+
/**
* run_cmd_parser() - Prepares the mcdserver_state before executing TCP packet
* functions.
@@ -340,6 +340,11 @@ int mcd_handle_packet(const char *line_buf)
cmd_parser = &open_server_cmd_desc;
}
break;
+ case TCP_CHAR_KILLQEMU:
+ /* kill qemu completely */
+ error_report("QEMU: Terminated via MCDstub");
+ mcd_exit(0);
+ exit(0);
case TCP_CHAR_CLOSE_SERVER:
{
static MCDCmdParseEntry close_server_cmd_desc = {
@@ -492,6 +497,16 @@ int process_string_cmd(void *user_ctx, const char *data,
return -1;
}
+void mcd_exit(int code)
+{
+ /* terminate qemu */
+ if (!mcdserver_state.init) {
+ return;
+ }
+
+ qemu_chr_fe_deinit(&mcdserver_system_state.chr, true);
+}
+
void mcd_chr_event(void *opaque, QEMUChrEvent event)
{
int i;