@@ -893,6 +893,7 @@ static BlockDriver bdrv_blkdebug = {
.protocol_name = "blkdebug",
.instance_size = sizeof(BDRVBlkdebugState),
.is_filter = true,
+ .runtime_opts = &runtime_opts,
.bdrv_parse_filename = blkdebug_parse_filename,
.bdrv_file_open = blkdebug_open,
@@ -696,6 +696,7 @@ BlockDriver bdrv_crypto_luks = {
.bdrv_co_create_opts = block_crypto_co_create_opts_luks,
.bdrv_truncate = block_crypto_truncate,
.create_opts = &block_crypto_create_opts_luks,
+ .runtime_opts = &block_crypto_runtime_opts_luks,
.bdrv_reopen_prepare = block_crypto_reopen_prepare,
.bdrv_refresh_limits = block_crypto_refresh_limits,
@@ -429,6 +429,8 @@ static QemuOptsList raw_runtime_opts = {
},
};
+static const char *const mutable_opts[] = { "x-check-cache-dropped", NULL };
+
static int raw_open_common(BlockDriverState *bs, QDict *options,
int bdrv_flags, int open_flags, Error **errp)
{
@@ -2582,6 +2584,8 @@ BlockDriver bdrv_file = {
.format_name = "file",
.protocol_name = "file",
.instance_size = sizeof(BDRVRawState),
+ .runtime_opts = &raw_runtime_opts,
+ .mutable_opts = mutable_opts,
.bdrv_needs_filename = true,
.bdrv_probe = NULL, /* no probe for protocols */
.bdrv_parse_filename = raw_parse_filename,
@@ -3064,6 +3068,8 @@ static BlockDriver bdrv_host_device = {
.format_name = "host_device",
.protocol_name = "host_device",
.instance_size = sizeof(BDRVRawState),
+ .runtime_opts = &raw_runtime_opts,
+ .mutable_opts = mutable_opts,
.bdrv_needs_filename = true,
.bdrv_probe_device = hdev_probe_device,
.bdrv_parse_filename = hdev_parse_filename,
@@ -3189,6 +3195,8 @@ static BlockDriver bdrv_host_cdrom = {
.format_name = "host_cdrom",
.protocol_name = "host_cdrom",
.instance_size = sizeof(BDRVRawState),
+ .runtime_opts = &raw_runtime_opts,
+ .mutable_opts = mutable_opts,
.bdrv_needs_filename = true,
.bdrv_probe_device = cdrom_probe_device,
.bdrv_parse_filename = cdrom_parse_filename,
@@ -3321,6 +3329,8 @@ static BlockDriver bdrv_host_cdrom = {
.format_name = "host_cdrom",
.protocol_name = "host_cdrom",
.instance_size = sizeof(BDRVRawState),
+ .runtime_opts = &raw_runtime_opts,
+ .mutable_opts = mutable_opts,
.bdrv_needs_filename = true,
.bdrv_probe_device = cdrom_probe_device,
.bdrv_parse_filename = cdrom_parse_filename,
@@ -2443,6 +2443,7 @@ static BlockDriver bdrv_iscsi = {
.bdrv_close = iscsi_close,
.bdrv_co_create_opts = iscsi_co_create_opts,
.create_opts = &iscsi_create_opts,
+ .runtime_opts = &runtime_opts,
.bdrv_reopen_prepare = iscsi_reopen_prepare,
.bdrv_reopen_commit = iscsi_reopen_commit,
.bdrv_co_invalidate_cache = iscsi_co_invalidate_cache,
@@ -2480,6 +2481,7 @@ static BlockDriver bdrv_iser = {
.bdrv_close = iscsi_close,
.bdrv_co_create_opts = iscsi_co_create_opts,
.create_opts = &iscsi_create_opts,
+ .runtime_opts = &runtime_opts,
.bdrv_reopen_prepare = iscsi_reopen_prepare,
.bdrv_reopen_commit = iscsi_reopen_commit,
.bdrv_co_invalidate_cache = iscsi_co_invalidate_cache,
@@ -260,6 +260,7 @@ static BlockDriver bdrv_null_co = {
.format_name = "null-co",
.protocol_name = "null-co",
.instance_size = sizeof(BDRVNullState),
+ .runtime_opts = &runtime_opts,
.bdrv_file_open = null_file_open,
.bdrv_parse_filename = null_co_parse_filename,
@@ -280,6 +281,7 @@ static BlockDriver bdrv_null_aio = {
.format_name = "null-aio",
.protocol_name = "null-aio",
.instance_size = sizeof(BDRVNullState),
+ .runtime_opts = &runtime_opts,
.bdrv_file_open = null_file_open,
.bdrv_parse_filename = null_aio_parse_filename,
@@ -1158,6 +1158,7 @@ static BlockDriver bdrv_nvme = {
.format_name = "nvme",
.protocol_name = "nvme",
.instance_size = sizeof(BDRVNVMeState),
+ .runtime_opts = &runtime_opts,
.bdrv_parse_filename = nvme_parse_filename,
.bdrv_file_open = nvme_file_open,
@@ -1188,6 +1188,7 @@ static QemuOptsList qcow_create_opts = {
static BlockDriver bdrv_qcow = {
.format_name = "qcow",
.instance_size = sizeof(BDRVQcowState),
+ .runtime_opts = &qcow_runtime_opts,
.bdrv_probe = qcow_probe,
.bdrv_open = qcow_open,
.bdrv_close = qcow_close,
@@ -1160,6 +1160,7 @@ static QemuOptsList qemu_rbd_create_opts = {
static BlockDriver bdrv_rbd = {
.format_name = "rbd",
.instance_size = sizeof(BDRVRBDState),
+ .runtime_opts = &runtime_opts,
.bdrv_parse_filename = qemu_rbd_parse_filename,
.bdrv_refresh_limits = qemu_rbd_refresh_limits,
.bdrv_file_open = qemu_rbd_open,
@@ -3301,6 +3301,7 @@ static BlockDriver bdrv_sheepdog_tcp = {
.bdrv_attach_aio_context = sd_attach_aio_context,
.create_opts = &sd_create_opts,
+ .runtime_opts = &runtime_opts,
};
static BlockDriver bdrv_sheepdog_unix = {
@@ -3338,6 +3339,7 @@ static BlockDriver bdrv_sheepdog_unix = {
.bdrv_attach_aio_context = sd_attach_aio_context,
.create_opts = &sd_create_opts,
+ .runtime_opts = &runtime_opts,
};
static void bdrv_sheepdog_init(void)
@@ -1234,6 +1234,7 @@ static BlockDriver bdrv_vpc = {
.bdrv_get_info = vpc_get_info,
.create_opts = &vpc_create_opts,
+ .runtime_opts = &vpc_runtime_opts,
.bdrv_has_zero_init = vpc_has_zero_init,
};
@@ -342,6 +342,10 @@ struct BlockDriver {
/* List of options for creating images, terminated by name == NULL */
QemuOptsList *create_opts;
+ /* Runtime options for a block device, terminated by name == NULL */
+ QemuOptsList *runtime_opts;
+ /* Names of the runtime options that can be modified, NULL-terminated */
+ const char *const *mutable_opts;
/*
* Returns 0 for completed check, -errno for internal errors.
This patch adds two new fields to BlockDriver: - runtime_opts: list of runtime options for a particular block driver. We'll use this list later to detect what options are missing when we try to reopen a block device. - mutable_opts: names of the runtime options that can be modified after a block device has been added. This way an option can not be changed unless we explicitly allow it. This also sets runtime_opts (and mutable_opts where appropriate) in all drivers that allow reopening. Most of those drivers don't actually support changing any of their options. If the user specifies a new value for an option that can't be changed then we already detect that and forbid it (in bdrv_reopen_prepare()). But if the user omits an option in order to try to reset it to its default value we need to detect that, so we'll use these two new fields for that. Signed-off-by: Alberto Garcia <berto@igalia.com> --- block/blkdebug.c | 1 + block/crypto.c | 1 + block/file-posix.c | 10 ++++++++++ block/iscsi.c | 2 ++ block/null.c | 2 ++ block/nvme.c | 1 + block/qcow.c | 1 + block/rbd.c | 1 + block/sheepdog.c | 2 ++ block/vpc.c | 1 + include/block/block_int.h | 4 ++++ 11 files changed, 26 insertions(+)