Kevin Wolf b94a261057 block: Avoid unecessary drv->bdrv_getlength() calls
The block layer generally keeps the size of an image cached in
bs->total_sectors so that it doesn't have to perform expensive
operations to get the size whenever it needs it.

This doesn't work however when using a backend that can change its size
without qemu being aware of it, i.e. passthrough of removable media like
CD-ROMs or floppy disks. For this reason, the caching is disabled when a
removable device is used.

It is obvious that checking whether the _guest_ device has removable
media isn't the right thing to do when we want to know whether the size
of the host backend can change. To make things worse, non-top-level
BlockDriverStates never have any device attached, which makes qemu
assume they are removable, so drv->bdrv_getlength() is always called on
the protocol layer. In the case of raw-posix, this causes unnecessary
lseek() system calls, which turned out to be rather expensive.

This patch completely changes the logic and disables bs->total_sectors
caching only for certain block driver types, for which a size change is
expected: host_cdrom and host_floppy on POSIX, host_device on win32; also
the raw format in case it sits on top of one of these protocols, but in
the common case the nested bdrv_getlength() call on the protocol driver
will use the cache again and avoid an expensive drv->bdrv_getlength()
call.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2013-10-29 13:10:26 +01:00
2013-10-21 16:49:35 +02:00
2013-04-18 13:50:53 +02:00
2013-07-09 13:38:56 -05:00
2013-10-29 13:06:39 +01:00
2013-10-11 09:34:56 -07:00
2013-08-07 12:48:00 -05:00
2013-10-03 00:04:20 +01:00
2013-10-11 09:34:56 -07:00
2013-10-12 16:19:20 -07:00
2013-10-28 17:34:42 +01:00
2013-05-03 13:58:09 +02:00
2013-10-17 17:30:55 +02:00
2012-09-07 09:02:44 +03:00
2013-10-11 09:34:56 -07:00
2013-09-05 09:40:31 -05:00
2013-09-30 17:15:01 -05:00
2013-10-17 10:19:59 +02:00
2013-10-11 10:52:54 +02:00
2013-10-11 09:34:56 -07:00
2013-10-17 17:31:00 +02:00
2013-09-03 12:25:55 +02:00
2013-07-23 02:41:31 +02:00
2013-10-17 10:10:14 +02:00
2013-02-21 16:17:31 -06:00
2013-08-12 09:15:12 -05:00
2013-10-11 16:50:01 +02:00
2013-09-03 12:25:55 +02:00
2013-09-03 12:33:32 -05:00
2013-09-06 15:25:08 +02:00
2013-05-18 16:35:12 +04:00
2013-10-11 09:34:56 -07:00
2013-07-19 12:52:03 +04:00
2013-05-01 13:06:07 +02:00
2013-09-02 09:08:29 -07:00
2013-10-11 09:34:56 -07:00
2013-09-25 21:23:05 +02:00
2013-08-15 15:41:13 -05:00
2013-10-11 09:34:56 -07:00
2013-10-17 12:42:54 +02:00
2013-04-08 18:13:10 +02:00

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

- QEMU team
Description
A fork of QEMU-Nyx which is better suited for my bachelors thesis
Readme 154 MiB
Languages
C 90.3%
Dylan 2.5%
Python 2.1%
C++ 2%
Shell 1.7%
Other 1.4%