]> git.proxmox.com Git - mirror_qemu.git/commitdiff
sysemu: Let VMChangeStateHandler take boolean 'running' argument
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Mon, 11 Jan 2021 15:20:20 +0000 (16:20 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Tue, 9 Mar 2021 22:13:57 +0000 (23:13 +0100)
The 'running' argument from VMChangeStateHandler does not require
other value than 0 / 1. Make it a plain boolean.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20210111152020.1422021-3-philmd@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
41 files changed:
accel/xen/xen-all.c
audio/audio.c
block/block-backend.c
gdbstub.c
hw/block/pflash_cfi01.c
hw/block/virtio-blk.c
hw/display/qxl.c
hw/i386/kvm/clock.c
hw/i386/kvm/i8254.c
hw/i386/kvmvapic.c
hw/i386/xen/xen-hvm.c
hw/ide/core.c
hw/intc/arm_gicv3_its_kvm.c
hw/intc/arm_gicv3_kvm.c
hw/intc/spapr_xive_kvm.c
hw/misc/mac_via.c
hw/net/e1000e_core.c
hw/nvram/spapr_nvram.c
hw/ppc/ppc.c
hw/ppc/ppc_booke.c
hw/s390x/tod-kvm.c
hw/scsi/scsi-bus.c
hw/usb/hcd-ehci.c
hw/usb/host-libusb.c
hw/usb/redirect.c
hw/vfio/migration.c
hw/virtio/virtio-rng.c
hw/virtio/virtio.c
include/sysemu/runstate.h
net/net.c
softmmu/memory.c
softmmu/runstate.c
target/arm/kvm.c
target/arm/kvm_arm.h
target/i386/kvm/kvm.c
target/i386/sev.c
target/i386/whpx/whpx-all.c
target/mips/kvm.c
target/ppc/cpu-qom.h
ui/gtk.c
ui/spice-core.c

index e9d2d6aaaa0a1cc2d6762d9aaea57fdb33f7ed06..69aa7d018b28bab1cda4dfa5607c61e1b3eb8a63 100644 (file)
@@ -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) {
index 6734c8af708cd8f60b3eb6714aaa4b6f6a4d79f5..534278edfed2a690747f2298c82d5f66851127a4 100644 (file)
@@ -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;
index e493f17515d88465796d298b5566d9687d54f2e2..413af51f3babd29b38a8419346c24eac2819fd40 100644 (file)
@@ -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;
index 16d7c8f534fa39823f02ddddcad75f1d085122a1..6de21f656741a15818a0fa58f3ed03d09ea6ab5a 100644 (file)
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -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);
index 22287a1522ec770bdeff3f4948ffacbbb14b2cd0..526b70417de8c14258dbeb3d587d466d9cf6b9bb 100644 (file)
@@ -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;
 
index e8600b069da36372f68c6b59baf9f920c299052b..3d2072cf75b9b635f2ed408a607a8be3240215af 100644 (file)
@@ -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;
index 6784d32920c5ca241ae3ae1cc563af95854487f0..93907e82a332969d202d009ec15bdfefa81b14f2 100644 (file)
@@ -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;
index 2d8a3663693652344cd9651690b561240877f4e7..51872dd84c0b3df99b65d700ff921769743d8c8b 100644 (file)
@@ -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;
index c73254e886608ad0ac5c00d94a8057448fcae188..c558893961bacf48fb4165598baaddd41f423a5f 100644 (file)
@@ -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;
index 2c1898032e426c41f9619fafcec1af961f6fd090..46315445d22b46c636874c1541061faf9baa0c3e 100644 (file)
@@ -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());
index 68821d90f52c6c7e1832c5420413217652dd332e..7ce672e5a5c308e1a6283a30807dc5346143b40f 100644 (file)
@@ -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;
index 81db2c95de33643ce971d10246585485197efc2e..fd69ca3167d97d45046e98b978bce40be5ad7bd2 100644 (file)
@@ -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;
 
index 057cb53f13c280860e18e2bbeb76098a6ba4894d..b554d2ede0ad2d601e6e6ea586cd22ed542d7332 100644 (file)
@@ -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;
index d040a5d1e99023b85e095dabd37fc8203f904d18..65a4c880a351f04d78fd5c6c6760d6e176d8aa3d 100644 (file)
@@ -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;
index acc8c3650c4ca84bfb0f7d817afb3a798d1f848e..c00833116071f25281c94cddd102c6cb5357ba52 100644 (file)
@@ -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;
index 488d086a17c4b387bb0bc8985bf5ceb7f0a10d25..ca2f939dd5882a7b0a9d7b19a14ee88de9454382 100644 (file)
@@ -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);
 
