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