Hi,
I recently tried to use qemu-img with qcow2 images of my VMs and
qemu-img finds them corrupted. I can reproduce the issue in the
following way (on -current, but is the same on -stable; tried different
hosts to exclude hardware errors):
marsden# vmctl create -s 300G test.qcow2
vmctl: qcow2 imagefile created
marsden# qemu-img check test.qcow2
No errors were found on the image.
Image end offset: 262144
marsden# vmctl start -cL -B net -b /bsd.rd -d test.qcow2 test
Connected to /dev/ttyp4 (speed 115200)
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
Copyright (c) 1995-2022 OpenBSD. All rights reserved. https://www.OpenBSD.org
OpenBSD 7.1-current (RAMDISK_CD) #444: Sat Apr 16 11:11:27 MDT 2022
[email protected]:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
real mem = 520093696 (496MB)
avail mem = 500371456 (477MB)
random: boothowto does not indicate good seed
mainbus0 at root
bios0 at mainbus0
acpi at bios0 not configured
cpu0 at mainbus0: (uniprocessor)
cpu0: Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz, 1992.01 MHz, 06-4e-03
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,CX8,SEP,PGE,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,ITSC,FSGSBASE,BMI1,AVX2,S
MEP,BMI2,ERMS,RDSEED,ADX,SMAP,CLFLUSHOPT,MD_CLEAR,MELTDOWN
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: using VERW MDS workaround
pvbus0 at mainbus0: OpenBSD
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "OpenBSD VMM Host" rev 0x00
virtio0 at pci0 dev 1 function 0 "Qumranet Virtio RNG" rev 0x00
viornd0 at virtio0
virtio0: irq 3
virtio1 at pci0 dev 2 function 0 "Qumranet Virtio Network" rev 0x00
vio0 at virtio1: address fe:e1:bb:d1:8a:69
virtio1: irq 5
virtio2 at pci0 dev 3 function 0 "Qumranet Virtio Storage" rev 0x00
vioblk0 at virtio2
scsibus0 at vioblk0: 1 targets
sd0 at scsibus0 targ 0 lun 0: <VirtIO, Block Device, >
sd0: 307200MB, 512 bytes/sector, 629145600 sectors
virtio2: irq 6
virtio3 at pci0 dev 4 function 0 "OpenBSD VMM Control" rev 0x00
vmmci0 at virtio3
virtio3: irq 7
isa0 at mainbus0
com0 at isa0 port 0x3f8/8 irq 4: ns8250, no fifo
com0: console
softraid0 at root
scsibus1 at softraid0: 256 targets
PXE boot MAC address fe:e1:bb:d1:8a:69, interface vio0
root on rd0a swap on rd0b dump on rd0b
erase ^?, werase ^W, kill ^U, intr ^C, status ^T
Welcome to the OpenBSD/amd64 7.1 installation program.
Starting non-interactive mode in 5 seconds...
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? I
At any prompt except password prompts you can escape to a shell by
typing '!'. Default answers are shown in []'s and are selected by
pressing RETURN. You can exit this program at any time by pressing
Control-C, but this can leave your system in an inconsistent state.
Terminal type? [vt220]
System hostname? (short form, e.g. 'foo') test
Available network interfaces are: vio0 vlan0.
Which network interface do you wish to configure? (or 'done') [vio0]
IPv4 address for vio0? (or 'autoconf' or 'none') [autoconf]
IPv6 address for vio0? (or 'autoconf' or 'none') [none]
Available network interfaces are: vio0 vlan0.
Which network interface do you wish to configure? (or 'done') [done]
Using DNS domainname my.domain
Using DNS nameservers at 100.64.1.2
Password for root account? (will not echo)
Password for root account? (again)
Start sshd(8) by default? [yes]
Change the default console to com0? [yes]
Available speeds are: 9600 19200 38400 57600 115200.
Which speed should com0 use? (or 'done') [115200]
Setup a user? (enter a lower-case loginname, or 'no') [no]
Since no user was setup, root logins via sshd(8) might be useful.
WARNING: root is targeted by password guessing attacks, pubkeys are safer.
Allow root ssh login? (yes, no, prohibit-password) [no]
Available disks are: sd0.
Which disk is the root disk? ('?' for details) [sd0]
No valid MBR or GPT.
Use (W)hole disk MBR, whole disk (G)PT or (E)dit? [whole]
Setting OpenBSD MBR partition to whole sd0...done.
The auto-allocated layout for sd0 is:
# size offset fstype [fsize bsize cpg]
a: 1024.0M 64 4.2BSD 2048 16384 1 # /
b: 752.0M 2097216 swap
c: 307200.0M 0 unused
d: 4096.0M 3637312 4.2BSD 2048 16384 1 # /tmp
e: 5088.0M 12025920 4.2BSD 2048 16384 1 # /var
f: 6144.0M 22446144 4.2BSD 2048 16384 1 # /usr
g: 1024.0M 35029056 4.2BSD 2048 16384 1 # /usr/X11R6
h: 20480.0M 37126208 4.2BSD 2048 16384 1 # /usr/local
i: 3072.0M 79069248 4.2BSD 2048 16384 1 # /usr/src
j: 6144.0M 85360704 4.2BSD 2048 16384 1 # /usr/obj
k: 259376.0M 97943616 4.2BSD 4096 32768 1 # /home
Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout? [a]
/dev/rsd0a: 1024.0MB in 2097152 sectors of 512 bytes
6 cylinder groups of 202.50MB, 12960 blocks, 25920 inodes each
/dev/rsd0k: 259376.0MB in 531201984 sectors of 512 bytes
319 cylinder groups of 814.44MB, 26062 blocks, 52224 inodes each
/dev/rsd0d: 4096.0MB in 8388608 sectors of 512 bytes
21 cylinder groups of 202.50MB, 12960 blocks, 25920 inodes each
/dev/rsd0f: 6144.0MB in 12582912 sectors of 512 bytes
31 cylinder groups of 202.50MB, 12960 blocks, 25920 inodes each
/dev/rsd0g: 1024.0MB in 2097152 sectors of 512 bytes
6 cylinder groups of 202.50MB, 12960 blocks, 25920 inodes each
/dev/rsd0h: 20480.0MB in 41943040 sectors of 512 bytes
102 cylinder groups of 202.50MB, 12960 blocks, 25920 inodes each
/dev/rsd0j: 6144.0MB in 12582912 sectors of 512 bytes
31 cylinder groups of 202.50MB, 12960 blocks, 25920 inodes each
/dev/rsd0i: 3072.0MB in 6291456 sectors of 512 bytes
16 cylinder groups of 202.50MB, 12960 blocks, 25920 inodes each
/dev/rsd0e: 5088.0MB in 10420224 sectors of 512 bytes
26 cylinder groups of 202.50MB, 12960 blocks, 25920 inodes each
/dev/sd0a (8396dc9c6585eb4b.a) on /mnt type ffs (rw, asynchronous, local)
/dev/sd0k (8396dc9c6585eb4b.k) on /mnt/home type ffs (rw, asynchronous, local,
nodev, nosuid)
/dev/sd0d (8396dc9c6585eb4b.d) on /mnt/tmp type ffs (rw, asynchronous, local,
nodev, nosuid)
/dev/sd0f (8396dc9c6585eb4b.f) on /mnt/usr type ffs (rw, asynchronous, local,
nodev)
/dev/sd0g (8396dc9c6585eb4b.g) on /mnt/usr/X11R6 type ffs (rw, asynchronous,
local, nodev)
/dev/sd0h (8396dc9c6585eb4b.h) on /mnt/usr/local type ffs (rw, asynchronous,
local, nodev)
/dev/sd0j (8396dc9c6585eb4b.j) on /mnt/usr/obj type ffs (rw, asynchronous,
local, nodev, nosuid)
/dev/sd0i (8396dc9c6585eb4b.i) on /mnt/usr/src type ffs (rw, asynchronous,
local, nodev, nosuid)
/dev/sd0e (8396dc9c6585eb4b.e) on /mnt/var type ffs (rw, asynchronous, local,
nodev, nosuid)
Let's install the sets!
Location of sets? (disk http nfs or 'done') [http]
HTTP proxy URL? (e.g. 'http://proxy:8080', or 'none') [none]
(Unable to get list from openbsd.org, but that is OK)
HTTP Server? (hostname or 'done') [ftp.fau.de]
Server directory? [pub/OpenBSD/snapshots/amd64]
Select sets by entering a set name, a file name pattern or 'all'. De-select
sets by prepending a '-', e.g.: '-game*'. Selected sets are labelled '[X]'.
[X] bsd [X] comp71.tgz [X] xbase71.tgz [X] xserv71.tgz
[X] bsd.rd [X] man71.tgz [X] xshare71.tgz
[X] base71.tgz [X] game71.tgz [X] xfont71.tgz
Set name(s)? (or 'abort' or 'done') [done]
Get/Verify SHA256.sig 100% |**************************| 2144 00:00
Signature Verified
Get/Verify bsd 100% |**************************| 22345 KB 00:17
Get/Verify bsd.rd 100% |**************************| 4499 KB 00:02
Get/Verify base71.tgz 100% |**************************| 331 MB 02:18
Get/Verify comp71.tgz 100% |**************************| 73367 KB 00:28
Get/Verify man71.tgz 100% |**************************| 7601 KB 00:05
Get/Verify game71.tgz 100% |**************************| 2744 KB 00:02
Get/Verify xbase71.tgz 100% |**************************| 55180 KB 00:19
Get/Verify xshare71.tgz 100% |**************************| 4544 KB 00:04
Get/Verify xfont71.tgz 100% |**************************| 22965 KB 00:14
Get/Verify xserv71.tgz 100% |**************************| 20117 KB 00:08
Installing bsd 100% |**************************| 22345 KB 00:00
Installing bsd.rd 100% |**************************| 4499 KB 00:00
Installing base71.tgz 100% |**************************| 331 MB 00:35
Extracting etc.tgz 100% |**************************| 246 KB 00:00
Installing comp71.tgz 100% |**************************| 73367 KB 00:16
Installing man71.tgz 100% |**************************| 7601 KB 00:02
Installing game71.tgz 100% |**************************| 2744 KB 00:00
Installing xbase71.tgz 100% |**************************| 55180 KB 00:11
Extracting xetc.tgz 100% |**************************| 7272 00:00
Installing xshare71.tgz 100% |**************************| 4544 KB 00:01
Installing xfont71.tgz 100% |**************************| 22965 KB 00:02
Installing xserv71.tgz 100% |**************************| 20117 KB 00:03
Location of sets? (disk http nfs or 'done') [done]
What timezone are you in? ('?' for list) [Canada/Mountain] Europe/Berlin
Saving configuration files... done.
Making all device nodes... done.
fw_update: added intel; updated none; kept none
Relinking to create unique kernel... done.
CONGRATULATIONS! Your OpenBSD install has been successfully completed!
When you login to your new system the first time, please read your mail
using the 'mail' command.
Exit to (S)hell, (H)alt or (R)eboot? [reboot] H
syncing disks... done
vmmci0: powerdown
The operating system has halted.
Please press any key to reboot.
[EOT]
marsden# qemu-img check test.qcow2
ERROR cluster 32769 refcount=0 reference=1
1 errors were found on the image.
Data may be corrupted, or further writes to the image may corrupt it.
39422/4915200 = 0.80% allocated, 3.31% fragmented, 0.00% compressed clusters
Image end offset: 2610888704
For bigger images the errors are at regular intervals (n*32768+1):
golem# qemu-img check www.qcow2
ERROR cluster 32769 refcount=0 reference=1
ERROR cluster 65537 refcount=0 reference=1
ERROR cluster 98305 refcount=0 reference=1
ERROR cluster 131073 refcount=0 reference=1
ERROR cluster 163841 refcount=0 reference=1
ERROR cluster 196609 refcount=0 reference=1
ERROR cluster 229377 refcount=0 reference=1
ERROR cluster 262145 refcount=0 reference=1
ERROR cluster 294913 refcount=0 reference=1
ERROR cluster 327681 refcount=0 reference=1
ERROR cluster 360449 refcount=0 reference=1
ERROR cluster 393217 refcount=0 reference=1
ERROR cluster 425985 refcount=0 reference=1
ERROR cluster 458753 refcount=0 reference=1
ERROR cluster 491521 refcount=0 reference=1
ERROR cluster 524289 refcount=0 reference=1
ERROR cluster 557057 refcount=0 reference=1
ERROR cluster 589825 refcount=0 reference=1
ERROR cluster 622593 refcount=0 reference=1
ERROR cluster 655361 refcount=0 reference=1
ERROR cluster 688129 refcount=0 reference=1
ERROR cluster 720897 refcount=0 reference=1
ERROR cluster 753665 refcount=0 reference=1
ERROR cluster 786433 refcount=0 reference=1
ERROR cluster 819201 refcount=0 reference=1
ERROR cluster 851969 refcount=0 reference=1
ERROR cluster 884737 refcount=0 reference=1
ERROR cluster 917505 refcount=0 reference=1
ERROR cluster 950273 refcount=0 reference=1
ERROR cluster 983041 refcount=0 reference=1
ERROR cluster 1015809 refcount=0 reference=1
ERROR cluster 1048577 refcount=0 reference=1
32 errors were found on the image.
Data may be corrupted, or further writes to the image may corrupt it.
1074802/4915200 = 21.87% allocated, 2.00% fragmented, 0.00% compressed clusters
Image end offset: 70456967168
Kind regards,
Thomas