Skip to content

Commit

Permalink
shutdown: Add source information to SHUTDOWN and RESET
Browse files Browse the repository at this point in the history
Time to wire up all the call sites that request a shutdown or
reset to use the enum added in the previous patch.

It would have been less churn to keep the common case with no
arguments as meaning guest-triggered, and only modified the
host-triggered code paths, via a wrapper function, but then we'd
still have to audit that I didn't miss any host-triggered spots;
changing the signature forces us to double-check that I correctly
categorized all callers.

Since command line options can change whether a guest reset request
causes an actual reset vs. a shutdown, it's easy to also add the
information to reset requests.

Signed-off-by: Eric Blake <[email protected]>
Acked-by: David Gibson <[email protected]> [ppc parts]
Reviewed-by: Mark Cave-Ayland <[email protected]> [SPARC part]
Reviewed-by: Cornelia Huck <[email protected]> [s390x parts]
Message-Id: <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
  • Loading branch information
ebblake authored and Markus Armbruster committed May 23, 2017
1 parent 802f045 commit cf83f14
Show file tree
Hide file tree
Showing 60 changed files with 98 additions and 98 deletions.
4 changes: 2 additions & 2 deletions hw/acpi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,15 +561,15 @@ static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)
uint16_t sus_typ = (val >> 10) & 7;
switch(sus_typ) {
case 0: /* soft power off */
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
break;
case 1:
qemu_system_suspend_request();
break;
default:
if (sus_typ == ar->pm1.cnt.s4_val) { /* S4 request */
qapi_event_send_suspend_disk(&error_abort);
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
}
break;
}
Expand Down
4 changes: 2 additions & 2 deletions hw/arm/highbank.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ static void hb_regs_write(void *opaque, hwaddr offset,

if (offset == 0xf00) {
if (value == 1 || value == 2) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
} else if (value == 3) {
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
}
}

