@@ -11,7 +11,6 @@ import (
11
11
"path/filepath"
12
12
13
13
"github.com/lima-vm/go-qcow2reader"
14
- "github.com/lima-vm/lima/pkg/qemu/imgutil"
15
14
"github.com/lima-vm/lima/pkg/store/filenames"
16
15
)
17
16
@@ -61,35 +60,25 @@ func InspectDisk(diskName string) (*Disk, error) {
61
60
return disk , nil
62
61
}
63
62
64
- // inspectDisk attempts to inspect the disk size and format by itself,
65
- // and falls back to inspectDiskWithQemuImg on an error.
63
+ // inspectDisk attempts to inspect the disk size and format with qcow2reader.
66
64
func inspectDisk (fName string ) (size int64 , format string , _ error ) {
67
65
f , err := os .Open (fName )
68
66
if err != nil {
69
- return inspectDiskWithQemuImg ( fName )
67
+ return - 1 , "" , err
70
68
}
71
69
defer f .Close ()
72
70
img , err := qcow2reader .Open (f )
73
71
if err != nil {
74
- return inspectDiskWithQemuImg ( fName )
72
+ return - 1 , "" , err
75
73
}
76
74
sz := img .Size ()
77
75
if sz < 0 {
78
- return inspectDiskWithQemuImg ( fName )
76
+ return - 1 , "" , fmt . Errorf ( "cannot determine size of %q" , fName )
79
77
}
80
78
81
79
return sz , string (img .Type ()), nil
82
80
}
83
81
84
- // inspectDiskSizeWithQemuImg invokes `qemu-img` binary to inspect the disk size and format.
85
- func inspectDiskWithQemuImg (fName string ) (size int64 , format string , _ error ) {
86
- info , err := imgutil .GetInfo (fName )
87
- if err != nil {
88
- return - 1 , "" , err
89
- }
90
- return info .VSize , info .Format , nil
91
- }
92
-
93
82
func (d * Disk ) Lock (instanceDir string ) error {
94
83
inUseBy := filepath .Join (d .Dir , filenames .InUseBy )
95
84
return os .Symlink (instanceDir , inUseBy )
0 commit comments