On Sun, 30 Sep 2018 12:27:00 -0700, Ori Bernstein <[email protected]> wrote:
> I've added 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.
And, a few fixes (thanks to Anton Lindqvist for testing and pointing
out issues). Please apply on top of the previous diff.
diff --git usr.sbin/vmd/config.c usr.sbin/vmd/config.c
index 21aeb050371..ff9f79b87b2 100644
--- usr.sbin/vmd/config.c
+++ usr.sbin/vmd/config.c
@@ -314,26 +314,30 @@ config_setvm(struct privsep *ps, struct vmd_vm *vm,
uint32_t peerid, uid_t uid)
goto fail;
}
- /*
- * Clear the read-write flag for base images.
+ /*
+ * Clear the read-write flag for base images.
* All writes should go to the top image.
*/
flags = O_RDONLY|O_EXLOCK|O_NONBLOCK;
n = virtio_get_base(diskfds[i][j], base, sizeof base,
vmc->vmc_disktypes[i]);
- if (n == -1)
- log_warnx("vm \"%s\" unable to read"
- "base for disk %s", vcp->vcp_name,
- vcp->vcp_disks[i]);
if (n == 0)
break;
- /*
+ if (n == -1) {
+ log_warnx("vm \"%s\" unable to read "
+ "base for disk %s", vcp->vcp_name,
+ vcp->vcp_disks[i]);
+ goto fail;
+ }
+ /*
* Relative paths should be interpreted relative
* to the disk image, rather than relative to the
* directory vmd happens to be running in, since
* this is the only userful interpretation.
*/
- if (base[0] != '/') {
+ if (base[0] == '/') {
+ realpath(base, path);
+ } else {
s = dirname(path);
snprintf(expanded, sizeof expanded,
"%s/%s", s, base);
--
Ori Bernstein