/* domain related functions */
+/* If the result is ERROR_ABORTED, the domain may or may not exist
+ * (in a half-created state). *domid will be valid and will be the
+ * domain id, or -1, as appropriate */
+
int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
uint32_t *domid,
const libxl_asyncop_how *ao_how,
if (!rc && d_config->b_info.exec_ssidref)
rc = xc_flask_relabel_domain(CTX->xch, dcs->guest_domid, d_config->b_info.exec_ssidref);
- if (!rc) {
+ bool retain_domain = !rc || rc == ERROR_ABORTED;
+
+ if (retain_domain) {
libxl__domain_userdata_lock *lock;
/* Note that we hold CTX lock at this point so only need to
rc = ERROR_LOCK_FAIL;
} else {
libxl__update_domain_configuration(gc, d_config_saved, d_config);
- rc = libxl__set_domain_configuration(gc, dcs->guest_domid,
- d_config_saved);
+ int cfg_rc = libxl__set_domain_configuration
+ (gc, dcs->guest_domid, d_config_saved);
+ if (!rc)
+ rc = cfg_rc;
libxl__unlock_domain_userdata(lock);
}
}
libxl_domain_config_dispose(d_config_saved);
- if (rc) {
+ if (!retain_domain) {
if (dcs->guest_domid) {
dcs->dds.ao = ao;
dcs->dds.domid = dcs->guest_domid;
libxl__app_domain_create_state *cdcs = CONTAINER_OF(dcs, *cdcs, dcs);
STATE_AO_GC(cdcs->dcs.ao);
- if (!rc)
- *cdcs->domid_out = domid;
+ *cdcs->domid_out = domid;
libxl__ao_complete(egc, ao, rc);
}