All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files
@ 2015-02-16 10:05 Pierre Schweitzer
  2015-02-17 14:50 ` [Qemu-devel] [Bug 1422307] " Max Reitz
                   ` (21 more replies)
  0 siblings, 22 replies; 25+ messages in thread
From: Pierre Schweitzer @ 2015-02-16 10:05 UTC (permalink / raw)
  To: qemu-devel

Public bug reported:

Dear all,

On Trusty, in certain situations, try to copy files over a qemu-nbd
mounted file system leads to write errors (and thus, file corruption).

Here is the last example I tried:
-> virtual disk is a VDI disk
-> It has only one partition, in FAT

Here is my mount process:
# modprobe nbd max_part=63
# qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
# partprobe /dev/nbd0
# mount /dev/nbd0p1 /tmp/mnt/

Partition is properly mounted at that point:
/dev/nbd0p1 on /tmp/mnt type vfat (rw)

Now, when I copy a file (rather big, ~28MB):
# cp file_to_copy /tmp/mnt/ ; sync
# md5sum /tmp/mnt/file_to_copy
2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
# umount /tmp/mnt 
# mount /dev/nbd0p1 /tmp/mnt/
# md5sum /tmp/mnt/file_to_copy
42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

The first hash was obviously the right one.

On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
It will randomly work after several attempts to write.

Version information:
# qemu-nbd --version
qemu-nbd version 0.0.1
Written by Anthony Liguori.

Cheers,

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
@ 2015-02-17 14:50 ` Max Reitz
  2015-02-17 14:50 ` Max Reitz
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Max Reitz @ 2015-02-17 14:50 UTC (permalink / raw)
  To: qemu-devel

Hi Pierre,

I can reproduce the bug with a 2 GB VDI image with a single
FAT32-formatted partition (on git master):

# cp src.vdi test.vdi
# ./qemu-nbd -c /dev/nbd0 test.vdi
# dd if=/dev/urandom of=/dev/nbd0 bs=1M count=64
64+0 records in
64+0 records out
67108864 bytes (67 MB) copied, 3.34091 s, 20.1 MB/s
# md5sum /dev/nbd0
bfa6726d0d8fe752c0c7dccbf770fae6  /dev/nbd0
# sync
# echo 1 > /proc/sys/vm/drop_caches
# md5sum /dev/nbd0
cb4762769e09ed6da5e327710bfb3996  /dev/nbd0
# ./qemu-nbd -d /dev/nbd0
/dev/nbd0 disconnected

Using qcow2 or not using NBD I cannot reproduce the issue. Using a qcow2
image and converting it to VDI, the issue appears again.

Using an empty VDI image, or one filled with random data, the issue does
not appear either.

I have attached a qcow2 image for others to test:

# ./qemu-img convert -O vdi src.qcow2 test.vdi; ./qemu-nbd -c /dev/nbd0 test.vdi; dd if=/dev/urandom of=/dev/nbd0 bs=1M count=64; md5sum /dev/nbd0; sync; echo 1 > /proc/sys/vm/drop_caches; md5sum /dev/nbd0; ./qemu-nbd -d /dev/nbd0                                                                                                                                                                 
64+0 records in
64+0 records out
67108864 bytes (67 MB) copied, 3.33071 s, 20.1 MB/s
9f683b4a58cecdd8da04ec2f1b7abc4a  /dev/nbd0
efb1cdd5ebe1dd326056eb2f2e500944  /dev/nbd0
/dev/nbd0 disconnected

Unfortunately, I do not yet know the cause of this issue.

