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.
This commit is contained in:
Anton Lindqvist 2018-10-01 13:51:43 +02:00 committed by Dmitry Vyukov
parent 42c78641f5
commit 4b94574dd4

View File

@ -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 {