[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien.grall@xxxxxxx>
CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
CC: Edwin Török <edvin.torok@xxxxxxxxxx>
CC: Christian Lindig <christian.lindig@xxxxxxxxxx>
CC: Pau Ruiz Safont <pau.safont@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.