numa: call ->ram_block_removed() in ram_block_notifer_remove()
[qemu/ar7.git] / qga / cutils.c
blobb8e142ef649d4bc4461981c501b06f150db98f23
1 /*
2 * This work is licensed under the terms of the GNU GPL, version 2 or later.
3 * See the COPYING file in the top-level directory.
4 */
5 #include "cutils.h"
7 #include "qapi/error.h"
9 /**
10 * qga_open_cloexec:
11 * @name: the pathname to open
12 * @flags: as in open()
13 * @mode: as in open()
15 * A wrapper for open() function which sets O_CLOEXEC.
17 * On error, -1 is returned.
19 int qga_open_cloexec(const char *name, int flags, mode_t mode)
21 int ret;
23 #ifdef O_CLOEXEC
24 ret = open(name, flags | O_CLOEXEC, mode);
25 #else
26 ret = open(name, flags, mode);
27 if (ret >= 0) {
28 qemu_set_cloexec(ret);
30 #endif
32 return ret;