diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-11-07 16:01:04 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-11-08 14:15:20 +0000 |
| commit | 0e6221e714759ad3d12fb1a94b62c5c607a4dbab (patch) | |
| tree | 7b0c2da5c189a282ad7ea83b61a97d1c14716083 /pkg | |
| parent | 9c60c31484778260e7eb20d563c33554cf39e8fd (diff) | |
syz-manager: add pause function
The pause function is useful to make manager stop consuming CPU
for some time, e.g. when it runs on a shared machine,
and a user wants to use CPU for something else.
Previously one would need to kill the manager process and
restart later to achieve this, but the restart is costly,
and aborts all bug reproductions.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/manager/http.go | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/pkg/manager/http.go b/pkg/manager/http.go index 06fa9ca2b..05972ba3d 100644 --- a/pkg/manager/http.go +++ b/pkg/manager/http.go @@ -46,13 +46,14 @@ type CoverageInfo struct { type HTTPServer struct { // To be set before calling Serve. - Cfg *mgrconfig.Config - StartTime time.Time - CrashStore *CrashStore - DiffStore *DiffFuzzerStore - ReproLoop *ReproLoop - Pool *vm.Dispatcher - Pools map[string]*vm.Dispatcher + Cfg *mgrconfig.Config + StartTime time.Time + CrashStore *CrashStore + DiffStore *DiffFuzzerStore + ReproLoop *ReproLoop + Pool *vm.Dispatcher + Pools map[string]*vm.Dispatcher + TogglePause func(paused bool) // Can be set dynamically after calling Serve. Corpus atomic.Pointer[corpus.Corpus] @@ -62,6 +63,7 @@ type HTTPServer struct { // Internal state. expertMode bool + paused bool } func (serv *HTTPServer) Serve() { @@ -113,6 +115,13 @@ func (serv *HTTPServer) httpAction(w http.ResponseWriter, r *http.Request) { switch r.FormValue("action") { case "toggle-expert": serv.expertMode = !serv.expertMode + case "pause-unpause": + if serv.TogglePause == nil { + http.Error(w, "pause is not implemented", http.StatusNotImplemented) + return + } + serv.paused = !serv.paused + serv.TogglePause(serv.paused) } http.Redirect(w, r, r.FormValue("url"), http.StatusFound) } @@ -960,6 +969,7 @@ type UIPageHeader struct { GitRevision string GitRevisionLink string ExpertMode bool + Paused bool } func (serv *HTTPServer) pageHeader(r *http.Request, title string) UIPageHeader { @@ -979,6 +989,7 @@ func (serv *HTTPServer) pageHeader(r *http.Request, title string) UIPageHeader { GitRevision: revision, GitRevisionLink: revisionLink, ExpertMode: serv.expertMode, + Paused: serv.paused, } } @@ -1003,6 +1014,9 @@ func createPage(data any, body string) *template.Template { <button type="submit" name="action" value="toggle-expert" class="action_button{{if .ExpertMode}}_selected{{end}}" title="Toggle expert mode"> π§ </input> + <button type="submit" name="action" value="pause-unpause" class="action_button{{if .Paused}}_selected{{end}}" title="Pause/unpause fuzzing"> + {{if .Paused}}βΆοΈ{{else}}βΈοΈ{{end}} + </input> </form> </td> <td class="search"> |
