aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Lindqvist <anton@basename.se>2018-10-01 13:51:43 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-10-11 19:47:20 +0200
commit4b94574dd47e568609dfdada988daf982d48fcce (patch)
tree4c46bfe62154f7b6078945d2d69a0cc51d88fd50
parent42c78641f53c8e6208bfd1808259f116a7ec71de (diff)
vm/vmm: use derived disks for VMs
As a result, the boot time is significantly improved since there's no longer any need to copy the complete disk. This feature was recently committed to OpenBSD-current. Any existing base image used must be recreated, this time using the qcow2 disk format.
-rw-r--r--vm/vmm/vmm.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/vm/vmm/vmm.go b/vm/vmm/vmm.go
index ad5c31d87..11b0b399f 100644
--- a/vm/vmm/vmm.go
+++ b/vm/vmm/vmm.go
@@ -94,18 +94,13 @@ func (pool *Pool) Count() int {
}
func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
- image := filepath.Join(workdir, "disk.img")
- if err := osutil.CopyFile(pool.env.Image, image); err != nil {
- return nil, err
- }
-
var tee io.Writer
if pool.env.Debug {
tee = os.Stdout
}
inst := &instance{
cfg: pool.cfg,
- image: image,
+ image: filepath.Join(workdir, "disk.qcow2"),
debug: pool.env.Debug,
os: pool.env.OS,
sshkey: pool.env.SSHKey,
@@ -122,6 +117,14 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
inst.vmctl("stop", inst.vmName, "-f", "-w")
time.Sleep(3 * time.Second)
+ createArgs := []string{
+ "create", inst.image,
+ "-b", pool.env.Image,
+ }
+ if _, err := inst.vmctl(createArgs...); err != nil {
+ return nil, err
+ }
+
closeInst := inst
defer func() {
if closeInst != nil {