diff --git a/pkg/proxmox/client.go b/pkg/proxmox/client.go index 2eec73dae..8b0450425 100644 --- a/pkg/proxmox/client.go +++ b/pkg/proxmox/client.go @@ -1460,8 +1460,8 @@ func (fs *VMFileSystem) UnmarshalJSON(data []byte) error { fs.Name = raw.Name fs.Type = raw.Type fs.Mountpoint = raw.Mountpoint - if fs.Mountpoint == "" { - if normalized, ok := normalizeWindowsDriveMountpoint(raw.Name); ok { + if normalized, ok := normalizeWindowsDriveMountpoint(raw.Name); ok { + if fs.Mountpoint == "" || isWindowsVolumeGUIDMountpoint(fs.Mountpoint) { fs.Mountpoint = normalized } } @@ -1490,6 +1490,11 @@ func normalizeWindowsDriveMountpoint(value string) (string, bool) { } } +func isWindowsVolumeGUIDMountpoint(value string) bool { + value = strings.TrimSpace(strings.ToLower(value)) + return strings.HasPrefix(value, `\\?\volume{`) && strings.HasSuffix(value, `}\`) +} + func parseUint64Flexible(value interface{}) (uint64, error) { switch v := value.(type) { case nil: diff --git a/pkg/proxmox/client_api_more3_test.go b/pkg/proxmox/client_api_more3_test.go index 5b863f59b..cda726808 100644 --- a/pkg/proxmox/client_api_more3_test.go +++ b/pkg/proxmox/client_api_more3_test.go @@ -131,6 +131,44 @@ func TestClientVMFSInfoParsingWindowsNameMountpointFallback(t *testing.T) { } } +func TestClientVMFSInfoParsingWindowsVolumeGUIDMountpointFallback(t *testing.T) { + client := newTestClient(t, func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/api2/json/nodes/node1/qemu/100/agent/get-fsinfo": + writeJSON(t, w, map[string]interface{}{ + "data": map[string]interface{}{ + "result": []map[string]interface{}{ + { + "name": "C:\\", + "type": "ntfs", + "mountpoint": "\\\\?\\Volume{1234-5678}\\", + "total-bytes": 500, + "used-bytes": 200, + }, + }, + }, + }) + default: + http.NotFound(w, r) + } + }) + + ctx := context.Background() + filesystems, err := client.GetVMFSInfo(ctx, "node1", 100) + if err != nil { + t.Fatalf("GetVMFSInfo error: %v", err) + } + if len(filesystems) != 1 { + t.Fatalf("expected 1 filesystem, got %d", len(filesystems)) + } + if filesystems[0].Mountpoint != "C:\\" { + t.Fatalf("expected windows drive-letter mountpoint fallback, got %q", filesystems[0].Mountpoint) + } + if filesystems[0].Disk != "C:" { + t.Fatalf("expected windows drive disk, got %q", filesystems[0].Disk) + } +} + func TestClientVMFSInfoObjectResult(t *testing.T) { client := newTestClient(t, func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path {