Use runstate_is_running() instead, which is introduced by this commit.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
int cpu_is_stopped(CPUState *env)
{
- return !vm_running || env->stopped;
+ return !runstate_is_running() || env->stopped;
}
static void do_vm_stop(RunState state)
{
- if (vm_running) {
+ if (runstate_is_running()) {
cpu_disable_ticks();
- vm_running = 0;
pause_all_vcpus();
runstate_set(state);
vm_state_notify(0, state);
if (env->stop) {
return 0;
}
- if (env->stopped || !vm_running) {
+ if (env->stopped || !runstate_is_running()) {
return 0;
}
return 1;
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) ||
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(RSTATE_PAUSED);
#ifndef _WIN32
static void gdb_sigterm_handler(int signal)
{
- if (vm_running) {
+ if (runstate_is_running()) {
vm_stop(RSTATE_PAUSED);
}
}
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)
* 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)
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;
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(RSTATE_PRE_MIGRATE);
static void do_info_status(Monitor *mon, QObject **ret_data)
{
*ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i }",
- vm_running, singlestep);
+ runstate_is_running(), singlestep);
}
static qemu_acl *find_acl(Monitor *mon, const char *name)
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(RSTATE_RESTORE);
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();
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) {
}
/* vm time timers */
- if (vm_running) {
+ if (runstate_is_running()) {
qemu_run_timers(vm_clock);
}
int saved_vm_running;
int ret;
- saved_vm_running = vm_running;
+ saved_vm_running = runstate_is_running();
vm_stop(RSTATE_SAVEVM);
if (qemu_savevm_state_blocked(mon)) {
return;
}
- saved_vm_running = vm_running;
+ saved_vm_running = runstate_is_running();
vm_stop(RSTATE_SAVEVM);
memset(sn, 0, sizeof(*sn));
extern const char *bios_name;
-extern int vm_running;
extern const char *qemu_name;
extern uint8_t qemu_uuid[];
int qemu_uuid_parse(const char *str, uint8_t *uuid);
void runstate_init(void);
bool runstate_check(RunState state);
void runstate_set(RunState new_state);
+int runstate_is_running(void);
typedef struct vm_change_state_entry VMChangeStateEntry;
typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
if (!env->tsc_valid) {
msrs[n++].index = MSR_IA32_TSC;
- env->tsc_valid = !vm_running;
+ env->tsc_valid = !runstate_is_running();
}
#ifdef TARGET_X86_64
char icon_title[1024];
const char *status = "";
- if (!vm_running)
+ if (!runstate_is_running())
status = " [Stopped]";
else if (gui_grab) {
if (alt_grab)
{
SDL_Event ev1, *ev = &ev1;
- if (last_vm_running != vm_running) {
- last_vm_running = vm_running;
+ if (last_vm_running != runstate_is_running()) {
+ last_vm_running = runstate_is_running();
sdl_update_caption();
}
#endif
int nb_nics;
NICInfo nd_table[MAX_NICS];
-int vm_running;
int autostart;
static int rtc_utc = 1;
static int rtc_date_offset = -1; /* -1 means no change */
current_run_state = new_state;
}
+int runstate_is_running(void)
+{
+ return runstate_check(RSTATE_RUNNING);
+}
+
/***********************************************************/
/* real time host monotonic timer */
void vm_start(void)
{
- if (!vm_running) {
+ if (!runstate_is_running()) {
cpu_enable_ticks();
- vm_running = 1;
runstate_set(RSTATE_RUNNING);
vm_state_notify(1, RSTATE_RUNNING);
resume_all_vcpus();
* guest resumes and does a hlt with interrupts disabled which
* causes Xen to powerdown the domain.
*/
- if (vm_running) {
+ if (runstate_is_running()) {
if (qemu_shutdown_requested_get()) {
destroy_hvm_domain();
}