@@ -20,13 +20,14 @@ import (
20
20
21
21
// startVM calls WSL to start a VM.
22
22
func startVM (ctx context.Context , distroName string ) error {
23
- _ , err := executil .RunUTF16leCommand ([]string {
23
+ out , err := executil .RunUTF16leCommand ([]string {
24
24
"wsl.exe" ,
25
25
"--distribution" ,
26
26
distroName ,
27
27
}, executil .WithContext (& ctx ))
28
28
if err != nil {
29
- return err
29
+ return fmt .Errorf ("failed to run `wsl.exe --distribution %s`: %w (out=%q)" ,
30
+ distroName , err , string (out ))
30
31
}
31
32
return nil
32
33
}
@@ -35,28 +36,30 @@ func startVM(ctx context.Context, distroName string) error {
35
36
func initVM (ctx context.Context , instanceDir , distroName string ) error {
36
37
baseDisk := filepath .Join (instanceDir , filenames .BaseDisk )
37
38
logrus .Infof ("Importing distro from %q to %q" , baseDisk , instanceDir )
38
- _ , err := executil .RunUTF16leCommand ([]string {
39
+ out , err := executil .RunUTF16leCommand ([]string {
39
40
"wsl.exe" ,
40
41
"--import" ,
41
42
distroName ,
42
43
instanceDir ,
43
44
baseDisk ,
44
45
}, executil .WithContext (& ctx ))
45
46
if err != nil {
46
- return err
47
+ return fmt .Errorf ("failed to run `wsl.exe --import %s %s %s`: %w (out=%q)" ,
48
+ distroName , instanceDir , baseDisk , err , string (out ))
47
49
}
48
50
return nil
49
51
}
50
52
51
53
// stopVM calls WSL to stop a running VM.
52
54
func stopVM (ctx context.Context , distroName string ) error {
53
- _ , err := executil .RunUTF16leCommand ([]string {
55
+ out , err := executil .RunUTF16leCommand ([]string {
54
56
"wsl.exe" ,
55
57
"--terminate" ,
56
58
distroName ,
57
59
}, executil .WithContext (& ctx ))
58
60
if err != nil {
59
- return err
61
+ return fmt .Errorf ("failed to run `wsl.exe --terminate %s`: %w (out=%q)" ,
62
+ distroName , err , string (out ))
60
63
}
61
64
return nil
62
65
}
@@ -86,10 +89,10 @@ func provisionVM(ctx context.Context, instanceDir, instanceName, distroName stri
86
89
"-c" ,
87
90
outString ,
88
91
)
89
- if _ , err := cmd .CombinedOutput (); err != nil {
92
+ if out , err := cmd .CombinedOutput (); err != nil {
90
93
* errCh <- fmt .Errorf (
91
- "error running wslCommand that executes boot.sh: %w, " +
92
- "check /var/log/lima-init.log for more details" , err )
94
+ "error running wslCommand that executes boot.sh (%v) : %w, " +
95
+ "check /var/log/lima-init.log for more details (out=%q) " , cmd . Args , err , string ( out ) )
93
96
}
94
97
95
98
for {
@@ -130,13 +133,14 @@ func keepAlive(ctx context.Context, distroName string, errCh *chan error) {
130
133
// unregisterVM calls WSL to unregister a VM.
131
134
func unregisterVM (ctx context.Context , distroName string ) error {
132
135
logrus .Info ("Unregistering WSL2 VM" )
133
- _ , err := executil .RunUTF16leCommand ([]string {
136
+ out , err := executil .RunUTF16leCommand ([]string {
134
137
"wsl.exe" ,
135
138
"--unregister" ,
136
139
distroName ,
137
140
}, executil .WithContext (& ctx ))
138
141
if err != nil {
139
- return err
142
+ return fmt .Errorf ("failed to run `wsl.exe --unregister %s`: %w (out=%q)" ,
143
+ distroName , err , string (out ))
140
144
}
141
145
return nil
142
146
}
0 commit comments