Skip to content

Commit 00b822a

Browse files
committed
Move the run parameter to the qemu driver
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
1 parent b8fe2a6 commit 00b822a

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

pkg/driver/driver.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ type Driver interface {
1717

1818
Stop(_ context.Context) error
1919

20-
CreateSnapshot(_ context.Context, run bool, tag string) error
20+
CreateSnapshot(_ context.Context, tag string) error
2121

22-
ApplySnapshot(_ context.Context, run bool, tag string) error
22+
ApplySnapshot(_ context.Context, tag string) error
2323

24-
DeleteSnapshot(_ context.Context, run bool, tag string) error
24+
DeleteSnapshot(_ context.Context, tag string) error
2525

26-
ListSnapshots(_ context.Context, run bool) (string, error)
26+
ListSnapshots(_ context.Context) (string, error)
2727
}
2828

2929
type BaseDriver struct {
@@ -49,18 +49,18 @@ func (d *BaseDriver) Stop(_ context.Context) error {
4949
return nil
5050
}
5151

52-
func (d *BaseDriver) CreateSnapshot(_ context.Context, _ bool, _ string) error {
52+
func (d *BaseDriver) CreateSnapshot(_ context.Context, _ string) error {
5353
return fmt.Errorf("unimplemented")
5454
}
5555

56-
func (d *BaseDriver) ApplySnapshot(_ context.Context, _ bool, _ string) error {
56+
func (d *BaseDriver) ApplySnapshot(_ context.Context, _ string) error {
5757
return fmt.Errorf("unimplemented")
5858
}
5959

60-
func (d *BaseDriver) DeleteSnapshot(_ context.Context, _ bool, _ string) error {
60+
func (d *BaseDriver) DeleteSnapshot(_ context.Context, _ string) error {
6161
return fmt.Errorf("unimplemented")
6262
}
6363

64-
func (d *BaseDriver) ListSnapshots(_ context.Context, _ bool) (string, error) {
64+
func (d *BaseDriver) ListSnapshots(_ context.Context) (string, error) {
6565
return "", nil
6666
}

pkg/qemu/qemu_driver.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/digitalocean/go-qemu/qmp/raw"
2020
"github.com/lima-vm/lima/pkg/driver"
2121
"github.com/lima-vm/lima/pkg/limayaml"
22+
"github.com/lima-vm/lima/pkg/store"
2223
"github.com/lima-vm/lima/pkg/store/filenames"
2324
"github.com/sirupsen/logrus"
2425
)
@@ -155,40 +156,40 @@ func logPipeRoutine(r io.Reader, header string) {
155156
}
156157
}
157158

158-
func (l *LimaQemuDriver) DeleteSnapshot(ctx context.Context, run bool, tag string) error {
159+
func (l *LimaQemuDriver) DeleteSnapshot(ctx context.Context, tag string) error {
159160
qCfg := Config{
160161
Name: l.Instance.Name,
161162
InstanceDir: l.Instance.Dir,
162163
LimaYAML: l.Yaml,
163164
}
164-
return Del(qCfg, run, tag)
165+
return Del(qCfg, l.Instance.Status == store.StatusRunning, tag)
165166
}
166167

167-
func (l *LimaQemuDriver) CreateSnapshot(ctx context.Context, run bool, tag string) error {
168+
func (l *LimaQemuDriver) CreateSnapshot(ctx context.Context, tag string) error {
168169
qCfg := Config{
169170
Name: l.Instance.Name,
170171
InstanceDir: l.Instance.Dir,
171172
LimaYAML: l.Yaml,
172173
}
173-
return Save(qCfg, run, tag)
174+
return Save(qCfg, l.Instance.Status == store.StatusRunning, tag)
174175
}
175176

176-
func (l *LimaQemuDriver) ApplySnapshot(ctx context.Context, run bool, tag string) error {
177+
func (l *LimaQemuDriver) ApplySnapshot(ctx context.Context, tag string) error {
177178
qCfg := Config{
178179
Name: l.Instance.Name,
179180
InstanceDir: l.Instance.Dir,
180181
LimaYAML: l.Yaml,
181182
}
182-
return Load(qCfg, run, tag)
183+
return Load(qCfg, l.Instance.Status == store.StatusRunning, tag)
183184
}
184185

185-
func (l *LimaQemuDriver) ListSnapshots(ctx context.Context, run bool) (string, error) {
186+
func (l *LimaQemuDriver) ListSnapshots(ctx context.Context) (string, error) {
186187
qCfg := Config{
187188
Name: l.Instance.Name,
188189
InstanceDir: l.Instance.Dir,
189190
LimaYAML: l.Yaml,
190191
}
191-
return List(qCfg, run)
192+
return List(qCfg, l.Instance.Status == store.StatusRunning)
192193
}
193194

194195
type qArgTemplateApplier struct {

pkg/snapshot/snapshot.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func Del(ctx context.Context, inst *store.Instance, tag string) error {
1717
Instance: inst,
1818
Yaml: y,
1919
})
20-
return limaDriver.DeleteSnapshot(ctx, inst.Status == store.StatusRunning, tag)
20+
return limaDriver.DeleteSnapshot(ctx, tag)
2121
}
2222

2323
func Save(ctx context.Context, inst *store.Instance, tag string) error {
@@ -29,7 +29,7 @@ func Save(ctx context.Context, inst *store.Instance, tag string) error {
2929
Instance: inst,
3030
Yaml: y,
3131
})
32-
return limaDriver.CreateSnapshot(ctx, inst.Status == store.StatusRunning, tag)
32+
return limaDriver.CreateSnapshot(ctx, tag)
3333
}
3434

3535
func Load(ctx context.Context, inst *store.Instance, tag string) error {
@@ -41,7 +41,7 @@ func Load(ctx context.Context, inst *store.Instance, tag string) error {
4141
Instance: inst,
4242
Yaml: y,
4343
})
44-
return limaDriver.ApplySnapshot(ctx, inst.Status == store.StatusRunning, tag)
44+
return limaDriver.ApplySnapshot(ctx, tag)
4545
}
4646

4747
func List(ctx context.Context, inst *store.Instance) (string, error) {
@@ -53,5 +53,5 @@ func List(ctx context.Context, inst *store.Instance) (string, error) {
5353
Instance: inst,
5454
Yaml: y,
5555
})
56-
return limaDriver.ListSnapshots(ctx, inst.Status == store.StatusRunning)
56+
return limaDriver.ListSnapshots(ctx)
5757
}

0 commit comments

Comments
 (0)