2019-05-23 17:35:08 +03:00
|
|
|
/*
|
2012-10-24 01:44:02 +04:00
|
|
|
* This file is supposed to be included only by .c files. No header file should
|
|
|
|
* depend on qemu-common.h, as this would easily lead to circular header
|
|
|
|
* dependencies.
|
|
|
|
*
|
|
|
|
* If a header file uses a definition from qemu-common.h, that definition
|
|
|
|
* must be moved to a separate header file, and the header that uses it
|
|
|
|
* must include that header.
|
|
|
|
*/
|
2007-11-11 05:51:17 +03:00
|
|
|
#ifndef QEMU_COMMON_H
|
|
|
|
#define QEMU_COMMON_H
|
|
|
|
|
2011-03-27 13:04:57 +04:00
|
|
|
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
|
2010-02-18 23:25:23 +03:00
|
|
|
|
2016-08-04 14:14:36 +03:00
|
|
|
/* Copyright string for -version arguments, About dialogs, etc */
|
2022-01-20 15:47:13 +03:00
|
|
|
#define QEMU_COPYRIGHT "Copyright (c) 2003-2022 " \
|
2016-08-04 14:14:36 +03:00
|
|
|
"Fabrice Bellard and the QEMU Project developers"
|
|
|
|
|
2017-08-03 19:33:53 +03:00
|
|
|
/* Bug reporting information for --help arguments, About dialogs, etc */
|
|
|
|
#define QEMU_HELP_BOTTOM \
|
2017-11-21 15:04:35 +03:00
|
|
|
"See <https://qemu.org/contribute/report-a-bug> for how to report bugs.\n" \
|
|
|
|
"More information on the QEMU project at <https://qemu.org>."
|
2017-08-03 19:33:53 +03:00
|
|
|
|
2011-05-29 21:42:51 +04:00
|
|
|
/* main function, renamed */
|
|
|
|
#if defined(CONFIG_COCOA)
|
|
|
|
int qemu_main(int argc, char **argv, char **envp);
|
|
|
|
#endif
|
|
|
|
|
2010-01-20 02:56:09 +03:00
|
|
|
ssize_t qemu_write_full(int fd, const void *buf, size_t count)
|
|
|
|
QEMU_WARN_UNUSED_RESULT;
|
2009-12-02 14:24:42 +03:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
int qemu_pipe(int pipefd[2]);
|
2013-06-05 18:44:54 +04:00
|
|
|
/* like openpty() but also makes it raw; return master fd */
|
|
|
|
int qemu_openpty_raw(int *aslave, char *pty_name);
|
2009-12-02 14:24:42 +03:00
|
|
|
#endif
|
|
|
|
|
2011-08-02 18:10:21 +04:00
|
|
|
void cpu_exec_init_all(void);
|
2016-06-30 08:12:55 +03:00
|
|
|
void cpu_exec_step_atomic(CPUState *cpu);
|
2010-03-29 23:23:48 +04:00
|
|
|
|
2016-10-24 18:26:49 +03:00
|
|
|
/**
|
|
|
|
* set_preferred_target_page_bits:
|
|
|
|
* @bits: number of bits needed to represent an address within the page
|
|
|
|
*
|
|
|
|
* Set the preferred target page size (the actual target page
|
|
|
|
* size may be smaller than any given CPU's preference).
|
|
|
|
* Returns true on success, false on failure (which can only happen
|
|
|
|
* if this is called after the system has already finalized its
|
|
|
|
* choice of page size and the requested page size is smaller than that).
|
|
|
|
*/
|
|
|
|
bool set_preferred_target_page_bits(int bits);
|
|
|
|
|
2019-09-19 23:30:29 +03:00
|
|
|
/**
|
|
|
|
* finalize_target_page_bits:
|
|
|
|
* Commit the final value set by set_preferred_target_page_bits.
|
|
|
|
*/
|
|
|
|
void finalize_target_page_bits(void);
|
|
|
|
|
2011-09-08 15:46:25 +04:00
|
|
|
/**
|
2012-06-07 20:22:46 +04:00
|
|
|
* Sends a (part of) iovec down a socket, yielding when the socket is full, or
|
|
|
|
* Receives data into a (part of) iovec from a socket,
|
|
|
|
* yielding when there is no data in the socket.
|
|
|
|
* The same interface as qemu_sendv_recvv(), with added yielding.
|
|
|
|
* XXX should mark these as coroutine_fn
|
2011-09-08 15:46:25 +04:00
|
|
|
*/
|
2012-06-07 20:22:46 +04:00
|
|
|
ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
|
|
|
|
size_t offset, size_t bytes, bool do_send);
|
|
|
|
#define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \
|
|
|
|
qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false)
|
|
|
|
#define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \
|
|
|
|
qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true)
|
2011-09-08 15:46:25 +04:00
|
|
|
|
|
|
|
/**
|
2012-06-07 20:22:46 +04:00
|
|
|
* The same as above, but with just a single buffer
|
2011-09-08 15:46:25 +04:00
|
|
|
*/
|
2012-06-07 20:22:46 +04:00
|
|
|
ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send);
|
|
|
|
#define qemu_co_recv(sockfd, buf, bytes) \
|
|
|
|
qemu_co_send_recv(sockfd, buf, bytes, false)
|
|
|
|
#define qemu_co_send(sockfd, buf, bytes) \
|
|
|
|
qemu_co_send_recv(sockfd, buf, bytes, true)
|
2011-09-08 15:46:25 +04:00
|
|
|
|
2011-03-30 16:16:25 +04:00
|
|
|
void qemu_progress_init(int enabled, float min_skip);
|
|
|
|
void qemu_progress_end(void);
|
2011-05-09 19:32:20 +04:00
|
|
|
void qemu_progress_print(float delta, int max);
|
2012-08-06 12:24:55 +04:00
|
|
|
const char *qemu_get_vm_name(void);
|
2011-03-30 16:16:25 +04:00
|
|
|
|
2011-03-27 13:04:57 +04:00
|
|
|
/* OS specific functions */
|
|
|
|
void os_setup_early_signal_handling(void);
|
2018-05-04 20:01:07 +03:00
|
|
|
int os_parse_cmd_args(int index, const char *optarg);
|
2011-03-27 13:04:57 +04:00
|
|
|
|
2020-09-25 12:10:54 +03:00
|
|
|
/*
|
|
|
|
* Hexdump a line of a byte buffer into a hexadecimal/ASCII buffer
|
|
|
|
*/
|
|
|
|
#define QEMU_HEXDUMP_LINE_BYTES 16 /* Number of bytes to dump */
|
|
|
|
#define QEMU_HEXDUMP_LINE_LEN 75 /* Number of characters in line */
|
|
|
|
void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr,
|
|
|
|
unsigned int len, bool ascii);
|
|
|
|
|
2013-03-15 20:41:58 +04:00
|
|
|
/*
|
|
|
|
* Hexdump a buffer to a file. An optional string prefix is added to every line
|
|
|
|
*/
|
|
|
|
|
2020-08-22 21:09:50 +03:00
|
|
|
void qemu_hexdump(FILE *fp, const char *prefix,
|
|
|
|
const void *bufptr, size_t size);
|
2013-03-15 20:41:58 +04:00
|
|
|
|
2013-03-04 20:41:28 +04:00
|
|
|
/*
|
|
|
|
* helper to parse debug environment variables
|
|
|
|
*/
|
|
|
|
int parse_debug_env(const char *name, int max, int initial);
|
|
|
|
|
2014-03-11 03:42:26 +04:00
|
|
|
const char *qemu_ether_ntoa(const MACAddr *mac);
|
2015-11-05 21:10:31 +03:00
|
|
|
void page_size_init(void);
|
2014-03-11 03:42:26 +04:00
|
|
|
|
2016-02-18 08:16:49 +03:00
|
|
|
/* returns non-zero if dump is in progress, otherwise zero is
|
|
|
|
* returned. */
|
|
|
|
bool dump_in_progress(void);
|
|
|
|
|
2007-11-11 05:51:17 +03:00
|
|
|
#endif
|