Skip to content

Commit

Permalink
sysemu: Let VMChangeStateHandler take boolean 'running' argument
Browse files Browse the repository at this point in the history
The 'running' argument from VMChangeStateHandler does not require
other value than 0 / 1. Make it a plain boolean.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Acked-by: David Gibson <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
  • Loading branch information
philmd authored and vivier committed Mar 9, 2021
1 parent 0a38950 commit 538f049
Show file tree
Hide file tree
Showing 41 changed files with 49 additions and 43 deletions.
2 changes: 1 addition & 1 deletion accel/xen/xen-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)
}


static void xen_change_state_handler(void *opaque, int running,
static void xen_change_state_handler(void *opaque, bool running,
RunState state)
{
if (running) {
Expand Down
2 changes: 1 addition & 1 deletion audio/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ static int audio_driver_init(AudioState *s, struct audio_driver *drv,
}
}

static void audio_vm_change_state_handler (void *opaque, int running,
static void audio_vm_change_state_handler (void *opaque, bool running,
RunState state)
{
AudioState *s = opaque;
Expand Down
2 changes: 1 addition & 1 deletion block/block-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static const char *blk_root_get_name(BdrvChild *child)
return blk_name(child->opaque);
}

static void blk_vm_state_changed(void *opaque, int running, RunState state)
static void blk_vm_state_changed(void *opaque, bool running, RunState state)
{
Error *local_err = NULL;
BlockBackend *blk = opaque;
Expand Down
2 changes: 1 addition & 1 deletion gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2754,7 +2754,7 @@ void gdb_set_stop_cpu(CPUState *cpu)
}

#ifndef CONFIG_USER_ONLY
static void gdb_vm_state_change(void *opaque, int running, RunState state)
static void gdb_vm_state_change(void *opaque, bool running, RunState state)
{
CPUState *cpu = gdbserver_state.c_cpu;
g_autoptr(GString) buf = g_string_new(NULL);
Expand Down
2 changes: 1 addition & 1 deletion hw/block/pflash_cfi01.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ void pflash_cfi01_legacy_drive(PFlashCFI01 *fl, DriveInfo *dinfo)
loc_pop(&loc);
}

static void postload_update_cb(void *opaque, int running, RunState state)
static void postload_update_cb(void *opaque, bool running, RunState state)
{
PFlashCFI01 *pfl = opaque;

Expand Down
2 changes: 1 addition & 1 deletion hw/block/virtio-blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ static void virtio_blk_dma_restart_bh(void *opaque)
virtio_blk_process_queued_requests(s, true);
}

static void virtio_blk_dma_restart_cb(void *opaque, int running,
static void virtio_blk_dma_restart_cb(void *opaque, bool running,
RunState state)
{
VirtIOBlock *s = opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/display/qxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ static void qxl_dirty_surfaces(PCIQXLDevice *qxl)
}
}

static void qxl_vm_change_state_handler(void *opaque, int running,
static void qxl_vm_change_state_handler(void *opaque, bool running,
RunState state)
{
PCIQXLDevice *qxl = opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/kvm/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void do_kvmclock_ctrl(CPUState *cpu, run_on_cpu_data data)
}
}

static void kvmclock_vm_state_change(void *opaque, int running,
static void kvmclock_vm_state_change(void *opaque, bool running,
RunState state)
{
KVMClockState *s = opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/kvm/i8254.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void kvm_pit_irq_control(void *opaque, int n, int enable)
kvm_pit_put(pit);
}

static void kvm_pit_vm_state_change(void *opaque, int running,
static void kvm_pit_vm_state_change(void *opaque, bool running,
RunState state)
{
KVMPITState *s = opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/kvmvapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ static void do_vapic_enable(CPUState *cs, run_on_cpu_data data)
s->state = VAPIC_ACTIVE;
}

static void kvmvapic_vm_state_change(void *opaque, int running,
static void kvmvapic_vm_state_change(void *opaque, bool running,
RunState state)
{
MachineState *ms = MACHINE(qdev_get_machine());
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/xen/xen-hvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ static void xen_main_loop_prepare(XenIOState *state)
}


static void xen_hvm_change_state_handler(void *opaque, int running,
static void xen_hvm_change_state_handler(void *opaque, bool running,
RunState rstate)
{
XenIOState *state = opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/ide/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,7 @@ static void ide_restart_bh(void *opaque)
}
}

static void ide_restart_cb(void *opaque, int running, RunState state)
static void ide_restart_cb(void *opaque, bool running, RunState state)
{
IDEBus *bus = opaque;

Expand Down
2 changes: 1 addition & 1 deletion hw/intc/arm_gicv3_its_kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int kvm_its_send_msi(GICv3ITSState *s, uint32_t value, uint16_t devid)
*
* The tables get flushed to guest RAM whenever the VM gets stopped.
*/
static void vm_change_state_handler(void *opaque, int running,
static void vm_change_state_handler(void *opaque, bool running,
RunState state)
{
GICv3ITSState *s = (GICv3ITSState *)opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/intc/arm_gicv3_kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = {
*
* The tables get flushed to guest RAM whenever the VM gets stopped.
*/
static void vm_change_state_handler(void *opaque, int running,
static void vm_change_state_handler(void *opaque, bool running,
RunState state)
{
GICv3State *s = (GICv3State *)opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/intc/spapr_xive_kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ static int kvmppc_xive_get_queues(SpaprXive *xive, Error **errp)
* runs again. If an interrupt was queued while the VM was stopped,
* simply generate a trigger.
*/
static void kvmppc_xive_change_state_handler(void *opaque, int running,
static void kvmppc_xive_change_state_handler(void *opaque, bool running,
RunState state)
{
SpaprXive *xive = opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/misc/mac_via.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ static void mac_via_init(Object *obj)
TYPE_ADB_BUS, DEVICE(obj), "adb.0");
}

static void postload_update_cb(void *opaque, int running, RunState state)
static void postload_update_cb(void *opaque, bool running, RunState state)
{
MacVIAState *m = MAC_VIA(opaque);

Expand Down
2 changes: 1 addition & 1 deletion hw/net/e1000e_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3298,7 +3298,7 @@ e1000e_autoneg_resume(E1000ECore *core)
}

static void
e1000e_vm_state_change(void *opaque, int running, RunState state)
e1000e_vm_state_change(void *opaque, bool running, RunState state)
{
E1000ECore *core = opaque;

Expand Down
2 changes: 1 addition & 1 deletion hw/nvram/spapr_nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static int spapr_nvram_pre_load(void *opaque)
return 0;
}

static void postload_update_cb(void *opaque, int running, RunState state)
static void postload_update_cb(void *opaque, bool running, RunState state)
{
SpaprNvram *nvram = opaque;

Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/ppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ static void timebase_load(PPCTimebase *tb)
}
}

void cpu_ppc_clock_vm_state_change(void *opaque, int running,
void cpu_ppc_clock_vm_state_change(void *opaque, bool running,
RunState state)
{
PPCTimebase *tb = opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/ppc_booke.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static void ppc_booke_timer_reset_handle(void *opaque)
* action will be taken. To avoid this we always clear the watchdog state when
* state changes to running.
*/
static void cpu_state_change_handler(void *opaque, int running, RunState state)
static void cpu_state_change_handler(void *opaque, bool running, RunState state)
{
PowerPCCPU *cpu = opaque;
CPUPPCState *env = &cpu->env;
Expand Down
2 changes: 1 addition & 1 deletion hw/s390x/tod-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static void kvm_s390_tod_set(S390TODState *td, const S390TOD *tod, Error **errp)
}
}

static void kvm_s390_tod_vm_state_change(void *opaque, int running,
static void kvm_s390_tod_vm_state_change(void *opaque, bool running,
RunState state)
{
S390TODState *td = opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/scsi/scsi-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void scsi_req_retry(SCSIRequest *req)
req->retry = true;
}

static void scsi_dma_restart_cb(void *opaque, int running, RunState state)
static void scsi_dma_restart_cb(void *opaque, bool running, RunState state)
{
SCSIDevice *s = opaque;

Expand Down
2 changes: 1 addition & 1 deletion hw/usb/hcd-ehci.c
Original file line number Diff line number Diff line change
Expand Up @@ -2436,7 +2436,7 @@ static int usb_ehci_post_load(void *opaque, int version_id)
return 0;
}

static void usb_ehci_vm_state_change(void *opaque, int running, RunState state)
static void usb_ehci_vm_state_change(void *opaque, bool running, RunState state)
{
EHCIState *ehci = opaque;

Expand Down
2 changes: 1 addition & 1 deletion hw/usb/host-libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ type_init(usb_host_register_types)
static QEMUTimer *usb_auto_timer;
static VMChangeStateEntry *usb_vmstate;

static void usb_host_vm_state(void *unused, int running, RunState state)
static void usb_host_vm_state(void *unused, bool running, RunState state)
{
if (running) {
usb_host_auto_check(unused);
Expand Down
2 changes: 1 addition & 1 deletion hw/usb/redirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ static void usbredir_chardev_event(void *opaque, QEMUChrEvent event)
* init + destroy
*/

static void usbredir_vm_state_change(void *priv, int running, RunState state)
static void usbredir_vm_state_change(void *priv, bool running, RunState state)
{
USBRedirDevice *dev = priv;

Expand Down
2 changes: 1 addition & 1 deletion hw/vfio/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ static SaveVMHandlers savevm_vfio_handlers = {

/* ---------------------------------------------------------------------- */

static void vfio_vmstate_change(void *opaque, int running, RunState state)
static void vfio_vmstate_change(void *opaque, bool running, RunState state)
{
VFIODevice *vbasedev = opaque;
VFIOMigration *migration = vbasedev->migration;
Expand Down
2 changes: 1 addition & 1 deletion hw/virtio/virtio-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static uint64_t get_features(VirtIODevice *vdev, uint64_t f, Error **errp)
return f;
}

static void virtio_rng_vm_state_change(void *opaque, int running,
static void virtio_rng_vm_state_change(void *opaque, bool running,
RunState state)
{
VirtIORNG *vrng = opaque;
Expand Down
2 changes: 1 addition & 1 deletion hw/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,7 @@ void virtio_cleanup(VirtIODevice *vdev)
qemu_del_vm_change_state_handler(vdev->vmstate);
}

static void virtio_vmstate_change(void *opaque, int running, RunState state)
static void virtio_vmstate_change(void *opaque, bool running, RunState state)
{
VirtIODevice *vdev = opaque;
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
Expand Down
10 changes: 8 additions & 2 deletions include/sysemu/runstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bool runstate_is_running(void);
bool runstate_needs_reset(void);
bool runstate_store(char *str, size_t size);

typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
typedef void VMChangeStateHandler(void *opaque, bool running, RunState state);

VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
void *opaque);
Expand All @@ -20,7 +20,13 @@ VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev,
VMChangeStateHandler *cb,
void *opaque);
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
void vm_state_notify(int running, RunState state);
/**
* vm_state_notify: Notify the state of the VM
*
* @running: whether the VM is running or not.
* @state: the #RunState of the VM.
*/
void vm_state_notify(bool running, RunState state);

static inline bool shutdown_caused_by_guest(ShutdownCause cause)
{
Expand Down
2 changes: 1 addition & 1 deletion net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ void qmp_set_link(const char *name, bool up, Error **errp)
}
}

static void net_vm_change_state_handler(void *opaque, int running,
static void net_vm_change_state_handler(void *opaque, bool running,
RunState state)
{
NetClientState *nc;
Expand Down
2 changes: 1 addition & 1 deletion softmmu/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2679,7 +2679,7 @@ static void memory_global_dirty_log_do_stop(void)
MEMORY_LISTENER_CALL_GLOBAL(log_global_stop, Reverse);
}

static void memory_vm_change_state_handler(void *opaque, int running,
static void memory_vm_change_state_handler(void *opaque, bool running,
RunState state)
{
if (running) {
Expand Down
2 changes: 1 addition & 1 deletion softmmu/runstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e)
g_free(e);
}

void vm_state_notify(int running, RunState state)
void vm_state_notify(bool running, RunState state)
{
VMChangeStateEntry *e, *next;

Expand Down
2 changes: 1 addition & 1 deletion target/arm/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
return MEMTXATTRS_UNSPECIFIED;
}

void kvm_arm_vm_state_change(void *opaque, int running, RunState state)
void kvm_arm_vm_state_change(void *opaque, bool running, RunState state)
{
CPUState *cs = opaque;
ARMCPU *cpu = ARM_CPU(cs);
Expand Down
2 changes: 1 addition & 1 deletion target/arm/kvm_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void kvm_arm_get_virtual_time(CPUState *cs);
*/
void kvm_arm_put_virtual_time(CPUState *cs);

void kvm_arm_vm_state_change(void *opaque, int running, RunState state);
void kvm_arm_vm_state_change(void *opaque, bool running, RunState state);

int kvm_arm_vgic_probe(void);

Expand Down
2 changes: 1 addition & 1 deletion target/i386/kvm/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ static int kvm_inject_mce_oldstyle(X86CPU *cpu)
return 0;
}

static void cpu_update_state(void *opaque, int running, RunState state)
static void cpu_update_state(void *opaque, bool running, RunState state)
{
CPUX86State *env = opaque;

Expand Down
2 changes: 1 addition & 1 deletion target/i386/sev.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ sev_launch_finish(SevGuestState *sev)
}

static void
sev_vm_state_change(void *opaque, int running, RunState state)
sev_vm_state_change(void *opaque, bool running, RunState state)
{
SevGuestState *sev = opaque;

Expand Down
2 changes: 1 addition & 1 deletion target/i386/whpx/whpx-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu)

static Error *whpx_migration_blocker;

static void whpx_cpu_update_state(void *opaque, int running, RunState state)
static void whpx_cpu_update_state(void *opaque, bool running, RunState state)
{
CPUX86State *env = opaque;

Expand Down
4 changes: 2 additions & 2 deletions target/mips/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
KVM_CAP_LAST_INFO
};

static void kvm_mips_update_state(void *opaque, int running, RunState state);
static void kvm_mips_update_state(void *opaque, bool running, RunState state);

unsigned long kvm_arch_vcpu_id(CPUState *cs)
{
Expand Down Expand Up @@ -553,7 +553,7 @@ static int kvm_mips_restore_count(CPUState *cs)
/*
* Handle the VM clock being started or stopped
*/
static void kvm_mips_update_state(void *opaque, int running, RunState state)
static void kvm_mips_update_state(void *opaque, bool running, RunState state)
{
CPUState *cs = opaque;
int ret;
Expand Down
2 changes: 1 addition & 1 deletion target/ppc/cpu-qom.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ extern const VMStateDescription vmstate_ppc_timebase;
.offset = vmstate_offset_value(_state, _field, PPCTimebase), \
}

void cpu_ppc_clock_vm_state_change(void *opaque, int running,
void cpu_ppc_clock_vm_state_change(void *opaque, bool running,
RunState state);
#endif

Expand Down
2 changes: 1 addition & 1 deletion ui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ static const DisplayChangeListenerOps dcl_egl_ops = {

/** QEMU Events **/

static void gd_change_runstate(void *opaque, int running, RunState state)
static void gd_change_runstate(void *opaque, bool running, RunState state)
{
GtkDisplayState *s = opaque;

Expand Down
2 changes: 1 addition & 1 deletion ui/spice-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ static int add_channel(void *opaque, const char *name, const char *value,
return 0;
}

static void vm_change_state_handler(void *opaque, int running,
static void vm_change_state_handler(void *opaque, bool running,
RunState state)
{
if (running) {
Expand Down

0 comments on commit 538f049

Please sign in to comment.