Skip to contentSkip to conversation

Containing AER unrecoverable errors

PATCH Superseded Venu Busireddy 3 participants 6 messages Mar 13, 2018 – Mar 16, 2018

lore
Share & tools
lore
#0 lore raw

v5 cover Containing AER unrecoverable errors

This patch set is part of a set of patches that together allow containment of unrecoverable AER errors from PCIe devices assigned to guests in passthrough mode. The containment is achieved by forcibly removing the erring PCIe device from the guest.

The original xen-pciback patch corresponding to this patch set is:
https://lists.xen.org/archives/html/xen-devel/2017-06/msg03274.html.
It will be reposted after this patch set is accepted.

Changes in v5:
* v4 worked only in the case of guests created using 'xl' command. Enhanced the fix to work for guests created using libvirt too.

Changes in v4:
* Made the following changes suggested by Wei Liu.
- Combine multiple LIBXL_HAVE_* definitions into one.
- Use libxl__calloc() instead of malloc().

Changes in v3:
* Made the following changes suggested by Wei Liu.
- Added LIBXL_HAVE macros to libxl.h.
- Don't hard-code dom0's domid to 0. Instead, use libxl__get_domid().
- Corrected comments.
* Made the following changes based on comments from Ian Jackson.
- Got rid of the global variable aer_watch.
- Added documentation (comments in code) for the new API calls.
- Removed the unnecessary writes to xenstore.

Changes in v2:
- Instead of killing the guest and hiding the device, forcibly remove the device from the guest.

Venu Busireddy (2):
libxl: Implement the handler to handle unrecoverable AER errors
xl: Register the AER event handler that handles AER errors

 tools/libxl/libxl.h          |   7 +++
 tools/libxl/libxl_create.c   |  11 +++-
 tools/libxl/libxl_domain.c   |   1 +
 tools/libxl/libxl_event.h    |   7 +++
 tools/libxl/libxl_internal.h |   8 +++
 tools/libxl/libxl_pci.c      | 123 +++++++++++++++++++++++++++++++++++++++++++
 tools/xl/xl_vmcontrol.c      |  14 ++++-
 7 files changed, 168 insertions(+), 3 deletions(-)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#1 lore raw

PATCH v5 1/2 libxl: Implement the handler to handle unrecoverable AER errors

Implement the callback function to handle unrecoverable AER errors, and also the public APIs that can be used to register/unregister the handler. When an AER error occurs, the handler will forcibly remove the erring PCIe device from the guest.

---
 tools/libxl/libxl.h          |   7 +++
 tools/libxl/libxl_event.h    |   7 +++
 tools/libxl/libxl_internal.h |   8 +++
 tools/libxl/libxl_pci.c      | 123 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 145 insertions(+)
tools/libxl/libxl.h +7 -0
index eca0ea2c50..99a3c8ae1f 100644
@@ -1120,6 +1120,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src);
  */
 #define LIBXL_HAVE_PV_SHIM 1
 
+/* LIBXL_HAVE_AER_EVENTS_HANDLER
+ *
+ * If this is defined, libxl has the library functions called
+ * libxl_reg_aer_events_handler and libxl_unreg_aer_events_handler.
+ */
+#define LIBXL_HAVE_AER_EVENTS_HANDLER 1
+
 typedef char **libxl_string_list;
 void libxl_string_list_dispose(libxl_string_list *sl);
 int libxl_string_list_length(const libxl_string_list *sl);
tools/libxl/libxl_event.h +7 -0
index 1ea789e231..63c29ae800 100644
@@ -184,6 +184,13 @@ void libxl_evdisable_domain_death(libxl_ctx *ctx, libxl_evgen_domain_death*);
    * may generate only a DEATH event.
    */
 
+typedef struct libxl__aer_watch libxl_aer_watch;
+int libxl_reg_aer_events_handler(libxl_ctx *, uint32_t);
+  /*
+   * Registers a handler to handle the occurrence of unrecoverable AER errors.
+   */
+void libxl_unreg_aer_events_handler(libxl_ctx *, uint32_t);
+
 typedef struct libxl__evgen_disk_eject libxl_evgen_disk_eject;
 int libxl_evenable_disk_eject(libxl_ctx *ctx, uint32_t domid, const char *vdev,
                         libxl_ev_user, libxl_evgen_disk_eject **evgen_out);
tools/libxl/libxl_internal.h +8 -0
index 506687fbe9..7972490050 100644
@@ -356,6 +356,14 @@ struct libxl__ev_child {
     LIBXL_LIST_ENTRY(struct libxl__ev_child) entry;
 };
 
+/*
+ * Structure used for AER event handling.
+ */
+struct libxl__aer_watch {
+    uint32_t domid;
+    libxl__ev_xswatch watch;
+    struct libxl__aer_watch *next;
+};
 
 /*
  * evgen structures, which are the state we use for generating
tools/libxl/libxl_pci.c +123 -0

129 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw

PATCH v5 2/2 xl: Register the AER event handler that handles AER errors

In reply to Venu Busireddy

When a guest is created, register the AER event handler to handle the AER errors. When an AER error occurs, the handler will forcibly remove the erring PCIe device from the guest.

---
 tools/libxl/libxl_create.c | 11 +++++++++--
 tools/libxl/libxl_domain.c |  1 +
 tools/xl/xl_vmcontrol.c    | 14 +++++++++++++-
 3 files changed, 23 insertions(+), 3 deletions(-)
tools/libxl/libxl_create.c +9 -2
index c498135246..2d247da5f0 100644
@@ -1663,7 +1663,7 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
 {
     AO_CREATE(ctx, 0, ao_how);
     libxl__app_domain_create_state *cdcs;
-    int rc;
+    int rc, ao_rc;
 
     GCNEW(cdcs);
     cdcs->dcs.ao = ao;
@@ -1698,7 +1698,14 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,
 
     initiate_domain_create(egc, &cdcs->dcs);
 
-    return AO_INPROGRESS;
+    ao_rc = AO_INPROGRESS;
+    rc = libxl_reg_aer_events_handler(ctx, *domid);
+    if (rc) {
+        /* Log the error, and move on... */
+        LOGD(ERROR, *domid,
+                "libxl_reg_aer_events_handler() failed, rc = %d", rc);
+    }
+    return ao_rc;
 
  out_err:
     return AO_CREATE_FAIL(rc);
tools/libxl/libxl_domain.c +1 -0
index 13b1c73d40..b8fb5e0349 100644
@@ -906,6 +906,7 @@ void libxl__domain_destroy(libxl__egc *egc, libxl__domain_destroy_state *dds)
     STATE_AO_GC(dds->ao);
     uint32_t stubdomid = libxl_get_stubdom_id(CTX, dds->domid);
 
+    libxl_unreg_aer_events_handler(CTX, dds->domid);
     if (stubdomid) {
         dds->stubdom.ao = ao;
         dds->stubdom.domid = stubdomid;
tools/xl/xl_vmcontrol.c +13 -1
index 89c2b25ded..5bf415fa6e 100644
@@ -945,8 +945,11 @@ start:
         libxl_domain_unpause(ctx, domid);
 
     ret = domid; /* caller gets success in parent */
-    if (!daemonize && !monitor)
+    if (!daemonize && !monitor) {
+        /* Unregister aer events handler before returning/exiting */
+        libxl_unreg_aer_events_handler(ctx, domid);
         goto out;
+    }
 
     if (dom_info->vnc)
         autoconnect_vncviewer(domid, vncautopass);
@@ -958,9 +961,17 @@ start:
         ret = do_daemonize(name, NULL);
         free(name);
         if (ret) {
+            /* Unregister aer events handler before returning/exiting */
+            libxl_unreg_aer_events_handler(ctx, domid);
             ret = (ret == 1) ? domid : ret;
             goto out;
         }
+        /* Child has new ctx. Re-register the events handler in child's ctx */
+        ret = libxl_reg_aer_events_handler(ctx, domid);
+        if (ret) {
+            /* Log the error, and move on... */
+            LOG("libxl_reg_aer_events_handler() failed, ret = %d", ret);
+        }
         need_daemon = 0;
     }
     LOG("Waiting for domain %s (domid %u) to die [pid %ld]",
@@ -1059,6 +1070,7 @@ start:
 
         case LIBXL_EVENT_TYPE_DOMAIN_DEATH:
             LOG("Domain %u has been destroyed.", domid);
+            libxl_unreg_aer_events_handler(ctx, domid);
             libxl_event_free(ctx, event);
             ret = 0;
             goto out;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Venu Busireddy
Quoted 5 lines · Venu Busireddy

This patch set is part of a set of patches that together allow containment of unrecoverable AER errors from PCIe devices assigned to guests in passthrough mode. The containment is achieved by forcibly removing the erring PCIe device from the guest.

Quoted 7 lines

The original xen-pciback patch corresponding to this patch set is:
https://lists.xen.org/archives/html/xen-devel/2017-06/msg03274.html.
It will be reposted after this patch set is accepted.

Changes in v5:
* v4 worked only in the case of guests created using 'xl' command. Enhanced the fix to work for guests created using libvirt too.

Are there any libvirt patches for this?

Quoted 24 lines

Changes in v4:
* Made the following changes suggested by Wei Liu.
- Combine multiple LIBXL_HAVE_* definitions into one.
- Use libxl__calloc() instead of malloc().

Changes in v3:
* Made the following changes suggested by Wei Liu.
- Added LIBXL_HAVE macros to libxl.h.
- Don't hard-code dom0's domid to 0. Instead, use libxl__get_domid().
- Corrected comments.
* Made the following changes based on comments from Ian Jackson.
- Got rid of the global variable aer_watch.
- Added documentation (comments in code) for the new API calls.
- Removed the unnecessary writes to xenstore.

Changes in v2:
- Instead of killing the guest and hiding the device, forcibly remove the device from the guest.

Venu Busireddy (2):
libxl: Implement the handler to handle unrecoverable AER errors
xl: Register the AER event handler that handles AER errors

Quoted 9 lines
 tools/libxl/libxl.h          |   7 +++
 tools/libxl/libxl_create.c   |  11 +++-
 tools/libxl/libxl_domain.c   |   1 +
 tools/libxl/libxl_event.h    |   7 +++
 tools/libxl/libxl_internal.h |   8 +++
 tools/libxl/libxl_pci.c      | 123 +++++++++++++++++++++++++++++++++++++++++++
 tools/xl/xl_vmcontrol.c      |  14 ++++-
 7 files changed, 168 insertions(+), 3 deletions(-)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 9 lines · Venu Busireddy

This patch set is part of a set of patches that together allow containment of unrecoverable AER errors from PCIe devices assigned to guests in passthrough mode. The containment is achieved by forcibly removing the erring PCIe device from the guest.

The original xen-pciback patch corresponding to this patch set is:
https://lists.xen.org/archives/html/xen-devel/2017-06/msg03274.html.
It will be reposted after this patch set is accepted.

Quoted 5 lines
Quoted 3 lines

Changes in v5:
* v4 worked only in the case of guests created using 'xl' command. Enhanced the fix to work for guests created using libvirt too.

Are there any libvirt patches for this?

No. There is no change to libvirt itself. All the changes are contained within xl and xen-pciback.

Venu

Quoted 24 lines
Quoted 24 lines

Changes in v4:
* Made the following changes suggested by Wei Liu.
- Combine multiple LIBXL_HAVE_* definitions into one.
- Use libxl__calloc() instead of malloc().

Changes in v3:
* Made the following changes suggested by Wei Liu.
- Added LIBXL_HAVE macros to libxl.h.
- Don't hard-code dom0's domid to 0. Instead, use libxl__get_domid().
- Corrected comments.
* Made the following changes based on comments from Ian Jackson.
- Got rid of the global variable aer_watch.
- Added documentation (comments in code) for the new API calls.
- Removed the unnecessary writes to xenstore.

Changes in v2:
- Instead of killing the guest and hiding the device, forcibly remove the device from the guest.

Venu Busireddy (2):
libxl: Implement the handler to handle unrecoverable AER errors
xl: Register the AER event handler that handles AER errors

Quoted 9 lines
Quoted 9 lines
 tools/libxl/libxl.h          |   7 +++
 tools/libxl/libxl_create.c   |  11 +++-
 tools/libxl/libxl_domain.c   |   1 +
 tools/libxl/libxl_event.h    |   7 +++
 tools/libxl/libxl_internal.h |   8 +++
 tools/libxl/libxl_pci.c      | 123 +++++++++++++++++++++++++++++++++++++++++++
 tools/xl/xl_vmcontrol.c      |  14 ++++-
 7 files changed, 168 insertions(+), 3 deletions(-)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 10 lines · On Fri, 16 Mar 2018 10:32:10 -0400 Konrad Rzeszutek Wilk…
Quoted 9 lines · Venu Busireddy

This patch set is part of a set of patches that together allow containment of unrecoverable AER errors from PCIe devices assigned to guests in passthrough mode. The containment is achieved by forcibly removing the erring PCIe device from the guest.

The original xen-pciback patch corresponding to this patch set is:
https://lists.xen.org/archives/html/xen-devel/2017-06/msg03274.html.
It will be reposted after this patch set is accepted.

Quoted 5 lines
Quoted 3 lines

Changes in v5:
* v4 worked only in the case of guests created using 'xl' command. Enhanced the fix to work for guests created using libvirt too.

Are there any libvirt patches for this?

No, the change to libxl (xenlight) Xen driver adds the support to libvirt when Xen guests are in effect per the libvirt loaded DSO.

Quoted 23 lines
Quoted 23 lines

Changes in v4:
* Made the following changes suggested by Wei Liu.
- Combine multiple LIBXL_HAVE_* definitions into one.
- Use libxl__calloc() instead of malloc().

Changes in v3:
* Made the following changes suggested by Wei Liu.
- Added LIBXL_HAVE macros to libxl.h.
- Don't hard-code dom0's domid to 0. Instead, use libxl__get_domid().
- Corrected comments.
* Made the following changes based on comments from Ian Jackson.
- Got rid of the global variable aer_watch.
- Added documentation (comments in code) for the new API calls.
- Removed the unnecessary writes to xenstore.

Changes in v2:
- Instead of killing the guest and hiding the device, forcibly remove the device from the guest.

Venu Busireddy (2):
libxl: Implement the handler to handle unrecoverable AER errors
xl: Register the AER event handler that handles AER errors

Quoted 9 lines
Quoted 9 lines
 tools/libxl/libxl.h          |   7 +++
 tools/libxl/libxl_create.c   |  11 +++-
 tools/libxl/libxl_domain.c   |   1 +
 tools/libxl/libxl_event.h    |   7 +++
 tools/libxl/libxl_internal.h |   8 +++
 tools/libxl/libxl_pci.c      | 123 +++++++++++++++++++++++++++++++++++++++++++
 tools/xl/xl_vmcontrol.c      |  14 ++++-
 7 files changed, 168 insertions(+), 3 deletions(-)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel