MORITA Kazutaka 893a8f6220 block: Produce zeros when protocols reading beyond end of file
While Asias is debugging an issue creating qcow2 images on top of
non-file protocols.  It boils down to this example using NBD:

$ qemu-io -c 'open -g nbd+unix:///?socket=/tmp/nbd.sock' -c 'read -v 0 512'

Notice the open -g option to set bs->growable.  This means you can
read/write beyond end of file.  Reading beyond end of file is supposed
to produce zeroes.

We rely on this behavior in qcow2_create2() during qcow2 image
creation.  We create a new file and then write the qcow2 header
structure using bdrv_pwrite().  Since QCowHeader is not a multiple of
sector size, block.c first uses bdrv_read() on the empty file to fetch
the first sector (should be all zeroes).

Here is the output from the qemu-io NBD example above:

$ qemu-io -c 'open -g nbd+unix:///?socket=/tmp/nbd.sock' -c 'read -v 0 512'
00000000:  ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab  ................
00000010:  ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab  ................
00000020:  ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab  ................
...

We are not zeroing the buffer!  As a result qcow2 image creation on top
of protocols is not guaranteed to work even when file creation is
supported by the protocol.

[Adapted this patch to use bs->zero_beyond_eof.
-- Stefan]

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Asias He <asias@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-08-22 14:14:56 +02:00
2013-04-18 13:50:53 +02:00
2013-07-09 13:38:56 -05:00
2013-08-20 11:23:52 -05:00
2013-07-30 23:11:07 +01:00
2013-08-07 12:48:00 -05:00
2013-07-26 22:01:31 +02:00
2013-07-30 23:11:07 +01:00
2013-08-05 08:06:25 -05:00
2013-05-03 13:58:09 +02:00
2013-07-30 10:25:47 +02:00
2012-09-07 09:02:44 +03:00
2013-06-11 23:45:43 +04:00
2013-07-18 08:17:42 -07:00
2013-08-19 08:49:37 -05:00
2013-08-19 15:52:19 +02:00
2013-08-19 15:52:19 +02:00
2013-07-23 11:12:00 +02:00
2013-08-19 15:52:19 +02:00
2013-04-08 18:13:10 +02:00
2012-05-14 07:27:24 +02:00
2013-08-05 08:06:25 -05:00
2008-10-12 17:54:42 +00:00
2013-08-16 18:44:33 +02:00
2013-07-31 21:03:59 +02:00
2013-07-23 02:41:31 +02:00
2013-07-15 09:49:00 +02:00
2013-02-21 16:17:31 -06:00
2013-08-12 09:15:12 -05:00
2013-08-19 15:52:19 +02:00
2013-08-19 08:49:37 -05:00
2013-06-14 15:33:10 +01:00
2013-08-02 18:05:16 +04:00
2013-05-03 13:05:49 +02:00
2013-05-18 16:35:12 +04:00
2013-02-22 21:21:10 +01:00
2013-06-06 11:27:05 +02:00
2013-07-19 12:52:03 +04:00
2013-05-01 13:06:07 +02:00
2011-12-11 17:50:43 -06:00
2013-05-03 12:04:40 -05:00
2013-07-23 11:11:59 +02:00
2013-08-19 15:52:19 +02:00
2013-08-15 15:41:13 -05:00
2013-07-30 10:25:47 +02:00
2013-07-04 17:42:45 +02:00
2013-04-08 18:13:10 +02:00

Read the documentation in qemu-doc.html or on http://wiki.qemu.org

- QEMU team
Description
No description provided
Readme 418 MiB
Languages
Rust 68.8%
C 26.3%
C++ 3%
Python 0.9%
Shell 0.5%
Other 0.3%