@@ -17,6 +17,9 @@ import (
1717
1818 "github.com/Code-Hex/vz/v3"
1919 "github.com/coreos/go-semver/semver"
20+ "github.com/lima-vm/go-qcow2reader/image"
21+ "github.com/lima-vm/go-qcow2reader/image/asif"
22+ "github.com/lima-vm/go-qcow2reader/image/raw"
2023 "github.com/sirupsen/logrus"
2124
2225 "github.com/lima-vm/lima/v2/pkg/driver"
@@ -75,11 +78,12 @@ const Enabled = true
7578type LimaVzDriver struct {
7679 Instance * limatype.Instance
7780
78- SSHLocalPort int
79- vSockPort int
80- virtioPort string
81- rosettaEnabled bool
82- rosettaBinFmt bool
81+ SSHLocalPort int
82+ vSockPort int
83+ virtioPort string
84+ rosettaEnabled bool
85+ rosettaBinFmt bool
86+ diskImageFormat image.Type
8387
8488 machine * virtualMachineWrapper
8589 waitSSHLocalPortAccessible <- chan any
@@ -125,6 +129,11 @@ func (l *LimaVzDriver) Configure(inst *limatype.Instance) *driver.ConfiguredDriv
125129 if vzOpts .Rosetta .BinFmt != nil {
126130 l .rosettaBinFmt = * vzOpts .Rosetta .BinFmt
127131 }
132+ if vzOpts .DiskImageFormat != nil {
133+ l .diskImageFormat = * vzOpts .DiskImageFormat
134+ } else {
135+ l .diskImageFormat = raw .Type
136+ }
128137
129138 return & driver.ConfiguredDriver {
130139 Driver : l ,
@@ -165,6 +174,9 @@ func (l *LimaVzDriver) FillConfig(ctx context.Context, cfg *limatype.LimaYAML, _
165174 if vzOpts .Rosetta .BinFmt == nil {
166175 vzOpts .Rosetta .BinFmt = ptr .Of (false )
167176 }
177+ if vzOpts .DiskImageFormat == nil {
178+ vzOpts .DiskImageFormat = ptr .Of (raw .Type )
179+ }
168180
169181 var opts any
170182 if err := limayaml .Convert (vzOpts , & opts , "" ); err != nil {
@@ -290,6 +302,19 @@ func validateConfig(_ context.Context, cfg *limatype.LimaYAML) error {
290302 default :
291303 logrus .Warnf ("field `video.display` must be \" vz\" , \" default\" , or \" none\" for VZ driver , got %q" , videoDisplay )
292304 }
305+ var vzOpts limatype.VZOpts
306+ if err := limayaml .Convert (cfg .VMOpts [limatype .VZ ], & vzOpts , "vmOpts.vz" ); err != nil {
307+ logrus .WithError (err ).Warnf ("Couldn't convert %q" , cfg .VMOpts [limatype .VZ ])
308+ }
309+ switch * vzOpts .DiskImageFormat {
310+ case raw .Type :
311+ case asif .Type :
312+ if macOSProductVersion .LessThan (* semver .New ("26.0.0" )) {
313+ return fmt .Errorf ("vmOpts.vz.diskImageFormat=%q requires macOS 26 or higher to run, got %q" , asif .Type , macOSProductVersion )
314+ }
315+ default :
316+ return fmt .Errorf ("field `vmOpts.vz.diskImageFormat` must be %q or %q, got %q" , raw .Type , asif .Type , * vzOpts .DiskImageFormat )
317+ }
293318 return nil
294319}
295320
@@ -299,7 +324,7 @@ func (l *LimaVzDriver) Create(_ context.Context) error {
299324}
300325
301326func (l * LimaVzDriver ) CreateDisk (ctx context.Context ) error {
302- return driverutil .EnsureDiskRaw (ctx , l .Instance )
327+ return driverutil .EnsureDisk (ctx , l .Instance . Dir , * l . Instance . Config . Disk , l . diskImageFormat )
303328}
304329
305330func (l * LimaVzDriver ) Start (ctx context.Context ) (chan error , error ) {
0 commit comments