Skip to content

Commit d6198b8

Browse files
committed
vz: create vz-identifier on limactl create, not on limactl start
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
1 parent 368777e commit d6198b8

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

pkg/driver/driver.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ type Driver interface {
1616
// Validate returns error if the current driver isn't support for given config
1717
Validate() error
1818

19+
// Initialize is called on creating the instance for initialization.
20+
// (e.g., creating "vz-identifier" file)
21+
//
22+
// Initialize must not return a non-nil error when it is called against an existing instance.
23+
//
24+
// Initialize does not create the disks.
25+
Initialize(_ context.Context) error
26+
1927
// CreateDisk returns error if the current driver fails in creating disk
2028
CreateDisk() error
2129

@@ -69,6 +77,10 @@ func (d *BaseDriver) Validate() error {
6977
return nil
7078
}
7179

80+
func (d *BaseDriver) Initialize(_ context.Context) error {
81+
return nil
82+
}
83+
7284
func (d *BaseDriver) CreateDisk() error {
7385
return nil
7486
}

pkg/start/start.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type Prepared struct {
7272
}
7373

7474
// Prepare ensures the disk, the nerdctl archive, etc.
75-
func Prepare(_ context.Context, inst *store.Instance) (*Prepared, error) {
75+
func Prepare(ctx context.Context, inst *store.Instance) (*Prepared, error) {
7676
y, err := inst.LoadYAML()
7777
if err != nil {
7878
return nil, err
@@ -87,6 +87,10 @@ func Prepare(_ context.Context, inst *store.Instance) (*Prepared, error) {
8787
return nil, err
8888
}
8989

90+
if err := limaDriver.Initialize(ctx); err != nil {
91+
return nil, err
92+
}
93+
9094
// Check if the instance has been created (the base disk already exists)
9195
created := false
9296
baseDisk := filepath.Join(inst.Dir, filenames.BaseDisk)

pkg/vz/vz_driver_darwin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ func (l *LimaVzDriver) Validate() error {
130130
return nil
131131
}
132132

133+
func (l *LimaVzDriver) Initialize(_ context.Context) error {
134+
_, err := getMachineIdentifier(l.BaseDriver)
135+
return err
136+
}
137+
133138
func (l *LimaVzDriver) CreateDisk() error {
134139
return EnsureDisk(l.BaseDriver)
135140
}

0 commit comments

Comments
 (0)