Skip to contentSkip to conversation

libxl: prepare environment for domcreate_stream_done

PATCH Superseded Olaf Hering 2 participants 6 messages Mar 7, 2019 – Mar 8, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: prepare environment for domcreate_stream_done

The function domcreate_bootloader_done may branch early to domcreate_stream_done, in case some error occoured. Here srs->dcs will be NULL, which leads to a crash.

It is unclear what the purpose of that backpointer is. Perhaps it can be removed, and domcreate_stream_done could use CONTAINER_OF.

---
 tools/libxl/libxl_create.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/libxl/libxl_create.c +4 -1
index a4e74a5cd2..989ce6d5bd 100644
@@ -1093,6 +1093,10 @@ static void domcreate_bootloader_done(libxl__egc *egc,
         return;
     }
 
+    /* Prepare environment for domcreate_stream_done */
+    if (!dcs->srs.dcs)
+        dcs->srs.dcs = dcs;
+
     /* Restore */
     callbacks->restore_results = libxl__srm_callout_callback_restore_results;
 
@@ -1116,7 +1120,6 @@ static void domcreate_bootloader_done(libxl__egc *egc,
         goto out;
 
     dcs->srs.ao = ao;
-    dcs->srs.dcs = dcs;
     dcs->srs.fd = restore_fd;
     dcs->srs.legacy = (dcs->restore_params.stream_version == 1);
     dcs->srs.back_channel = false;

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

#1 lore raw

Thanks for the patch!

Quoted 17 lines · Olaf Hering

The function domcreate_bootloader_done may branch early to domcreate_stream_done, in case some error occoured. Here srs->dcs will be NULL, which leads to a crash.

It is unclear what the purpose of that backpointer is. Perhaps it can be removed, and domcreate_stream_done could use CONTAINER_OF.

---
 tools/libxl/libxl_create.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/libxl/libxl_create.c +0 -0
index a4e74a5cd2..989ce6d5bd 100644

tools/libxl/libxl_create.c static void domcreate_bootloader_done(libxl__egc *egc, · line 1099

Quoted 7 lines
tools/libxl/libxl_create.c +4 -0
@@ -1093,6 +1093,10 @@ static void domcreate_bootloader_done(libxl__egc *egc,
         return;
     }
 
+    /* Prepare environment for domcreate_stream_done */
+    if (!dcs->srs.dcs)
+        dcs->srs.dcs = dcs;
+

Have you seen the field been set before entering this function? Or is the if () just a precaution?

If it is the latter, can we have an ASSERT instead? Seeing the original code already unconditionally assigns dcs, I don't think you can make it any worse than before.

Wei.

tools/libxl/libxl_create.c static void domcreate_bootloader_done(libxl__egc *egc, · line 1125

Quoted 11 lines
tools/libxl/libxl_create.c +0 -1
     /* Restore */
     callbacks->restore_results = libxl__srm_callout_callback_restore_results;
 
@@ -1116,7 +1120,6 @@ static void domcreate_bootloader_done(libxl__egc *egc,
         goto out;
 
     dcs->srs.ao = ao;
-    dcs->srs.dcs = dcs;
     dcs->srs.fd = restore_fd;
     dcs->srs.legacy = (dcs->restore_params.stream_version == 1);
     dcs->srs.back_channel = false;

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

#2 lore raw

Am Thu, 7 Mar 2019 11:02:47 +0000
schrieb Wei Liu <[email protected]>:

Quoted 2 lines

Have you seen the field been set before entering this function? Or is the if () just a precaution?

Sorry, this is not the variant I intended to send. The assignment was supposed to be unconditionally.

Today I browsed the code and it was not clear if that backpointer is really required. Does anyone know if srs->dcs can ever be something else than the dcs which contains that srs?

Olaf

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

#3 lore raw
Quoted 6 lines · Olaf Hering

Am Thu, 7 Mar 2019 11:02:47 +0000
schrieb Wei Liu <[email protected]>:

Quoted 2 lines

Have you seen the field been set before entering this function? Or is the if () just a precaution?

Quoted 6 lines

Sorry, this is not the variant I intended to send. The assignment was supposed to be unconditionally.

Today I browsed the code and it was not clear if that backpointer is really required. Does anyone know if srs->dcs can ever be something else than the dcs which contains that srs?

That code has been changed quite a bit with migration v2 and COLO. I wouldn't be surprised if some code becomes stale.

Sadly I won't have time today to dig into the history.

Wei.

Quoted 2 lines

Olaf

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

#4 lore raw

Am Thu, 7 Mar 2019 12:18:20 +0000
schrieb Wei Liu <[email protected]>:

Quoted 2 lines

That code has been changed quite a bit with migration v2 and COLO. I wouldn't be surprised if some code becomes stale.

Are you ok with just moving that assignment up to avoid the crash? This should be backported to at least 4.10, older branches need that too. A thoroughly review can still be done later.

Olaf

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

#5 lore raw
Quoted 10 lines · Olaf Hering

Am Thu, 7 Mar 2019 12:18:20 +0000
schrieb Wei Liu <[email protected]>:

Quoted 2 lines

That code has been changed quite a bit with migration v2 and COLO. I wouldn't be surprised if some code becomes stale.

Are you ok with just moving that assignment up to avoid the crash? This should be backported to at least 4.10, older branches need that too. A thoroughly review can still be done later.

Sure. That would be fine by me. Thanks for fixing this issue.

Wei.

Quoted 1 line

Olaf

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