From: @kuhnchen18 Reviewed-by: @zhanghailiang_lucky Signed-off-by: @zhanghailiang_lucky
This commit is contained in:
commit
e9fa45ed60
119
libvirt-Add-retry-support-for-error-policy.patch
Normal file
119
libvirt-Add-retry-support-for-error-policy.patch
Normal file
@ -0,0 +1,119 @@
|
||||
From b70fa44fc68c2c845bb6a7e82d6798268b1150ce Mon Sep 17 00:00:00 2001
|
||||
From: Jiahui Cen <cenjiahui@huawei.com>
|
||||
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 <cenjiahui@huawei.com>
|
||||
Signed-off-by: Ying Fang <fangying1@huawei.com>
|
||||
---
|
||||
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 cf93a591f4..1e4ed87978 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,
|
||||
@@ -10212,6 +10213,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 33875d942f..97c301ebf1 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 2f65b8ddc6..e901ea0534 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 dd48b6fff3..daab7ebec3 100644
|
||||
--- a/src/qemu/qemu_domain.c
|
||||
+++ b/src/qemu/qemu_domain.c
|
||||
@@ -12299,6 +12299,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
|
||||
|
||||
87
libvirt-conf-Set-default-values-of-retry-fileds.patch
Normal file
87
libvirt-conf-Set-default-values-of-retry-fileds.patch
Normal file
@ -0,0 +1,87 @@
|
||||
From 285179a9e8440b32175a0793172b81cf6fcdfa4c Mon Sep 17 00:00:00 2001
|
||||
From: Jiahui Cen <cenjiahui@huawei.com>
|
||||
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 <cenjiahui@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
10
libvirt.spec
10
libvirt.spec
@ -99,7 +99,7 @@
|
||||
Summary: Library providing a simple virtualization API
|
||||
Name: libvirt
|
||||
Version: 6.2.0
|
||||
Release: 10
|
||||
Release: 11
|
||||
License: LGPLv2+
|
||||
URL: https://libvirt.org/
|
||||
|
||||
@ -137,6 +137,9 @@ Patch0026: rpc-require-write-acl-for-guest-agent-in-virDomainIn.patch
|
||||
Patch0027: qemu-agent-set-ifname-to-NULL-after-freeing.patch
|
||||
Patch0028: util-Move-virIsDevMapperDevice-to-virdevmapper.c.patch
|
||||
Patch0029: virdevmapper-Don-t-use-libdevmapper-to-obtain-depend.patch
|
||||
Patch0030: libvirt-Add-retry-support-for-error-policy.patch
|
||||
Patch0031: qemu-Support-retry-BLOCK_IO_ERROR-event.patch
|
||||
Patch0032: libvirt-conf-Set-default-values-of-retry-fileds.patch
|
||||
|
||||
Requires: libvirt-daemon = %{version}-%{release}
|
||||
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
||||
@ -1869,6 +1872,11 @@ exit 0
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Apr 23 2021 Chen Qun <kuhn.chenqun@huawei.com>
|
||||
- libvirt: Add 'retry' support for error policy
|
||||
- qemu: Support 'retry' BLOCK_IO_ERROR event.
|
||||
- libvirt/conf: Set default values of retry fileds
|
||||
|
||||
* Wed Jan 20 2021 Huawei Technologies Co., Ltd <alex.chen@huawei.com>
|
||||
- util: Move virIsDevMapperDevice() to virdevmapper.c
|
||||
- virdevmapper: Don't use libdevmapper to obtain dependencies
|
||||
|
||||
57
qemu-Support-retry-BLOCK_IO_ERROR-event.patch
Normal file
57
qemu-Support-retry-BLOCK_IO_ERROR-event.patch
Normal file
@ -0,0 +1,57 @@
|
||||
From 0b8b52e43ba34993c4b2781db477c4131f3abd30 Mon Sep 17 00:00:00 2001
|
||||
From: Jiahui Cen <cenjiahui@huawei.com>
|
||||
Date: Thu, 25 Feb 2021 18:55:31 +0800
|
||||
Subject: [PATCH] qemu: Support 'retry' BLOCK_IO_ERROR event.
|
||||
|
||||
Accept BLOCK_IO_ERROR event with action='retry' from qemu.
|
||||
|
||||
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
|
||||
Signed-off-by: Ying Fang <fangying1@huawei.com>
|
||||
---
|
||||
include/libvirt/libvirt-domain.h | 1 +
|
||||
src/qemu/qemu_monitor_json.c | 2 +-
|
||||
tools/virsh-domain.c | 3 ++-
|
||||
3 files changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
|
||||
index b440818ec2..90cb652db1 100644
|
||||
--- a/include/libvirt/libvirt-domain.h
|
||||
+++ b/include/libvirt/libvirt-domain.h
|
||||
@@ -3701,6 +3701,7 @@ typedef enum {
|
||||
VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0, /* No action, IO error ignored */
|
||||
VIR_DOMAIN_EVENT_IO_ERROR_PAUSE, /* Guest CPUs are paused */
|
||||
VIR_DOMAIN_EVENT_IO_ERROR_REPORT, /* IO error reported to guest OS */
|
||||
+ VIR_DOMAIN_EVENT_IO_ERROR_RETRY, /* Failed IO retried */
|
||||
|
||||
# ifdef VIR_ENUM_SENTINELS
|
||||
VIR_DOMAIN_EVENT_IO_ERROR_LAST
|
||||
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
|
||||
index 619717eae5..ef25764a98 100644
|
||||
--- a/src/qemu/qemu_monitor_json.c
|
||||
+++ b/src/qemu/qemu_monitor_json.c
|
||||
@@ -898,7 +898,7 @@ static void qemuMonitorJSONHandleWatchdog(qemuMonitorPtr mon, virJSONValuePtr da
|
||||
VIR_ENUM_DECL(qemuMonitorIOErrorAction);
|
||||
VIR_ENUM_IMPL(qemuMonitorIOErrorAction,
|
||||
VIR_DOMAIN_EVENT_IO_ERROR_LAST,
|
||||
- "ignore", "stop", "report",
|
||||
+ "ignore", "stop", "report", "retry",
|
||||
);
|
||||
|
||||
|
||||
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
|
||||
index 0a623086a4..65d5c831ec 100644
|
||||
--- a/tools/virsh-domain.c
|
||||
+++ b/tools/virsh-domain.c
|
||||
@@ -13065,7 +13065,8 @@ VIR_ENUM_IMPL(virshDomainEventIOError,
|
||||
VIR_DOMAIN_EVENT_IO_ERROR_LAST,
|
||||
N_("none"),
|
||||
N_("pause"),
|
||||
- N_("report"));
|
||||
+ N_("report"),
|
||||
+ N_("retry"));
|
||||
|
||||
static const char *
|
||||
virshDomainEventIOErrorToString(int action)
|
||||
--
|
||||
2.27.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user