Max

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
  2015-02-17 14:50 ` [Qemu-devel] [Bug 1422307] " Max Reitz
@ 2015-02-17 14:50 ` Max Reitz
  2015-02-17 17:18 ` Max Reitz
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Max Reitz @ 2015-02-17 14:50 UTC (permalink / raw)
  To: qemu-devel

** Attachment added: "src.qcow2"
   https://bugs.launchpad.net/qemu/+bug/1422307/+attachment/4321013/+files/src.qcow2

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
  2015-02-17 14:50 ` [Qemu-devel] [Bug 1422307] " Max Reitz
  2015-02-17 14:50 ` Max Reitz
@ 2015-02-17 17:18 ` Max Reitz
  2015-02-17 18:22 ` Max Reitz
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Max Reitz @ 2015-02-17 17:18 UTC (permalink / raw)
  To: qemu-devel

For whatever reason, using an empty image now works for me, too:

$ ./qemu-img create -f vdi test.vdi 64M; ./qemu-nbd -c /dev/nbd0 test.vdi; dd if=/dev/urandom of=/dev/nbd0 bs=1K count=16384; md5sum /dev/nbd0; sync; echo 1 > /proc/sys/vm/drop_caches; md5sum /dev/nbd0; ./qemu-nbd -d /dev/nbd0
Formatting 'test.vdi', fmt=vdi size=67108864 static=off
16384+0 records in
16384+0 records out
16777216 bytes (17 MB) copied, 0.982225 s, 17.1 MB/s
216f7abbf90bf2539163396bdb7fd7b9  /dev/nbd0
a42faf71124c1f6102fa39cea82a1c86  /dev/nbd0
/dev/nbd0 disconnected

Writing less than 16384 kB, the issue is not always reproducible; for
me, it disappears around 16160 kB (it's fuzzy, sometimes it appears,
sometimes it doesn't).

So far I was only able to reproduce the issue by connecting qemu-nbd to
the the Linux NBD interface; connecting to qemu-nbd via TCP worked fine.

So, a couple of test cases:

VDI and NBD over /dev/nbd0:
# for i in $(seq 0 9); do ./qemu-img create -f vdi test.vdi 64M > /dev/null; ./qemu-nbd -c /dev/nbd0 test.vdi; sleep 1; ./qemu-img convert -n blob.raw /dev/nbd0; ./qemu-img convert /dev/nbd0 test1.raw; sync; echo 1 > /proc/sys/vm/drop_caches; ./qemu-img convert /dev/nbd0 test2.raw; ./qemu-nbd -d /dev/nbd0 > /dev/null; if ! ./qemu-img compare -q test1.raw test2.raw; then md5sum test1.raw test2.raw; echo "$i failed"; break; fi; done; echo 'done'
e5185b807948d65bb4e837d992cea429  test1.raw
9907ca700f6ee4d4cdb136bb90fd8df1  test2.raw
6 failed
done

VDI and NBD over TCP:
# for i in $(seq 0 9); do ./qemu-img create -f vdi test.vdi 64M > /dev/null; (./qemu-nbd -t test.vdi &); sleep 1; ./qemu-img convert -n blob.raw nbd://localhost; ./qemu-img convert nbd://localhost test1.raw; sync; echo 1 > /proc/sys/vm/drop_caches; ./qemu-img convert nbd://localhost test2.raw; killall qemu-nbd; if ! ./qemu-img compare -q test1.raw test2.raw; then md5sum test1.raw test2.raw; echo "$i failed"; break; fi; done; echo 'done'      
done

VDI and NBD over a Unix socket:
# for i in $(seq 0 9); do ./qemu-img create -f vdi test.vdi 64M > /dev/null; (./qemu-nbd -k /tmp/nbd -t test.vdi &); sleep 1; ./qemu-img convert -n blob.raw nbd+unix:///\?socket=/tmp/nbd; ./qemu-img convert nbd+unix:///\?socket=/tmp/nbd test1.raw; sync; echo 1 > /proc/sys/vm/drop_caches; ./qemu-img convert nbd+unix:///\?socket=/tmp/nbd test2.raw; killall qemu-nbd; if ! ./qemu-img compare -q test1.raw test2.raw; then md5sum test1.raw test2.raw; echo "$i failed"; break; fi; done; echo 'done'                                     
done

VDI without NBD:
# for i in $(seq 0 9); do ./qemu-img create -f vdi test.vdi 64M > /dev/null; ./qemu-img convert -n -O vdi blob.raw test.vdi; ./qemu-img convert test.vdi test1.raw; sync; echo 1 > /proc/sys/vm/drop_caches; ./qemu-img convert test.vdi test2.raw; if ! ./qemu-img compare -q test1.raw test2.raw; then md5sum test1.raw test2.raw; echo "$i failed"; break; fi; done; echo 'done'
done

qcow2 and NBD over /dev/nbd0:
# for i in $(seq 0 9); do ./qemu-img create -f qcow2 test.qcow2 64M > /dev/null; ./qemu-nbd -c /dev/nbd0 test.qcow2; sleep 1; ./qemu-img convert -n blob.raw /dev/nbd0; ./qemu-img convert /dev/nbd0 test1.raw; sync; echo 1 > /proc/sys/vm/drop_caches; ./qemu-img convert /dev/nbd0 test2.raw; ./qemu-nbd -d /dev/nbd0 > /dev/null; if ! ./qemu-img compare -q test1.raw test2.raw; then md5sum test1.raw test2.raw; echo "$i failed"; break; fi; done; echo 'done'
done

raw and NBD over /dev/nbd0:
# for i in $(seq 0 9); do ./qemu-img create -f raw test.raw 64M > /dev/null; ./qemu-nbd -f raw -c /dev/nbd0 test.raw; sleep 1; ./qemu-img convert -n blob.raw /dev/nbd0; ./qemu-img convert /dev/nbd0 test1.raw; sync; echo 1 > /proc/sys/vm/drop_caches; ./qemu-img convert /dev/nbd0 test2.raw; ./qemu-nbd -d /dev/nbd0 > /dev/null; if ! ./qemu-img compare -q test1.raw test2.raw; then md5sum test1.raw test2.raw; echo "$i failed"; break; fi; done; echo 'done'
done

In conclusion, the only combination I can reproduce the issue with is
VDI with NBD over the Linux NBD interface. It doesn't seem to be the
kernel's fault because other file formats work fine; it doesn't seem to
be qemu-nbd's fault because not using the kernel interface works fine;
and it doesn't seem to be VDI's fault because not using NBD or at least
using NBD over TCP or Unix sockets works fine, too.

I'll keep looking into it.

Max

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (2 preceding siblings ...)
  2015-02-17 17:18 ` Max Reitz
