[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v5 2/2] xl: Register the AER event handler that handles AER errors



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.

Signed-off-by: Venu Busireddy <venu.busireddy@xxxxxxxxxx>
Signed-off-by: Wim Ten Have <wim.ten.have@xxxxxxxxxx>
---
 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(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index c498135246..2d247da5f0 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -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);
diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
index 13b1c73d40..b8fb5e0349 100644
--- a/tools/libxl/libxl_domain.c
+++ b/tools/libxl/libxl_domain.c
@@ -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;
diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
index 89c2b25ded..5bf415fa6e 100644
--- a/tools/xl/xl_vmcontrol.c
+++ b/tools/xl/xl_vmcontrol.c
@@ -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
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.