v0.59.0: report backing device + capacity for a registry-sourced /disks row
Agent-view showed "—" device + no size for a raw (no-PVE-storage) drive because the registry union row never set backing_device/total_bytes/used_bytes (Observe drives get those from pvesm status). Resolve BackingDevice via ByUUIDDevicePath + read capacity via statfsCapacity (build-tagged syscall.Statfs; no-op off-Linux). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -235,6 +235,18 @@ func (s *Server) handleDisks(w http.ResponseWriter, r *http.Request, vmid int) {
|
||||
di.GuestPath = gp
|
||||
di.BoundUnderParent = s.boundUnderParent(r.Context(), vmid, gp)
|
||||
}
|
||||
// A registry drive has no PVE `pvesm status` snapshot, so fill backing device + capacity
|
||||
// from the host directly: resolve the device by fs-UUID, and statfs the mount for size —
|
||||
// else the agent-view shows "—" for the device and no size bar.
|
||||
if d.UUID != "" {
|
||||
if dev, err := storage.ByUUIDDevicePath(d.UUID); err == nil {
|
||||
di.BackingDevice = dev
|
||||
}
|
||||
}
|
||||
if total, used, okc := statfsCapacity(d.MountPath); okc {
|
||||
di.TotalBytes, di.UsedBytes = total, used
|
||||
di.UsedFraction = float64(used) / float64(total)
|
||||
}
|
||||
out = append(out, di)
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user