@@ -15,6 +15,7 @@ import (
15
15
"github.com/lima-vm/lima/pkg/driver"
16
16
"github.com/lima-vm/lima/pkg/iso9660util"
17
17
"github.com/lima-vm/lima/pkg/limayaml"
18
+ "github.com/lima-vm/lima/pkg/store"
18
19
"github.com/lima-vm/lima/pkg/store/filenames"
19
20
"github.com/sirupsen/logrus"
20
21
)
@@ -61,6 +62,30 @@ func (l *LimaVBoxDriver) create(ctx context.Context, name string) error {
61
62
62
63
baseDisk := filepath .Join (l .Instance .Dir , filenames .BaseDisk )
63
64
diffDisk := filepath .Join (l .Instance .Dir , filenames .DiffDisk )
65
+ extraDisks := []string {}
66
+ if len (l .Instance .AdditionalDisks ) > 0 {
67
+ for _ , d := range l .Instance .AdditionalDisks {
68
+ diskName := d .Name
69
+ disk , err := store .InspectDisk (diskName )
70
+ if err != nil {
71
+ logrus .Errorf ("could not load disk %q: %q" , diskName , err )
72
+ return err
73
+ }
74
+
75
+ if disk .Instance != "" {
76
+ logrus .Errorf ("could not attach disk %q, in use by instance %q" , diskName , disk .Instance )
77
+ return err
78
+ }
79
+ logrus .Infof ("Mounting disk %q on %q" , diskName , disk .MountPoint )
80
+ err = disk .Lock (l .Instance .Dir )
81
+ if err != nil {
82
+ logrus .Errorf ("could not lock disk %q: %q" , diskName , err )
83
+ return err
84
+ }
85
+ dataDisk := filepath .Join (disk .Dir , filenames .DataDisk )
86
+ extraDisks = append (extraDisks , dataDisk )
87
+ }
88
+ }
64
89
isBaseDiskISO , err := iso9660util .IsISO9660 (baseDisk )
65
90
if err != nil {
66
91
return err
@@ -128,6 +153,17 @@ func (l *LimaVBoxDriver) create(ctx context.Context, name string) error {
128
153
logrus .Debugf ("diffdisk %v" , err )
129
154
return err
130
155
}
156
+ for i , extraDisk := range extraDisks {
157
+ if err := exec .CommandContext (ctx , qExe , "storageattach" , name ,
158
+ "--storagectl" , "SATA" ,
159
+ "--port" , "3" ,
160
+ "--device" , fmt .Sprintf ("%d" , i ),
161
+ "--type" , "hdd" ,
162
+ "--medium" , extraDisk ).Run (); err != nil {
163
+ logrus .Debugf ("extradisk %v" , err )
164
+ return err
165
+ }
166
+ }
131
167
132
168
if err := exec .CommandContext (ctx , qExe , "storageattach" , name ,
133
169
"--storagectl" , "SATA" ,
0 commit comments