mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'qmp/queue/qmp' into staging
This commit is contained in:
+1
-1
@@ -1743,7 +1743,7 @@ static int audio_driver_init (AudioState *s, struct audio_driver *drv)
|
||||
}
|
||||
|
||||
static void audio_vm_change_state_handler (void *opaque, int running,
|
||||
int reason)
|
||||
RunState state)
|
||||
{
|
||||
AudioState *s = opaque;
|
||||
HWVoiceOut *hwo = NULL;
|
||||
|
||||
@@ -115,16 +115,16 @@ void cpu_synchronize_all_post_init(void)
|
||||
|
||||
int cpu_is_stopped(CPUState *env)
|
||||
{
|
||||
return !vm_running || env->stopped;
|
||||
return !runstate_is_running() || env->stopped;
|
||||
}
|
||||
|
||||
static void do_vm_stop(int reason)
|
||||
static void do_vm_stop(RunState state)
|
||||
{
|
||||
if (vm_running) {
|
||||
if (runstate_is_running()) {
|
||||
cpu_disable_ticks();
|
||||
vm_running = 0;
|
||||
pause_all_vcpus();
|
||||
vm_state_notify(0, reason);
|
||||
runstate_set(state);
|
||||
vm_state_notify(0, state);
|
||||
qemu_aio_flush();
|
||||
bdrv_flush_all();
|
||||
monitor_protocol_event(QEVENT_STOP, NULL);
|
||||
@@ -136,7 +136,7 @@ static int cpu_can_run(CPUState *env)
|
||||
if (env->stop) {
|
||||
return 0;
|
||||
}
|
||||
if (env->stopped || !vm_running) {
|
||||
if (env->stopped || !runstate_is_running()) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -147,7 +147,7 @@ static bool cpu_thread_is_idle(CPUState *env)
|
||||
if (env->stop || env->queued_work_first) {
|
||||
return false;
|
||||
}
|
||||
if (env->stopped || !vm_running) {
|
||||
if (env->stopped || !runstate_is_running()) {
|
||||
return true;
|
||||
}
|
||||
if (!env->halted || qemu_cpu_has_work(env) ||
|
||||
@@ -878,10 +878,10 @@ void cpu_stop_current(void)
|
||||
}
|
||||
}
|
||||
|
||||
void vm_stop(int reason)
|
||||
void vm_stop(RunState state)
|
||||
{
|
||||
if (!qemu_thread_is_self(&io_thread)) {
|
||||
qemu_system_vmstop_request(reason);
|
||||
qemu_system_vmstop_request(state);
|
||||
/*
|
||||
* FIXME: should not return to device code in case
|
||||
* vm_stop() has been requested.
|
||||
@@ -889,7 +889,7 @@ void vm_stop(int reason)
|
||||
cpu_stop_current();
|
||||
return;
|
||||
}
|
||||
do_vm_stop(reason);
|
||||
do_vm_stop(state);
|
||||
}
|
||||
|
||||
static int tcg_cpu_exec(CPUState *env)
|
||||
|
||||
@@ -15,7 +15,6 @@ void cpu_synchronize_all_post_init(void);
|
||||
/* vl.c */
|
||||
extern int smp_cores;
|
||||
extern int smp_threads;
|
||||
void vm_state_notify(int running, int reason);
|
||||
bool cpu_exec_all(void);
|
||||
void set_numa_modes(void);
|
||||
void set_cpu_log(const char *optarg);
|
||||
|
||||
@@ -2373,7 +2373,7 @@ void gdb_set_stop_cpu(CPUState *env)
|
||||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
static void gdb_vm_state_change(void *opaque, int running, int reason)
|
||||
static void gdb_vm_state_change(void *opaque, int running, RunState state)
|
||||
{
|
||||
GDBState *s = gdbserver_state;
|
||||
CPUState *env = s->c_cpu;
|
||||
@@ -2384,8 +2384,8 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
|
||||
if (running || s->state == RS_INACTIVE || s->state == RS_SYSCALL) {
|
||||
return;
|
||||
}
|
||||
switch (reason) {
|
||||
case VMSTOP_DEBUG:
|
||||
switch (state) {
|
||||
case RSTATE_DEBUG:
|
||||
if (env->watchpoint_hit) {
|
||||
switch (env->watchpoint_hit->flags & BP_MEM_ACCESS) {
|
||||
case BP_MEM_READ:
|
||||
@@ -2408,25 +2408,25 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
|
||||
tb_flush(env);
|
||||
ret = GDB_SIGNAL_TRAP;
|
||||
break;
|
||||
case VMSTOP_USER:
|
||||
case RSTATE_PAUSED:
|
||||
ret = GDB_SIGNAL_INT;
|
||||
break;
|
||||
case VMSTOP_SHUTDOWN:
|
||||
case RSTATE_SHUTDOWN:
|
||||
ret = GDB_SIGNAL_QUIT;
|
||||
break;
|
||||
case VMSTOP_DISKFULL:
|
||||
case RSTATE_IO_ERROR:
|
||||
ret = GDB_SIGNAL_IO;
|
||||
break;
|
||||
case VMSTOP_WATCHDOG:
|
||||
case RSTATE_WATCHDOG:
|
||||
ret = GDB_SIGNAL_ALRM;
|
||||
break;
|
||||
case VMSTOP_PANIC:
|
||||
case RSTATE_PANICKED:
|
||||
ret = GDB_SIGNAL_ABRT;
|
||||
break;
|
||||
case VMSTOP_SAVEVM:
|
||||
case VMSTOP_LOADVM:
|
||||
case RSTATE_SAVEVM:
|
||||
case RSTATE_RESTORE:
|
||||
return;
|
||||
case VMSTOP_MIGRATE:
|
||||
case RSTATE_PRE_MIGRATE:
|
||||
ret = GDB_SIGNAL_XCPU;
|
||||
break;
|
||||
default:
|
||||
@@ -2463,7 +2463,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(VMSTOP_DEBUG);
|
||||
vm_stop(RSTATE_DEBUG);
|
||||
#endif
|
||||
s->state = RS_IDLE;
|
||||
va_start(va, fmt);
|
||||
@@ -2534,10 +2534,10 @@ static void gdb_read_byte(GDBState *s, int ch)
|
||||
if (ch != '$')
|
||||
return;
|
||||
}
|
||||
if (vm_running) {
|
||||
if (runstate_is_running()) {
|
||||
/* when the CPU is running, we cannot do anything except stop
|
||||
it when receiving a char */
|
||||
vm_stop(VMSTOP_USER);
|
||||
vm_stop(RSTATE_PAUSED);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -2799,7 +2799,7 @@ static void gdb_chr_event(void *opaque, int event)
|
||||
{
|
||||
switch (event) {
|
||||
case CHR_EVENT_OPENED:
|
||||
vm_stop(VMSTOP_USER);
|
||||
vm_stop(RSTATE_PAUSED);
|
||||
gdb_has_xml = 0;
|
||||
break;
|
||||
default:
|
||||
@@ -2839,8 +2839,8 @@ 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(VMSTOP_USER);
|
||||
if (runstate_is_running()) {
|
||||
vm_stop(RSTATE_PAUSED);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -732,7 +732,7 @@ static void DMA_run(void *opaque)
|
||||
struct fs_dma_ctrl *etraxfs_dmac = opaque;
|
||||
int p = 1;
|
||||
|
||||
if (vm_running)
|
||||
if (runstate_is_running())
|
||||
p = etraxfs_dmac_run(etraxfs_dmac);
|
||||
|
||||
if (p)
|
||||
|
||||
+1
-1
@@ -1103,7 +1103,7 @@ static void ahci_irq_set(void *opaque, int n, int level)
|
||||
{
|
||||
}
|
||||
|
||||
static void ahci_dma_restart_cb(void *opaque, int running, int reason)
|
||||
static void ahci_dma_restart_cb(void *opaque, int running, RunState state)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -527,7 +527,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->error_status = op;
|
||||
bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read);
|
||||
vm_stop(VMSTOP_DISKFULL);
|
||||
vm_stop(RSTATE_IO_ERROR);
|
||||
} else {
|
||||
if (op & BM_STATUS_DMA_RETRY) {
|
||||
dma_buf_commit(s, 0);
|
||||
@@ -1910,7 +1910,7 @@ static int ide_nop_int(IDEDMA *dma, int x)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ide_nop_restart(void *opaque, int x, int y)
|
||||
static void ide_nop_restart(void *opaque, int x, RunState y)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@
|
||||
#include <hw/ide.h>
|
||||
#include "iorange.h"
|
||||
#include "dma.h"
|
||||
#include "sysemu.h"
|
||||
|
||||
/* debug IDE devices */
|
||||
//#define DEBUG_IDE
|
||||
@@ -387,7 +388,7 @@ typedef void EndTransferFunc(IDEState *);
|
||||
typedef void DMAStartFunc(IDEDMA *, IDEState *, BlockDriverCompletionFunc *);
|
||||
typedef int DMAFunc(IDEDMA *);
|
||||
typedef int DMAIntFunc(IDEDMA *, int);
|
||||
typedef void DMARestartFunc(void *, int, int);
|
||||
typedef void DMARestartFunc(void *, int, RunState);
|
||||
|
||||
struct unreported_events {
|
||||
bool eject_request;
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ static void bmdma_restart_bh(void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
static void bmdma_restart_cb(void *opaque, int running, int reason)
|
||||
static void bmdma_restart_cb(void *opaque, int running, RunState state)
|
||||
{
|
||||
IDEDMA *dma = opaque;
|
||||
BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma);
|
||||
|
||||
+3
-2
@@ -46,7 +46,7 @@ static void kvmclock_pre_save(void *opaque)
|
||||
* it on next vmsave (which would return a different value). Will be reset
|
||||
* when the VM is continued.
|
||||
*/
|
||||
s->clock_valid = !vm_running;
|
||||
s->clock_valid = !runstate_is_running();
|
||||
}
|
||||
|
||||
static int kvmclock_post_load(void *opaque, int version_id)
|
||||
@@ -59,7 +59,8 @@ static int kvmclock_post_load(void *opaque, int version_id)
|
||||
return kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data);
|
||||
}
|
||||
|
||||
static void kvmclock_vm_state_change(void *opaque, int running, int reason)
|
||||
static void kvmclock_vm_state_change(void *opaque, int running,
|
||||
RunState state)
|
||||
{
|
||||
KVMClockState *s = opaque;
|
||||
|
||||
|
||||
@@ -1453,10 +1453,11 @@ static void qxl_hw_text_update(void *opaque, console_ch_t *chardata)
|
||||
}
|
||||
}
|
||||
|
||||
static void qxl_vm_change_state_handler(void *opaque, int running, int reason)
|
||||
static void qxl_vm_change_state_handler(void *opaque, int running,
|
||||
RunState state)
|
||||
{
|
||||
PCIQXLDevice *qxl = opaque;
|
||||
qemu_spice_vm_change_state_handler(&qxl->ssd, running, reason);
|
||||
qemu_spice_vm_change_state_handler(&qxl->ssd, running, state);
|
||||
|
||||
if (running) {
|
||||
/*
|
||||
|
||||
+2
-2
@@ -217,7 +217,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(VMSTOP_DISKFULL);
|
||||
vm_stop(RSTATE_IO_ERROR);
|
||||
} else {
|
||||
switch (error) {
|
||||
case ENOMEM:
|
||||
@@ -338,7 +338,7 @@ static void scsi_dma_restart_bh(void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
static void scsi_dma_restart_cb(void *opaque, int running, int reason)
|
||||
static void scsi_dma_restart_cb(void *opaque, int running, RunState state)
|
||||
{
|
||||
SCSIDiskState *s = opaque;
|
||||
|
||||
|
||||
+3
-2
@@ -77,7 +77,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(VMSTOP_DISKFULL);
|
||||
vm_stop(RSTATE_IO_ERROR);
|
||||
} else {
|
||||
virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
|
||||
bdrv_acct_done(s->bs, &req->acct);
|
||||
@@ -439,7 +439,8 @@ static void virtio_blk_dma_restart_bh(void *opaque)
|
||||
virtio_submit_multiwrite(s->bs, &mrb);
|
||||
}
|
||||
|
||||
static void virtio_blk_dma_restart_cb(void *opaque, int running, int reason)
|
||||
static void virtio_blk_dma_restart_cb(void *opaque, int running,
|
||||
RunState state)
|
||||
{
|
||||
VirtIOBlock *s = opaque;
|
||||
|
||||
|
||||
+2
-2
@@ -847,7 +847,7 @@ void virtio_cleanup(VirtIODevice *vdev)
|
||||
g_free(vdev);
|
||||
}
|
||||
|
||||
static void virtio_vmstate_change(void *opaque, int running, int reason)
|
||||
static void virtio_vmstate_change(void *opaque, int running, RunState state)
|
||||
{
|
||||
VirtIODevice *vdev = opaque;
|
||||
bool backend_run = running && (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK);
|
||||
@@ -880,7 +880,7 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
|
||||
vdev->queue_sel = 0;
|
||||
vdev->config_vector = VIRTIO_NO_VECTOR;
|
||||
vdev->vq = g_malloc0(sizeof(VirtQueue) * VIRTIO_PCI_QUEUE_MAX);
|
||||
vdev->vm_running = vm_running;
|
||||
vdev->vm_running = runstate_is_running();
|
||||
for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
|
||||
vdev->vq[i].vector = VIRTIO_NO_VECTOR;
|
||||
vdev->vq[i].vdev = vdev;
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ void watchdog_perform_action(void)
|
||||
|
||||
case WDT_PAUSE: /* same as 'stop' command in monitor */
|
||||
watchdog_mon_event("pause");
|
||||
vm_stop(VMSTOP_WATCHDOG);
|
||||
vm_stop(RSTATE_WATCHDOG);
|
||||
break;
|
||||
|
||||
case WDT_DEBUG:
|
||||
|
||||
@@ -1014,7 +1014,7 @@ int kvm_cpu_exec(CPUState *env)
|
||||
|
||||
if (ret < 0) {
|
||||
cpu_dump_state(env, stderr, fprintf, CPU_DUMP_CODE);
|
||||
vm_stop(VMSTOP_PANIC);
|
||||
vm_stop(RSTATE_PANICKED);
|
||||
}
|
||||
|
||||
env->exit_request = 0;
|
||||
|
||||
+9
-5
@@ -70,10 +70,11 @@ void process_incoming_migration(QEMUFile *f)
|
||||
qemu_announce_self();
|
||||
DPRINTF("successfully loaded vm state\n");
|
||||
|
||||
incoming_expected = false;
|
||||
|
||||
if (autostart)
|
||||
if (autostart) {
|
||||
vm_start();
|
||||
} else {
|
||||
runstate_set(RSTATE_PRE_LAUNCH);
|
||||
}
|
||||
}
|
||||
|
||||
int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||
@@ -371,10 +372,10 @@ void migrate_fd_put_ready(void *opaque)
|
||||
DPRINTF("iterate\n");
|
||||
if (qemu_savevm_state_iterate(s->mon, s->file) == 1) {
|
||||
int state;
|
||||
int old_vm_running = vm_running;
|
||||
int old_vm_running = runstate_is_running();
|
||||
|
||||
DPRINTF("done iterating\n");
|
||||
vm_stop(VMSTOP_MIGRATE);
|
||||
vm_stop(RSTATE_PRE_MIGRATE);
|
||||
|
||||
if ((qemu_savevm_state_complete(s->mon, s->file)) < 0) {
|
||||
if (old_vm_running) {
|
||||
@@ -390,6 +391,9 @@ void migrate_fd_put_ready(void *opaque)
|
||||
}
|
||||
state = MIG_STATE_ERROR;
|
||||
}
|
||||
if (state == MIG_STATE_COMPLETED) {
|
||||
runstate_set(RSTATE_POST_MIGRATE);
|
||||
}
|
||||
s->state = state;
|
||||
notifier_list_notify(&migration_state_notifiers, NULL);
|
||||
}
|
||||
|
||||
@@ -1293,7 +1293,7 @@ static void do_singlestep(Monitor *mon, const QDict *qdict)
|
||||
*/
|
||||
static int do_stop(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||
{
|
||||
vm_stop(VMSTOP_USER);
|
||||
vm_stop(RSTATE_PAUSED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1311,10 +1311,15 @@ static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||
{
|
||||
struct bdrv_iterate_context context = { mon, 0 };
|
||||
|
||||
if (incoming_expected) {
|
||||
if (runstate_check(RSTATE_IN_MIGRATE)) {
|
||||
qerror_report(QERR_MIGRATION_EXPECTED);
|
||||
return -1;
|
||||
} else if (runstate_check(RSTATE_PANICKED) ||
|
||||
runstate_check(RSTATE_SHUTDOWN)) {
|
||||
qerror_report(QERR_RESET_REQUIRED);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bdrv_iterate(encrypted_bdrv_it, &context);
|
||||
/* only resume the vm if all keys are set and valid */
|
||||
if (!context.err) {
|
||||
@@ -2613,6 +2618,7 @@ static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||
static void do_info_status_print(Monitor *mon, const QObject *data)
|
||||
{
|
||||
QDict *qdict;
|
||||
const char *status;
|
||||
|
||||
qdict = qobject_to_qdict(data);
|
||||
|
||||
@@ -2626,13 +2632,17 @@ static void do_info_status_print(Monitor *mon, const QObject *data)
|
||||
monitor_printf(mon, "paused");
|
||||
}
|
||||
|
||||
status = qdict_get_str(qdict, "status");
|
||||
if (strcmp(status, "paused") && strcmp(status, "running")) {
|
||||
monitor_printf(mon, " (%s)", status);
|
||||
}
|
||||
|
||||
monitor_printf(mon, "\n");
|
||||
}
|
||||
|
||||
static void do_info_status(Monitor *mon, QObject **ret_data)
|
||||
{
|
||||
*ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i }",
|
||||
vm_running, singlestep);
|
||||
*ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i, 'status': %s }", runstate_is_running(), singlestep, runstate_as_string());
|
||||
}
|
||||
|
||||
static qemu_acl *find_acl(Monitor *mon, const char *name)
|
||||
@@ -2825,10 +2835,10 @@ static int do_closefd(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||
|
||||
static void do_loadvm(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
int saved_vm_running = vm_running;
|
||||
int saved_vm_running = runstate_is_running();
|
||||
const char *name = qdict_get_str(qdict, "name");
|
||||
|
||||
vm_stop(VMSTOP_LOADVM);
|
||||
vm_stop(RSTATE_RESTORE);
|
||||
|
||||
if (load_vmstate(name) == 0 && saved_vm_running) {
|
||||
vm_start();
|
||||
|
||||
+5
-4
@@ -230,7 +230,7 @@ static void icount_adjust(void)
|
||||
int64_t delta;
|
||||
static int64_t last_delta;
|
||||
/* If the VM is not running, then do nothing. */
|
||||
if (!vm_running)
|
||||
if (!runstate_is_running())
|
||||
return;
|
||||
|
||||
cur_time = cpu_get_clock();
|
||||
@@ -388,7 +388,7 @@ static void icount_warp_rt(void *opaque)
|
||||
return;
|
||||
}
|
||||
|
||||
if (vm_running) {
|
||||
if (runstate_is_running()) {
|
||||
int64_t clock = qemu_get_clock_ns(rt_clock);
|
||||
int64_t warp_delta = clock - vm_clock_warp_start;
|
||||
if (use_icount == 1) {
|
||||
@@ -710,7 +710,7 @@ void qemu_run_all_timers(void)
|
||||
}
|
||||
|
||||
/* vm time timers */
|
||||
if (vm_running) {
|
||||
if (runstate_is_running()) {
|
||||
qemu_run_timers(vm_clock);
|
||||
}
|
||||
|
||||
@@ -1116,7 +1116,8 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t)
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
static void alarm_timer_on_change_state_rearm(void *opaque, int running, int reason)
|
||||
static void alarm_timer_on_change_state_rearm(void *opaque, int running,
|
||||
RunState state)
|
||||
{
|
||||
if (running)
|
||||
qemu_rearm_alarm_timer((struct qemu_alarm_timer *) opaque);
|
||||
|
||||
@@ -193,6 +193,10 @@ static const QErrorStringTable qerror_table[] = {
|
||||
.error_fmt = QERR_QMP_EXTRA_MEMBER,
|
||||
.desc = "QMP input object member '%(member)' is unexpected",
|
||||
},
|
||||
{
|
||||
.error_fmt = QERR_RESET_REQUIRED,
|
||||
.desc = "Resetting the Virtual Machine is required",
|
||||
},
|
||||
{
|
||||
.error_fmt = QERR_SET_PASSWD_FAILED,
|
||||
.desc = "Could not set password",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user