From e1a0ba5580ffb8d9de09885bef23b26d34b691c4 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-event.c       | 8 ++++++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index a1902546bb..7d6117208b 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -4695,6 +4695,7 @@ typedef enum {
     VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0,  /* No action, IO error ignored (Since: 0.8.0) */
     VIR_DOMAIN_EVENT_IO_ERROR_PAUSE,     /* Guest CPUs are paused (Since: 0.8.0) */
     VIR_DOMAIN_EVENT_IO_ERROR_REPORT,    /* IO error reported to guest OS (Since: 0.8.0) */
+    VIR_DOMAIN_EVENT_IO_ERROR_RETRY,     /* Failed IO retried (Since: 6.2.0) */
 
 # ifdef VIR_ENUM_SENTINELS
     VIR_DOMAIN_EVENT_IO_ERROR_LAST /* (Since: 0.9.10) */
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a9133793f6..231a9d8a2b 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -685,7 +685,7 @@ static void qemuMonitorJSONHandleWatchdog(qemuMonitor *mon, virJSONValue *data)
 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-event.c b/tools/virsh-domain-event.c
index 6887c195a0..822d9e1e83 100644
--- a/tools/virsh-domain-event.c
+++ b/tools/virsh-domain-event.c
@@ -397,6 +397,10 @@ virshEventIOErrorPrint(virConnectPtr conn G_GNUC_UNUSED,
         virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2$s (%3$s) report\n"),
                          virDomainGetName(dom), srcPath, devAlias);
         break;
+    case VIR_DOMAIN_EVENT_IO_ERROR_RETRY:
+        virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2$s (%3$s) report\n"),
+                         virDomainGetName(dom), srcPath, devAlias);
+        break;
     case VIR_DOMAIN_EVENT_IO_ERROR_LAST:
     default:
         virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2$s (%3$s) unknown\n"),
@@ -458,6 +462,10 @@ virshEventIOErrorReasonPrint(virConnectPtr conn G_GNUC_UNUSED,
         virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2$s (%3$s) report due to %4$s\n"),
                          virDomainGetName(dom), srcPath, devAlias, reason);
         break;
+    case VIR_DOMAIN_EVENT_IO_ERROR_RETRY:
+        virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2$s (%3$s) report\n"),
+                         virDomainGetName(dom), srcPath, devAlias);
+        break;
     case VIR_DOMAIN_EVENT_IO_ERROR_LAST:
     default:
         virshEventPrintf(opaque, _("event 'io-error' for domain '%1$s': %2$s (%3$s) unknown due to %4$s\n"),
-- 
2.27.0

