diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2018-10-08 16:32:02 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2018-10-08 16:32:02 +0000 |
commit | 7d1fb9b21014f5228785a590c2a168ee1a37cbf9 (patch) | |
tree | 93ad71dcb2ca88cb98cd4028cf7d55c09a03eee0 /usr.sbin/vmd/vmd.c | |
parent | c92abada57222b3de4c40244b747671a838884db (diff) |
Add support for qcow2 base images (external snapshots).
This works is from Ori Bernstein, committing on his behalf:
Add support to vmd for external snapshots. That is, snapshots that are
derived from a base image. Data lookups start in the derived image,
and if the derived image does not contain some data, the search
proceeds ot the base image. Multiple derived images may exist off of
a single base image.
A limitation of this format is that modifying the base image will
corrupt the derived image.
This change also adds support for creating disk derived disk images to
vmctl. To use it:
vmctl create derived.qcow2 -s 16G -b base.qcow2
From Ori Bernstein
OK mlarkin@ reyk@
Diffstat (limited to 'usr.sbin/vmd/vmd.c')
-rw-r--r-- | usr.sbin/vmd/vmd.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index 1571be21bc5..057b67770c9 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.102 2018/09/29 22:33:09 pd Exp $ */ +/* $OpenBSD: vmd.c,v 1.103 2018/10/08 16:32:01 reyk Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -1097,7 +1097,7 @@ void vm_stop(struct vmd_vm *vm, int keeptty, const char *caller) { struct privsep *ps = &env->vmd_ps; - unsigned int i; + unsigned int i, j; if (vm == NULL) return; @@ -1117,9 +1117,11 @@ vm_stop(struct vmd_vm *vm, int keeptty, const char *caller) close(vm->vm_iev.ibuf.fd); } for (i = 0; i < VMM_MAX_DISKS_PER_VM; i++) { - if (vm->vm_disks[i] != -1) { - close(vm->vm_disks[i]); - vm->vm_disks[i] = -1; + for (j = 0; j < VM_MAX_BASE_PER_DISK; j++) { + if (vm->vm_disks[i][j] != -1) { + close(vm->vm_disks[i][j]); + vm->vm_disks[i][j] = -1; + } } } for (i = 0; i < VMM_MAX_NICS_PER_VM; i++) { @@ -1176,7 +1178,7 @@ vm_register(struct privsep *ps, struct vmop_create_params *vmc, struct vmop_owner *vmo = NULL; struct vmd_user *usr = NULL; uint32_t rng; - unsigned int i; + unsigned int i, j; struct vmd_switch *sw; char *s; @@ -1267,7 +1269,8 @@ vm_register(struct privsep *ps, struct vmop_create_params *vmc, vm->vm_user = usr; for (i = 0; i < VMM_MAX_DISKS_PER_VM; i++) - vm->vm_disks[i] = -1; + for (j = 0; j < VM_MAX_BASE_PER_DISK; j++) + vm->vm_disks[i][j] = -1; for (i = 0; i < VMM_MAX_NICS_PER_VM; i++) vm->vm_ifs[i].vif_fd = -1; for (i = 0; i < vcp->vcp_nnics; i++) { |