qemu/include/qemu-common.h
<<
>>
Prefs
   1/*
   2 * This file is supposed to be included only by .c files. No header file should
   3 * depend on qemu-common.h, as this would easily lead to circular header
   4 * dependencies.
   5 *
   6 * If a header file uses a definition from qemu-common.h, that definition
   7 * must be moved to a separate header file, and the header that uses it
   8 * must include that header.
   9 */
  10#ifndef QEMU_COMMON_H
  11#define QEMU_COMMON_H
  12
  13#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
  14
  15/* Copyright string for -version arguments, About dialogs, etc */
  16#define QEMU_COPYRIGHT "Copyright (c) 2003-2022 " \
  17    "Fabrice Bellard and the QEMU Project developers"
  18
  19/* Bug reporting information for --help arguments, About dialogs, etc */
  20#define QEMU_HELP_BOTTOM \
  21    "See <https://qemu.org/contribute/report-a-bug> for how to report bugs.\n" \
  22    "More information on the QEMU project at <https://qemu.org>."
  23
  24/* main function, renamed */
  25#if defined(CONFIG_COCOA)
  26int qemu_main(int argc, char **argv, char **envp);
  27#endif
  28
  29ssize_t qemu_write_full(int fd, const void *buf, size_t count)
  30    G_GNUC_WARN_UNUSED_RESULT;
  31
  32#ifndef _WIN32
  33int qemu_pipe(int pipefd[2]);
  34/* like openpty() but also makes it raw; return master fd */
  35int qemu_openpty_raw(int *aslave, char *pty_name);
  36#endif
  37
  38void cpu_exec_init_all(void);
  39void cpu_exec_step_atomic(CPUState *cpu);
  40
  41/**
  42 * set_preferred_target_page_bits:
  43 * @bits: number of bits needed to represent an address within the page
  44 *
  45 * Set the preferred target page size (the actual target page
  46 * size may be smaller than any given CPU's preference).
  47 * Returns true on success, false on failure (which can only happen
  48 * if this is called after the system has already finalized its
  49 * choice of page size and the requested page size is smaller than that).
  50 */
  51bool set_preferred_target_page_bits(int bits);
  52
  53/**
  54 * finalize_target_page_bits:
  55 * Commit the final value set by set_preferred_target_page_bits.
  56 */
  57void finalize_target_page_bits(void);
  58
  59/**
  60 * Sends a (part of) iovec down a socket, yielding when the socket is full, or
  61 * Receives data into a (part of) iovec from a socket,
  62 * yielding when there is no data in the socket.
  63 * The same interface as qemu_sendv_recvv(), with added yielding.
  64 * XXX should mark these as coroutine_fn
  65 */
  66ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
  67                            size_t offset, size_t bytes, bool do_send);
  68#define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \
  69  qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false)
  70#define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \
  71  qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true)
  72
  73/**
  74 * The same as above, but with just a single buffer
  75 */
  76ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send);
  77#define qemu_co_recv(sockfd, buf, bytes) \
  78  qemu_co_send_recv(sockfd, buf, bytes, false)
  79#define qemu_co_send(sockfd, buf, bytes) \
  80  qemu_co_send_recv(sockfd, buf, bytes, true)
  81
  82void qemu_progress_init(int enabled, float min_skip);
  83void qemu_progress_end(void);
  84void qemu_progress_print(float delta, int max);
  85const char *qemu_get_vm_name(void);
  86
  87/* OS specific functions */
  88void os_setup_early_signal_handling(void);
  89int os_parse_cmd_args(int index, const char *optarg);
  90
  91/*
  92 * Hexdump a line of a byte buffer into a hexadecimal/ASCII buffer
  93 */
  94#define QEMU_HEXDUMP_LINE_BYTES 16 /* Number of bytes to dump */
  95#define QEMU_HEXDUMP_LINE_LEN 75   /* Number of characters in line */
  96void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr,
  97                       unsigned int len, bool ascii);
  98
  99/*
 100 * Hexdump a buffer to a file. An optional string prefix is added to every line
 101 */
 102
 103void qemu_hexdump(FILE *fp, const char *prefix,
 104                  const void *bufptr, size_t size);
 105
 106/*
 107 * helper to parse debug environment variables
 108 */
 109int parse_debug_env(const char *name, int max, int initial);
 110
 111void page_size_init(void);
 112
 113/* returns non-zero if dump is in progress, otherwise zero is
 114 * returned. */
 115bool dump_in_progress(void);
 116
 117#endif
 118