@@ -8,14 +8,17 @@ import (
8
8
"fmt"
9
9
"net"
10
10
"path/filepath"
11
+ "runtime"
11
12
"time"
12
13
13
14
"github.com/Code-Hex/vz/v3"
15
+ "github.com/mitchellh/mapstructure"
14
16
15
17
"github.com/sirupsen/logrus"
16
18
17
19
"github.com/lima-vm/lima/pkg/driver"
18
20
"github.com/lima-vm/lima/pkg/limayaml"
21
+ "github.com/lima-vm/lima/pkg/osutil"
19
22
"github.com/lima-vm/lima/pkg/reflectutil"
20
23
"github.com/lima-vm/lima/pkg/store/filenames"
21
24
)
@@ -204,6 +207,34 @@ func (l *LimaVzDriver) RunGUI() error {
204
207
return fmt .Errorf ("RunGUI is not supported for the given driver '%s' and display '%s'" , "vz" , * l .Instance .Config .Video .Display )
205
208
}
206
209
210
+ func (l * LimaVzDriver ) RuntimeConfig (_ context.Context , config interface {}) (interface {}, error ) {
211
+ if config == nil {
212
+ return l .config , nil
213
+ }
214
+ var newConfig LimaVzDriverRuntimeConfig
215
+ err := mapstructure .Decode (config , & newConfig )
216
+ if err != nil {
217
+ return nil , err
218
+ }
219
+ if newConfig .SaveOnStop {
220
+ if runtime .GOARCH != "arm64" {
221
+ return nil , fmt .Errorf ("saveOnStop is not supported on %s" , runtime .GOARCH )
222
+ } else if runtime .GOOS != "darwin" {
223
+ return nil , fmt .Errorf ("saveOnStop is not supported on %s" , runtime .GOOS )
224
+ } else if macOSProductVersion , err := osutil .ProductVersion (); err != nil {
225
+ return nil , fmt .Errorf ("failed to get macOS product version: %w" , err )
226
+ } else if macOSProductVersion .Major < 14 {
227
+ return nil , fmt .Errorf ("saveOnStop is not supported on macOS %d" , macOSProductVersion .Major )
228
+ }
229
+ logrus .Info ("VZ RuntimeConfiguration changed: SaveOnStop is enabled" )
230
+ l .config .SaveOnStop = true
231
+ } else {
232
+ logrus .Info ("VZ RuntimeConfiguration changed: SaveOnStop is disabled" )
233
+ l .config .SaveOnStop = false
234
+ }
235
+ return l .config , nil
236
+ }
237
+
207
238
func (l * LimaVzDriver ) Stop (_ context.Context ) error {
208
239
if l .config .SaveOnStop {
209
240
machineStatePath := filepath .Join (l .Instance .Dir , filenames .VzMachineState )
0 commit comments