@ 2015-02-17 18:22 ` Max Reitz
  2015-02-17 19:21 ` Max Reitz
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Max Reitz @ 2015-02-17 18:22 UTC (permalink / raw)
  To: qemu-devel

First insight: Having the VDI image in tmpfs or using --cache=none for
qemu-nbd changes nothing, therefore the reason why dropping the caches
affects the result is probably Linux's cache for the NBD block device.

Second insight: Using blkverify makes it look very much like qemu's VDI
implementation is the culprit:

# for i in $(seq 0 9); do ./qemu-img create -f vdi /tmp/test.vdi 64M > /dev/null; ./qemu-img create -f raw /tmp/test.raw 64M > /dev/null; (./qemu-nbd -v -f raw -c /dev/nbd0 blkverify:/tmp/test.raw:/tmp/test.vdi &); sleep 1; ./qemu-img convert -n blob.raw /dev/nbd0; ./qemu-img convert /dev/nbd0 /tmp/test1.raw; sync; echo 1 > /proc/sys/vm/drop_caches; ./qemu-img convert /dev/nbd0 /tmp/test2.raw; ./qemu-nbd -d /dev/nbd0 > /dev/null; if ! ./qemu-img compare -q /tmp/test1.raw /tmp/test2.raw; then md5sum /tmp/test1.raw /tmp/test2.raw; echo "$i failed"; break; fi; done; echo 'done'
NBD device /dev/nbd0 is now connected to blkverify:/tmp/test.raw:/tmp/test.vdi
NBD device /dev/nbd0 is now connected to blkverify:/tmp/test.raw:/tmp/test.vdi
NBD device /dev/nbd0 is now connected to blkverify:/tmp/test.raw:/tmp/test.vdi
blkverify: read sector_num=27872 nb_sectors=256 contents mismatch in sector 27904
blkverify: read sector_num=28128 nb_sectors=256 contents mismatch in sector 28128
qemu-img: error while reading sector 24576: Input/output error
e5185b807948d65bb4e837d992cea429  /tmp/test1.raw
b8a195424a240ed77c849d89002fa23b  /tmp/test2.raw
2 failed
done

Max

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (3 preceding siblings ...)
  2015-02-17 18:22 ` Max Reitz
@ 2015-02-17 19:21 ` Max Reitz
  2015-02-17 21:25 ` Max Reitz
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Max Reitz @ 2015-02-17 19:21 UTC (permalink / raw)
  To: qemu-devel

I succeeded to reproduce the bug without NBD:

$ ./qemu-img create -f vdi test.vdi 2G
Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
$ ./qemu-img create -f raw test.raw 2G
Formatting 'test.raw', fmt=raw size=2147483648
$ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008

Operations in the guest:
$ dd if=/dev/vdb of=/dev/vda
$ dd if=/dev/vda of=/dev/null

So it really looks like something's broken in qemu's VDI block driver.

Max

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (4 preceding siblings ...)
  2015-02-17 19:21 ` Max Reitz
@ 2015-02-17 21:25 ` Max Reitz
  2015-02-18  9:11 ` Pierre Schweitzer
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Max Reitz @ 2015-02-17 21:25 UTC (permalink / raw)
  To: qemu-devel

Adding some locking in qemu's VDI implementation makes the bug
disappear, at least I can't reproduce it anymore. I'll send a patch.

