[Xen-devel] [PATCH 4/4] xen/watchdog: Support disable all watchdog timers in one go

Andrew Cooper posted 4 patches 1 year, 11 months ago

[Xen-devel] [PATCH 4/4] xen/watchdog: Support disable all watchdog timers in one go

Posted by Andrew Cooper 1 year, 11 months ago
For a domain which has been using watchdogs, but wants to cleanly reboot,
stopping all active timers is necessary to avoid crashing late during
shutdown.

The number of watchdogs isn't part of Xen's ABI, so to simplify cleanup and
error handling logic, support using id = 0, timeout = 0 to deactivate all
timers in one go.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Edwin Török <edvin.torok@citrix.com>
CC: Christian Lindig <christian.lindig@citrix.com>
CC: Pau Ruiz Safont <pau.safont@citrix.com>
---
 xen/common/schedule.c      | 9 ++++++++-
 xen/include/public/sched.h | 6 ++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 98c2c35..284f657 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -1066,7 +1066,7 @@ static long domain_watchdog(struct domain *d, uint32_t id, uint32_t timeout)
             goto unlock;
         }
     }
-    else /* Allocate the next available timer. */
+    else if ( timeout ) /* Allocate the next available timer. */
     {
         id = ffs(~d->watchdog_inuse_map) - 1;
 
@@ -1079,6 +1079,13 @@ static long domain_watchdog(struct domain *d, uint32_t id, uint32_t timeout)
         __set_bit(id, &d->watchdog_inuse_map);
         rc = id + 1;
     }
+    else /* id 0, timeout 0 => disable all timers. */
+    {
+        d->watchdog_inuse_map = 0;
+        for ( ; id < NR_DOMAIN_WATCHDOG_TIMERS; ++id )
+            stop_timer(&d->watchdog_timer[id]);
+        goto unlock;
+    }
 
     /* (re-)arm, or clear a specific timer. */
     if ( unlikely(timeout == 0) )
diff --git a/xen/include/public/sched.h b/xen/include/public/sched.h
index 811bd87..994a0e5 100644
--- a/xen/include/public/sched.h
+++ b/xen/include/public/sched.h
@@ -112,8 +112,10 @@
 /*
  * Setup, poke and destroy a domain watchdog timer.
  * @arg == pointer to sched_watchdog_t structure.
- * With id == 0, setup a domain watchdog timer to cause domain shutdown
- *               after timeout, returns watchdog id.
+ * With id == 0 and timeout != 0, setup a domain watchdog timer to cause
+ *                                domain shutdown after timeout, returns
+ *                                watchdog id.
+ * With id == 0 and timeout == 0, destroy all watchdog timers.
  * With id != 0 and timeout == 0, destroy domain watchdog timer.
  * With id != 0 and timeout != 0, poke watchdog timer and set new timeout.
  */
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel