1 Star 0 Fork 70

mds.lanruo/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
libvirt-Add-retry-support-for-error-policy.patch 4.65 KB
一键复制 编辑 原始数据 按行查看 历史
From 9ba3e54d2b33e1105f5879fff3656c093337e60a Mon Sep 17 00:00:00 2001
From: Jiahui Cen <[email protected]>
Date: Thu, 25 Feb 2021 18:55:30 +0800
Subject: [PATCH] libvirt: Add 'retry' support for error policy
Introduce error_policy=/rerror_policy='retry' to support
werror=/rerror=retry mechanism in qemu.
Add retry_interval parameter to control the interval between retries.
Add retry_timeout parameter to control the total retry times.
Signed-off-by: Jiahui Cen <[email protected]>
Signed-off-by: Ying Fang <[email protected]>
---
src/conf/domain_conf.c | 25 +++++++++++++++++++++++++
src/conf/domain_conf.h | 3 +++
src/qemu/qemu_command.c | 8 ++++++++
src/qemu/qemu_domain.c | 2 ++
4 files changed, 38 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index dbc3e103ff..5c469cedd0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -355,6 +355,7 @@ VIR_ENUM_IMPL(virDomainDiskErrorPolicy,
"report",
"ignore",
"enospace",
+ "retry",
);
VIR_ENUM_IMPL(virDomainDiskIo,
@@ -10213,6 +10214,30 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
}
VIR_FREE(tmp);
+ def->retry_interval = -1;
+ if ((tmp = virXMLPropString(cur, "retry_interval")) &&
+ ((def->error_policy != VIR_DOMAIN_DISK_ERROR_POLICY_RETRY &&
+ def->rerror_policy != VIR_DOMAIN_DISK_ERROR_POLICY_RETRY) ||
+ (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;
+ }
+ 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) ||
+ (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;
+ }
+ VIR_FREE(tmp);
+
if ((tmp = virXMLPropString(cur, "io")) &&
(def->iomode = virDomainDiskIoTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 16e625331c..86a86d3090 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -396,6 +396,7 @@ typedef enum {
VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
+ VIR_DOMAIN_DISK_ERROR_POLICY_RETRY,
VIR_DOMAIN_DISK_ERROR_POLICY_LAST
} virDomainDiskErrorPolicy;
@@ -561,6 +562,8 @@ struct _virDomainDiskDef {
int cachemode; /* enum virDomainDiskCache */
int error_policy; /* enum virDomainDiskErrorPolicy */
int rerror_policy; /* enum virDomainDiskErrorPolicy */
+ long retry_interval;
+ long retry_timeout;
int iomode; /* enum virDomainDiskIo */
int ioeventfd; /* enum virTristateSwitch */
int event_idx; /* enum virTristateSwitch */
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 315deb5cfd..c3ad041959 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1723,6 +1723,14 @@ qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDefPtr disk,
virBufferAsprintf(buf, ",werror=%s", wpolicy);
if (rpolicy)
virBufferAsprintf(buf, ",rerror=%s", rpolicy);
+ if ((disk->error_policy == VIR_DOMAIN_DISK_ERROR_POLICY_RETRY ||
+ disk->rerror_policy == VIR_DOMAIN_DISK_ERROR_POLICY_RETRY) &&
+ disk->retry_interval >= 0)
+ virBufferAsprintf(buf, ",retry_interval=%ld", disk->retry_interval);
+ if ((disk->error_policy == VIR_DOMAIN_DISK_ERROR_POLICY_RETRY ||
+ disk->rerror_policy == VIR_DOMAIN_DISK_ERROR_POLICY_RETRY) &&
+ disk->retry_timeout >= 0)
+ virBufferAsprintf(buf, ",retry_timeout=%ld", disk->retry_timeout);
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f89ff20a84..58493706a1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -12308,6 +12308,8 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
CHECK_EQ(cachemode, "cache", true);
CHECK_EQ(error_policy, "error_policy", true);
CHECK_EQ(rerror_policy, "rerror_policy", true);
+ CHECK_EQ(retry_interval, "retry_interval", true);
+ CHECK_EQ(retry_timeout, "retry_timeout", true);
CHECK_EQ(iomode, "io", true);
CHECK_EQ(ioeventfd, "ioeventfd", true);
CHECK_EQ(event_idx, "event_idx", true);
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mdslanruo/libvirt.git
[email protected]:mdslanruo/libvirt.git
mdslanruo
libvirt
libvirt
master

搜索帮助