2015-08-19 17:20:20 +02:00
|
|
|
/*
|
|
|
|
* OS includes and handling of OS dependencies
|
|
|
|
*
|
|
|
|
* This header exists to pull in some common system headers that
|
|
|
|
* most code in QEMU will want, and to fix up some possible issues with
|
|
|
|
* it (missing defines, Windows weirdness, and so on).
|
|
|
|
*
|
|
|
|
* To avoid getting into possible circular include dependencies, this
|
|
|
|
* file should not include any other QEMU headers, with the exceptions
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 09:01:28 +01:00
|
|
|
* of config-host.h, config-target.h, qemu/compiler.h,
|
|
|
|
* sysemu/os-posix.h, sysemu/os-win32.h, glib-compat.h and
|
|
|
|
* qemu/typedefs.h, all of which are doing a similar job to this file
|
|
|
|
* and are under similar constraints.
|
2015-08-19 17:20:20 +02:00
|
|
|
*
|
|
|
|
* This header also contains prototypes for functions defined in
|
|
|
|
* os-*.c and util/oslib-*.c; those would probably be better split
|
|
|
|
* out into separate header files.
|
|
|
|
*
|
|
|
|
* In an ideal world this header would contain only:
|
|
|
|
* (1) things which everybody needs
|
|
|
|
* (2) things without which code would work on most platforms but
|
|
|
|
* fail to compile or misbehave on a minority of host OSes
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
2004-02-16 23:12:40 +01:00
|
|
|
#ifndef QEMU_OSDEP_H
|
|
|
|
#define QEMU_OSDEP_H
|
|
|
|
|
2013-04-21 12:01:06 +02:00
|
|
|
#include "config-host.h"
|
2016-02-23 12:58:02 +01:00
|
|
|
#ifdef NEED_CPU_H
|
|
|
|
#include "config-target.h"
|
|
|
|
#endif
|
2015-08-19 17:20:19 +02:00
|
|
|
#include "qemu/compiler.h"
|
2016-02-08 20:08:10 +01:00
|
|
|
|
2016-02-23 12:58:02 +01:00
|
|
|
/* Older versions of C++ don't get definitions of various macros from
|
|
|
|
* stdlib.h unless we define these macros before first inclusion of
|
|
|
|
* that system header.
|
|
|
|
*/
|
|
|
|
#ifndef __STDC_CONSTANT_MACROS
|
|
|
|
#define __STDC_CONSTANT_MACROS
|
|
|
|
#endif
|
|
|
|
#ifndef __STDC_LIMIT_MACROS
|
|
|
|
#define __STDC_LIMIT_MACROS
|
|
|
|
#endif
|
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
|
|
|
#define __STDC_FORMAT_MACROS
|
|
|
|
#endif
|
|
|
|
|
2016-02-08 20:08:10 +01:00
|
|
|
/* The following block of code temporarily renames the daemon() function so the
|
|
|
|
* compiler does not see the warning associated with it in stdlib.h on OSX
|
|
|
|
*/
|
|
|
|
#ifdef __APPLE__
|
|
|
|
#define daemon qemu_fake_daemon_function
|
|
|
|
#include <stdlib.h>
|
|
|
|
#undef daemon
|
|
|
|
extern int daemon(int, int);
|
|
|
|
#endif
|
|
|
|
|
2004-02-16 23:12:40 +01:00
|
|
|
#include <stdarg.h>
|
2009-09-12 11:58:46 +02:00
|
|
|
#include <stddef.h>
|
2012-08-03 20:39:21 +02:00
|
|
|
#include <stdbool.h>
|
2014-10-31 17:38:37 +01:00
|
|
|
#include <stdint.h>
|
2008-08-15 20:33:42 +02:00
|
|
|
#include <sys/types.h>
|
2015-08-19 17:20:19 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <limits.h>
|
oslib-win32: only provide localtime_r/gmtime_r if missing
The oslib-win32 file currently provides a localtime_r and
gmtime_r replacement unconditionally. Some versions of
Mingw-w64 would provide crude macros for localtime_r/gmtime_r
which QEMU takes care to disable. Latest versions of Mingw-w64
now provide actual functions for localtime_r/gmtime_r, but
with a twist that you have to include unistd.h or pthread.h
before including time.h. By luck some files in QEMU have
such an include order, resulting in compile errors:
CC util/osdep.o
In file included from include/qemu-common.h:48:0,
from util/osdep.c:48:
include/sysemu/os-win32.h:77:12: error: redundant redeclaration of 'gmtime_r' [-Werror=redundant-decls]
struct tm *gmtime_r(const time_t *timep, struct tm *result);
^
In file included from include/qemu-common.h:35:0,
from util/osdep.c:48:
/usr/i686-w64-mingw32/sys-root/mingw/include/time.h:272:107: note: previous definition of 'gmtime_r' was here
In file included from include/qemu-common.h:48:0,
from util/osdep.c:48:
include/sysemu/os-win32.h:79:12: error: redundant redeclaration of 'localtime_r' [-Werror=redundant-decls]
struct tm *localtime_r(const time_t *timep, struct tm *result);
^
In file included from include/qemu-common.h:35:0,
from util/osdep.c:48:
/usr/i686-w64-mingw32/sys-root/mingw/include/time.h:269:107: note: previous definition of 'localtime_r' was here
This change adds a configure test to see if localtime_r
exits, and only enables the QEMU impl if missing. We also
re-arrange qemu-common.h try attempt to guarantee that all
source files get unistd.h before time.h and thus see the
localtime_r/gmtime_r defs.
[sw: Use "official" spellings for Mingw-w64, MinGW in comments.]
[sw: Terminate sentences with a dot in comments.]
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-09-22 16:13:26 +02:00
|
|
|
/* Put unistd.h before time.h as that triggers localtime_r/gmtime_r
|
|
|
|
* function availability on recentish Mingw-w64 platforms. */
|
|
|
|
#include <unistd.h>
|
2015-08-19 17:20:19 +02:00
|
|
|
#include <time.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <assert.h>
|
2016-03-12 07:20:49 +01:00
|
|
|
/* setjmp must be declared before sysemu/os-win32.h
|
|
|
|
* because it is redefined there. */
|
|
|
|
#include <setjmp.h>
|
2015-08-19 17:20:19 +02:00
|
|
|
#include <signal.h>
|
|
|
|
|
2013-05-10 21:58:21 +02:00
|
|
|
#ifdef __OpenBSD__
|
2008-08-15 20:33:42 +02:00
|
|
|
#include <sys/signal.h>
|
|
|
|
#endif
|
2004-02-16 23:12:40 +01:00
|
|
|
|
2013-02-22 17:36:38 +01:00
|
|
|
#ifndef _WIN32
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#else
|
|
|
|
#define WIFEXITED(x) 1
|
|
|
|
#define WEXITSTATUS(x) (x)
|
|
|
|
#endif
|
|
|
|
|
2015-08-19 17:20:19 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "sysemu/os-win32.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_POSIX
|
|
|
|
#include "sysemu/os-posix.h"
|
|
|
|
#endif
|
2009-01-07 18:40:15 +01:00
|
|
|
|
2015-12-04 18:34:20 +01:00
|
|
|
#include "glib-compat.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 09:01:28 +01:00
|
|
|
#include "qemu/typedefs.h"
|
2015-08-28 15:40:01 +02:00
|
|
|
|
2015-08-19 17:20:19 +02:00
|
|
|
#ifndef O_LARGEFILE
|
|
|
|
#define O_LARGEFILE 0
|
|
|
|
#endif
|
|
|
|
#ifndef O_BINARY
|
|
|
|
#define O_BINARY 0
|
|
|
|
#endif
|
|
|
|
#ifndef MAP_ANONYMOUS
|
|
|
|
#define MAP_ANONYMOUS MAP_ANON
|
|
|
|
#endif
|
|
|
|
#ifndef ENOMEDIUM
|
|
|
|
#define ENOMEDIUM ENODEV
|
|
|
|
#endif
|
|
|
|
#if !defined(ENOTSUP)
|
|
|
|
#define ENOTSUP 4096
|
|
|
|
#endif
|
|
|
|
#if !defined(ECANCELED)
|
|
|
|
#define ECANCELED 4097
|
|
|
|
#endif
|
|
|
|
#if !defined(EMEDIUMTYPE)
|
|
|
|
#define EMEDIUMTYPE 4098
|
|
|
|
#endif
|
|
|
|
#ifndef TIME_MAX
|
|
|
|
#define TIME_MAX LONG_MAX
|
|
|
|
#endif
|
|
|
|
|
2016-03-11 13:41:13 +01:00
|
|
|
/* HOST_LONG_BITS is the size of a native pointer in bits. */
|
|
|
|
#if UINTPTR_MAX == UINT32_MAX
|
|
|
|
# define HOST_LONG_BITS 32
|
|
|
|
#elif UINTPTR_MAX == UINT64_MAX
|
|
|
|
# define HOST_LONG_BITS 64
|
|
|
|
#else
|
|
|
|
# error Unknown pointer size
|
|
|
|
#endif
|
|
|
|
|
2007-11-19 01:38:33 +01:00
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
#ifndef MAX
|
|
|
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
|
2014-10-27 10:18:43 +01:00
|
|
|
/* Minimum function that returns zero only iff both values are zero.
|
|
|
|
* Intended for use with unsigned values only. */
|
|
|
|
#ifndef MIN_NON_ZERO
|
|
|
|
#define MIN_NON_ZERO(a, b) (((a) != 0 && (a) < (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
|
2016-03-11 16:27:23 +01:00
|
|
|
/* Round number down to multiple */
|
|
|
|
#define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m))
|
|
|
|
|
|
|
|
/* Round number up to multiple */
|
|
|
|
#define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m))
|
|
|
|
|
2016-04-22 18:08:43 +02:00
|
|
|
/* Check if n is a multiple of m */
|
|
|
|
#define QEMU_IS_ALIGNED(n, m) (((n) % (m)) == 0)
|
|
|
|
|
2016-04-22 18:08:44 +02:00
|
|
|
/* n-byte align pointer down */
|
|
|
|
#define QEMU_ALIGN_PTR_DOWN(p, n) \
|
|
|
|
((typeof(p))QEMU_ALIGN_DOWN((uintptr_t)(p), (n)))
|
|
|
|
|
|
|
|
/* n-byte align pointer up */
|
|
|
|
#define QEMU_ALIGN_PTR_UP(p, n) \
|
|
|
|
((typeof(p))QEMU_ALIGN_UP((uintptr_t)(p), (n)))
|
|
|
|
|
|
|
|
/* Check if pointer p is n-bytes aligned */
|
|
|
|
#define QEMU_PTR_IS_ALIGNED(p, n) QEMU_IS_ALIGNED((uintptr_t)(p), (n))
|
|
|
|
|
2013-03-29 02:08:15 +01:00
|
|
|
#ifndef ROUND_UP
|
|
|
|
#define ROUND_UP(n,d) (((n) + (d) - 1) & -(d))
|
|
|
|
#endif
|
|
|
|
|
2011-02-04 09:06:04 +01:00
|
|
|
#ifndef DIV_ROUND_UP
|
|
|
|
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
|
|
|
|
#endif
|
|
|
|
|
2008-03-11 22:01:02 +01:00
|
|
|
#ifndef ARRAY_SIZE
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
#endif
|
|
|
|
|
2011-06-07 05:34:10 +02:00
|
|
|
int qemu_daemon(int nochdir, int noclose);
|
2014-05-20 12:24:05 +02:00
|
|
|
void *qemu_try_memalign(size_t alignment, size_t size);
|
2007-12-24 15:33:24 +01:00
|
|
|
void *qemu_memalign(size_t alignment, size_t size);
|
2014-10-31 17:38:37 +01:00
|
|
|
void *qemu_anon_ram_alloc(size_t size, uint64_t *align);
|
2005-02-10 22:59:25 +01:00
|
|
|
void qemu_vfree(void *ptr);
|
2013-05-13 16:19:56 +02:00
|
|
|
void qemu_anon_ram_free(void *ptr, size_t size);
|
2004-02-16 23:12:40 +01:00
|
|
|
|
2010-09-25 13:26:05 +02:00
|
|
|
#define QEMU_MADV_INVALID -1
|
|
|
|
|
|
|
|
#if defined(CONFIG_MADVISE)
|
|
|
|
|
2015-11-05 19:10:37 +01:00
|
|
|
#include <sys/mman.h>
|
|
|
|
|
2010-09-25 13:26:05 +02:00
|
|
|
#define QEMU_MADV_WILLNEED MADV_WILLNEED
|
|
|
|
#define QEMU_MADV_DONTNEED MADV_DONTNEED
|
|
|
|
#ifdef MADV_DONTFORK
|
|
|
|
#define QEMU_MADV_DONTFORK MADV_DONTFORK
|
|
|
|
#else
|
|
|
|
#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
|
|
|
|
#endif
|
|
|
|
#ifdef MADV_MERGEABLE
|
|
|
|
#define QEMU_MADV_MERGEABLE MADV_MERGEABLE
|
|
|
|
#else
|
|
|
|
#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
|
|
|
|
#endif
|
2014-06-10 13:15:22 +02:00
|
|
|
#ifdef MADV_UNMERGEABLE
|
|
|
|
#define QEMU_MADV_UNMERGEABLE MADV_UNMERGEABLE
|
|
|
|
#else
|
|
|
|
#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
|
|
|
|
#endif
|
|
|
|
#ifdef MADV_DODUMP
|
|
|
|
#define QEMU_MADV_DODUMP MADV_DODUMP
|
|
|
|
#else
|
|
|
|
#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
|
|
|
|
#endif
|
2012-08-02 21:44:16 +02:00
|
|
|
#ifdef MADV_DONTDUMP
|
|
|
|
#define QEMU_MADV_DONTDUMP MADV_DONTDUMP
|
|
|
|
#else
|
|
|
|
#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
|
|
|
|
#endif
|
2012-10-05 21:47:57 +02:00
|
|
|
#ifdef MADV_HUGEPAGE
|
|
|
|
#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE
|
|
|
|
#else
|
|
|
|
#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
|
|
|
|
#endif
|
2015-11-05 19:10:37 +01:00
|
|
|
#ifdef MADV_NOHUGEPAGE
|
|
|
|
#define QEMU_MADV_NOHUGEPAGE MADV_NOHUGEPAGE
|
|
|
|
#else
|
|
|
|
#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
|
|
|
|
#endif
|
2010-09-25 13:26:05 +02:00
|
|
|
|
|
|
|
#elif defined(CONFIG_POSIX_MADVISE)
|
|
|
|
|
|
|
|
#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED
|
|
|
|
#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED
|
|
|
|
#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
|
|
|
|
#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
|
2014-06-18 20:48:19 +02:00
|
|
|
#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
|
|
|
|
#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
|
2012-08-02 21:44:16 +02:00
|
|
|
#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
|
2012-10-24 18:12:15 +02:00
|
|
|
#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
|
2015-11-05 19:10:37 +01:00
|
|
|
#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
|
2010-09-25 13:26:05 +02:00
|
|
|
|
|
|
|
#else /* no-op */
|
|
|
|
|
|
|
|
#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID
|
|
|
|
#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID
|
|
|
|
#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
|
|
|
|
#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
|
2014-06-18 20:48:19 +02:00
|
|
|
#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
|
|
|
|
#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
|
2012-08-02 21:44:16 +02:00
|
|
|
#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
|
2012-10-24 18:12:15 +02:00
|
|
|
#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
|
2015-11-05 19:10:37 +01:00
|
|
|
#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
|
2010-09-25 13:26:05 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int qemu_madvise(void *addr, size_t len, int advice);
|
|
|
|
|
2012-11-14 16:42:39 +01:00
|
|
|
int qemu_open(const char *name, int flags, ...);
|
|
|
|
int qemu_close(int fd);
|
|
|
|
|
2011-06-02 19:58:06 +02:00
|
|
|
#if defined(__HAIKU__) && defined(__i386__)
|
|
|
|
#define FMT_pid "%ld"
|
2011-07-15 21:38:13 +02:00
|
|
|
#elif defined(WIN64)
|
|
|
|
#define FMT_pid "%" PRId64
|
2011-06-02 19:58:06 +02:00
|
|
|
#else
|
|
|
|
#define FMT_pid "%d"
|
|
|
|
#endif
|
|
|
|
|
2007-03-25 23:33:06 +02:00
|
|
|
int qemu_create_pidfile(const char *filename);
|
2011-03-15 12:26:31 +01:00
|
|
|
int qemu_get_thread_id(void);
|
2007-03-25 23:33:06 +02:00
|
|
|
|
2013-04-21 12:01:06 +02:00
|
|
|
#ifndef CONFIG_IOVEC
|
|
|
|
struct iovec {
|
|
|
|
void *iov_base;
|
|
|
|
size_t iov_len;
|
|
|
|
};
|
|
|
|
/*
|
|
|
|
* Use the same value as Linux for now.
|
|
|
|
*/
|
|
|
|
#define IOV_MAX 1024
|
|
|
|
|
|
|
|
ssize_t readv(int fd, const struct iovec *iov, int iov_cnt);
|
|
|
|
ssize_t writev(int fd, const struct iovec *iov, int iov_cnt);
|
|
|
|
#else
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#endif
|
|
|
|
|
2011-03-13 11:30:52 +01:00
|
|
|
#ifdef _WIN32
|
|
|
|
static inline void qemu_timersub(const struct timeval *val1,
|
|
|
|
const struct timeval *val2,
|
|
|
|
struct timeval *res)
|
|
|
|
{
|
|
|
|
res->tv_sec = val1->tv_sec - val2->tv_sec;
|
|
|
|
if (val1->tv_usec < val2->tv_usec) {
|
|
|
|
res->tv_sec--;
|
|
|
|
res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000;
|
|
|
|
} else {
|
|
|
|
res->tv_usec = val1->tv_usec - val2->tv_usec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define qemu_timersub timersub
|
|
|
|
#endif
|
|
|
|
|
2012-03-28 15:42:05 +02:00
|
|
|
void qemu_set_cloexec(int fd);
|
|
|
|
|
2015-11-12 18:29:54 +01:00
|
|
|
/* QEMU "hardware version" setting. Used to replace code that exposed
|
|
|
|
* QEMU_VERSION to guests in the past and need to keep compatibilty.
|
|
|
|
* Do not use qemu_hw_version() in new code.
|
|
|
|
*/
|
2015-10-30 20:36:08 +01:00
|
|
|
void qemu_set_hw_version(const char *);
|
|
|
|
const char *qemu_hw_version(void);
|
2012-05-30 05:35:51 +02:00
|
|
|
|
2012-08-03 20:39:21 +02:00
|
|
|
void fips_set_state(bool requested);
|
|
|
|
bool fips_get_state(void);
|
|
|
|
|
2013-05-18 06:31:48 +02:00
|
|
|
/* Return a dynamically allocated pathname denoting a file or directory that is
|
|
|
|
* appropriate for storing local state.
|
|
|
|
*
|
|
|
|
* @relative_pathname need not start with a directory separator; one will be
|
|
|
|
* added automatically.
|
|
|
|
*
|
|
|
|
* The caller is responsible for releasing the value returned with g_free()
|
|
|
|
* after use.
|
|
|
|
*/
|
|
|
|
char *qemu_get_local_state_pathname(const char *relative_pathname);
|
|
|
|
|
2014-02-10 07:48:51 +01:00
|
|
|
/* Find program directory, and save it for later usage with
|
|
|
|
* qemu_get_exec_dir().
|
|
|
|
* Try OS specific API first, if not working, parse from argv0. */
|
|
|
|
void qemu_init_exec_dir(const char *argv0);
|
|
|
|
|
|
|
|
/* Get the saved exec dir.
|
|
|
|
* Caller needs to release the returned string by g_free() */
|
|
|
|
char *qemu_get_exec_dir(void);
|
|
|
|
|
2013-06-04 20:24:49 +02:00
|
|
|
/**
|
|
|
|
* qemu_getauxval:
|
|
|
|
* @type: the auxiliary vector key to lookup
|
|
|
|
*
|
|
|
|
* Search the auxiliary vector for @type, returning the value
|
|
|
|
* or 0 if @type is not present.
|
|
|
|
*/
|
|
|
|
unsigned long qemu_getauxval(unsigned long type);
|
|
|
|
|
2013-11-14 11:54:16 +01:00
|
|
|
void qemu_set_tty_echo(int fd, bool echo);
|
|
|
|
|
2014-05-14 11:43:21 +02:00
|
|
|
void os_mem_prealloc(int fd, char *area, size_t sz);
|
|
|
|
|
2015-05-12 18:09:19 +02:00
|
|
|
int qemu_read_password(char *buf, int buf_size);
|
|
|
|
|
2015-08-28 15:40:01 +02:00
|
|
|
/**
|
|
|
|
* qemu_fork:
|
|
|
|
*
|
|
|
|
* A version of fork that avoids signal handler race
|
|
|
|
* conditions that can lead to child process getting
|
|
|
|
* signals that are otherwise only expected by the
|
|
|
|
* parent. It also resets all signal handlers to the
|
|
|
|
* default settings.
|
|
|
|
*
|
|
|
|
* Returns 0 to child process, pid number to parent
|
|
|
|
* or -1 on failure.
|
|
|
|
*/
|
|
|
|
pid_t qemu_fork(Error **errp);
|
|
|
|
|
2004-02-16 23:12:40 +01:00
|
|
|
#endif
|