mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
libxl: fix fd check in libxl__spawn_local_dm
Checking the logfile_w fd for -1 on failure is no longer true, because
libxl__create_qemu_logfile will now return ERROR_FAIL on failure which
is -3.
While there also add an error check for opening /dev/null.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
(cherry picked from commit 3b88d95e9c)
Conflicts:
tools/libxl/libxl_dm.c
This commit is contained in:
1 parent
4cbbbdfb77
commit
8f1bd27fcd
1 file changed
+7
-2
@@ -1180,6 +1180,11 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss)
|
||||
logfile_w = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644);
|
||||
free(logfile);
|
||||
null = open("/dev/null", O_RDONLY);
|
||||
if (null < 0) {
|
||||
LOGE(ERROR, "unable to open /dev/null");
|
||||
rc = ERROR_FAIL;
|
||||
goto out_close;
|
||||
}
|
||||
|
||||
const char *dom_path = libxl__xs_get_dompath(gc, domid);
|
||||
spawn->pidpath = GCSPRINTF("%s/%s", dom_path, "image/device-model-pid");
|
||||
@@ -1227,8 +1232,8 @@ retry_transaction:
|
||||
rc = 0;
|
||||
|
||||
out_close:
|
||||
close(null);
|
||||
close(logfile_w);
|
||||
if (null >= 0) close(null);
|
||||
if (logfile_w >= 0) close(logfile_w);
|
||||
out:
|
||||
if (rc)
|
||||
device_model_spawn_outcome(egc, dmss, rc);
|
||||
|
||||