Skip to contentSkip to conversation

Misc: Make watchdog devices using qemu_system_reset_request() use watchdog_perfom_action()

PATCH Superseded Abhiram Tilak 2 participants 9 messages Feb 16, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Misc: Make watchdog devices using qemu_system_reset_request() use watchdog_perfom_action()

A few watchdog devices use qemu_system_reset_request(). This is not ideal since behaviour of watchdog-expiry can't be changed by QMP using watchdog_action. As stated in BiteSizedTasks wiki page, instead of using qemu_system_reset_request() to reset when a watchdog timer expires, let watchdog_perform_action() decide what to do.

I am unsure about the changes in spapr_watchdog.c in patch 3, it would be great if any of the maintainers review it.

Abhiram Tilak (3):
misc: m48t59: replace qemu_system_reset_request() call with
watchdog_perform_action()
misc: pxa2xx_timer: replace qemu_system_reset_request() call with
watchdog_perform_action()
misc: ppc/spapr: replace qemu_system_reset_request() calls with
watchdog_perform_action()

 hw/rtc/m48t59.c              | 4 ++--
 hw/timer/pxa2xx_timer.c      | 3 ++-
 hw/watchdog/spapr_watchdog.c | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)

--
2.42.1

#4 lore raw

PATCH 2/3 misc: pxa2xx_timer: replace qemu_system_reset_request() call with watchdog_perform_action()

A few watchdog devices use qemu_system_reset_request(). This is not ideal since behaviour of watchdog-expiry can't be changed by QMP using watchdog_action. As stated in BiteSizedTasks wiki page, instead of using qemu_system_reset_request() to reset when a watchdog timer expires, let watchdog_perform_action() decide what to do.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124

---
 hw/timer/pxa2xx_timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/timer/pxa2xx_timer.c +2 -1
index 6a7d5551f4..6479ab1a8b 100644
@@ -18,6 +18,7 @@
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "qom/object.h"
+#include "sysemu/watchdog.h"
 
 #define OSMR0	0x00
 #define OSMR1	0x04
@@ -417,7 +418,7 @@ static void pxa2xx_timer_tick(void *opaque)
     if (t->num == 3)
         if (i->reset3 & 1) {
             i->reset3 = 0;
-            qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
+            watchdog_perform_action();
         }
 }
 
Signature · 1 line
2.42.1
#1 lore raw

PATCH 1/3 misc: m48t59: replace qemu_system_reset_request() call with watchdog_perform_action()

In reply to Abhiram Tilak

A few watchdog devices use qemu_system_reset_request(). This is not ideal since behaviour of watchdog-expiry can't be changed by QMP using watchdog_action. As stated in BiteSizedTasks wiki page, instead of using qemu_system_reset_request() to reset when a watchdog timer expires, let watchdog_perform_action() decide what to do.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124

---
 hw/rtc/m48t59.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/rtc/m48t59.c +2 -2
index aa44c4b20c..ebda084478 100644
@@ -36,6 +36,7 @@
 #include "qemu/bcd.h"
 #include "qemu/module.h"
 #include "trace.h"
+#include "sysemu/watchdog.h"
 
 #include "m48t59-internal.h"
 #include "migration/vmstate.h"
