Skip to contentSkip to conversation

libxl: set guest_domid even if libxl__domain_make fails

PATCH In review Roger Pau Monne 2 participants 3 messages May 4, 2012 – May 10, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: set guest_domid even if libxl__domain_make fails

This is needed in order to perform the domain destruction if libxl__domain_make fails.

---
To be applied after IanJ libxl: subprocess handling series

 tools/libxl/libxl_create.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
tools/libxl/libxl_create.c +1 -0
index 928a48c..788e553 100644
@@ -607,6 +607,7 @@ static void initiate_domain_create(libxl__egc *egc,
     ret = libxl__domain_make(gc, &d_config->c_info, &domid);
     if (ret) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
+        dcs->guest_domid = domid;
         ret = ERROR_FAIL;
         goto error_out;
     }
Signature · 1 line
1.7.7.5 (Apple Git-26)
Acked-by on v1 1/1
#1 lore raw

Roger Pau Monne writes ("[PATCH] libxl: set guest_domid even if libxl__domain_make fails"):

Quoted 9 lines

This is needed in order to perform the domain destruction if libxl__domain_make fails.

     ret = libxl__domain_make(gc, &d_config->c_info, &domid);
     if (ret) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
+        dcs->guest_domid = domid;
         ret = ERROR_FAIL;
         goto error_out;

This is a bit odd. The documentation for libxl__domain_make says:

/* from xl_create */
_hidden int libxl__domain_make(libxl__gc *gc,

                                  libxl_domain_create_info *info,
                                  uint32_t *domid);

Yes, that's it. So apparently this function does actually create the domain on error ? Oh wait I see there is a doc comment but it's next to the definition.

/* on entry, libxl_domid_valid_guest(domid) must be false;
* on exit (even error exit), domid may be valid and refer to a domain */

So yes, that's correct.

Ian.

#2 lore raw
In reply to Roger Pau Monne

Roger Pau Monne writes ("[Xen-devel] [PATCH] libxl: set guest_domid even if libxl__domain_make fails"):

Quoted 2 lines

This is needed in order to perform the domain destruction if libxl__domain_make fails.

Thanks, I have included this in my series in the form below.

From: Roger Pau Monne <[email protected]>
Subject: [PATCH] libxl: set guest_domid even if libxl__domain_make fails

This is needed in order to perform the domain destruction if libxl__domain_make fails.

Also move doc comment about error behaviour of libxl__domain_make from implementation to declaration.

---
 tools/libxl/libxl_create.c   |    3 +--
 tools/libxl/libxl_internal.h |    4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)
tools/libxl/libxl_create.c +1 -2
index 0f17202..447d8ba 100644
@@ -396,8 +396,6 @@ out:
 
 int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info,
                        uint32_t *domid)
- /* on entry, libxl_domid_valid_guest(domid) must be false;
-  * on exit (even error exit), domid may be valid and refer to a domain */
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int flags, ret, rc;
@@ -600,6 +598,7 @@ static void initiate_domain_create(libxl__egc *egc,
     ret = libxl__domain_make(gc, &d_config->c_info, &domid);
     if (ret) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
+        dcs->guest_domid = domid;
         ret = ERROR_FAIL;
         goto error_out;
     }
tools/libxl/libxl_internal.h +4 -0
index 90b08ef..84bfbc6 100644
@@ -1073,9 +1073,13 @@ _hidden void libxl__exec(int stdinfd, int stdoutfd, int stderrfd,
                const char *arg0, char **args); // logs errors, never returns
 
 /* from xl_create */
+
+ /* on entry, libxl_domid_valid_guest(domid) must be false;
+  * on exit (even error exit), domid may be valid and refer to a domain */
 _hidden int libxl__domain_make(libxl__gc *gc,
                                libxl_domain_create_info *info,
                                uint32_t *domid);
+
 _hidden int libxl__domain_build(libxl__gc *gc,
                                 libxl_domain_build_info *info,
                                 uint32_t domid,
Signature · 1 line
tg: (3aaba1c..) t/xen/xl.create-do-destroy (depends on: t/xen/xl.event.spawn)