From 6a7628c72ee6374e37de5b72a7f4d37be196ba7a Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 18 Mar 2021 19:45:11 +0800 Subject: [PATCH 1/3] block: Add sanity check when setting retry parameters Add sanity check when setting retry parameters to avoid invalid retry configuration. Signed-off-by: Jiahui Cen --- ...-check-when-setting-retry-parameters.patch | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 block-Add-sanity-check-when-setting-retry-parameters.patch diff --git a/block-Add-sanity-check-when-setting-retry-parameters.patch b/block-Add-sanity-check-when-setting-retry-parameters.patch new file mode 100644 index 00000000..0af7b6e1 --- /dev/null +++ b/block-Add-sanity-check-when-setting-retry-parameters.patch @@ -0,0 +1,118 @@ +From 6642b2c6fcad2e1099c61b56f4fe78f3180d005e Mon Sep 17 00:00:00 2001 +From: Jiahui Cen +Date: Thu, 18 Mar 2021 19:45:11 +0800 +Subject: [PATCH] block: Add sanity check when setting retry parameters + +Add sanity check when setting retry parameters to avoid invalid retry +configuration. + +Signed-off-by: Jiahui Cen +--- + hw/core/qdev-properties.c | 45 ++++++++++++++++++++++++++++++++++++ + include/hw/block/block.h | 7 +++--- + include/hw/qdev-properties.h | 8 +++++++ + 3 files changed, 57 insertions(+), 3 deletions(-) + +diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c +index 709f9e0f9d..2601091f8f 100644 +--- a/hw/core/qdev-properties.c ++++ b/hw/core/qdev-properties.c +@@ -628,6 +628,51 @@ const PropertyInfo qdev_prop_blockdev_on_error = { + .set_default_value = set_default_value_enum, + }; + ++static void set_retry_time(Object *obj, Visitor *v, const char *name, ++ void *opaque, Error **errp) ++{ ++ DeviceState *dev = DEVICE(obj); ++ Property *prop = opaque; ++ int64_t value, *ptr = qdev_get_prop_ptr(dev, prop); ++ Error *local_err = NULL; ++ ++ if (dev->realized) { ++ qdev_prop_set_after_realize(dev, name, errp); ++ return; ++ } ++ ++ visit_type_int64(v, name, &value, &local_err); ++ if (local_err) { ++ error_propagate(errp, local_err); ++ return; ++ } ++ ++ /* value should not be negative */ ++ if (value < 0) { ++ error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, ++ dev->id ? : "", name, (int64_t)value, 0L, LONG_MAX); ++ return; ++ } ++ ++ *ptr = value; ++} ++ ++const PropertyInfo qdev_prop_blockdev_retry_interval = { ++ .name = "BlockdevRetryInterval", ++ .description = "Interval for retry error handling policy", ++ .get = get_int64, ++ .set = set_retry_time, ++ .set_default_value = set_default_value_int, ++}; ++ ++const PropertyInfo qdev_prop_blockdev_retry_timeout = { ++ .name = "BlockdevRetryTimeout", ++ .description = "Timeout for retry error handling policy", ++ .get = get_int64, ++ .set = set_retry_time, ++ .set_default_value = set_default_value_int, ++}; ++ + /* --- BIOS CHS translation */ + + QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int)); +diff --git a/include/hw/block/block.h b/include/hw/block/block.h +index d12603aabd..c5276fec0d 100644 +--- a/include/hw/block/block.h ++++ b/include/hw/block/block.h +@@ -74,9 +74,10 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) + BLOCKDEV_ON_ERROR_AUTO), \ + DEFINE_PROP_BLOCKDEV_ON_ERROR("werror", _state, _conf.werror, \ + BLOCKDEV_ON_ERROR_AUTO), \ +- DEFINE_PROP_INT64("retry_interval", _state, _conf.retry_interval, \ +- -1), \ +- DEFINE_PROP_INT64("retry_timeout", _state, _conf.retry_timeout, -1) ++ DEFINE_PROP_BLOCKDEV_RETRY_INTERVAL("retry_interval", _state, \ ++ _conf.retry_interval, 1000), \ ++ DEFINE_PROP_BLOCKDEV_RETRY_TIMEOUT("retry_timeout", _state, \ ++ _conf.retry_timeout, 0) + + /* Backend access helpers */ + +diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h +index a22a532eb8..d7742be3bc 100644 +--- a/include/hw/qdev-properties.h ++++ b/include/hw/qdev-properties.h +@@ -26,6 +26,8 @@ extern const PropertyInfo qdev_prop_on_off_auto; + extern const PropertyInfo qdev_prop_compress_method; + extern const PropertyInfo qdev_prop_losttickpolicy; + extern const PropertyInfo qdev_prop_blockdev_on_error; ++extern const PropertyInfo qdev_prop_blockdev_retry_interval; ++extern const PropertyInfo qdev_prop_blockdev_retry_timeout; + extern const PropertyInfo qdev_prop_bios_chs_trans; + extern const PropertyInfo qdev_prop_fdc_drive_type; + extern const PropertyInfo qdev_prop_drive; +@@ -215,6 +217,12 @@ extern const PropertyInfo qdev_prop_pcie_link_width; + #define DEFINE_PROP_BLOCKDEV_ON_ERROR(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_blockdev_on_error, \ + BlockdevOnError) ++#define DEFINE_PROP_BLOCKDEV_RETRY_INTERVAL(_n, _s, _f, _d) \ ++ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_blockdev_retry_interval, \ ++ int64_t) ++#define DEFINE_PROP_BLOCKDEV_RETRY_TIMEOUT(_n, _s, _f, _d) \ ++ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_blockdev_retry_timeout, \ ++ int64_t) + #define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int) + #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \ +-- +2.27.0 + -- Gitee From 7671afd0a84451fcfe45e653cdd0f7c0fd072e80 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 18 Mar 2021 22:02:16 +0800 Subject: [PATCH 2/3] spec: Update patch and changelog with !87 block: Add sanity check when setting retry parameters !87 block: Add sanity check when setting retry parameters Signed-off-by: Chen Qun --- qemu.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu.spec b/qemu.spec index 94dc4703..f540ae28 100644 --- a/qemu.spec +++ b/qemu.spec @@ -315,6 +315,7 @@ Patch0302: migration-fix-memory-leak-in-qmp_migrate_set_paramet.patch Patch0303: migration-tls-fix-inverted-semantics-in-multifd_chan.patch Patch0304: migration-tls-add-error-handling-in-multifd_tls_hand.patch Patch0305: net-vmxnet3-validate-configuration-values-during-act.patch +Patch0306: block-Add-sanity-check-when-setting-retry-parameters.patch BuildRequires: flex BuildRequires: bison @@ -704,6 +705,9 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Thu Mar 18 2021 Chen Qun +- block: Add sanity check when setting retry parameters + * Wed Mar 17 2021 Huawei Technologies Co., Ltd - qemu.spec: enable strip for qemu-block-rbd.so and qemu-block-ssh.so -- Gitee From ce2f9ed549d30da3e0a019063eca13b0d9a60905 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 18 Mar 2021 22:02:41 +0800 Subject: [PATCH 3/3] spec: Update release version with !87 increase release verison by one Signed-off-by: Chen Qun --- qemu.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu.spec b/qemu.spec index f540ae28..6cf205a2 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,6 +1,6 @@ Name: qemu Version: 4.1.0 -Release: 52 +Release: 53 Epoch: 2 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY-SA-4.0 -- Gitee