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

Improve vm_stop reason declarations



Define and use dedicated constants for vm_stop reasons, they actually
have nothing to do with the EXCP_* defines used so far. At this chance,
specify more detailed reasons so that VM state change handlers can
evaluate them.

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

#ifdef CONFIG_LINUX
+10 −9
Original line number Diff line number Diff line
@@ -2194,14 +2194,14 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
    const char *type;
    int ret;

    if (running || (reason != EXCP_DEBUG && reason != EXCP_INTERRUPT) ||
        s->state == RS_INACTIVE || s->state == RS_SYSCALL)
    if (running || (reason != VMSTOP_DEBUG && reason != VMSTOP_USER) ||
        s->state == RS_INACTIVE || s->state == RS_SYSCALL) {
        return;

    }
    /* disable single step if it was enable */
    cpu_single_step(env, 0);

    if (reason == EXCP_DEBUG) {
    if (reason == VMSTOP_DEBUG) {
        if (env->watchpoint_hit) {
            switch (env->watchpoint_hit->flags & BP_MEM_ACCESS) {
            case BP_MEM_READ:
@@ -2252,7 +2252,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
    gdb_current_syscall_cb = cb;
    s->state = RS_SYSCALL;
#ifndef CONFIG_USER_ONLY
    vm_stop(EXCP_DEBUG);
    vm_stop(VMSTOP_DEBUG);
#endif
    s->state = RS_IDLE;
    va_start(va, fmt);
@@ -2326,7 +2326,7 @@ static void gdb_read_byte(GDBState *s, int ch)
    if (vm_running) {
        /* when the CPU is running, we cannot do anything except stop
           it when receiving a char */
        vm_stop(EXCP_INTERRUPT);
        vm_stop(VMSTOP_USER);
    } else
#endif
    {
@@ -2588,7 +2588,7 @@ static void gdb_chr_event(void *opaque, int event)
{
    switch (event) {
    case CHR_EVENT_OPENED:
        vm_stop(EXCP_INTERRUPT);
        vm_stop(VMSTOP_USER);
        gdb_has_xml = 0;
        break;
    default:
@@ -2628,8 +2628,9 @@ static int gdb_monitor_write(CharDriverState *chr, const uint8_t *buf, int len)
#ifndef _WIN32
static void gdb_sigterm_handler(int signal)
{
    if (vm_running)
        vm_stop(EXCP_INTERRUPT);
    if (vm_running) {
        vm_stop(VMSTOP_USER);
    }
}
#endif

+1 −1
Original line number Diff line number Diff line
@@ -465,7 +465,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)
        s->bus->dma->ops->set_unit(s->bus->dma, s->unit);
        s->bus->dma->ops->add_status(s->bus->dma, op);
        bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read);
        vm_stop(0);
        vm_stop(VMSTOP_DISKFULL);
    } else {
        if (op & BM_STATUS_DMA_RETRY) {
            dma_buf_commit(s, 0);
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type)
        r->status |= SCSI_REQ_STATUS_RETRY | type;

        bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read);
        vm_stop(0);
        vm_stop(VMSTOP_DISKFULL);
    } else {
        if (type == SCSI_REQ_STATUS_RETRY_READ) {
            r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, 0);
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
        req->next = s->rq;
        s->rq = req;
        bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read);
        vm_stop(0);
        vm_stop(VMSTOP_DISKFULL);
    } else {
        virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
        bdrv_mon_event(s->bs, BDRV_ACTION_REPORT, is_read);
Loading