The usr.sbin/vmd/diskfmt regression test was broken, and also
apparently never got listed in the parent Makefile.
Caveat: The test creates a couple of fairly large files; e.g. my own /usr/src
wasn't big enough for them. (Is that why the test was never enabled?)
$ du -ah scribble.*
948M scribble.qcow2
809M scribble.raw
Changes:
* The -s argument to vmctl create needs to come before the disk image
name.
* Some function names have changed. Handle part of that by just copying
over log.c instead of re-implementing bits of it. (This seems really
hacky, but it's already done for a couple of other files, and I'm
still finding my way around the source tree so maybe not the best
person to try to improve that.)
* Now we can create disk images without the qemu package, if we change
the extension t ".qcow2".
* Add diskfmt to SUBDIR.
I stumbled on this because I think I found a bug and was considering
adding a regression test before trying to fix it. Here's the alleged bug, in
case someone reading this can point out something obvious:
falsifian angel d $ vmctl create -s 1g base.qcow2
vmctl: qcow2 imagefile created
falsifian angel d $ vmctl create -b base.qcow2 derived.qcow2
vmctl: qcow2 imagefile created
falsifian angel d $ vmctl create -i derived.qcow2 fresh.qcow2
unable to resolve base.qcow2
vmctl: failed to open source image file
I expected the last command to create a fresh copy of derived.qcow2
that doesn't depend on base.qcow2. I haven't (yet) investigated why it
doesn't work.
- James
diff --git a/regress/usr.sbin/vmd/Makefile b/regress/usr.sbin/vmd/Makefile
index 9e605b6ba87..4f174550fff 100644
--- a/regress/usr.sbin/vmd/Makefile
+++ b/regress/usr.sbin/vmd/Makefile
@@ -2,7 +2,7 @@
.if ${MACHINE} == "amd64"
SUBDIR =
-SUBDIR += config
+SUBDIR += config diskfmt
.elif make(regress) || make(all)
${.TARGETS}:
diff --git a/regress/usr.sbin/vmd/diskfmt/Makefile
b/regress/usr.sbin/vmd/diskfmt/Makefile
index 33ac4c6cf18..446ae4114f0 100644
--- a/regress/usr.sbin/vmd/diskfmt/Makefile
+++ b/regress/usr.sbin/vmd/diskfmt/Makefile
@@ -4,28 +4,25 @@
# qcow disk image, and scribbles the same data to both
# of them. It verifies that they both have the same
# result.
-#
-# In order for this test to work, qemu must be installed
-# in order to create the disk images.
VMD_DIR=$(BSDSRCDIR)/usr.sbin/vmd/
PROG=vioscribble
-SRCS=vioscribble.c vioqcow2.c vioraw.c
+SRCS=vioscribble.c log.c vioqcow2.c vioraw.c
CFLAGS+=-I$(VMD_DIR) -pthread
LDFLAGS+=-pthread
run-regress-vioscribble: scribble-images
scribble-images:
- rm -f scribble.raw scribble.qc2
- vmctl create scribble.raw -s 4G
- qemu-img create -f qcow2 scribble.qc2 4G
+ rm -f scribble.raw scribble.qcow2
+ vmctl create -s 4G scribble.raw
+ vmctl create -s 4G scribble.qcow2
.PHONY: ${REGRESS_TARGETS} scribble-images
.include <bsd.regress.mk>
-vioqcow2.c vioraw.c: $(VMD_DIR)/vioqcow2.c $(VMD_DIR)/vioraw.c
- cp $(VMD_DIR)/vioqcow2.c $(VMD_DIR)/vioraw.c .
+log.c vioqcow2.c vioraw.c: $(VMD_DIR)/log.c $(VMD_DIR)/vioqcow2.c
$(VMD_DIR)/vioraw.c
+ cp $(VMD_DIR)/log.c $(VMD_DIR)/vioqcow2.c $(VMD_DIR)/vioraw.c .
diff --git a/regress/usr.sbin/vmd/diskfmt/vioscribble.c
b/regress/usr.sbin/vmd/diskfmt/vioscribble.c
index 0152b8d4bb4..12c316f88a0 100644
--- a/regress/usr.sbin/vmd/diskfmt/vioscribble.c
+++ b/regress/usr.sbin/vmd/diskfmt/vioscribble.c
@@ -65,43 +65,6 @@ struct virtio_backing rawfile;
/* We expect the scribble disks to be 4g in size */
#define DISKSZ (4ull*1024ull*1024ull*1024ull)
-/* functions that io code depends on */
-
-void
-log_debug(const char *emsg, ...)
-{
- if (verbose) {
- va_list ap;
-
- va_start(ap, emsg);
- vfprintf(stdout, emsg, ap);
- fprintf(stdout, "\n");
- va_end(ap);
- }
-}
-
-void
-log_warnx(const char *emsg, ...)
-{
- va_list ap;
-
- va_start(ap, emsg);
- vfprintf(stdout, emsg, ap);
- fprintf(stdout, "\n");
- va_end(ap);
-}
-
-void
-log_warn(const char *emsg, ...)
-{
- va_list ap;
-
- va_start(ap, emsg);
- vfprintf(stdout, emsg, ap);
- fprintf(stdout, "\n");
- va_end(ap);
-}
-
static void
fill(size_t off, char *buf, size_t len)
{
@@ -120,13 +83,13 @@ main(int argc, char **argv)
off_t len, off, qcsz, rawsz;
verbose = !!getenv("VERBOSE");
- qcfd = open("scribble.qc2", O_RDWR);
+ qcfd = open("scribble.qcow2", O_RDWR);
rawfd = open("scribble.raw", O_RDWR);
if (qcfd == -1)
err(1, "unable to open qcow");
- if (virtio_init_qcow2(&qcowfile, &qcsz, &qcfd, 1) == -1)
+ if (virtio_qcow2_init(&qcowfile, &qcsz, &qcfd, 1) == -1)
err(1, "unable to init qcow");
- if (rawfd == -1 || virtio_init_raw(&rawfile, &rawsz, &rawfd, 1) == -1)
+ if (rawfd == -1 || virtio_raw_init(&rawfile, &rawsz, &rawfd, 1) == -1)
err(1, "unable to open raw");
srandom_deterministic(123);