|
|
958e1b |
From 8a53023561ad1fdc87104ef15494803ae00e069b Mon Sep 17 00:00:00 2001
|
|
|
958e1b |
From: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
Date: Mon, 14 Jul 2014 01:05:21 -0500
|
|
|
958e1b |
Subject: [CHANGE 21/29] block: Improve driver whitelist checks
|
|
|
958e1b |
To: rhvirt-patches@redhat.com,
|
|
|
958e1b |
jen@redhat.com
|
|
|
958e1b |
|
|
|
958e1b |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
Message-id: <1405299921-2619-1-git-send-email-famz@redhat.com>
|
|
|
958e1b |
Patchwork-id: 59871
|
|
|
958e1b |
O-Subject: [RHEL-7 qemu-kvm PATCH] block: Improve driver whitelist checks
|
|
|
958e1b |
Bugzilla: 999789
|
|
|
958e1b |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
958e1b |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
958e1b |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
958e1b |
|
|
|
958e1b |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
958e1b |
|
|
|
958e1b |
Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=7695744
|
|
|
958e1b |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=999789
|
|
|
958e1b |
|
|
|
958e1b |
The main intent of this patch is to consolidate the whitelist checks to
|
|
|
958e1b |
a single point in the code instead of spreading it everywhere. This adds
|
|
|
958e1b |
a nicer error message for read-only whitelisting, too, in places where
|
|
|
958e1b |
it was still missing.
|
|
|
958e1b |
|
|
|
958e1b |
The patch also contains a bonus bug fix: By finding the format first in
|
|
|
958e1b |
bdrv_open() and then independently checking against the whitelist only
|
|
|
958e1b |
later, we avoid the case that use of a non-whitelisted format results in
|
|
|
958e1b |
probing rather than an error message. Previously, this could happen when
|
|
|
958e1b |
using the driver=... option.
|
|
|
958e1b |
|
|
|
958e1b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
958e1b |
Reviewed-by: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
(cherry picked from commit 8f94a6e40e46cbc8e8014da825d25824b1803b34)
|
|
|
958e1b |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
Signed-off-by: jen <jen@redhat.com>
|
|
|
958e1b |
|
|
|
958e1b |
Conflicts:
|
|
|
958e1b |
blockdev.c
|
|
|
958e1b |
Error report is different.
|
|
|
958e1b |
---
|
|
|
958e1b |
block.c | 10 +++++++---
|
|
|
958e1b |
blockdev.c | 2 +-
|
|
|
958e1b |
2 files changed, 8 insertions(+), 4 deletions(-)
|
|
|
958e1b |
|
|
|
958e1b |
Signed-off-by: jen <jen@redhat.com>
|
|
|
958e1b |
---
|
|
|
958e1b |
block.c | 10 +++++++---
|
|
|
958e1b |
blockdev.c | 2 +-
|
|
|
958e1b |
2 files changed, 8 insertions(+), 4 deletions(-)
|
|
|
958e1b |
|
|
|
958e1b |
diff --git a/block.c b/block.c
|
|
|
958e1b |
index 43e325e..a2e95f6 100644
|
|
|
958e1b |
--- a/block.c
|
|
|
958e1b |
+++ b/block.c
|
|
|
958e1b |
@@ -786,7 +786,11 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
|
|
|
958e1b |
bs->read_only = !(open_flags & BDRV_O_RDWR);
|
|
|
958e1b |
|
|
|
958e1b |
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
|
|
|
958e1b |
- error_setg(errp, "Driver '%s' is not whitelisted", drv->format_name);
|
|
|
958e1b |
+ error_setg(errp,
|
|
|
958e1b |
+ !bs->read_only && bdrv_is_whitelisted(drv, true)
|
|
|
958e1b |
+ ? "Driver '%s' can only be used for read-only devices"
|
|
|
958e1b |
+ : "Driver '%s' is not whitelisted",
|
|
|
958e1b |
+ drv->format_name);
|
|
|
958e1b |
return -ENOTSUP;
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
@@ -908,7 +912,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
|
|
|
958e1b |
/* Find the right block driver */
|
|
|
958e1b |
drvname = qdict_get_try_str(options, "driver");
|
|
|
958e1b |
if (drvname) {
|
|
|
958e1b |
- drv = bdrv_find_whitelisted_format(drvname, !(flags & BDRV_O_RDWR));
|
|
|
958e1b |
+ drv = bdrv_find_format(drvname);
|
|
|
958e1b |
if (!drv) {
|
|
|
958e1b |
error_setg(errp, "Unknown driver '%s'", drvname);
|
|
|
958e1b |
}
|
|
|
958e1b |
@@ -1177,7 +1181,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
|
|
|
958e1b |
/* Find the right image format driver */
|
|
|
958e1b |
drvname = qdict_get_try_str(options, "driver");
|
|
|
958e1b |
if (drvname) {
|
|
|
958e1b |
- drv = bdrv_find_whitelisted_format(drvname, !(flags & BDRV_O_RDWR));
|
|
|
958e1b |
+ drv = bdrv_find_format(drvname);
|
|
|
958e1b |
qdict_del(options, "driver");
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
diff --git a/blockdev.c b/blockdev.c
|
|
|
958e1b |
index e51203c..aa5d0a6 100644
|
|
|
958e1b |
--- a/blockdev.c
|
|
|
958e1b |
+++ b/blockdev.c
|
|
|
958e1b |
@@ -414,7 +414,7 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
958e1b |
goto early_err;
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
- drv = bdrv_find_whitelisted_format(buf, ro);
|
|
|
958e1b |
+ drv = bdrv_find_format(buf);
|
|
|
958e1b |
if (!drv) {
|
|
|
958e1b |
error_setg(errp, "'%s' invalid format", buf);
|
|
|
958e1b |
goto early_err;
|
|
|
958e1b |
--
|
|
|
958e1b |
1.9.3
|
|
|
958e1b |
|