libxl: fix libxl__build_hvm error code return path
PATCH 1/1 libxl: fix libxl__build_hvm error code return path
This is a simple fix to make sure libxl__build_hvm returns an error code in case of failure.
---
I would rather prefer to have it fixed in a proper way like it's done in my "libxl: fix libxl__build_hvm error handling" as part of the HVMlite series, but I understand that given the current status of the tree and the willingness to backport this to stable branches the other approach is going to be much harder.
--- tools/libxl/libxl_dom.c | 1 + 1 file changed, 1 insertion(+)
tools/libxl/libxl_dom.c +1 -0
@@ -1019,6 +1019,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,return 0 ; out: + rc =ERROR_FAIL ;return rc; }
Signature · 7 lines
1.9.5 (Apple Git-50.3) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 11 lines · Roger Pau Monne
This is a simple fix to make sure
libxl__build_hvmreturns an error code in case of failure.Signed-off-by Roger Pau Monné <[email protected]>Cc Ian Jackson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
Though I would like to make commit message clearer.
In 25652f23 ("tools/libxl: detect and avoid conflicts with RDM"), new code was added to use rc to store libxl function call return value, which complied to libxl coding style. That patch, however, didn't change other locations where return value was stored in ret. In the end libxl__build_hvm could return 0 when it failed.
Explicitly set rc to ERROR_FAIL in error path to fix this. A more comprehensive fix would be changing all ret to rc, which should be done when next development window opens.
Quoted 24 lines
---
I would rather prefer to have it fixed in a proper way like it's done in my "libxl: fixlibxl__build_hvmerror handling" as part of the HVMlite series, but I understand that given the current status of the tree and the willingness to backport this to stable branches the other approach is going to be much harder.--- tools/libxl/libxl_dom.c | 1 + 1 file changed, 1 insertion(+)tools/libxl/libxl_dom.c +1
-0@@ -1019,6 +1019,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,return 0 ; out: + rc =ERROR_FAIL ;return rc; }Signature · 1 line
1.9.5 (Apple Git-50.3)
Quoted 8 lines · Wei Liu
Quoted 4 lines · Roger Pau Monne
This is a simple fix to make sure
libxl__build_hvmreturns an error code in
case of failure.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Roger Pau Monné <[email protected]>Cc Ian Jackson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>Acked-by Wei Liu <[email protected]>
Unfortunately I think this will result in any valid rc's any path happens to have being discarded in favour of a generic ERROR_FAIL.
If we are going to band aid this for 4.6 then I think setting rc = ERROR_FAIL just after the libxl__domain_device_construct_rdm error handling might be better.
Even better would be to put the rc = ERROR_FAIL into the various if (ret) blocks. I don't think that would be an unacceptably large patch (it's 3-4 sites from what I can see) and it would be closer to heading in the right direction.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 15 lines · Ian Campbell
Quoted 14 lines · Wei Liu
Quoted 12 lines · Roger Pau Monne
This is a simple fix to make sure
libxl__build_hvmreturns an error code in
case of failure.Signed-off-by Roger Pau Monné <[email protected]>Cc Ian Jackson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
Quoted 5 lines
Quoted 1 line
Acked-by Wei Liu <[email protected]>Unfortunately I think this will result in any valid rc's any path happens to have being discarded in favour of a generic
ERROR_FAIL.
Don't worry, this is the original behaviour.
Quoted 9 lines
If we are going to band aid this for 4.6 then I think setting rc =
ERROR_FAILjust after thelibxl__domain_device_construct_rdmerror handling might be better.Even better would be to put the rc =
ERROR_FAILinto the various if (ret) blocks. I don't think that would be an unacceptably large patch (it's 3-4 sites from what I can see) and it would be closer to heading in the right direction.
I can do this as well, since Roger is on vacation at the moment.
Wei.
Quoted 1 line
Ian.