diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2018-10-01 09:31:16 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2018-10-01 09:31:16 +0000 |
commit | 8a17797083cb25f778796323294e512fb3897f9c (patch) | |
tree | 853400434e2c4cb62da44f09a848afc6bd270260 /usr.sbin/vmd/vioqcow2.c | |
parent | fbba9821f37775291dad9d0c9b16da39b95fa34b (diff) |
Try to derive the qcow2 file format from an image file automatically.
This makes the "-d qcow2:" and "format qcow" arguments optional as vmctl
and vmd will read the magic bytes at the beginning of a file to guess if
it is a raw or a qcow image file.
The "vmctl create" command has been changed by removing the -f qcow2 option
and replacing it with the same syntax as -d: "vmctl create qcow2:foo.img".
In a slightly ununixy but intended way, the create command now also
considers the file extension for the format as "vmctl create foo.qcow2"
creates a qcow2 disk and not a raw image file.
Ok mlarkin@ (and ccardenas@ on an earlier version of the diff)
Diffstat (limited to 'usr.sbin/vmd/vioqcow2.c')
-rw-r--r-- | usr.sbin/vmd/vioqcow2.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.sbin/vmd/vioqcow2.c b/usr.sbin/vmd/vioqcow2.c index ada0bafc72d..ceb95fe37c4 100644 --- a/usr.sbin/vmd/vioqcow2.c +++ b/usr.sbin/vmd/vioqcow2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioqcow2.c,v 1.5 2018/09/28 12:35:32 reyk Exp $ */ +/* $OpenBSD: vioqcow2.c,v 1.6 2018/10/01 09:31:15 reyk Exp $ */ /* * Copyright (c) 2018 Ori Bernstein <ori@eigenstate.org> @@ -169,7 +169,8 @@ qc2_open(struct qcdisk *disk, int fd) log_warn("%s: short read on header", __func__); goto error; } - if (strncmp(header.magic, "QFI\xfb", 4) != 0) { + if (strncmp(header.magic, + VM_MAGIC_QCOW, strlen(VM_MAGIC_QCOW)) != 0) { log_warn("%s: invalid magic numbers", __func__); goto error; } |