Re: [Xen-devel] [PATCH v6 3/5] shutdown: Add source information to SHUTDOWN and RESET
On Mon, May 08, 2017 at 09:32:42AM -0500, Eric Blake wrote: > On 05/08/2017 12:26 AM, David Gibson wrote: > > On Fri, May 05, 2017 at 02:38:08PM -0500, Eric Blake wrote: > >> 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. > >> > >> Replay adds a FIXME to preserve the cause across the replay stream, > >> that will be tackled in the next patch. > >> > >> Signed-off-by: Eric Blake > >> Acked-by: David Gibson [ppc parts] > >> Reviewed-by: Mark Cave-Ayland [SPARC part] > > > > [snip] > > > >> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > >> index 9f18f75..2735fe9 100644 > >> --- a/hw/ppc/spapr_hcall.c > >> +++ b/hw/ppc/spapr_hcall.c > >> @@ -1166,7 +1166,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); > > > > I'm not 100% sure about this one, since I'm not sure 100% of how the > > different enum values are defined. This one is tripped when feature > > negotiation between firmware and guest can't be satisfied without > > rebooting (next time round the firmware will use some different > > options). > > Patch 2/5 introduced the enum. The biggest part of the patch (for now) > is that anything SHUTDOWN_CAUSE_HOST_ will be exposed to the QMP client > as host-triggered, anything SHUTDOWN_CAUSE_GUEST_ will be exposed as > guest-triggered. I basically used SHUTDOWN_CAUSE_GUEST_RESET for any > call to qemu_system_reset_requst() underneath the hw/ tree, because the > hw/ tree is emulating guest behavior and therefore it is presumably a > reset caused by a guest request. Ok. > > So it's essentially a firmware/hypervisor triggered reset, but one > > that should only ever be tripped during early guest boot. Is > > CAUSE_GUEST_RESET correct for that? > > Of course, I'm not an export on SPAPR, so I'll happily change it to > anything else if you think that is more appropriate. But the rule of > thumb I went by is whether this is qemu emulating a bare-metal > reset/shutdown, vs. qemu killing the guest without waiting for guest > instructions to reach some magic > memory/register/ACPI/who-knows-what-else request. While it may happen > only early during guest boot, it is still the guest firmware that is > requesting it, and not qemu causing a unilateral death. So, I think GUEST_RESET is the right choice here. The distinctions are blurry, because PAPR is built as a paravirtualized platform - there is no bare metal equivalent. For example, on PowerVM this really would be initiated by guest firmware, but it's working in communication with the hypervisor. But with qemu and KVM, we actually implement all this negotiation logic in qemu directly (this is easier than having complex communication channels between guest firware and qemu). But I guess the point is that this is a "business as usual" reboot and the guest is expected to continue booting at some point after this, rather than being killed by qemu. Things get more complicated still if we think about what happens if this feature negotiation fails - then we can't boot the guest OS. At the moment the few cases where this happens, I think we just exit qemu, but notifying this as a host caused shutdown might be appropriate. -- David Gibson| I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson signature.asc Description: PGP signature ___ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v6 3/5] shutdown: Add source information to SHUTDOWN and RESET
On 05/08/2017 12:26 AM, David Gibson wrote: > On Fri, May 05, 2017 at 02:38:08PM -0500, Eric Blake wrote: >> 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. >> >> Replay adds a FIXME to preserve the cause across the replay stream, >> that will be tackled in the next patch. >> >> Signed-off-by: Eric Blake >> Acked-by: David Gibson [ppc parts] >> Reviewed-by: Mark Cave-Ayland [SPARC part] > > [snip] > >> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c >> index 9f18f75..2735fe9 100644 >> --- a/hw/ppc/spapr_hcall.c >> +++ b/hw/ppc/spapr_hcall.c >> @@ -1166,7 +1166,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); > > I'm not 100% sure about this one, since I'm not sure 100% of how the > different enum values are defined. This one is tripped when feature > negotiation between firmware and guest can't be satisfied without > rebooting (next time round the firmware will use some different > options). Patch 2/5 introduced the enum. The biggest part of the patch (for now) is that anything SHUTDOWN_CAUSE_HOST_ will be exposed to the QMP client as host-triggered, anything SHUTDOWN_CAUSE_GUEST_ will be exposed as guest-triggered. I basically used SHUTDOWN_CAUSE_GUEST_RESET for any call to qemu_system_reset_requst() underneath the hw/ tree, because the hw/ tree is emulating guest behavior and therefore it is presumably a reset caused by a guest request. > > So it's essentially a firmware/hypervisor triggered reset, but one > that should only ever be tripped during early guest boot. Is > CAUSE_GUEST_RESET correct for that? Of course, I'm not an export on SPAPR, so I'll happily change it to anything else if you think that is more appropriate. But the rule of thumb I went by is whether this is qemu emulating a bare-metal reset/shutdown, vs. qemu killing the guest without waiting for guest instructions to reach some magic memory/register/ACPI/who-knows-what-else request. While it may happen only early during guest boot, it is still the guest firmware that is requesting it, and not qemu causing a unilateral death. > > Apart from this, ppc changes > > Acked-by: David Gibson Thanks. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org signature.asc Description: OpenPGP digital signature ___ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v6 3/5] shutdown: Add source information to SHUTDOWN and RESET
On Fri, May 05, 2017 at 02:38:08PM -0500, Eric Blake wrote: > 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. > > Replay adds a FIXME to preserve the cause across the replay stream, > that will be tackled in the next patch. > > Signed-off-by: Eric Blake > Acked-by: David Gibson [ppc parts] > Reviewed-by: Mark Cave-Ayland [SPARC part] [snip] > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > index 9f18f75..2735fe9 100644 > --- a/hw/ppc/spapr_hcall.c > +++ b/hw/ppc/spapr_hcall.c > @@ -1166,7 +1166,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); I'm not 100% sure about this one, since I'm not sure 100% of how the different enum values are defined. This one is tripped when feature negotiation between firmware and guest can't be satisfied without rebooting (next time round the firmware will use some different options). So it's essentially a firmware/hypervisor triggered reset, but one that should only ever be tripped during early guest boot. Is CAUSE_GUEST_RESET correct for that? Apart from this, ppc changes Acked-by: David Gibson -- David Gibson| I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson signature.asc Description: PGP signature ___ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
[Xen-devel] [PATCH v6 3/5] shutdown: Add source information to SHUTDOWN and RESET
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. Replay adds a FIXME to preserve the cause across the replay stream, that will be tackled in the next patch. Signed-off-by: Eric Blake Acked-by: David Gibson [ppc parts] Reviewed-by: Mark Cave-Ayland [SPARC part] --- v6: defer event additions to later, add reviews of unchanged portions v5: drop accidental addition of unrelated files v4: s/ShutdownType/ShutdownCause/, no thanks to mingw header pollution v3: retitle again, fix qemu-iotests, use enum rather than raw bool in all callers v2: retitle (was "event: Add signal information to SHUTDOWN"), completely rework to post bool based on whether it is guest-initiated v1: initial submission, exposing just Unix signals from host --- include/sysemu/sysemu.h | 4 ++-- vl.c| 17 - hw/acpi/core.c | 4 ++-- hw/arm/highbank.c | 4 ++-- hw/arm/integratorcp.c | 2 +- hw/arm/musicpal.c | 2 +- hw/arm/omap1.c | 10 ++ hw/arm/omap2.c | 2 +- hw/arm/spitz.c | 2 +- hw/arm/stellaris.c | 2 +- hw/arm/tosa.c | 2 +- hw/i386/pc.c| 2 +- hw/i386/xen/xen-hvm.c | 2 +- hw/input/pckbd.c| 4 ++-- hw/ipmi/ipmi.c | 4 ++-- hw/isa/lpc_ich9.c | 2 +- hw/mips/boston.c| 2 +- hw/mips/mips_malta.c| 2 +- hw/mips/mips_r4k.c | 4 ++-- hw/misc/arm_sysctl.c| 8 hw/misc/cbus.c | 2 +- hw/misc/macio/cuda.c| 4 ++-- hw/misc/slavio_misc.c | 4 ++-- hw/misc/zynq_slcr.c | 2 +- hw/pci-host/apb.c | 4 ++-- hw/pci-host/bonito.c| 2 +- hw/pci-host/piix.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc/mpc8544_guts.c | 2 +- hw/ppc/ppc.c| 2 +- hw/ppc/ppc405_uc.c | 2 +- hw/ppc/spapr_hcall.c| 2 +- hw/ppc/spapr_rtas.c | 4 ++-- hw/s390x/ipl.c | 2 +- hw/sh4/r2d.c| 2 +- hw/timer/etraxfs_timer.c| 2 +- hw/timer/m48t59.c | 4 ++-- hw/timer/milkymist-sysctl.c | 4 ++-- hw/timer/pxa2xx_timer.c | 2 +- hw/watchdog/watchdog.c | 2 +- hw/xenpv/xen_domainbuild.c | 2 +- hw/xtensa/xtfpga.c | 2 +- kvm-all.c | 6 +++--- os-win32.c | 2 +- qmp.c | 4 ++-- replay/replay.c | 3 ++- target/alpha/sys_helper.c | 4 ++-- target/arm/psci.c | 4 ++-- target/i386/excp_helper.c | 2 +- target/i386/hax-all.c | 6 +++--- target/i386/helper.c| 2 +- target/i386/kvm.c | 2 +- target/s390x/helper.c | 2 +- target/s390x/kvm.c | 4 ++-- target/s390x/misc_helper.c | 4 ++-- target/sparc/int32_helper.c | 2 +- ui/sdl.c| 2 +- ui/sdl2.c | 4 ++-- trace-events| 2 +- ui/cocoa.m | 2 +- 60 files changed, 98 insertions(+), 96 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index e4da9d4..89d0e3e 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -65,13 +65,13 @@ typedef enum WakeupReason { QEMU_WAKEUP_REASON_OTHER, } WakeupReason; -void qemu_system_reset_request(void); +void qemu_system_reset_request(ShutdownCause reason); void qemu_system_suspend_request(void); void qemu_register_suspend_notifier(Notifier *notifier); void qemu_system_wakeup_request(WakeupReason reason); void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); void qemu_register_wakeup_notifier(Notifier *notifier); -void qemu_system_shutdown_request(void); +void qemu_system_shutdown_request(ShutdownCause reason); void qemu_system_powerdown_request(void); void qemu_register_powerdown_notifier(Notifier *notifier); void qemu_system_debug_request(void); diff --git a/vl.c b/vl.c index 6069fb2..9579d5f 100644 --- a/vl.c +++ b/vl.c @@ -1725,7 +1725,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info) if (!no_shutdown) { qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF, !!info, info, &error_abort); -qemu_system_shutdown_request(); +qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_PANIC); } if (info) { @@ -1742,13 +174