aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-10-18 14:10:33 +0200
committerTaras Madan <tarasmadan@google.com>2024-10-25 12:08:02 +0000
commitc0aa87d6da9bb0a5b04e70e4d2bb3cd187c566b6 (patch)
tree623be3ebff9fe881cfabe3f6214e7283429a3a22
parent668455c34bb42e5068264dae8ba909be95260c81 (diff)
pkg/manager: support multiple pools in Web UI
-rw-r--r--pkg/manager/http.go19
-rw-r--r--pkg/rpcserver/rpcserver.go26
-rw-r--r--syz-manager/manager.go2
3 files changed, 34 insertions, 13 deletions
diff --git a/pkg/manager/http.go b/pkg/manager/http.go
index 96cd5a8bb..155765534 100644
--- a/pkg/manager/http.go
+++ b/pkg/manager/http.go
@@ -18,6 +18,7 @@ import (
"sort"
"strconv"
"strings"
+ "sync"
"sync/atomic"
"time"
@@ -55,7 +56,7 @@ type HTTPServer struct {
Fuzzer atomic.Pointer[fuzzer.Fuzzer]
Cover atomic.Pointer[CoverageInfo]
ReproLoop atomic.Pointer[ReproLoop]
- Pool atomic.Pointer[dispatcher.Pool[*vm.Instance]]
+ Pools sync.Map // string => dispatcher.Pool[*vm.Instance]
EnabledSyscalls atomic.Value // map[*prog.Syscall]bool
// Internal state.
@@ -198,12 +199,15 @@ func (serv *HTTPServer) httpStats(w http.ResponseWriter, r *http.Request) {
executeTemplate(w, pages.StatsTemplate, stat.RenderGraphs())
}
+const DefaultPool = ""
+
func (serv *HTTPServer) httpVMs(w http.ResponseWriter, r *http.Request) {
- pool := serv.Pool.Load()
- if pool == nil {
- http.Error(w, "no VM pool is present (yet)", http.StatusInternalServerError)
+ poolObj, ok := serv.Pools.Load(r.FormValue("pool"))
+ if !ok {
+ http.Error(w, "no such VM pool is known (yet)", http.StatusInternalServerError)
return
}
+ pool := poolObj.(*dispatcher.Pool[*vm.Instance])
data := &UIVMData{
Name: serv.Cfg.Name,
}
@@ -241,11 +245,12 @@ func (serv *HTTPServer) httpVMs(w http.ResponseWriter, r *http.Request) {
}
func (serv *HTTPServer) httpVM(w http.ResponseWriter, r *http.Request) {
- pool := serv.Pool.Load()
- if pool == nil {
- http.Error(w, "no VM pool is present (yet)", http.StatusInternalServerError)
+ poolObj, ok := serv.Pools.Load(r.FormValue("pool"))
+ if !ok {
+ http.Error(w, "no such VM pool is known (yet)", http.StatusInternalServerError)
return
}
+ pool := poolObj.(*dispatcher.Pool[*vm.Instance])
w.Header().Set("Content-Type", ctTextPlain)
id, err := strconv.Atoi(r.FormValue("id"))
diff --git a/pkg/rpcserver/rpcserver.go b/pkg/rpcserver/rpcserver.go
index 76f1ddc68..10455cee7 100644
--- a/pkg/rpcserver/rpcserver.go
+++ b/pkg/rpcserver/rpcserver.go
@@ -8,6 +8,7 @@ import (
"context"
"errors"
"fmt"
+ "net/url"
"slices"
"sort"
"strings"
@@ -103,12 +104,27 @@ type Stats struct {
}
func NewStats() Stats {
+ return NewNamedStats("")
+}
+
+func NewNamedStats(name string) Stats {
+ suffix := name
+ if suffix != "" {
+ suffix = " [" + suffix + "]"
+ }
+ vmsLink := "/vms"
+ if name != "" {
+ vmsLink += "?pool=" + url.QueryEscape(name)
+ }
return Stats{
- StatExecs: stat.New("exec total", "Total test program executions",
- stat.Console, stat.Rate{}, stat.Prometheus("syz_exec_total")),
- StatNumFuzzing: stat.New("fuzzing VMs",
- "Number of VMs that are currently fuzzing", stat.Graph("fuzzing VMs")),
- StatVMRestarts: stat.New("vm restarts", "Total number of VM starts",
+ StatExecs: stat.New("exec total"+suffix, "Total test program executions",
+ stat.Console, stat.Rate{}, stat.Prometheus("syz_exec_total"+name),
+ ),
+ StatNumFuzzing: stat.New("fuzzing VMs"+suffix,
+ "Number of VMs that are currently fuzzing", stat.Graph("fuzzing VMs"),
+ stat.Link(vmsLink),
+ ),
+ StatVMRestarts: stat.New("vm restarts"+suffix, "Total number of VM starts",
stat.Rate{}, stat.NoGraph),
}
}
diff --git a/syz-manager/manager.go b/syz-manager/manager.go
index 2c7d13830..b5c879cad 100644
--- a/syz-manager/manager.go
+++ b/syz-manager/manager.go
@@ -299,7 +299,7 @@ func RunManager(mode Mode, cfg *mgrconfig.Config) {
return
}
mgr.pool = vm.NewDispatcher(mgr.vmPool, mgr.fuzzerInstance)
- mgr.http.Pool.Store(mgr.pool)
+ mgr.http.Pools.Store(manager.DefaultPool, mgr.pool)
mgr.reproLoop = manager.NewReproLoop(mgr, mgr.vmPool.Count()-mgr.cfg.FuzzingVMs, mgr.cfg.DashboardOnlyRepro)
mgr.http.ReproLoop.Store(mgr.reproLoop)