From 80dd3606909ce1de5b6ecc50a512ecd219874ef7 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 18 Mar 2021 15:14:20 +0800 Subject: [PATCH] libvirt/conf: Set default values of retry fileds Currently the default values of retry_interval and retry_timeout are set to -1, when 'driver' option exists without retry fileds. It conflicts with the default values when the 'driver' option does not exist. So let's set default values of retry_interval and retry_timeout to 0 when retry policy is not enabled. Signed-off-by: Jiahui Cen --- ...f-Set-default-values-of-retry-fileds.patch | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 libvirt-conf-Set-default-values-of-retry-fileds.patch diff --git a/libvirt-conf-Set-default-values-of-retry-fileds.patch b/libvirt-conf-Set-default-values-of-retry-fileds.patch new file mode 100644 index 0000000..1f1165d --- /dev/null +++ b/libvirt-conf-Set-default-values-of-retry-fileds.patch @@ -0,0 +1,87 @@ +From 285179a9e8440b32175a0793172b81cf6fcdfa4c Mon Sep 17 00:00:00 2001 +From: Jiahui Cen +Date: Thu, 18 Mar 2021 15:14:20 +0800 +Subject: [PATCH] libvirt/conf: Set default values of retry fileds + +Currently the default values of retry_interval and retry_timeout are set +to -1, when 'driver' option exists without retry fileds. It conflicts +with the default values when the 'driver' option does not exist. + +So let's set default values of retry_interval and retry_timeout to 0 when +retry policy is not enabled. + +Signed-off-by: Jiahui Cen +--- + src/conf/domain_conf.c | 18 ++++++++++++------ + src/conf/domain_conf.h | 3 +++ + 2 files changed, 15 insertions(+), 6 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 1e4ed87978..2b7eee17f0 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -10185,6 +10185,7 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def, + xmlNodePtr cur) + { + g_autofree char *tmp = NULL; ++ bool retry_enabled = false; + + def->driverName = virXMLPropString(cur, "name"); + +@@ -10213,28 +10214,33 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def, + } + VIR_FREE(tmp); + +- def->retry_interval = -1; ++ retry_enabled = (def->error_policy == VIR_DOMAIN_DISK_ERROR_POLICY_RETRY) || ++ (def->rerror_policy == VIR_DOMAIN_DISK_ERROR_POLICY_RETRY); ++ + if ((tmp = virXMLPropString(cur, "retry_interval")) && +- ((def->error_policy != VIR_DOMAIN_DISK_ERROR_POLICY_RETRY && +- def->rerror_policy != VIR_DOMAIN_DISK_ERROR_POLICY_RETRY) || ++ (!retry_enabled || + (virStrToLong_l(tmp, NULL, 10, &def->retry_interval) < 0) || + (def->retry_interval < 0))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk retry interval '%s'"), tmp); + return -1; + } ++ if (retry_enabled && !tmp) { ++ def->retry_interval = VIR_DOMAIN_DISK_DEFAULT_RETRY_INTERVAL; ++ } + VIR_FREE(tmp); + +- def->retry_timeout = -1; + if ((tmp = virXMLPropString(cur, "retry_timeout")) && +- ((def->error_policy != VIR_DOMAIN_DISK_ERROR_POLICY_RETRY && +- def->rerror_policy != VIR_DOMAIN_DISK_ERROR_POLICY_RETRY) || ++ (!retry_enabled || + (virStrToLong_l(tmp, NULL, 10, &def->retry_timeout) < 0) || + (def->retry_timeout < 0))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk retry interval '%s'"), tmp); + return -1; + } ++ if (retry_enabled && !tmp) { ++ def->retry_timeout = VIR_DOMAIN_DISK_DEFAULT_RETRY_TIMEOUT; ++ } + VIR_FREE(tmp); + + if ((tmp = virXMLPropString(cur, "io")) && +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 97c301ebf1..bebb9f46fb 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -523,6 +523,9 @@ typedef enum { + } virDomainMemoryAllocation; + + ++#define VIR_DOMAIN_DISK_DEFAULT_RETRY_INTERVAL 1000 ++#define VIR_DOMAIN_DISK_DEFAULT_RETRY_TIMEOUT 0 ++ + /* Stores the virtual disk configuration */ + struct _virDomainDiskDef { + virStorageSourcePtr src; /* non-NULL. XXX Allow NULL for empty cdrom? */ +-- +2.27.0 +