index 4dcb92d966bb19790e2760c41f502973c5e5e734..b75f2ab8fc147e4c322fcd5e03a0ee7595160658 100644 (file)
@@ -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;
 
index 9e51bc82ae40059c4cc66ac575140f27105c9fe8..01f77520146368787601fea1cbb02268f2b04b28 100644 (file)
@@ -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;
 
index 5cbbff1f8d0c30ddbed3a0dae47a20e6129a5901..bf28d6bfc8d16c1f304e8e1c3e591b3c48e7773b 100644 (file)
@@ -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;
index 652a21b8064bcd1ade2ea02bdaf6eaa37f2246c3..974c0c8a752851e58be3923e3f5f82f4e615acb5 100644 (file)
@@ -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;
index 6e21d83181d7a483a68e754b1dffe31c16bd048b..0b9447748619d735431d001b6dc860d401ba8bb6 100644 (file)
@@ -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;
index 2d674f94d7de299181a8553e36a756e532e193df..2a0a98cac91d3813929ccb93fe1bb9a57223384c 100644 (file)
@@ -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;
 
index 212eb05d3d3ca64d0b72d6d75bbf0cbd2c81e013..f71af0ad2d8fa96b30383bf42e1ea1dd5c8c9df4 100644 (file)
@@ -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;
 
index 354713a77dc9afb43260bce448c724e6a5061ea2..2518306f527f17d2be30138192c723154a5f114c 100644 (file)
@@ -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);
index 7e9e3fecbfec7ef46d22e3e08ac7dbfaa3a08237..17f06f34179a257e3fd2b354164e986deb7f94c0 100644 (file)
@@ -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;
 
index 00daa50ed81890b8d9f9fd7d381b0078d71843f2..134bdccc4f8b7c3bb6f85f477eadd6049dfb51a6 100644 (file)
@@ -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;
index 76ce9376931bd55e0c0176a8b06c7b9240e7b70a..cc8e9f775d87865a255c80cf977b9719371a8661 100644 (file)
@@ -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;
index 1fd1917ca0f6cf44d65adeb2d811bd6d2552cd7e..07f4e60b30992a2ab93e2759764d9dad182f8644 100644 (file)
@@ -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));
index 3ab35a039a0ead00a2f750bedfaa120163470b1f..a53569157343499a997188621b664a3062183020 100644 (file)
@@ -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);
@@ -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)
 {
index ca30df963d778055ccd7c7f551926e1ec02f5fb2..555c5551077d28444b8b12e8d7f98699f4758bd8 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -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;
index 91f1bf47c301e6618a3ec75449b88684b4c5e7db..9db47b7db6bf72b9403caf94331a54b3b9eab481 100644 (file)
@@ -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) {
index 0187f182260834e374a5ce8e8da1bda6c856d1e8..ce8977c6a29c939ac5890b170031d56aceae230e 100644 (file)
@@ -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;
 
index 00e124c8123978e437c4230964173e79d04e2e06..bebea9012298c7e7d368a621641466e547dce133 100644 (file)
@@ -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);
index eb81b7059eb1c444be134a77662b4c9784404e23..68ec970c4f4c9e8c127c1fbb2f40154e2d917c71 100644 (file)
@@ -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);
 
index c8d61daf68b545e48c7471cb201dede9bb00ae7d..7fe9f527103c6fa11443598f1dc5393f2125f877 100644 (file)
@@ -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;
 
index 0f414df02f39ddf93153958a8560a74a16ab0823..72b9e2ab4010f6a3fb4effda3cb5284fcf0fde1e 100644 (file)
@@ -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;
 
index f0a35df3bba6efdf07b2fdd6ea74b81da5cf33d4..f832f286ac3d957b634cde5c998fdbb22b4672fd 100644 (file)
@@ -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;
 
index 123ec1be7e1fe99ce6c64ef2aa4dbd2471c6ae73..086debd9f013737f9a0e889afc712adb4c3f8f74 100644 (file)
@@ -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)
 {
@@ -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;
index 63b9e8632cab30ffddf2e530a23ffb2704f6db47..118baf8d41f7583227b254bb0b30aafc6d42e421 100644 (file)
@@ -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
 
index 3edaf041defcf9ea1e4de2dcc76f7d3817375f2a..916056d89e8794684ef414665051f8160df2fe05 100644 (file)
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -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;
 
index beee932f5546c5ccaf81552bd5881cd8bd4cd9e5..cadec766fe3ae644060d0f3a249bcb105ba68867 100644 (file)
@@ -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) {