On Sun, 13 Jun 2021 11:09:20 -0400, Dave Voutila <d...@sisu.io> wrote:

> Was about to add a test for something I'm hacking on when I noticed the
> diskfmt regress test wasn't enabled. I took a look and it's rotted. :(
> 
> It was originally written by Ori Bernstein and imported by ccardenas@
> days before the vmctl(8) qcow2 disk creation capability was
> committed by the same team. (8 Sep 2011 and 11 Sep 2011 respectively.)
> 
> The below diff allows it to compile and run properly. It also removes
> the requirement of qemu from ports for making the qcow2 image since
> vmctl(8) can do that now. Since it can now run with just vmctl, I've
> also wired it into the parent Makefile to run with the other vmd regress
> tests.
> 
> OK?


Ok by me.
 
> -dv
> 
> Index: regress/usr.sbin/vmd/Makefile
> ===================================================================
> RCS file: /cvs/src/regress/usr.sbin/vmd/Makefile,v
> retrieving revision 1.2
> diff -u -p -r1.2 Makefile
> --- regress/usr.sbin/vmd/Makefile     29 Jan 2019 21:08:12 -0000      1.2
> +++ regress/usr.sbin/vmd/Makefile     13 Jun 2021 14:42:42 -0000
> @@ -2,7 +2,7 @@
> 
>  .if ${MACHINE} == "amd64"
>  SUBDIR =
> -SUBDIR += config
> +SUBDIR += config diskfmt
> 
>  .elif make(regress) || make(all)
>  ${.TARGETS}:
> Index: regress/usr.sbin/vmd/diskfmt/Makefile
> ===================================================================
> RCS file: /cvs/src/regress/usr.sbin/vmd/diskfmt/Makefile,v
> retrieving revision 1.2
> diff -u -p -r1.2 Makefile
> --- regress/usr.sbin/vmd/diskfmt/Makefile     8 Oct 2018 16:32:01 -0000       
> 1.2
> +++ regress/usr.sbin/vmd/diskfmt/Makefile     13 Jun 2021 14:42:42 -0000
> @@ -4,28 +4,26 @@
>  # 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/
> +VMD_DIR=$(BSDSRCDIR)/usr.sbin/vmd
> 
>  PROG=vioscribble
> -SRCS=vioscribble.c vioqcow2.c vioraw.c
> +SRCS=vioscribble.c vioqcow2.c vioraw.c log.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 .
> +vioqcow2.c vioraw.c log.c: $(VMD_DIR)/vioqcow2.c $(VMD_DIR)/vioraw.c \
> +                             $(VMD_DIR)/log.c
> +     cp $(VMD_DIR)/vioqcow2.c $(VMD_DIR)/vioraw.c $(VMD_DIR)/log.c .
> Index: regress/usr.sbin/vmd/diskfmt/vioscribble.c
> ===================================================================
> RCS file: /cvs/src/regress/usr.sbin/vmd/diskfmt/vioscribble.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 vioscribble.c
> --- regress/usr.sbin/vmd/diskfmt/vioscribble.c        8 Oct 2018 16:32:01 
> -0000       1.2
> +++ regress/usr.sbin/vmd/diskfmt/vioscribble.c        13 Jun 2021 14:42:42 
> -0000
> @@ -16,7 +16,7 @@
>   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
> 
> -/*
> +/*
>   * Quick hack of a program to try to test vioqcow2.c against
>   * vioraw.c.
>   *
> @@ -51,7 +51,6 @@
>  #include <assert.h>
>  #include <err.h>
> 
> -#include "pci.h"
>  #include "vmd.h"
>  #include "vmm.h"
>  #include "virtio.h"
> @@ -65,43 +64,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 +82,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);
> 


-- 
    Ori Bernstein

Reply via email to