Commit 8cf71710 authored by Jan Kiszka's avatar Jan Kiszka Committed by Marcelo Tosatti
Browse files

Refactor debug and vmstop request interface



Instead of fiddling with debug_requested and vmstop_requested directly,
introduce qemu_system_debug_request and turn qemu_system_vmstop_request
into a public interface. This aligns those services with exiting ones in
vl.c.

Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent e07bbac5
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -168,8 +168,7 @@ static bool all_cpu_threads_idle(void)
static void cpu_debug_handler(CPUState *env)
{
    gdb_set_stop_cpu(env);
    debug_requested = VMSTOP_DEBUG;
    vm_stop(VMSTOP_DEBUG);
    qemu_system_debug_request();
}

#ifdef CONFIG_LINUX
@@ -990,12 +989,6 @@ void qemu_notify_event(void)
    qemu_event_increment();
}

static void qemu_system_vmstop_request(int reason)
{
    vmstop_requested = reason;
    qemu_notify_event();
}

void cpu_stop_current(void)
{
    if (cpu_single_env) {
+0 −2
Original line number Diff line number Diff line
@@ -11,8 +11,6 @@ void cpu_stop_current(void);
/* vl.c */
extern int smp_cores;
extern int smp_threads;
extern int debug_requested;
extern int vmstop_requested;
void vm_state_notify(int running, int reason);
bool cpu_exec_all(void);
void set_numa_modes(void);
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ void cpu_disable_ticks(void);
void qemu_system_reset_request(void);
void qemu_system_shutdown_request(void);
void qemu_system_powerdown_request(void);
void qemu_system_debug_request(void);
void qemu_system_vmstop_request(int reason);
int qemu_shutdown_requested(void);
int qemu_reset_requested(void);
int qemu_powerdown_requested(void);
+16 −4
Original line number Diff line number Diff line
@@ -1217,8 +1217,8 @@ static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
static int reset_requested;
static int shutdown_requested;
static int powerdown_requested;
int debug_requested;
int vmstop_requested;
static int debug_requested;
static int vmstop_requested;

int qemu_shutdown_requested(void)
{
@@ -1312,6 +1312,18 @@ void qemu_system_powerdown_request(void)
    qemu_notify_event();
}

void qemu_system_debug_request(void)
{
    debug_requested = 1;
    vm_stop(VMSTOP_DEBUG);
}

void qemu_system_vmstop_request(int reason)
{
    vmstop_requested = reason;
    qemu_notify_event();
}

void main_loop_wait(int nonblocking)
{
    IOHandlerRecord *ioh;
@@ -1427,8 +1439,8 @@ static void main_loop(void)
        dev_time += profile_getclock() - ti;
#endif

        if ((r = qemu_debug_requested())) {
            vm_stop(r);
        if (qemu_debug_requested()) {
            vm_stop(VMSTOP_DEBUG);
        }
        if (qemu_shutdown_requested()) {
            monitor_protocol_event(QEVENT_SHUTDOWN, NULL);