@@ -163,8 +164,7 @@ static void watchdog_cb (void *opaque)
     if (NVRAM->buffer[0x1FF7] & 0x80) {
         NVRAM->buffer[0x1FF7] = 0x00;
         NVRAM->buffer[0x1FFC] &= ~0x40;
-        /* May it be a hw CPU Reset instead ? */
-        qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
+        watchdog_perform_action(); /* watchdog-expired action */
     } else {
         qemu_set_irq(NVRAM->IRQ, 1);
         qemu_set_irq(NVRAM->IRQ, 0);
Signature · 1 line
2.42.1
#6 lore raw

PATCH 3/3 misc: ppc/spapr: replace qemu_system_reset_request() calls with watchdog_perform_action()

In reply to Abhiram Tilak

A few watchdog devices use qemu_system_reset_request(). This is not ideal since behaviour of watchdog-expiry can't be changed by QMP using watchdog_action. As stated in BiteSizedTasks wiki page, instead of using qemu_system_reset_request() to reset when a watchdog timer expires, let watchdog_perform_action() decide what to do.

I am unsure about the changes in spapr_watchdog.c in patch 3, it would be great if any of the maintainers review it.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124

---
 hw/watchdog/spapr_watchdog.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/watchdog/spapr_watchdog.c +2 -1
index 2bb1d3c532..9751b19506 100644
@@ -18,6 +18,7 @@
 #include "target/ppc/cpu.h"
 #include "migration/vmstate.h"
 #include "trace.h"
+#include "sysemu/watchdog.h"
 
 #include "hw/ppc/spapr.h"
 
@@ -114,7 +115,7 @@ static void watchdog_expired(void *pw)
         qemu_system_vmstop_request(RUN_STATE_SHUTDOWN);
         break;
     case PSERIES_WDTF_ACTION_HARD_RESTART:
-        qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
+        watchdog_perform_action();
         break;
     case PSERIES_WDTF_ACTION_DUMP_RESTART:
         CPU_FOREACH(cs) {
Signature · 1 line
2.42.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] misc: m48t59: replace qemu_system_reset_request() call with watchdog_perform_action()

In reply to Abhiram Tilak
Quoted 26 lines · Abhiram Tilak

A few watchdog devices use qemu_system_reset_request(). This is not ideal since behaviour of watchdog-expiry can't be changed by QMP using watchdog_action. As stated in BiteSizedTasks wiki page, instead of using qemu_system_reset_request() to reset when a watchdog timer expires, let watchdog_perform_action() decide what to do.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124

---
 hw/rtc/m48t59.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/rtc/m48t59.c +1 -0
index aa44c4b20c..ebda084478 100644
@@ -36,6 +36,7 @@
 #include "qemu/bcd.h"
 #include "qemu/module.h"
 #include "trace.h"
+#include "sysemu/watchdog.h"
 
 #include "m48t59-internal.h"
 #include "migration/vmstate.h"

hw/rtc/m48t59.c static void watchdog_cb (void *opaque) · line 168

Quoted 7 lines
hw/rtc/m48t59.c +1 -2
@@ -163,8 +164,7 @@ static void watchdog_cb (void *opaque)
     if (NVRAM->buffer[0x1FF7] & 0x80) {
         NVRAM->buffer[0x1FF7] = 0x00;
         NVRAM->buffer[0x1FFC] &= ~0x40;
-        /* May it be a hw CPU Reset instead ? */
-        qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
+        watchdog_perform_action(); /* watchdog-expired action */
     } else {

I don't think we need the comment, it's clear enough from the name of the function.

Otherwise

thanks
-- PMM

Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] misc: pxa2xx_timer: replace qemu_system_reset_request() call with watchdog_perform_action()

In reply to Abhiram Tilak
Quoted 26 lines · Abhiram Tilak

A few watchdog devices use qemu_system_reset_request(). This is not ideal since behaviour of watchdog-expiry can't be changed by QMP using watchdog_action. As stated in BiteSizedTasks wiki page, instead of using qemu_system_reset_request() to reset when a watchdog timer expires, let watchdog_perform_action() decide what to do.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124

---
 hw/timer/pxa2xx_timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/timer/pxa2xx_timer.c +1 -0
index 6a7d5551f4..6479ab1a8b 100644
@@ -18,6 +18,7 @@
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "qom/object.h"
+#include "sysemu/watchdog.h"
 
 #define OSMR0  0x00
 #define OSMR1  0x04

hw/timer/pxa2xx_timer.c static void pxa2xx_timer_tick(void *opaque) · line 423

Quoted 7 lines
hw/timer/pxa2xx_timer.c +1 -1
@@ -417,7 +418,7 @@ static void pxa2xx_timer_tick(void *opaque)
     if (t->num == 3)
         if (i->reset3 & 1) {
             i->reset3 = 0;
-            qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
+            watchdog_perform_action();
         }
 }

thanks
-- PMM

#7 lore raw

Re: [PATCH 3/3] misc: ppc/spapr: replace qemu_system_reset_request() calls with watchdog_perform_action()

In reply to Abhiram Tilak
Quoted 29 lines · Abhiram Tilak

A few watchdog devices use qemu_system_reset_request(). This is not ideal since behaviour of watchdog-expiry can't be changed by QMP using watchdog_action. As stated in BiteSizedTasks wiki page, instead of using qemu_system_reset_request() to reset when a watchdog timer expires, let watchdog_perform_action() decide what to do.

I am unsure about the changes in spapr_watchdog.c in patch 3, it would be great if any of the maintainers review it.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124

---
 hw/watchdog/spapr_watchdog.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/watchdog/spapr_watchdog.c +1 -0
index 2bb1d3c532..9751b19506 100644
@@ -18,6 +18,7 @@
 #include "target/ppc/cpu.h"
 #include "migration/vmstate.h"
 #include "trace.h"
+#include "sysemu/watchdog.h"
 
 #include "hw/ppc/spapr.h"
 

hw/watchdog/spapr_watchdog.c static void watchdog_expired(void *pw) · line 121

Quoted 8 lines
hw/watchdog/spapr_watchdog.c +1 -1
@@ -114,7 +115,7 @@ static void watchdog_expired(void *pw)
         qemu_system_vmstop_request(RUN_STATE_SHUTDOWN);
         break;
     case PSERIES_WDTF_ACTION_HARD_RESTART:
