Configurable block format whitelist

We have code for a quite a few block formats.  While I trust that all
of these formats are useful at least for some people in some
circumstances, some of them are of a kind that friends don't let
friends use in production.

This patch provides an optional block format whitelist, default off.
If a whitelist is configured with --block-drv-whitelist, QEMU proper
can use only whitelisted formats.  Other programs, like qemu-img, are
not affected.

Drivers for formats off the whitelist still participate in format
probing, to ensure all programs probe exactly the same.  Without that,
QEMU proper would be prone to treat images with a format off the
whitelist as raw when the image's format is probed.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Markus Armbruster 2009-10-27 18:41:44 +01:00 committed by Anthony Liguori
parent 39a51dfda8
commit eb852011ab
7 changed files with 58 additions and 5 deletions

View file

@ -630,7 +630,8 @@ static int blk_init(struct XenDevice *xendev)
blkdev->bs = bdrv_new(blkdev->dev);
if (blkdev->bs) {
if (bdrv_open2(blkdev->bs, blkdev->filename, qflags,
bdrv_find_format(blkdev->fileproto)) != 0) {
bdrv_find_whitelisted_format(blkdev->fileproto))
!= 0) {
bdrv_delete(blkdev->bs);
blkdev->bs = NULL;
}