Expand Down
2 changes: 1 addition & 1 deletion hw/arm/integratorcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static void integratorcm_do_remap(IntegratorCMState *s)
static void integratorcm_set_ctrl(IntegratorCMState *s, uint32_t value)
{
if (value & 8) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
if ((s->cm_ctrl ^ value) & 1) {
/* (value & 1) != 0 means the green "MISC LED" is lit.
Expand Down
2 changes: 1 addition & 1 deletion hw/arm/musicpal.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ static void mv88w8618_pit_write(void *opaque, hwaddr offset,

case MP_BOARD_RESET:
if (value == MP_BOARD_RESET_MAGIC) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
break;
}
Expand Down
10 changes: 6 additions & 4 deletions hw/arm/omap1.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static void omap_wd_timer_write(void *opaque, hwaddr addr,
/* XXX: on T|E hardware somehow this has no effect,
* on Zire 71 it works as specified. */
s->reset = 1;
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
}
s->last_wr = value & 0xff;
Expand Down Expand Up @@ -1545,8 +1545,10 @@ static inline void omap_clkm_idlect1_update(struct omap_mpu_state_s *s,
if (value & (1 << 11)) { /* SETARM_IDLE */
cpu_interrupt(CPU(s->cpu), CPU_INTERRUPT_HALT);
}
if (!(value & (1 << 10))) /* WKUP_MODE */
qemu_system_shutdown_request(); /* XXX: disable wakeup from IRQ */
if (!(value & (1 << 10))) { /* WKUP_MODE */
/* XXX: disable wakeup from IRQ */
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
}

#define SET_CANIDLE(clock, bit) \
if (diff & (1 << bit)) { \
Expand Down Expand Up @@ -1693,7 +1695,7 @@ static void omap_clkm_write(void *opaque, hwaddr addr,
diff = s->clkm.arm_rstct1 ^ value;
s->clkm.arm_rstct1 = value & 0x0007;
if (value & 9) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
s->clkm.cold_start = 0xa;
}
if (diff & ~value & 4) { /* DSP_RST */
Expand Down
2 changes: 1 addition & 1 deletion hw/arm/omap2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ static void omap_prcm_write(void *opaque, hwaddr addr,
case 0x450: /* RM_RSTCTRL_WKUP */
/* TODO: reset */
if (value & 2)
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
break;
case 0x454: /* RM_RSTTIME_WKUP */
s->rsttime_wkup = value & 0x1fff;
Expand Down
2 changes: 1 addition & 1 deletion hw/arm/spitz.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ static void spitz_lcd_hsync_handler(void *opaque, int line, int level)
static void spitz_reset(void *opaque, int line, int level)
{
if (level) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
}

Expand Down
2 changes: 1 addition & 1 deletion hw/arm/stellaris.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ static
void do_sys_reset(void *opaque, int n, int level)
{
if (level) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
}

Expand Down
2 changes: 1 addition & 1 deletion hw/arm/tosa.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void tosa_out_switch(void *opaque, int line, int level)
static void tosa_reset(void *opaque, int line, int level)
{
if (level) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
}

Expand Down
2 changes: 1 addition & 1 deletion hw/i386/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static void port92_write(void *opaque, hwaddr addr, uint64_t val,
s->outport = val;
qemu_set_irq(s->a20_out, (val >> 1) & 1);
if ((val & 1) && !(oldval & 1)) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
}

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 @@ -1398,7 +1398,7 @@ void xen_shutdown_fatal_error(const char *fmt, ...)
va_end(ap);
fprintf(stderr, "Will destroy the domain.\n");
/* destroy the domain */
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR);
}

void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
Expand Down
4 changes: 2 additions & 2 deletions hw/input/pckbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static void outport_write(KBDState *s, uint32_t val)
s->outport = val;
qemu_set_irq(s->a20_out, (val >> 1) & 1);
if (!(val & 1)) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
}

Expand Down Expand Up @@ -301,7 +301,7 @@ static void kbd_write_command(void *opaque, hwaddr addr,
s->outport &= ~KBD_OUT_A20;
break;
case KBD_CCMD_RESET:
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
break;
case KBD_CCMD_NO_OP:
/* ignore that */
Expand Down
4 changes: 2 additions & 2 deletions hw/ipmi/ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ static int ipmi_do_hw_op(IPMIInterface *s, enum ipmi_op op, int checkonly)
if (checkonly) {
return 0;
}
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
return 0;

case IPMI_POWEROFF_CHASSIS:
if (checkonly) {
return 0;
}
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
return 0;

case IPMI_SEND_NMI:
Expand Down
2 changes: 1 addition & 1 deletion hw/isa/lpc_ich9.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ static void ich9_rst_cnt_write(void *opaque, hwaddr addr, uint64_t val,
ICH9LPCState *lpc = opaque;

if (val & 4) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
return;
}
lpc->rst_cnt = val & 0xA; /* keep FULL_RST (bit 3) and SYS_RST (bit 1) */
Expand Down
2 changes: 1 addition & 1 deletion hw/mips/boston.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static void boston_platreg_write(void *opaque, hwaddr addr,
break;
case PLAT_SOFTRST_CTL:
if (val & PLAT_SOFTRST_CTL_SYSRESET) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion hw/mips/mips_malta.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ static void malta_fpga_write(void *opaque, hwaddr addr,
/* SOFTRES Register */
case 0x00500:
if (val == 0x42)
qemu_system_reset_request ();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
break;

/* BRKRES Register */
Expand Down
4 changes: 2 additions & 2 deletions hw/mips/mips_r4k.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ static void mips_qemu_write (void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
if ((addr & 0xffff) == 0 && val == 42)
qemu_system_reset_request ();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
else if ((addr & 0xffff) == 4 && val == 42)
qemu_system_shutdown_request ();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
}

static uint64_t mips_qemu_read (void *opaque, hwaddr addr,
Expand Down
8 changes: 4 additions & 4 deletions hw/misc/arm_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,13 @@ static bool vexpress_cfgctrl_write(arm_sysctl_state *s, unsigned int dcc,
break;
case SYS_CFG_SHUTDOWN:
if (site == SYS_CFG_SITE_MB && device == 0) {
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
return true;
}
break;
case SYS_CFG_REBOOT:
if (site == SYS_CFG_SITE_MB && device == 0) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
return true;
}
break;
Expand Down Expand Up @@ -429,7 +429,7 @@ static void arm_sysctl_write(void *opaque, hwaddr offset,
if (s->lockval == LOCK_VALUE) {
s->resetlevel = val;
if (val & 0x100) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
}
break;
Expand All @@ -438,7 +438,7 @@ static void arm_sysctl_write(void *opaque, hwaddr offset,
if (s->lockval == LOCK_VALUE) {
s->resetlevel = val;
if (val & 0x04) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
}
break;
Expand Down
2 changes: 1 addition & 1 deletion hw/misc/cbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ static inline void retu_write(CBusRetu *s, int reg, uint16_t val)

case RETU_REG_WATCHDOG:
if (val == 0 && (s->cc[0] & 2))
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
break;

case RETU_REG_TXCR:
Expand Down
4 changes: 2 additions & 2 deletions hw/misc/macio/cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ static bool cuda_cmd_powerdown(CUDAState *s,
return false;
}

qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
return true;
}

Expand All @@ -624,7 +624,7 @@ static bool cuda_cmd_reset_system(CUDAState *s,
return false;
}

qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions hw/misc/slavio_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static void slavio_aux2_mem_writeb(void *opaque, hwaddr addr,
val &= AUX2_PWROFF;
s->aux2 = val;
if (val & AUX2_PWROFF)
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
slavio_misc_update_irq(s);
}

Expand Down Expand Up @@ -338,7 +338,7 @@ static void slavio_sysctrl_mem_writel(void *opaque, hwaddr addr,
case 0:
if (val & SYS_RESET) {
s->sysctrl = SYS_RESETSTAT;
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion hw/misc/zynq_slcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static void zynq_slcr_write(void *opaque, hwaddr offset,
switch (offset) {
case PSS_RST_CTRL:
if (val & R_PSS_RST_CTRL_SOFT_RST) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
break;
}
Expand Down
4 changes: 2 additions & 2 deletions hw/pci-host/apb.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ static void apb_config_writel (void *opaque, hwaddr addr,
s->reset_control |= val & RESET_WMASK;
if (val & SOFT_POR) {
s->nr_resets = 0;
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
} else if (val & SOFT_XIR) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
}
break;
Expand Down
2 changes: 1 addition & 1 deletion hw/pci-host/bonito.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static void bonito_writel(void *opaque, hwaddr addr,
}
s->regs[saddr] = val;
if (reset) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
break;
case BONITO_INTENSET:
Expand Down
2 changes: 1 addition & 1 deletion hw/pci-host/piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ static void rcr_write(void *opaque, hwaddr addr, uint64_t val, unsigned len)
PIIX3State *d = opaque;

if (val & 4) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
return;
}
d->rcr = val & 2; /* keep System Reset type only */
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/e500.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ static qemu_irq *ppce500_init_mpic(MachineState *machine, PPCE500Params *params,
static void ppce500_power_off(void *opaque, int line, int on)
{
if (on) {
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
}
}

Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/mpc8544_guts.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static void mpc8544_guts_write(void *opaque, hwaddr addr,
switch (addr) {
case MPC8544_GUTS_ADDR_RSTCR:
if (value & MPC8544_GUTS_RSTCR_RESET) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/ppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static void ppce500_set_irq(void *opaque, int pin, int level)
if (level) {
LOG_IRQ("%s: reset the PowerPC system\n",
__func__);
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}
break;
case PPCE500_INPUT_RESET_CORE:
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/ppc405_uc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,7 @@ void ppc40x_chip_reset(PowerPCCPU *cpu)
void ppc40x_system_reset(PowerPCCPU *cpu)
{
printf("Reset PowerPC system\n");
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}

void store_40x_dbcr0 (CPUPPCState *env, uint32_t val)
Expand Down
2 changes: 1 addition & 1 deletion hw/ppc/spapr_hcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
spapr_ovec_cleanup(ov5_updates);

if (spapr->cas_reboot) {
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
} else {
/* If ppc_spapr_reset() did not set up a HPT but one is necessary
* (because the guest isn't going to use radix) then set it up here. */
Expand Down
4 changes: 2 additions & 2 deletions hw/ppc/spapr_rtas.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static void rtas_power_off(PowerPCCPU *cpu, sPAPRMachineState *spapr,
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
qemu_system_shutdown_request();
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
cpu_stop_current();
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
}
Expand All @@ -124,7 +124,7 @@ static void rtas_system_reboot(PowerPCCPU *cpu, sPAPRMachineState *spapr,
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
}

Expand Down
2 changes: 1 addition & 1 deletion hw/s390x/ipl.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void s390_reipl_request(void)
S390IPLState *ipl = get_ipl_device();

ipl->reipl_requested = true;
qemu_system_reset_request();
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
}

void s390_ipl_prepare_cpu(S390CPU *cpu)
Expand Down
Loading

0 comments on commit cf83f14

Please sign in to comment.