-        qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
+        watchdog_perform_action();
         break;
     case PSERIES_WDTF_ACTION_DUMP_RESTART:
         CPU_FOREACH(cs) {

This one is more complicated, because the spapr watchdog has multiple possible behaviours which the guest can ask for.

We had a discussion on the mailing list about this a little while back:
https://lore.kernel.org/qemu-devel/CAFEAcA_KjSgt-oC=d2m6WAdqoRsUcs1W_ji7Ng2fgVjxAWLZEw@mail.gmail.com/

The conclusion was that the watchdog-behaviour QAPI API needs to be enhanced to be able to handle this kind of "the guest picks an action" watchdog, so that the user can either override the guest's choice, or request that the behaviour be what the guest wants it to be.

thanks
-- PMM

author
#8 lore raw

Re: [PATCH 3/3] misc: ppc/spapr: replace qemu_system_reset_request() calls with watchdog_perform_action()

I will exclude this patch from the series for now. According to the discussions, the current code honours the guest's preference.
Will wait for the enhancements needed in watchdog QAPI.

Abhiram

Quoted 60 lines · Peter Maydell
Quoted 2 lines · Abhiram Tilak

A few watchdog devices use qemu_system_reset_request(). This is not

ideal since

Quoted 1 line

behaviour of watchdog-expiry can't be changed by QMP using

watchdog_action.

Quoted 1 line

As stated in BiteSizedTasks wiki page, instead of using

qemu_system_reset_request()

Quoted 1 line

to reset when a watchdog timer expires, let watchdog_perform_action()

decide

Quoted 3 lines

what to do.

I am unsure about the changes in spapr_watchdog.c in patch 3, it would

be great

Quoted 21 lines

if any of the maintainers review it.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124

---
 hw/watchdog/spapr_watchdog.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/watchdog/spapr_watchdog.c +1 -0
index 2bb1d3c532..9751b19506 100644
@@ -18,6 +18,7 @@
 #include "target/ppc/cpu.h"
 #include "migration/vmstate.h"
 #include "trace.h"
+#include "sysemu/watchdog.h"
 
 #include "hw/ppc/spapr.h"
 

hw/watchdog/spapr_watchdog.c static void watchdog_expired(void *pw) · line 121

Quoted 8 lines
hw/watchdog/spapr_watchdog.c +1 -1
@@ -114,7 +115,7 @@ static void watchdog_expired(void *pw)
         qemu_system_vmstop_request(RUN_STATE_SHUTDOWN);
         break;
     case PSERIES_WDTF_ACTION_HARD_RESTART:
-        qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
+        watchdog_perform_action();
         break;
     case PSERIES_WDTF_ACTION_DUMP_RESTART:
         CPU_FOREACH(cs) {

This one is more complicated, because the spapr watchdog has multiple possible behaviours which the guest can ask for.

We had a discussion on the mailing list about this a little while back:

https://lore.kernel.org/qemu-devel/CAFEAcA_KjSgt-oC=d2m6WAdqoRsUcs1W_ji7Ng2fgVjxAWLZEw@mail.gmail.com/

The conclusion was that the watchdog-behaviour QAPI API needs to be enhanced to be able to handle this kind of "the guest picks an action" watchdog, so that the user can either override the guest's choice, or request that the behaviour be what the guest wants it to be.

thanks
-- PMM

author
#3 lore raw

Re: [PATCH 1/3] misc: m48t59: replace qemu_system_reset_request() call with watchdog_perform_action()

In reply to Peter Maydell

I agree, comment here is redundant, i will fix
it in the next patch.

Abhiram

Quoted 48 lines · Peter Maydell
Quoted 2 lines · Abhiram Tilak

A few watchdog devices use qemu_system_reset_request(). This is not

ideal since

Quoted 1 line

behaviour of watchdog-expiry can't be changed by QMP using

watchdog_action.

Quoted 1 line

As stated in BiteSizedTasks wiki page, instead of using

qemu_system_reset_request()

Quoted 1 line

to reset when a watchdog timer expires, let watchdog_perform_action()

decide

Quoted 21 lines

what to do.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124

---
 hw/rtc/m48t59.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/rtc/m48t59.c +1 -0
index aa44c4b20c..ebda084478 100644
@@ -36,6 +36,7 @@
 #include "qemu/bcd.h"
 #include "qemu/module.h"
 #include "trace.h"
+#include "sysemu/watchdog.h"
 
 #include "m48t59-internal.h"
 #include "migration/vmstate.h"

hw/rtc/m48t59.c static void watchdog_cb (void *opaque) · line 168

Quoted 7 lines
hw/rtc/m48t59.c +1 -2
@@ -163,8 +164,7 @@ static void watchdog_cb (void *opaque)
     if (NVRAM->buffer[0x1FF7] & 0x80) {
         NVRAM->buffer[0x1FF7] = 0x00;
         NVRAM->buffer[0x1FFC] &= ~0x40;
-        /* May it be a hw CPU Reset instead ? */
-        qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
+        watchdog_perform_action(); /* watchdog-expired action */
     } else {

I don't think we need the comment, it's clear enough from the name of the function.

Otherwise

thanks
-- PMM