Max

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (5 preceding siblings ...)
  2015-02-17 21:25 ` Max Reitz
@ 2015-02-18  9:11 ` Pierre Schweitzer
  2015-02-18 13:58   ` Stefan Hajnoczi
  2015-02-19 17:48 ` Pierre Schweitzer
                   ` (14 subsequent siblings)
  21 siblings, 1 reply; 25+ messages in thread
From: Pierre Schweitzer @ 2015-02-18  9:11 UTC (permalink / raw)
  To: qemu-devel

So, if I understand well, it's "just" some kind of race condition in the
handling of writes in the VDI driver of Qemu?

Does that mean it can also affect VMs running with VDI disk(s)?

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-18  9:11 ` Pierre Schweitzer
@ 2015-02-18 13:58   ` Stefan Hajnoczi
  0 siblings, 0 replies; 25+ messages in thread
From: Stefan Hajnoczi @ 2015-02-18 13:58 UTC (permalink / raw)
  To: Bug 1422307; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

On Wed, Feb 18, 2015 at 09:11:57AM -0000, Pierre Schweitzer wrote:
> Does that mean it can also affect VMs running with VDI disk(s)?

Yes, that's what Max's example showed.

Note that only raw, qcow2, and qed support in QEMU is designed for
running guests.  The other formats like vmdk and vdi are mainly for
qemu-img convert and will perform poorly because they don't handle
parallel I/O requests.

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (6 preceding siblings ...)
  2015-02-18  9:11 ` Pierre Schweitzer
@ 2015-02-19 17:48 ` Pierre Schweitzer
  2015-02-23 10:42   ` Stefan Hajnoczi
  2015-04-09  8:00 ` Pierre Schweitzer
                   ` (13 subsequent siblings)
  21 siblings, 1 reply; 25+ messages in thread
From: Pierre Schweitzer @ 2015-02-19 17:48 UTC (permalink / raw)
  To: qemu-devel

Thanks Max & Stefan.

Could you please let me know when the commit makes it to the QEMU
repository? And give me its commit ID?

So that I can ask for a bugfix backport in Trusty.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-19 17:48 ` Pierre Schweitzer
@ 2015-02-23 10:42   ` Stefan Hajnoczi
  0 siblings, 0 replies; 25+ messages in thread
From: Stefan Hajnoczi @ 2015-02-23 10:42 UTC (permalink / raw)
  To: Bug 1422307; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

On Thu, Feb 19, 2015 at 05:48:03PM -0000, Pierre Schweitzer wrote:
> Thanks Max & Stefan.
> 
> Could you please let me know when the commit makes it to the QEMU
> repository? And give me its commit ID?
> 
> So that I can ask for a bugfix backport in Trusty.

Hi Pierre,
In case I forget, please follow this patch series from Max:
http://patchwork.ozlabs.org/patch/440713/

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (7 preceding siblings ...)
  2015-02-19 17:48 ` Pierre Schweitzer
@ 2015-04-09  8:00 ` Pierre Schweitzer
  2015-07-06 11:40 ` Nicolas Rüegg
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Pierre Schweitzer @ 2015-04-09  8:00 UTC (permalink / raw)
  To: qemu-devel

Hi,
Was the patch abandoned? I haven't seen any further progress on it for a month...
Cheers,

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (8 preceding siblings ...)
  2015-04-09  8:00 ` Pierre Schweitzer
@ 2015-07-06 11:40 ` Nicolas Rüegg
  2015-07-06 13:46 ` Max Reitz
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Nicolas Rüegg @ 2015-07-06 11:40 UTC (permalink / raw)
  To: qemu-devel

Hi,

Has this patch already been incorporated? I'm observing the bug as well
when copying files into a VDI image.

Kind regards,

Nicolas

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (9 preceding siblings ...)
  2015-07-06 11:40 ` Nicolas Rüegg
@ 2015-07-06 13:46 ` Max Reitz
  2015-07-06 14:46 ` Pierre Schweitzer
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Max Reitz @ 2015-07-06 13:46 UTC (permalink / raw)
  To: qemu-devel

Hi Nicolas,

It (that is, its v2) has been merged into upstream master
(http://git.qemu.org/?p=qemu.git;a=commit;h=f0ab6f109630940146cbaf47d0cd99993ddba824)
and is part of qemu 2.3.0 (and will probably become part of 2.2.2, too).

Max

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (10 preceding siblings ...)
  2015-07-06 13:46 ` Max Reitz
@ 2015-07-06 14:46 ` Pierre Schweitzer
  2015-08-17 10:29 ` Robie Basak
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Pierre Schweitzer @ 2015-07-06 14:46 UTC (permalink / raw)
  To: qemu-devel

Thanks for the extra information.

I'll open a new bug report at Ubuntu to get the fix backported to
Trusty. Thanks!

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  New

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (11 preceding siblings ...)
  2015-07-06 14:46 ` Pierre Schweitzer
@ 2015-08-17 10:29 ` Robie Basak
  2015-08-17 10:30 ` Robie Basak
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Robie Basak @ 2015-08-17 10:29 UTC (permalink / raw)
  To: qemu-devel

Based on Max's comment this is Fix Released upstream.

** Also affects: qemu (Ubuntu)
   Importance: Undecided
       Status: New

** Changed in: qemu
       Status: New => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Triaged

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (12 preceding siblings ...)
  2015-08-17 10:29 ` Robie Basak
@ 2015-08-17 10:30 ` Robie Basak
  2015-08-19  7:28 ` Pierre Schweitzer
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Robie Basak @ 2015-08-17 10:30 UTC (permalink / raw)
  To: qemu-devel

And since Ubuntu Wily ships 2.3, I presume this is also fixed in Ubuntu
in Wily. I'll mark that Fix Released too, and add a task for Trusty.

** Changed in: qemu (Ubuntu)
       Status: New => Fix Released

** Also affects: qemu (Ubuntu Trusty)
   Importance: Undecided
       Status: New

** Changed in: qemu (Ubuntu Trusty)
       Status: New => Triaged

** Changed in: qemu (Ubuntu Trusty)
   Importance: Undecided => Medium

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Triaged

Bug description:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt 
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (13 preceding siblings ...)
  2015-08-17 10:30 ` Robie Basak
@ 2015-08-19  7:28 ` Pierre Schweitzer
  2015-08-26 16:49 ` Serge Hallyn
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Pierre Schweitzer @ 2015-08-19  7:28 UTC (permalink / raw)
  To: qemu-devel

Please find attach a proposed debdiff for fixing the issue in Ubuntu
Trusty by backporting the fix which is now in Wily.

** Description changed:

+ [Impact]
+ A race condition in the VDI block driver of Qemu leads to image (and thus file system) corruption under certain circumstances.
+ This makes Qemu tools usage for VDI formatted images particularly dangerous (qemu-img, qemu-nbd).
+ The bug fix introduces locks to prevent such race condition.
+ 
+ 
+ [Test Case]
+ A simple test case was provided in comment #5 (https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/comments/5):
+ 
+ $ ./qemu-img create -f vdi test.vdi 2G
+ Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
+ $ ./qemu-img create -f raw test.raw 2G
+ Formatting 'test.raw', fmt=raw size=2147483648
+ $ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
+ blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008
+ 
+ Operations in the guest:
+ $ dd if=/dev/vdb of=/dev/vda
+ $ dd if=/dev/vda of=/dev/null
+ 
+ [Regression Potential]
+ In case of bugs affecting the way locks are used, deadlocks could be a regression, but they would only affect VDI images.
+ 
+ 
+ Original bug report:
  Dear all,
  
  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).
  
  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT
  
  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/
  
  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)
  
  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
- # umount /tmp/mnt 
+ # umount /tmp/mnt
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy
  
  The first hash was obviously the right one.
  
  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.
  
  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.
  
  Cheers,

** Patch added: "qemu_2.0.0+dfsg-2ubuntu1.17.diff"
   https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/+attachment/4448189/+files/qemu_2.0.0%2Bdfsg-2ubuntu1.17.diff

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Triaged

Bug description:
  [Impact]
  A race condition in the VDI block driver of Qemu leads to image (and thus file system) corruption under certain circumstances.
  This makes Qemu tools usage for VDI formatted images particularly dangerous (qemu-img, qemu-nbd).
  The bug fix introduces locks to prevent such race condition.

  
  [Test Case]
  A simple test case was provided in comment #5 (https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/comments/5):

  $ ./qemu-img create -f vdi test.vdi 2G
  Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
  $ ./qemu-img create -f raw test.raw 2G
  Formatting 'test.raw', fmt=raw size=2147483648
  $ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
  blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008

  Operations in the guest:
  $ dd if=/dev/vdb of=/dev/vda
  $ dd if=/dev/vda of=/dev/null

  [Regression Potential]
  In case of bugs affecting the way locks are used, deadlocks could be a regression, but they would only affect VDI images.

  
  Original bug report:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (14 preceding siblings ...)
  2015-08-19  7:28 ` Pierre Schweitzer
@ 2015-08-26 16:49 ` Serge Hallyn
  2015-08-26 21:32 ` Serge Hallyn
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Serge Hallyn @ 2015-08-26 16:49 UTC (permalink / raw)
  To: qemu-devel

** Changed in: qemu (Ubuntu Trusty)
   Importance: Medium => High

** Changed in: qemu (Ubuntu Trusty)
     Assignee: (unassigned) => Serge Hallyn (serge-hallyn)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Triaged

