See the commit message of patch 3 for the why and how.
Old relevant discussions: October 2014: '[PATCH RFC 0/2] block: Warn on insecure format probing' http://lists.nongnu.org/archive/html/qemu-devel/2014-10/msg03440.html August 2014: '[PATCH 0/3] vpc: support probing of fixed size images' https://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg02456.html July 2010: 'Make default invocation of block drivers safer (v3)' http://patchwork.ozlabs.org/patch/58980/ Kevin Wolf (3): block: Read only one sector for format probing raw: Prohibit dangerous writes for probed images qemu-iotests: Test writing non-raw image headers to raw image Markus Armbruster (1): block: Factor bdrv_probe_all() out of find_image_format() block.c | 48 ++++++++++++----- block/raw_bsd.c | 46 +++++++++++++++- include/block/block_int.h | 5 ++ tests/qemu-iotests/109 | 100 +++++++++++++++++++++++++++++++++++ tests/qemu-iotests/109.out | 128 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 6 files changed, 313 insertions(+), 15 deletions(-) create mode 100755 tests/qemu-iotests/109 create mode 100644 tests/qemu-iotests/109.out -- 1.8.3.1