Bug description:
  [Impact]
  A race condition in the VDI block driver of Qemu leads to image (and thus file system) corruption under certain circumstances.
  This makes Qemu tools usage for VDI formatted images particularly dangerous (qemu-img, qemu-nbd).
  The bug fix introduces locks to prevent such race condition.

  
  [Test Case]
  A simple test case was provided in comment #5 (https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/comments/5):

  $ ./qemu-img create -f vdi test.vdi 2G
  Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
  $ ./qemu-img create -f raw test.raw 2G
  Formatting 'test.raw', fmt=raw size=2147483648
  $ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
  blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008

  Operations in the guest:
  $ dd if=/dev/vdb of=/dev/vda
  $ dd if=/dev/vda of=/dev/null

  [Regression Potential]
  In case of bugs affecting the way locks are used, deadlocks could be a regression, but they would only affect VDI images.

  
  Original bug report:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (15 preceding siblings ...)
  2015-08-26 16:49 ` Serge Hallyn
@ 2015-08-26 21:32 ` Serge Hallyn
  2015-08-27 22:41 ` Brian Murray
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Serge Hallyn @ 2015-08-26 21:32 UTC (permalink / raw)
  To: qemu-devel

** Changed in: qemu (Ubuntu Trusty)
     Assignee: Serge Hallyn (serge-hallyn) => (unassigned)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Triaged

Bug description:
  [Impact]
  A race condition in the VDI block driver of Qemu leads to image (and thus file system) corruption under certain circumstances.
  This makes Qemu tools usage for VDI formatted images particularly dangerous (qemu-img, qemu-nbd).
  The bug fix introduces locks to prevent such race condition.

  
  [Test Case]
  A simple test case was provided in comment #5 (https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/comments/5):

  $ ./qemu-img create -f vdi test.vdi 2G
  Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
  $ ./qemu-img create -f raw test.raw 2G
  Formatting 'test.raw', fmt=raw size=2147483648
  $ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
  blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008

  Operations in the guest:
  $ dd if=/dev/vdb of=/dev/vda
  $ dd if=/dev/vda of=/dev/null

  [Regression Potential]
  In case of bugs affecting the way locks are used, deadlocks could be a regression, but they would only affect VDI images.

  
  Original bug report:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (16 preceding siblings ...)
  2015-08-26 21:32 ` Serge Hallyn
@ 2015-08-27 22:41 ` Brian Murray
  2015-08-28  6:29 ` Pierre Schweitzer
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Brian Murray @ 2015-08-27 22:41 UTC (permalink / raw)
  To: qemu-devel

Hello Pierre, or anyone else affected,

Accepted qemu into trusty-proposed. The package will build now and be
available at https://launchpad.net/ubuntu/+source/qemu/2.0.0+dfsg-
2ubuntu1.18 in a few hours, and then in the -proposed repository.

Please help us by testing this new package.  See
https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to
enable and use -proposed.  Your feedback will aid us getting this update
out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug,
mentioning the version of the package you tested, and change the tag
from verification-needed to verification-done. If it does not fix the
bug for you, please add a comment stating that, and change the tag to
verification-failed.  In either case, details of your testing will help
us make a better decision.

Further information regarding the verification process can be found at
https://wiki.ubuntu.com/QATeam/PerformingSRUVerification .  Thank you in
advance!

** Changed in: qemu (Ubuntu Trusty)
       Status: Triaged => Fix Committed

** Tags added: verification-needed

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Fix Committed

Bug description:
  [Impact]
  A race condition in the VDI block driver of Qemu leads to image (and thus file system) corruption under certain circumstances.
  This makes Qemu tools usage for VDI formatted images particularly dangerous (qemu-img, qemu-nbd).
  The bug fix introduces locks to prevent such race condition.

  
  [Test Case]
  A simple test case was provided in comment #5 (https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/comments/5):

  $ ./qemu-img create -f vdi test.vdi 2G
  Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
  $ ./qemu-img create -f raw test.raw 2G
  Formatting 'test.raw', fmt=raw size=2147483648
  $ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
  blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008

  Operations in the guest:
  $ dd if=/dev/vdb of=/dev/vda
  $ dd if=/dev/vda of=/dev/null

  [Regression Potential]
  In case of bugs affecting the way locks are used, deadlocks could be a regression, but they would only affect VDI images.

  
  Original bug report:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (17 preceding siblings ...)
  2015-08-27 22:41 ` Brian Murray
@ 2015-08-28  6:29 ` Pierre Schweitzer
  2015-08-28  6:42 ` Pierre Schweitzer
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 25+ messages in thread
From: Pierre Schweitzer @ 2015-08-28  6:29 UTC (permalink / raw)
  To: qemu-devel

** Tags removed: verification-needed
** Tags added: verification-done

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Fix Committed

Bug description:
  [Impact]
  A race condition in the VDI block driver of Qemu leads to image (and thus file system) corruption under certain circumstances.
  This makes Qemu tools usage for VDI formatted images particularly dangerous (qemu-img, qemu-nbd).
  The bug fix introduces locks to prevent such race condition.

  
  [Test Case]
  A simple test case was provided in comment #5 (https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/comments/5):

  $ ./qemu-img create -f vdi test.vdi 2G
  Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
  $ ./qemu-img create -f raw test.raw 2G
  Formatting 'test.raw', fmt=raw size=2147483648
  $ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
  blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008

  Operations in the guest:
  $ dd if=/dev/vdb of=/dev/vda
  $ dd if=/dev/vda of=/dev/null

  [Regression Potential]
  In case of bugs affecting the way locks are used, deadlocks could be a regression, but they would only affect VDI images.

  
  Original bug report:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (18 preceding siblings ...)
  2015-08-28  6:29 ` Pierre Schweitzer
@ 2015-08-28  6:42 ` Pierre Schweitzer
  2015-09-09  1:28 ` Launchpad Bug Tracker
  2015-09-09  1:28 ` [Qemu-devel] [Bug 1422307] Update Released Chris Halse Rogers
  21 siblings, 0 replies; 25+ messages in thread
From: Pierre Schweitzer @ 2015-08-28  6:42 UTC (permalink / raw)
  To: qemu-devel

Tested 2.0.0+dfsg-2ubuntu1.18.
Cannot reproduce the issue. 

TEST CASE 1:
Attempt several times to copy files on a VDI disk, and couldn't trigger any corruption (nor deadlock - no regression). Given my test scenario, previously, I would already have hit the corruption.

TEST CASE 2:
Tested with test scenario provided in comment #4. Couldn't reproduce, and no regression.

TEST CASE 3:
Tested with test scenario provided in comment #5. Couldn't reproduce, and no regression.

Marking as verification-done

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Fix Committed

Bug description:
  [Impact]
  A race condition in the VDI block driver of Qemu leads to image (and thus file system) corruption under certain circumstances.
  This makes Qemu tools usage for VDI formatted images particularly dangerous (qemu-img, qemu-nbd).
  The bug fix introduces locks to prevent such race condition.

  
  [Test Case]
  A simple test case was provided in comment #5 (https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/comments/5):

  $ ./qemu-img create -f vdi test.vdi 2G
  Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
  $ ./qemu-img create -f raw test.raw 2G
  Formatting 'test.raw', fmt=raw size=2147483648
  $ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
  blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008

  Operations in the guest:
  $ dd if=/dev/vdb of=/dev/vda
  $ dd if=/dev/vda of=/dev/null

  [Regression Potential]
  In case of bugs affecting the way locks are used, deadlocks could be a regression, but they would only affect VDI images.

  
  Original bug report:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Re: qemu-nbd corrupts files
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (19 preceding siblings ...)
  2015-08-28  6:42 ` Pierre Schweitzer
@ 2015-09-09  1:28 ` Launchpad Bug Tracker
  2015-09-09  1:28 ` [Qemu-devel] [Bug 1422307] Update Released Chris Halse Rogers
  21 siblings, 0 replies; 25+ messages in thread
From: Launchpad Bug Tracker @ 2015-09-09  1:28 UTC (permalink / raw)
  To: qemu-devel

This bug was fixed in the package qemu - 2.0.0+dfsg-2ubuntu1.18

---------------
qemu (2.0.0+dfsg-2ubuntu1.18) trusty-proposed; urgency=medium

  * qemu-nbd-fix-vdi-corruption.patch:
    qemu-nbd: fix corruption while writing VDI volumes (LP: #1422307)

 -- Pierre Schweitzer <pierre@reactos.org>  Mon, 17 Aug 2015 11:43:39
+0200

** Changed in: qemu (Ubuntu Trusty)
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Fix Released

Bug description:
  [Impact]
  A race condition in the VDI block driver of Qemu leads to image (and thus file system) corruption under certain circumstances.
  This makes Qemu tools usage for VDI formatted images particularly dangerous (qemu-img, qemu-nbd).
  The bug fix introduces locks to prevent such race condition.

  
  [Test Case]
  A simple test case was provided in comment #5 (https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/comments/5):

  $ ./qemu-img create -f vdi test.vdi 2G
  Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
  $ ./qemu-img create -f raw test.raw 2G
  Formatting 'test.raw', fmt=raw size=2147483648
  $ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
  blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008

  Operations in the guest:
  $ dd if=/dev/vdb of=/dev/vda
  $ dd if=/dev/vda of=/dev/null

  [Regression Potential]
  In case of bugs affecting the way locks are used, deadlocks could be a regression, but they would only affect VDI images.

  
  Original bug report:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [Bug 1422307] Update Released
  2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
                   ` (20 preceding siblings ...)
  2015-09-09  1:28 ` Launchpad Bug Tracker
@ 2015-09-09  1:28 ` Chris Halse Rogers
  21 siblings, 0 replies; 25+ messages in thread
From: Chris Halse Rogers @ 2015-09-09  1:28 UTC (permalink / raw)
  To: qemu-devel

The verification of the Stable Release Update for qemu has completed
successfully and the package has now been released to -updates.
Subsequently, the Ubuntu Stable Release Updates Team is being
unsubscribed and will not receive messages about this bug report.  In
the event that you encounter a regression using the package from
-updates please report a new bug using ubuntu-bug and tag the bug report
regression-update so we can easily find any regressions.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1422307

Title:
  qemu-nbd corrupts files

Status in QEMU:
  Fix Released
Status in qemu package in Ubuntu:
  Fix Released
Status in qemu source package in Trusty:
  Fix Released

Bug description:
  [Impact]
  A race condition in the VDI block driver of Qemu leads to image (and thus file system) corruption under certain circumstances.
  This makes Qemu tools usage for VDI formatted images particularly dangerous (qemu-img, qemu-nbd).
  The bug fix introduces locks to prevent such race condition.

  
  [Test Case]
  A simple test case was provided in comment #5 (https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1422307/comments/5):

  $ ./qemu-img create -f vdi test.vdi 2G
  Formatting 'test.vdi', fmt=vdi size=2147483648 static=off
  $ ./qemu-img create -f raw test.raw 2G
  Formatting 'test.raw', fmt=raw size=2147483648
  $ x86_64-softmmu/qemu-system-x86_64 -enable-kvm -drive if=virtio,file=blkverify:test.raw:test.vdi,format=raw -drive if=virtio,file=data.img,format=raw,format=raw -cdrom ~/tmp/arch.iso -m 512 -boot d
  blkverify: read sector_num=810976 nb_sectors=256 contents mismatch in sector 811008

  Operations in the guest:
  $ dd if=/dev/vdb of=/dev/vda
  $ dd if=/dev/vda of=/dev/null

  [Regression Potential]
  In case of bugs affecting the way locks are used, deadlocks could be a regression, but they would only affect VDI images.

  
  Original bug report:
  Dear all,

  On Trusty, in certain situations, try to copy files over a qemu-nbd
  mounted file system leads to write errors (and thus, file corruption).

  Here is the last example I tried:
  -> virtual disk is a VDI disk
  -> It has only one partition, in FAT

  Here is my mount process:
  # modprobe nbd max_part=63
  # qemu-nbd -c /dev/nbd0 "virtual_disk.vdi"
  # partprobe /dev/nbd0
  # mount /dev/nbd0p1 /tmp/mnt/

  Partition is properly mounted at that point:
  /dev/nbd0p1 on /tmp/mnt type vfat (rw)

  Now, when I copy a file (rather big, ~28MB):
  # cp file_to_copy /tmp/mnt/ ; sync
  # md5sum /tmp/mnt/file_to_copy
  2efc9f32e4267782b11d63d2f128a363  /tmp/mnt/file_to_copy
  # umount /tmp/mnt
  # mount /dev/nbd0p1 /tmp/mnt/
  # md5sum /tmp/mnt/file_to_copy
  42b0a3bf73f704d03ce301716d7654de  /tmp/mnt/file_to_copy

  The first hash was obviously the right one.

  On a previous attempt I did, I spotted thanks to vbindiff that parts of the file were just filed with 0s instead of actual data.
  It will randomly work after several attempts to write.

  Version information:
  # qemu-nbd --version
  qemu-nbd version 0.0.1
  Written by Anthony Liguori.

  Cheers,

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1422307/+subscriptions

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-09-09  1:35 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-16 10:05 [Qemu-devel] [Bug 1422307] [NEW] qemu-nbd corrupts files Pierre Schweitzer
2015-02-17 14:50 ` [Qemu-devel] [Bug 1422307] " Max Reitz
2015-02-17 14:50 ` Max Reitz
2015-02-17 17:18 ` Max Reitz
2015-02-17 18:22 ` Max Reitz
2015-02-17 19:21 ` Max Reitz
2015-02-17 21:25 ` Max Reitz
2015-02-18  9:11 ` Pierre Schweitzer
2015-02-18 13:58   ` Stefan Hajnoczi
2015-02-19 17:48 ` Pierre Schweitzer
2015-02-23 10:42   ` Stefan Hajnoczi
2015-04-09  8:00 ` Pierre Schweitzer
2015-07-06 11:40 ` Nicolas Rüegg
2015-07-06 13:46 ` Max Reitz
2015-07-06 14:46 ` Pierre Schweitzer
2015-08-17 10:29 ` Robie Basak
2015-08-17 10:30 ` Robie Basak
2015-08-19  7:28 ` Pierre Schweitzer
2015-08-26 16:49 ` Serge Hallyn
2015-08-26 21:32 ` Serge Hallyn
2015-08-27 22:41 ` Brian Murray
2015-08-28  6:29 ` Pierre Schweitzer
2015-08-28  6:42 ` Pierre Schweitzer
2015-09-09  1:28 ` Launchpad Bug Tracker
2015-09-09  1:28 ` [Qemu-devel] [Bug 1422307] Update Released Chris Halse Rogers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.