From a96ed02fc73e23748c8b3e38880eeac91f83ab9f Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Tue, 21 Aug 2012 20:52:07 +0000 Subject: monitor: Rename+move net_handle_fd_param -> monitor_handle_fd_param This patch renames+moves the net_handle_fd_param() caller used to obtain a file descriptor from either qemu_parse_fd() (the normal case) or from monitor_get_fd() (migration case) into a generically prefixed monitor_handle_fd_param() to be used by vhost-scsi code. Also update net/[socket,tap].c consumers to use the new prefix. Reported-by: Michael S. Tsirkin Cc: Michael S. Tsirkin Cc: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Anthony Liguori Signed-off-by: Nicholas Bellinger Signed-off-by: Michael S. Tsirkin --- net/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/socket.c') diff --git a/net/socket.c b/net/socket.c index c172c249be..7c602e4c3a 100644 --- a/net/socket.c +++ b/net/socket.c @@ -629,7 +629,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name, if (sock->has_fd) { int fd; - fd = net_handle_fd_param(cur_mon, sock->fd); + fd = monitor_handle_fd_param(cur_mon, sock->fd); if (fd == -1 || !net_socket_fd_init(peer, "socket", name, fd, 1)) { return -1; } -- cgit v1.2.3-55-g7522 From 863f678fba4191f3b695620f41056cb7c124425d Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 20 Aug 2012 10:21:54 +0100 Subject: net: asynchronous send/receive infrastructure for net/socket.c The net/socket.c net client is not truly asynchronous. This patch borrows the qemu_set_fd_handler2() code from net/tap.c as the basis for proper asynchronous send/receive. Only read packets from the socket when the peer is able to receive. This avoids needless queuing. Later patches implement asynchronous send. Signed-off-by: Stefan Hajnoczi --- net/socket.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) (limited to 'net/socket.c') diff --git a/net/socket.c b/net/socket.c index 7c602e4c3a..7bff5367ac 100644 --- a/net/socket.c +++ b/net/socket.c @@ -42,9 +42,51 @@ typedef struct NetSocketState { unsigned int packet_len; uint8_t buf[4096]; struct sockaddr_in dgram_dst; /* contains inet host and port destination iff connectionless (SOCK_DGRAM) */ + IOHandler *send_fn; /* differs between SOCK_STREAM/SOCK_DGRAM */ + bool read_poll; /* waiting to receive data? */ + bool write_poll; /* waiting to transmit data? */ } NetSocketState; static void net_socket_accept(void *opaque); +static void net_socket_writable(void *opaque); + +/* Only read packets from socket when peer can receive them */ +static int net_socket_can_send(void *opaque) +{ + NetSocketState *s = opaque; + + return qemu_can_send_packet(&s->nc); +} + +static void net_socket_update_fd_handler(NetSocketState *s) +{ + qemu_set_fd_handler2(s->fd, + s->read_poll ? net_socket_can_send : NULL, + s->read_poll ? s->send_fn : NULL, + s->write_poll ? net_socket_writable : NULL, + s); +} + +static void net_socket_read_poll(NetSocketState *s, bool enable) +{ + s->read_poll = enable; + net_socket_update_fd_handler(s); +} + +static void net_socket_write_poll(NetSocketState *s, bool enable) +{ + s->write_poll = enable; + net_socket_update_fd_handler(s); +} + +static void net_socket_writable(void *opaque) +{ + NetSocketState *s = opaque; + + net_socket_write_poll(s, false); + + qemu_flush_queued_packets(&s->nc); +} /* XXX: we consider we can send the whole packet without blocking */ static ssize_t net_socket_receive(NetClientState *nc, const uint8_t *buf, size_t size) @@ -81,7 +123,8 @@ static void net_socket_send(void *opaque) } else if (size == 0) { /* end of connection */ eoc: - qemu_set_fd_handler(s->fd, NULL, NULL, NULL); + net_socket_read_poll(s, false); + net_socket_write_poll(s, false); if (s->listen_fd != -1) { qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s); } @@ -152,7 +195,8 @@ static void net_socket_send_dgram(void *opaque) return; if (size == 0) { /* end of connection */ - qemu_set_fd_handler(s->fd, NULL, NULL, NULL); + net_socket_read_poll(s, false); + net_socket_write_poll(s, false); return; } qemu_send_packet(&s->nc, s->buf, size); @@ -243,7 +287,8 @@ static void net_socket_cleanup(NetClientState *nc) { NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc); if (s->fd != -1) { - qemu_set_fd_handler(s->fd, NULL, NULL, NULL); + net_socket_read_poll(s, false); + net_socket_write_poll(s, false); close(s->fd); s->fd = -1; } @@ -314,8 +359,8 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer, s->fd = fd; s->listen_fd = -1; - - qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s); + s->send_fn = net_socket_send_dgram; + net_socket_read_poll(s, true); /* mcast: save bound address as dst */ if (is_connected) { @@ -332,7 +377,8 @@ err: static void net_socket_connect(void *opaque) { NetSocketState *s = opaque; - qemu_set_fd_handler(s->fd, net_socket_send, NULL, s); + s->send_fn = net_socket_send; + net_socket_read_poll(s, true); } static NetClientInfo net_socket_info = { -- cgit v1.2.3-55-g7522 From 213fd5087e2e4e2da10ad266df0ba950cf7618bf Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 20 Aug 2012 10:28:53 +0100 Subject: net: EAGAIN handling for net/socket.c UDP Implement asynchronous send for UDP (or other SOCK_DGRAM) sockets. If send fails with EAGAIN we wait for the socket to become writable again. Signed-off-by: Stefan Hajnoczi --- net/socket.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'net/socket.c') diff --git a/net/socket.c b/net/socket.c index 7bff5367ac..aabf0a48c5 100644 --- a/net/socket.c +++ b/net/socket.c @@ -102,9 +102,19 @@ static ssize_t net_socket_receive(NetClientState *nc, const uint8_t *buf, size_t static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf, size_t size) { NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc); + ssize_t ret; - return sendto(s->fd, (const void *)buf, size, 0, - (struct sockaddr *)&s->dgram_dst, sizeof(s->dgram_dst)); + do { + ret = sendto(s->fd, buf, size, 0, + (struct sockaddr *)&s->dgram_dst, + sizeof(s->dgram_dst)); + } while (ret == -1 && errno == EINTR); + + if (ret == -1 && errno == EAGAIN) { + net_socket_write_poll(s, true); + return 0; + } + return ret; } static void net_socket_send(void *opaque) -- cgit v1.2.3-55-g7522 From 45a7f54a8bb3928ffa58d522e0d61acaee8277bb Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 20 Aug 2012 10:14:35 +0100 Subject: net: EAGAIN handling for net/socket.c TCP Replace spinning send_all() with a proper non-blocking send. When the socket write buffer limit is reached, we should stop trying to send and wait for the socket to become writable again. Non-blocking TCP sockets can return in two different ways when the write buffer limit is reached: 1. ret = -1 and errno = EAGAIN/EWOULDBLOCK. No data has been written. 2. ret < total_size. Short write, only part of the message was transmitted. Handle both cases and keep track of how many bytes have been written in s->send_index. (This includes the 'length' header before the actual payload buffer.) Signed-off-by: Stefan Hajnoczi --- net/socket.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'net/socket.c') diff --git a/net/socket.c b/net/socket.c index aabf0a48c5..5e0c92e062 100644 --- a/net/socket.c +++ b/net/socket.c @@ -32,6 +32,7 @@ #include "qemu-error.h" #include "qemu-option.h" #include "qemu_socket.h" +#include "iov.h" typedef struct NetSocketState { NetClientState nc; @@ -40,6 +41,7 @@ typedef struct NetSocketState { int state; /* 0 = getting length, 1 = getting data */ unsigned int index; unsigned int packet_len; + unsigned int send_index; /* number of bytes sent (only SOCK_STREAM) */ uint8_t buf[4096]; struct sockaddr_in dgram_dst; /* contains inet host and port destination iff connectionless (SOCK_DGRAM) */ IOHandler *send_fn; /* differs between SOCK_STREAM/SOCK_DGRAM */ @@ -88,15 +90,39 @@ static void net_socket_writable(void *opaque) qemu_flush_queued_packets(&s->nc); } -/* XXX: we consider we can send the whole packet without blocking */ static ssize_t net_socket_receive(NetClientState *nc, const uint8_t *buf, size_t size) { NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc); - uint32_t len; - len = htonl(size); + uint32_t len = htonl(size); + struct iovec iov[] = { + { + .iov_base = &len, + .iov_len = sizeof(len), + }, { + .iov_base = (void *)buf, + .iov_len = size, + }, + }; + size_t remaining; + ssize_t ret; + + remaining = iov_size(iov, 2) - s->send_index; + ret = iov_send(s->fd, iov, 2, s->send_index, remaining); - send_all(s->fd, (const uint8_t *)&len, sizeof(len)); - return send_all(s->fd, buf, size); + if (ret == -1 && errno == EAGAIN) { + ret = 0; /* handled further down */ + } + if (ret == -1) { + s->send_index = 0; + return -errno; + } + if (ret < (ssize_t)remaining) { + s->send_index += ret; + net_socket_write_poll(s, true); + return 0; + } + s->send_index = 0; + return size; } static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf, size_t size) -- cgit v1.2.3-55-g7522 From 73062dfe6be0050dbd43ce3516e935ebb2545add Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 22 Sep 2012 21:13:28 +0200 Subject: net/socket: Fix compiler warning (regression for MinGW) Commit 213fd5087e2e4e2da10ad266df0ba950cf7618bf removed a type cast which is needed for MinGW: net/socket.c:136: warning: pointer targets in passing argument 2 of ‘sendto’ differ in signedness /usr/lib/gcc/amd64-mingw32msvc/4.4.4/../../../../amd64-mingw32msvc/include/winsock2.h:1313: note: expected ‘const char *’ but argument is of type ‘const uint8_t *’ Add a 'qemu_sendto' macro which provides that type cast where needed and use the new macro instead of 'sendto'. Signed-off-by: Stefan Weil Signed-off-by: Stefan Hajnoczi --- net/socket.c | 6 +++--- qemu-common.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'net/socket.c') diff --git a/net/socket.c b/net/socket.c index 5e0c92e062..f3d7878264 100644 --- a/net/socket.c +++ b/net/socket.c @@ -131,9 +131,9 @@ static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf, ssize_t ret; do { - ret = sendto(s->fd, buf, size, 0, - (struct sockaddr *)&s->dgram_dst, - sizeof(s->dgram_dst)); + ret = qemu_sendto(s->fd, buf, size, 0, + (struct sockaddr *)&s->dgram_dst, + sizeof(s->dgram_dst)); } while (ret == -1 && errno == EINTR); if (ret == -1 && errno == EAGAIN) { diff --git a/qemu-common.h b/qemu-common.h index e5c2bcd204..15d9e4ed71 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -223,9 +223,14 @@ int qemu_pipe(int pipefd[2]); #endif #ifdef _WIN32 +/* MinGW needs a type cast for the 'buf' argument. */ #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags) +#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \ + sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen) #else #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags) +#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \ + sendto(sockfd, buf, len, flags, destaddr, addrlen) #endif /* Error handling. */ -- cgit v1.2.3-55-g7522 From a245fc18352fe286ba45ae0661a73b3841514889 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Sep 2012 18:43:51 +0200 Subject: net: consolidate NetClientState header files into one This patch doesn't seem much useful alone, I must admit. However, it makes sense as part of the upcoming directory reorganization, where I want to have include/net/tap.h as the net<->hw interface for tap. Then having both net/tap.h and include/net/tap.h does not work. "Fixed" by moving all the init functions to a single header file net/clients.h. The patch also adopts a uniform style for including net/*.h files from net/*.c, without the net/ path. Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- net.c | 11 ++++------- net/clients.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/dump.c | 2 +- net/dump.h | 33 --------------------------------- net/hub.c | 1 + net/hub.h | 2 -- net/slirp.c | 3 ++- net/slirp.h | 3 --- net/socket.c | 3 +-- net/socket.h | 33 --------------------------------- net/tap-win32.c | 2 +- net/tap.c | 3 ++- net/tap.h | 6 ------ net/vde.c | 3 +-- net/vde.h | 37 ------------------------------------- 15 files changed, 68 insertions(+), 129 deletions(-) create mode 100644 net/clients.h delete mode 100644 net/dump.h delete mode 100644 net/socket.h delete mode 100644 net/vde.h (limited to 'net/socket.c') diff --git a/net.c b/net.c index a187a7b3db..ae4bc0d431 100644 --- a/net.c +++ b/net.c @@ -21,17 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "net.h" - #include "config-host.h" -#include "net/tap.h" -#include "net/socket.h" -#include "net/dump.h" -#include "net/slirp.h" -#include "net/vde.h" +#include "net.h" +#include "net/clients.h" #include "net/hub.h" +#include "net/slirp.h" #include "net/util.h" + #include "monitor.h" #include "qemu-common.h" #include "qemu_socket.h" diff --git a/net/clients.h b/net/clients.h new file mode 100644 index 0000000000..c58cc6087c --- /dev/null +++ b/net/clients.h @@ -0,0 +1,55 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef QEMU_NET_CLIENTS_H +#define QEMU_NET_CLIENTS_H + +#include "net.h" +#include "qapi-types.h" + +int net_init_dump(const NetClientOptions *opts, const char *name, + NetClientState *peer); + +#ifdef CONFIG_SLIRP +int net_init_slirp(const NetClientOptions *opts, const char *name, + NetClientState *peer); +#endif + +int net_init_hubport(const NetClientOptions *opts, const char *name, + NetClientState *peer); + +int net_init_socket(const NetClientOptions *opts, const char *name, + NetClientState *peer); + +int net_init_tap(const NetClientOptions *opts, const char *name, + NetClientState *peer); + +int net_init_bridge(const NetClientOptions *opts, const char *name, + NetClientState *peer); + +#ifdef CONFIG_VDE +int net_init_vde(const NetClientOptions *opts, const char *name, + NetClientState *peer); +#endif + +#endif /* QEMU_NET_CLIENTS_H */ diff --git a/net/dump.c b/net/dump.c index 004231d481..e0a5d74644 100644 --- a/net/dump.c +++ b/net/dump.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "dump.h" +#include "clients.h" #include "qemu-common.h" #include "qemu-error.h" #include "qemu-log.h" diff --git a/net/dump.h b/net/dump.h deleted file mode 100644 index 33f152b460..0000000000 --- a/net/dump.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef QEMU_NET_DUMP_H -#define QEMU_NET_DUMP_H - -#include "net.h" -#include "qapi-types.h" - -int net_init_dump(const NetClientOptions *opts, const char *name, - NetClientState *peer); - -#endif /* QEMU_NET_DUMP_H */ diff --git a/net/hub.c b/net/hub.c index 650a8b4a40..be413012bb 100644 --- a/net/hub.c +++ b/net/hub.c @@ -14,6 +14,7 @@ #include "monitor.h" #include "net.h" +#include "clients.h" #include "hub.h" #include "iov.h" diff --git a/net/hub.h b/net/hub.h index 26a1ade1f9..4cbfdb128b 100644 --- a/net/hub.h +++ b/net/hub.h @@ -17,8 +17,6 @@ #include "qemu-common.h" -int net_init_hubport(const NetClientOptions *opts, const char *name, - NetClientState *peer); NetClientState *net_hub_add_port(int hub_id, const char *name); NetClientState *net_hub_find_client_by_name(int hub_id, const char *name); void net_hub_info(Monitor *mon); diff --git a/net/slirp.c b/net/slirp.c index 8db66ea539..bf86a446c3 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -30,7 +30,8 @@ #include #endif #include "net.h" -#include "net/hub.h" +#include "clients.h" +#include "hub.h" #include "monitor.h" #include "qemu_socket.h" #include "slirp/libslirp.h" diff --git a/net/slirp.h b/net/slirp.h index 5f685c4fb1..2ca09b65b7 100644 --- a/net/slirp.h +++ b/net/slirp.h @@ -31,9 +31,6 @@ #ifdef CONFIG_SLIRP -int net_init_slirp(const NetClientOptions *opts, const char *name, - NetClientState *peer); - void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict); void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict); diff --git a/net/socket.c b/net/socket.c index f3d7878264..b75d567695 100644 --- a/net/socket.c +++ b/net/socket.c @@ -21,11 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "net/socket.h" - #include "config-host.h" #include "net.h" +#include "clients.h" #include "monitor.h" #include "qemu-char.h" #include "qemu-common.h" diff --git a/net/socket.h b/net/socket.h deleted file mode 100644 index 3f8a092459..0000000000 --- a/net/socket.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef QEMU_NET_SOCKET_H -#define QEMU_NET_SOCKET_H - -#include "net.h" -#include "qapi-types.h" - -int net_init_socket(const NetClientOptions *opts, const char *name, - NetClientState *peer); - -#endif /* QEMU_NET_SOCKET_H */ diff --git a/net/tap-win32.c b/net/tap-win32.c index c0ea954ca1..f1801e22d2 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -26,7 +26,7 @@ * distribution); if not, see . */ -#include "net/tap.h" +#include "tap.h" #include "qemu-common.h" #include "net.h" diff --git a/net/tap.c b/net/tap.c index a88ae8f61a..df89caaac6 100644 --- a/net/tap.c +++ b/net/tap.c @@ -23,7 +23,7 @@ * THE SOFTWARE. */ -#include "net/tap.h" +#include "tap.h" #include "config-host.h" @@ -34,6 +34,7 @@ #include #include "net.h" +#include "clients.h" #include "monitor.h" #include "sysemu.h" #include "qemu-char.h" diff --git a/net/tap.h b/net/tap.h index 0fb018c4b7..d44d83ae73 100644 --- a/net/tap.h +++ b/net/tap.h @@ -32,9 +32,6 @@ #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" -int net_init_tap(const NetClientOptions *opts, const char *name, - NetClientState *peer); - int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required); ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen); @@ -58,7 +55,4 @@ int tap_get_fd(NetClientState *nc); struct vhost_net; struct vhost_net *tap_get_vhost_net(NetClientState *nc); -int net_init_bridge(const NetClientOptions *opts, const char *name, - NetClientState *peer); - #endif /* QEMU_NET_TAP_H */ diff --git a/net/vde.c b/net/vde.c index b91a6c799b..275bda92c3 100644 --- a/net/vde.c +++ b/net/vde.c @@ -21,13 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "net/vde.h" - #include "config-host.h" #include #include "net.h" +#include "clients.h" #include "qemu-char.h" #include "qemu-common.h" #include "qemu-option.h" diff --git a/net/vde.h b/net/vde.h deleted file mode 100644 index 6ce6698937..0000000000 --- a/net/vde.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef QEMU_NET_VDE_H -#define QEMU_NET_VDE_H - -#include "qemu-common.h" -#include "qapi-types.h" - -#ifdef CONFIG_VDE - -int net_init_vde(const NetClientOptions *opts, const char *name, - NetClientState *peer); - -#endif /* CONFIG_VDE */ - -#endif /* QEMU_NET_VDE_H */ -- cgit v1.2.3-55-g7522 From f0e3ac70341febed02591b61b579723279783053 Mon Sep 17 00:00:00 2001 From: Lei Li Date: Thu, 1 Nov 2012 17:39:55 +0800 Subject: net: use "socket" model name for UDP sockets Fix the problem that can not delete the udp socket. It's caused by passing "udp" model to net_socket_udp_init, but we do not have "udp" model in our model list. Pass the right model "socket" to init function. https://bugs.launchpad.net/qemu/+bug/1073585?comments=all Signed-off-by: Lei Li Signed-off-by: Stefan Hajnoczi --- net/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/socket.c') diff --git a/net/socket.c b/net/socket.c index b75d567695..c01323d4b0 100644 --- a/net/socket.c +++ b/net/socket.c @@ -747,7 +747,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name, error_report("localaddr= is mandatory with udp="); return -1; } - if (net_socket_udp_init(peer, "udp", name, sock->udp, sock->localaddr) == + if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr) == -1) { return -1; } -- cgit v1.2.3-55-g7522 From f8fe796407d8b340def61a6b57991e47aee3cfc4 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 24 Oct 2012 08:49:51 +0200 Subject: janitor: do not include qemu-char everywhere Touching char/char.h basically causes the whole of QEMU to be rebuilt. Avoid this, it is usually unnecessary. Signed-off-by: Paolo Bonzini --- audio/alsaaudio.c | 1 - audio/ossaudio.c | 1 - block/raw-posix.c | 1 - bt-host.c | 1 - bt-vhci.c | 1 - buffered_file.c | 1 - console.c | 1 + console.h | 1 - hmp.c | 1 + hw/9pfs/virtio-9p-coth.c | 1 - hw/ivshmem.c | 1 + hw/spapr_hcall.c | 2 -- hw/strongarm.c | 1 + hw/xen_disk.c | 1 - hw/xen_nic.c | 1 - hw/xilinx_axidma.c | 1 - hw/xilinx_axienet.c | 1 - hw/xtensa_lx60.c | 1 + iohandler.c | 1 - migration-exec.c | 1 - migration-fd.c | 1 - migration-tcp.c | 1 - migration-unix.c | 1 - monitor.h | 1 - net/slirp.c | 1 + net/socket.c | 1 - net/tap.c | 1 - net/vde.c | 1 - qmp.c | 1 + savevm.c | 1 - ui/qemu-spice.h | 1 - 31 files changed, 7 insertions(+), 25 deletions(-) (limited to 'net/socket.c') diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 564d632d0c..cd553c2a7b 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -24,7 +24,6 @@ #include #include "qemu-common.h" #include "main-loop.h" -#include "qemu-char.h" #include "audio.h" #if QEMU_GNUC_PREREQ(4, 3) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 45abe39a6d..8249a00449 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -33,7 +33,6 @@ #include "qemu-common.h" #include "main-loop.h" #include "host-utils.h" -#include "qemu-char.h" #include "audio.h" #define AUDIO_CAP "oss" diff --git a/block/raw-posix.c b/block/raw-posix.c index abfedbea73..48eff2fd83 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -23,7 +23,6 @@ */ #include "qemu-common.h" #include "qemu-timer.h" -#include "qemu-char.h" #include "qemu-log.h" #include "block_int.h" #include "module.h" diff --git a/bt-host.c b/bt-host.c index 8b47370b26..311864517d 100644 --- a/bt-host.c +++ b/bt-host.c @@ -18,7 +18,6 @@ */ #include "qemu-common.h" -#include "qemu-char.h" #include "net.h" #include "bt-host.h" #include "main-loop.h" diff --git a/bt-vhci.c b/bt-vhci.c index 878460aeb5..6fecb66716 100644 --- a/bt-vhci.c +++ b/bt-vhci.c @@ -18,7 +18,6 @@ */ #include "qemu-common.h" -#include "qemu-char.h" #include "net.h" #include "hw/bt.h" #include "main-loop.h" diff --git a/buffered_file.c b/buffered_file.c index bd0f61d8c9..f13443ee91 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -16,7 +16,6 @@ #include "qemu-common.h" #include "hw/hw.h" #include "qemu-timer.h" -#include "qemu-char.h" #include "buffered_file.h" //#define DEBUG_BUFFERED_FILE diff --git a/console.c b/console.c index 048b48e721..9ac7b28742 100644 --- a/console.c +++ b/console.c @@ -25,6 +25,7 @@ #include "console.h" #include "qemu-timer.h" #include "qmp-commands.h" +#include "qemu-char.h" //#define DEBUG_CONSOLE #define DEFAULT_BACKSCROLL 512 diff --git a/console.h b/console.h index edb1950871..33354e437a 100644 --- a/console.h +++ b/console.h @@ -1,7 +1,6 @@ #ifndef CONSOLE_H #define CONSOLE_H -#include "qemu-char.h" #include "qemu-pixman.h" #include "qdict.h" #include "notify.h" diff --git a/hmp.c b/hmp.c index 180ba2bfd9..873962f710 100644 --- a/hmp.c +++ b/hmp.c @@ -15,6 +15,7 @@ #include "hmp.h" #include "net.h" +#include "qemu-char.h" #include "qemu-option.h" #include "qemu-timer.h" #include "qmp-commands.h" diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c index 25556cc6a7..9368df7610 100644 --- a/hw/9pfs/virtio-9p-coth.c +++ b/hw/9pfs/virtio-9p-coth.c @@ -12,7 +12,6 @@ * */ -#include "qemu-char.h" #include "fsdev/qemu-fsdev.h" #include "qemu-thread.h" #include "qemu-coroutine.h" diff --git a/hw/ivshmem.c b/hw/ivshmem.c index cf64f32ac0..5c648d98d3 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -24,6 +24,7 @@ #include "migration.h" #include "qerror.h" #include "event_notifier.h" +#include "qemu-char.h" #include #include diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c index 63cadb8d92..1fac362329 100644 --- a/hw/spapr_hcall.c +++ b/hw/spapr_hcall.c @@ -1,8 +1,6 @@ #include "sysemu.h" #include "cpu.h" -#include "qemu-char.h" #include "sysemu.h" -#include "qemu-char.h" #include "helper_regs.h" #include "hw/spapr.h" diff --git a/hw/strongarm.c b/hw/strongarm.c index 43855151ce..44bec34e07 100644 --- a/hw/strongarm.c +++ b/hw/strongarm.c @@ -30,6 +30,7 @@ #include "strongarm.h" #include "qemu-error.h" #include "arm-misc.h" +#include "qemu-char.h" #include "sysemu.h" #include "ssi.h" diff --git a/hw/xen_disk.c b/hw/xen_disk.c index e6bb2f20b9..423b580cff 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -36,7 +36,6 @@ #include #include "hw.h" -#include "qemu-char.h" #include "xen_backend.h" #include "xen_blkif.h" #include "blockdev.h" diff --git a/hw/xen_nic.c b/hw/xen_nic.c index cf7d5591b3..dadacb1fb5 100644 --- a/hw/xen_nic.c +++ b/hw/xen_nic.c @@ -39,7 +39,6 @@ #include "net.h" #include "net/checksum.h" #include "net/util.h" -#include "qemu-char.h" #include "xen_backend.h" #include diff --git a/hw/xilinx_axidma.c b/hw/xilinx_axidma.c index 4575da1765..2fd6068428 100644 --- a/hw/xilinx_axidma.c +++ b/hw/xilinx_axidma.c @@ -23,7 +23,6 @@ */ #include "sysbus.h" -#include "qemu-char.h" #include "qemu-timer.h" #include "ptimer.h" #include "qemu-log.h" diff --git a/hw/xilinx_axienet.c b/hw/xilinx_axienet.c index f2e3bf1274..c859fde09e 100644 --- a/hw/xilinx_axienet.c +++ b/hw/xilinx_axienet.c @@ -23,7 +23,6 @@ */ #include "sysbus.h" -#include "qemu-char.h" #include "qemu-log.h" #include "net.h" #include "net/checksum.h" diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c index 4c42edc4ea..bc10d3161f 100644 --- a/hw/xtensa_lx60.c +++ b/hw/xtensa_lx60.c @@ -36,6 +36,7 @@ #include "sysbus.h" #include "flash.h" #include "blockdev.h" +#include "qemu-char.h" #include "xtensa_bootparam.h" typedef struct LxBoardDesc { diff --git a/iohandler.c b/iohandler.c index 60460a6f88..258f42d8d2 100644 --- a/iohandler.c +++ b/iohandler.c @@ -24,7 +24,6 @@ #include "config-host.h" #include "qemu-common.h" -#include "qemu-char.h" #include "qemu-queue.h" #include "qemu-aio.h" #include "main-loop.h" diff --git a/migration-exec.c b/migration-exec.c index 2b6fcb4262..b4a3ca3921 100644 --- a/migration-exec.c +++ b/migration-exec.c @@ -18,7 +18,6 @@ #include "qemu-common.h" #include "qemu_socket.h" #include "migration.h" -#include "qemu-char.h" #include "buffered_file.h" #include "block.h" #include diff --git a/migration-fd.c b/migration-fd.c index 5fe28e09fd..6d42287913 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -17,7 +17,6 @@ #include "qemu_socket.h" #include "migration.h" #include "monitor.h" -#include "qemu-char.h" #include "buffered_file.h" #include "block.h" #include "qemu_socket.h" diff --git a/migration-tcp.c b/migration-tcp.c index 5e855fe72f..a9bb817d99 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -16,7 +16,6 @@ #include "qemu-common.h" #include "qemu_socket.h" #include "migration.h" -#include "qemu-char.h" #include "buffered_file.h" #include "block.h" diff --git a/migration-unix.c b/migration-unix.c index dba72b4a54..e58e8bc15b 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -16,7 +16,6 @@ #include "qemu-common.h" #include "qemu_socket.h" #include "migration.h" -#include "qemu-char.h" #include "buffered_file.h" #include "block.h" diff --git a/monitor.h b/monitor.h index b4ef9559dc..4595c217ed 100644 --- a/monitor.h +++ b/monitor.h @@ -2,7 +2,6 @@ #define MONITOR_H #include "qemu-common.h" -#include "qemu-char.h" #include "qerror.h" #include "qdict.h" #include "block.h" diff --git a/net/slirp.c b/net/slirp.c index afb52c3af1..f117412bad 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -35,6 +35,7 @@ #include "monitor.h" #include "qemu_socket.h" #include "slirp/libslirp.h" +#include "qemu-char.h" static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) { diff --git a/net/socket.c b/net/socket.c index c01323d4b0..cf309cd5b9 100644 --- a/net/socket.c +++ b/net/socket.c @@ -26,7 +26,6 @@ #include "net.h" #include "clients.h" #include "monitor.h" -#include "qemu-char.h" #include "qemu-common.h" #include "qemu-error.h" #include "qemu-option.h" diff --git a/net/tap.c b/net/tap.c index 1abfd44bd9..5ff78934dc 100644 --- a/net/tap.c +++ b/net/tap.c @@ -37,7 +37,6 @@ #include "clients.h" #include "monitor.h" #include "sysemu.h" -#include "qemu-char.h" #include "qemu-common.h" #include "qemu-error.h" diff --git a/net/vde.c b/net/vde.c index 275bda92c3..cc5a07d65e 100644 --- a/net/vde.c +++ b/net/vde.c @@ -27,7 +27,6 @@ #include "net.h" #include "clients.h" -#include "qemu-char.h" #include "qemu-common.h" #include "qemu-option.h" diff --git a/qmp.c b/qmp.c index e3a7f0b217..e873f0a0dc 100644 --- a/qmp.c +++ b/qmp.c @@ -16,6 +16,7 @@ #include "qemu-common.h" #include "sysemu.h" #include "qmp-commands.h" +#include "qemu-char.h" #include "ui/qemu-spice.h" #include "ui/vnc.h" #include "kvm.h" diff --git a/savevm.c b/savevm.c index 5d04d59688..f5886ce772 100644 --- a/savevm.c +++ b/savevm.c @@ -76,7 +76,6 @@ #include "monitor.h" #include "sysemu.h" #include "qemu-timer.h" -#include "qemu-char.h" #include "audio/audio.h" #include "migration.h" #include "qemu_socket.h" diff --git a/ui/qemu-spice.h b/ui/qemu-spice.h index 3299da87d6..5857b8a92e 100644 --- a/ui/qemu-spice.h +++ b/ui/qemu-spice.h @@ -24,7 +24,6 @@ #include "qemu-option.h" #include "qemu-config.h" -#include "qemu-char.h" #include "monitor.h" extern int using_spice; -- cgit v1.2.3-55-g7522 From 1422e32db51ff2b1194fb24a6201c4310be5667d Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 24 Oct 2012 08:43:34 +0200 Subject: net: reorganize headers Move public headers to include/net, and leave private headers in net/. Put the virtio headers in include/net/tap.h, removing the multiple copies that existed. Leave include/net/tap.h as the interface for NICs, and net/tap_int.h as the interface for OS-specific parts of the tap backend. Signed-off-by: Paolo Bonzini --- hmp.c | 2 +- hw/axis_dev88.c | 2 +- hw/cadence_gem.c | 2 +- hw/dp8393x.c | 2 +- hw/e1000.c | 2 +- hw/eepro100.c | 2 +- hw/etraxfs.h | 2 +- hw/etraxfs_eth.c | 2 +- hw/exynos4_boards.c | 2 +- hw/gumstix.c | 2 +- hw/highbank.c | 2 +- hw/integratorcp.c | 2 +- hw/kzm.c | 2 +- hw/lan9118.c | 2 +- hw/lance.c | 2 +- hw/mainstone.c | 2 +- hw/mcf5208.c | 2 +- hw/mcf_fec.c | 2 +- hw/milkymist-hw.h | 2 +- hw/milkymist-minimac2.c | 2 +- hw/mips_fulong2e.c | 2 +- hw/mips_jazz.c | 2 +- hw/mips_malta.c | 2 +- hw/mips_mipssim.c | 2 +- hw/mips_r4k.c | 2 +- hw/mipsnet.c | 2 +- hw/musicpal.c | 2 +- hw/ne2000-isa.c | 2 +- hw/ne2000.c | 2 +- hw/opencores_eth.c | 2 +- hw/openrisc_sim.c | 2 +- hw/pc.h | 2 +- hw/pc_piix.c | 2 +- hw/pci/pci-hotplug.c | 2 +- hw/pci/pci.c | 2 +- hw/pcnet-pci.c | 2 +- hw/pcnet.c | 2 +- hw/petalogix_ml605_mmu.c | 2 +- hw/petalogix_s3adsp1800_mmu.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc440_bamboo.c | 2 +- hw/ppc_newworld.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/ppc_prep.c | 2 +- hw/qdev-properties.c | 2 +- hw/qdev.c | 2 +- hw/r2d.c | 2 +- hw/realview.c | 2 +- hw/rtl8139.c | 2 +- hw/s390-virtio.c | 2 +- hw/smc91c111.c | 2 +- hw/spapr.c | 2 +- hw/spapr_llan.c | 2 +- hw/stellaris.c | 2 +- hw/stellaris_enet.c | 2 +- hw/sun4m.c | 2 +- hw/sun4u.c | 2 +- hw/usb/dev-network.c | 2 +- hw/versatilepb.c | 2 +- hw/vexpress.c | 2 +- hw/vhost_net.c | 2 +- hw/vhost_net.h | 2 +- hw/virtio-net.c | 2 +- hw/virtio-net.h | 27 ------- hw/virtio.h | 2 +- hw/xen_backend.h | 2 +- hw/xen_nic.c | 2 +- hw/xgmac.c | 2 +- hw/xilinx.h | 2 +- hw/xilinx_axienet.c | 2 +- hw/xilinx_ethlite.c | 2 +- hw/xilinx_zynq.c | 2 +- hw/xtensa_lx60.c | 2 +- include/net/checksum.h | 29 +++++++ include/net/net.h | 175 ++++++++++++++++++++++++++++++++++++++++++ include/net/queue.h | 58 ++++++++++++++ include/net/slirp.h | 47 ++++++++++++ include/net/tap.h | 67 ++++++++++++++++ monitor.c | 2 +- net.h | 172 ----------------------------------------- net/checksum.h | 29 ------- net/clients.h | 2 +- net/hub.c | 2 +- net/hub.h | 2 - net/net.c | 4 +- net/queue.c | 2 +- net/queue.h | 58 -------------- net/slirp.c | 2 +- net/slirp.h | 47 ------------ net/socket.c | 2 +- net/tap-aix.c | 2 +- net/tap-bsd.c | 2 +- net/tap-haiku.c | 2 +- net/tap-linux.c | 3 +- net/tap-linux.h | 20 +---- net/tap-solaris.c | 2 +- net/tap-win32.c | 4 +- net/tap.c | 6 +- net/tap.h | 58 -------------- net/tap_int.h | 46 +++++++++++ net/util.c | 2 +- net/vde.c | 2 +- savevm.c | 2 +- vl.c | 2 +- 104 files changed, 519 insertions(+), 505 deletions(-) create mode 100644 include/net/checksum.h create mode 100644 include/net/net.h create mode 100644 include/net/queue.h create mode 100644 include/net/slirp.h create mode 100644 include/net/tap.h delete mode 100644 net.h delete mode 100644 net/checksum.h delete mode 100644 net/queue.h delete mode 100644 net/slirp.h delete mode 100644 net/tap.h create mode 100644 net/tap_int.h (limited to 'net/socket.c') diff --git a/hmp.c b/hmp.c index 873962f710..9b31e9f8a7 100644 --- a/hmp.c +++ b/hmp.c @@ -14,7 +14,7 @@ */ #include "hmp.h" -#include "net.h" +#include "net/net.h" #include "qemu-char.h" #include "qemu-option.h" #include "qemu-timer.h" diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c index aa1ac9e479..50ddbc920d 100644 --- a/hw/axis_dev88.c +++ b/hw/axis_dev88.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" -#include "net.h" +#include "net/net.h" #include "flash.h" #include "boards.h" #include "etraxfs.h" diff --git a/hw/cadence_gem.c b/hw/cadence_gem.c index 0c037a2993..40a239973c 100644 --- a/hw/cadence_gem.c +++ b/hw/cadence_gem.c @@ -25,7 +25,7 @@ #include /* For crc32 */ #include "sysbus.h" -#include "net.h" +#include "net/net.h" #include "net/checksum.h" #ifdef CADENCE_GEM_ERR_DEBUG diff --git a/hw/dp8393x.c b/hw/dp8393x.c index 3f6386eee8..d59b6118ad 100644 --- a/hw/dp8393x.c +++ b/hw/dp8393x.c @@ -19,7 +19,7 @@ #include "hw.h" #include "qemu-timer.h" -#include "net.h" +#include "net/net.h" #include "mips.h" //#define DEBUG_SONIC diff --git a/hw/e1000.c b/hw/e1000.c index c89c8d22ab..aeee3e61f4 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -27,7 +27,7 @@ #include "hw.h" #include "pci/pci.h" -#include "net.h" +#include "net/net.h" #include "net/checksum.h" #include "loader.h" #include "sysemu.h" diff --git a/hw/eepro100.c b/hw/eepro100.c index 992f03ace7..9e2be4ea0d 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -43,7 +43,7 @@ #include /* offsetof */ #include "hw.h" #include "pci/pci.h" -#include "net.h" +#include "net/net.h" #include "eeprom93xx.h" #include "sysemu.h" #include "dma.h" diff --git a/hw/etraxfs.h b/hw/etraxfs.h index 725bb9e142..bc60713633 100644 --- a/hw/etraxfs.h +++ b/hw/etraxfs.h @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "net.h" +#include "net/net.h" #include "etraxfs_dma.h" qemu_irq *cris_pic_init_cpu(CPUCRISState *env); diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c index 3d42426823..289a810edc 100644 --- a/hw/etraxfs_eth.c +++ b/hw/etraxfs_eth.c @@ -24,7 +24,7 @@ #include #include "sysbus.h" -#include "net.h" +#include "net/net.h" #include "etraxfs.h" #define D(x) diff --git a/hw/exynos4_boards.c b/hw/exynos4_boards.c index bc815bbae3..c375f16479 100644 --- a/hw/exynos4_boards.c +++ b/hw/exynos4_boards.c @@ -23,7 +23,7 @@ #include "sysemu.h" #include "sysbus.h" -#include "net.h" +#include "net/net.h" #include "arm-misc.h" #include "exec-memory.h" #include "exynos4210.h" diff --git a/hw/gumstix.c b/hw/gumstix.c index 4103a88b80..545b92fd95 100644 --- a/hw/gumstix.c +++ b/hw/gumstix.c @@ -36,7 +36,7 @@ #include "hw.h" #include "pxa.h" -#include "net.h" +#include "net/net.h" #include "flash.h" #include "devices.h" #include "boards.h" diff --git a/hw/highbank.c b/hw/highbank.c index 8e35127c8a..90f7cb5ef2 100644 --- a/hw/highbank.c +++ b/hw/highbank.c @@ -21,7 +21,7 @@ #include "arm-misc.h" #include "devices.h" #include "loader.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "boards.h" #include "sysbus.h" diff --git a/hw/integratorcp.c b/hw/integratorcp.c index 77807c39e3..2b59fea9f1 100644 --- a/hw/integratorcp.c +++ b/hw/integratorcp.c @@ -11,7 +11,7 @@ #include "devices.h" #include "boards.h" #include "arm-misc.h" -#include "net.h" +#include "net/net.h" #include "exec-memory.h" #include "sysemu.h" diff --git a/hw/kzm.c b/hw/kzm.c index 687daf3b2c..a27ecbba84 100644 --- a/hw/kzm.c +++ b/hw/kzm.c @@ -18,7 +18,7 @@ #include "hw.h" #include "arm-misc.h" #include "devices.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "boards.h" #include "serial.h" diff --git a/hw/lan9118.c b/hw/lan9118.c index f724e1c301..4c72d0d98e 100644 --- a/hw/lan9118.c +++ b/hw/lan9118.c @@ -11,7 +11,7 @@ */ #include "sysbus.h" -#include "net.h" +#include "net/net.h" #include "devices.h" #include "sysemu.h" #include "ptimer.h" diff --git a/hw/lance.c b/hw/lance.c index a3e6dd91d5..a384676158 100644 --- a/hw/lance.c +++ b/hw/lance.c @@ -36,7 +36,7 @@ */ #include "sysbus.h" -#include "net.h" +#include "net/net.h" #include "qemu-timer.h" #include "qemu_socket.h" #include "sun4m.h" diff --git a/hw/mainstone.c b/hw/mainstone.c index 5bbecb7304..58c8b0748e 100644 --- a/hw/mainstone.c +++ b/hw/mainstone.c @@ -14,7 +14,7 @@ #include "hw.h" #include "pxa.h" #include "arm-misc.h" -#include "net.h" +#include "net/net.h" #include "devices.h" #include "boards.h" #include "flash.h" diff --git a/hw/mcf5208.c b/hw/mcf5208.c index b1db54937e..6326624111 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -10,7 +10,7 @@ #include "qemu-timer.h" #include "ptimer.h" #include "sysemu.h" -#include "net.h" +#include "net/net.h" #include "boards.h" #include "loader.h" #include "elf.h" diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c index 1ed193c5db..b5fb18f67f 100644 --- a/hw/mcf_fec.c +++ b/hw/mcf_fec.c @@ -6,7 +6,7 @@ * This code is licensed under the GPL */ #include "hw.h" -#include "net.h" +#include "net/net.h" #include "mcf.h" /* For crc32 */ #include diff --git a/hw/milkymist-hw.h b/hw/milkymist-hw.h index 0253b7ab26..812ddd2bd1 100644 --- a/hw/milkymist-hw.h +++ b/hw/milkymist-hw.h @@ -3,7 +3,7 @@ #include "qdev.h" #include "qdev-addr.h" -#include "net.h" +#include "net/net.h" static inline DeviceState *milkymist_uart_create(hwaddr base, qemu_irq irq) diff --git a/hw/milkymist-minimac2.c b/hw/milkymist-minimac2.c index b204e5f890..926f7f9a8b 100644 --- a/hw/milkymist-minimac2.c +++ b/hw/milkymist-minimac2.c @@ -25,7 +25,7 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "net.h" +#include "net/net.h" #include "qemu-error.h" #include "qdev-addr.h" diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index d5cf33b4b6..bab96b27c1 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -22,7 +22,7 @@ #include "pc.h" #include "serial.h" #include "fdc.h" -#include "net.h" +#include "net/net.h" #include "boards.h" #include "smbus.h" #include "block.h" diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index ea1416ae2f..8e5e8ef1af 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -32,7 +32,7 @@ #include "sysemu.h" #include "arch_init.h" #include "boards.h" -#include "net.h" +#include "net/net.h" #include "esp.h" #include "mips-bios.h" #include "loader.h" diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 571903dfc5..3f9f171385 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -26,7 +26,7 @@ #include "pc.h" #include "serial.h" #include "fdc.h" -#include "net.h" +#include "net/net.h" #include "boards.h" #include "smbus.h" #include "block.h" diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c index 20b5f1a58c..78317426a7 100644 --- a/hw/mips_mipssim.c +++ b/hw/mips_mipssim.c @@ -29,7 +29,7 @@ #include "mips_cpudevs.h" #include "serial.h" #include "isa.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "boards.h" #include "mips-bios.h" diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 325098a43a..ec99d7d6a6 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -13,7 +13,7 @@ #include "pc.h" #include "serial.h" #include "isa.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "boards.h" #include "flash.h" diff --git a/hw/mipsnet.c b/hw/mipsnet.c index bece332c4e..bb752d3950 100644 --- a/hw/mipsnet.c +++ b/hw/mipsnet.c @@ -1,5 +1,5 @@ #include "hw.h" -#include "net.h" +#include "net/net.h" #include "trace.h" #include "sysbus.h" diff --git a/hw/musicpal.c b/hw/musicpal.c index e0c57c84eb..4e8399ab63 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -12,7 +12,7 @@ #include "sysbus.h" #include "arm-misc.h" #include "devices.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "boards.h" #include "serial.h" diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c index 69982a9abb..99477a412a 100644 --- a/hw/ne2000-isa.c +++ b/hw/ne2000-isa.c @@ -25,7 +25,7 @@ #include "pc.h" #include "isa.h" #include "qdev.h" -#include "net.h" +#include "net/net.h" #include "ne2000.h" #include "exec-memory.h" diff --git a/hw/ne2000.c b/hw/ne2000.c index fb78e5b252..2001264e14 100644 --- a/hw/ne2000.c +++ b/hw/ne2000.c @@ -23,7 +23,7 @@ */ #include "hw.h" #include "pci/pci.h" -#include "net.h" +#include "net/net.h" #include "ne2000.h" #include "loader.h" #include "sysemu.h" diff --git a/hw/opencores_eth.c b/hw/opencores_eth.c index b2780b9334..fd2f0f61c3 100644 --- a/hw/opencores_eth.c +++ b/hw/opencores_eth.c @@ -33,7 +33,7 @@ #include "hw.h" #include "sysbus.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/openrisc_sim.c b/hw/openrisc_sim.c index 23c66df1fb..a879fb0dd0 100644 --- a/hw/openrisc_sim.c +++ b/hw/openrisc_sim.c @@ -22,7 +22,7 @@ #include "boards.h" #include "elf.h" #include "serial.h" -#include "net.h" +#include "net/net.h" #include "loader.h" #include "exec-memory.h" #include "sysemu.h" diff --git a/hw/pc.h b/hw/pc.h index 2237e86446..5e4d103813 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -6,7 +6,7 @@ #include "ioport.h" #include "isa.h" #include "fdc.h" -#include "net.h" +#include "net/net.h" #include "memory.h" #include "ioapic.h" diff --git a/hw/pc_piix.c b/hw/pc_piix.c index c2b4cb07e5..7268dcd944 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -30,7 +30,7 @@ #include "pci/pci.h" #include "pci/pci_ids.h" #include "usb.h" -#include "net.h" +#include "net/net.h" #include "boards.h" #include "ide.h" #include "kvm.h" diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index 4b4c931c74..b850400252 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -25,7 +25,7 @@ #include "hw/hw.h" #include "hw/boards.h" #include "hw/pci/pci.h" -#include "net.h" +#include "net/net.h" #include "hw/pc.h" #include "monitor.h" #include "hw/scsi.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2e455e22d2..105fe9560e 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -26,7 +26,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" #include "monitor.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "hw/loader.h" #include "range.h" diff --git a/hw/pcnet-pci.c b/hw/pcnet-pci.c index c1abbf8d0d..c6768bcbdc 100644 --- a/hw/pcnet-pci.c +++ b/hw/pcnet-pci.c @@ -28,7 +28,7 @@ */ #include "pci/pci.h" -#include "net.h" +#include "net/net.h" #include "loader.h" #include "qemu-timer.h" #include "dma.h" diff --git a/hw/pcnet.c b/hw/pcnet.c index 54eecd01d3..5b03edecdd 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -36,7 +36,7 @@ */ #include "qdev.h" -#include "net.h" +#include "net/net.h" #include "qemu-timer.h" #include "qemu_socket.h" #include "sysemu.h" diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c index 3589a4bc7f..df51a74450 100644 --- a/hw/petalogix_ml605_mmu.c +++ b/hw/petalogix_ml605_mmu.c @@ -27,7 +27,7 @@ #include "sysbus.h" #include "hw.h" -#include "net.h" +#include "net/net.h" #include "flash.h" #include "sysemu.h" #include "devices.h" diff --git a/hw/petalogix_s3adsp1800_mmu.c b/hw/petalogix_s3adsp1800_mmu.c index c5fd5e793a..37b0d5595a 100644 --- a/hw/petalogix_s3adsp1800_mmu.c +++ b/hw/petalogix_s3adsp1800_mmu.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "hw.h" -#include "net.h" +#include "net/net.h" #include "flash.h" #include "sysemu.h" #include "devices.h" diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 2b1558b16e..4690bd8b00 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -18,7 +18,7 @@ #include "qemu-common.h" #include "e500.h" #include "e500-ccsr.h" -#include "net.h" +#include "net/net.h" #include "qemu-config.h" #include "hw/hw.h" #include "hw/serial.h" diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index 0b39a81ec5..5193a0c4be 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -13,7 +13,7 @@ #include "config.h" #include "qemu-common.h" -#include "net.h" +#include "net/net.h" #include "hw.h" #include "pci/pci.h" #include "boards.h" diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 2bf3094e9f..657f405f1b 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -53,7 +53,7 @@ #include "mac_dbdma.h" #include "nvram.h" #include "pci/pci.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "boards.h" #include "fw_cfg.h" diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index 3bc29c619c..a149306cc9 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -30,7 +30,7 @@ #include "mac_dbdma.h" #include "nvram.h" #include "sysemu.h" -#include "net.h" +#include "net/net.h" #include "isa.h" #include "pci/pci.h" #include "boards.h" diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index f6ffb593b7..25cc0490f9 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -26,7 +26,7 @@ #include "pc.h" #include "serial.h" #include "fdc.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "isa.h" #include "pci/pci.h" diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index b9cd3c0077..7ab55efe43 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -1,4 +1,4 @@ -#include "net.h" +#include "net/net.h" #include "qdev.h" #include "qerror.h" #include "blockdev.h" diff --git a/hw/qdev.c b/hw/qdev.c index 599382cab2..6b91fb987b 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -25,7 +25,7 @@ inherit from a particular bus (e.g. PCI or I2C) rather than this API directly. */ -#include "net.h" +#include "net/net.h" #include "qdev.h" #include "sysemu.h" #include "error.h" diff --git a/hw/r2d.c b/hw/r2d.c index e18c23b28b..b1c278f73f 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -30,7 +30,7 @@ #include "sysemu.h" #include "boards.h" #include "pci/pci.h" -#include "net.h" +#include "net/net.h" #include "sh7750_regs.h" #include "ide.h" #include "loader.h" diff --git a/hw/realview.c b/hw/realview.c index 5fbdcbf2b0..17d1ba2266 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -12,7 +12,7 @@ #include "primecell.h" #include "devices.h" #include "pci/pci.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "boards.h" #include "i2c.h" diff --git a/hw/rtl8139.c b/hw/rtl8139.c index e294a2a5e3..e024520b8b 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -55,7 +55,7 @@ #include "pci/pci.h" #include "dma.h" #include "qemu-timer.h" -#include "net.h" +#include "net/net.h" #include "loader.h" #include "sysemu.h" #include "iov.h" diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index 7aca0c4aad..8c724b942c 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -21,7 +21,7 @@ #include "block.h" #include "blockdev.h" #include "sysemu.h" -#include "net.h" +#include "net/net.h" #include "boards.h" #include "monitor.h" #include "loader.h" diff --git a/hw/smc91c111.c b/hw/smc91c111.c index 4ceed01a1a..2161b4af7a 100644 --- a/hw/smc91c111.c +++ b/hw/smc91c111.c @@ -8,7 +8,7 @@ */ #include "sysbus.h" -#include "net.h" +#include "net/net.h" #include "devices.h" /* For crc32 */ #include diff --git a/hw/spapr.c b/hw/spapr.c index 7306ab368a..395c4ac69b 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -27,7 +27,7 @@ #include "sysemu.h" #include "hw.h" #include "elf.h" -#include "net.h" +#include "net/net.h" #include "blockdev.h" #include "cpus.h" #include "kvm.h" diff --git a/hw/spapr_llan.c b/hw/spapr_llan.c index 09ad69f6b5..8077eb94bc 100644 --- a/hw/spapr_llan.c +++ b/hw/spapr_llan.c @@ -25,7 +25,7 @@ * */ #include "hw.h" -#include "net.h" +#include "net/net.h" #include "hw/qdev.h" #include "hw/spapr.h" #include "hw/spapr_vio.h" diff --git a/hw/stellaris.c b/hw/stellaris.c index b038f10f3a..f3eb4bbc01 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -13,7 +13,7 @@ #include "devices.h" #include "qemu-timer.h" #include "i2c.h" -#include "net.h" +#include "net/net.h" #include "boards.h" #include "exec-memory.h" diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c index a530b10598..d7e1e21ff9 100644 --- a/hw/stellaris_enet.c +++ b/hw/stellaris_enet.c @@ -7,7 +7,7 @@ * This code is licensed under the GPL. */ #include "sysbus.h" -#include "net.h" +#include "net/net.h" #include //#define DEBUG_STELLARIS_ENET 1 diff --git a/hw/sun4m.c b/hw/sun4m.c index 52cf82b681..9a784dfd04 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -28,7 +28,7 @@ #include "sparc32_dma.h" #include "fdc.h" #include "sysemu.h" -#include "net.h" +#include "net/net.h" #include "boards.h" #include "firmware_abi.h" #include "esp.h" diff --git a/hw/sun4u.c b/hw/sun4u.c index 47bcf9382d..d9e752fe83 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -28,7 +28,7 @@ #include "serial.h" #include "nvram.h" #include "fdc.h" -#include "net.h" +#include "net/net.h" #include "qemu-timer.h" #include "sysemu.h" #include "boards.h" diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 0552e6f438..bf289ff5a6 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -26,7 +26,7 @@ #include "qemu-common.h" #include "hw/usb.h" #include "hw/usb/desc.h" -#include "net.h" +#include "net/net.h" #include "qemu-queue.h" #include "qemu-config.h" #include "sysemu.h" diff --git a/hw/versatilepb.c b/hw/versatilepb.c index f5a742b37f..af398d9cca 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -10,7 +10,7 @@ #include "sysbus.h" #include "arm-misc.h" #include "devices.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "pci/pci.h" #include "i2c.h" diff --git a/hw/vexpress.c b/hw/vexpress.c index e89694c86e..5c9c08b991 100644 --- a/hw/vexpress.c +++ b/hw/vexpress.c @@ -25,7 +25,7 @@ #include "arm-misc.h" #include "primecell.h" #include "devices.h" -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "boards.h" #include "exec-memory.h" diff --git a/hw/vhost_net.c b/hw/vhost_net.c index 8241601539..93ad89a11c 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -13,7 +13,7 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "net.h" +#include "net/net.h" #include "net/tap.h" #include "virtio-net.h" diff --git a/hw/vhost_net.h b/hw/vhost_net.h index a9db23423c..012aba4148 100644 --- a/hw/vhost_net.h +++ b/hw/vhost_net.h @@ -1,7 +1,7 @@ #ifndef VHOST_NET_H #define VHOST_NET_H -#include "net.h" +#include "net/net.h" struct vhost_net; typedef struct vhost_net VHostNetState; diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 108ce07cfc..dc7c6d6b56 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -13,7 +13,7 @@ #include "iov.h" #include "virtio.h" -#include "net.h" +#include "net/net.h" #include "net/checksum.h" #include "net/tap.h" #include "qemu-error.h" diff --git a/hw/virtio-net.h b/hw/virtio-net.h index 2566ea13ec..d46fb9840f 100644 --- a/hw/virtio-net.h +++ b/hw/virtio-net.h @@ -73,33 +73,6 @@ struct virtio_net_config uint16_t status; } QEMU_PACKED; -/* This is the first element of the scatter-gather list. If you don't - * specify GSO or CSUM features, you can simply ignore the header. */ -struct virtio_net_hdr -{ -#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset -#define VIRTIO_NET_HDR_F_DATA_VALID 2 // Csum is valid - uint8_t flags; -#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame -#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO) -#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO) -#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP -#define VIRTIO_NET_HDR_GSO_ECN 0x80 // TCP has ECN set - uint8_t gso_type; - uint16_t hdr_len; - uint16_t gso_size; - uint16_t csum_start; - uint16_t csum_offset; -}; - -/* This is the version of the header to use when the MRG_RXBUF - * feature has been negotiated. */ -struct virtio_net_hdr_mrg_rxbuf -{ - struct virtio_net_hdr hdr; - uint16_t num_buffers; /* Number of merged rx buffers */ -}; - /* * Control virtqueue data structures * diff --git a/hw/virtio.h b/hw/virtio.h index 7c17f7ba0b..cdcb490733 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -15,7 +15,7 @@ #define _QEMU_VIRTIO_H #include "hw.h" -#include "net.h" +#include "net/net.h" #include "qdev.h" #include "sysemu.h" #include "event_notifier.h" diff --git a/hw/xen_backend.h b/hw/xen_backend.h index 3305630903..92ab501d37 100644 --- a/hw/xen_backend.h +++ b/hw/xen_backend.h @@ -3,7 +3,7 @@ #include "xen_common.h" #include "sysemu.h" -#include "net.h" +#include "net/net.h" /* ------------------------------------------------------------- */ diff --git a/hw/xen_nic.c b/hw/xen_nic.c index dadacb1fb5..dc12110dba 100644 --- a/hw/xen_nic.c +++ b/hw/xen_nic.c @@ -36,7 +36,7 @@ #include #include "hw.h" -#include "net.h" +#include "net/net.h" #include "net/checksum.h" #include "net/util.h" #include "xen_backend.h" diff --git a/hw/xgmac.c b/hw/xgmac.c index ec50c745d0..d0d510ed6a 100644 --- a/hw/xgmac.c +++ b/hw/xgmac.c @@ -27,7 +27,7 @@ #include "sysbus.h" #include "qemu-char.h" #include "qemu-log.h" -#include "net.h" +#include "net/net.h" #include "net/checksum.h" #ifdef DEBUG_XGMAC diff --git a/hw/xilinx.h b/hw/xilinx.h index 9323fd07c6..735f8e257d 100644 --- a/hw/xilinx.h +++ b/hw/xilinx.h @@ -1,6 +1,6 @@ #include "stream.h" #include "qemu-common.h" -#include "net.h" +#include "net/net.h" static inline DeviceState * xilinx_intc_create(hwaddr base, qemu_irq irq, int kind_of_intr) diff --git a/hw/xilinx_axienet.c b/hw/xilinx_axienet.c index c859fde09e..35979e65c9 100644 --- a/hw/xilinx_axienet.c +++ b/hw/xilinx_axienet.c @@ -24,7 +24,7 @@ #include "sysbus.h" #include "qemu-log.h" -#include "net.h" +#include "net/net.h" #include "net/checksum.h" #include "stream.h" diff --git a/hw/xilinx_ethlite.c b/hw/xilinx_ethlite.c index 13bd45613d..4de4a53a0b 100644 --- a/hw/xilinx_ethlite.c +++ b/hw/xilinx_ethlite.c @@ -24,7 +24,7 @@ #include "sysbus.h" #include "hw.h" -#include "net.h" +#include "net/net.h" #define D(x) #define R_TX_BUF0 0 diff --git a/hw/xilinx_zynq.c b/hw/xilinx_zynq.c index 9ca22a4e7d..67adc52725 100644 --- a/hw/xilinx_zynq.c +++ b/hw/xilinx_zynq.c @@ -17,7 +17,7 @@ #include "sysbus.h" #include "arm-misc.h" -#include "net.h" +#include "net/net.h" #include "exec-memory.h" #include "sysemu.h" #include "boards.h" diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c index bc10d3161f..0399de777e 100644 --- a/hw/xtensa_lx60.c +++ b/hw/xtensa_lx60.c @@ -32,7 +32,7 @@ #include "memory.h" #include "exec-memory.h" #include "serial.h" -#include "net.h" +#include "net/net.h" #include "sysbus.h" #include "flash.h" #include "blockdev.h" diff --git a/include/net/checksum.h b/include/net/checksum.h new file mode 100644 index 0000000000..1f052986e6 --- /dev/null +++ b/include/net/checksum.h @@ -0,0 +1,29 @@ +/* + * IP checksumming functions. + * (c) 2008 Gerd Hoffmann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef QEMU_NET_CHECKSUM_H +#define QEMU_NET_CHECKSUM_H + +#include + +uint32_t net_checksum_add(int len, uint8_t *buf); +uint16_t net_checksum_finish(uint32_t sum); +uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, + uint8_t *addrs, uint8_t *buf); +void net_checksum_calculate(uint8_t *data, int length); + +#endif /* QEMU_NET_CHECKSUM_H */ diff --git a/include/net/net.h b/include/net/net.h new file mode 100644 index 0000000000..9ff9305d7a --- /dev/null +++ b/include/net/net.h @@ -0,0 +1,175 @@ +#ifndef QEMU_NET_H +#define QEMU_NET_H + +#include "qemu-queue.h" +#include "qemu-common.h" +#include "qdict.h" +#include "qemu-option.h" +#include "net/queue.h" +#include "vmstate.h" +#include "qapi-types.h" + +struct MACAddr { + uint8_t a[6]; +}; + +/* qdev nic properties */ + +typedef struct NICConf { + MACAddr macaddr; + NetClientState *peer; + int32_t bootindex; +} NICConf; + +#define DEFINE_NIC_PROPERTIES(_state, _conf) \ + DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \ + DEFINE_PROP_VLAN("vlan", _state, _conf.peer), \ + DEFINE_PROP_NETDEV("netdev", _state, _conf.peer), \ + DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1) + +/* Net clients */ + +typedef void (NetPoll)(NetClientState *, bool enable); +typedef int (NetCanReceive)(NetClientState *); +typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t); +typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int); +typedef void (NetCleanup) (NetClientState *); +typedef void (LinkStatusChanged)(NetClientState *); + +typedef struct NetClientInfo { + NetClientOptionsKind type; + size_t size; + NetReceive *receive; + NetReceive *receive_raw; + NetReceiveIOV *receive_iov; + NetCanReceive *can_receive; + NetCleanup *cleanup; + LinkStatusChanged *link_status_changed; + NetPoll *poll; +} NetClientInfo; + +struct NetClientState { + NetClientInfo *info; + int link_down; + QTAILQ_ENTRY(NetClientState) next; + NetClientState *peer; + NetQueue *send_queue; + char *model; + char *name; + char info_str[256]; + unsigned receive_disabled : 1; +}; + +typedef struct NICState { + NetClientState nc; + NICConf *conf; + void *opaque; + bool peer_deleted; +} NICState; + +NetClientState *qemu_find_netdev(const char *id); +NetClientState *qemu_new_net_client(NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name); +NICState *qemu_new_nic(NetClientInfo *info, + NICConf *conf, + const char *model, + const char *name, + void *opaque); +void qemu_del_net_client(NetClientState *nc); +NetClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id, + const char *client_str); +typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque); +void qemu_foreach_nic(qemu_nic_foreach func, void *opaque); +int qemu_can_send_packet(NetClientState *nc); +ssize_t qemu_sendv_packet(NetClientState *nc, const struct iovec *iov, + int iovcnt); +ssize_t qemu_sendv_packet_async(NetClientState *nc, const struct iovec *iov, + int iovcnt, NetPacketSent *sent_cb); +void qemu_send_packet(NetClientState *nc, const uint8_t *buf, int size); +ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size); +ssize_t qemu_send_packet_async(NetClientState *nc, const uint8_t *buf, + int size, NetPacketSent *sent_cb); +void qemu_purge_queued_packets(NetClientState *nc); +void qemu_flush_queued_packets(NetClientState *nc); +void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); +void qemu_macaddr_default_if_unset(MACAddr *macaddr); +int qemu_show_nic_models(const char *arg, const char *const *models); +void qemu_check_nic_model(NICInfo *nd, const char *model); +int qemu_find_nic_model(NICInfo *nd, const char * const *models, + const char *default_model); + +ssize_t qemu_deliver_packet(NetClientState *sender, + unsigned flags, + const uint8_t *data, + size_t size, + void *opaque); +ssize_t qemu_deliver_packet_iov(NetClientState *sender, + unsigned flags, + const struct iovec *iov, + int iovcnt, + void *opaque); + +void print_net_client(Monitor *mon, NetClientState *nc); +void do_info_network(Monitor *mon); + +/* NIC info */ + +#define MAX_NICS 8 + +struct NICInfo { + MACAddr macaddr; + char *model; + char *name; + char *devaddr; + NetClientState *netdev; + int used; /* is this slot in nd_table[] being used? */ + int instantiated; /* does this NICInfo correspond to an instantiated NIC? */ + int nvectors; +}; + +extern int nb_nics; +extern NICInfo nd_table[MAX_NICS]; +extern int default_net; + +/* from net.c */ +extern const char *legacy_tftp_prefix; +extern const char *legacy_bootp_filename; + +int net_client_init(QemuOpts *opts, int is_netdev, Error **errp); +int net_client_parse(QemuOptsList *opts_list, const char *str); +int net_init_clients(void); +void net_check_clients(void); +void net_cleanup(void); +void net_host_device_add(Monitor *mon, const QDict *qdict); +void net_host_device_remove(Monitor *mon, const QDict *qdict); +void netdev_add(QemuOpts *opts, Error **errp); +int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret); + +int net_hub_id_for_client(NetClientState *nc, int *id); +NetClientState *net_hub_port_find(int hub_id); + +#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" +#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" +#define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper" +#define DEFAULT_BRIDGE_INTERFACE "br0" + +void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); + +#define POLYNOMIAL 0x04c11db6 +unsigned compute_mcast_idx(const uint8_t *ep); + +#define vmstate_offset_macaddr(_state, _field) \ + vmstate_offset_array(_state, _field.a, uint8_t, \ + sizeof(typeof_field(_state, _field))) + +#define VMSTATE_MACADDR(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(MACAddr), \ + .info = &vmstate_info_buffer, \ + .flags = VMS_BUFFER, \ + .offset = vmstate_offset_macaddr(_state, _field), \ +} + +#endif diff --git a/include/net/queue.h b/include/net/queue.h new file mode 100644 index 0000000000..fc02b33915 --- /dev/null +++ b/include/net/queue.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_NET_QUEUE_H +#define QEMU_NET_QUEUE_H + +#include "qemu-common.h" + +typedef struct NetPacket NetPacket; +typedef struct NetQueue NetQueue; + +typedef void (NetPacketSent) (NetClientState *sender, ssize_t ret); + +#define QEMU_NET_PACKET_FLAG_NONE 0 +#define QEMU_NET_PACKET_FLAG_RAW (1<<0) + +NetQueue *qemu_new_net_queue(void *opaque); + +void qemu_del_net_queue(NetQueue *queue); + +ssize_t qemu_net_queue_send(NetQueue *queue, + NetClientState *sender, + unsigned flags, + const uint8_t *data, + size_t size, + NetPacketSent *sent_cb); + +ssize_t qemu_net_queue_send_iov(NetQueue *queue, + NetClientState *sender, + unsigned flags, + const struct iovec *iov, + int iovcnt, + NetPacketSent *sent_cb); + +void qemu_net_queue_purge(NetQueue *queue, NetClientState *from); +bool qemu_net_queue_flush(NetQueue *queue); + +#endif /* QEMU_NET_QUEUE_H */ diff --git a/include/net/slirp.h b/include/net/slirp.h new file mode 100644 index 0000000000..2ca09b65b7 --- /dev/null +++ b/include/net/slirp.h @@ -0,0 +1,47 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef QEMU_NET_SLIRP_H +#define QEMU_NET_SLIRP_H + +#include "qemu-common.h" +#include "qdict.h" +#include "qemu-option.h" +#include "qapi-types.h" + +#ifdef CONFIG_SLIRP + +void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict); +void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict); + +int net_slirp_redir(const char *redir_str); + +int net_slirp_parse_legacy(QemuOptsList *opts_list, const char *optarg, int *ret); + +int net_slirp_smb(const char *exported_dir); + +void do_info_usernet(Monitor *mon); + +#endif + +#endif /* QEMU_NET_SLIRP_H */ diff --git a/include/net/tap.h b/include/net/tap.h new file mode 100644 index 0000000000..bb7efb5439 --- /dev/null +++ b/include/net/tap.h @@ -0,0 +1,67 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_NET_TAP_H +#define QEMU_NET_TAP_H + +#include "qemu-common.h" +#include "qapi-types.h" + +int tap_has_ufo(NetClientState *nc); +int tap_has_vnet_hdr(NetClientState *nc); +int tap_has_vnet_hdr_len(NetClientState *nc, int len); +void tap_using_vnet_hdr(NetClientState *nc, int using_vnet_hdr); +void tap_set_offload(NetClientState *nc, int csum, int tso4, int tso6, int ecn, int ufo); +void tap_set_vnet_hdr_len(NetClientState *nc, int len); + +int tap_get_fd(NetClientState *nc); + +struct vhost_net; +struct vhost_net *tap_get_vhost_net(NetClientState *nc); + +struct virtio_net_hdr +{ +#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset +#define VIRTIO_NET_HDR_F_DATA_VALID 2 // Csum is valid + uint8_t flags; +#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame +#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO) +#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO) +#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP +#define VIRTIO_NET_HDR_GSO_ECN 0x80 // TCP has ECN set + uint8_t gso_type; + uint16_t hdr_len; + uint16_t gso_size; + uint16_t csum_start; + uint16_t csum_offset; +}; + +struct virtio_net_hdr_mrg_rxbuf +{ + struct virtio_net_hdr hdr; + uint16_t num_buffers; /* Number of merged rx buffers */ +}; + +#endif /* QEMU_NET_TAP_H */ diff --git a/monitor.c b/monitor.c index bd63768c27..37b9d20299 100644 --- a/monitor.c +++ b/monitor.c @@ -31,7 +31,7 @@ #include "hw/watchdog.h" #include "hw/loader.h" #include "gdbstub.h" -#include "net.h" +#include "net/net.h" #include "net/slirp.h" #include "qemu-char.h" #include "ui/qemu-spice.h" diff --git a/net.h b/net.h deleted file mode 100644 index 1d0816bc0a..0000000000 --- a/net.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef QEMU_NET_H -#define QEMU_NET_H - -#include "qemu-queue.h" -#include "qemu-common.h" -#include "qdict.h" -#include "qemu-option.h" -#include "net/queue.h" -#include "vmstate.h" -#include "qapi-types.h" - -struct MACAddr { - uint8_t a[6]; -}; - -/* qdev nic properties */ - -typedef struct NICConf { - MACAddr macaddr; - NetClientState *peer; - int32_t bootindex; -} NICConf; - -#define DEFINE_NIC_PROPERTIES(_state, _conf) \ - DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \ - DEFINE_PROP_VLAN("vlan", _state, _conf.peer), \ - DEFINE_PROP_NETDEV("netdev", _state, _conf.peer), \ - DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1) - -/* Net clients */ - -typedef void (NetPoll)(NetClientState *, bool enable); -typedef int (NetCanReceive)(NetClientState *); -typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t); -typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int); -typedef void (NetCleanup) (NetClientState *); -typedef void (LinkStatusChanged)(NetClientState *); - -typedef struct NetClientInfo { - NetClientOptionsKind type; - size_t size; - NetReceive *receive; - NetReceive *receive_raw; - NetReceiveIOV *receive_iov; - NetCanReceive *can_receive; - NetCleanup *cleanup; - LinkStatusChanged *link_status_changed; - NetPoll *poll; -} NetClientInfo; - -struct NetClientState { - NetClientInfo *info; - int link_down; - QTAILQ_ENTRY(NetClientState) next; - NetClientState *peer; - NetQueue *send_queue; - char *model; - char *name; - char info_str[256]; - unsigned receive_disabled : 1; -}; - -typedef struct NICState { - NetClientState nc; - NICConf *conf; - void *opaque; - bool peer_deleted; -} NICState; - -NetClientState *qemu_find_netdev(const char *id); -NetClientState *qemu_new_net_client(NetClientInfo *info, - NetClientState *peer, - const char *model, - const char *name); -NICState *qemu_new_nic(NetClientInfo *info, - NICConf *conf, - const char *model, - const char *name, - void *opaque); -void qemu_del_net_client(NetClientState *nc); -NetClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id, - const char *client_str); -typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque); -void qemu_foreach_nic(qemu_nic_foreach func, void *opaque); -int qemu_can_send_packet(NetClientState *nc); -ssize_t qemu_sendv_packet(NetClientState *nc, const struct iovec *iov, - int iovcnt); -ssize_t qemu_sendv_packet_async(NetClientState *nc, const struct iovec *iov, - int iovcnt, NetPacketSent *sent_cb); -void qemu_send_packet(NetClientState *nc, const uint8_t *buf, int size); -ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size); -ssize_t qemu_send_packet_async(NetClientState *nc, const uint8_t *buf, - int size, NetPacketSent *sent_cb); -void qemu_purge_queued_packets(NetClientState *nc); -void qemu_flush_queued_packets(NetClientState *nc); -void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); -void qemu_macaddr_default_if_unset(MACAddr *macaddr); -int qemu_show_nic_models(const char *arg, const char *const *models); -void qemu_check_nic_model(NICInfo *nd, const char *model); -int qemu_find_nic_model(NICInfo *nd, const char * const *models, - const char *default_model); - -ssize_t qemu_deliver_packet(NetClientState *sender, - unsigned flags, - const uint8_t *data, - size_t size, - void *opaque); -ssize_t qemu_deliver_packet_iov(NetClientState *sender, - unsigned flags, - const struct iovec *iov, - int iovcnt, - void *opaque); - -void print_net_client(Monitor *mon, NetClientState *nc); -void do_info_network(Monitor *mon); - -/* NIC info */ - -#define MAX_NICS 8 - -struct NICInfo { - MACAddr macaddr; - char *model; - char *name; - char *devaddr; - NetClientState *netdev; - int used; /* is this slot in nd_table[] being used? */ - int instantiated; /* does this NICInfo correspond to an instantiated NIC? */ - int nvectors; -}; - -extern int nb_nics; -extern NICInfo nd_table[MAX_NICS]; -extern int default_net; - -/* from net.c */ -extern const char *legacy_tftp_prefix; -extern const char *legacy_bootp_filename; - -int net_client_init(QemuOpts *opts, int is_netdev, Error **errp); -int net_client_parse(QemuOptsList *opts_list, const char *str); -int net_init_clients(void); -void net_check_clients(void); -void net_cleanup(void); -void net_host_device_add(Monitor *mon, const QDict *qdict); -void net_host_device_remove(Monitor *mon, const QDict *qdict); -void netdev_add(QemuOpts *opts, Error **errp); -int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret); - -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" -#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" -#define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper" -#define DEFAULT_BRIDGE_INTERFACE "br0" - -void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); - -#define POLYNOMIAL 0x04c11db6 -unsigned compute_mcast_idx(const uint8_t *ep); - -#define vmstate_offset_macaddr(_state, _field) \ - vmstate_offset_array(_state, _field.a, uint8_t, \ - sizeof(typeof_field(_state, _field))) - -#define VMSTATE_MACADDR(_field, _state) { \ - .name = (stringify(_field)), \ - .size = sizeof(MACAddr), \ - .info = &vmstate_info_buffer, \ - .flags = VMS_BUFFER, \ - .offset = vmstate_offset_macaddr(_state, _field), \ -} - -#endif diff --git a/net/checksum.h b/net/checksum.h deleted file mode 100644 index 1f052986e6..0000000000 --- a/net/checksum.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * IP checksumming functions. - * (c) 2008 Gerd Hoffmann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; under version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -#ifndef QEMU_NET_CHECKSUM_H -#define QEMU_NET_CHECKSUM_H - -#include - -uint32_t net_checksum_add(int len, uint8_t *buf); -uint16_t net_checksum_finish(uint32_t sum); -uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, - uint8_t *addrs, uint8_t *buf); -void net_checksum_calculate(uint8_t *data, int length); - -#endif /* QEMU_NET_CHECKSUM_H */ diff --git a/net/clients.h b/net/clients.h index c58cc6087c..77932942bd 100644 --- a/net/clients.h +++ b/net/clients.h @@ -24,7 +24,7 @@ #ifndef QEMU_NET_CLIENTS_H #define QEMU_NET_CLIENTS_H -#include "net.h" +#include "net/net.h" #include "qapi-types.h" int net_init_dump(const NetClientOptions *opts, const char *name, diff --git a/net/hub.c b/net/hub.c index be413012bb..8508ecf380 100644 --- a/net/hub.c +++ b/net/hub.c @@ -13,7 +13,7 @@ */ #include "monitor.h" -#include "net.h" +#include "net/net.h" #include "clients.h" #include "hub.h" #include "iov.h" diff --git a/net/hub.h b/net/hub.h index 4cbfdb128b..583ada89d8 100644 --- a/net/hub.h +++ b/net/hub.h @@ -20,8 +20,6 @@ NetClientState *net_hub_add_port(int hub_id, const char *name); NetClientState *net_hub_find_client_by_name(int hub_id, const char *name); void net_hub_info(Monitor *mon); -int net_hub_id_for_client(NetClientState *nc, int *id); void net_hub_check_clients(void); -NetClientState *net_hub_port_find(int hub_id); #endif /* NET_HUB_H */ diff --git a/net/net.c b/net/net.c index 7b1600f17c..a4395be140 100644 --- a/net/net.c +++ b/net/net.c @@ -23,10 +23,10 @@ */ #include "config-host.h" -#include "net.h" +#include "net/net.h" #include "clients.h" #include "hub.h" -#include "slirp.h" +#include "net/slirp.h" #include "util.h" #include "monitor.h" diff --git a/net/queue.c b/net/queue.c index 254f28013a..542c549b1a 100644 --- a/net/queue.c +++ b/net/queue.c @@ -23,7 +23,7 @@ #include "net/queue.h" #include "qemu-queue.h" -#include "net.h" +#include "net/net.h" /* The delivery handler may only return zero if it will call * qemu_net_queue_flush() when it determines that it is once again able diff --git a/net/queue.h b/net/queue.h deleted file mode 100644 index fc02b33915..0000000000 --- a/net/queue.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2009 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_NET_QUEUE_H -#define QEMU_NET_QUEUE_H - -#include "qemu-common.h" - -typedef struct NetPacket NetPacket; -typedef struct NetQueue NetQueue; - -typedef void (NetPacketSent) (NetClientState *sender, ssize_t ret); - -#define QEMU_NET_PACKET_FLAG_NONE 0 -#define QEMU_NET_PACKET_FLAG_RAW (1<<0) - -NetQueue *qemu_new_net_queue(void *opaque); - -void qemu_del_net_queue(NetQueue *queue); - -ssize_t qemu_net_queue_send(NetQueue *queue, - NetClientState *sender, - unsigned flags, - const uint8_t *data, - size_t size, - NetPacketSent *sent_cb); - -ssize_t qemu_net_queue_send_iov(NetQueue *queue, - NetClientState *sender, - unsigned flags, - const struct iovec *iov, - int iovcnt, - NetPacketSent *sent_cb); - -void qemu_net_queue_purge(NetQueue *queue, NetClientState *from); -bool qemu_net_queue_flush(NetQueue *queue); - -#endif /* QEMU_NET_QUEUE_H */ diff --git a/net/slirp.c b/net/slirp.c index f117412bad..5a11ac5859 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -29,7 +29,7 @@ #include #include #endif -#include "net.h" +#include "net/net.h" #include "clients.h" #include "hub.h" #include "monitor.h" diff --git a/net/slirp.h b/net/slirp.h deleted file mode 100644 index 2ca09b65b7..0000000000 --- a/net/slirp.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef QEMU_NET_SLIRP_H -#define QEMU_NET_SLIRP_H - -#include "qemu-common.h" -#include "qdict.h" -#include "qemu-option.h" -#include "qapi-types.h" - -#ifdef CONFIG_SLIRP - -void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict); -void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict); - -int net_slirp_redir(const char *redir_str); - -int net_slirp_parse_legacy(QemuOptsList *opts_list, const char *optarg, int *ret); - -int net_slirp_smb(const char *exported_dir); - -void do_info_usernet(Monitor *mon); - -#endif - -#endif /* QEMU_NET_SLIRP_H */ diff --git a/net/socket.c b/net/socket.c index cf309cd5b9..8430f1a161 100644 --- a/net/socket.c +++ b/net/socket.c @@ -23,7 +23,7 @@ */ #include "config-host.h" -#include "net.h" +#include "net/net.h" #include "clients.h" #include "monitor.h" #include "qemu-common.h" diff --git a/net/tap-aix.c b/net/tap-aix.c index f27c17729e..aff6c527e9 100644 --- a/net/tap-aix.c +++ b/net/tap-aix.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "net/tap.h" +#include "tap_int.h" #include int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required) diff --git a/net/tap-bsd.c b/net/tap-bsd.c index a3b717dd1c..a1c55ad3de 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "net/tap.h" +#include "tap_int.h" #include "qemu-common.h" #include "sysemu.h" #include "qemu-error.h" diff --git a/net/tap-haiku.c b/net/tap-haiku.c index 34739d1562..08cc034cee 100644 --- a/net/tap-haiku.c +++ b/net/tap-haiku.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "net/tap.h" +#include "tap_int.h" #include int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required) diff --git a/net/tap-linux.c b/net/tap-linux.c index 3eaedc40ad..3de7b3b6ce 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -23,8 +23,9 @@ * THE SOFTWARE. */ +#include "tap_int.h" +#include "tap-linux.h" #include "net/tap.h" -#include "net/tap-linux.h" #include #include diff --git a/net/tap-linux.h b/net/tap-linux.h index 659e98122b..cb2a6d480a 100644 --- a/net/tap-linux.h +++ b/net/tap-linux.h @@ -13,8 +13,8 @@ * GNU General Public License for more details. */ -#ifndef QEMU_TAP_H -#define QEMU_TAP_H +#ifndef QEMU_TAP_LINUX_H +#define QEMU_TAP_LINUX_H #include #ifdef __linux__ @@ -44,20 +44,4 @@ #define TUN_F_TSO_ECN 0x08 /* I can handle TSO with ECN bits. */ #define TUN_F_UFO 0x10 /* I can handle UFO packets */ -struct virtio_net_hdr -{ - uint8_t flags; - uint8_t gso_type; - uint16_t hdr_len; - uint16_t gso_size; - uint16_t csum_start; - uint16_t csum_offset; -}; - -struct virtio_net_hdr_mrg_rxbuf -{ - struct virtio_net_hdr hdr; - uint16_t num_buffers; /* Number of merged rx buffers */ -}; - #endif /* QEMU_TAP_H */ diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 5d6ac42f24..f228fffb6d 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "net/tap.h" +#include "tap_int.h" #include "sysemu.h" #include diff --git a/net/tap-win32.c b/net/tap-win32.c index f9bd74109c..e37d8ee458 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -26,11 +26,11 @@ * distribution); if not, see . */ -#include "tap.h" +#include "tap_int.h" #include "qemu-common.h" #include "clients.h" /* net_init_tap */ -#include "net.h" +#include "net/net.h" #include "sysemu.h" #include "qemu-error.h" #include diff --git a/net/tap.c b/net/tap.c index 5ff78934dc..f8cabc4f86 100644 --- a/net/tap.c +++ b/net/tap.c @@ -23,7 +23,7 @@ * THE SOFTWARE. */ -#include "tap.h" +#include "tap_int.h" #include "config-host.h" @@ -33,14 +33,14 @@ #include #include -#include "net.h" +#include "net/net.h" #include "clients.h" #include "monitor.h" #include "sysemu.h" #include "qemu-common.h" #include "qemu-error.h" -#include "net/tap-linux.h" +#include "net/tap.h" #include "hw/vhost_net.h" diff --git a/net/tap.h b/net/tap.h deleted file mode 100644 index d44d83ae73..0000000000 --- a/net/tap.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2009 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_NET_TAP_H -#define QEMU_NET_TAP_H - -#include "qemu-common.h" -#include "qapi-types.h" - -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" -#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" - -int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required); - -ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen); - -int tap_has_ufo(NetClientState *nc); -int tap_has_vnet_hdr(NetClientState *nc); -int tap_has_vnet_hdr_len(NetClientState *nc, int len); -void tap_using_vnet_hdr(NetClientState *nc, int using_vnet_hdr); -void tap_set_offload(NetClientState *nc, int csum, int tso4, int tso6, int ecn, int ufo); -void tap_set_vnet_hdr_len(NetClientState *nc, int len); - -int tap_set_sndbuf(int fd, const NetdevTapOptions *tap); -int tap_probe_vnet_hdr(int fd); -int tap_probe_vnet_hdr_len(int fd, int len); -int tap_probe_has_ufo(int fd); -void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo); -void tap_fd_set_vnet_hdr_len(int fd, int len); - -int tap_get_fd(NetClientState *nc); - -struct vhost_net; -struct vhost_net *tap_get_vhost_net(NetClientState *nc); - -#endif /* QEMU_NET_TAP_H */ diff --git a/net/tap_int.h b/net/tap_int.h new file mode 100644 index 0000000000..1dffe12a45 --- /dev/null +++ b/net/tap_int.h @@ -0,0 +1,46 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_TAP_H +#define QEMU_TAP_H + +#include "qemu-common.h" +#include "qapi-types.h" + +#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" +#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" + +int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required); + +ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen); + +int tap_set_sndbuf(int fd, const NetdevTapOptions *tap); +int tap_probe_vnet_hdr(int fd); +int tap_probe_vnet_hdr_len(int fd, int len); +int tap_probe_has_ufo(int fd); +void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo); +void tap_fd_set_vnet_hdr_len(int fd, int len); + +#endif /* QEMU_TAP_H */ diff --git a/net/util.c b/net/util.c index 1e9afbc1ae..7e9507679d 100644 --- a/net/util.c +++ b/net/util.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "net/util.h" +#include "util.h" #include #include diff --git a/net/vde.c b/net/vde.c index cc5a07d65e..52d4f19fba 100644 --- a/net/vde.c +++ b/net/vde.c @@ -25,7 +25,7 @@ #include -#include "net.h" +#include "net/net.h" #include "clients.h" #include "qemu-common.h" #include "qemu-option.h" diff --git a/savevm.c b/savevm.c index f5886ce772..ae8787868f 100644 --- a/savevm.c +++ b/savevm.c @@ -72,7 +72,7 @@ #include "qemu-common.h" #include "hw/hw.h" #include "hw/qdev.h" -#include "net.h" +#include "net/net.h" #include "monitor.h" #include "sysemu.h" #include "qemu-timer.h" diff --git a/vl.c b/vl.c index 571a49b931..a7eeafc26e 100644 --- a/vl.c +++ b/vl.c @@ -127,7 +127,7 @@ int main(int argc, char **argv) #include "hw/qdev.h" #include "hw/loader.h" #include "bt-host.h" -#include "net.h" +#include "net/net.h" #include "net/slirp.h" #include "monitor.h" #include "console.h" -- cgit v1.2.3-55-g7522 From 83c9089e73b81c69dc1ecdf859fa84d2c500fb5f Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:19:49 +0100 Subject: monitor: move include files to include/monitor/ Signed-off-by: Paolo Bonzini --- arch_init.c | 2 +- audio/audio.c | 2 +- audio/wavcapture.c | 2 +- balloon.c | 2 +- balloon.h | 2 +- block.c | 2 +- blockdev-nbd.c | 2 +- blockdev.c | 2 +- blockjob.c | 2 +- cpus.c | 2 +- disas.c | 2 +- dump.c | 2 +- gdbstub.c | 2 +- hmp.c | 2 +- hw/acpi.c | 2 +- hw/ccid-card-emulated.c | 2 +- hw/ccid-card-passthru.c | 2 +- hw/device-hotplug.c | 2 +- hw/i8259.c | 2 +- hw/ide/ahci.c | 2 +- hw/isa-bus.c | 2 +- hw/kvm/pci-assign.c | 2 +- hw/lm32_pic.c | 2 +- hw/loader.c | 2 +- hw/pc.c | 2 +- hw/pci/pci-hotplug.c | 2 +- hw/pci/pci-stub.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pcie_aer.c | 2 +- hw/qdev-monitor.c | 2 +- hw/qdev-monitor.h | 2 +- hw/qxl.c | 2 +- hw/s390-virtio-bus.c | 2 +- hw/s390-virtio.c | 2 +- hw/s390x/event-facility.c | 2 +- hw/slavio_intctl.c | 2 +- hw/spapr_vio.c | 2 +- hw/sun4c_intctl.c | 2 +- hw/sysbus.c | 2 +- hw/usb/bus.c | 2 +- hw/usb/dev-smartcard-reader.c | 2 +- hw/usb/dev-storage.c | 2 +- hw/usb/hcd-ehci.h | 2 +- hw/usb/host-bsd.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/host-stub.c | 2 +- hw/usb/redirect.c | 2 +- hw/virtio-serial-bus.c | 2 +- hw/watchdog.c | 2 +- include/block/block_int.h | 2 +- include/monitor/monitor.h | 101 ++++++++++++++++++++++++++++++++++++++++++ include/monitor/readline.h | 55 +++++++++++++++++++++++ include/ui/console.h | 2 +- include/ui/qemu-spice.h | 4 +- migration-fd.c | 2 +- migration.c | 2 +- monitor.c | 4 +- monitor.h | 101 ------------------------------------------ net/hub.c | 2 +- net/net.c | 2 +- net/slirp.c | 2 +- net/socket.c | 2 +- net/tap.c | 2 +- osdep.c | 2 +- qemu-char.c | 2 +- qemu-error.c | 2 +- qemu-sockets.c | 2 +- qemu-timer.c | 2 +- qemu-tool.c | 2 +- qemu-user.c | 2 +- qerror.c | 2 +- readline.c | 4 +- readline.h | 55 ----------------------- savevm.c | 2 +- slirp/misc.c | 4 +- stubs/fdset-add-fd.c | 2 +- stubs/fdset-find-fd.c | 2 +- stubs/fdset-get-fd.c | 2 +- stubs/fdset-remove-fd.c | 2 +- stubs/get-fd.c | 2 +- target-i386/helper.c | 2 +- ui/input.c | 2 +- ui/spice-core.c | 2 +- ui/spice-display.c | 2 +- ui/vnc.h | 2 +- vl.c | 2 +- 86 files changed, 242 insertions(+), 242 deletions(-) create mode 100644 include/monitor/monitor.h create mode 100644 include/monitor/readline.h delete mode 100644 monitor.h delete mode 100644 readline.h (limited to 'net/socket.c') diff --git a/arch_init.c b/arch_init.c index e15cedad04..93d1e52f4a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -29,7 +29,7 @@ #include #endif #include "config.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "bitops.h" #include "bitmap.h" diff --git a/audio/audio.c b/audio/audio.c index 1c7738930b..a0cc727020 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -23,7 +23,7 @@ */ #include "hw/hw.h" #include "audio.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-timer.h" #include "sysemu.h" diff --git a/audio/wavcapture.c b/audio/wavcapture.c index 4f785f5f49..9d94623225 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -1,5 +1,5 @@ #include "hw/hw.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "audio.h" typedef struct { diff --git a/balloon.c b/balloon.c index c24458b5f9..d1de4352b4 100644 --- a/balloon.c +++ b/balloon.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "monitor.h" +#include "monitor/monitor.h" #include "exec/cpu-common.h" #include "kvm.h" #include "balloon.h" diff --git a/balloon.h b/balloon.h index b803a00741..bd9d39505d 100644 --- a/balloon.h +++ b/balloon.h @@ -14,7 +14,7 @@ #ifndef _QEMU_BALLOON_H #define _QEMU_BALLOON_H -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi-types.h" typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target); diff --git a/block.c b/block.c index 5eab9e2519..0e7f18c6d3 100644 --- a/block.c +++ b/block.c @@ -24,7 +24,7 @@ #include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" #include "module.h" diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 81aa1d34ef..596b47499d 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -11,7 +11,7 @@ #include "blockdev.h" #include "hw/block-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "sysemu.h" #include "qmp-commands.h" diff --git a/blockdev.c b/blockdev.c index ff6b333f69..a2308fa718 100644 --- a/blockdev.c +++ b/blockdev.c @@ -10,7 +10,7 @@ #include "blockdev.h" #include "hw/block-common.h" #include "block/blockjob.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "qemu-option.h" #include "qemu-config.h" diff --git a/blockjob.c b/blockjob.c index 004480d714..4bc60c7378 100644 --- a/blockjob.c +++ b/blockjob.c @@ -26,7 +26,7 @@ #include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "block/block.h" #include "block/blockjob.h" #include "block/block_int.h" diff --git a/cpus.c b/cpus.c index 8926873ad1..3a66401e0d 100644 --- a/cpus.c +++ b/cpus.c @@ -25,7 +25,7 @@ /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "exec/gdbstub.h" #include "dma.h" diff --git a/disas.c b/disas.c index 8157b96fc1..a46faeed80 100644 --- a/disas.c +++ b/disas.c @@ -374,7 +374,7 @@ const char *lookup_symbol(target_ulong orig_addr) #if !defined(CONFIG_USER_ONLY) -#include "monitor.h" +#include "monitor/monitor.h" static int monitor_disas_is_physical; diff --git a/dump.c b/dump.c index e70e0f3b21..871ee1727a 100644 --- a/dump.c +++ b/dump.c @@ -16,7 +16,7 @@ #include "cpu.h" #include "exec/cpu-all.h" #include "exec/hwaddr.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "kvm.h" #include "dump.h" #include "sysemu.h" diff --git a/gdbstub.c b/gdbstub.c index 70ad79a748..9395c829a2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -29,7 +29,7 @@ #include "qemu.h" #else -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-char.h" #include "sysemu.h" #include "exec/gdbstub.h" diff --git a/hmp.c b/hmp.c index f235134bb6..a76a8f06ea 100644 --- a/hmp.c +++ b/hmp.c @@ -20,7 +20,7 @@ #include "qemu-timer.h" #include "qmp-commands.h" #include "qemu_socket.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" static void hmp_handle_error(Monitor *mon, Error **errp) diff --git a/hw/acpi.c b/hw/acpi.c index ae29a59077..fe9b76a9b0 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -22,7 +22,7 @@ #include "hw.h" #include "pc.h" #include "acpi.h" -#include "monitor.h" +#include "monitor/monitor.h" struct acpi_table_header { uint16_t _length; /* our length, not actual part of the hdr */ diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c index f4a6da4283..845a764446 100644 --- a/hw/ccid-card-emulated.c +++ b/hw/ccid-card-emulated.c @@ -33,7 +33,7 @@ #include "qemu-thread.h" #include "qemu-char.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/ccid.h" #define DPRINTF(card, lvl, fmt, ...) \ diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c index bd6c77777d..f5b4794e90 100644 --- a/hw/ccid-card-passthru.c +++ b/hw/ccid-card-passthru.c @@ -10,7 +10,7 @@ #include "qemu-char.h" #include "qemu_socket.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/ccid.h" #include "libcacard/vscard_common.h" diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 336ffc2274..809a598e3a 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -27,7 +27,7 @@ #include "blockdev.h" #include "qemu-config.h" #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" DriveInfo *add_init_drive(const char *optstr) { diff --git a/hw/i8259.c b/hw/i8259.c index af0ba4d7c6..5e935e7f99 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -24,7 +24,7 @@ #include "hw.h" #include "pc.h" #include "isa.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-timer.h" #include "i8259_internal.h" diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index f32a84761d..d38c6e4574 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -27,7 +27,7 @@ #include #include -#include "monitor.h" +#include "monitor/monitor.h" #include "dma.h" #include "exec/cpu-common.h" #include "internal.h" diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 8f40974166..a2be67df56 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ #include "hw.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" #include "sysemu.h" #include "isa.h" diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index 2629775589..ff0dc0dfd4 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -31,7 +31,7 @@ #include "qemu-error.h" #include "ui/console.h" #include "hw/loader.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "range.h" #include "sysemu.h" #include "hw/pci/pci.h" diff --git a/hw/lm32_pic.c b/hw/lm32_pic.c index 32f65db7f1..42d5602cf0 100644 --- a/hw/lm32_pic.c +++ b/hw/lm32_pic.c @@ -21,7 +21,7 @@ #include "hw.h" #include "pc.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" #include "trace.h" #include "lm32_pic.h" diff --git a/hw/loader.c b/hw/loader.c index 03f0318d91..f5ef575b52 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -44,7 +44,7 @@ #include "hw.h" #include "disas/disas.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "uboot_image.h" #include "loader.h" diff --git a/hw/pc.c b/hw/pc.c index 2452fd4214..7aaff0f2fd 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -28,7 +28,7 @@ #include "fdc.h" #include "ide.h" #include "pci/pci.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "fw_cfg.h" #include "hpet_emul.h" #include "smbios.h" diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index 5ba7558ecd..e5e8a7ab58 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -27,7 +27,7 @@ #include "hw/pci/pci.h" #include "net/net.h" #include "hw/pc.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/scsi.h" #include "hw/virtio-blk.h" #include "qemu-config.h" diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c index b5c43a935b..5891dc959d 100644 --- a/hw/pci/pci-stub.c +++ b/hw/pci/pci-stub.c @@ -19,7 +19,7 @@ */ #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/pci/pci.h" #include "qmp-commands.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fa0f08eb0a..e062f66088 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -25,7 +25,7 @@ #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "net/net.h" #include "sysemu.h" #include "hw/loader.h" diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index b6f4f8510f..f7f3633f5b 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -20,7 +20,7 @@ #include "sysemu.h" #include "qapi/qmp/types.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pcie.h" #include "hw/pci/msix.h" diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 5aaf74b98a..207282c4a4 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -18,7 +18,7 @@ */ #include "qdev.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qmp-commands.h" #include "arch_init.h" #include "qemu-config.h" diff --git a/hw/qdev-monitor.h b/hw/qdev-monitor.h index 220ceba4c5..fae1b1ec84 100644 --- a/hw/qdev-monitor.h +++ b/hw/qdev-monitor.h @@ -2,7 +2,7 @@ #define QEMU_QDEV_MONITOR_H #include "qdev-core.h" -#include "monitor.h" +#include "monitor/monitor.h" /*** monitor commands ***/ diff --git a/hw/qxl.c b/hw/qxl.c index 96887c4aad..ad0214827e 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -23,7 +23,7 @@ #include "qemu-common.h" #include "qemu-timer.h" #include "qemu-queue.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c index f7e1939288..769015c136 100644 --- a/hw/s390-virtio-bus.c +++ b/hw/s390-virtio-bus.c @@ -21,7 +21,7 @@ #include "block/block.h" #include "sysemu.h" #include "boards.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/virtio.h" diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index 0a15625b73..7dfe87ade3 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -23,7 +23,7 @@ #include "sysemu.h" #include "net/net.h" #include "boards.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/virtio.h" diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index bc9cea9e1b..748118d0f0 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -15,7 +15,7 @@ * */ -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "sclp.h" diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c index 6aafa8b233..a44ce95c1f 100644 --- a/hw/slavio_intctl.c +++ b/hw/slavio_intctl.c @@ -23,7 +23,7 @@ */ #include "sun4m.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c index 1f19fedd0e..fdf8db9158 100644 --- a/hw/spapr_vio.c +++ b/hw/spapr_vio.c @@ -22,7 +22,7 @@ #include "hw.h" #include "sysemu.h" #include "boards.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/sysbus.h" diff --git a/hw/sun4c_intctl.c b/hw/sun4c_intctl.c index 702e9f5444..b78d54f232 100644 --- a/hw/sun4c_intctl.c +++ b/hw/sun4c_intctl.c @@ -24,7 +24,7 @@ #include "hw.h" #include "sun4m.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" //#define DEBUG_IRQ_COUNT diff --git a/hw/sysbus.c b/hw/sysbus.c index 7ab250463c..49a41775f8 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -18,7 +18,7 @@ */ #include "sysbus.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "exec/address-spaces.h" static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent); diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 8264c240ee..74728c94e5 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -2,7 +2,7 @@ #include "hw/usb.h" #include "hw/qdev.h" #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "trace.h" static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent); diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index de955b709f..3862c9b6c9 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -38,7 +38,7 @@ #include "qemu-error.h" #include "hw/usb.h" #include "hw/usb/desc.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/ccid.h" diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index de56fea610..0d7597b4d1 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -14,7 +14,7 @@ #include "hw/usb/desc.h" #include "hw/scsi.h" #include "ui/console.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "blockdev.h" diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 837c63be85..740f7309fb 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -20,7 +20,7 @@ #include "hw/hw.h" #include "qemu-timer.h" #include "hw/usb.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "trace.h" #include "dma.h" #include "sysemu.h" diff --git a/hw/usb/host-bsd.c b/hw/usb/host-bsd.c index dae0009378..340c21aeb4 100644 --- a/hw/usb/host-bsd.c +++ b/hw/usb/host-bsd.c @@ -25,7 +25,7 @@ */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/usb.h" /* usb.h declares these */ diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index bdafb6bc87..5a56e99891 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -32,7 +32,7 @@ #include "qemu-common.h" #include "qemu-timer.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/usb/host-stub.c b/hw/usb/host-stub.c index e8da3221f6..58423a0f5c 100644 --- a/hw/usb/host-stub.c +++ b/hw/usb/host-stub.c @@ -33,7 +33,7 @@ #include "qemu-common.h" #include "ui/console.h" #include "hw/usb.h" -#include "monitor.h" +#include "monitor/monitor.h" void usb_host_info(Monitor *mon) { diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 9e7f6453f7..3621076020 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -27,7 +27,7 @@ #include "qemu-common.h" #include "qemu-timer.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "iov.h" diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 155da58dcd..5559518a93 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -19,7 +19,7 @@ */ #include "iov.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-queue.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/watchdog.c b/hw/watchdog.c index f878bec860..623b299f71 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -24,7 +24,7 @@ #include "qemu-config.h" #include "qemu-queue.h" #include "qapi/qmp/types.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "hw/watchdog.h" diff --git a/include/block/block_int.h b/include/block/block_int.h index d06de2637b..14c57afd54 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -31,7 +31,7 @@ #include "qemu-timer.h" #include "qapi-types.h" #include "qapi/qmp/qerror.h" -#include "monitor.h" +#include "monitor/monitor.h" #define BLOCK_FLAG_ENCRYPT 1 #define BLOCK_FLAG_COMPAT6 4 diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h new file mode 100644 index 0000000000..87fb49c092 --- /dev/null +++ b/include/monitor/monitor.h @@ -0,0 +1,101 @@ +#ifndef MONITOR_H +#define MONITOR_H + +#include "qemu-common.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qmp/qdict.h" +#include "block/block.h" +#include "monitor/readline.h" + +extern Monitor *cur_mon; +extern Monitor *default_mon; + +/* flags for monitor_init */ +#define MONITOR_IS_DEFAULT 0x01 +#define MONITOR_USE_READLINE 0x02 +#define MONITOR_USE_CONTROL 0x04 +#define MONITOR_USE_PRETTY 0x08 + +/* flags for monitor commands */ +#define MONITOR_CMD_ASYNC 0x0001 + +/* QMP events */ +typedef enum MonitorEvent { + QEVENT_SHUTDOWN, + QEVENT_RESET, + QEVENT_POWERDOWN, + QEVENT_STOP, + QEVENT_RESUME, + QEVENT_VNC_CONNECTED, + QEVENT_VNC_INITIALIZED, + QEVENT_VNC_DISCONNECTED, + QEVENT_BLOCK_IO_ERROR, + QEVENT_RTC_CHANGE, + QEVENT_WATCHDOG, + QEVENT_SPICE_CONNECTED, + QEVENT_SPICE_INITIALIZED, + QEVENT_SPICE_DISCONNECTED, + QEVENT_BLOCK_JOB_COMPLETED, + QEVENT_BLOCK_JOB_CANCELLED, + QEVENT_BLOCK_JOB_ERROR, + QEVENT_BLOCK_JOB_READY, + QEVENT_DEVICE_TRAY_MOVED, + QEVENT_SUSPEND, + QEVENT_SUSPEND_DISK, + QEVENT_WAKEUP, + QEVENT_BALLOON_CHANGE, + QEVENT_SPICE_MIGRATE_COMPLETED, + + /* Add to 'monitor_event_names' array in monitor.c when + * defining new events here */ + + QEVENT_MAX, +} MonitorEvent; + +int monitor_cur_is_qmp(void); + +void monitor_protocol_event(MonitorEvent event, QObject *data); +void monitor_init(CharDriverState *chr, int flags); + +int monitor_suspend(Monitor *mon); +void monitor_resume(Monitor *mon); + +int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, + BlockDriverCompletionFunc *completion_cb, + void *opaque); +int monitor_read_block_device_key(Monitor *mon, const char *device, + BlockDriverCompletionFunc *completion_cb, + void *opaque); + +int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); +int monitor_handle_fd_param(Monitor *mon, const char *fdname); + +void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) + GCC_FMT_ATTR(2, 0); +void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +void monitor_print_filename(Monitor *mon, const char *filename); +void monitor_flush(Monitor *mon); +int monitor_set_cpu(int cpu_index); +int monitor_get_cpu_index(void); + +typedef void (MonitorCompletion)(void *opaque, QObject *ret_data); + +void monitor_set_error(Monitor *mon, QError *qerror); +void monitor_read_command(Monitor *mon, int show_prompt); +ReadLineState *monitor_get_rs(Monitor *mon); +int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, + void *opaque); + +int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret); + +int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret); + +AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, + bool has_opaque, const char *opaque, + Error **errp); +int monitor_fdset_get_fd(int64_t fdset_id, int flags); +int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); +int monitor_fdset_dup_fd_remove(int dup_fd); +int monitor_fdset_dup_fd_find(int dup_fd); + +#endif /* !MONITOR_H */ diff --git a/include/monitor/readline.h b/include/monitor/readline.h new file mode 100644 index 0000000000..fc9806ecf1 --- /dev/null +++ b/include/monitor/readline.h @@ -0,0 +1,55 @@ +#ifndef READLINE_H +#define READLINE_H + +#include "qemu-common.h" + +#define READLINE_CMD_BUF_SIZE 4095 +#define READLINE_MAX_CMDS 64 +#define READLINE_MAX_COMPLETIONS 256 + +typedef void ReadLineFunc(Monitor *mon, const char *str, void *opaque); +typedef void ReadLineCompletionFunc(const char *cmdline); + +typedef struct ReadLineState { + char cmd_buf[READLINE_CMD_BUF_SIZE + 1]; + int cmd_buf_index; + int cmd_buf_size; + + char last_cmd_buf[READLINE_CMD_BUF_SIZE + 1]; + int last_cmd_buf_index; + int last_cmd_buf_size; + + int esc_state; + int esc_param; + + char *history[READLINE_MAX_CMDS]; + int hist_entry; + + ReadLineCompletionFunc *completion_finder; + char *completions[READLINE_MAX_COMPLETIONS]; + int nb_completions; + int completion_index; + + ReadLineFunc *readline_func; + void *readline_opaque; + int read_password; + char prompt[256]; + Monitor *mon; +} ReadLineState; + +void readline_add_completion(ReadLineState *rs, const char *str); +void readline_set_completion_index(ReadLineState *rs, int completion_index); + +const char *readline_get_history(ReadLineState *rs, unsigned int index); + +void readline_handle_byte(ReadLineState *rs, int ch); + +void readline_start(ReadLineState *rs, const char *prompt, int read_password, + ReadLineFunc *readline_func, void *opaque); +void readline_restart(ReadLineState *rs); +void readline_show_prompt(ReadLineState *rs); + +ReadLineState *readline_init(Monitor *mon, + ReadLineCompletionFunc *completion_finder); + +#endif /* !READLINE_H */ diff --git a/include/ui/console.h b/include/ui/console.h index eff5cc92d6..3db6635b0a 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -4,7 +4,7 @@ #include "ui/qemu-pixman.h" #include "qapi/qmp/qdict.h" #include "notify.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "trace.h" #include "qapi-types.h" #include "qapi/error.h" diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 5857b8a92e..3e08be06bf 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -24,7 +24,7 @@ #include "qemu-option.h" #include "qemu-config.h" -#include "monitor.h" +#include "monitor/monitor.h" extern int using_spice; @@ -47,7 +47,7 @@ void do_info_spice(Monitor *mon, QObject **ret_data); CharDriverState *qemu_chr_open_spice(QemuOpts *opts); #else /* CONFIG_SPICE */ -#include "monitor.h" +#include "monitor/monitor.h" #define using_spice 0 static inline int qemu_spice_set_passwd(const char *passwd, diff --git a/migration-fd.c b/migration-fd.c index e86228823f..73a1dfcc93 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -16,7 +16,7 @@ #include "qemu-common.h" #include "qemu_socket.h" #include "migration.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "buffered_file.h" #include "block/block.h" #include "qemu_socket.h" diff --git a/migration.c b/migration.c index 1fce152548..27a272eace 100644 --- a/migration.c +++ b/migration.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "migration.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "buffered_file.h" #include "sysemu.h" #include "block/block.h" diff --git a/monitor.c b/monitor.c index a3e010968e..94c6bb6672 100644 --- a/monitor.c +++ b/monitor.c @@ -36,8 +36,8 @@ #include "qemu-char.h" #include "ui/qemu-spice.h" #include "sysemu.h" -#include "monitor.h" -#include "readline.h" +#include "monitor/monitor.h" +#include "monitor/readline.h" #include "ui/console.h" #include "blockdev.h" #include "audio/audio.h" diff --git a/monitor.h b/monitor.h deleted file mode 100644 index 9e96e83f5f..0000000000 --- a/monitor.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef MONITOR_H -#define MONITOR_H - -#include "qemu-common.h" -#include "qapi/qmp/qerror.h" -#include "qapi/qmp/qdict.h" -#include "block/block.h" -#include "readline.h" - -extern Monitor *cur_mon; -extern Monitor *default_mon; - -/* flags for monitor_init */ -#define MONITOR_IS_DEFAULT 0x01 -#define MONITOR_USE_READLINE 0x02 -#define MONITOR_USE_CONTROL 0x04 -#define MONITOR_USE_PRETTY 0x08 - -/* flags for monitor commands */ -#define MONITOR_CMD_ASYNC 0x0001 - -/* QMP events */ -typedef enum MonitorEvent { - QEVENT_SHUTDOWN, - QEVENT_RESET, - QEVENT_POWERDOWN, - QEVENT_STOP, - QEVENT_RESUME, - QEVENT_VNC_CONNECTED, - QEVENT_VNC_INITIALIZED, - QEVENT_VNC_DISCONNECTED, - QEVENT_BLOCK_IO_ERROR, - QEVENT_RTC_CHANGE, - QEVENT_WATCHDOG, - QEVENT_SPICE_CONNECTED, - QEVENT_SPICE_INITIALIZED, - QEVENT_SPICE_DISCONNECTED, - QEVENT_BLOCK_JOB_COMPLETED, - QEVENT_BLOCK_JOB_CANCELLED, - QEVENT_BLOCK_JOB_ERROR, - QEVENT_BLOCK_JOB_READY, - QEVENT_DEVICE_TRAY_MOVED, - QEVENT_SUSPEND, - QEVENT_SUSPEND_DISK, - QEVENT_WAKEUP, - QEVENT_BALLOON_CHANGE, - QEVENT_SPICE_MIGRATE_COMPLETED, - - /* Add to 'monitor_event_names' array in monitor.c when - * defining new events here */ - - QEVENT_MAX, -} MonitorEvent; - -int monitor_cur_is_qmp(void); - -void monitor_protocol_event(MonitorEvent event, QObject *data); -void monitor_init(CharDriverState *chr, int flags); - -int monitor_suspend(Monitor *mon); -void monitor_resume(Monitor *mon); - -int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, - BlockDriverCompletionFunc *completion_cb, - void *opaque); -int monitor_read_block_device_key(Monitor *mon, const char *device, - BlockDriverCompletionFunc *completion_cb, - void *opaque); - -int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); -int monitor_handle_fd_param(Monitor *mon, const char *fdname); - -void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) - GCC_FMT_ATTR(2, 0); -void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -void monitor_print_filename(Monitor *mon, const char *filename); -void monitor_flush(Monitor *mon); -int monitor_set_cpu(int cpu_index); -int monitor_get_cpu_index(void); - -typedef void (MonitorCompletion)(void *opaque, QObject *ret_data); - -void monitor_set_error(Monitor *mon, QError *qerror); -void monitor_read_command(Monitor *mon, int show_prompt); -ReadLineState *monitor_get_rs(Monitor *mon); -int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, - void *opaque); - -int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret); - -int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret); - -AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, - bool has_opaque, const char *opaque, - Error **errp); -int monitor_fdset_get_fd(int64_t fdset_id, int flags); -int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); -int monitor_fdset_dup_fd_remove(int dup_fd); -int monitor_fdset_dup_fd_find(int dup_fd); - -#endif /* !MONITOR_H */ diff --git a/net/hub.c b/net/hub.c index 8508ecf380..81a73b54a7 100644 --- a/net/hub.c +++ b/net/hub.c @@ -12,7 +12,7 @@ * */ -#include "monitor.h" +#include "monitor/monitor.h" #include "net/net.h" #include "clients.h" #include "hub.h" diff --git a/net/net.c b/net/net.c index ead7e96fe1..e4d85a9cfa 100644 --- a/net/net.c +++ b/net/net.c @@ -29,7 +29,7 @@ #include "net/slirp.h" #include "util.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-common.h" #include "qemu_socket.h" #include "qemu-config.h" diff --git a/net/slirp.c b/net/slirp.c index 5a11ac5859..c37a5ef959 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -32,7 +32,7 @@ #include "net/net.h" #include "clients.h" #include "hub.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu_socket.h" #include "slirp/libslirp.h" #include "qemu-char.h" diff --git a/net/socket.c b/net/socket.c index 8430f1a161..bc2b951832 100644 --- a/net/socket.c +++ b/net/socket.c @@ -25,7 +25,7 @@ #include "net/net.h" #include "clients.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-common.h" #include "qemu-error.h" #include "qemu-option.h" diff --git a/net/tap.c b/net/tap.c index f8cabc4f86..9a677e9864 100644 --- a/net/tap.c +++ b/net/tap.c @@ -35,7 +35,7 @@ #include "net/net.h" #include "clients.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "qemu-common.h" #include "qemu-error.h" diff --git a/osdep.c b/osdep.c index 3a63d26e75..807e90cf97 100644 --- a/osdep.c +++ b/osdep.c @@ -48,7 +48,7 @@ extern int madvise(caddr_t, size_t, int); #include "qemu-common.h" #include "trace.h" #include "qemu_socket.h" -#include "monitor.h" +#include "monitor/monitor.h" static bool fips_enabled = false; diff --git a/qemu-char.c b/qemu-char.c index bc53d09a9b..16021c5a43 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" #include "qemu-timer.h" diff --git a/qemu-error.c b/qemu-error.c index 7cd5ffe1e9..08a36f480c 100644 --- a/qemu-error.c +++ b/qemu-error.c @@ -11,7 +11,7 @@ */ #include -#include "monitor.h" +#include "monitor/monitor.h" /* * Print to current monitor if we have one, else to stderr. diff --git a/qemu-sockets.c b/qemu-sockets.c index c52a40a411..cea0a4b8ac 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -22,7 +22,7 @@ #include #include -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu_socket.h" #include "qemu-common.h" /* for qemu_isdigit */ #include "main-loop.h" diff --git a/qemu-timer.c b/qemu-timer.c index 5a99403fda..8e0dccc087 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -23,7 +23,7 @@ */ #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "hw/hw.h" diff --git a/qemu-tool.c b/qemu-tool.c index b46631e422..40453fdd99 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-timer.h" #include "qemu-log.h" #include "migration.h" diff --git a/qemu-user.c b/qemu-user.c index 08ccb0fe8e..f8b450c03d 100644 --- a/qemu-user.c +++ b/qemu-user.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" Monitor *cur_mon; diff --git a/qerror.c b/qerror.c index 8c78104277..3aee1cf6a6 100644 --- a/qerror.c +++ b/qerror.c @@ -10,7 +10,7 @@ * See the COPYING.LIB file in the top-level directory. */ -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qerror.h" #include "qemu-common.h" diff --git a/readline.c b/readline.c index 540cd8a025..5fc9643c2b 100644 --- a/readline.c +++ b/readline.c @@ -21,8 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "readline.h" -#include "monitor.h" +#include "monitor/readline.h" +#include "monitor/monitor.h" #define IS_NORM 0 #define IS_ESC 1 diff --git a/readline.h b/readline.h deleted file mode 100644 index fc9806ecf1..0000000000 --- a/readline.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef READLINE_H -#define READLINE_H - -#include "qemu-common.h" - -#define READLINE_CMD_BUF_SIZE 4095 -#define READLINE_MAX_CMDS 64 -#define READLINE_MAX_COMPLETIONS 256 - -typedef void ReadLineFunc(Monitor *mon, const char *str, void *opaque); -typedef void ReadLineCompletionFunc(const char *cmdline); - -typedef struct ReadLineState { - char cmd_buf[READLINE_CMD_BUF_SIZE + 1]; - int cmd_buf_index; - int cmd_buf_size; - - char last_cmd_buf[READLINE_CMD_BUF_SIZE + 1]; - int last_cmd_buf_index; - int last_cmd_buf_size; - - int esc_state; - int esc_param; - - char *history[READLINE_MAX_CMDS]; - int hist_entry; - - ReadLineCompletionFunc *completion_finder; - char *completions[READLINE_MAX_COMPLETIONS]; - int nb_completions; - int completion_index; - - ReadLineFunc *readline_func; - void *readline_opaque; - int read_password; - char prompt[256]; - Monitor *mon; -} ReadLineState; - -void readline_add_completion(ReadLineState *rs, const char *str); -void readline_set_completion_index(ReadLineState *rs, int completion_index); - -const char *readline_get_history(ReadLineState *rs, unsigned int index); - -void readline_handle_byte(ReadLineState *rs, int ch); - -void readline_start(ReadLineState *rs, const char *prompt, int read_password, - ReadLineFunc *readline_func, void *opaque); -void readline_restart(ReadLineState *rs); -void readline_show_prompt(ReadLineState *rs); - -ReadLineState *readline_init(Monitor *mon, - ReadLineCompletionFunc *completion_finder); - -#endif /* !READLINE_H */ diff --git a/savevm.c b/savevm.c index cb33501ecc..bf341bb25f 100644 --- a/savevm.c +++ b/savevm.c @@ -73,7 +73,7 @@ #include "hw/hw.h" #include "hw/qdev.h" #include "net/net.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "qemu-timer.h" #include "audio/audio.h" diff --git a/slirp/misc.c b/slirp/misc.c index 664532a663..d4df972d13 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -8,7 +8,7 @@ #include #include -#include "monitor.h" +#include "monitor/monitor.h" #ifdef DEBUG int slirp_debug = DBG_CALL|DBG_MISC|DBG_ERROR; @@ -242,7 +242,7 @@ strdup(str) } #endif -#include "monitor.h" +#include "monitor/monitor.h" void lprint(const char *format, ...) { diff --git a/stubs/fdset-add-fd.c b/stubs/fdset-add-fd.c index 09fe2a839a..ee1643708c 100644 --- a/stubs/fdset-add-fd.c +++ b/stubs/fdset-add-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd) { diff --git a/stubs/fdset-find-fd.c b/stubs/fdset-find-fd.c index f82baa066c..4f18344bad 100644 --- a/stubs/fdset-find-fd.c +++ b/stubs/fdset-find-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_dup_fd_find(int dup_fd) { diff --git a/stubs/fdset-get-fd.c b/stubs/fdset-get-fd.c index 4106cf90f0..7112c155e3 100644 --- a/stubs/fdset-get-fd.c +++ b/stubs/fdset-get-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_get_fd(int64_t fdset_id, int flags) { diff --git a/stubs/fdset-remove-fd.c b/stubs/fdset-remove-fd.c index 861b31247e..b3886d9f45 100644 --- a/stubs/fdset-remove-fd.c +++ b/stubs/fdset-remove-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_dup_fd_remove(int dupfd) { diff --git a/stubs/get-fd.c b/stubs/get-fd.c index 3561ab60e2..9f2c65cf0a 100644 --- a/stubs/get-fd.c +++ b/stubs/get-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_get_fd(Monitor *mon, const char *name, Error **errp) { diff --git a/target-i386/helper.c b/target-i386/helper.c index 00341c5233..bd47b8e58e 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -21,7 +21,7 @@ #include "kvm.h" #ifndef CONFIG_USER_ONLY #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #endif //#define DEBUG_MMU diff --git a/ui/input.c b/ui/input.c index 65950af9af..05f6c0c849 100644 --- a/ui/input.c +++ b/ui/input.c @@ -23,7 +23,7 @@ */ #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "qapi/error.h" #include "qmp-commands.h" diff --git a/ui/spice-core.c b/ui/spice-core.c index 0550805b38..379677554e 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -35,7 +35,7 @@ #include "qapi/qmp/qjson.h" #include "notify.h" #include "migration.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/hw.h" #include "ui/spice-display.h" diff --git a/ui/spice-display.c b/ui/spice-display.c index 681fe32fed..56ebf80805 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -19,7 +19,7 @@ #include "ui/qemu-spice.h" #include "qemu-timer.h" #include "qemu-queue.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" #include "trace.h" diff --git a/ui/vnc.h b/ui/vnc.h index 7ec183372a..e5c043ff45 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -31,7 +31,7 @@ #include "qemu-queue.h" #include "qemu-thread.h" #include "ui/console.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "audio/audio.h" #include "bitmap.h" #include diff --git a/vl.c b/vl.c index 015f0a4757..9adaf28e64 100644 --- a/vl.c +++ b/vl.c @@ -129,7 +129,7 @@ int main(int argc, char **argv) #include "bt-host.h" #include "net/net.h" #include "net/slirp.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" #include "exec/gdbstub.h" -- cgit v1.2.3-55-g7522 From 1de7afc984b49af164e2619e6850b9732b173b34 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:20:00 +0100 Subject: misc: move include files to include/qemu/ Signed-off-by: Paolo Bonzini --- acl.c | 2 +- acl.h | 74 ----- aio-posix.c | 4 +- aio-win32.c | 4 +- arch_init.c | 6 +- async.c | 2 +- audio/alsaaudio.c | 2 +- audio/audio.c | 2 +- audio/audio.h | 2 +- audio/noaudio.c | 2 +- audio/ossaudio.c | 4 +- audio/spiceaudio.c | 2 +- audio/wavaudio.c | 2 +- backends/rng-random.c | 2 +- bitmap.c | 4 +- bitmap.h | 222 ------------- bitops.c | 2 +- bitops.h | 362 -------------------- block-migration.c | 4 +- block.c | 6 +- block/blkdebug.c | 4 +- block/blkverify.c | 2 +- block/bochs.c | 2 +- block/cloop.c | 2 +- block/cow.c | 2 +- block/dmg.c | 4 +- block/gluster.c | 4 +- block/iscsi.c | 4 +- block/linux-aio.c | 4 +- block/nbd.c | 6 +- block/parallels.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 4 +- block/qed-table.c | 2 +- block/qed.c | 2 +- block/raw-posix.c | 8 +- block/raw-win32.c | 6 +- block/raw.c | 2 +- block/rbd.c | 2 +- block/sheepdog.c | 6 +- block/vdi.c | 2 +- block/vmdk.c | 2 +- block/vpc.c | 2 +- block/vvfat.c | 2 +- block/win32-aio.c | 6 +- blockdev-nbd.c | 2 +- blockdev.c | 4 +- blockdev.h | 2 +- blockjob.c | 2 +- bsd-user/main.c | 4 +- bsd-user/qemu.h | 2 +- bswap.h | 713 ---------------------------------------- bt-host.c | 2 +- bt-vhci.c | 2 +- buffered_file.c | 2 +- cache-utils.c | 2 +- cache-utils.h | 44 --- cmd.c | 2 +- compatfd.c | 2 +- compatfd.h | 44 --- compiler.h | 58 ---- cpu-exec.c | 2 +- cpus.c | 8 +- cutils.c | 6 +- device_tree.c | 4 +- dma-helpers.c | 4 +- envlist.c | 4 +- envlist.h | 22 -- event_notifier-posix.c | 4 +- event_notifier-win32.c | 4 +- event_notifier.h | 46 --- exec.c | 6 +- fpu/softfloat.h | 2 +- fsdev/qemu-fsdev-dummy.c | 4 +- fsdev/qemu-fsdev.c | 6 +- fsdev/qemu-fsdev.h | 2 +- fsdev/virtfs-proxy-helper.c | 4 +- fsdev/virtio-9p-marshal.c | 4 +- gdbstub.c | 2 +- hmp.c | 6 +- host-utils.c | 2 +- host-utils.h | 240 -------------- hw/9pfs/codir.c | 2 +- hw/9pfs/cofile.c | 2 +- hw/9pfs/cofs.c | 2 +- hw/9pfs/coxattr.c | 2 +- hw/9pfs/virtio-9p-coth.c | 2 +- hw/9pfs/virtio-9p-coth.h | 2 +- hw/9pfs/virtio-9p-device.c | 2 +- hw/9pfs/virtio-9p-handle.c | 2 +- hw/9pfs/virtio-9p-local.c | 2 +- hw/9pfs/virtio-9p-posix-acl.c | 2 +- hw/9pfs/virtio-9p-xattr.h | 2 +- hw/9pfs/virtio-9p.c | 2 +- hw/9pfs/virtio-9p.h | 2 +- hw/acpi.h | 2 +- hw/acpi_ich9.c | 2 +- hw/acpi_piix4.c | 2 +- hw/adlib.c | 2 +- hw/alpha_pci.c | 2 +- hw/apic.c | 4 +- hw/apic_internal.h | 2 +- hw/applesmc.c | 2 +- hw/arm11mpcore.c | 2 +- hw/arm_boot.c | 2 +- hw/arm_mptimer.c | 2 +- hw/arm_sysctl.c | 2 +- hw/arm_timer.c | 2 +- hw/armv7m_nvic.c | 2 +- hw/baum.c | 2 +- hw/block-common.c | 2 +- hw/bt-hci-csr.c | 2 +- hw/bt-hci.c | 2 +- hw/bt-hid.c | 2 +- hw/bt-l2cap.c | 2 +- hw/cadence_ttc.c | 2 +- hw/cadence_uart.c | 2 +- hw/ccid-card-emulated.c | 2 +- hw/ccid-card-passthru.c | 2 +- hw/cs4231a.c | 2 +- hw/cuda.c | 2 +- hw/device-hotplug.c | 2 +- hw/dma.c | 2 +- hw/dp8393x.c | 2 +- hw/esp-pci.c | 2 +- hw/esp.c | 2 +- hw/etraxfs_ser.c | 2 +- hw/etraxfs_timer.c | 2 +- hw/exynos4210_fimd.c | 2 +- hw/exynos4210_i2c.c | 2 +- hw/exynos4210_mct.c | 2 +- hw/exynos4210_pwm.c | 2 +- hw/exynos4210_rtc.c | 4 +- hw/fdc.c | 6 +- hw/fw_cfg.c | 4 +- hw/grlib_gptimer.c | 2 +- hw/hid.c | 2 +- hw/hpet.c | 2 +- hw/hw.h | 2 +- hw/i8254.c | 2 +- hw/i8254_common.c | 2 +- hw/i8259.c | 2 +- hw/ich9.h | 2 +- hw/ide/core.c | 4 +- hw/ide/qdev.c | 2 +- hw/imx_avic.c | 2 +- hw/imx_timer.c | 2 +- hw/intel-hda.c | 2 +- hw/ivshmem.c | 2 +- hw/kvm/i8254.c | 2 +- hw/kvm/pci-assign.c | 4 +- hw/lance.c | 4 +- hw/leon3.c | 2 +- hw/lm32_sys.c | 6 +- hw/lm32_timer.c | 4 +- hw/lm32_uart.c | 2 +- hw/lm832x.c | 2 +- hw/lpc_ich9.c | 2 +- hw/m48t59.c | 2 +- hw/mac_dbdma.c | 2 +- hw/mc146818rtc.c | 2 +- hw/mcf5206.c | 2 +- hw/mcf5208.c | 2 +- hw/megasas.c | 2 +- hw/microblaze_boot.c | 4 +- hw/milkymist-ac97.c | 2 +- hw/milkymist-hpdmc.c | 2 +- hw/milkymist-memcard.c | 2 +- hw/milkymist-minimac2.c | 2 +- hw/milkymist-pfpu.c | 4 +- hw/milkymist-softusb.c | 2 +- hw/milkymist-sysctl.c | 4 +- hw/milkymist-tmu2.c | 2 +- hw/milkymist-uart.c | 2 +- hw/milkymist-vgafb.c | 2 +- hw/mips_fulong2e.c | 2 +- hw/mips_malta.c | 2 +- hw/mips_r4k.c | 2 +- hw/mips_timer.c | 2 +- hw/musicpal.c | 2 +- hw/nand.c | 2 +- hw/omap1.c | 2 +- hw/omap2.c | 2 +- hw/omap_dma.c | 2 +- hw/omap_gptimer.c | 2 +- hw/omap_synctimer.c | 2 +- hw/onenand.c | 2 +- hw/openrisc_timer.c | 2 +- hw/pc.c | 2 +- hw/pci/msi.c | 2 +- hw/pci/msix.c | 2 +- hw/pci/pci-hotplug.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pci_bridge.c | 2 +- hw/pci/pcie.c | 2 +- hw/pci/shpc.c | 4 +- hw/pcnet-pci.c | 2 +- hw/pcnet.c | 4 +- hw/pcspk.c | 2 +- hw/pflash_cfi01.c | 4 +- hw/pflash_cfi02.c | 4 +- hw/piix_pci.c | 2 +- hw/pl031.c | 2 +- hw/ppc.c | 4 +- hw/ppc/e500.c | 4 +- hw/ppc405_boards.c | 2 +- hw/ppc405_uc.c | 4 +- hw/ppc4xx_devs.c | 2 +- hw/ppc_booke.c | 4 +- hw/ppc_prep.c | 2 +- hw/ppce500_pci.c | 2 +- hw/ptimer.c | 4 +- hw/ptimer.h | 2 +- hw/pxa2xx_timer.c | 2 +- hw/q35.h | 2 +- hw/qdev-core.h | 6 +- hw/qdev-monitor.c | 2 +- hw/qxl-logger.c | 2 +- hw/qxl.c | 4 +- hw/qxl.h | 2 +- hw/rc4030.c | 2 +- hw/rtl8139.c | 4 +- hw/s390x/event-facility.h | 2 +- hw/s390x/sclpconsole.c | 2 +- hw/sb16.c | 4 +- hw/scsi-bus.c | 2 +- hw/scsi-disk.c | 2 +- hw/scsi-generic.c | 2 +- hw/sd.c | 2 +- hw/serial.c | 2 +- hw/sh_pci.c | 2 +- hw/sh_timer.c | 2 +- hw/slavio_timer.c | 2 +- hw/sm501.c | 2 +- hw/soc_dma.c | 2 +- hw/spapr.c | 2 +- hw/spitz.c | 2 +- hw/stellaris.c | 2 +- hw/strongarm.c | 2 +- hw/sun4m.c | 2 +- hw/sun4u.c | 2 +- hw/tsc2005.c | 2 +- hw/tsc210x.c | 2 +- hw/tusb6010.c | 2 +- hw/twl92230.c | 2 +- hw/usb.h | 2 +- hw/usb/combined-packet.c | 2 +- hw/usb/core.c | 2 +- hw/usb/dev-hid.c | 2 +- hw/usb/dev-network.c | 6 +- hw/usb/dev-serial.c | 2 +- hw/usb/dev-smartcard-reader.c | 2 +- hw/usb/dev-storage.c | 4 +- hw/usb/dev-uas.c | 4 +- hw/usb/hcd-ehci-pci.c | 2 +- hw/usb/hcd-ehci.h | 2 +- hw/usb/hcd-musb.c | 2 +- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 4 +- hw/usb/hcd-xhci.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/redirect.c | 4 +- hw/vfio_pci.c | 8 +- hw/vga-isa-mm.c | 2 +- hw/vga-isa.c | 2 +- hw/vga-pci.c | 2 +- hw/vga.c | 2 +- hw/vhost.c | 2 +- hw/vhost_net.c | 2 +- hw/virtex_ml507.c | 2 +- hw/virtio-balloon.c | 2 +- hw/virtio-blk.c | 2 +- hw/virtio-console.c | 2 +- hw/virtio-net.c | 6 +- hw/virtio-pci.c | 4 +- hw/virtio-rng.c | 2 +- hw/virtio-serial-bus.c | 4 +- hw/virtio.c | 4 +- hw/virtio.h | 2 +- hw/vt82c686.c | 2 +- hw/watchdog.c | 6 +- hw/watchdog.h | 2 +- hw/wdt_i6300esb.c | 2 +- hw/wdt_ib700.c | 2 +- hw/xen_backend.c | 2 +- hw/xen_common.h | 2 +- hw/xen_domainbuild.c | 4 +- hw/xen_pt.c | 2 +- hw/xen_pt_config_init.c | 2 +- hw/xgmac.c | 2 +- hw/xilinx_axidma.c | 4 +- hw/xilinx_axienet.c | 2 +- hw/xilinx_spi.c | 2 +- hw/xilinx_spips.c | 4 +- hw/xilinx_timer.c | 2 +- hw/xtensa_pic.c | 4 +- hw/zynq_slcr.c | 2 +- include/block/aio.h | 4 +- include/block/block.h | 2 +- include/block/block_int.h | 6 +- include/block/coroutine.h | 4 +- include/block/coroutine_int.h | 2 +- include/block/thread-pool.h | 4 +- include/exec/cpu-all.h | 2 +- include/exec/cpu-common.h | 4 +- include/exec/cpu-defs.h | 4 +- include/exec/exec-all.h | 2 +- include/exec/gen-icount.h | 2 +- include/exec/memory.h | 4 +- include/exec/softmmu_template.h | 2 +- include/migration/migration.h | 2 +- include/net/net.h | 4 +- include/net/slirp.h | 2 +- include/qapi/error.h | 2 +- include/qapi/opts-visitor.h | 2 +- include/qapi/qmp/qdict.h | 2 +- include/qapi/qmp/qerror.h | 2 +- include/qapi/qmp/qjson.h | 2 +- include/qapi/qmp/qlist.h | 4 +- include/qemu/acl.h | 74 +++++ include/qemu/atomic.h | 67 ++++ include/qemu/bitmap.h | 222 +++++++++++++ include/qemu/bitops.h | 362 ++++++++++++++++++++ include/qemu/bswap.h | 713 ++++++++++++++++++++++++++++++++++++++++ include/qemu/cache-utils.h | 44 +++ include/qemu/compatfd.h | 44 +++ include/qemu/compiler.h | 58 ++++ include/qemu/config-file.h | 30 ++ include/qemu/envlist.h | 22 ++ include/qemu/error-report.h | 43 +++ include/qemu/event_notifier.h | 46 +++ include/qemu/host-utils.h | 240 ++++++++++++++ include/qemu/int128.h | 116 +++++++ include/qemu/iov.h | 102 ++++++ include/qemu/log.h | 160 +++++++++ include/qemu/main-loop.h | 306 +++++++++++++++++ include/qemu/module.h | 40 +++ include/qemu/notify.h | 43 +++ include/qemu/option.h | 158 +++++++++ include/qemu/option_int.h | 54 +++ include/qemu/osdep.h | 178 ++++++++++ include/qemu/queue.h | 414 +++++++++++++++++++++++ include/qemu/range.h | 29 ++ include/qemu/sockets.h | 77 +++++ include/qemu/thread-posix.h | 28 ++ include/qemu/thread-win32.h | 29 ++ include/qemu/thread.h | 56 ++++ include/qemu/timer.h | 310 +++++++++++++++++ include/qemu/tls.h | 52 +++ include/qemu/typedefs.h | 61 ++++ include/qemu/uri.h | 113 +++++++ include/qemu/xattr.h | 30 ++ include/qom/cpu.h | 2 +- include/qom/object.h | 2 +- include/ui/console.h | 2 +- include/ui/qemu-spice.h | 4 +- include/ui/spice-display.h | 2 +- int128.h | 116 ------- iohandler.c | 4 +- iov.c | 2 +- iov.h | 102 ------ kvm-all.c | 10 +- kvm.h | 2 +- libcacard/event.c | 2 +- libcacard/vreader.c | 2 +- libcacard/vscclient.c | 4 +- libfdt_env.h | 2 +- linux-user/main.c | 6 +- linux-user/qemu.h | 4 +- linux-user/syscall.c | 2 +- main-loop.c | 6 +- main-loop.h | 306 ----------------- memory.c | 2 +- memory_mapping.h | 2 +- migration-exec.c | 2 +- migration-fd.c | 4 +- migration-tcp.c | 2 +- migration-unix.c | 2 +- migration.c | 2 +- module.c | 4 +- module.h | 40 --- monitor.c | 8 +- nbd.c | 4 +- net/dump.c | 6 +- net/hub.c | 2 +- net/net.c | 6 +- net/queue.c | 2 +- net/slirp.c | 2 +- net/socket.c | 8 +- net/tap-bsd.c | 2 +- net/tap-linux.c | 2 +- net/tap-solaris.c | 2 +- net/tap-win32.c | 2 +- net/tap.c | 2 +- net/vde.c | 2 +- notify.c | 2 +- notify.h | 43 --- osdep.c | 2 +- osdep.h | 178 ---------- oslib-posix.c | 2 +- oslib-win32.c | 4 +- qapi/opts-visitor.c | 4 +- qapi/qapi-dealloc-visitor.c | 2 +- qapi/qmp-input-visitor.c | 2 +- qapi/qmp-output-visitor.c | 2 +- qdict.c | 2 +- qemu-barrier.h | 67 ---- qemu-bridge-helper.c | 2 +- qemu-char.c | 4 +- qemu-char.h | 8 +- qemu-common.h | 10 +- qemu-config.c | 6 +- qemu-config.h | 30 -- qemu-coroutine-io.c | 4 +- qemu-coroutine-lock.c | 2 +- qemu-coroutine-sleep.c | 2 +- qemu-error.h | 43 --- qemu-img.c | 6 +- qemu-io.c | 2 +- qemu-log.c | 2 +- qemu-log.h | 160 --------- qemu-option-internal.h | 54 --- qemu-option.c | 4 +- qemu-option.h | 158 --------- qemu-progress.c | 2 +- qemu-queue.h | 414 ----------------------- qemu-seccomp.h | 2 +- qemu-sockets.c | 4 +- qemu-thread-posix.c | 2 +- qemu-thread-posix.h | 28 -- qemu-thread-win32.c | 2 +- qemu-thread-win32.h | 29 -- qemu-thread.h | 56 ---- qemu-timer-common.c | 2 +- qemu-timer.c | 4 +- qemu-timer.h | 310 ----------------- qemu-tls.h | 52 --- qemu-tool.c | 8 +- qemu-types.h | 61 ---- qemu-xattr.h | 30 -- qemu_socket.h | 77 ----- qga/channel-posix.c | 4 +- qga/commands-posix.c | 4 +- qga/main.c | 2 +- qlist.c | 2 +- qom/container.c | 2 +- range.h | 29 -- savevm.c | 10 +- scripts/qapi-commands.py | 2 +- slirp/if.c | 2 +- slirp/ip_input.c | 2 +- slirp/sbuf.c | 2 +- slirp/slirp.c | 2 +- slirp/slirp.h | 4 +- spice-qemu-char.c | 2 +- stubs/fd-register.c | 2 +- stubs/set-fd-handler.c | 2 +- sysemu.h | 12 +- target-alpha/int_helper.c | 2 +- target-alpha/sys_helper.c | 2 +- target-alpha/translate.c | 2 +- target-arm/helper.c | 4 +- target-arm/translate.c | 2 +- target-cris/helper.c | 2 +- target-cris/op_helper.c | 2 +- target-i386/cpu.c | 4 +- target-i386/excp_helper.c | 2 +- target-i386/int_helper.c | 2 +- target-i386/kvm.c | 4 +- target-i386/seg_helper.c | 2 +- target-lm32/helper.c | 2 +- target-lm32/op_helper.c | 2 +- target-m68k/translate.c | 2 +- target-microblaze/helper.c | 2 +- target-microblaze/op_helper.c | 2 +- target-mips/op_helper.c | 2 +- target-openrisc/int_helper.c | 2 +- target-openrisc/interrupt.c | 2 +- target-openrisc/mmu.c | 2 +- target-openrisc/translate.c | 4 +- target-ppc/int_helper.c | 2 +- target-ppc/kvm.c | 2 +- target-ppc/kvm_ppc.c | 2 +- target-ppc/mem_helper.c | 2 +- target-ppc/translate.c | 2 +- target-s390x/cpu.c | 2 +- target-s390x/helper.c | 2 +- target-s390x/int_helper.c | 2 +- target-s390x/kvm.c | 2 +- target-s390x/misc_helper.c | 4 +- target-s390x/translate.c | 2 +- target-sparc/cpu.h | 2 +- target-sparc/helper.c | 2 +- target-sparc/machine.c | 2 +- target-unicore32/helper.c | 2 +- target-unicore32/translate.c | 2 +- target-xtensa/core-dc232b.c | 2 +- target-xtensa/core-dc233c.c | 2 +- target-xtensa/core-fsf.c | 2 +- target-xtensa/helper.c | 2 +- target-xtensa/op_helper.c | 2 +- target-xtensa/translate.c | 2 +- target-xtensa/xtensa-semi.c | 2 +- tcg/tcg.c | 6 +- tests/libqtest.c | 4 +- tests/tcg/test-i386-fprem.c | 4 +- tests/tcg/test-i386.c | 2 +- tests/test-iov.c | 4 +- tests/test-qmp-commands.c | 2 +- thread-pool.c | 8 +- trace/simple.c | 2 +- translate-all.c | 2 +- ui/console.c | 2 +- ui/sdl_zoom.c | 2 +- ui/spice-core.c | 10 +- ui/spice-display.c | 4 +- ui/vnc-auth-sasl.h | 2 +- ui/vnc-enc-tight.c | 2 +- ui/vnc-jobs.c | 2 +- ui/vnc-palette.h | 2 +- ui/vnc-tls.c | 2 +- ui/vnc-tls.h | 2 +- ui/vnc.c | 8 +- ui/vnc.h | 6 +- uri.c | 2 +- uri.h | 113 ------- vl.c | 18 +- xen-all.c | 2 +- xen-mapcache.c | 2 +- 529 files changed, 4978 insertions(+), 4978 deletions(-) delete mode 100644 acl.h delete mode 100644 bitmap.h delete mode 100644 bitops.h delete mode 100644 bswap.h delete mode 100644 cache-utils.h delete mode 100644 compatfd.h delete mode 100644 compiler.h delete mode 100644 envlist.h delete mode 100644 event_notifier.h delete mode 100644 host-utils.h create mode 100644 include/qemu/acl.h create mode 100644 include/qemu/atomic.h create mode 100644 include/qemu/bitmap.h create mode 100644 include/qemu/bitops.h create mode 100644 include/qemu/bswap.h create mode 100644 include/qemu/cache-utils.h create mode 100644 include/qemu/compatfd.h create mode 100644 include/qemu/compiler.h create mode 100644 include/qemu/config-file.h create mode 100644 include/qemu/envlist.h create mode 100644 include/qemu/error-report.h create mode 100644 include/qemu/event_notifier.h create mode 100644 include/qemu/host-utils.h create mode 100644 include/qemu/int128.h create mode 100644 include/qemu/iov.h create mode 100644 include/qemu/log.h create mode 100644 include/qemu/main-loop.h create mode 100644 include/qemu/module.h create mode 100644 include/qemu/notify.h create mode 100644 include/qemu/option.h create mode 100644 include/qemu/option_int.h create mode 100644 include/qemu/osdep.h create mode 100644 include/qemu/queue.h create mode 100644 include/qemu/range.h create mode 100644 include/qemu/sockets.h create mode 100644 include/qemu/thread-posix.h create mode 100644 include/qemu/thread-win32.h create mode 100644 include/qemu/thread.h create mode 100644 include/qemu/timer.h create mode 100644 include/qemu/tls.h create mode 100644 include/qemu/typedefs.h create mode 100644 include/qemu/uri.h create mode 100644 include/qemu/xattr.h delete mode 100644 int128.h delete mode 100644 iov.h delete mode 100644 main-loop.h delete mode 100644 module.h delete mode 100644 notify.h delete mode 100644 osdep.h delete mode 100644 qemu-barrier.h delete mode 100644 qemu-config.h delete mode 100644 qemu-error.h delete mode 100644 qemu-log.h delete mode 100644 qemu-option-internal.h delete mode 100644 qemu-option.h delete mode 100644 qemu-queue.h delete mode 100644 qemu-thread-posix.h delete mode 100644 qemu-thread-win32.h delete mode 100644 qemu-thread.h delete mode 100644 qemu-timer.h delete mode 100644 qemu-tls.h delete mode 100644 qemu-types.h delete mode 100644 qemu-xattr.h delete mode 100644 qemu_socket.h delete mode 100644 range.h delete mode 100644 uri.h (limited to 'net/socket.c') diff --git a/acl.c b/acl.c index e840b9b633..81ac25599b 100644 --- a/acl.c +++ b/acl.c @@ -24,7 +24,7 @@ #include "qemu-common.h" -#include "acl.h" +#include "qemu/acl.h" #ifdef CONFIG_FNMATCH #include diff --git a/acl.h b/acl.h deleted file mode 100644 index 0ef780401f..0000000000 --- a/acl.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * QEMU access control list management - * - * Copyright (C) 2009 Red Hat, Inc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef __QEMU_ACL_H__ -#define __QEMU_ACL_H__ - -#include "qemu-queue.h" - -typedef struct qemu_acl_entry qemu_acl_entry; -typedef struct qemu_acl qemu_acl; - -struct qemu_acl_entry { - char *match; - int deny; - - QTAILQ_ENTRY(qemu_acl_entry) next; -}; - -struct qemu_acl { - char *aclname; - unsigned int nentries; - QTAILQ_HEAD(,qemu_acl_entry) entries; - int defaultDeny; -}; - -qemu_acl *qemu_acl_init(const char *aclname); - -qemu_acl *qemu_acl_find(const char *aclname); - -int qemu_acl_party_is_allowed(qemu_acl *acl, - const char *party); - -void qemu_acl_reset(qemu_acl *acl); - -int qemu_acl_append(qemu_acl *acl, - int deny, - const char *match); -int qemu_acl_insert(qemu_acl *acl, - int deny, - const char *match, - int index); -int qemu_acl_remove(qemu_acl *acl, - const char *match); - -#endif /* __QEMU_ACL_H__ */ - -/* - * Local variables: - * c-indent-level: 4 - * c-basic-offset: 4 - * tab-width: 8 - * End: - */ diff --git a/aio-posix.c b/aio-posix.c index d1e1bc2c75..88d09e1cfb 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -15,8 +15,8 @@ #include "qemu-common.h" #include "block/block.h" -#include "qemu-queue.h" -#include "qemu_socket.h" +#include "qemu/queue.h" +#include "qemu/sockets.h" struct AioHandler { diff --git a/aio-win32.c b/aio-win32.c index 9a26f9c3d9..f5ea027f8c 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -17,8 +17,8 @@ #include "qemu-common.h" #include "block/block.h" -#include "qemu-queue.h" -#include "qemu_socket.h" +#include "qemu/queue.h" +#include "qemu/sockets.h" struct AioHandler { EventNotifier *e; diff --git a/arch_init.c b/arch_init.c index f627253a20..9dacf5689b 100644 --- a/arch_init.c +++ b/arch_init.c @@ -31,8 +31,8 @@ #include "config.h" #include "monitor/monitor.h" #include "sysemu.h" -#include "bitops.h" -#include "bitmap.h" +#include "qemu/bitops.h" +#include "qemu/bitmap.h" #include "arch_init.h" #include "audio/audio.h" #include "hw/pc.h" @@ -45,7 +45,7 @@ #include "exec/address-spaces.h" #include "hw/pcspk.h" #include "migration/page_cache.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "qmp-commands.h" #include "trace.h" diff --git a/async.c b/async.c index 6df4caf68a..72d268ae35 100644 --- a/async.c +++ b/async.c @@ -24,7 +24,7 @@ #include "qemu-common.h" #include "block/aio.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /***********************************************************/ /* bottom halves (can be seen as timers which expire ASAP) */ diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index cd553c2a7b..e4e5442631 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -23,7 +23,7 @@ */ #include #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "audio.h" #if QEMU_GNUC_PREREQ(4, 3) diff --git a/audio/audio.c b/audio/audio.c index a0cc727020..eb2222c10f 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -24,7 +24,7 @@ #include "hw/hw.h" #include "audio.h" #include "monitor/monitor.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #define AUDIO_CAP "audio" diff --git a/audio/audio.h b/audio/audio.h index a70fda97e3..e7ea39777e 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -25,7 +25,7 @@ #define QEMU_AUDIO_H #include "config-host.h" -#include "qemu-queue.h" +#include "qemu/queue.h" typedef void (*audio_callback_fn) (void *opaque, int avail); diff --git a/audio/noaudio.c b/audio/noaudio.c index 54958f8623..9f23aa2cb3 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "audio.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define AUDIO_CAP "noaudio" #include "audio_int.h" diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 8249a00449..00be9c91e3 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -31,8 +31,8 @@ #include #endif #include "qemu-common.h" -#include "main-loop.h" -#include "host-utils.h" +#include "qemu/main-loop.h" +#include "qemu/host-utils.h" #include "audio.h" #define AUDIO_CAP "oss" diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 6f15591a74..bc24557de4 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -18,7 +18,7 @@ */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/qemu-spice.h" #define AUDIO_CAP "spice" diff --git a/audio/wavaudio.c b/audio/wavaudio.c index a449b5127e..950fa8f19c 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "audio.h" #define AUDIO_CAP "wav" diff --git a/backends/rng-random.c b/backends/rng-random.c index c201953f29..d479ce8c56 100644 --- a/backends/rng-random.c +++ b/backends/rng-random.c @@ -13,7 +13,7 @@ #include "qemu/rng-random.h" #include "qemu/rng.h" #include "qapi/qmp/qerror.h" -#include "main-loop.h" +#include "qemu/main-loop.h" struct RndRandom { diff --git a/bitmap.c b/bitmap.c index a62c8ba681..687841dcec 100644 --- a/bitmap.c +++ b/bitmap.c @@ -9,8 +9,8 @@ * Version 2. */ -#include "bitops.h" -#include "bitmap.h" +#include "qemu/bitops.h" +#include "qemu/bitmap.h" /* * bitmaps provide an array of bits, implemented using an an diff --git a/bitmap.h b/bitmap.h deleted file mode 100644 index 08755eba11..0000000000 --- a/bitmap.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Bitmap Module - * - * Copyright (C) 2010 Corentin Chary - * - * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. - * See the COPYING.LIB file in the top-level directory. - */ - -#ifndef BITMAP_H -#define BITMAP_H - -#include "qemu-common.h" -#include "bitops.h" - -/* - * The available bitmap operations and their rough meaning in the - * case that the bitmap is a single unsigned long are thus: - * - * Note that nbits should be always a compile time evaluable constant. - * Otherwise many inlines will generate horrible code. - * - * bitmap_zero(dst, nbits) *dst = 0UL - * bitmap_fill(dst, nbits) *dst = ~0UL - * bitmap_copy(dst, src, nbits) *dst = *src - * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 - * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 - * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 - * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2) - * bitmap_complement(dst, src, nbits) *dst = ~(*src) - * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? - * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? - * bitmap_empty(src, nbits) Are all bits zero in *src? - * bitmap_full(src, nbits) Are all bits set in *src? - * bitmap_set(dst, pos, nbits) Set specified bit area - * bitmap_clear(dst, pos, nbits) Clear specified bit area - * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area - */ - -/* - * Also the following operations apply to bitmaps. - * - * set_bit(bit, addr) *addr |= bit - * clear_bit(bit, addr) *addr &= ~bit - * change_bit(bit, addr) *addr ^= bit - * test_bit(bit, addr) Is bit set in *addr? - * test_and_set_bit(bit, addr) Set bit and return old value - * test_and_clear_bit(bit, addr) Clear bit and return old value - * test_and_change_bit(bit, addr) Change bit and return old value - * find_first_zero_bit(addr, nbits) Position first zero bit in *addr - * find_first_bit(addr, nbits) Position first set bit in *addr - * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit - * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit - */ - -#define BITMAP_LAST_WORD_MASK(nbits) \ - ( \ - ((nbits) % BITS_PER_LONG) ? \ - (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ - ) - -#define DECLARE_BITMAP(name,bits) \ - unsigned long name[BITS_TO_LONGS(bits)] - -#define small_nbits(nbits) \ - ((nbits) <= BITS_PER_LONG) - -int slow_bitmap_empty(const unsigned long *bitmap, int bits); -int slow_bitmap_full(const unsigned long *bitmap, int bits); -int slow_bitmap_equal(const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -void slow_bitmap_complement(unsigned long *dst, const unsigned long *src, - int bits); -void slow_bitmap_shift_right(unsigned long *dst, - const unsigned long *src, int shift, int bits); -void slow_bitmap_shift_left(unsigned long *dst, - const unsigned long *src, int shift, int bits); -int slow_bitmap_and(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -void slow_bitmap_or(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -void slow_bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -int slow_bitmap_intersects(const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); - -static inline unsigned long *bitmap_new(int nbits) -{ - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - return g_malloc0(len); -} - -static inline void bitmap_zero(unsigned long *dst, int nbits) -{ - if (small_nbits(nbits)) { - *dst = 0UL; - } else { - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memset(dst, 0, len); - } -} - -static inline void bitmap_fill(unsigned long *dst, int nbits) -{ - size_t nlongs = BITS_TO_LONGS(nbits); - if (!small_nbits(nbits)) { - int len = (nlongs - 1) * sizeof(unsigned long); - memset(dst, 0xff, len); - } - dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); -} - -static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, - int nbits) -{ - if (small_nbits(nbits)) { - *dst = *src; - } else { - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memcpy(dst, src, len); - } -} - -static inline int bitmap_and(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return (*dst = *src1 & *src2) != 0; - } - return slow_bitmap_and(dst, src1, src2, nbits); -} - -static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - *dst = *src1 | *src2; - } else { - slow_bitmap_or(dst, src1, src2, nbits); - } -} - -static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - *dst = *src1 ^ *src2; - } else { - slow_bitmap_xor(dst, src1, src2, nbits); - } -} - -static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return (*dst = *src1 & ~(*src2)) != 0; - } - return slow_bitmap_andnot(dst, src1, src2, nbits); -} - -static inline void bitmap_complement(unsigned long *dst, const unsigned long *src, - int nbits) -{ - if (small_nbits(nbits)) { - *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits); - } else { - slow_bitmap_complement(dst, src, nbits); - } -} - -static inline int bitmap_equal(const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); - } else { - return slow_bitmap_equal(src1, src2, nbits); - } -} - -static inline int bitmap_empty(const unsigned long *src, int nbits) -{ - if (small_nbits(nbits)) { - return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); - } else { - return slow_bitmap_empty(src, nbits); - } -} - -static inline int bitmap_full(const unsigned long *src, int nbits) -{ - if (small_nbits(nbits)) { - return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); - } else { - return slow_bitmap_full(src, nbits); - } -} - -static inline int bitmap_intersects(const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; - } else { - return slow_bitmap_intersects(src1, src2, nbits); - } -} - -void bitmap_set(unsigned long *map, int i, int len); -void bitmap_clear(unsigned long *map, int start, int nr); -unsigned long bitmap_find_next_zero_area(unsigned long *map, - unsigned long size, - unsigned long start, - unsigned int nr, - unsigned long align_mask); - -#endif /* BITMAP_H */ diff --git a/bitops.c b/bitops.c index d9de71f7e8..4c3a836a01 100644 --- a/bitops.c +++ b/bitops.c @@ -11,7 +11,7 @@ * 2 of the License, or (at your option) any later version. */ -#include "bitops.h" +#include "qemu/bitops.h" #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) diff --git a/bitops.h b/bitops.h deleted file mode 100644 index 74e14e5724..0000000000 --- a/bitops.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Bitops Module - * - * Copyright (C) 2010 Corentin Chary - * - * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. - * See the COPYING.LIB file in the top-level directory. - */ - -#ifndef BITOPS_H -#define BITOPS_H - -#include "qemu-common.h" - -#define BITS_PER_BYTE CHAR_BIT -#define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) - -#define BIT(nr) (1UL << (nr)) -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) - -/** - * bitops_ffs - find first bit in word. - * @word: The word to search - * - * Undefined if no bit exists, so code should check against 0 first. - */ -static unsigned long bitops_ffsl(unsigned long word) -{ - int num = 0; - -#if LONG_MAX > 0x7FFFFFFF - if ((word & 0xffffffff) == 0) { - num += 32; - word >>= 32; - } -#endif - if ((word & 0xffff) == 0) { - num += 16; - word >>= 16; - } - if ((word & 0xff) == 0) { - num += 8; - word >>= 8; - } - if ((word & 0xf) == 0) { - num += 4; - word >>= 4; - } - if ((word & 0x3) == 0) { - num += 2; - word >>= 2; - } - if ((word & 0x1) == 0) { - num += 1; - } - return num; -} - -/** - * bitops_fls - find last (most-significant) set bit in a long word - * @word: the word to search - * - * Undefined if no set bit exists, so code should check against 0 first. - */ -static inline unsigned long bitops_flsl(unsigned long word) -{ - int num = BITS_PER_LONG - 1; - -#if LONG_MAX > 0x7FFFFFFF - if (!(word & (~0ul << 32))) { - num -= 32; - word <<= 32; - } -#endif - if (!(word & (~0ul << (BITS_PER_LONG-16)))) { - num -= 16; - word <<= 16; - } - if (!(word & (~0ul << (BITS_PER_LONG-8)))) { - num -= 8; - word <<= 8; - } - if (!(word & (~0ul << (BITS_PER_LONG-4)))) { - num -= 4; - word <<= 4; - } - if (!(word & (~0ul << (BITS_PER_LONG-2)))) { - num -= 2; - - word <<= 2; - } - if (!(word & (~0ul << (BITS_PER_LONG-1)))) - num -= 1; - return num; -} - -/** - * ffz - find first zero in word. - * @word: The word to search - * - * Undefined if no zero exists, so code should check against ~0UL first. - */ -static inline unsigned long ffz(unsigned long word) -{ - return bitops_ffsl(~word); -} - -/** - * set_bit - Set a bit in memory - * @nr: the bit to set - * @addr: the address to start counting from - */ -static inline void set_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - - *p |= mask; -} - -/** - * clear_bit - Clears a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - */ -static inline void clear_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - - *p &= ~mask; -} - -/** - * change_bit - Toggle a bit in memory - * @nr: Bit to change - * @addr: Address to start counting from - */ -static inline void change_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - - *p ^= mask; -} - -/** - * test_and_set_bit - Set a bit and return its old value - * @nr: Bit to set - * @addr: Address to count from - */ -static inline int test_and_set_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - unsigned long old = *p; - - *p = old | mask; - return (old & mask) != 0; -} - -/** - * test_and_clear_bit - Clear a bit and return its old value - * @nr: Bit to clear - * @addr: Address to count from - */ -static inline int test_and_clear_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - unsigned long old = *p; - - *p = old & ~mask; - return (old & mask) != 0; -} - -/** - * test_and_change_bit - Change a bit and return its old value - * @nr: Bit to change - * @addr: Address to count from - */ -static inline int test_and_change_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - unsigned long old = *p; - - *p = old ^ mask; - return (old & mask) != 0; -} - -/** - * test_bit - Determine whether a bit is set - * @nr: bit number to test - * @addr: Address to start counting from - */ -static inline int test_bit(int nr, const unsigned long *addr) -{ - return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); -} - -/** - * find_last_bit - find the last set bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit number of the first set bit, or size. - */ -unsigned long find_last_bit(const unsigned long *addr, - unsigned long size); - -/** - * find_next_bit - find the next set bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The bitmap size in bits - */ -unsigned long find_next_bit(const unsigned long *addr, - unsigned long size, unsigned long offset); - -/** - * find_next_zero_bit - find the next cleared bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The bitmap size in bits - */ - -unsigned long find_next_zero_bit(const unsigned long *addr, - unsigned long size, - unsigned long offset); - -/** - * find_first_bit - find the first set bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit number of the first set bit. - */ -static inline unsigned long find_first_bit(const unsigned long *addr, - unsigned long size) -{ - return find_next_bit(addr, size, 0); -} - -/** - * find_first_zero_bit - find the first cleared bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit number of the first cleared bit. - */ -static inline unsigned long find_first_zero_bit(const unsigned long *addr, - unsigned long size) -{ - return find_next_zero_bit(addr, size, 0); -} - -static inline unsigned long hweight_long(unsigned long w) -{ - unsigned long count; - - for (count = 0; w; w >>= 1) { - count += w & 1; - } - return count; -} - -/** - * extract32: - * @value: the value to extract the bit field from - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * - * Extract from the 32 bit input @value the bit field specified by the - * @start and @length parameters, and return it. The bit field must - * lie entirely within the 32 bit word. It is valid to request that - * all 32 bits are returned (ie @length 32 and @start 0). - * - * Returns: the value of the bit field extracted from the input value. - */ -static inline uint32_t extract32(uint32_t value, int start, int length) -{ - assert(start >= 0 && length > 0 && length <= 32 - start); - return (value >> start) & (~0U >> (32 - length)); -} - -/** - * extract64: - * @value: the value to extract the bit field from - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * - * Extract from the 64 bit input @value the bit field specified by the - * @start and @length parameters, and return it. The bit field must - * lie entirely within the 64 bit word. It is valid to request that - * all 64 bits are returned (ie @length 64 and @start 0). - * - * Returns: the value of the bit field extracted from the input value. - */ -static inline uint64_t extract64(uint64_t value, int start, int length) -{ - assert(start >= 0 && length > 0 && length <= 64 - start); - return (value >> start) & (~0ULL >> (64 - length)); -} - -/** - * deposit32: - * @value: initial value to insert bit field into - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * @fieldval: the value to insert into the bit field - * - * Deposit @fieldval into the 32 bit @value at the bit field specified - * by the @start and @length parameters, and return the modified - * @value. Bits of @value outside the bit field are not modified. - * Bits of @fieldval above the least significant @length bits are - * ignored. The bit field must lie entirely within the 32 bit word. - * It is valid to request that all 32 bits are modified (ie @length - * 32 and @start 0). - * - * Returns: the modified @value. - */ -static inline uint32_t deposit32(uint32_t value, int start, int length, - uint32_t fieldval) -{ - uint32_t mask; - assert(start >= 0 && length > 0 && length <= 32 - start); - mask = (~0U >> (32 - length)) << start; - return (value & ~mask) | ((fieldval << start) & mask); -} - -/** - * deposit64: - * @value: initial value to insert bit field into - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * @fieldval: the value to insert into the bit field - * - * Deposit @fieldval into the 64 bit @value at the bit field specified - * by the @start and @length parameters, and return the modified - * @value. Bits of @value outside the bit field are not modified. - * Bits of @fieldval above the least significant @length bits are - * ignored. The bit field must lie entirely within the 64 bit word. - * It is valid to request that all 64 bits are modified (ie @length - * 64 and @start 0). - * - * Returns: the modified @value. - */ -static inline uint64_t deposit64(uint64_t value, int start, int length, - uint64_t fieldval) -{ - uint64_t mask; - assert(start >= 0 && length > 0 && length <= 64 - start); - mask = (~0ULL >> (64 - length)) << start; - return (value & ~mask) | ((fieldval << start) & mask); -} - -#endif diff --git a/block-migration.c b/block-migration.c index 2d2dcbda94..4e865a6781 100644 --- a/block-migration.c +++ b/block-migration.c @@ -16,8 +16,8 @@ #include "qemu-common.h" #include "block/block_int.h" #include "hw/hw.h" -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "migration/block.h" #include "migration/migration.h" #include "blockdev.h" diff --git a/block.c b/block.c index 0e7f18c6d3..1af4b99ee8 100644 --- a/block.c +++ b/block.c @@ -27,13 +27,13 @@ #include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" -#include "module.h" +#include "qemu/module.h" #include "qapi/qmp/qjson.h" #include "sysemu.h" -#include "notify.h" +#include "qemu/notify.h" #include "block/coroutine.h" #include "qmp-commands.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CONFIG_BSD #include diff --git a/block/blkdebug.c b/block/blkdebug.c index cd2866e7bd..6f7463772b 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -23,9 +23,9 @@ */ #include "qemu-common.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" typedef struct BDRVBlkdebugState { int state; diff --git a/block/blkverify.c b/block/blkverify.c index cde5098e5a..a7dd45909b 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -8,7 +8,7 @@ */ #include -#include "qemu_socket.h" /* for EINPROGRESS on Windows */ +#include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "block/block_int.h" typedef struct { diff --git a/block/bochs.c b/block/bochs.c index 2cc7524782..1b1d9cdbe5 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -24,7 +24,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" /**************************************************************/ diff --git a/block/cloop.c b/block/cloop.c index da29ff379c..5a0d0d805f 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include typedef struct BDRVCloopState { diff --git a/block/cow.c b/block/cow.c index 1438ae1e3b..a33ce950d4 100644 --- a/block/cow.c +++ b/block/cow.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" /**************************************************************/ /* COW block driver using file system holes */ diff --git a/block/dmg.c b/block/dmg.c index 6ee505a9f5..ac397dc8f7 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -23,8 +23,8 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "bswap.h" -#include "module.h" +#include "qemu/bswap.h" +#include "qemu/module.h" #include typedef struct BDRVDMGState { diff --git a/block/gluster.c b/block/gluster.c index 4cb4e60227..0f2c32a3fa 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -17,8 +17,8 @@ */ #include #include "block/block_int.h" -#include "qemu_socket.h" -#include "uri.h" +#include "qemu/sockets.h" +#include "qemu/uri.h" typedef struct GlusterAIOCB { BlockDriverAIOCB common; diff --git a/block/iscsi.c b/block/iscsi.c index 77e619a1fd..041ee07de3 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -27,8 +27,8 @@ #include #include #include "qemu-common.h" -#include "qemu-config.h" -#include "qemu-error.h" +#include "qemu/config-file.h" +#include "qemu/error-report.h" #include "block/block_int.h" #include "trace.h" #include "hw/scsi-defs.h" diff --git a/block/linux-aio.c b/block/linux-aio.c index 28e5a04e12..ee0f8d10c9 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -9,9 +9,9 @@ */ #include "qemu-common.h" #include "block/aio.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/raw-aio.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include diff --git a/block/nbd.c b/block/nbd.c index 38d6b90ab2..a5812948d2 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -28,10 +28,10 @@ #include "qemu-common.h" #include "block/nbd.h" -#include "uri.h" +#include "qemu/uri.h" #include "block/block_int.h" -#include "module.h" -#include "qemu_socket.h" +#include "qemu/module.h" +#include "qemu/sockets.h" #include #include diff --git a/block/parallels.c b/block/parallels.c index ae88cd6359..377375046f 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -25,7 +25,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" /**************************************************************/ diff --git a/block/qcow.c b/block/qcow.c index f36671196e..4276610afd 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include #include "block/aes.h" #include "migration/migration.h" diff --git a/block/qcow2.c b/block/qcow2.c index 205d910a52..d603f98a9c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -23,11 +23,11 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include #include "block/aes.h" #include "block/qcow2.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qapi/qmp/qerror.h" #include "trace.h" diff --git a/block/qed-table.c b/block/qed-table.c index de845ec3d0..76d2dcccf8 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -13,7 +13,7 @@ */ #include "trace.h" -#include "qemu_socket.h" /* for EINPROGRESS on Windows */ +#include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "qed.h" typedef struct { diff --git a/block/qed.c b/block/qed.c index 10d0827482..cf85d8f2b4 100644 --- a/block/qed.c +++ b/block/qed.c @@ -12,7 +12,7 @@ * */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "trace.h" #include "qed.h" #include "qapi/qmp/qerror.h" diff --git a/block/raw-posix.c b/block/raw-posix.c index 4e73885269..91159c7887 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -22,13 +22,13 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" -#include "qemu-log.h" +#include "qemu/timer.h" +#include "qemu/log.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "trace.h" #include "block/thread-pool.h" -#include "iov.h" +#include "qemu/iov.h" #include "raw-aio.h" #if defined(__APPLE__) && (__MACH__) diff --git a/block/raw-win32.c b/block/raw-win32.c index 9269fe84c0..f58334be08 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -22,13 +22,13 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "raw-aio.h" #include "trace.h" #include "block/thread-pool.h" -#include "iov.h" +#include "qemu/iov.h" #include #include diff --git a/block/raw.c b/block/raw.c index 6aec93dadb..75812db3c2 100644 --- a/block/raw.c +++ b/block/raw.c @@ -1,7 +1,7 @@ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" static int raw_open(BlockDriverState *bs, int flags) { diff --git a/block/rbd.c b/block/rbd.c index 8def2f174c..8cd10a7b59 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -14,7 +14,7 @@ #include #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "block/block_int.h" #include diff --git a/block/sheepdog.c b/block/sheepdog.c index da70df2d00..13dc023fdb 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -13,10 +13,10 @@ */ #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu_socket.h" +#include "qemu/error-report.h" +#include "qemu/sockets.h" #include "block/block_int.h" -#include "bitops.h" +#include "qemu/bitops.h" #define SD_PROTO_VER 0x01 diff --git a/block/vdi.c b/block/vdi.c index b1d199a2e5..7b6231941b 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -51,7 +51,7 @@ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #if defined(CONFIG_UUID) diff --git a/block/vmdk.c b/block/vmdk.c index 77a1a67c61..19298c2a3e 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -25,7 +25,7 @@ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #include diff --git a/block/vpc.c b/block/vpc.c index 47b5518aee..7948609e50 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -24,7 +24,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #if defined(CONFIG_UUID) #include diff --git a/block/vvfat.c b/block/vvfat.c index a63c3ea7cd..83706ce556 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -26,7 +26,7 @@ #include #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #ifndef S_IWGRP diff --git a/block/win32-aio.c b/block/win32-aio.c index 606e4d6925..46a5db78cc 100644 --- a/block/win32-aio.c +++ b/block/win32-aio.c @@ -22,13 +22,13 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "qemu-common.h" #include "block/aio.h" #include "raw-aio.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include #include diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 596b47499d..95b621699a 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -17,7 +17,7 @@ #include "qmp-commands.h" #include "trace.h" #include "block/nbd.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" static int server_fd = -1; diff --git a/blockdev.c b/blockdev.c index a2308fa718..3ebff44310 100644 --- a/blockdev.c +++ b/blockdev.c @@ -12,8 +12,8 @@ #include "block/blockjob.h" #include "monitor/monitor.h" #include "qapi/qmp/qerror.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qapi/qmp/types.h" #include "sysemu.h" #include "block/block_int.h" diff --git a/blockdev.h b/blockdev.h index 4134864758..1fe533299e 100644 --- a/blockdev.h +++ b/blockdev.h @@ -12,7 +12,7 @@ #include "block/block.h" #include "qapi/error.h" -#include "qemu-queue.h" +#include "qemu/queue.h" void blockdev_mark_auto_del(BlockDriverState *bs); void blockdev_auto_del(BlockDriverState *bs); diff --git a/blockjob.c b/blockjob.c index 4bc60c7378..ca80df1d0e 100644 --- a/blockjob.c +++ b/blockjob.c @@ -33,7 +33,7 @@ #include "qapi/qmp/qjson.h" #include "block/coroutine.h" #include "qmp-commands.h" -#include "qemu-timer.h" +#include "qemu/timer.h" void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, int64_t speed, BlockDriverCompletionFunc *cb, diff --git a/bsd-user/main.c b/bsd-user/main.c index 095ae8eaaa..1dc033046b 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -31,8 +31,8 @@ /* For tb_lock */ #include "cpu.h" #include "tcg.h" -#include "qemu-timer.h" -#include "envlist.h" +#include "qemu/timer.h" +#include "qemu/envlist.h" #define DEBUG_LOGFILE "/tmp/qemu.log" diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index c64c3ccca3..a826086dab 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -146,7 +146,7 @@ int get_osversion(void); void fork_start(void); void fork_end(int child); -#include "qemu-log.h" +#include "qemu/log.h" /* strace.c */ void diff --git a/bswap.h b/bswap.h deleted file mode 100644 index cc7f84d30f..0000000000 --- a/bswap.h +++ /dev/null @@ -1,713 +0,0 @@ -#ifndef BSWAP_H -#define BSWAP_H - -#include "config-host.h" - -#include -#include "softfloat.h" - -#ifdef CONFIG_MACHINE_BSWAP_H -#include -#include -#include -#else - -#ifdef CONFIG_BYTESWAP_H -#include -#else - -#define bswap_16(x) \ -({ \ - uint16_t __x = (x); \ - ((uint16_t)( \ - (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \ - (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \ -}) - -#define bswap_32(x) \ -({ \ - uint32_t __x = (x); \ - ((uint32_t)( \ - (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ - (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ - (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ - (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ -}) - -#define bswap_64(x) \ -({ \ - uint64_t __x = (x); \ - ((uint64_t)( \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ -}) - -#endif /* !CONFIG_BYTESWAP_H */ - -static inline uint16_t bswap16(uint16_t x) -{ - return bswap_16(x); -} - -static inline uint32_t bswap32(uint32_t x) -{ - return bswap_32(x); -} - -static inline uint64_t bswap64(uint64_t x) -{ - return bswap_64(x); -} - -#endif /* ! CONFIG_MACHINE_BSWAP_H */ - -static inline void bswap16s(uint16_t *s) -{ - *s = bswap16(*s); -} - -static inline void bswap32s(uint32_t *s) -{ - *s = bswap32(*s); -} - -static inline void bswap64s(uint64_t *s) -{ - *s = bswap64(*s); -} - -#if defined(HOST_WORDS_BIGENDIAN) -#define be_bswap(v, size) (v) -#define le_bswap(v, size) bswap ## size(v) -#define be_bswaps(v, size) -#define le_bswaps(p, size) *p = bswap ## size(*p); -#else -#define le_bswap(v, size) (v) -#define be_bswap(v, size) bswap ## size(v) -#define le_bswaps(v, size) -#define be_bswaps(p, size) *p = bswap ## size(*p); -#endif - -#define CPU_CONVERT(endian, size, type)\ -static inline type endian ## size ## _to_cpu(type v)\ -{\ - return endian ## _bswap(v, size);\ -}\ -\ -static inline type cpu_to_ ## endian ## size(type v)\ -{\ - return endian ## _bswap(v, size);\ -}\ -\ -static inline void endian ## size ## _to_cpus(type *p)\ -{\ - endian ## _bswaps(p, size)\ -}\ -\ -static inline void cpu_to_ ## endian ## size ## s(type *p)\ -{\ - endian ## _bswaps(p, size)\ -}\ -\ -static inline type endian ## size ## _to_cpup(const type *p)\ -{\ - return endian ## size ## _to_cpu(*p);\ -}\ -\ -static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\ -{\ - *p = cpu_to_ ## endian ## size(v);\ -} - -CPU_CONVERT(be, 16, uint16_t) -CPU_CONVERT(be, 32, uint32_t) -CPU_CONVERT(be, 64, uint64_t) - -CPU_CONVERT(le, 16, uint16_t) -CPU_CONVERT(le, 32, uint32_t) -CPU_CONVERT(le, 64, uint64_t) - -/* unaligned versions (optimized for frequent unaligned accesses)*/ - -#if defined(__i386__) || defined(_ARCH_PPC) - -#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v) -#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v) -#define le16_to_cpupu(p) le16_to_cpup(p) -#define le32_to_cpupu(p) le32_to_cpup(p) -#define be32_to_cpupu(p) be32_to_cpup(p) - -#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v) -#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v) -#define cpu_to_be64wu(p, v) cpu_to_be64w(p, v) - -#else - -static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v & 0xff; - p1[1] = v >> 8; -} - -static inline void cpu_to_le32wu(uint32_t *p, uint32_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v & 0xff; - p1[1] = v >> 8; - p1[2] = v >> 16; - p1[3] = v >> 24; -} - -static inline uint16_t le16_to_cpupu(const uint16_t *p) -{ - const uint8_t *p1 = (const uint8_t *)p; - return p1[0] | (p1[1] << 8); -} - -static inline uint32_t le32_to_cpupu(const uint32_t *p) -{ - const uint8_t *p1 = (const uint8_t *)p; - return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24); -} - -static inline uint32_t be32_to_cpupu(const uint32_t *p) -{ - const uint8_t *p1 = (const uint8_t *)p; - return p1[3] | (p1[2] << 8) | (p1[1] << 16) | (p1[0] << 24); -} - -static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v >> 8; - p1[1] = v & 0xff; -} - -static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v >> 24; - p1[1] = v >> 16; - p1[2] = v >> 8; - p1[3] = v & 0xff; -} - -static inline void cpu_to_be64wu(uint64_t *p, uint64_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v >> 56; - p1[1] = v >> 48; - p1[2] = v >> 40; - p1[3] = v >> 32; - p1[4] = v >> 24; - p1[5] = v >> 16; - p1[6] = v >> 8; - p1[7] = v & 0xff; -} - -#endif - -#ifdef HOST_WORDS_BIGENDIAN -#define cpu_to_32wu cpu_to_be32wu -#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v) -#else -#define cpu_to_32wu cpu_to_le32wu -#define leul_to_cpu(v) (v) -#endif - -#undef le_bswap -#undef be_bswap -#undef le_bswaps -#undef be_bswaps - -/* len must be one of 1, 2, 4 */ -static inline uint32_t qemu_bswap_len(uint32_t value, int len) -{ - return bswap32(value) >> (32 - 8 * len); -} - -typedef union { - float32 f; - uint32_t l; -} CPU_FloatU; - -typedef union { - float64 d; -#if defined(HOST_WORDS_BIGENDIAN) - struct { - uint32_t upper; - uint32_t lower; - } l; -#else - struct { - uint32_t lower; - uint32_t upper; - } l; -#endif - uint64_t ll; -} CPU_DoubleU; - -typedef union { - floatx80 d; - struct { - uint64_t lower; - uint16_t upper; - } l; -} CPU_LDoubleU; - -typedef union { - float128 q; -#if defined(HOST_WORDS_BIGENDIAN) - struct { - uint32_t upmost; - uint32_t upper; - uint32_t lower; - uint32_t lowest; - } l; - struct { - uint64_t upper; - uint64_t lower; - } ll; -#else - struct { - uint32_t lowest; - uint32_t lower; - uint32_t upper; - uint32_t upmost; - } l; - struct { - uint64_t lower; - uint64_t upper; - } ll; -#endif -} CPU_QuadU; - -/* unaligned/endian-independent pointer access */ - -/* - * the generic syntax is: - * - * load: ld{type}{sign}{size}{endian}_p(ptr) - * - * store: st{type}{size}{endian}_p(ptr, val) - * - * Note there are small differences with the softmmu access API! - * - * type is: - * (empty): integer access - * f : float access - * - * sign is: - * (empty): for floats or 32 bit size - * u : unsigned - * s : signed - * - * size is: - * b: 8 bits - * w: 16 bits - * l: 32 bits - * q: 64 bits - * - * endian is: - * (empty): 8 bit access - * be : big endian - * le : little endian - */ -static inline int ldub_p(const void *ptr) -{ - return *(uint8_t *)ptr; -} - -static inline int ldsb_p(const void *ptr) -{ - return *(int8_t *)ptr; -} - -static inline void stb_p(void *ptr, int v) -{ - *(uint8_t *)ptr = v; -} - -/* NOTE: on arm, putting 2 in /proc/sys/debug/alignment so that the - kernel handles unaligned load/stores may give better results, but - it is a system wide setting : bad */ -#if defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) - -/* conservative code for little endian unaligned accesses */ -static inline int lduw_le_p(const void *ptr) -{ -#ifdef _ARCH_PPC - int val; - __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); - return val; -#else - const uint8_t *p = ptr; - return p[0] | (p[1] << 8); -#endif -} - -static inline int ldsw_le_p(const void *ptr) -{ -#ifdef _ARCH_PPC - int val; - __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); - return (int16_t)val; -#else - const uint8_t *p = ptr; - return (int16_t)(p[0] | (p[1] << 8)); -#endif -} - -static inline int ldl_le_p(const void *ptr) -{ -#ifdef _ARCH_PPC - int val; - __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (ptr)); - return val; -#else - const uint8_t *p = ptr; - return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); -#endif -} - -static inline uint64_t ldq_le_p(const void *ptr) -{ - const uint8_t *p = ptr; - uint32_t v1, v2; - v1 = ldl_le_p(p); - v2 = ldl_le_p(p + 4); - return v1 | ((uint64_t)v2 << 32); -} - -static inline void stw_le_p(void *ptr, int v) -{ -#ifdef _ARCH_PPC - __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr)); -#else - uint8_t *p = ptr; - p[0] = v; - p[1] = v >> 8; -#endif -} - -static inline void stl_le_p(void *ptr, int v) -{ -#ifdef _ARCH_PPC - __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr)); -#else - uint8_t *p = ptr; - p[0] = v; - p[1] = v >> 8; - p[2] = v >> 16; - p[3] = v >> 24; -#endif -} - -static inline void stq_le_p(void *ptr, uint64_t v) -{ - uint8_t *p = ptr; - stl_le_p(p, (uint32_t)v); - stl_le_p(p + 4, v >> 32); -} - -/* float access */ - -static inline float32 ldfl_le_p(const void *ptr) -{ - union { - float32 f; - uint32_t i; - } u; - u.i = ldl_le_p(ptr); - return u.f; -} - -static inline void stfl_le_p(void *ptr, float32 v) -{ - union { - float32 f; - uint32_t i; - } u; - u.f = v; - stl_le_p(ptr, u.i); -} - -static inline float64 ldfq_le_p(const void *ptr) -{ - CPU_DoubleU u; - u.l.lower = ldl_le_p(ptr); - u.l.upper = ldl_le_p(ptr + 4); - return u.d; -} - -static inline void stfq_le_p(void *ptr, float64 v) -{ - CPU_DoubleU u; - u.d = v; - stl_le_p(ptr, u.l.lower); - stl_le_p(ptr + 4, u.l.upper); -} - -#else - -static inline int lduw_le_p(const void *ptr) -{ - return *(uint16_t *)ptr; -} - -static inline int ldsw_le_p(const void *ptr) -{ - return *(int16_t *)ptr; -} - -static inline int ldl_le_p(const void *ptr) -{ - return *(uint32_t *)ptr; -} - -static inline uint64_t ldq_le_p(const void *ptr) -{ - return *(uint64_t *)ptr; -} - -static inline void stw_le_p(void *ptr, int v) -{ - *(uint16_t *)ptr = v; -} - -static inline void stl_le_p(void *ptr, int v) -{ - *(uint32_t *)ptr = v; -} - -static inline void stq_le_p(void *ptr, uint64_t v) -{ - *(uint64_t *)ptr = v; -} - -/* float access */ - -static inline float32 ldfl_le_p(const void *ptr) -{ - return *(float32 *)ptr; -} - -static inline float64 ldfq_le_p(const void *ptr) -{ - return *(float64 *)ptr; -} - -static inline void stfl_le_p(void *ptr, float32 v) -{ - *(float32 *)ptr = v; -} - -static inline void stfq_le_p(void *ptr, float64 v) -{ - *(float64 *)ptr = v; -} -#endif - -#if !defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) - -static inline int lduw_be_p(const void *ptr) -{ -#if defined(__i386__) - int val; - asm volatile ("movzwl %1, %0\n" - "xchgb %b0, %h0\n" - : "=q" (val) - : "m" (*(uint16_t *)ptr)); - return val; -#else - const uint8_t *b = ptr; - return ((b[0] << 8) | b[1]); -#endif -} - -static inline int ldsw_be_p(const void *ptr) -{ -#if defined(__i386__) - int val; - asm volatile ("movzwl %1, %0\n" - "xchgb %b0, %h0\n" - : "=q" (val) - : "m" (*(uint16_t *)ptr)); - return (int16_t)val; -#else - const uint8_t *b = ptr; - return (int16_t)((b[0] << 8) | b[1]); -#endif -} - -static inline int ldl_be_p(const void *ptr) -{ -#if defined(__i386__) || defined(__x86_64__) - int val; - asm volatile ("movl %1, %0\n" - "bswap %0\n" - : "=r" (val) - : "m" (*(uint32_t *)ptr)); - return val; -#else - const uint8_t *b = ptr; - return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; -#endif -} - -static inline uint64_t ldq_be_p(const void *ptr) -{ - uint32_t a,b; - a = ldl_be_p(ptr); - b = ldl_be_p((uint8_t *)ptr + 4); - return (((uint64_t)a<<32)|b); -} - -static inline void stw_be_p(void *ptr, int v) -{ -#if defined(__i386__) - asm volatile ("xchgb %b0, %h0\n" - "movw %w0, %1\n" - : "=q" (v) - : "m" (*(uint16_t *)ptr), "0" (v)); -#else - uint8_t *d = (uint8_t *) ptr; - d[0] = v >> 8; - d[1] = v; -#endif -} - -static inline void stl_be_p(void *ptr, int v) -{ -#if defined(__i386__) || defined(__x86_64__) - asm volatile ("bswap %0\n" - "movl %0, %1\n" - : "=r" (v) - : "m" (*(uint32_t *)ptr), "0" (v)); -#else - uint8_t *d = (uint8_t *) ptr; - d[0] = v >> 24; - d[1] = v >> 16; - d[2] = v >> 8; - d[3] = v; -#endif -} - -static inline void stq_be_p(void *ptr, uint64_t v) -{ - stl_be_p(ptr, v >> 32); - stl_be_p((uint8_t *)ptr + 4, v); -} - -/* float access */ - -static inline float32 ldfl_be_p(const void *ptr) -{ - union { - float32 f; - uint32_t i; - } u; - u.i = ldl_be_p(ptr); - return u.f; -} - -static inline void stfl_be_p(void *ptr, float32 v) -{ - union { - float32 f; - uint32_t i; - } u; - u.f = v; - stl_be_p(ptr, u.i); -} - -static inline float64 ldfq_be_p(const void *ptr) -{ - CPU_DoubleU u; - u.l.upper = ldl_be_p(ptr); - u.l.lower = ldl_be_p((uint8_t *)ptr + 4); - return u.d; -} - -static inline void stfq_be_p(void *ptr, float64 v) -{ - CPU_DoubleU u; - u.d = v; - stl_be_p(ptr, u.l.upper); - stl_be_p((uint8_t *)ptr + 4, u.l.lower); -} - -#else - -static inline int lduw_be_p(const void *ptr) -{ - return *(uint16_t *)ptr; -} - -static inline int ldsw_be_p(const void *ptr) -{ - return *(int16_t *)ptr; -} - -static inline int ldl_be_p(const void *ptr) -{ - return *(uint32_t *)ptr; -} - -static inline uint64_t ldq_be_p(const void *ptr) -{ - return *(uint64_t *)ptr; -} - -static inline void stw_be_p(void *ptr, int v) -{ - *(uint16_t *)ptr = v; -} - -static inline void stl_be_p(void *ptr, int v) -{ - *(uint32_t *)ptr = v; -} - -static inline void stq_be_p(void *ptr, uint64_t v) -{ - *(uint64_t *)ptr = v; -} - -/* float access */ - -static inline float32 ldfl_be_p(const void *ptr) -{ - return *(float32 *)ptr; -} - -static inline float64 ldfq_be_p(const void *ptr) -{ - return *(float64 *)ptr; -} - -static inline void stfl_be_p(void *ptr, float32 v) -{ - *(float32 *)ptr = v; -} - -static inline void stfq_be_p(void *ptr, float64 v) -{ - *(float64 *)ptr = v; -} - -#endif - -#endif /* BSWAP_H */ diff --git a/bt-host.c b/bt-host.c index 65aaca337c..4f5f9f93c5 100644 --- a/bt-host.c +++ b/bt-host.c @@ -19,7 +19,7 @@ #include "qemu-common.h" #include "bt-host.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifndef _WIN32 # include diff --git a/bt-vhci.c b/bt-vhci.c index 13c0e53729..f5d856a809 100644 --- a/bt-vhci.c +++ b/bt-vhci.c @@ -20,7 +20,7 @@ #include "qemu-common.h" #include "bt-host.h" #include "hw/bt.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #define VHCI_DEV "/dev/vhci" #define VHCI_UDEV "/dev/hci_vhci" diff --git a/buffered_file.c b/buffered_file.c index f13443ee91..27627a1b71 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "buffered_file.h" //#define DEBUG_BUFFERED_FILE diff --git a/cache-utils.c b/cache-utils.c index 2db5af2db1..b94013a8cb 100644 --- a/cache-utils.c +++ b/cache-utils.c @@ -1,4 +1,4 @@ -#include "cache-utils.h" +#include "qemu/cache-utils.h" #if defined(_ARCH_PPC) struct qemu_cache_conf qemu_cache_conf = { diff --git a/cache-utils.h b/cache-utils.h deleted file mode 100644 index 2c57f78fc1..0000000000 --- a/cache-utils.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef QEMU_CACHE_UTILS_H -#define QEMU_CACHE_UTILS_H - -#if defined(_ARCH_PPC) - -#include /* uintptr_t */ - -struct qemu_cache_conf { - unsigned long dcache_bsize; - unsigned long icache_bsize; -}; - -extern struct qemu_cache_conf qemu_cache_conf; - -void qemu_cache_utils_init(char **envp); - -/* mildly adjusted code from tcg-dyngen.c */ -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - unsigned long p, start1, stop1; - unsigned long dsize = qemu_cache_conf.dcache_bsize; - unsigned long isize = qemu_cache_conf.icache_bsize; - - start1 = start & ~(dsize - 1); - stop1 = (stop + dsize - 1) & ~(dsize - 1); - for (p = start1; p < stop1; p += dsize) { - asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - - start &= start & ~(isize - 1); - stop1 = (stop + isize - 1) & ~(isize - 1); - for (p = start1; p < stop1; p += isize) { - asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - asm volatile ("isync" : : : "memory"); -} - -#else -#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) -#endif - -#endif /* QEMU_CACHE_UTILS_H */ diff --git a/cmd.c b/cmd.c index 01a8c3a299..10a8688b2d 100644 --- a/cmd.c +++ b/cmd.c @@ -25,7 +25,7 @@ #include "cmd.h" #include "block/aio.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #define _(x) x /* not gettext support yet */ diff --git a/compatfd.c b/compatfd.c index 42f81cafe4..9cf3f2834d 100644 --- a/compatfd.c +++ b/compatfd.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "compatfd.h" +#include "qemu/compatfd.h" #include #include diff --git a/compatfd.h b/compatfd.h deleted file mode 100644 index 6b04877b97..0000000000 --- a/compatfd.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * signalfd/eventfd compatibility - * - * Copyright IBM, Corp. 2008 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_COMPATFD_H -#define QEMU_COMPATFD_H - -#include - -struct qemu_signalfd_siginfo { - uint32_t ssi_signo; /* Signal number */ - int32_t ssi_errno; /* Error number (unused) */ - int32_t ssi_code; /* Signal code */ - uint32_t ssi_pid; /* PID of sender */ - uint32_t ssi_uid; /* Real UID of sender */ - int32_t ssi_fd; /* File descriptor (SIGIO) */ - uint32_t ssi_tid; /* Kernel timer ID (POSIX timers) */ - uint32_t ssi_band; /* Band event (SIGIO) */ - uint32_t ssi_overrun; /* POSIX timer overrun count */ - uint32_t ssi_trapno; /* Trap number that caused signal */ - int32_t ssi_status; /* Exit status or signal (SIGCHLD) */ - int32_t ssi_int; /* Integer sent by sigqueue(2) */ - uint64_t ssi_ptr; /* Pointer sent by sigqueue(2) */ - uint64_t ssi_utime; /* User CPU time consumed (SIGCHLD) */ - uint64_t ssi_stime; /* System CPU time consumed (SIGCHLD) */ - uint64_t ssi_addr; /* Address that generated signal - (for hardware-generated signals) */ - uint8_t pad[48]; /* Pad size to 128 bytes (allow for - additional fields in the future) */ -}; - -int qemu_signalfd(const sigset_t *mask); -bool qemu_signalfd_available(void); - -#endif diff --git a/compiler.h b/compiler.h deleted file mode 100644 index 2f7998b6c1..0000000000 --- a/compiler.h +++ /dev/null @@ -1,58 +0,0 @@ -/* public domain */ - -#ifndef COMPILER_H -#define COMPILER_H - -#include "config-host.h" - -/*---------------------------------------------------------------------------- -| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler. -| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h. -*----------------------------------------------------------------------------*/ -#if defined(__GNUC__) && defined(__GNUC_MINOR__) -# define QEMU_GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -#else -# define QEMU_GNUC_PREREQ(maj, min) 0 -#endif - -#define QEMU_NORETURN __attribute__ ((__noreturn__)) - -#if QEMU_GNUC_PREREQ(3, 4) -#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -#define QEMU_WARN_UNUSED_RESULT -#endif - -#if defined(_WIN32) -# define QEMU_PACKED __attribute__((gcc_struct, packed)) -#else -# define QEMU_PACKED __attribute__((packed)) -#endif - -#define cat(x,y) x ## y -#define cat2(x,y) cat(x,y) -#define QEMU_BUILD_BUG_ON(x) \ - typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1]; - -#if defined __GNUC__ -# if !QEMU_GNUC_PREREQ(4, 4) - /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */ -# define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2))) -# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m))) -# else - /* Use gnu_printf when supported (qemu uses standard format strings). */ -# define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2))) -# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m))) -# if defined(_WIN32) - /* Map __printf__ to __gnu_printf__ because we want standard format strings - * even when MinGW or GLib include files use __printf__. */ -# define __printf__ __gnu_printf__ -# endif -# endif -#else -#define GCC_ATTR /**/ -#define GCC_FMT_ATTR(n, m) -#endif - -#endif /* COMPILER_H */ diff --git a/cpu-exec.c b/cpu-exec.c index b5a32b84e4..54e62ed551 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg.h" -#include "qemu-barrier.h" +#include "qemu/atomic.h" #include "qtest.h" int tb_invalidated_flag; diff --git a/cpus.c b/cpus.c index 3a66401e0d..036418d62c 100644 --- a/cpus.c +++ b/cpus.c @@ -32,14 +32,14 @@ #include "kvm.h" #include "qmp-commands.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "cpus.h" #include "qtest.h" -#include "main-loop.h" -#include "bitmap.h" +#include "qemu/main-loop.h" +#include "qemu/bitmap.h" #ifndef _WIN32 -#include "compatfd.h" +#include "qemu/compatfd.h" #endif #ifdef CONFIG_LINUX diff --git a/cutils.c b/cutils.c index 4f0692f78e..d06590b330 100644 --- a/cutils.c +++ b/cutils.c @@ -22,11 +22,11 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include -#include "qemu_socket.h" -#include "iov.h" +#include "qemu/sockets.h" +#include "qemu/iov.h" void strpadcpy(char *buf, int buf_size, const char *str, char pad) { diff --git a/device_tree.c b/device_tree.c index a9236133c7..c3e1ba4904 100644 --- a/device_tree.c +++ b/device_tree.c @@ -22,8 +22,8 @@ #include "qemu-common.h" #include "device_tree.h" #include "hw/loader.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include diff --git a/dma-helpers.c b/dma-helpers.c index 4f5fb649e7..e6a6dd82fd 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -9,8 +9,8 @@ #include "dma.h" #include "trace.h" -#include "range.h" -#include "qemu-thread.h" +#include "qemu/range.h" +#include "qemu/thread.h" /* #define DEBUG_IOMMU */ diff --git a/envlist.c b/envlist.c index f2303cdd79..ff99fc44e9 100644 --- a/envlist.c +++ b/envlist.c @@ -4,8 +4,8 @@ #include #include -#include "qemu-queue.h" -#include "envlist.h" +#include "qemu/queue.h" +#include "qemu/envlist.h" struct envlist_entry { const char *ev_var; /* actual env value */ diff --git a/envlist.h b/envlist.h deleted file mode 100644 index b9addcc11f..0000000000 --- a/envlist.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef ENVLIST_H -#define ENVLIST_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct envlist envlist_t; - -envlist_t *envlist_create(void); -void envlist_free(envlist_t *); -int envlist_setenv(envlist_t *, const char *); -int envlist_unsetenv(envlist_t *, const char *); -int envlist_parse_set(envlist_t *, const char *); -int envlist_parse_unset(envlist_t *, const char *); -char **envlist_to_environ(const envlist_t *, size_t *); - -#ifdef __cplusplus -} -#endif - -#endif /* ENVLIST_H */ diff --git a/event_notifier-posix.c b/event_notifier-posix.c index f0bd839acd..a53b95688d 100644 --- a/event_notifier-posix.c +++ b/event_notifier-posix.c @@ -11,9 +11,9 @@ */ #include "qemu-common.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "qemu-char.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifdef CONFIG_EVENTFD #include diff --git a/event_notifier-win32.c b/event_notifier-win32.c index 4ed21c2a7c..6dbb530cfa 100644 --- a/event_notifier-win32.c +++ b/event_notifier-win32.c @@ -11,8 +11,8 @@ */ #include "qemu-common.h" -#include "event_notifier.h" -#include "main-loop.h" +#include "qemu/event_notifier.h" +#include "qemu/main-loop.h" int event_notifier_init(EventNotifier *e, int active) { diff --git a/event_notifier.h b/event_notifier.h deleted file mode 100644 index 88b57af7ce..0000000000 --- a/event_notifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * event notifier support - * - * Copyright Red Hat, Inc. 2010 - * - * Authors: - * Michael S. Tsirkin - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef QEMU_EVENT_NOTIFIER_H -#define QEMU_EVENT_NOTIFIER_H - -#include "qemu-common.h" - -#ifdef _WIN32 -#include -#endif - -struct EventNotifier { -#ifdef _WIN32 - HANDLE event; -#else - int rfd; - int wfd; -#endif -}; - -typedef void EventNotifierHandler(EventNotifier *); - -int event_notifier_init(EventNotifier *, int active); -void event_notifier_cleanup(EventNotifier *); -int event_notifier_set(EventNotifier *); -int event_notifier_test_and_clear(EventNotifier *); -int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *); - -#ifdef CONFIG_POSIX -void event_notifier_init_fd(EventNotifier *, int fd); -int event_notifier_get_fd(EventNotifier *); -#else -HANDLE event_notifier_get_handle(EventNotifier *); -#endif - -#endif diff --git a/exec.c b/exec.c index 17fc7cf854..917bec0ecd 100644 --- a/exec.c +++ b/exec.c @@ -29,11 +29,11 @@ #include "tcg.h" #include "hw/hw.h" #include "hw/qdev.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "kvm.h" #include "hw/xen.h" -#include "qemu-timer.h" -#include "qemu-config.h" +#include "qemu/timer.h" +#include "qemu/config-file.h" #include "exec/memory.h" #include "dma.h" #include "exec/address-spaces.h" diff --git a/fpu/softfloat.h b/fpu/softfloat.h index d8999b311a..0946f0739d 100644 --- a/fpu/softfloat.h +++ b/fpu/softfloat.h @@ -44,7 +44,7 @@ these four paragraphs for those parts of this code that are retained. #include #include "config-host.h" -#include "osdep.h" +#include "qemu/osdep.h" /*---------------------------------------------------------------------------- | Each of the following `typedef's defines the most convenient type that holds diff --git a/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c index 300f2758be..4bcf38fe4b 100644 --- a/fsdev/qemu-fsdev-dummy.c +++ b/fsdev/qemu-fsdev-dummy.c @@ -13,8 +13,8 @@ #include #include #include "qemu-fsdev.h" -#include "qemu-config.h" -#include "module.h" +#include "qemu/config-file.h" +#include "qemu/module.h" int qemu_fsdev_add(QemuOpts *opts) { diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index e20202a4bf..4cc04d4fde 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -13,10 +13,10 @@ #include #include #include "qemu-fsdev.h" -#include "qemu-queue.h" -#include "osdep.h" +#include "qemu/queue.h" +#include "qemu/osdep.h" #include "qemu-common.h" -#include "qemu-config.h" +#include "qemu/config-file.h" static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries = QTAILQ_HEAD_INITIALIZER(fsdriver_entries); diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h index 1af1f545d8..9fa45bf510 100644 --- a/fsdev/qemu-fsdev.h +++ b/fsdev/qemu-fsdev.h @@ -12,7 +12,7 @@ */ #ifndef QEMU_FSDEV_H #define QEMU_FSDEV_H -#include "qemu-option.h" +#include "qemu/option.h" #include "file-op-9p.h" diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index df2a9392b1..6b9afd32d5 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -21,8 +21,8 @@ #include #endif #include "qemu-common.h" -#include "qemu_socket.h" -#include "qemu-xattr.h" +#include "qemu/sockets.h" +#include "qemu/xattr.h" #include "virtio-9p-marshal.h" #include "hw/9pfs/virtio-9p-proxy.h" #include "fsdev/virtio-9p-marshal.h" diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c index bf980bfa38..20f308b760 100644 --- a/fsdev/virtio-9p-marshal.c +++ b/fsdev/virtio-9p-marshal.c @@ -22,9 +22,9 @@ #include #include -#include "compiler.h" +#include "qemu/compiler.h" #include "virtio-9p-marshal.h" -#include "bswap.h" +#include "qemu/bswap.h" void v9fs_string_free(V9fsString *str) { diff --git a/gdbstub.c b/gdbstub.c index 9395c829a2..4b178a608f 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -38,7 +38,7 @@ #define MAX_PACKET_LENGTH 4096 #include "cpu.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "kvm.h" #ifndef TARGET_CPU_MEMORY_RW_DEBUG diff --git a/hmp.c b/hmp.c index a76a8f06ea..3d056b0e38 100644 --- a/hmp.c +++ b/hmp.c @@ -16,10 +16,10 @@ #include "hmp.h" #include "net/net.h" #include "qemu-char.h" -#include "qemu-option.h" -#include "qemu-timer.h" +#include "qemu/option.h" +#include "qemu/timer.h" #include "qmp-commands.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "monitor/monitor.h" #include "ui/console.h" diff --git a/host-utils.c b/host-utils.c index dc9612387b..5e3915abba 100644 --- a/host-utils.c +++ b/host-utils.c @@ -25,7 +25,7 @@ #include #include -#include "host-utils.h" +#include "qemu/host-utils.h" //#define DEBUG_MULDIV diff --git a/host-utils.h b/host-utils.h deleted file mode 100644 index a5f8464fb2..0000000000 --- a/host-utils.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Utility compute operations used by translated code. - * - * Copyright (c) 2007 Thiemo Seufer - * Copyright (c) 2007 Jocelyn Mayer - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef HOST_UTILS_H -#define HOST_UTILS_H 1 - -#include "compiler.h" /* QEMU_GNUC_PREREQ */ - -#if defined(__x86_64__) -#define __HAVE_FAST_MULU64__ -static inline void mulu64(uint64_t *plow, uint64_t *phigh, - uint64_t a, uint64_t b) -{ - __asm__ ("mul %0\n\t" - : "=d" (*phigh), "=a" (*plow) - : "a" (a), "0" (b)); -} -#define __HAVE_FAST_MULS64__ -static inline void muls64(uint64_t *plow, uint64_t *phigh, - int64_t a, int64_t b) -{ - __asm__ ("imul %0\n\t" - : "=d" (*phigh), "=a" (*plow) - : "a" (a), "0" (b)); -} -#else -void muls64(uint64_t *phigh, uint64_t *plow, int64_t a, int64_t b); -void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); -#endif - -/* Binary search for leading zeros. */ - -static inline int clz32(uint32_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_clz(val); - else - return 32; -#else - int cnt = 0; - - if (!(val & 0xFFFF0000U)) { - cnt += 16; - val <<= 16; - } - if (!(val & 0xFF000000U)) { - cnt += 8; - val <<= 8; - } - if (!(val & 0xF0000000U)) { - cnt += 4; - val <<= 4; - } - if (!(val & 0xC0000000U)) { - cnt += 2; - val <<= 2; - } - if (!(val & 0x80000000U)) { - cnt++; - val <<= 1; - } - if (!(val & 0x80000000U)) { - cnt++; - } - return cnt; -#endif -} - -static inline int clo32(uint32_t val) -{ - return clz32(~val); -} - -static inline int clz64(uint64_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_clzll(val); - else - return 64; -#else - int cnt = 0; - - if (!(val >> 32)) { - cnt += 32; - } else { - val >>= 32; - } - - return cnt + clz32(val); -#endif -} - -static inline int clo64(uint64_t val) -{ - return clz64(~val); -} - -static inline int ctz32(uint32_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_ctz(val); - else - return 32; -#else - int cnt; - - cnt = 0; - if (!(val & 0x0000FFFFUL)) { - cnt += 16; - val >>= 16; - } - if (!(val & 0x000000FFUL)) { - cnt += 8; - val >>= 8; - } - if (!(val & 0x0000000FUL)) { - cnt += 4; - val >>= 4; - } - if (!(val & 0x00000003UL)) { - cnt += 2; - val >>= 2; - } - if (!(val & 0x00000001UL)) { - cnt++; - val >>= 1; - } - if (!(val & 0x00000001UL)) { - cnt++; - } - - return cnt; -#endif -} - -static inline int cto32(uint32_t val) -{ - return ctz32(~val); -} - -static inline int ctz64(uint64_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_ctzll(val); - else - return 64; -#else - int cnt; - - cnt = 0; - if (!((uint32_t)val)) { - cnt += 32; - val >>= 32; - } - - return cnt + ctz32(val); -#endif -} - -static inline int cto64(uint64_t val) -{ - return ctz64(~val); -} - -static inline int ctpop8(uint8_t val) -{ - val = (val & 0x55) + ((val >> 1) & 0x55); - val = (val & 0x33) + ((val >> 2) & 0x33); - val = (val & 0x0f) + ((val >> 4) & 0x0f); - - return val; -} - -static inline int ctpop16(uint16_t val) -{ - val = (val & 0x5555) + ((val >> 1) & 0x5555); - val = (val & 0x3333) + ((val >> 2) & 0x3333); - val = (val & 0x0f0f) + ((val >> 4) & 0x0f0f); - val = (val & 0x00ff) + ((val >> 8) & 0x00ff); - - return val; -} - -static inline int ctpop32(uint32_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - return __builtin_popcount(val); -#else - val = (val & 0x55555555) + ((val >> 1) & 0x55555555); - val = (val & 0x33333333) + ((val >> 2) & 0x33333333); - val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f); - val = (val & 0x00ff00ff) + ((val >> 8) & 0x00ff00ff); - val = (val & 0x0000ffff) + ((val >> 16) & 0x0000ffff); - - return val; -#endif -} - -static inline int ctpop64(uint64_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - return __builtin_popcountll(val); -#else - val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); - val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL); - val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL); - val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & 0x00ff00ff00ff00ffULL); - val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL); - val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL); - - return val; -#endif -} - -#endif diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index cd137330b9..65ad3298be 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c index 6d6dac7abf..2efebf3571 100644 --- a/hw/9pfs/cofile.c +++ b/hw/9pfs/cofile.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/cofs.c b/hw/9pfs/cofs.c index 4b9ba30157..3891050748 100644 --- a/hw/9pfs/cofs.c +++ b/hw/9pfs/cofs.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/coxattr.c b/hw/9pfs/coxattr.c index 08365a697e..18ee08df0f 100644 --- a/hw/9pfs/coxattr.c +++ b/hw/9pfs/coxattr.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c index 958725e5cc..ae6cde8005 100644 --- a/hw/9pfs/virtio-9p-coth.c +++ b/hw/9pfs/virtio-9p-coth.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/virtio-9p-coth.h b/hw/9pfs/virtio-9p-coth.h index 8c48a16c10..86d5ed4169 100644 --- a/hw/9pfs/virtio-9p-coth.h +++ b/hw/9pfs/virtio-9p-coth.h @@ -15,7 +15,7 @@ #ifndef _QEMU_VIRTIO_9P_COTH_H #define _QEMU_VIRTIO_9P_COTH_H -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p.h" #include diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index b8220abae7..6761bce9dc 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -13,7 +13,7 @@ #include "hw/virtio.h" #include "hw/pc.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "hw/virtio-pci.h" #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c index f96d17a974..e30fdb6730 100644 --- a/hw/9pfs/virtio-9p-handle.c +++ b/hw/9pfs/virtio-9p-handle.c @@ -19,7 +19,7 @@ #include #include #include -#include "qemu-xattr.h" +#include "qemu/xattr.h" #include #include #ifdef CONFIG_LINUX_MAGIC_H diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c index 33a41d2e18..113602144c 100644 --- a/hw/9pfs/virtio-9p-local.c +++ b/hw/9pfs/virtio-9p-local.c @@ -19,7 +19,7 @@ #include #include #include -#include "qemu-xattr.h" +#include "qemu/xattr.h" #include #include #ifdef CONFIG_LINUX_MAGIC_H diff --git a/hw/9pfs/virtio-9p-posix-acl.c b/hw/9pfs/virtio-9p-posix-acl.c index c064017b1f..08bb0e8bca 100644 --- a/hw/9pfs/virtio-9p-posix-acl.c +++ b/hw/9pfs/virtio-9p-posix-acl.c @@ -12,7 +12,7 @@ */ #include -#include "qemu-xattr.h" +#include "qemu/xattr.h" #include "hw/virtio.h" #include "virtio-9p.h" #include "fsdev/file-op-9p.h" diff --git a/hw/9pfs/virtio-9p-xattr.h b/hw/9pfs/virtio-9p-xattr.h index 9437280c99..41cc6cbc7b 100644 --- a/hw/9pfs/virtio-9p-xattr.h +++ b/hw/9pfs/virtio-9p-xattr.h @@ -13,7 +13,7 @@ #ifndef _QEMU_VIRTIO_9P_XATTR_H #define _QEMU_VIRTIO_9P_XATTR_H -#include "qemu-xattr.h" +#include "qemu/xattr.h" typedef struct xattr_operations { diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index ede20ce80e..0aaf0d2de0 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -13,7 +13,7 @@ #include "hw/virtio.h" #include "hw/pc.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "hw/virtio-pci.h" #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 2c0c3baad4..406fe522db 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -9,7 +9,7 @@ #include "hw/virtio.h" #include "fsdev/file-op-9p.h" #include "fsdev/virtio-9p-marshal.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" diff --git a/hw/acpi.h b/hw/acpi.h index afda153d09..c3628d070d 100644 --- a/hw/acpi.h +++ b/hw/acpi.h @@ -127,7 +127,7 @@ void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci, MemoryRegion *parent); void acpi_pm_tmr_reset(ACPIREGS *ar); -#include "qemu-timer.h" +#include "qemu/timer.h" static inline int64_t acpi_pm_tmr_get_clock(void) { return muldiv64(qemu_get_clock_ns(vm_clock), PM_TIMER_FREQUENCY, diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c index 92af3a554c..8d1a689a36 100644 --- a/hw/acpi_ich9.c +++ b/hw/acpi_ich9.c @@ -26,7 +26,7 @@ #include "hw.h" #include "pc.h" #include "pci/pci.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "acpi.h" #include "kvm.h" diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index 4f43f6e070..ebd015dc02 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -25,7 +25,7 @@ #include "pci/pci.h" #include "acpi.h" #include "sysemu.h" -#include "range.h" +#include "qemu/range.h" #include "exec/ioport.h" #include "fw_cfg.h" #include "exec/address-spaces.h" diff --git a/hw/adlib.c b/hw/adlib.c index d39cd97384..07c69fc967 100644 --- a/hw/adlib.c +++ b/hw/adlib.c @@ -32,7 +32,7 @@ #define ADLIB_KILL_TIMERS 1 #ifdef DEBUG -#include "qemu-timer.h" +#include "qemu/timer.h" #endif #define dolog(...) AUD_log ("adlib", __VA_ARGS__) diff --git a/hw/alpha_pci.c b/hw/alpha_pci.c index 7e7b1d27d2..78d93e55ec 100644 --- a/hw/alpha_pci.c +++ b/hw/alpha_pci.c @@ -8,7 +8,7 @@ #include "config.h" #include "alpha_sys.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "sysemu.h" diff --git a/hw/apic.c b/hw/apic.c index d66a476aac..81b82f694c 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -16,12 +16,12 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see */ -#include "qemu-thread.h" +#include "qemu/thread.h" #include "apic_internal.h" #include "apic.h" #include "ioapic.h" #include "pci/msi.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "trace.h" #include "pc.h" #include "apic-msidef.h" diff --git a/hw/apic_internal.h b/hw/apic_internal.h index fea95654ca..dcbbfd41cb 100644 --- a/hw/apic_internal.h +++ b/hw/apic_internal.h @@ -22,7 +22,7 @@ #include "exec/memory.h" #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* APIC Local Vector Table */ #define APIC_LVT_TIMER 0 diff --git a/hw/applesmc.c b/hw/applesmc.c index 91e7cb3d5c..c564b60c0a 100644 --- a/hw/applesmc.c +++ b/hw/applesmc.c @@ -33,7 +33,7 @@ #include "hw.h" #include "isa.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* #define DEBUG_SMC */ diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c index 640ed20a61..093331124a 100644 --- a/hw/arm11mpcore.c +++ b/hw/arm11mpcore.c @@ -8,7 +8,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* MPCore private memory region. */ diff --git a/hw/arm_boot.c b/hw/arm_boot.c index 63ff559cf7..bb9889fbef 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -15,7 +15,7 @@ #include "loader.h" #include "elf.h" #include "device_tree.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #define KERNEL_ARGS_ADDR 0x100 #define KERNEL_LOAD_ADDR 0x00010000 diff --git a/hw/arm_mptimer.c b/hw/arm_mptimer.c index 6790832236..1febaeb7b1 100644 --- a/hw/arm_mptimer.c +++ b/hw/arm_mptimer.c @@ -20,7 +20,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* This device implements the per-cpu private timer and watchdog block * which is used in both the ARM11MPCore and Cortex-A9MP. diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c index 58eb98216d..0884f6275c 100644 --- a/hw/arm_sysctl.c +++ b/hw/arm_sysctl.c @@ -8,7 +8,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysbus.h" #include "primecell.h" #include "sysemu.h" diff --git a/hw/arm_timer.c b/hw/arm_timer.c index af339d3d19..37e28e993c 100644 --- a/hw/arm_timer.c +++ b/hw/arm_timer.c @@ -8,7 +8,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "qdev.h" #include "ptimer.h" diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c index 270c307717..0907e42c0c 100644 --- a/hw/armv7m_nvic.c +++ b/hw/armv7m_nvic.c @@ -11,7 +11,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "arm-misc.h" #include "exec/address-spaces.h" #include "arm_gic_internal.h" diff --git a/hw/baum.c b/hw/baum.c index 3e94f84e51..97d13ea344 100644 --- a/hw/baum.c +++ b/hw/baum.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "usb.h" #include "baum.h" #include diff --git a/hw/block-common.c b/hw/block-common.c index f0196d78dc..c24208e560 100644 --- a/hw/block-common.c +++ b/hw/block-common.c @@ -9,7 +9,7 @@ #include "blockdev.h" #include "hw/block-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" void blkconf_serial(BlockConf *conf, char **serial) { diff --git a/hw/bt-hci-csr.c b/hw/bt-hci-csr.c index 0faabbb585..e1dcb6d099 100644 --- a/hw/bt-hci-csr.c +++ b/hw/bt-hci-csr.c @@ -20,7 +20,7 @@ #include "qemu-common.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "irq.h" #include "bt-host.h" #include "bt.h" diff --git a/hw/bt-hci.c b/hw/bt-hci.c index d2ad57faa9..da096d8c37 100644 --- a/hw/bt-hci.c +++ b/hw/bt-hci.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "usb.h" #include "bt-host.h" #include "bt.h" diff --git a/hw/bt-hid.c b/hw/bt-hid.c index 0ec0c013b0..cfa7c145b8 100644 --- a/hw/bt-hid.c +++ b/hw/bt-hid.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" #include "hid.h" #include "bt.h" diff --git a/hw/bt-l2cap.c b/hw/bt-l2cap.c index cb43ee7733..ba061c0da3 100644 --- a/hw/bt-l2cap.c +++ b/hw/bt-l2cap.c @@ -18,7 +18,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "bt.h" #define L2CAP_CID_MAX 0x100 /* Between 0x40 and 0x10000 */ diff --git a/hw/cadence_ttc.c b/hw/cadence_ttc.c index ec78a52180..9e1cb1f152 100644 --- a/hw/cadence_ttc.c +++ b/hw/cadence_ttc.c @@ -17,7 +17,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CADENCE_TTC_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/hw/cadence_uart.c b/hw/cadence_uart.c index 686e6172d0..f34acc8c46 100644 --- a/hw/cadence_uart.c +++ b/hw/cadence_uart.c @@ -18,7 +18,7 @@ #include "sysbus.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CADENCE_UART_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c index 845a764446..e508380482 100644 --- a/hw/ccid-card-emulated.c +++ b/hw/ccid-card-emulated.c @@ -31,7 +31,7 @@ #include #include -#include "qemu-thread.h" +#include "qemu/thread.h" #include "qemu-char.h" #include "monitor/monitor.h" #include "hw/ccid.h" diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c index f5b4794e90..48e4228b9d 100644 --- a/hw/ccid-card-passthru.c +++ b/hw/ccid-card-passthru.c @@ -9,7 +9,7 @@ */ #include "qemu-char.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "monitor/monitor.h" #include "hw/ccid.h" #include "libcacard/vscard_common.h" diff --git a/hw/cs4231a.c b/hw/cs4231a.c index 0257fd8d2a..9d528c43b0 100644 --- a/hw/cs4231a.c +++ b/hw/cs4231a.c @@ -26,7 +26,7 @@ #include "audio/audio.h" #include "isa.h" #include "qdev.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* Missing features: diff --git a/hw/cuda.c b/hw/cuda.c index f1f408b839..cf83956e1a 100644 --- a/hw/cuda.c +++ b/hw/cuda.c @@ -25,7 +25,7 @@ #include "hw.h" #include "ppc_mac.h" #include "adb.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" /* XXX: implement all timer modes */ diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 809a598e3a..34543786e5 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -25,7 +25,7 @@ #include "hw.h" #include "boards.h" #include "blockdev.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "sysemu.h" #include "monitor/monitor.h" diff --git a/hw/dma.c b/hw/dma.c index 364f54d2d7..0634baa552 100644 --- a/hw/dma.c +++ b/hw/dma.c @@ -23,7 +23,7 @@ */ #include "hw.h" #include "isa.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /* #define DEBUG_DMA */ diff --git a/hw/dp8393x.c b/hw/dp8393x.c index d59b6118ad..b5014501df 100644 --- a/hw/dp8393x.c +++ b/hw/dp8393x.c @@ -18,7 +18,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "net/net.h" #include "mips.h" diff --git a/hw/esp-pci.c b/hw/esp-pci.c index d433473d6a..c949e6e0d9 100644 --- a/hw/esp-pci.c +++ b/hw/esp-pci.c @@ -27,7 +27,7 @@ #include "eeprom93xx.h" #include "esp.h" #include "trace.h" -#include "qemu-log.h" +#include "qemu/log.h" #define TYPE_AM53C974_DEVICE "am53c974" diff --git a/hw/esp.c b/hw/esp.c index 6d01624a49..0e4e430880 100644 --- a/hw/esp.c +++ b/hw/esp.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "esp.h" #include "trace.h" -#include "qemu-log.h" +#include "qemu/log.h" /* * On Sparc32, this is the ESP (NCR53C90) part of chip STP2000 (Master I/O), diff --git a/hw/etraxfs_ser.c b/hw/etraxfs_ser.c index ee0d72bf87..59cb7d2172 100644 --- a/hw/etraxfs_ser.c +++ b/hw/etraxfs_ser.c @@ -24,7 +24,7 @@ #include "sysbus.h" #include "qemu-char.h" -#include "qemu-log.h" +#include "qemu/log.h" #define D(x) diff --git a/hw/etraxfs_timer.c b/hw/etraxfs_timer.c index f5601dc7a5..cc8b327715 100644 --- a/hw/etraxfs_timer.c +++ b/hw/etraxfs_timer.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #define D(x) diff --git a/hw/exynos4210_fimd.c b/hw/exynos4210_fimd.c index cfca72ab67..5c29b5d01d 100644 --- a/hw/exynos4210_fimd.c +++ b/hw/exynos4210_fimd.c @@ -27,7 +27,7 @@ #include "sysbus.h" #include "ui/console.h" #include "ui/pixel_ops.h" -#include "bswap.h" +#include "qemu/bswap.h" /* Debug messages configuration */ #define EXYNOS4210_FIMD_DEBUG 0 diff --git a/hw/exynos4210_i2c.c b/hw/exynos4210_i2c.c index 1e11d9b48c..cefd736092 100644 --- a/hw/exynos4210_i2c.c +++ b/hw/exynos4210_i2c.c @@ -20,7 +20,7 @@ * */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysbus.h" #include "i2c.h" diff --git a/hw/exynos4210_mct.c b/hw/exynos4210_mct.c index 37dbda92df..41cd142227 100644 --- a/hw/exynos4210_mct.c +++ b/hw/exynos4210_mct.c @@ -53,7 +53,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "ptimer.h" diff --git a/hw/exynos4210_pwm.c b/hw/exynos4210_pwm.c index 5e2872f8f7..3a3eb8c27a 100644 --- a/hw/exynos4210_pwm.c +++ b/hw/exynos4210_pwm.c @@ -21,7 +21,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "ptimer.h" diff --git a/hw/exynos4210_rtc.c b/hw/exynos4210_rtc.c index c4fbd49461..6ebc9b1790 100644 --- a/hw/exynos4210_rtc.c +++ b/hw/exynos4210_rtc.c @@ -26,12 +26,12 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "ptimer.h" #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "exynos4210.h" diff --git a/hw/fdc.c b/hw/fdc.c index 29b5449ff8..b67d3a574b 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -29,14 +29,14 @@ #include "hw.h" #include "fdc.h" -#include "qemu-error.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" #include "isa.h" #include "sysbus.h" #include "qdev-addr.h" #include "blockdev.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" /********************************************************/ /* debug Floppy devices */ diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index 7b0e50f70d..2a00163a04 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -26,8 +26,8 @@ #include "isa.h" #include "fw_cfg.h" #include "sysbus.h" -#include "qemu-error.h" -#include "qemu-config.h" +#include "qemu/error-report.h" +#include "qemu/config-file.h" /* debug firmware config */ //#define DEBUG_FW_CFG diff --git a/hw/grlib_gptimer.c b/hw/grlib_gptimer.c index 2fdccfba06..252ba893e3 100644 --- a/hw/grlib_gptimer.c +++ b/hw/grlib_gptimer.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "trace.h" diff --git a/hw/hid.c b/hw/hid.c index 7935998e83..0fee3b6ddd 100644 --- a/hw/hid.c +++ b/hw/hid.c @@ -24,7 +24,7 @@ */ #include "hw.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hid.h" #define HID_USAGE_ERROR_ROLLOVER 0x01 diff --git a/hw/hpet.c b/hw/hpet.c index 49e1b631b5..78c0662dfc 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -27,7 +27,7 @@ #include "hw.h" #include "pc.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hpet_emul.h" #include "sysbus.h" #include "mc146818rtc.h" diff --git a/hw/hw.h b/hw/hw.h index 883ddb60f9..dfced97bbc 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -13,7 +13,7 @@ #include "block/aio.h" #include "migration/qemu-file.h" #include "migration/vmstate.h" -#include "qemu-log.h" +#include "qemu/log.h" #ifdef NEED_CPU_H #if TARGET_LONG_BITS == 64 diff --git a/hw/i8254.c b/hw/i8254.c index bea5f92fd2..7c2aa6238d 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -24,7 +24,7 @@ #include "hw.h" #include "pc.h" #include "isa.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8254.h" #include "i8254_internal.h" diff --git a/hw/i8254_common.c b/hw/i8254_common.c index a03d7cd458..08ab8d14bd 100644 --- a/hw/i8254_common.c +++ b/hw/i8254_common.c @@ -25,7 +25,7 @@ #include "hw.h" #include "pc.h" #include "isa.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8254.h" #include "i8254_internal.h" diff --git a/hw/i8259.c b/hw/i8259.c index 5e935e7f99..8fc6339250 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -25,7 +25,7 @@ #include "pc.h" #include "isa.h" #include "monitor/monitor.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8259_internal.h" /* debug PIC */ diff --git a/hw/ich9.h b/hw/ich9.h index 5c73f94caf..b8d8e6d3df 100644 --- a/hw/ich9.h +++ b/hw/ich9.h @@ -2,7 +2,7 @@ #define HW_ICH9_H #include "hw.h" -#include "range.h" +#include "qemu/range.h" #include "isa.h" #include "sysbus.h" #include "pc.h" diff --git a/hw/ide/core.c b/hw/ide/core.c index 0e5bc7fe3b..bf65cb407e 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -26,8 +26,8 @@ #include #include #include -#include "qemu-error.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" #include "sysemu.h" #include "dma.h" #include "hw/block-common.h" diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index f2e4ea4207..c85e1ac018 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -18,7 +18,7 @@ */ #include #include "dma.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include #include "blockdev.h" #include "hw/block-common.h" diff --git a/hw/imx_avic.c b/hw/imx_avic.c index 810979366d..f1f066cf9c 100644 --- a/hw/imx_avic.c +++ b/hw/imx_avic.c @@ -16,7 +16,7 @@ #include "hw.h" #include "sysbus.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #define DEBUG_INT 1 #undef DEBUG_INT /* comment out for debugging */ diff --git a/hw/imx_timer.c b/hw/imx_timer.c index 33f33fb41e..e924c747c5 100644 --- a/hw/imx_timer.c +++ b/hw/imx_timer.c @@ -12,7 +12,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysbus.h" #include "imx.h" diff --git a/hw/intel-hda.c b/hw/intel-hda.c index c21bf7204a..7ef3a15e08 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -20,7 +20,7 @@ #include "hw.h" #include "pci/pci.h" #include "pci/msi.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "audiodev.h" #include "intel-hda.h" #include "intel-hda-defs.h" diff --git a/hw/ivshmem.c b/hw/ivshmem.c index d5b91dd24e..af34f3b582 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -23,7 +23,7 @@ #include "kvm.h" #include "migration/migration.h" #include "qapi/qmp/qerror.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "qemu-char.h" #include diff --git a/hw/kvm/i8254.c b/hw/kvm/i8254.c index 53d13e3123..8ee1c352cf 100644 --- a/hw/kvm/i8254.c +++ b/hw/kvm/i8254.c @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "hw/i8254.h" #include "hw/i8254_internal.h" diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index ff0dc0dfd4..2f06c27e83 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -28,11 +28,11 @@ #include #include "hw/hw.h" #include "hw/pc.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "ui/console.h" #include "hw/loader.h" #include "monitor/monitor.h" -#include "range.h" +#include "qemu/range.h" #include "sysemu.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" diff --git a/hw/lance.c b/hw/lance.c index a384676158..b7265c0fed 100644 --- a/hw/lance.c +++ b/hw/lance.c @@ -37,8 +37,8 @@ #include "sysbus.h" #include "net/net.h" -#include "qemu-timer.h" -#include "qemu_socket.h" +#include "qemu/timer.h" +#include "qemu/sockets.h" #include "sun4m.h" #include "pcnet.h" #include "trace.h" diff --git a/hw/leon3.c b/hw/leon3.c index e8d54e5d06..776ab97a78 100644 --- a/hw/leon3.c +++ b/hw/leon3.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "qemu-char.h" #include "sysemu.h" diff --git a/hw/lm32_sys.c b/hw/lm32_sys.c index a7887d14f6..b3350890cb 100644 --- a/hw/lm32_sys.c +++ b/hw/lm32_sys.c @@ -31,10 +31,10 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-log.h" -#include "qemu-error.h" +#include "qemu/log.h" +#include "qemu/error-report.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" enum { R_CTRL = 0, diff --git a/hw/lm32_timer.c b/hw/lm32_timer.c index a8be9cc168..bd4c346386 100644 --- a/hw/lm32_timer.c +++ b/hw/lm32_timer.c @@ -24,9 +24,9 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #define DEFAULT_FREQUENCY (50*1000000) diff --git a/hw/lm32_uart.c b/hw/lm32_uart.c index adb9287568..bf2f507523 100644 --- a/hw/lm32_uart.c +++ b/hw/lm32_uart.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "trace.h" #include "qemu-char.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_RXTX = 0, diff --git a/hw/lm832x.c b/hw/lm832x.c index b14a089b32..3649e3d249 100644 --- a/hw/lm832x.c +++ b/hw/lm832x.c @@ -20,7 +20,7 @@ #include "hw.h" #include "i2c.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" typedef struct { diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c index e225693721..76217a74fc 100644 --- a/hw/lpc_ich9.c +++ b/hw/lpc_ich9.c @@ -29,7 +29,7 @@ */ #include "qemu-common.h" #include "hw.h" -#include "range.h" +#include "qemu/range.h" #include "isa.h" #include "sysbus.h" #include "pc.h" diff --git a/hw/m48t59.c b/hw/m48t59.c index 491d433ae7..301b10ce79 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -23,7 +23,7 @@ */ #include "hw.h" #include "nvram.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "sysbus.h" #include "isa.h" diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c index 41eee50a35..b894ab21aa 100644 --- a/hw/mac_dbdma.c +++ b/hw/mac_dbdma.c @@ -39,7 +39,7 @@ #include "hw.h" #include "isa.h" #include "mac_dbdma.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /* debug DBDMA */ //#define DEBUG_DBDMA diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 2a1278f393..fba75029df 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "mc146818rtc.h" #include "qapi/visitor.h" diff --git a/hw/mcf5206.c b/hw/mcf5206.c index 5edc931abd..fbc806ac18 100644 --- a/hw/mcf5206.c +++ b/hw/mcf5206.c @@ -7,7 +7,7 @@ */ #include "hw.h" #include "mcf.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysemu.h" #include "exec/address-spaces.h" diff --git a/hw/mcf5208.c b/hw/mcf5208.c index 997b34847c..fea8a69262 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -7,7 +7,7 @@ */ #include "hw.h" #include "mcf.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysemu.h" #include "net/net.h" diff --git a/hw/megasas.c b/hw/megasas.c index f4fbe9790a..e80c0d1c25 100644 --- a/hw/megasas.c +++ b/hw/megasas.c @@ -22,7 +22,7 @@ #include "pci/pci.h" #include "dma.h" #include "pci/msix.h" -#include "iov.h" +#include "qemu/iov.h" #include "scsi.h" #include "scsi-defs.h" #include "trace.h" diff --git a/hw/microblaze_boot.c b/hw/microblaze_boot.c index 02c349c189..76d33021c0 100644 --- a/hw/microblaze_boot.c +++ b/hw/microblaze_boot.c @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qemu-common.h" #include "device_tree.h" #include "loader.h" diff --git a/hw/milkymist-ac97.c b/hw/milkymist-ac97.c index d87656c9ac..f46af1c509 100644 --- a/hw/milkymist-ac97.c +++ b/hw/milkymist-ac97.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "trace.h" #include "audio/audio.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_AC97_CTRL = 0, diff --git a/hw/milkymist-hpdmc.c b/hw/milkymist-hpdmc.c index 5d120a497f..fd54d3129a 100644 --- a/hw/milkymist-hpdmc.c +++ b/hw/milkymist-hpdmc.c @@ -24,7 +24,7 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_SYSTEM = 0, diff --git a/hw/milkymist-memcard.c b/hw/milkymist-memcard.c index ca5df56290..5dc30ace60 100644 --- a/hw/milkymist-memcard.c +++ b/hw/milkymist-memcard.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "sysemu.h" #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "blockdev.h" #include "sd.h" diff --git a/hw/milkymist-minimac2.c b/hw/milkymist-minimac2.c index 926f7f9a8b..4e92ac3dcb 100644 --- a/hw/milkymist-minimac2.c +++ b/hw/milkymist-minimac2.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "trace.h" #include "net/net.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qdev-addr.h" #include diff --git a/hw/milkymist-pfpu.c b/hw/milkymist-pfpu.c index 450bab921f..0521829202 100644 --- a/hw/milkymist-pfpu.c +++ b/hw/milkymist-pfpu.c @@ -25,8 +25,8 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-log.h" -#include "qemu-error.h" +#include "qemu/log.h" +#include "qemu/error-report.h" #include /* #define TRACE_EXEC */ diff --git a/hw/milkymist-softusb.c b/hw/milkymist-softusb.c index 0743668d18..b7beb4bedb 100644 --- a/hw/milkymist-softusb.c +++ b/hw/milkymist-softusb.c @@ -26,7 +26,7 @@ #include "trace.h" #include "ui/console.h" #include "hid.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_CTRL = 0, diff --git a/hw/milkymist-sysctl.c b/hw/milkymist-sysctl.c index f951ef9ca8..519462afcc 100644 --- a/hw/milkymist-sysctl.c +++ b/hw/milkymist-sysctl.c @@ -25,9 +25,9 @@ #include "sysbus.h" #include "sysemu.h" #include "trace.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { CTRL_ENABLE = (1<<0), diff --git a/hw/milkymist-tmu2.c b/hw/milkymist-tmu2.c index 3f9a684eda..a11772aebe 100644 --- a/hw/milkymist-tmu2.c +++ b/hw/milkymist-tmu2.c @@ -27,7 +27,7 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include #include diff --git a/hw/milkymist-uart.c b/hw/milkymist-uart.c index aefa8c7f1c..ef5518e5c2 100644 --- a/hw/milkymist-uart.c +++ b/hw/milkymist-uart.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "trace.h" #include "qemu-char.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_RXTX = 0, diff --git a/hw/milkymist-vgafb.c b/hw/milkymist-vgafb.c index c3471315d3..561285154f 100644 --- a/hw/milkymist-vgafb.c +++ b/hw/milkymist-vgafb.c @@ -28,7 +28,7 @@ #include "ui/console.h" #include "framebuffer.h" #include "ui/pixel_ops.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #define BITS 8 #include "milkymist-vgafb_template.h" diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 34619b7e3e..60dd8c69bb 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -33,7 +33,7 @@ #include "qemu-char.h" #include "sysemu.h" #include "audio/audio.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" #include "mips-bios.h" #include "ide.h" diff --git a/hw/mips_malta.c b/hw/mips_malta.c index d65d1256fd..04c7a2612c 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -38,7 +38,7 @@ #include "sysemu.h" #include "arch_init.h" #include "boards.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "mips-bios.h" #include "ide.h" #include "loader.h" diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 05494b9b40..511e1e41c0 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -17,7 +17,7 @@ #include "sysemu.h" #include "boards.h" #include "flash.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "mips-bios.h" #include "ide.h" #include "loader.h" diff --git a/hw/mips_timer.c b/hw/mips_timer.c index 7aa9004a0e..83c400c158 100644 --- a/hw/mips_timer.c +++ b/hw/mips_timer.c @@ -22,7 +22,7 @@ #include "hw.h" #include "mips_cpudevs.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define TIMER_FREQ 100 * 1000 * 1000 diff --git a/hw/musicpal.c b/hw/musicpal.c index 436b3f7c37..5a7bf8bee1 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -16,7 +16,7 @@ #include "sysemu.h" #include "boards.h" #include "serial.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "block/block.h" #include "flash.h" diff --git a/hw/nand.c b/hw/nand.c index 01f3adaee1..a73205d866 100644 --- a/hw/nand.c +++ b/hw/nand.c @@ -22,7 +22,7 @@ # include "flash.h" # include "blockdev.h" # include "sysbus.h" -#include "qemu-error.h" +#include "qemu/error-report.h" # define NAND_CMD_READ0 0x00 # define NAND_CMD_READ1 0x01 diff --git a/hw/omap1.c b/hw/omap1.c index 4d5815eb08..50c4570f31 100644 --- a/hw/omap1.c +++ b/hw/omap1.c @@ -22,7 +22,7 @@ #include "sysemu.h" #include "soc_dma.h" #include "blockdev.h" -#include "range.h" +#include "qemu/range.h" #include "sysbus.h" /* Should signal the TCMI/GPMC */ diff --git a/hw/omap2.c b/hw/omap2.c index 96aba71052..7ccee69661 100644 --- a/hw/omap2.c +++ b/hw/omap2.c @@ -23,7 +23,7 @@ #include "arm-misc.h" #include "omap.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" #include "flash.h" #include "soc_dma.h" diff --git a/hw/omap_dma.c b/hw/omap_dma.c index e619c7b7de..aec5874311 100644 --- a/hw/omap_dma.c +++ b/hw/omap_dma.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "omap.h" #include "irq.h" #include "soc_dma.h" diff --git a/hw/omap_gptimer.c b/hw/omap_gptimer.c index e39da74067..a5db710dcb 100644 --- a/hw/omap_gptimer.c +++ b/hw/omap_gptimer.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "omap.h" /* GP timers */ diff --git a/hw/omap_synctimer.c b/hw/omap_synctimer.c index 7031a88531..945711eff5 100644 --- a/hw/omap_synctimer.c +++ b/hw/omap_synctimer.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "omap.h" struct omap_synctimer_s { MemoryRegion iomem; diff --git a/hw/onenand.c b/hw/onenand.c index 7d255c563f..2e26e3a05d 100644 --- a/hw/onenand.c +++ b/hw/onenand.c @@ -26,7 +26,7 @@ #include "exec/memory.h" #include "exec/address-spaces.h" #include "sysbus.h" -#include "qemu-error.h" +#include "qemu/error-report.h" /* 11 for 2kB-page OneNAND ("2nd generation") and 10 for 1kB-page chips */ #define PAGE_SHIFT 11 diff --git a/hw/openrisc_timer.c b/hw/openrisc_timer.c index 7916e61d24..d965be77de 100644 --- a/hw/openrisc_timer.c +++ b/hw/openrisc_timer.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define TIMER_FREQ (20 * 1000 * 1000) /* 20MHz */ diff --git a/hw/pc.c b/hw/pc.c index 7aaff0f2fd..0a92ea6bed 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -50,7 +50,7 @@ #include "exec/memory.h" #include "exec/address-spaces.h" #include "arch_init.h" -#include "bitmap.h" +#include "qemu/bitmap.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ diff --git a/hw/pci/msi.c b/hw/pci/msi.c index 680e4637d7..2a04d18884 100644 --- a/hw/pci/msi.c +++ b/hw/pci/msi.c @@ -19,7 +19,7 @@ */ #include "hw/pci/msi.h" -#include "range.h" +#include "qemu/range.h" /* Eventually those constants should go to Linux pci_regs.h */ #define PCI_MSI_PENDING_32 0x10 diff --git a/hw/pci/msix.c b/hw/pci/msix.c index a6a401e286..073e22c315 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -18,7 +18,7 @@ #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/pci/pci.h" -#include "range.h" +#include "qemu/range.h" #define MSIX_CAP_LENGTH 12 diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index e5e8a7ab58..2bc02e344f 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -30,7 +30,7 @@ #include "monitor/monitor.h" #include "hw/scsi.h" #include "hw/virtio-blk.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "blockdev.h" #include "qapi/error.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e062f66088..c9ed95be89 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -29,7 +29,7 @@ #include "net/net.h" #include "sysemu.h" #include "hw/loader.h" -#include "range.h" +#include "qemu/range.h" #include "qmp-commands.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index 131091408d..995842a72d 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -31,7 +31,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" -#include "range.h" +#include "qemu/range.h" /* PCI bridge subsystem vendor ID helper functions */ #define PCI_SSVID_SIZEOF 8 diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index b60a6faaf3..6c916d15ec 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -25,7 +25,7 @@ #include "hw/pci/msi.h" #include "hw/pci/pci_bus.h" #include "hw/pci/pcie_regs.h" -#include "range.h" +#include "qemu/range.h" //#define DEBUG_PCIE #ifdef DEBUG_PCIE diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 18b1512b43..f07266da66 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -1,7 +1,7 @@ #include #include -#include "range.h" -#include "range.h" +#include "qemu/range.h" +#include "qemu/range.h" #include "hw/pci/shpc.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" diff --git a/hw/pcnet-pci.c b/hw/pcnet-pci.c index c6768bcbdc..5e8eed3af8 100644 --- a/hw/pcnet-pci.c +++ b/hw/pcnet-pci.c @@ -30,7 +30,7 @@ #include "pci/pci.h" #include "net/net.h" #include "loader.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "dma.h" #include "pcnet.h" diff --git a/hw/pcnet.c b/hw/pcnet.c index 5b03edecdd..87736542e4 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -37,8 +37,8 @@ #include "qdev.h" #include "net/net.h" -#include "qemu-timer.h" -#include "qemu_socket.h" +#include "qemu/timer.h" +#include "qemu/sockets.h" #include "sysemu.h" #include "pcnet.h" diff --git a/hw/pcspk.c b/hw/pcspk.c index ad6491b0f4..6d55ebe82f 100644 --- a/hw/pcspk.c +++ b/hw/pcspk.c @@ -26,7 +26,7 @@ #include "pc.h" #include "isa.h" #include "audio/audio.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8254.h" #include "pcspk.h" diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index 36af4647df..59982dcd6f 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -39,9 +39,9 @@ #include "hw.h" #include "flash.h" #include "block/block.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "sysbus.h" #define PFLASH_BUG(fmt, ...) \ diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c index c689cc9f42..6924f064c2 100644 --- a/hw/pflash_cfi02.c +++ b/hw/pflash_cfi02.c @@ -37,10 +37,10 @@ #include "hw.h" #include "flash.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "block/block.h" #include "exec/address-spaces.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "sysbus.h" //#define PFLASH_DEBUG diff --git a/hw/piix_pci.c b/hw/piix_pci.c index b5ea68bc61..3d79c73fda 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -28,7 +28,7 @@ #include "pci/pci_host.h" #include "isa.h" #include "sysbus.h" -#include "range.h" +#include "qemu/range.h" #include "xen.h" #include "pam.h" diff --git a/hw/pl031.c b/hw/pl031.c index 8bf0183289..834a20c917 100644 --- a/hw/pl031.c +++ b/hw/pl031.c @@ -12,7 +12,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" //#define DEBUG_PL031 diff --git a/hw/ppc.c b/hw/ppc.c index 11fd199eaa..f066367609 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -23,10 +23,10 @@ */ #include "hw.h" #include "ppc.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "nvram.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" #include "kvm.h" #include "kvm_ppc.h" diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 798e67cedf..3593f7c0e2 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -19,7 +19,7 @@ #include "e500.h" #include "e500-ccsr.h" #include "net/net.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "hw/hw.h" #include "hw/serial.h" #include "hw/pci/pci.h" @@ -34,7 +34,7 @@ #include "elf.h" #include "hw/sysbus.h" #include "exec/address-spaces.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "hw/ppce500_pci.h" #define BINARY_DEVICE_TREE_FILE "mpc8544ds.dtb" diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c index 5a0e0260e6..31bcc4bb95 100644 --- a/hw/ppc405_boards.c +++ b/hw/ppc405_boards.c @@ -29,7 +29,7 @@ #include "sysemu.h" #include "block/block.h" #include "boards.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" #include "blockdev.h" #include "exec/address-spaces.h" diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c index aabb2efb48..b1ed8837d6 100644 --- a/hw/ppc405_uc.c +++ b/hw/ppc405_uc.c @@ -25,9 +25,9 @@ #include "ppc.h" #include "ppc405.h" #include "serial.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "exec/address-spaces.h" #define DEBUG_OPBA diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c index 3b9dc06716..d1fb1576b0 100644 --- a/hw/ppc4xx_devs.c +++ b/hw/ppc4xx_devs.c @@ -24,7 +24,7 @@ #include "hw.h" #include "ppc.h" #include "ppc4xx.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "exec/address-spaces.h" //#define DEBUG_MMIO diff --git a/hw/ppc_booke.c b/hw/ppc_booke.c index d51e7fad67..a7182be0d3 100644 --- a/hw/ppc_booke.c +++ b/hw/ppc_booke.c @@ -23,10 +23,10 @@ */ #include "hw.h" #include "ppc.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "nvram.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index aa46cc6f55..072535294e 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -33,7 +33,7 @@ #include "pci/pci_host.h" #include "ppc.h" #include "boards.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "ide.h" #include "loader.h" #include "mc146818rtc.h" diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c index feefc6596b..1e1ade3d2e 100644 --- a/hw/ppce500_pci.c +++ b/hw/ppce500_pci.c @@ -18,7 +18,7 @@ #include "hw/ppc/e500-ccsr.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "bswap.h" +#include "qemu/bswap.h" #include "ppce500_pci.h" #ifdef DEBUG_PCI diff --git a/hw/ptimer.c b/hw/ptimer.c index bc0b3f802f..24af6a2afe 100644 --- a/hw/ptimer.c +++ b/hw/ptimer.c @@ -6,9 +6,9 @@ * This code is licensed under the GNU LGPL. */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "host-utils.h" +#include "qemu/host-utils.h" struct ptimer_state { diff --git a/hw/ptimer.h b/hw/ptimer.h index 9d172f7764..28fcaf17f8 100644 --- a/hw/ptimer.h +++ b/hw/ptimer.h @@ -9,7 +9,7 @@ #define PTIMER_H #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "migration/vmstate.h" /* ptimer.c */ diff --git a/hw/pxa2xx_timer.c b/hw/pxa2xx_timer.c index 8242d26c37..1481c6d3e1 100644 --- a/hw/pxa2xx_timer.c +++ b/hw/pxa2xx_timer.c @@ -8,7 +8,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "pxa.h" #include "sysbus.h" diff --git a/hw/q35.h b/hw/q35.h index 2f951c8a94..246c12cb04 100644 --- a/hw/q35.h +++ b/hw/q35.h @@ -23,7 +23,7 @@ #define HW_Q35_H #include "hw.h" -#include "range.h" +#include "qemu/range.h" #include "isa.h" #include "sysbus.h" #include "pc.h" diff --git a/hw/qdev-core.h b/hw/qdev-core.h index 93a3a2a7bc..fdf14ec4a6 100644 --- a/hw/qdev-core.h +++ b/hw/qdev-core.h @@ -1,9 +1,9 @@ #ifndef QDEV_CORE_H #define QDEV_CORE_H -#include "qemu-queue.h" -#include "qemu-option.h" -#include "qemu-types.h" +#include "qemu/queue.h" +#include "qemu/option.h" +#include "qemu/typedefs.h" #include "qom/object.h" #include "hw/irq.h" #include "qapi/error.h" diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 207282c4a4..1c6712e6de 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -21,7 +21,7 @@ #include "monitor/monitor.h" #include "qmp-commands.h" #include "arch_init.h" -#include "qemu-config.h" +#include "qemu/config-file.h" /* * Aliases were a bad idea from the start. Let's keep them diff --git a/hw/qxl-logger.c b/hw/qxl-logger.c index fe2878c836..3cd85d9b97 100644 --- a/hw/qxl-logger.c +++ b/hw/qxl-logger.c @@ -19,7 +19,7 @@ * along with this program; if not, see . */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qxl.h" static const char *qxl_type[] = { diff --git a/hw/qxl.c b/hw/qxl.c index ad0214827e..b88a39cc93 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -21,8 +21,8 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" -#include "qemu-queue.h" +#include "qemu/timer.h" +#include "qemu/queue.h" #include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/qxl.h b/hw/qxl.h index 9130261524..f867a1d0ac 100644 --- a/hw/qxl.h +++ b/hw/qxl.h @@ -7,7 +7,7 @@ #include "hw.h" #include "pci/pci.h" #include "vga_int.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "ui/qemu-spice.h" #include "ui/spice-display.h" diff --git a/hw/rc4030.c b/hw/rc4030.c index e0024c87e8..a0358a319c 100644 --- a/hw/rc4030.c +++ b/hw/rc4030.c @@ -24,7 +24,7 @@ #include "hw.h" #include "mips.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /********************************************************/ /* debug rc4030 */ diff --git a/hw/rtl8139.c b/hw/rtl8139.c index e024520b8b..19c31a02c6 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -54,11 +54,11 @@ #include "hw.h" #include "pci/pci.h" #include "dma.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "net/net.h" #include "loader.h" #include "sysemu.h" -#include "iov.h" +#include "qemu/iov.h" /* debug RTL8139 card */ //#define DEBUG_RTL8139 1 diff --git a/hw/s390x/event-facility.h b/hw/s390x/event-facility.h index 30af0a76a7..791ab2a6de 100644 --- a/hw/s390x/event-facility.h +++ b/hw/s390x/event-facility.h @@ -16,7 +16,7 @@ #define HW_S390_SCLP_EVENT_FACILITY_H #include -#include "qemu-thread.h" +#include "qemu/thread.h" /* SCLP event types */ #define SCLP_EVENT_ASCII_CONSOLE_DATA 0x1a diff --git a/hw/s390x/sclpconsole.c b/hw/s390x/sclpconsole.c index 9ad297c999..ca78d6796a 100644 --- a/hw/s390x/sclpconsole.c +++ b/hw/s390x/sclpconsole.c @@ -13,7 +13,7 @@ */ #include -#include "qemu-thread.h" +#include "qemu/thread.h" #include "sclp.h" #include "event-facility.h" diff --git a/hw/sb16.c b/hw/sb16.c index 523ab0d5fd..bb460ccb60 100644 --- a/hw/sb16.c +++ b/hw/sb16.c @@ -26,8 +26,8 @@ #include "audio/audio.h" #include "isa.h" #include "qdev.h" -#include "qemu-timer.h" -#include "host-utils.h" +#include "qemu/timer.h" +#include "qemu/host-utils.h" #define dolog(...) AUD_log ("sb16", __VA_ARGS__) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index dfb2631210..5dc9f512b5 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -1,5 +1,5 @@ #include "hw.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "scsi.h" #include "scsi-defs.h" #include "qdev.h" diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 49b5686a92..c65da4a9c9 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -29,7 +29,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0) #endif #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "scsi.h" #include "scsi-defs.h" #include "sysemu.h" diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index d9045341ba..faeb61ee2c 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "scsi.h" #include "blockdev.h" diff --git a/hw/sd.c b/hw/sd.c index 2e54eea981..428bd78e32 100644 --- a/hw/sd.c +++ b/hw/sd.c @@ -32,7 +32,7 @@ #include "hw.h" #include "block/block.h" #include "sd.h" -#include "bitmap.h" +#include "qemu/bitmap.h" //#define DEBUG_SD 1 diff --git a/hw/serial.c b/hw/serial.c index 3968c4fc46..2cbb5447a7 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -25,7 +25,7 @@ #include "serial.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" //#define DEBUG_SERIAL diff --git a/hw/sh_pci.c b/hw/sh_pci.c index d5218420a3..018b1c198b 100644 --- a/hw/sh_pci.c +++ b/hw/sh_pci.c @@ -25,7 +25,7 @@ #include "sh.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "bswap.h" +#include "qemu/bswap.h" #include "exec/address-spaces.h" typedef struct SHPCIState { diff --git a/hw/sh_timer.c b/hw/sh_timer.c index da6689f369..64ea23fce6 100644 --- a/hw/sh_timer.c +++ b/hw/sh_timer.c @@ -10,7 +10,7 @@ #include "hw.h" #include "sh.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" #include "ptimer.h" diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c index c07ceb1de0..584629f1a5 100644 --- a/hw/slavio_timer.c +++ b/hw/slavio_timer.c @@ -23,7 +23,7 @@ */ #include "sun4m.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/sm501.c b/hw/sm501.c index 714aca0492..dd186aa7f2 100644 --- a/hw/sm501.c +++ b/hw/sm501.c @@ -29,7 +29,7 @@ #include "devices.h" #include "sysbus.h" #include "qdev-addr.h" -#include "range.h" +#include "qemu/range.h" #include "ui/pixel_ops.h" /* diff --git a/hw/soc_dma.c b/hw/soc_dma.c index 50d5f84b4e..64e8ee1d13 100644 --- a/hw/soc_dma.c +++ b/hw/soc_dma.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "soc_dma.h" static void transfer_mem2mem(struct soc_dma_ch_s *ch) diff --git a/hw/spapr.c b/hw/spapr.c index d1252fc68c..1abfde2a05 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -49,7 +49,7 @@ #include "exec/address-spaces.h" #include "hw/usb.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include diff --git a/hw/spitz.c b/hw/spitz.c index 48668a0f10..1259e32974 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -18,7 +18,7 @@ #include "i2c.h" #include "ssi.h" #include "flash.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "devices.h" #include "sharpsl.h" #include "ui/console.h" diff --git a/hw/stellaris.c b/hw/stellaris.c index 368f8a5e73..26da3c7f60 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -11,7 +11,7 @@ #include "ssi.h" #include "arm-misc.h" #include "devices.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i2c.h" #include "net/net.h" #include "boards.h" diff --git a/hw/strongarm.c b/hw/strongarm.c index 44bec34e07..f776fee3bc 100644 --- a/hw/strongarm.c +++ b/hw/strongarm.c @@ -28,7 +28,7 @@ */ #include "sysbus.h" #include "strongarm.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "arm-misc.h" #include "qemu-char.h" #include "sysemu.h" diff --git a/hw/sun4m.c b/hw/sun4m.c index 9a784dfd04..4245854949 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sun4m.h" #include "nvram.h" #include "sparc32_dma.h" diff --git a/hw/sun4u.c b/hw/sun4u.c index 000f6118e1..8bca4fdff9 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -29,7 +29,7 @@ #include "nvram.h" #include "fdc.h" #include "net/net.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "boards.h" #include "firmware_abi.h" diff --git a/hw/tsc2005.c b/hw/tsc2005.c index e2326283c0..740ff86aa8 100644 --- a/hw/tsc2005.c +++ b/hw/tsc2005.c @@ -19,7 +19,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" #include "devices.h" diff --git a/hw/tsc210x.c b/hw/tsc210x.c index 2b3535d4fc..2076c355d2 100644 --- a/hw/tsc210x.c +++ b/hw/tsc210x.c @@ -21,7 +21,7 @@ #include "hw.h" #include "audio/audio.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" #include "omap.h" /* For I2SCodec and uWireSlave */ #include "devices.h" diff --git a/hw/tusb6010.c b/hw/tusb6010.c index 325200bd34..990d50619d 100644 --- a/hw/tusb6010.c +++ b/hw/tusb6010.c @@ -19,7 +19,7 @@ * with this program; if not, see . */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "usb.h" #include "omap.h" #include "irq.h" diff --git a/hw/twl92230.c b/hw/twl92230.c index ce699bdbdd..3210b9ef4e 100644 --- a/hw/twl92230.c +++ b/hw/twl92230.c @@ -20,7 +20,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i2c.h" #include "sysemu.h" #include "ui/console.h" diff --git a/hw/usb.h b/hw/usb.h index efae65dcad..81e265c4fd 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -26,7 +26,7 @@ */ #include "qdev.h" -#include "qemu-queue.h" +#include "qemu/queue.h" /* Constants related to the USB / PCI interaction */ #define USB_SBRN 0x60 /* Serial Bus Release Number Register */ diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c index 4a0c299457..13f6602ad2 100644 --- a/hw/usb/combined-packet.c +++ b/hw/usb/combined-packet.c @@ -21,7 +21,7 @@ */ #include "qemu-common.h" #include "hw/usb.h" -#include "iov.h" +#include "qemu/iov.h" #include "trace.h" static void usb_combined_packet_add(USBCombinedPacket *combined, USBPacket *p) diff --git a/hw/usb/core.c b/hw/usb/core.c index 8e360d3ec0..e315fc1021 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -25,7 +25,7 @@ */ #include "qemu-common.h" #include "hw/usb.h" -#include "iov.h" +#include "qemu/iov.h" #include "trace.h" void usb_attach(USBPort *port) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 6953f2e710..ce38fef9f6 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -26,7 +26,7 @@ #include "ui/console.h" #include "hw/usb.h" #include "hw/usb/desc.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/hid.h" /* HID interface requests */ diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index bf289ff5a6..e8ada9f02c 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -27,10 +27,10 @@ #include "hw/usb.h" #include "hw/usb/desc.h" #include "net/net.h" -#include "qemu-queue.h" -#include "qemu-config.h" +#include "qemu/queue.h" +#include "qemu/config-file.h" #include "sysemu.h" -#include "iov.h" +#include "qemu/iov.h" /*#define TRAFFIC_DEBUG*/ /* Thanks to NetChip Technologies for donating this product ID. diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 99b19df1d1..2ff4fe247a 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -9,7 +9,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "qemu-char.h" diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 3862c9b6c9..f26bb341f7 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -35,7 +35,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "monitor/monitor.h" diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 0d7597b4d1..6d27bac94f 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -8,8 +8,8 @@ */ #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "hw/scsi.h" diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index a21b2ba627..9a0088928f 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -10,8 +10,8 @@ */ #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "trace.h" #include "hw/usb.h" diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 8b043966f6..ee77d41db5 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -17,7 +17,7 @@ #include "hw/usb/hcd-ehci.h" #include "hw/pci/pci.h" -#include "range.h" +#include "qemu/range.h" typedef struct EHCIPCIState { PCIDevice pcidev; diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 740f7309fb..5bc80031bf 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -18,7 +18,7 @@ #define HW_USB_EHCI_H 1 #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "monitor/monitor.h" #include "trace.h" diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c index c707f7a2bb..64e9e834bf 100644 --- a/hw/usb/hcd-musb.c +++ b/hw/usb/hcd-musb.c @@ -21,7 +21,7 @@ * Only host-mode and non-DMA accesses are currently supported. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "hw/irq.h" #include "hw/hw.h" diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 4faf8e1aed..052c4a3037 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -27,7 +27,7 @@ */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "hw/pci/pci.h" #include "hw/sysbus.h" diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 04c944613c..c9b8a31465 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -28,8 +28,8 @@ #include "hw/hw.h" #include "hw/usb.h" #include "hw/pci/pci.h" -#include "qemu-timer.h" -#include "iov.h" +#include "qemu/timer.h" +#include "qemu/iov.h" #include "dma.h" #include "trace.h" diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 220c3b536a..e2de71ef1a 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -19,7 +19,7 @@ * License along with this library; if not, see . */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index 5a56e99891..9a8c26ceaf 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -31,7 +31,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 3621076020..31e5f27595 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -26,10 +26,10 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "monitor/monitor.h" #include "sysemu.h" -#include "iov.h" +#include "qemu/iov.h" #include #include diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index 096621cdbd..9f204bc113 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -27,7 +27,7 @@ #include #include "config.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "exec/address-spaces.h" #include "kvm.h" #include "exec/memory.h" @@ -35,9 +35,9 @@ #include "pci/msix.h" #include "pci/pci.h" #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-queue.h" -#include "range.h" +#include "qemu/error-report.h" +#include "qemu/queue.h" +#include "qemu/range.h" /* #define DEBUG_VFIO */ #ifdef DEBUG_VFIO diff --git a/hw/vga-isa-mm.c b/hw/vga-isa-mm.c index 008703ff57..311c966f77 100644 --- a/hw/vga-isa-mm.c +++ b/hw/vga-isa-mm.c @@ -26,7 +26,7 @@ #include "pc.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define VGA_RAM_SIZE (8192 * 1024) diff --git a/hw/vga-isa.c b/hw/vga-isa.c index d1d5b11828..cbe7b05a7e 100644 --- a/hw/vga-isa.c +++ b/hw/vga-isa.c @@ -28,7 +28,7 @@ #include "pc.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "loader.h" typedef struct ISAVGAState { diff --git a/hw/vga-pci.c b/hw/vga-pci.c index fe3a3d4899..87c7c0648d 100644 --- a/hw/vga-pci.c +++ b/hw/vga-pci.c @@ -28,7 +28,7 @@ #include "pci/pci.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "loader.h" #define PCI_VGA_IOPORT_OFFSET 0x400 diff --git a/hw/vga.c b/hw/vga.c index 4007116859..e2ba7f208c 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -28,7 +28,7 @@ #include "pci/pci.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "xen.h" #include "trace.h" diff --git a/hw/vhost.c b/hw/vhost.c index feaff64c15..4e1cb47418 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -16,7 +16,7 @@ #include #include "vhost.h" #include "hw/hw.h" -#include "range.h" +#include "qemu/range.h" #include #include "exec/address-spaces.h" diff --git a/hw/vhost_net.c b/hw/vhost_net.c index 93ad89a11c..ae2785d83f 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -18,7 +18,7 @@ #include "virtio-net.h" #include "vhost_net.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "config.h" diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c index 0f27c2b414..5134e2f477 100644 --- a/hw/virtex_ml507.c +++ b/hw/virtex_ml507.c @@ -32,7 +32,7 @@ #include "device_tree.h" #include "loader.h" #include "elf.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "exec/address-spaces.h" #include "ppc.h" diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index 97d3a932d9..2eb709b422 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -13,7 +13,7 @@ * */ -#include "iov.h" +#include "qemu/iov.h" #include "qemu-common.h" #include "virtio.h" #include "pc.h" diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index e25cc96477..208caa2642 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "trace.h" #include "hw/block-common.h" #include "blockdev.h" diff --git a/hw/virtio-console.c b/hw/virtio-console.c index cffee3d470..df0951e973 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -11,7 +11,7 @@ */ #include "qemu-char.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "trace.h" #include "virtio-serial.h" diff --git a/hw/virtio-net.c b/hw/virtio-net.c index dc7c6d6b56..5d03b31c1b 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -11,13 +11,13 @@ * */ -#include "iov.h" +#include "qemu/iov.h" #include "virtio.h" #include "net/net.h" #include "net/checksum.h" #include "net/tap.h" -#include "qemu-error.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" #include "virtio-net.h" #include "vhost_net.h" diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index a2355dc867..f58917f75f 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -23,14 +23,14 @@ #include "virtio-serial.h" #include "virtio-scsi.h" #include "pci/pci.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "pci/msi.h" #include "pci/msix.h" #include "loader.h" #include "kvm.h" #include "blockdev.h" #include "virtio-pci.h" -#include "range.h" +#include "qemu/range.h" /* from Linux's linux/virtio_pci.h */ diff --git a/hw/virtio-rng.c b/hw/virtio-rng.c index a73ef8e334..e063127df6 100644 --- a/hw/virtio-rng.c +++ b/hw/virtio-rng.c @@ -9,7 +9,7 @@ * top-level directory. */ -#include "iov.h" +#include "qemu/iov.h" #include "qdev.h" #include "virtio.h" #include "virtio-rng.h" diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 5559518a93..fc5cb32277 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -18,9 +18,9 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "iov.h" +#include "qemu/iov.h" #include "monitor/monitor.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "sysbus.h" #include "trace.h" #include "virtio-serial.h" diff --git a/hw/virtio.c b/hw/virtio.c index f40a8c5571..0455a9e8f3 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -14,9 +14,9 @@ #include #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "virtio.h" -#include "qemu-barrier.h" +#include "qemu/atomic.h" /* The alignment to use between consumer and producer parts of vring. * x86 pagesize again. */ diff --git a/hw/virtio.h b/hw/virtio.h index cdcb490733..511a16992e 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -18,7 +18,7 @@ #include "net/net.h" #include "qdev.h" #include "sysemu.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #ifdef CONFIG_LINUX #include "9p.h" #endif diff --git a/hw/vt82c686.c b/hw/vt82c686.c index edceb5a01d..a18aaed217 100644 --- a/hw/vt82c686.c +++ b/hw/vt82c686.c @@ -23,7 +23,7 @@ #include "acpi.h" #include "pm_smbus.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" typedef uint32_t pci_addr_t; diff --git a/hw/watchdog.c b/hw/watchdog.c index 623b299f71..5b04215374 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -20,9 +20,9 @@ */ #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-config.h" -#include "qemu-queue.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "qemu/queue.h" #include "qapi/qmp/types.h" #include "monitor/monitor.h" #include "sysemu.h" diff --git a/hw/watchdog.h b/hw/watchdog.h index c12a29311a..3e9a970686 100644 --- a/hw/watchdog.h +++ b/hw/watchdog.h @@ -22,7 +22,7 @@ #ifndef QEMU_WATCHDOG_H #define QEMU_WATCHDOG_H -#include "qemu-queue.h" +#include "qemu/queue.h" struct WatchdogTimerModel { QLIST_ENTRY(WatchdogTimerModel) entry; diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c index 181774220d..54f0665135 100644 --- a/hw/wdt_i6300esb.c +++ b/hw/wdt_i6300esb.c @@ -22,7 +22,7 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "watchdog.h" #include "hw.h" #include "pci/pci.h" diff --git a/hw/wdt_ib700.c b/hw/wdt_ib700.c index 7f6c21d809..4475f7b862 100644 --- a/hw/wdt_ib700.c +++ b/hw/wdt_ib700.c @@ -20,7 +20,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "watchdog.h" #include "hw.h" #include "isa.h" diff --git a/hw/xen_backend.c b/hw/xen_backend.c index f83a1e1d09..270584fc10 100644 --- a/hw/xen_backend.c +++ b/hw/xen_backend.c @@ -36,7 +36,7 @@ #include "hw.h" #include "qemu-char.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "xen_backend.h" #include diff --git a/hw/xen_common.h b/hw/xen_common.h index 727757afb4..95bc9a7825 100644 --- a/hw/xen_common.h +++ b/hw/xen_common.h @@ -16,7 +16,7 @@ #include "hw.h" #include "xen.h" -#include "qemu-queue.h" +#include "qemu/queue.h" /* * We don't support Xen prior to 3.3.0. diff --git a/hw/xen_domainbuild.c b/hw/xen_domainbuild.c index db1497469a..a4272f0680 100644 --- a/hw/xen_domainbuild.c +++ b/hw/xen_domainbuild.c @@ -1,8 +1,8 @@ #include #include "xen_backend.h" #include "xen_domainbuild.h" -#include "qemu-timer.h" -#include "qemu-log.h" +#include "qemu/timer.h" +#include "qemu/log.h" #include diff --git a/hw/xen_pt.c b/hw/xen_pt.c index 5c50d562d9..9ebd028f2e 100644 --- a/hw/xen_pt.c +++ b/hw/xen_pt.c @@ -58,7 +58,7 @@ #include "xen.h" #include "xen_backend.h" #include "xen_pt.h" -#include "range.h" +#include "qemu/range.h" #include "exec/address-spaces.h" #define XEN_PT_NR_IRQS (256) diff --git a/hw/xen_pt_config_init.c b/hw/xen_pt_config_init.c index 0a5f82cb80..54a179af90 100644 --- a/hw/xen_pt_config_init.c +++ b/hw/xen_pt_config_init.c @@ -12,7 +12,7 @@ * This file implements direct PCI assignment to a HVM guest */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "xen_backend.h" #include "xen_pt.h" diff --git a/hw/xgmac.c b/hw/xgmac.c index d0d510ed6a..acc3d37648 100644 --- a/hw/xgmac.c +++ b/hw/xgmac.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "qemu-char.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "net/net.h" #include "net/checksum.h" diff --git a/hw/xilinx_axidma.c b/hw/xilinx_axidma.c index 2fd6068428..ce02764b3f 100644 --- a/hw/xilinx_axidma.c +++ b/hw/xilinx_axidma.c @@ -23,9 +23,9 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "qdev-addr.h" #include "stream.h" diff --git a/hw/xilinx_axienet.c b/hw/xilinx_axienet.c index 35979e65c9..09e49b0aee 100644 --- a/hw/xilinx_axienet.c +++ b/hw/xilinx_axienet.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "net/net.h" #include "net/checksum.h" diff --git a/hw/xilinx_spi.c b/hw/xilinx_spi.c index 039027442c..4eed1828e3 100644 --- a/hw/xilinx_spi.c +++ b/hw/xilinx_spi.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "fifo.h" #include "ssi.h" diff --git a/hw/xilinx_spips.c b/hw/xilinx_spips.c index ee7656d7d8..ebe375e56f 100644 --- a/hw/xilinx_spips.c +++ b/hw/xilinx_spips.c @@ -25,10 +25,10 @@ #include "sysbus.h" #include "sysemu.h" #include "ptimer.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "fifo.h" #include "ssi.h" -#include "bitops.h" +#include "qemu/bitops.h" #ifdef XILINX_SPIPS_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/hw/xilinx_timer.c b/hw/xilinx_timer.c index 2b01dc2869..69294bb83c 100644 --- a/hw/xilinx_timer.c +++ b/hw/xilinx_timer.c @@ -24,7 +24,7 @@ #include "sysbus.h" #include "ptimer.h" -#include "qemu-log.h" +#include "qemu/log.h" #define D(x) diff --git a/hw/xtensa_pic.c b/hw/xtensa_pic.c index 1ec70cd969..97d36be272 100644 --- a/hw/xtensa_pic.c +++ b/hw/xtensa_pic.c @@ -26,8 +26,8 @@ */ #include "hw.h" -#include "qemu-log.h" -#include "qemu-timer.h" +#include "qemu/log.h" +#include "qemu/timer.h" void xtensa_advance_ccount(CPUXtensaState *env, uint32_t d) { diff --git a/hw/zynq_slcr.c b/hw/zynq_slcr.c index dde4306195..c7ce51f4a6 100644 --- a/hw/zynq_slcr.c +++ b/hw/zynq_slcr.c @@ -15,7 +15,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysbus.h" #include "sysemu.h" diff --git a/include/block/aio.h b/include/block/aio.h index 31884a8f16..0933f05878 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -15,8 +15,8 @@ #define QEMU_AIO_H #include "qemu-common.h" -#include "qemu-queue.h" -#include "event_notifier.h" +#include "qemu/queue.h" +#include "qemu/event_notifier.h" typedef struct BlockDriverAIOCB BlockDriverAIOCB; typedef void BlockDriverCompletionFunc(void *opaque, int ret); diff --git a/include/block/block.h b/include/block/block.h index d49ce4dbc5..b81d200b03 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -3,7 +3,7 @@ #include "block/aio.h" #include "qemu-common.h" -#include "qemu-option.h" +#include "qemu/option.h" #include "block/coroutine.h" #include "qapi/qmp/qobject.h" #include "qapi-types.h" diff --git a/include/block/block_int.h b/include/block/block_int.h index 14c57afd54..f83ffb8a08 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -25,10 +25,10 @@ #define BLOCK_INT_H #include "block/block.h" -#include "qemu-option.h" -#include "qemu-queue.h" +#include "qemu/option.h" +#include "qemu/queue.h" #include "block/coroutine.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qapi-types.h" #include "qapi/qmp/qerror.h" #include "monitor/monitor.h" diff --git a/include/block/coroutine.h b/include/block/coroutine.h index 34c15d4116..c31fae3f3c 100644 --- a/include/block/coroutine.h +++ b/include/block/coroutine.h @@ -16,8 +16,8 @@ #define QEMU_COROUTINE_H #include -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/queue.h" +#include "qemu/timer.h" /** * Coroutines are a mechanism for stack switching and can be used for diff --git a/include/block/coroutine_int.h b/include/block/coroutine_int.h index 282a3ceda6..17eb71e723 100644 --- a/include/block/coroutine_int.h +++ b/include/block/coroutine_int.h @@ -25,7 +25,7 @@ #ifndef QEMU_COROUTINE_INT_H #define QEMU_COROUTINE_INT_H -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/coroutine.h" typedef enum { diff --git a/include/block/thread-pool.h b/include/block/thread-pool.h index a87b287081..200703e35f 100644 --- a/include/block/thread-pool.h +++ b/include/block/thread-pool.h @@ -19,8 +19,8 @@ #define QEMU_THREAD_POOL_H 1 #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-thread.h" +#include "qemu/queue.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "block/block_int.h" diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index bec04e2008..c12e35f54d 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -20,7 +20,7 @@ #define CPU_ALL_H #include "qemu-common.h" -#include "qemu-tls.h" +#include "qemu/tls.h" #include "exec/cpu-common.h" /* some important defines: diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index f83d6180f3..4d4f8d4e98 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -9,8 +9,8 @@ #include "exec/poison.h" #endif -#include "bswap.h" -#include "qemu-queue.h" +#include "qemu/bswap.h" +#include "qemu/queue.h" #if !defined(CONFIG_USER_ONLY) diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 8d2230e50e..aea0ece051 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -27,8 +27,8 @@ #include #include #include -#include "osdep.h" -#include "qemu-queue.h" +#include "qemu/osdep.h" +#include "qemu/queue.h" #include "exec/hwaddr.h" #ifndef TARGET_LONG_BITS diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 2ae8aae3d6..46dca74fda 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -70,7 +70,7 @@ typedef struct TranslationBlock TranslationBlock; #define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) -#include "qemu-log.h" +#include "qemu/log.h" void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb); diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 1541f0b1e4..8043b3ba26 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -1,7 +1,7 @@ #ifndef GEN_ICOUNT_H #define GEN_ICOUNT_H 1 -#include "qemu-timer.h" +#include "qemu/timer.h" /* Helpers for instruction counting code generation. */ diff --git a/include/exec/memory.h b/include/exec/memory.h index b0c474584f..aada969628 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -21,10 +21,10 @@ #include "qemu-common.h" #include "exec/cpu-common.h" #include "exec/hwaddr.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "exec/iorange.h" #include "exec/ioport.h" -#include "int128.h" +#include "qemu/int128.h" typedef struct MemoryRegionOps MemoryRegionOps; typedef struct MemoryRegion MemoryRegion; diff --git a/include/exec/softmmu_template.h b/include/exec/softmmu_template.h index 15d4c519ee..b219191abd 100644 --- a/include/exec/softmmu_template.h +++ b/include/exec/softmmu_template.h @@ -21,7 +21,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/memory.h" #define DATA_SIZE (1 << SHIFT) diff --git a/include/migration/migration.h b/include/migration/migration.h index a95f761e4c..8b7af61e7e 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -16,7 +16,7 @@ #include "qapi/qmp/qdict.h" #include "qemu-common.h" -#include "notify.h" +#include "qemu/notify.h" #include "qapi/error.h" #include "migration/vmstate.h" #include "qapi-types.h" diff --git a/include/net/net.h b/include/net/net.h index 41d3729867..de42dd76da 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -1,10 +1,10 @@ #ifndef QEMU_NET_H #define QEMU_NET_H -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/qdict.h" -#include "qemu-option.h" +#include "qemu/option.h" #include "net/queue.h" #include "migration/vmstate.h" #include "qapi-types.h" diff --git a/include/net/slirp.h b/include/net/slirp.h index ac9d44964f..54b655c272 100644 --- a/include/net/slirp.h +++ b/include/net/slirp.h @@ -26,7 +26,7 @@ #include "qemu-common.h" #include "qapi/qmp/qdict.h" -#include "qemu-option.h" +#include "qemu/option.h" #include "qapi-types.h" #ifdef CONFIG_SLIRP diff --git a/include/qapi/error.h b/include/qapi/error.h index 4d52e7369e..5cd2f0c302 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -12,7 +12,7 @@ #ifndef ERROR_H #define ERROR_H -#include "compiler.h" +#include "qemu/compiler.h" #include "qapi-types.h" #include diff --git a/include/qapi/opts-visitor.h b/include/qapi/opts-visitor.h index 31fa4c5628..5939eeebc7 100644 --- a/include/qapi/opts-visitor.h +++ b/include/qapi/opts-visitor.h @@ -14,7 +14,7 @@ #define OPTS_VISITOR_H #include "qapi/visitor.h" -#include "qemu-option.h" +#include "qemu/option.h" typedef struct OptsVisitor OptsVisitor; diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index c815981d30..6d9a4be3a5 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -15,7 +15,7 @@ #include "qapi/qmp/qobject.h" #include "qapi/qmp/qlist.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include #define QDICT_BUCKET_MAX 512 diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index d912297590..6c0a18dfc4 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -14,7 +14,7 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "qapi-types.h" #include diff --git a/include/qapi/qmp/qjson.h b/include/qapi/qmp/qjson.h index 0473374bf2..73351ed6d6 100644 --- a/include/qapi/qmp/qjson.h +++ b/include/qapi/qmp/qjson.h @@ -15,7 +15,7 @@ #define QJSON_H #include -#include "compiler.h" +#include "qemu/compiler.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h index ffa0846d48..382f04c3c4 100644 --- a/include/qapi/qmp/qlist.h +++ b/include/qapi/qmp/qlist.h @@ -14,8 +14,8 @@ #define QLIST_H #include "qapi/qmp/qobject.h" -#include "qemu-queue.h" -#include "qemu-queue.h" +#include "qemu/queue.h" +#include "qemu/queue.h" typedef struct QListEntry { QObject *value; diff --git a/include/qemu/acl.h b/include/qemu/acl.h new file mode 100644 index 0000000000..116487e282 --- /dev/null +++ b/include/qemu/acl.h @@ -0,0 +1,74 @@ +/* + * QEMU access control list management + * + * Copyright (C) 2009 Red Hat, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef __QEMU_ACL_H__ +#define __QEMU_ACL_H__ + +#include "qemu/queue.h" + +typedef struct qemu_acl_entry qemu_acl_entry; +typedef struct qemu_acl qemu_acl; + +struct qemu_acl_entry { + char *match; + int deny; + + QTAILQ_ENTRY(qemu_acl_entry) next; +}; + +struct qemu_acl { + char *aclname; + unsigned int nentries; + QTAILQ_HEAD(,qemu_acl_entry) entries; + int defaultDeny; +}; + +qemu_acl *qemu_acl_init(const char *aclname); + +qemu_acl *qemu_acl_find(const char *aclname); + +int qemu_acl_party_is_allowed(qemu_acl *acl, + const char *party); + +void qemu_acl_reset(qemu_acl *acl); + +int qemu_acl_append(qemu_acl *acl, + int deny, + const char *match); +int qemu_acl_insert(qemu_acl *acl, + int deny, + const char *match, + int index); +int qemu_acl_remove(qemu_acl *acl, + const char *match); + +#endif /* __QEMU_ACL_H__ */ + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h new file mode 100644 index 0000000000..96a194bbee --- /dev/null +++ b/include/qemu/atomic.h @@ -0,0 +1,67 @@ +#ifndef __QEMU_BARRIER_H +#define __QEMU_BARRIER_H 1 + +/* Compiler barrier */ +#define barrier() asm volatile("" ::: "memory") + +#if defined(__i386__) + +#include "qemu/compiler.h" /* QEMU_GNUC_PREREQ */ + +/* + * Because of the strongly ordered x86 storage model, wmb() and rmb() are nops + * on x86(well, a compiler barrier only). Well, at least as long as + * qemu doesn't do accesses to write-combining memory or non-temporal + * load/stores from C code. + */ +#define smp_wmb() barrier() +#define smp_rmb() barrier() +/* + * We use GCC builtin if it's available, as that can use + * mfence on 32 bit as well, e.g. if built with -march=pentium-m. + * However, on i386, there seem to be known bugs as recently as 4.3. + * */ +#if QEMU_GNUC_PREREQ(4, 4) +#define smp_mb() __sync_synchronize() +#else +#define smp_mb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory") +#endif + +#elif defined(__x86_64__) + +#define smp_wmb() barrier() +#define smp_rmb() barrier() +#define smp_mb() asm volatile("mfence" ::: "memory") + +#elif defined(_ARCH_PPC) + +/* + * We use an eieio() for wmb() on powerpc. This assumes we don't + * need to order cacheable and non-cacheable stores with respect to + * each other + */ +#define smp_wmb() asm volatile("eieio" ::: "memory") + +#if defined(__powerpc64__) +#define smp_rmb() asm volatile("lwsync" ::: "memory") +#else +#define smp_rmb() asm volatile("sync" ::: "memory") +#endif + +#define smp_mb() asm volatile("sync" ::: "memory") + +#else + +/* + * For (host) platforms we don't have explicit barrier definitions + * for, we use the gcc __sync_synchronize() primitive to generate a + * full barrier. This should be safe on all platforms, though it may + * be overkill for wmb() and rmb(). + */ +#define smp_wmb() __sync_synchronize() +#define smp_mb() __sync_synchronize() +#define smp_rmb() __sync_synchronize() + +#endif + +#endif diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h new file mode 100644 index 0000000000..308bbb71e9 --- /dev/null +++ b/include/qemu/bitmap.h @@ -0,0 +1,222 @@ +/* + * Bitmap Module + * + * Copyright (C) 2010 Corentin Chary + * + * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + */ + +#ifndef BITMAP_H +#define BITMAP_H + +#include "qemu-common.h" +#include "qemu/bitops.h" + +/* + * The available bitmap operations and their rough meaning in the + * case that the bitmap is a single unsigned long are thus: + * + * Note that nbits should be always a compile time evaluable constant. + * Otherwise many inlines will generate horrible code. + * + * bitmap_zero(dst, nbits) *dst = 0UL + * bitmap_fill(dst, nbits) *dst = ~0UL + * bitmap_copy(dst, src, nbits) *dst = *src + * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 + * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 + * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 + * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2) + * bitmap_complement(dst, src, nbits) *dst = ~(*src) + * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? + * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? + * bitmap_empty(src, nbits) Are all bits zero in *src? + * bitmap_full(src, nbits) Are all bits set in *src? + * bitmap_set(dst, pos, nbits) Set specified bit area + * bitmap_clear(dst, pos, nbits) Clear specified bit area + * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area + */ + +/* + * Also the following operations apply to bitmaps. + * + * set_bit(bit, addr) *addr |= bit + * clear_bit(bit, addr) *addr &= ~bit + * change_bit(bit, addr) *addr ^= bit + * test_bit(bit, addr) Is bit set in *addr? + * test_and_set_bit(bit, addr) Set bit and return old value + * test_and_clear_bit(bit, addr) Clear bit and return old value + * test_and_change_bit(bit, addr) Change bit and return old value + * find_first_zero_bit(addr, nbits) Position first zero bit in *addr + * find_first_bit(addr, nbits) Position first set bit in *addr + * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit + * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit + */ + +#define BITMAP_LAST_WORD_MASK(nbits) \ + ( \ + ((nbits) % BITS_PER_LONG) ? \ + (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ + ) + +#define DECLARE_BITMAP(name,bits) \ + unsigned long name[BITS_TO_LONGS(bits)] + +#define small_nbits(nbits) \ + ((nbits) <= BITS_PER_LONG) + +int slow_bitmap_empty(const unsigned long *bitmap, int bits); +int slow_bitmap_full(const unsigned long *bitmap, int bits); +int slow_bitmap_equal(const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void slow_bitmap_complement(unsigned long *dst, const unsigned long *src, + int bits); +void slow_bitmap_shift_right(unsigned long *dst, + const unsigned long *src, int shift, int bits); +void slow_bitmap_shift_left(unsigned long *dst, + const unsigned long *src, int shift, int bits); +int slow_bitmap_and(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void slow_bitmap_or(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void slow_bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +int slow_bitmap_intersects(const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); + +static inline unsigned long *bitmap_new(int nbits) +{ + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + return g_malloc0(len); +} + +static inline void bitmap_zero(unsigned long *dst, int nbits) +{ + if (small_nbits(nbits)) { + *dst = 0UL; + } else { + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + memset(dst, 0, len); + } +} + +static inline void bitmap_fill(unsigned long *dst, int nbits) +{ + size_t nlongs = BITS_TO_LONGS(nbits); + if (!small_nbits(nbits)) { + int len = (nlongs - 1) * sizeof(unsigned long); + memset(dst, 0xff, len); + } + dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); +} + +static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, + int nbits) +{ + if (small_nbits(nbits)) { + *dst = *src; + } else { + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + memcpy(dst, src, len); + } +} + +static inline int bitmap_and(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return (*dst = *src1 & *src2) != 0; + } + return slow_bitmap_and(dst, src1, src2, nbits); +} + +static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + *dst = *src1 | *src2; + } else { + slow_bitmap_or(dst, src1, src2, nbits); + } +} + +static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + *dst = *src1 ^ *src2; + } else { + slow_bitmap_xor(dst, src1, src2, nbits); + } +} + +static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return (*dst = *src1 & ~(*src2)) != 0; + } + return slow_bitmap_andnot(dst, src1, src2, nbits); +} + +static inline void bitmap_complement(unsigned long *dst, const unsigned long *src, + int nbits) +{ + if (small_nbits(nbits)) { + *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits); + } else { + slow_bitmap_complement(dst, src, nbits); + } +} + +static inline int bitmap_equal(const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_equal(src1, src2, nbits); + } +} + +static inline int bitmap_empty(const unsigned long *src, int nbits) +{ + if (small_nbits(nbits)) { + return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_empty(src, nbits); + } +} + +static inline int bitmap_full(const unsigned long *src, int nbits) +{ + if (small_nbits(nbits)) { + return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_full(src, nbits); + } +} + +static inline int bitmap_intersects(const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; + } else { + return slow_bitmap_intersects(src1, src2, nbits); + } +} + +void bitmap_set(unsigned long *map, int i, int len); +void bitmap_clear(unsigned long *map, int start, int nr); +unsigned long bitmap_find_next_zero_area(unsigned long *map, + unsigned long size, + unsigned long start, + unsigned int nr, + unsigned long align_mask); + +#endif /* BITMAP_H */ diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h new file mode 100644 index 0000000000..74e14e5724 --- /dev/null +++ b/include/qemu/bitops.h @@ -0,0 +1,362 @@ +/* + * Bitops Module + * + * Copyright (C) 2010 Corentin Chary + * + * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + */ + +#ifndef BITOPS_H +#define BITOPS_H + +#include "qemu-common.h" + +#define BITS_PER_BYTE CHAR_BIT +#define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) + +#define BIT(nr) (1UL << (nr)) +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) + +/** + * bitops_ffs - find first bit in word. + * @word: The word to search + * + * Undefined if no bit exists, so code should check against 0 first. + */ +static unsigned long bitops_ffsl(unsigned long word) +{ + int num = 0; + +#if LONG_MAX > 0x7FFFFFFF + if ((word & 0xffffffff) == 0) { + num += 32; + word >>= 32; + } +#endif + if ((word & 0xffff) == 0) { + num += 16; + word >>= 16; + } + if ((word & 0xff) == 0) { + num += 8; + word >>= 8; + } + if ((word & 0xf) == 0) { + num += 4; + word >>= 4; + } + if ((word & 0x3) == 0) { + num += 2; + word >>= 2; + } + if ((word & 0x1) == 0) { + num += 1; + } + return num; +} + +/** + * bitops_fls - find last (most-significant) set bit in a long word + * @word: the word to search + * + * Undefined if no set bit exists, so code should check against 0 first. + */ +static inline unsigned long bitops_flsl(unsigned long word) +{ + int num = BITS_PER_LONG - 1; + +#if LONG_MAX > 0x7FFFFFFF + if (!(word & (~0ul << 32))) { + num -= 32; + word <<= 32; + } +#endif + if (!(word & (~0ul << (BITS_PER_LONG-16)))) { + num -= 16; + word <<= 16; + } + if (!(word & (~0ul << (BITS_PER_LONG-8)))) { + num -= 8; + word <<= 8; + } + if (!(word & (~0ul << (BITS_PER_LONG-4)))) { + num -= 4; + word <<= 4; + } + if (!(word & (~0ul << (BITS_PER_LONG-2)))) { + num -= 2; + + word <<= 2; + } + if (!(word & (~0ul << (BITS_PER_LONG-1)))) + num -= 1; + return num; +} + +/** + * ffz - find first zero in word. + * @word: The word to search + * + * Undefined if no zero exists, so code should check against ~0UL first. + */ +static inline unsigned long ffz(unsigned long word) +{ + return bitops_ffsl(~word); +} + +/** + * set_bit - Set a bit in memory + * @nr: the bit to set + * @addr: the address to start counting from + */ +static inline void set_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + *p |= mask; +} + +/** + * clear_bit - Clears a bit in memory + * @nr: Bit to clear + * @addr: Address to start counting from + */ +static inline void clear_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + *p &= ~mask; +} + +/** + * change_bit - Toggle a bit in memory + * @nr: Bit to change + * @addr: Address to start counting from + */ +static inline void change_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + *p ^= mask; +} + +/** + * test_and_set_bit - Set a bit and return its old value + * @nr: Bit to set + * @addr: Address to count from + */ +static inline int test_and_set_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + unsigned long old = *p; + + *p = old | mask; + return (old & mask) != 0; +} + +/** + * test_and_clear_bit - Clear a bit and return its old value + * @nr: Bit to clear + * @addr: Address to count from + */ +static inline int test_and_clear_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + unsigned long old = *p; + + *p = old & ~mask; + return (old & mask) != 0; +} + +/** + * test_and_change_bit - Change a bit and return its old value + * @nr: Bit to change + * @addr: Address to count from + */ +static inline int test_and_change_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + unsigned long old = *p; + + *p = old ^ mask; + return (old & mask) != 0; +} + +/** + * test_bit - Determine whether a bit is set + * @nr: bit number to test + * @addr: Address to start counting from + */ +static inline int test_bit(int nr, const unsigned long *addr) +{ + return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); +} + +/** + * find_last_bit - find the last set bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first set bit, or size. + */ +unsigned long find_last_bit(const unsigned long *addr, + unsigned long size); + +/** + * find_next_bit - find the next set bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The bitmap size in bits + */ +unsigned long find_next_bit(const unsigned long *addr, + unsigned long size, unsigned long offset); + +/** + * find_next_zero_bit - find the next cleared bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The bitmap size in bits + */ + +unsigned long find_next_zero_bit(const unsigned long *addr, + unsigned long size, + unsigned long offset); + +/** + * find_first_bit - find the first set bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first set bit. + */ +static inline unsigned long find_first_bit(const unsigned long *addr, + unsigned long size) +{ + return find_next_bit(addr, size, 0); +} + +/** + * find_first_zero_bit - find the first cleared bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first cleared bit. + */ +static inline unsigned long find_first_zero_bit(const unsigned long *addr, + unsigned long size) +{ + return find_next_zero_bit(addr, size, 0); +} + +static inline unsigned long hweight_long(unsigned long w) +{ + unsigned long count; + + for (count = 0; w; w >>= 1) { + count += w & 1; + } + return count; +} + +/** + * extract32: + * @value: the value to extract the bit field from + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * + * Extract from the 32 bit input @value the bit field specified by the + * @start and @length parameters, and return it. The bit field must + * lie entirely within the 32 bit word. It is valid to request that + * all 32 bits are returned (ie @length 32 and @start 0). + * + * Returns: the value of the bit field extracted from the input value. + */ +static inline uint32_t extract32(uint32_t value, int start, int length) +{ + assert(start >= 0 && length > 0 && length <= 32 - start); + return (value >> start) & (~0U >> (32 - length)); +} + +/** + * extract64: + * @value: the value to extract the bit field from + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * + * Extract from the 64 bit input @value the bit field specified by the + * @start and @length parameters, and return it. The bit field must + * lie entirely within the 64 bit word. It is valid to request that + * all 64 bits are returned (ie @length 64 and @start 0). + * + * Returns: the value of the bit field extracted from the input value. + */ +static inline uint64_t extract64(uint64_t value, int start, int length) +{ + assert(start >= 0 && length > 0 && length <= 64 - start); + return (value >> start) & (~0ULL >> (64 - length)); +} + +/** + * deposit32: + * @value: initial value to insert bit field into + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * @fieldval: the value to insert into the bit field + * + * Deposit @fieldval into the 32 bit @value at the bit field specified + * by the @start and @length parameters, and return the modified + * @value. Bits of @value outside the bit field are not modified. + * Bits of @fieldval above the least significant @length bits are + * ignored. The bit field must lie entirely within the 32 bit word. + * It is valid to request that all 32 bits are modified (ie @length + * 32 and @start 0). + * + * Returns: the modified @value. + */ +static inline uint32_t deposit32(uint32_t value, int start, int length, + uint32_t fieldval) +{ + uint32_t mask; + assert(start >= 0 && length > 0 && length <= 32 - start); + mask = (~0U >> (32 - length)) << start; + return (value & ~mask) | ((fieldval << start) & mask); +} + +/** + * deposit64: + * @value: initial value to insert bit field into + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * @fieldval: the value to insert into the bit field + * + * Deposit @fieldval into the 64 bit @value at the bit field specified + * by the @start and @length parameters, and return the modified + * @value. Bits of @value outside the bit field are not modified. + * Bits of @fieldval above the least significant @length bits are + * ignored. The bit field must lie entirely within the 64 bit word. + * It is valid to request that all 64 bits are modified (ie @length + * 64 and @start 0). + * + * Returns: the modified @value. + */ +static inline uint64_t deposit64(uint64_t value, int start, int length, + uint64_t fieldval) +{ + uint64_t mask; + assert(start >= 0 && length > 0 && length <= 64 - start); + mask = (~0ULL >> (64 - length)) << start; + return (value & ~mask) | ((fieldval << start) & mask); +} + +#endif diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h new file mode 100644 index 0000000000..cc7f84d30f --- /dev/null +++ b/include/qemu/bswap.h @@ -0,0 +1,713 @@ +#ifndef BSWAP_H +#define BSWAP_H + +#include "config-host.h" + +#include +#include "softfloat.h" + +#ifdef CONFIG_MACHINE_BSWAP_H +#include +#include +#include +#else + +#ifdef CONFIG_BYTESWAP_H +#include +#else + +#define bswap_16(x) \ +({ \ + uint16_t __x = (x); \ + ((uint16_t)( \ + (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \ + (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \ +}) + +#define bswap_32(x) \ +({ \ + uint32_t __x = (x); \ + ((uint32_t)( \ + (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ +}) + +#define bswap_64(x) \ +({ \ + uint64_t __x = (x); \ + ((uint64_t)( \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ +}) + +#endif /* !CONFIG_BYTESWAP_H */ + +static inline uint16_t bswap16(uint16_t x) +{ + return bswap_16(x); +} + +static inline uint32_t bswap32(uint32_t x) +{ + return bswap_32(x); +} + +static inline uint64_t bswap64(uint64_t x) +{ + return bswap_64(x); +} + +#endif /* ! CONFIG_MACHINE_BSWAP_H */ + +static inline void bswap16s(uint16_t *s) +{ + *s = bswap16(*s); +} + +static inline void bswap32s(uint32_t *s) +{ + *s = bswap32(*s); +} + +static inline void bswap64s(uint64_t *s) +{ + *s = bswap64(*s); +} + +#if defined(HOST_WORDS_BIGENDIAN) +#define be_bswap(v, size) (v) +#define le_bswap(v, size) bswap ## size(v) +#define be_bswaps(v, size) +#define le_bswaps(p, size) *p = bswap ## size(*p); +#else +#define le_bswap(v, size) (v) +#define be_bswap(v, size) bswap ## size(v) +#define le_bswaps(v, size) +#define be_bswaps(p, size) *p = bswap ## size(*p); +#endif + +#define CPU_CONVERT(endian, size, type)\ +static inline type endian ## size ## _to_cpu(type v)\ +{\ + return endian ## _bswap(v, size);\ +}\ +\ +static inline type cpu_to_ ## endian ## size(type v)\ +{\ + return endian ## _bswap(v, size);\ +}\ +\ +static inline void endian ## size ## _to_cpus(type *p)\ +{\ + endian ## _bswaps(p, size)\ +}\ +\ +static inline void cpu_to_ ## endian ## size ## s(type *p)\ +{\ + endian ## _bswaps(p, size)\ +}\ +\ +static inline type endian ## size ## _to_cpup(const type *p)\ +{\ + return endian ## size ## _to_cpu(*p);\ +}\ +\ +static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\ +{\ + *p = cpu_to_ ## endian ## size(v);\ +} + +CPU_CONVERT(be, 16, uint16_t) +CPU_CONVERT(be, 32, uint32_t) +CPU_CONVERT(be, 64, uint64_t) + +CPU_CONVERT(le, 16, uint16_t) +CPU_CONVERT(le, 32, uint32_t) +CPU_CONVERT(le, 64, uint64_t) + +/* unaligned versions (optimized for frequent unaligned accesses)*/ + +#if defined(__i386__) || defined(_ARCH_PPC) + +#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v) +#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v) +#define le16_to_cpupu(p) le16_to_cpup(p) +#define le32_to_cpupu(p) le32_to_cpup(p) +#define be32_to_cpupu(p) be32_to_cpup(p) + +#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v) +#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v) +#define cpu_to_be64wu(p, v) cpu_to_be64w(p, v) + +#else + +static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v & 0xff; + p1[1] = v >> 8; +} + +static inline void cpu_to_le32wu(uint32_t *p, uint32_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v & 0xff; + p1[1] = v >> 8; + p1[2] = v >> 16; + p1[3] = v >> 24; +} + +static inline uint16_t le16_to_cpupu(const uint16_t *p) +{ + const uint8_t *p1 = (const uint8_t *)p; + return p1[0] | (p1[1] << 8); +} + +static inline uint32_t le32_to_cpupu(const uint32_t *p) +{ + const uint8_t *p1 = (const uint8_t *)p; + return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24); +} + +static inline uint32_t be32_to_cpupu(const uint32_t *p) +{ + const uint8_t *p1 = (const uint8_t *)p; + return p1[3] | (p1[2] << 8) | (p1[1] << 16) | (p1[0] << 24); +} + +static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v >> 8; + p1[1] = v & 0xff; +} + +static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v >> 24; + p1[1] = v >> 16; + p1[2] = v >> 8; + p1[3] = v & 0xff; +} + +static inline void cpu_to_be64wu(uint64_t *p, uint64_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v >> 56; + p1[1] = v >> 48; + p1[2] = v >> 40; + p1[3] = v >> 32; + p1[4] = v >> 24; + p1[5] = v >> 16; + p1[6] = v >> 8; + p1[7] = v & 0xff; +} + +#endif + +#ifdef HOST_WORDS_BIGENDIAN +#define cpu_to_32wu cpu_to_be32wu +#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v) +#else +#define cpu_to_32wu cpu_to_le32wu +#define leul_to_cpu(v) (v) +#endif + +#undef le_bswap +#undef be_bswap +#undef le_bswaps +#undef be_bswaps + +/* len must be one of 1, 2, 4 */ +static inline uint32_t qemu_bswap_len(uint32_t value, int len) +{ + return bswap32(value) >> (32 - 8 * len); +} + +typedef union { + float32 f; + uint32_t l; +} CPU_FloatU; + +typedef union { + float64 d; +#if defined(HOST_WORDS_BIGENDIAN) + struct { + uint32_t upper; + uint32_t lower; + } l; +#else + struct { + uint32_t lower; + uint32_t upper; + } l; +#endif + uint64_t ll; +} CPU_DoubleU; + +typedef union { + floatx80 d; + struct { + uint64_t lower; + uint16_t upper; + } l; +} CPU_LDoubleU; + +typedef union { + float128 q; +#if defined(HOST_WORDS_BIGENDIAN) + struct { + uint32_t upmost; + uint32_t upper; + uint32_t lower; + uint32_t lowest; + } l; + struct { + uint64_t upper; + uint64_t lower; + } ll; +#else + struct { + uint32_t lowest; + uint32_t lower; + uint32_t upper; + uint32_t upmost; + } l; + struct { + uint64_t lower; + uint64_t upper; + } ll; +#endif +} CPU_QuadU; + +/* unaligned/endian-independent pointer access */ + +/* + * the generic syntax is: + * + * load: ld{type}{sign}{size}{endian}_p(ptr) + * + * store: st{type}{size}{endian}_p(ptr, val) + * + * Note there are small differences with the softmmu access API! + * + * type is: + * (empty): integer access + * f : float access + * + * sign is: + * (empty): for floats or 32 bit size + * u : unsigned + * s : signed + * + * size is: + * b: 8 bits + * w: 16 bits + * l: 32 bits + * q: 64 bits + * + * endian is: + * (empty): 8 bit access + * be : big endian + * le : little endian + */ +static inline int ldub_p(const void *ptr) +{ + return *(uint8_t *)ptr; +} + +static inline int ldsb_p(const void *ptr) +{ + return *(int8_t *)ptr; +} + +static inline void stb_p(void *ptr, int v) +{ + *(uint8_t *)ptr = v; +} + +/* NOTE: on arm, putting 2 in /proc/sys/debug/alignment so that the + kernel handles unaligned load/stores may give better results, but + it is a system wide setting : bad */ +#if defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) + +/* conservative code for little endian unaligned accesses */ +static inline int lduw_le_p(const void *ptr) +{ +#ifdef _ARCH_PPC + int val; + __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); + return val; +#else + const uint8_t *p = ptr; + return p[0] | (p[1] << 8); +#endif +} + +static inline int ldsw_le_p(const void *ptr) +{ +#ifdef _ARCH_PPC + int val; + __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); + return (int16_t)val; +#else + const uint8_t *p = ptr; + return (int16_t)(p[0] | (p[1] << 8)); +#endif +} + +static inline int ldl_le_p(const void *ptr) +{ +#ifdef _ARCH_PPC + int val; + __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (ptr)); + return val; +#else + const uint8_t *p = ptr; + return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); +#endif +} + +static inline uint64_t ldq_le_p(const void *ptr) +{ + const uint8_t *p = ptr; + uint32_t v1, v2; + v1 = ldl_le_p(p); + v2 = ldl_le_p(p + 4); + return v1 | ((uint64_t)v2 << 32); +} + +static inline void stw_le_p(void *ptr, int v) +{ +#ifdef _ARCH_PPC + __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr)); +#else + uint8_t *p = ptr; + p[0] = v; + p[1] = v >> 8; +#endif +} + +static inline void stl_le_p(void *ptr, int v) +{ +#ifdef _ARCH_PPC + __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr)); +#else + uint8_t *p = ptr; + p[0] = v; + p[1] = v >> 8; + p[2] = v >> 16; + p[3] = v >> 24; +#endif +} + +static inline void stq_le_p(void *ptr, uint64_t v) +{ + uint8_t *p = ptr; + stl_le_p(p, (uint32_t)v); + stl_le_p(p + 4, v >> 32); +} + +/* float access */ + +static inline float32 ldfl_le_p(const void *ptr) +{ + union { + float32 f; + uint32_t i; + } u; + u.i = ldl_le_p(ptr); + return u.f; +} + +static inline void stfl_le_p(void *ptr, float32 v) +{ + union { + float32 f; + uint32_t i; + } u; + u.f = v; + stl_le_p(ptr, u.i); +} + +static inline float64 ldfq_le_p(const void *ptr) +{ + CPU_DoubleU u; + u.l.lower = ldl_le_p(ptr); + u.l.upper = ldl_le_p(ptr + 4); + return u.d; +} + +static inline void stfq_le_p(void *ptr, float64 v) +{ + CPU_DoubleU u; + u.d = v; + stl_le_p(ptr, u.l.lower); + stl_le_p(ptr + 4, u.l.upper); +} + +#else + +static inline int lduw_le_p(const void *ptr) +{ + return *(uint16_t *)ptr; +} + +static inline int ldsw_le_p(const void *ptr) +{ + return *(int16_t *)ptr; +} + +static inline int ldl_le_p(const void *ptr) +{ + return *(uint32_t *)ptr; +} + +static inline uint64_t ldq_le_p(const void *ptr) +{ + return *(uint64_t *)ptr; +} + +static inline void stw_le_p(void *ptr, int v) +{ + *(uint16_t *)ptr = v; +} + +static inline void stl_le_p(void *ptr, int v) +{ + *(uint32_t *)ptr = v; +} + +static inline void stq_le_p(void *ptr, uint64_t v) +{ + *(uint64_t *)ptr = v; +} + +/* float access */ + +static inline float32 ldfl_le_p(const void *ptr) +{ + return *(float32 *)ptr; +} + +static inline float64 ldfq_le_p(const void *ptr) +{ + return *(float64 *)ptr; +} + +static inline void stfl_le_p(void *ptr, float32 v) +{ + *(float32 *)ptr = v; +} + +static inline void stfq_le_p(void *ptr, float64 v) +{ + *(float64 *)ptr = v; +} +#endif + +#if !defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) + +static inline int lduw_be_p(const void *ptr) +{ +#if defined(__i386__) + int val; + asm volatile ("movzwl %1, %0\n" + "xchgb %b0, %h0\n" + : "=q" (val) + : "m" (*(uint16_t *)ptr)); + return val; +#else + const uint8_t *b = ptr; + return ((b[0] << 8) | b[1]); +#endif +} + +static inline int ldsw_be_p(const void *ptr) +{ +#if defined(__i386__) + int val; + asm volatile ("movzwl %1, %0\n" + "xchgb %b0, %h0\n" + : "=q" (val) + : "m" (*(uint16_t *)ptr)); + return (int16_t)val; +#else + const uint8_t *b = ptr; + return (int16_t)((b[0] << 8) | b[1]); +#endif +} + +static inline int ldl_be_p(const void *ptr) +{ +#if defined(__i386__) || defined(__x86_64__) + int val; + asm volatile ("movl %1, %0\n" + "bswap %0\n" + : "=r" (val) + : "m" (*(uint32_t *)ptr)); + return val; +#else + const uint8_t *b = ptr; + return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; +#endif +} + +static inline uint64_t ldq_be_p(const void *ptr) +{ + uint32_t a,b; + a = ldl_be_p(ptr); + b = ldl_be_p((uint8_t *)ptr + 4); + return (((uint64_t)a<<32)|b); +} + +static inline void stw_be_p(void *ptr, int v) +{ +#if defined(__i386__) + asm volatile ("xchgb %b0, %h0\n" + "movw %w0, %1\n" + : "=q" (v) + : "m" (*(uint16_t *)ptr), "0" (v)); +#else + uint8_t *d = (uint8_t *) ptr; + d[0] = v >> 8; + d[1] = v; +#endif +} + +static inline void stl_be_p(void *ptr, int v) +{ +#if defined(__i386__) || defined(__x86_64__) + asm volatile ("bswap %0\n" + "movl %0, %1\n" + : "=r" (v) + : "m" (*(uint32_t *)ptr), "0" (v)); +#else + uint8_t *d = (uint8_t *) ptr; + d[0] = v >> 24; + d[1] = v >> 16; + d[2] = v >> 8; + d[3] = v; +#endif +} + +static inline void stq_be_p(void *ptr, uint64_t v) +{ + stl_be_p(ptr, v >> 32); + stl_be_p((uint8_t *)ptr + 4, v); +} + +/* float access */ + +static inline float32 ldfl_be_p(const void *ptr) +{ + union { + float32 f; + uint32_t i; + } u; + u.i = ldl_be_p(ptr); + return u.f; +} + +static inline void stfl_be_p(void *ptr, float32 v) +{ + union { + float32 f; + uint32_t i; + } u; + u.f = v; + stl_be_p(ptr, u.i); +} + +static inline float64 ldfq_be_p(const void *ptr) +{ + CPU_DoubleU u; + u.l.upper = ldl_be_p(ptr); + u.l.lower = ldl_be_p((uint8_t *)ptr + 4); + return u.d; +} + +static inline void stfq_be_p(void *ptr, float64 v) +{ + CPU_DoubleU u; + u.d = v; + stl_be_p(ptr, u.l.upper); + stl_be_p((uint8_t *)ptr + 4, u.l.lower); +} + +#else + +static inline int lduw_be_p(const void *ptr) +{ + return *(uint16_t *)ptr; +} + +static inline int ldsw_be_p(const void *ptr) +{ + return *(int16_t *)ptr; +} + +static inline int ldl_be_p(const void *ptr) +{ + return *(uint32_t *)ptr; +} + +static inline uint64_t ldq_be_p(const void *ptr) +{ + return *(uint64_t *)ptr; +} + +static inline void stw_be_p(void *ptr, int v) +{ + *(uint16_t *)ptr = v; +} + +static inline void stl_be_p(void *ptr, int v) +{ + *(uint32_t *)ptr = v; +} + +static inline void stq_be_p(void *ptr, uint64_t v) +{ + *(uint64_t *)ptr = v; +} + +/* float access */ + +static inline float32 ldfl_be_p(const void *ptr) +{ + return *(float32 *)ptr; +} + +static inline float64 ldfq_be_p(const void *ptr) +{ + return *(float64 *)ptr; +} + +static inline void stfl_be_p(void *ptr, float32 v) +{ + *(float32 *)ptr = v; +} + +static inline void stfq_be_p(void *ptr, float64 v) +{ + *(float64 *)ptr = v; +} + +#endif + +#endif /* BSWAP_H */ diff --git a/include/qemu/cache-utils.h b/include/qemu/cache-utils.h new file mode 100644 index 0000000000..2c57f78fc1 --- /dev/null +++ b/include/qemu/cache-utils.h @@ -0,0 +1,44 @@ +#ifndef QEMU_CACHE_UTILS_H +#define QEMU_CACHE_UTILS_H + +#if defined(_ARCH_PPC) + +#include /* uintptr_t */ + +struct qemu_cache_conf { + unsigned long dcache_bsize; + unsigned long icache_bsize; +}; + +extern struct qemu_cache_conf qemu_cache_conf; + +void qemu_cache_utils_init(char **envp); + +/* mildly adjusted code from tcg-dyngen.c */ +static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + unsigned long p, start1, stop1; + unsigned long dsize = qemu_cache_conf.dcache_bsize; + unsigned long isize = qemu_cache_conf.icache_bsize; + + start1 = start & ~(dsize - 1); + stop1 = (stop + dsize - 1) & ~(dsize - 1); + for (p = start1; p < stop1; p += dsize) { + asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + + start &= start & ~(isize - 1); + stop1 = (stop + isize - 1) & ~(isize - 1); + for (p = start1; p < stop1; p += isize) { + asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + asm volatile ("isync" : : : "memory"); +} + +#else +#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) +#endif + +#endif /* QEMU_CACHE_UTILS_H */ diff --git a/include/qemu/compatfd.h b/include/qemu/compatfd.h new file mode 100644 index 0000000000..6b04877b97 --- /dev/null +++ b/include/qemu/compatfd.h @@ -0,0 +1,44 @@ +/* + * signalfd/eventfd compatibility + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_COMPATFD_H +#define QEMU_COMPATFD_H + +#include + +struct qemu_signalfd_siginfo { + uint32_t ssi_signo; /* Signal number */ + int32_t ssi_errno; /* Error number (unused) */ + int32_t ssi_code; /* Signal code */ + uint32_t ssi_pid; /* PID of sender */ + uint32_t ssi_uid; /* Real UID of sender */ + int32_t ssi_fd; /* File descriptor (SIGIO) */ + uint32_t ssi_tid; /* Kernel timer ID (POSIX timers) */ + uint32_t ssi_band; /* Band event (SIGIO) */ + uint32_t ssi_overrun; /* POSIX timer overrun count */ + uint32_t ssi_trapno; /* Trap number that caused signal */ + int32_t ssi_status; /* Exit status or signal (SIGCHLD) */ + int32_t ssi_int; /* Integer sent by sigqueue(2) */ + uint64_t ssi_ptr; /* Pointer sent by sigqueue(2) */ + uint64_t ssi_utime; /* User CPU time consumed (SIGCHLD) */ + uint64_t ssi_stime; /* System CPU time consumed (SIGCHLD) */ + uint64_t ssi_addr; /* Address that generated signal + (for hardware-generated signals) */ + uint8_t pad[48]; /* Pad size to 128 bytes (allow for + additional fields in the future) */ +}; + +int qemu_signalfd(const sigset_t *mask); +bool qemu_signalfd_available(void); + +#endif diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h new file mode 100644 index 0000000000..2f7998b6c1 --- /dev/null +++ b/include/qemu/compiler.h @@ -0,0 +1,58 @@ +/* public domain */ + +#ifndef COMPILER_H +#define COMPILER_H + +#include "config-host.h" + +/*---------------------------------------------------------------------------- +| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler. +| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h. +*----------------------------------------------------------------------------*/ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define QEMU_GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define QEMU_GNUC_PREREQ(maj, min) 0 +#endif + +#define QEMU_NORETURN __attribute__ ((__noreturn__)) + +#if QEMU_GNUC_PREREQ(3, 4) +#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define QEMU_WARN_UNUSED_RESULT +#endif + +#if defined(_WIN32) +# define QEMU_PACKED __attribute__((gcc_struct, packed)) +#else +# define QEMU_PACKED __attribute__((packed)) +#endif + +#define cat(x,y) x ## y +#define cat2(x,y) cat(x,y) +#define QEMU_BUILD_BUG_ON(x) \ + typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1]; + +#if defined __GNUC__ +# if !QEMU_GNUC_PREREQ(4, 4) + /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */ +# define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2))) +# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m))) +# else + /* Use gnu_printf when supported (qemu uses standard format strings). */ +# define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2))) +# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m))) +# if defined(_WIN32) + /* Map __printf__ to __gnu_printf__ because we want standard format strings + * even when MinGW or GLib include files use __printf__. */ +# define __printf__ __gnu_printf__ +# endif +# endif +#else +#define GCC_ATTR /**/ +#define GCC_FMT_ATTR(n, m) +#endif + +#endif /* COMPILER_H */ diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h new file mode 100644 index 0000000000..486c77cad4 --- /dev/null +++ b/include/qemu/config-file.h @@ -0,0 +1,30 @@ +#ifndef QEMU_CONFIG_H +#define QEMU_CONFIG_H + +#include +#include "qemu/option.h" +#include "qapi/error.h" +#include "qemu/option.h" + +extern QemuOptsList qemu_fsdev_opts; +extern QemuOptsList qemu_virtfs_opts; +extern QemuOptsList qemu_spice_opts; +extern QemuOptsList qemu_sandbox_opts; + +QemuOptsList *qemu_find_opts(const char *group); +QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); +void qemu_add_opts(QemuOptsList *list); +int qemu_set_option(const char *str); +int qemu_global_option(const char *str); +void qemu_add_globals(void); + +void qemu_config_write(FILE *fp); +int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname); + +int qemu_read_config_file(const char *filename); + +/* Read default QEMU config files + */ +int qemu_read_default_config_files(bool userconfig); + +#endif /* QEMU_CONFIG_H */ diff --git a/include/qemu/envlist.h b/include/qemu/envlist.h new file mode 100644 index 0000000000..b9addcc11f --- /dev/null +++ b/include/qemu/envlist.h @@ -0,0 +1,22 @@ +#ifndef ENVLIST_H +#define ENVLIST_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct envlist envlist_t; + +envlist_t *envlist_create(void); +void envlist_free(envlist_t *); +int envlist_setenv(envlist_t *, const char *); +int envlist_unsetenv(envlist_t *, const char *); +int envlist_parse_set(envlist_t *, const char *); +int envlist_parse_unset(envlist_t *, const char *); +char **envlist_to_environ(const envlist_t *, size_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* ENVLIST_H */ diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h new file mode 100644 index 0000000000..c902cc10de --- /dev/null +++ b/include/qemu/error-report.h @@ -0,0 +1,43 @@ +/* + * Error reporting + * + * Copyright (C) 2010 Red Hat Inc. + * + * Authors: + * Markus Armbruster , + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_ERROR_H +#define QEMU_ERROR_H + +#include + +typedef struct Location { + /* all members are private to qemu-error.c */ + enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind; + int num; + const void *ptr; + struct Location *prev; +} Location; + +Location *loc_push_restore(Location *loc); +Location *loc_push_none(Location *loc); +Location *loc_pop(Location *loc); +Location *loc_save(Location *loc); +void loc_restore(Location *loc); +void loc_set_none(void); +void loc_set_cmdline(char **argv, int idx, int cnt); +void loc_set_file(const char *fname, int lno); + +void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); +void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void error_print_loc(void); +void error_set_progname(const char *argv0); +void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +const char *error_get_progname(void); + +#endif diff --git a/include/qemu/event_notifier.h b/include/qemu/event_notifier.h new file mode 100644 index 0000000000..88b57af7ce --- /dev/null +++ b/include/qemu/event_notifier.h @@ -0,0 +1,46 @@ +/* + * event notifier support + * + * Copyright Red Hat, Inc. 2010 + * + * Authors: + * Michael S. Tsirkin + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_EVENT_NOTIFIER_H +#define QEMU_EVENT_NOTIFIER_H + +#include "qemu-common.h" + +#ifdef _WIN32 +#include +#endif + +struct EventNotifier { +#ifdef _WIN32 + HANDLE event; +#else + int rfd; + int wfd; +#endif +}; + +typedef void EventNotifierHandler(EventNotifier *); + +int event_notifier_init(EventNotifier *, int active); +void event_notifier_cleanup(EventNotifier *); +int event_notifier_set(EventNotifier *); +int event_notifier_test_and_clear(EventNotifier *); +int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *); + +#ifdef CONFIG_POSIX +void event_notifier_init_fd(EventNotifier *, int fd); +int event_notifier_get_fd(EventNotifier *); +#else +HANDLE event_notifier_get_handle(EventNotifier *); +#endif + +#endif diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h new file mode 100644 index 0000000000..81c9a754ae --- /dev/null +++ b/include/qemu/host-utils.h @@ -0,0 +1,240 @@ +/* + * Utility compute operations used by translated code. + * + * Copyright (c) 2007 Thiemo Seufer + * Copyright (c) 2007 Jocelyn Mayer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef HOST_UTILS_H +#define HOST_UTILS_H 1 + +#include "qemu/compiler.h" /* QEMU_GNUC_PREREQ */ + +#if defined(__x86_64__) +#define __HAVE_FAST_MULU64__ +static inline void mulu64(uint64_t *plow, uint64_t *phigh, + uint64_t a, uint64_t b) +{ + __asm__ ("mul %0\n\t" + : "=d" (*phigh), "=a" (*plow) + : "a" (a), "0" (b)); +} +#define __HAVE_FAST_MULS64__ +static inline void muls64(uint64_t *plow, uint64_t *phigh, + int64_t a, int64_t b) +{ + __asm__ ("imul %0\n\t" + : "=d" (*phigh), "=a" (*plow) + : "a" (a), "0" (b)); +} +#else +void muls64(uint64_t *phigh, uint64_t *plow, int64_t a, int64_t b); +void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); +#endif + +/* Binary search for leading zeros. */ + +static inline int clz32(uint32_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_clz(val); + else + return 32; +#else + int cnt = 0; + + if (!(val & 0xFFFF0000U)) { + cnt += 16; + val <<= 16; + } + if (!(val & 0xFF000000U)) { + cnt += 8; + val <<= 8; + } + if (!(val & 0xF0000000U)) { + cnt += 4; + val <<= 4; + } + if (!(val & 0xC0000000U)) { + cnt += 2; + val <<= 2; + } + if (!(val & 0x80000000U)) { + cnt++; + val <<= 1; + } + if (!(val & 0x80000000U)) { + cnt++; + } + return cnt; +#endif +} + +static inline int clo32(uint32_t val) +{ + return clz32(~val); +} + +static inline int clz64(uint64_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_clzll(val); + else + return 64; +#else + int cnt = 0; + + if (!(val >> 32)) { + cnt += 32; + } else { + val >>= 32; + } + + return cnt + clz32(val); +#endif +} + +static inline int clo64(uint64_t val) +{ + return clz64(~val); +} + +static inline int ctz32(uint32_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_ctz(val); + else + return 32; +#else + int cnt; + + cnt = 0; + if (!(val & 0x0000FFFFUL)) { + cnt += 16; + val >>= 16; + } + if (!(val & 0x000000FFUL)) { + cnt += 8; + val >>= 8; + } + if (!(val & 0x0000000FUL)) { + cnt += 4; + val >>= 4; + } + if (!(val & 0x00000003UL)) { + cnt += 2; + val >>= 2; + } + if (!(val & 0x00000001UL)) { + cnt++; + val >>= 1; + } + if (!(val & 0x00000001UL)) { + cnt++; + } + + return cnt; +#endif +} + +static inline int cto32(uint32_t val) +{ + return ctz32(~val); +} + +static inline int ctz64(uint64_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_ctzll(val); + else + return 64; +#else + int cnt; + + cnt = 0; + if (!((uint32_t)val)) { + cnt += 32; + val >>= 32; + } + + return cnt + ctz32(val); +#endif +} + +static inline int cto64(uint64_t val) +{ + return ctz64(~val); +} + +static inline int ctpop8(uint8_t val) +{ + val = (val & 0x55) + ((val >> 1) & 0x55); + val = (val & 0x33) + ((val >> 2) & 0x33); + val = (val & 0x0f) + ((val >> 4) & 0x0f); + + return val; +} + +static inline int ctpop16(uint16_t val) +{ + val = (val & 0x5555) + ((val >> 1) & 0x5555); + val = (val & 0x3333) + ((val >> 2) & 0x3333); + val = (val & 0x0f0f) + ((val >> 4) & 0x0f0f); + val = (val & 0x00ff) + ((val >> 8) & 0x00ff); + + return val; +} + +static inline int ctpop32(uint32_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + return __builtin_popcount(val); +#else + val = (val & 0x55555555) + ((val >> 1) & 0x55555555); + val = (val & 0x33333333) + ((val >> 2) & 0x33333333); + val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f); + val = (val & 0x00ff00ff) + ((val >> 8) & 0x00ff00ff); + val = (val & 0x0000ffff) + ((val >> 16) & 0x0000ffff); + + return val; +#endif +} + +static inline int ctpop64(uint64_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + return __builtin_popcountll(val); +#else + val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); + val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL); + val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL); + val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & 0x00ff00ff00ff00ffULL); + val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL); + val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL); + + return val; +#endif +} + +#endif diff --git a/include/qemu/int128.h b/include/qemu/int128.h new file mode 100644 index 0000000000..b3864b6cd4 --- /dev/null +++ b/include/qemu/int128.h @@ -0,0 +1,116 @@ +#ifndef INT128_H +#define INT128_H + +typedef struct Int128 Int128; + +struct Int128 { + uint64_t lo; + int64_t hi; +}; + +static inline Int128 int128_make64(uint64_t a) +{ + return (Int128) { a, 0 }; +} + +static inline uint64_t int128_get64(Int128 a) +{ + assert(!a.hi); + return a.lo; +} + +static inline Int128 int128_zero(void) +{ + return int128_make64(0); +} + +static inline Int128 int128_one(void) +{ + return int128_make64(1); +} + +static inline Int128 int128_2_64(void) +{ + return (Int128) { 0, 1 }; +} + +static inline Int128 int128_add(Int128 a, Int128 b) +{ + Int128 r = { a.lo + b.lo, a.hi + b.hi }; + r.hi += (r.lo < a.lo) || (r.lo < b.lo); + return r; +} + +static inline Int128 int128_neg(Int128 a) +{ + a.lo = ~a.lo; + a.hi = ~a.hi; + return int128_add(a, int128_one()); +} + +static inline Int128 int128_sub(Int128 a, Int128 b) +{ + return int128_add(a, int128_neg(b)); +} + +static inline bool int128_nonneg(Int128 a) +{ + return a.hi >= 0; +} + +static inline bool int128_eq(Int128 a, Int128 b) +{ + return a.lo == b.lo && a.hi == b.hi; +} + +static inline bool int128_ne(Int128 a, Int128 b) +{ + return !int128_eq(a, b); +} + +static inline bool int128_ge(Int128 a, Int128 b) +{ + return int128_nonneg(int128_sub(a, b)); +} + +static inline bool int128_lt(Int128 a, Int128 b) +{ + return !int128_ge(a, b); +} + +static inline bool int128_le(Int128 a, Int128 b) +{ + return int128_ge(b, a); +} + +static inline bool int128_gt(Int128 a, Int128 b) +{ + return !int128_le(a, b); +} + +static inline bool int128_nz(Int128 a) +{ + return a.lo || a.hi; +} + +static inline Int128 int128_min(Int128 a, Int128 b) +{ + return int128_le(a, b) ? a : b; +} + +static inline Int128 int128_max(Int128 a, Int128 b) +{ + return int128_ge(a, b) ? a : b; +} + +static inline void int128_addto(Int128 *a, Int128 b) +{ + *a = int128_add(*a, b); +} + +static inline void int128_subfrom(Int128 *a, Int128 b) +{ + *a = int128_sub(*a, b); +} + +#endif diff --git a/include/qemu/iov.h b/include/qemu/iov.h new file mode 100644 index 0000000000..d06f8b9ce3 --- /dev/null +++ b/include/qemu/iov.h @@ -0,0 +1,102 @@ +/* + * Helpers for using (partial) iovecs. + * + * Copyright (C) 2010 Red Hat, Inc. + * + * Author(s): + * Amit Shah + * Michael Tokarev + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#ifndef IOV_H +#define IOV_H + +#include "qemu-common.h" + +/** + * count and return data size, in bytes, of an iovec + * starting at `iov' of `iov_cnt' number of elements. + */ +size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt); + +/** + * Copy from single continuous buffer to scatter-gather vector of buffers + * (iovec) and back like memcpy() between two continuous memory regions. + * Data in single continuous buffer starting at address `buf' and + * `bytes' bytes long will be copied to/from an iovec `iov' with + * `iov_cnt' number of elements, starting at byte position `offset' + * within the iovec. If the iovec does not contain enough space, + * only part of data will be copied, up to the end of the iovec. + * Number of bytes actually copied will be returned, which is + * min(bytes, iov_size(iov)-offset) + * `Offset' must point to the inside of iovec. + * It is okay to use very large value for `bytes' since we're + * limited by the size of the iovec anyway, provided that the + * buffer pointed to by buf has enough space. One possible + * such "large" value is -1 (sinice size_t is unsigned), + * so specifying `-1' as `bytes' means 'up to the end of iovec'. + */ +size_t iov_from_buf(const struct iovec *iov, unsigned int iov_cnt, + size_t offset, const void *buf, size_t bytes); +size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, + size_t offset, void *buf, size_t bytes); + +/** + * Set data bytes pointed out by iovec `iov' of size `iov_cnt' elements, + * starting at byte offset `start', to value `fillc', repeating it + * `bytes' number of times. `Offset' must point to the inside of iovec. + * If `bytes' is large enough, only last bytes portion of iovec, + * up to the end of it, will be filled with the specified value. + * Function return actual number of bytes processed, which is + * min(size, iov_size(iov) - offset). + * Again, it is okay to use large value for `bytes' to mean "up to the end". + */ +size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, + size_t offset, int fillc, size_t bytes); + +/* + * Send/recv data from/to iovec buffers directly + * + * `offset' bytes in the beginning of iovec buffer are skipped and + * next `bytes' bytes are used, which must be within data of iovec. + * + * r = iov_send_recv(sockfd, iov, iovcnt, offset, bytes, true); + * + * is logically equivalent to + * + * char *buf = malloc(bytes); + * iov_to_buf(iov, iovcnt, offset, buf, bytes); + * r = send(sockfd, buf, bytes, 0); + * free(buf); + * + * For iov_send_recv() _whole_ area being sent or received + * should be within the iovec, not only beginning of it. + */ +ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, + size_t offset, size_t bytes, bool do_send); +#define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \ + iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false) +#define iov_send(sockfd, iov, iov_cnt, offset, bytes) \ + iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, true) + +/** + * Produce a text hexdump of iovec `iov' with `iov_cnt' number of elements + * in file `fp', prefixing each line with `prefix' and processing not more + * than `limit' data bytes. + */ +void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, + FILE *fp, const char *prefix, size_t limit); + +/* + * Partial copy of vector from iov to dst_iov (data is not copied). + * dst_iov overlaps iov at a specified offset. + * size of dst_iov is at most bytes. dst vector count is returned. + */ +unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, + const struct iovec *iov, unsigned int iov_cnt, + size_t offset, size_t bytes); + +#endif diff --git a/include/qemu/log.h b/include/qemu/log.h new file mode 100644 index 0000000000..58f69cb494 --- /dev/null +++ b/include/qemu/log.h @@ -0,0 +1,160 @@ +#ifndef QEMU_LOG_H +#define QEMU_LOG_H + +#include +#ifdef NEED_CPU_H +#include "disas/disas.h" +#endif + +/* Private global variables, don't use */ +extern FILE *qemu_logfile; +extern int qemu_loglevel; + +/* + * The new API: + * + */ + +/* Log settings checking macros: */ + +/* Returns true if qemu_log() will really write somewhere + */ +static inline bool qemu_log_enabled(void) +{ + return qemu_logfile != NULL; +} + +#define CPU_LOG_TB_OUT_ASM (1 << 0) +#define CPU_LOG_TB_IN_ASM (1 << 1) +#define CPU_LOG_TB_OP (1 << 2) +#define CPU_LOG_TB_OP_OPT (1 << 3) +#define CPU_LOG_INT (1 << 4) +#define CPU_LOG_EXEC (1 << 5) +#define CPU_LOG_PCALL (1 << 6) +#define CPU_LOG_IOPORT (1 << 7) +#define CPU_LOG_TB_CPU (1 << 8) +#define CPU_LOG_RESET (1 << 9) +#define LOG_UNIMP (1 << 10) +#define LOG_GUEST_ERROR (1 << 11) + +/* Returns true if a bit is set in the current loglevel mask + */ +static inline bool qemu_loglevel_mask(int mask) +{ + return (qemu_loglevel & mask) != 0; +} + +/* Logging functions: */ + +/* main logging function + */ +void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...); + +/* vfprintf-like logging function + */ +static inline void GCC_FMT_ATTR(1, 0) +qemu_log_vprintf(const char *fmt, va_list va) +{ + if (qemu_logfile) { + vfprintf(qemu_logfile, fmt, va); + } +} + +/* log only if a bit is set on the current loglevel mask + */ +void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...); + + +/* Special cases: */ + +#ifdef NEED_CPU_H +/* cpu_dump_state() logging functions: */ +static inline void log_cpu_state(CPUArchState *env1, int flags) +{ + if (qemu_log_enabled()) { + cpu_dump_state(env1, qemu_logfile, fprintf, flags); + } +} + +static inline void log_cpu_state_mask(int mask, CPUArchState *env1, int flags) +{ + if (qemu_loglevel & mask) { + log_cpu_state(env1, flags); + } +} + +/* disas() and target_disas() to qemu_logfile: */ +static inline void log_target_disas(CPUArchState *env, target_ulong start, + target_ulong len, int flags) +{ + target_disas(qemu_logfile, env, start, len, flags); +} + +static inline void log_disas(void *code, unsigned long size) +{ + disas(qemu_logfile, code, size); +} + +#if defined(CONFIG_USER_ONLY) +/* page_dump() output to the log file: */ +static inline void log_page_dump(void) +{ + page_dump(qemu_logfile); +} +#endif +#endif + + +/* Maintenance: */ + +/* fflush() the log file */ +static inline void qemu_log_flush(void) +{ + fflush(qemu_logfile); +} + +/* Close the log file */ +static inline void qemu_log_close(void) +{ + fclose(qemu_logfile); + qemu_logfile = NULL; +} + +/* Set up a new log file */ +static inline void qemu_log_set_file(FILE *f) +{ + qemu_logfile = f; +} + +/* Set up a new log file, only if none is set */ +static inline void qemu_log_try_set_file(FILE *f) +{ + if (!qemu_logfile) { + qemu_logfile = f; + } +} + +/* define log items */ +typedef struct CPULogItem { + int mask; + const char *name; + const char *help; +} CPULogItem; + +extern const CPULogItem cpu_log_items[]; + +void qemu_set_log(int log_flags, bool use_own_buffers); + +static inline void cpu_set_log(int log_flags) +{ +#ifdef CONFIG_USER_ONLY + qemu_set_log(log_flags, true); +#else + qemu_set_log(log_flags, false); +#endif +} + +void cpu_set_log_filename(const char *filename); +int cpu_str_to_log_mask(const char *str); + +#endif diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h new file mode 100644 index 0000000000..e8059c3d0a --- /dev/null +++ b/include/qemu/main-loop.h @@ -0,0 +1,306 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_MAIN_LOOP_H +#define QEMU_MAIN_LOOP_H 1 + +#include "block/aio.h" + +#define SIG_IPI SIGUSR1 + +/** + * qemu_init_main_loop: Set up the process so that it can run the main loop. + * + * This includes setting up signal handlers. It should be called before + * any other threads are created. In addition, threads other than the + * main one should block signals that are trapped by the main loop. + * For simplicity, you can consider these signals to be safe: SIGUSR1, + * SIGUSR2, thread signals (SIGFPE, SIGILL, SIGSEGV, SIGBUS) and real-time + * signals if available. Remember that Windows in practice does not have + * signals, though. + * + * In the case of QEMU tools, this will also start/initialize timers. + */ +int qemu_init_main_loop(void); + +/** + * main_loop_wait: Run one iteration of the main loop. + * + * If @nonblocking is true, poll for events, otherwise suspend until + * one actually occurs. The main loop usually consists of a loop that + * repeatedly calls main_loop_wait(false). + * + * Main loop services include file descriptor callbacks, bottom halves + * and timers (defined in qemu-timer.h). Bottom halves are similar to timers + * that execute immediately, but have a lower overhead and scheduling them + * is wait-free, thread-safe and signal-safe. + * + * It is sometimes useful to put a whole program in a coroutine. In this + * case, the coroutine actually should be started from within the main loop, + * so that the main loop can run whenever the coroutine yields. To do this, + * you can use a bottom half to enter the coroutine as soon as the main loop + * starts: + * + * void enter_co_bh(void *opaque) { + * QEMUCoroutine *co = opaque; + * qemu_coroutine_enter(co, NULL); + * } + * + * ... + * QEMUCoroutine *co = qemu_coroutine_create(coroutine_entry); + * QEMUBH *start_bh = qemu_bh_new(enter_co_bh, co); + * qemu_bh_schedule(start_bh); + * while (...) { + * main_loop_wait(false); + * } + * + * (In the future we may provide a wrapper for this). + * + * @nonblocking: Whether the caller should block until an event occurs. + */ +int main_loop_wait(int nonblocking); + +/** + * qemu_notify_event: Force processing of pending events. + * + * Similar to signaling a condition variable, qemu_notify_event forces + * main_loop_wait to look at pending events and exit. The caller of + * main_loop_wait will usually call it again very soon, so qemu_notify_event + * also has the side effect of recalculating the sets of file descriptors + * that the main loop waits for. + * + * Calling qemu_notify_event is rarely necessary, because main loop + * services (bottom halves and timers) call it themselves. One notable + * exception occurs when using qemu_set_fd_handler2 (see below). + */ +void qemu_notify_event(void); + +#ifdef _WIN32 +/* return TRUE if no sleep should be done afterwards */ +typedef int PollingFunc(void *opaque); + +/** + * qemu_add_polling_cb: Register a Windows-specific polling callback + * + * Currently, under Windows some events are polled rather than waited for. + * Polling callbacks do not ensure that @func is called timely, because + * the main loop might wait for an arbitrarily long time. If possible, + * you should instead create a separate thread that does a blocking poll + * and set a Win32 event object. The event can then be passed to + * qemu_add_wait_object. + * + * Polling callbacks really have nothing Windows specific in them, but + * as they are a hack and are currently not necessary under POSIX systems, + * they are only available when QEMU is running under Windows. + * + * @func: The function that does the polling, and returns 1 to force + * immediate completion of main_loop_wait. + * @opaque: A pointer-size value that is passed to @func. + */ +int qemu_add_polling_cb(PollingFunc *func, void *opaque); + +/** + * qemu_del_polling_cb: Unregister a Windows-specific polling callback + * + * This function removes a callback that was registered with + * qemu_add_polling_cb. + * + * @func: The function that was passed to qemu_add_polling_cb. + * @opaque: A pointer-size value that was passed to qemu_add_polling_cb. + */ +void qemu_del_polling_cb(PollingFunc *func, void *opaque); + +/* Wait objects handling */ +typedef void WaitObjectFunc(void *opaque); + +/** + * qemu_add_wait_object: Register a callback for a Windows handle + * + * Under Windows, the iohandler mechanism can only be used with sockets. + * QEMU must use the WaitForMultipleObjects API to wait on other handles. + * This function registers a #HANDLE with QEMU, so that it will be included + * in the main loop's calls to WaitForMultipleObjects. When the handle + * is in a signaled state, QEMU will call @func. + * + * @handle: The Windows handle to be observed. + * @func: A function to be called when @handle is in a signaled state. + * @opaque: A pointer-size value that is passed to @func. + */ +int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); + +/** + * qemu_del_wait_object: Unregister a callback for a Windows handle + * + * This function removes a callback that was registered with + * qemu_add_wait_object. + * + * @func: The function that was passed to qemu_add_wait_object. + * @opaque: A pointer-size value that was passed to qemu_add_wait_object. + */ +void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); +#endif + +/* async I/O support */ + +typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); +typedef int IOCanReadHandler(void *opaque); + +/** + * qemu_set_fd_handler2: Register a file descriptor with the main loop + * + * This function tells the main loop to wake up whenever one of the + * following conditions is true: + * + * 1) if @fd_write is not %NULL, when the file descriptor is writable; + * + * 2) if @fd_read is not %NULL, when the file descriptor is readable. + * + * @fd_read_poll can be used to disable the @fd_read callback temporarily. + * This is useful to avoid calling qemu_set_fd_handler2 every time the + * client becomes interested in reading (or dually, stops being interested). + * A typical example is when @fd is a listening socket and you want to bound + * the number of active clients. Remember to call qemu_notify_event whenever + * the condition may change from %false to %true. + * + * The callbacks that are set up by qemu_set_fd_handler2 are level-triggered. + * If @fd_read does not read from @fd, or @fd_write does not write to @fd + * until its buffers are full, they will be called again on the next + * iteration. + * + * @fd: The file descriptor to be observed. Under Windows it must be + * a #SOCKET. + * + * @fd_read_poll: A function that returns 1 if the @fd_read callback + * should be fired. If the function returns 0, the main loop will not + * end its iteration even if @fd becomes readable. + * + * @fd_read: A level-triggered callback that is fired if @fd is readable + * at the beginning of a main loop iteration, or if it becomes readable + * during one. + * + * @fd_write: A level-triggered callback that is fired when @fd is writable + * at the beginning of a main loop iteration, or if it becomes writable + * during one. + * + * @opaque: A pointer-sized value that is passed to @fd_read_poll, + * @fd_read and @fd_write. + */ +int qemu_set_fd_handler2(int fd, + IOCanReadHandler *fd_read_poll, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque); + +/** + * qemu_set_fd_handler: Register a file descriptor with the main loop + * + * This function tells the main loop to wake up whenever one of the + * following conditions is true: + * + * 1) if @fd_write is not %NULL, when the file descriptor is writable; + * + * 2) if @fd_read is not %NULL, when the file descriptor is readable. + * + * The callbacks that are set up by qemu_set_fd_handler are level-triggered. + * If @fd_read does not read from @fd, or @fd_write does not write to @fd + * until its buffers are full, they will be called again on the next + * iteration. + * + * @fd: The file descriptor to be observed. Under Windows it must be + * a #SOCKET. + * + * @fd_read: A level-triggered callback that is fired if @fd is readable + * at the beginning of a main loop iteration, or if it becomes readable + * during one. + * + * @fd_write: A level-triggered callback that is fired when @fd is writable + * at the beginning of a main loop iteration, or if it becomes writable + * during one. + * + * @opaque: A pointer-sized value that is passed to @fd_read and @fd_write. + */ +int qemu_set_fd_handler(int fd, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque); + +#ifdef CONFIG_POSIX +/** + * qemu_add_child_watch: Register a child process for reaping. + * + * Under POSIX systems, a parent process must read the exit status of + * its child processes using waitpid, or the operating system will not + * free some of the resources attached to that process. + * + * This function directs the QEMU main loop to observe a child process + * and call waitpid as soon as it exits; the watch is then removed + * automatically. It is useful whenever QEMU forks a child process + * but will find out about its termination by other means such as a + * "broken pipe". + * + * @pid: The pid that QEMU should observe. + */ +int qemu_add_child_watch(pid_t pid); +#endif + +/** + * qemu_mutex_lock_iothread: Lock the main loop mutex. + * + * This function locks the main loop mutex. The mutex is taken by + * qemu_init_main_loop and always taken except while waiting on + * external events (such as with select). The mutex should be taken + * by threads other than the main loop thread when calling + * qemu_bh_new(), qemu_set_fd_handler() and basically all other + * functions documented in this file. + * + * NOTE: tools currently are single-threaded and qemu_mutex_lock_iothread + * is a no-op there. + */ +void qemu_mutex_lock_iothread(void); + +/** + * qemu_mutex_unlock_iothread: Unlock the main loop mutex. + * + * This function unlocks the main loop mutex. The mutex is taken by + * qemu_init_main_loop and always taken except while waiting on + * external events (such as with select). The mutex should be unlocked + * as soon as possible by threads other than the main loop thread, + * because it prevents the main loop from processing callbacks, + * including timers and bottom halves. + * + * NOTE: tools currently are single-threaded and qemu_mutex_unlock_iothread + * is a no-op there. + */ +void qemu_mutex_unlock_iothread(void); + +/* internal interfaces */ + +void qemu_fd_register(int fd); +void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds); +void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int rc); + +QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque); +void qemu_bh_schedule_idle(QEMUBH *bh); + +#endif diff --git a/include/qemu/module.h b/include/qemu/module.h new file mode 100644 index 0000000000..c4ccd57166 --- /dev/null +++ b/include/qemu/module.h @@ -0,0 +1,40 @@ +/* + * QEMU Module Infrastructure + * + * Copyright IBM, Corp. 2009 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_MODULE_H +#define QEMU_MODULE_H + +/* This should not be used directly. Use block_init etc. instead. */ +#define module_init(function, type) \ +static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \ + register_module_init(function, type); \ +} + +typedef enum { + MODULE_INIT_BLOCK, + MODULE_INIT_MACHINE, + MODULE_INIT_QAPI, + MODULE_INIT_QOM, + MODULE_INIT_MAX +} module_init_type; + +#define block_init(function) module_init(function, MODULE_INIT_BLOCK) +#define machine_init(function) module_init(function, MODULE_INIT_MACHINE) +#define qapi_init(function) module_init(function, MODULE_INIT_QAPI) +#define type_init(function) module_init(function, MODULE_INIT_QOM) + +void register_module_init(void (*fn)(void), module_init_type type); + +void module_call_init(module_init_type type); + +#endif diff --git a/include/qemu/notify.h b/include/qemu/notify.h new file mode 100644 index 0000000000..4e2e7f0ec4 --- /dev/null +++ b/include/qemu/notify.h @@ -0,0 +1,43 @@ +/* + * Notifier lists + * + * Copyright IBM, Corp. 2010 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_NOTIFY_H +#define QEMU_NOTIFY_H + +#include "qemu/queue.h" + +typedef struct Notifier Notifier; + +struct Notifier +{ + void (*notify)(Notifier *notifier, void *data); + QLIST_ENTRY(Notifier) node; +}; + +typedef struct NotifierList +{ + QLIST_HEAD(, Notifier) notifiers; +} NotifierList; + +#define NOTIFIER_LIST_INITIALIZER(head) \ + { QLIST_HEAD_INITIALIZER((head).notifiers) } + +void notifier_list_init(NotifierList *list); + +void notifier_list_add(NotifierList *list, Notifier *notifier); + +void notifier_remove(Notifier *notifier); + +void notifier_list_notify(NotifierList *list, void *data); + +#endif diff --git a/include/qemu/option.h b/include/qemu/option.h new file mode 100644 index 0000000000..ba197cddcf --- /dev/null +++ b/include/qemu/option.h @@ -0,0 +1,158 @@ +/* + * Commandline option parsing functions + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009 Kevin Wolf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OPTIONS_H +#define QEMU_OPTIONS_H + +#include +#include "qemu/queue.h" +#include "qapi/error.h" +#include "qapi/qmp/qdict.h" + +enum QEMUOptionParType { + OPT_FLAG, + OPT_NUMBER, + OPT_SIZE, + OPT_STRING, +}; + +typedef struct QEMUOptionParameter { + const char *name; + enum QEMUOptionParType type; + union { + uint64_t n; + char* s; + } value; + const char *help; +} QEMUOptionParameter; + + +const char *get_opt_name(char *buf, int buf_size, const char *p, char delim); +const char *get_opt_value(char *buf, int buf_size, const char *p); +int get_next_param_value(char *buf, int buf_size, + const char *tag, const char **pstr); +int get_param_value(char *buf, int buf_size, + const char *tag, const char *str); +int check_params(char *buf, int buf_size, + const char * const *params, const char *str); + + +/* + * The following functions take a parameter list as input. This is a pointer to + * the first element of a QEMUOptionParameter array which is terminated by an + * entry with entry->name == NULL. + */ + +QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list, + const char *name); +int set_option_parameter(QEMUOptionParameter *list, const char *name, + const char *value); +int set_option_parameter_int(QEMUOptionParameter *list, const char *name, + uint64_t value); +QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest, + QEMUOptionParameter *list); +QEMUOptionParameter *parse_option_parameters(const char *param, + QEMUOptionParameter *list, QEMUOptionParameter *dest); +void free_option_parameters(QEMUOptionParameter *list); +void print_option_parameters(QEMUOptionParameter *list); +void print_option_help(QEMUOptionParameter *list); + +/* ------------------------------------------------------------------ */ + +typedef struct QemuOpt QemuOpt; +typedef struct QemuOpts QemuOpts; +typedef struct QemuOptsList QemuOptsList; + +enum QemuOptType { + QEMU_OPT_STRING = 0, /* no parsing (use string as-is) */ + QEMU_OPT_BOOL, /* on/off */ + QEMU_OPT_NUMBER, /* simple number */ + QEMU_OPT_SIZE, /* size, accepts (K)ilo, (M)ega, (G)iga, (T)era postfix */ +}; + +typedef struct QemuOptDesc { + const char *name; + enum QemuOptType type; + const char *help; +} QemuOptDesc; + +struct QemuOptsList { + const char *name; + const char *implied_opt_name; + bool merge_lists; /* Merge multiple uses of option into a single list? */ + QTAILQ_HEAD(, QemuOpts) head; + QemuOptDesc desc[]; +}; + +const char *qemu_opt_get(QemuOpts *opts, const char *name); +/** + * qemu_opt_has_help_opt: + * @opts: options to search for a help request + * + * Check whether the options specified by @opts include one of the + * standard strings which indicate that the user is asking for a + * list of the valid values for a command line option (as defined + * by is_help_option()). + * + * Returns: true if @opts includes 'help' or equivalent. + */ +bool qemu_opt_has_help_opt(QemuOpts *opts); +bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval); +uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval); +uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval); +int qemu_opt_set(QemuOpts *opts, const char *name, const char *value); +void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value, + Error **errp); +int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val); +int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val); +typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque); +int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, + int abort_on_failure); + +QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id); +QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, + int fail_if_exists, Error **errp); +QemuOpts *qemu_opts_create_nofail(QemuOptsList *list); +void qemu_opts_reset(QemuOptsList *list); +void qemu_opts_loc_restore(QemuOpts *opts); +int qemu_opts_set(QemuOptsList *list, const char *id, + const char *name, const char *value); +const char *qemu_opts_id(QemuOpts *opts); +void qemu_opts_del(QemuOpts *opts); +void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp); +int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname); +QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev); +void qemu_opts_set_defaults(QemuOptsList *list, const char *params, + int permit_abbrev); +QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, + Error **errp); +QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict); + +typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque); +int qemu_opts_print(QemuOpts *opts, void *dummy); +int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, + int abort_on_failure); + +#endif diff --git a/include/qemu/option_int.h b/include/qemu/option_int.h new file mode 100644 index 0000000000..8212fa4a48 --- /dev/null +++ b/include/qemu/option_int.h @@ -0,0 +1,54 @@ +/* + * Commandline option parsing functions + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009 Kevin Wolf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OPTIONS_INTERNAL_H +#define QEMU_OPTIONS_INTERNAL_H + +#include "qemu/option.h" +#include "qemu/error-report.h" + +struct QemuOpt { + const char *name; + const char *str; + + const QemuOptDesc *desc; + union { + bool boolean; + uint64_t uint; + } value; + + QemuOpts *opts; + QTAILQ_ENTRY(QemuOpt) next; +}; + +struct QemuOpts { + char *id; + QemuOptsList *list; + Location loc; + QTAILQ_HEAD(QemuOptHead, QemuOpt) head; + QTAILQ_ENTRY(QemuOpts) next; +}; + +#endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h new file mode 100644 index 0000000000..87d3b9cfa8 --- /dev/null +++ b/include/qemu/osdep.h @@ -0,0 +1,178 @@ +#ifndef QEMU_OSDEP_H +#define QEMU_OSDEP_H + +#include +#include +#include +#ifdef __OpenBSD__ +#include +#include +#endif + +#include + +#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10 +/* [u]int_fast*_t not in */ +typedef unsigned char uint_fast8_t; +typedef unsigned int uint_fast16_t; +typedef signed int int_fast16_t; +#endif + +#ifndef glue +#define xglue(x, y) x ## y +#define glue(x, y) xglue(x, y) +#define stringify(s) tostring(s) +#define tostring(s) #s +#endif + +#ifndef likely +#if __GNUC__ < 3 +#define __builtin_expect(x, n) (x) +#endif + +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif + +#ifndef container_of +#define container_of(ptr, type, member) ({ \ + const typeof(((type *) 0)->member) *__mptr = (ptr); \ + (type *) ((char *) __mptr - offsetof(type, member));}) +#endif + +/* Convert from a base type to a parent type, with compile time checking. */ +#ifdef __GNUC__ +#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ + char __attribute__((unused)) offset_must_be_zero[ \ + -offsetof(type, field)]; \ + container_of(dev, type, field);})) +#else +#define DO_UPCAST(type, field, dev) container_of(dev, type, field) +#endif + +#define typeof_field(type, field) typeof(((type *)0)->field) +#define type_check(t1,t2) ((t1*)0 - (t2*)0) + +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef DIV_ROUND_UP +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif + +#ifndef always_inline +#if !((__GNUC__ < 3) || defined(__APPLE__)) +#ifdef __OPTIMIZE__ +#undef inline +#define inline __attribute__ (( always_inline )) __inline__ +#endif +#endif +#else +#undef inline +#define inline always_inline +#endif + +#define qemu_printf printf + +int qemu_daemon(int nochdir, int noclose); +void *qemu_memalign(size_t alignment, size_t size); +void *qemu_vmalloc(size_t size); +void qemu_vfree(void *ptr); + +#define QEMU_MADV_INVALID -1 + +#if defined(CONFIG_MADVISE) + +#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 +#ifdef MADV_DONTDUMP +#define QEMU_MADV_DONTDUMP MADV_DONTDUMP +#else +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#endif +#ifdef MADV_HUGEPAGE +#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE +#else +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID +#endif + +#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 +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID + +#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 +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID + +#endif + +int qemu_madvise(void *addr, size_t len, int advice); + +int qemu_open(const char *name, int flags, ...); +int qemu_close(int fd); + +#if defined(__HAIKU__) && defined(__i386__) +#define FMT_pid "%ld" +#elif defined(WIN64) +#define FMT_pid "%" PRId64 +#else +#define FMT_pid "%d" +#endif + +int qemu_create_pidfile(const char *filename); +int qemu_get_thread_id(void); + +#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 + +void qemu_set_cloexec(int fd); + +void qemu_set_version(const char *); +const char *qemu_get_version(void); + +void fips_set_state(bool requested); +bool fips_get_state(void); + +#endif diff --git a/include/qemu/queue.h b/include/qemu/queue.h new file mode 100644 index 0000000000..d433b9017c --- /dev/null +++ b/include/qemu/queue.h @@ -0,0 +1,414 @@ +/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */ + +/* + * QEMU version: Copy from netbsd, removed debug code, removed some of + * the implementations. Left in singly-linked lists, lists, simple + * queues, and tail queues. + */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef QEMU_SYS_QUEUE_H_ +#define QEMU_SYS_QUEUE_H_ + +/* + * This file defines four types of data structures: singly-linked lists, + * lists, simple queues, and tail queues. + * + * A singly-linked list is headed by a single forward pointer. The + * elements are singly linked for minimum space and pointer manipulation + * overhead at the expense of O(n) removal for arbitrary elements. New + * elements can be added to the list after an existing element or at the + * head of the list. Elements being removed from the head of the list + * should use the explicit macro for this purpose for optimum + * efficiency. A singly-linked list may only be traversed in the forward + * direction. Singly-linked lists are ideal for applications with large + * datasets and few or no removals or for implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +#include "qemu/atomic.h" /* for smp_wmb() */ + +/* + * List definitions. + */ +#define QLIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define QLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define QLIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List functions. + */ +#define QLIST_INIT(head) do { \ + (head)->lh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_AFTER(listelm, elm, field) do { \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_HEAD_RCU(head, elm, field) do { \ + (elm)->field.le_prev = &(head)->lh_first; \ + (elm)->field.le_next = (head)->lh_first; \ + smp_wmb(); /* fill elm before linking it */ \ + if ((head)->lh_first != NULL) { \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next; \ + } \ + (head)->lh_first = (elm); \ + smp_wmb(); \ +} while (/* CONSTCOND*/0) + +#define QLIST_REMOVE(elm, field) do { \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define QLIST_FOREACH(var, head, field) \ + for ((var) = ((head)->lh_first); \ + (var); \ + (var) = ((var)->field.le_next)) + +#define QLIST_FOREACH_SAFE(var, head, field, next_var) \ + for ((var) = ((head)->lh_first); \ + (var) && ((next_var) = ((var)->field.le_next), 1); \ + (var) = (next_var)) + +/* + * List access methods. + */ +#define QLIST_EMPTY(head) ((head)->lh_first == NULL) +#define QLIST_FIRST(head) ((head)->lh_first) +#define QLIST_NEXT(elm, field) ((elm)->field.le_next) + + +/* + * Singly-linked List definitions. + */ +#define QSLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define QSLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define QSLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List functions. + */ +#define QSLIST_INIT(head) do { \ + (head)->slh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define QSLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (/*CONSTCOND*/0) + +#define QSLIST_REMOVE_AFTER(slistelm, field) do { \ + (slistelm)->field.sle_next = \ + QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_FOREACH(var, head, field) \ + for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) + +#define QSLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = QSLIST_FIRST((head)); \ + (var) && ((tvar) = QSLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked List access methods. + */ +#define QSLIST_EMPTY(head) ((head)->slh_first == NULL) +#define QSLIST_FIRST(head) ((head)->slh_first) +#define QSLIST_NEXT(elm, field) ((elm)->field.sle_next) + + +/* + * Simple queue definitions. + */ +#define QSIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define QSIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define QSIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue functions. + */ +#define QSIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_REMOVE(head, elm, type, field) do { \ + if ((head)->sqh_first == (elm)) { \ + QSIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = \ + curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); \ + (var); \ + (var) = ((var)->field.sqe_next)) + +#define QSIMPLEQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->sqh_first); \ + (var) && ((next = ((var)->field.sqe_next)), 1); \ + (var) = (next)) + +#define QSIMPLEQ_CONCAT(head1, head2) do { \ + if (!QSIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + QSIMPLEQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_LAST(head, type, field) \ + (QSIMPLEQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->sqh_last) - offsetof(struct type, field)))) + +/* + * Simple queue access methods. + */ +#define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) +#define QSIMPLEQ_FIRST(head) ((head)->sqh_first) +#define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + + +/* + * Tail queue definitions. + */ +#define Q_TAILQ_HEAD(name, type, qual) \ +struct name { \ + qual type *tqh_first; /* first element */ \ + qual type *qual *tqh_last; /* addr of last next element */ \ +} +#define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,) + +#define QTAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define Q_TAILQ_ENTRY(type, qual) \ +struct { \ + qual type *tqe_next; /* next element */ \ + qual type *qual *tqe_prev; /* address of previous next element */\ +} +#define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,) + +/* + * Tail queue functions. + */ +#define QTAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_REMOVE(head, elm, field) do { \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->tqh_first); \ + (var); \ + (var) = ((var)->field.tqe_next)) + +#define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \ + for ((var) = ((head)->tqh_first); \ + (var) && ((next_var) = ((var)->field.tqe_next), 1); \ + (var) = (next_var)) + +#define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ + (var); \ + (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) + +/* + * Tail queue access methods. + */ +#define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#define QTAILQ_FIRST(head) ((head)->tqh_first) +#define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next) + +#define QTAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define QTAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + +#endif /* !QEMU_SYS_QUEUE_H_ */ diff --git a/include/qemu/range.h b/include/qemu/range.h new file mode 100644 index 0000000000..350237212b --- /dev/null +++ b/include/qemu/range.h @@ -0,0 +1,29 @@ +#ifndef QEMU_RANGE_H +#define QEMU_RANGE_H + +/* Get last byte of a range from offset + length. + * Undefined for ranges that wrap around 0. */ +static inline uint64_t range_get_last(uint64_t offset, uint64_t len) +{ + return offset + len - 1; +} + +/* Check whether a given range covers a given byte. */ +static inline int range_covers_byte(uint64_t offset, uint64_t len, + uint64_t byte) +{ + return offset <= byte && byte <= range_get_last(offset, len); +} + +/* Check whether 2 given ranges overlap. + * Undefined if ranges that wrap around 0. */ +static inline int ranges_overlap(uint64_t first1, uint64_t len1, + uint64_t first2, uint64_t len2) +{ + uint64_t last1 = range_get_last(first1, len1); + uint64_t last2 = range_get_last(first2, len2); + + return !(last2 < first1 || last1 < first2); +} + +#endif diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h new file mode 100644 index 0000000000..803ae1798c --- /dev/null +++ b/include/qemu/sockets.h @@ -0,0 +1,77 @@ +/* headers to use the BSD sockets */ +#ifndef QEMU_SOCKET_H +#define QEMU_SOCKET_H + +#ifdef _WIN32 +#include +#include +#include + +#define socket_error() WSAGetLastError() + +int inet_aton(const char *cp, struct in_addr *ia); + +#else + +#include +#include +#include +#include +#include +#include +#include + +#define socket_error() errno +#define closesocket(s) close(s) + +#endif /* !_WIN32 */ + +#include "qemu/option.h" +#include "qapi/error.h" +#include "qapi/qmp/qerror.h" + +/* misc helpers */ +int qemu_socket(int domain, int type, int protocol); +int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); +int socket_set_cork(int fd, int v); +void socket_set_block(int fd); +void socket_set_nonblock(int fd); +int send_all(int fd, const void *buf, int len1); + +/* callback function for nonblocking connect + * valid fd on success, negative error code on failure + */ +typedef void NonBlockingConnectHandler(int fd, void *opaque); + +int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp); +int inet_listen(const char *str, char *ostr, int olen, + int socktype, int port_offset, Error **errp); +int inet_connect_opts(QemuOpts *opts, Error **errp, + NonBlockingConnectHandler *callback, void *opaque); +int inet_connect(const char *str, Error **errp); +int inet_nonblocking_connect(const char *str, + NonBlockingConnectHandler *callback, + void *opaque, Error **errp); + +int inet_dgram_opts(QemuOpts *opts, Error **errp); +const char *inet_strfamily(int family); + +int unix_listen_opts(QemuOpts *opts, Error **errp); +int unix_listen(const char *path, char *ostr, int olen, Error **errp); +int unix_connect_opts(QemuOpts *opts, Error **errp, + NonBlockingConnectHandler *callback, void *opaque); +int unix_connect(const char *path, Error **errp); +int unix_nonblocking_connect(const char *str, + NonBlockingConnectHandler *callback, + void *opaque, Error **errp); + +SocketAddress *socket_parse(const char *str, Error **errp); +int socket_connect(SocketAddress *addr, Error **errp, + NonBlockingConnectHandler *callback, void *opaque); +int socket_listen(SocketAddress *addr, Error **errp); + +/* Old, ipv4 only bits. Don't use for new code. */ +int parse_host_port(struct sockaddr_in *saddr, const char *str); +int socket_init(void); + +#endif /* QEMU_SOCKET_H */ diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h new file mode 100644 index 0000000000..380bae209b --- /dev/null +++ b/include/qemu/thread-posix.h @@ -0,0 +1,28 @@ +#ifndef __QEMU_THREAD_POSIX_H +#define __QEMU_THREAD_POSIX_H 1 +#include "pthread.h" +#include + +struct QemuMutex { + pthread_mutex_t lock; +}; + +struct QemuCond { + pthread_cond_t cond; +}; + +struct QemuSemaphore { +#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) + pthread_mutex_t lock; + pthread_cond_t cond; + int count; +#else + sem_t sem; +#endif +}; + +struct QemuThread { + pthread_t thread; +}; + +#endif diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h new file mode 100644 index 0000000000..13adb958f0 --- /dev/null +++ b/include/qemu/thread-win32.h @@ -0,0 +1,29 @@ +#ifndef __QEMU_THREAD_WIN32_H +#define __QEMU_THREAD_WIN32_H 1 +#include "windows.h" + +struct QemuMutex { + CRITICAL_SECTION lock; + LONG owner; +}; + +struct QemuCond { + LONG waiters, target; + HANDLE sema; + HANDLE continue_event; +}; + +struct QemuSemaphore { + HANDLE sema; +}; + +typedef struct QemuThreadData QemuThreadData; +struct QemuThread { + QemuThreadData *data; + unsigned tid; +}; + +/* Only valid for joinable threads. */ +HANDLE qemu_thread_get_handle(QemuThread *thread); + +#endif diff --git a/include/qemu/thread.h b/include/qemu/thread.h new file mode 100644 index 0000000000..c02404b9fb --- /dev/null +++ b/include/qemu/thread.h @@ -0,0 +1,56 @@ +#ifndef __QEMU_THREAD_H +#define __QEMU_THREAD_H 1 + +#include +#include + +typedef struct QemuMutex QemuMutex; +typedef struct QemuCond QemuCond; +typedef struct QemuSemaphore QemuSemaphore; +typedef struct QemuThread QemuThread; + +#ifdef _WIN32 +#include "qemu/thread-win32.h" +#else +#include "qemu/thread-posix.h" +#endif + +#define QEMU_THREAD_JOINABLE 0 +#define QEMU_THREAD_DETACHED 1 + +void qemu_mutex_init(QemuMutex *mutex); +void qemu_mutex_destroy(QemuMutex *mutex); +void qemu_mutex_lock(QemuMutex *mutex); +int qemu_mutex_trylock(QemuMutex *mutex); +void qemu_mutex_unlock(QemuMutex *mutex); + +#define rcu_read_lock() do { } while (0) +#define rcu_read_unlock() do { } while (0) + +void qemu_cond_init(QemuCond *cond); +void qemu_cond_destroy(QemuCond *cond); + +/* + * IMPORTANT: The implementation does not guarantee that pthread_cond_signal + * and pthread_cond_broadcast can be called except while the same mutex is + * held as in the corresponding pthread_cond_wait calls! + */ +void qemu_cond_signal(QemuCond *cond); +void qemu_cond_broadcast(QemuCond *cond); +void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex); + +void qemu_sem_init(QemuSemaphore *sem, int init); +void qemu_sem_post(QemuSemaphore *sem); +void qemu_sem_wait(QemuSemaphore *sem); +int qemu_sem_timedwait(QemuSemaphore *sem, int ms); +void qemu_sem_destroy(QemuSemaphore *sem); + +void qemu_thread_create(QemuThread *thread, + void *(*start_routine)(void *), + void *arg, int mode); +void *qemu_thread_join(QemuThread *thread); +void qemu_thread_get_self(QemuThread *thread); +bool qemu_thread_is_self(QemuThread *thread); +void qemu_thread_exit(void *retval); + +#endif diff --git a/include/qemu/timer.h b/include/qemu/timer.h new file mode 100644 index 0000000000..1766b2d6c7 --- /dev/null +++ b/include/qemu/timer.h @@ -0,0 +1,310 @@ +#ifndef QEMU_TIMER_H +#define QEMU_TIMER_H + +#include "qemu-common.h" +#include "qemu/main-loop.h" +#include "qemu/notify.h" + +#ifdef __FreeBSD__ +#include +#endif + +/* timers */ + +#define SCALE_MS 1000000 +#define SCALE_US 1000 +#define SCALE_NS 1 + +typedef struct QEMUClock QEMUClock; +typedef void QEMUTimerCB(void *opaque); + +/* The real time clock should be used only for stuff which does not + change the virtual machine state, as it is run even if the virtual + machine is stopped. The real time clock has a frequency of 1000 + Hz. */ +extern QEMUClock *rt_clock; + +/* The virtual clock is only run during the emulation. It is stopped + when the virtual machine is stopped. Virtual timers use a high + precision clock, usually cpu cycles (use ticks_per_sec). */ +extern QEMUClock *vm_clock; + +/* The host clock should be use for device models that emulate accurate + real time sources. It will continue to run when the virtual machine + is suspended, and it will reflect system time changes the host may + undergo (e.g. due to NTP). The host clock has the same precision as + the virtual clock. */ +extern QEMUClock *host_clock; + +int64_t qemu_get_clock_ns(QEMUClock *clock); +int64_t qemu_clock_has_timers(QEMUClock *clock); +int64_t qemu_clock_expired(QEMUClock *clock); +int64_t qemu_clock_deadline(QEMUClock *clock); +void qemu_clock_enable(QEMUClock *clock, bool enabled); +void qemu_clock_warp(QEMUClock *clock); + +void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier); +void qemu_unregister_clock_reset_notifier(QEMUClock *clock, + Notifier *notifier); + +QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale, + QEMUTimerCB *cb, void *opaque); +void qemu_free_timer(QEMUTimer *ts); +void qemu_del_timer(QEMUTimer *ts); +void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time); +void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time); +bool qemu_timer_pending(QEMUTimer *ts); +bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); +uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts); + +void qemu_run_timers(QEMUClock *clock); +void qemu_run_all_timers(void); +void configure_alarms(char const *opt); +void init_clocks(void); +int init_timer_alarm(void); + +int64_t cpu_get_ticks(void); +void cpu_enable_ticks(void); +void cpu_disable_ticks(void); + +static inline QEMUTimer *qemu_new_timer_ns(QEMUClock *clock, QEMUTimerCB *cb, + void *opaque) +{ + return qemu_new_timer(clock, SCALE_NS, cb, opaque); +} + +static inline QEMUTimer *qemu_new_timer_ms(QEMUClock *clock, QEMUTimerCB *cb, + void *opaque) +{ + return qemu_new_timer(clock, SCALE_MS, cb, opaque); +} + +static inline int64_t qemu_get_clock_ms(QEMUClock *clock) +{ + return qemu_get_clock_ns(clock) / SCALE_MS; +} + +static inline int64_t get_ticks_per_sec(void) +{ + return 1000000000LL; +} + +/* real time host monotonic timer */ +static inline int64_t get_clock_realtime(void) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000); +} + +/* Warning: don't insert tracepoints into these functions, they are + also used by simpletrace backend and tracepoints would cause + an infinite recursion! */ +#ifdef _WIN32 +extern int64_t clock_freq; + +static inline int64_t get_clock(void) +{ + LARGE_INTEGER ti; + QueryPerformanceCounter(&ti); + return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq); +} + +#else + +extern int use_rt_clock; + +static inline int64_t get_clock(void) +{ +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ + || defined(__DragonFly__) || defined(__FreeBSD_kernel__) + if (use_rt_clock) { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec * 1000000000LL + ts.tv_nsec; + } else +#endif + { + /* XXX: using gettimeofday leads to problems if the date + changes, so it should be avoided. */ + return get_clock_realtime(); + } +} +#endif + +void qemu_get_timer(QEMUFile *f, QEMUTimer *ts); +void qemu_put_timer(QEMUFile *f, QEMUTimer *ts); + +/* icount */ +int64_t cpu_get_icount(void); +int64_t cpu_get_clock(void); + +/*******************************************/ +/* host CPU ticks (if available) */ + +#if defined(_ARCH_PPC) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t retval; +#ifdef _ARCH_PPC64 + /* This reads timebase in one 64bit go and includes Cell workaround from: + http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html + */ + __asm__ __volatile__ ("mftb %0\n\t" + "cmpwi %0,0\n\t" + "beq- $-8" + : "=r" (retval)); +#else + /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */ + unsigned long junk; + __asm__ __volatile__ ("mfspr %1,269\n\t" /* mftbu */ + "mfspr %L0,268\n\t" /* mftb */ + "mfspr %0,269\n\t" /* mftbu */ + "cmpw %0,%1\n\t" + "bne $-16" + : "=r" (retval), "=r" (junk)); +#endif + return retval; +} + +#elif defined(__i386__) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile ("rdtsc" : "=A" (val)); + return val; +} + +#elif defined(__x86_64__) + +static inline int64_t cpu_get_real_ticks(void) +{ + uint32_t low,high; + int64_t val; + asm volatile("rdtsc" : "=a" (low), "=d" (high)); + val = high; + val <<= 32; + val |= low; + return val; +} + +#elif defined(__hppa__) + +static inline int64_t cpu_get_real_ticks(void) +{ + int val; + asm volatile ("mfctl %%cr16, %0" : "=r"(val)); + return val; +} + +#elif defined(__ia64) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory"); + return val; +} + +#elif defined(__s390__) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc"); + return val; +} + +#elif defined(__sparc__) + +static inline int64_t cpu_get_real_ticks (void) +{ +#if defined(_LP64) + uint64_t rval; + asm volatile("rd %%tick,%0" : "=r"(rval)); + return rval; +#else + /* We need an %o or %g register for this. For recent enough gcc + there is an "h" constraint for that. Don't bother with that. */ + union { + uint64_t i64; + struct { + uint32_t high; + uint32_t low; + } i32; + } rval; + asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1" + : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1"); + return rval.i64; +#endif +} + +#elif defined(__mips__) && \ + ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__)) +/* + * binutils wants to use rdhwr only on mips32r2 + * but as linux kernel emulate it, it's fine + * to use it. + * + */ +#define MIPS_RDHWR(rd, value) { \ + __asm__ __volatile__ (".set push\n\t" \ + ".set mips32r2\n\t" \ + "rdhwr %0, "rd"\n\t" \ + ".set pop" \ + : "=r" (value)); \ + } + +static inline int64_t cpu_get_real_ticks(void) +{ + /* On kernels >= 2.6.25 rdhwr , $2 and $3 are emulated */ + uint32_t count; + static uint32_t cyc_per_count = 0; + + if (!cyc_per_count) { + MIPS_RDHWR("$3", cyc_per_count); + } + + MIPS_RDHWR("$2", count); + return (int64_t)(count * cyc_per_count); +} + +#elif defined(__alpha__) + +static inline int64_t cpu_get_real_ticks(void) +{ + uint64_t cc; + uint32_t cur, ofs; + + asm volatile("rpcc %0" : "=r"(cc)); + cur = cc; + ofs = cc >> 32; + return cur - ofs; +} + +#else +/* The host CPU doesn't have an easily accessible cycle counter. + Just return a monotonically increasing value. This will be + totally wrong, but hopefully better than nothing. */ +static inline int64_t cpu_get_real_ticks (void) +{ + static int64_t ticks = 0; + return ticks++; +} +#endif + +#ifdef CONFIG_PROFILER +static inline int64_t profile_getclock(void) +{ + return cpu_get_real_ticks(); +} + +extern int64_t qemu_time, qemu_time_start; +extern int64_t tlb_flush_time; +extern int64_t dev_time; +#endif + +#endif diff --git a/include/qemu/tls.h b/include/qemu/tls.h new file mode 100644 index 0000000000..b92ea9d7da --- /dev/null +++ b/include/qemu/tls.h @@ -0,0 +1,52 @@ +/* + * Abstraction layer for defining and using TLS variables + * + * Copyright (c) 2011 Red Hat, Inc + * Copyright (c) 2011 Linaro Limited + * + * Authors: + * Paolo Bonzini + * Peter Maydell + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef QEMU_TLS_H +#define QEMU_TLS_H + +/* Per-thread variables. Note that we only have implementations + * which are really thread-local on Linux; the dummy implementations + * define plain global variables. + * + * This means that for the moment use should be restricted to + * per-VCPU variables, which are OK because: + * - the only -user mode supporting multiple VCPU threads is linux-user + * - TCG system mode is single-threaded regarding VCPUs + * - KVM system mode is multi-threaded but limited to Linux + * + * TODO: proper implementations via Win32 .tls sections and + * POSIX pthread_getspecific. + */ +#ifdef __linux__ +#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) +#define DEFINE_TLS(type, x) __thread __typeof__(type) tls__##x +#define tls_var(x) tls__##x +#else +/* Dummy implementations which define plain global variables */ +#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) +#define DEFINE_TLS(type, x) __typeof__(type) tls__##x +#define tls_var(x) tls__##x +#endif + +#endif diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h new file mode 100644 index 0000000000..fd532a268d --- /dev/null +++ b/include/qemu/typedefs.h @@ -0,0 +1,61 @@ +#ifndef QEMU_TYPEDEFS_H +#define QEMU_TYPEDEFS_H + +/* A load of opaque types so that device init declarations don't have to + pull in all the real definitions. */ +typedef struct QEMUTimer QEMUTimer; +typedef struct QEMUFile QEMUFile; +typedef struct QEMUBH QEMUBH; + +struct Monitor; +typedef struct Monitor Monitor; +typedef struct MigrationParams MigrationParams; + +typedef struct Property Property; +typedef struct PropertyInfo PropertyInfo; +typedef struct CompatProperty CompatProperty; +typedef struct DeviceState DeviceState; +typedef struct BusState BusState; +typedef struct BusClass BusClass; + +typedef struct NICInfo NICInfo; +typedef struct HCIInfo HCIInfo; +typedef struct AudioState AudioState; +typedef struct BlockDriverState BlockDriverState; +typedef struct DriveInfo DriveInfo; +typedef struct DisplayState DisplayState; +typedef struct DisplayChangeListener DisplayChangeListener; +typedef struct DisplaySurface DisplaySurface; +typedef struct PixelFormat PixelFormat; +typedef struct QemuConsole QemuConsole; +typedef struct CharDriverState CharDriverState; +typedef struct MACAddr MACAddr; +typedef struct NetClientState NetClientState; +typedef struct i2c_bus i2c_bus; +typedef struct ISABus ISABus; +typedef struct ISADevice ISADevice; +typedef struct SMBusDevice SMBusDevice; +typedef struct PCIHostState PCIHostState; +typedef struct PCIExpressHost PCIExpressHost; +typedef struct PCIBus PCIBus; +typedef struct PCIDevice PCIDevice; +typedef struct PCIExpressDevice PCIExpressDevice; +typedef struct PCIBridge PCIBridge; +typedef struct PCIEAERMsg PCIEAERMsg; +typedef struct PCIEAERLog PCIEAERLog; +typedef struct PCIEAERErr PCIEAERErr; +typedef struct PCIEPort PCIEPort; +typedef struct PCIESlot PCIESlot; +typedef struct MSIMessage MSIMessage; +typedef struct SerialState SerialState; +typedef struct PCMCIACardState PCMCIACardState; +typedef struct MouseTransformInfo MouseTransformInfo; +typedef struct uWireSlave uWireSlave; +typedef struct I2SCodec I2SCodec; +typedef struct SSIBus SSIBus; +typedef struct EventNotifier EventNotifier; +typedef struct VirtIODevice VirtIODevice; +typedef struct QEMUSGList QEMUSGList; +typedef struct SHPCDevice SHPCDevice; + +#endif /* QEMU_TYPEDEFS_H */ diff --git a/include/qemu/uri.h b/include/qemu/uri.h new file mode 100644 index 0000000000..de99b3bd4b --- /dev/null +++ b/include/qemu/uri.h @@ -0,0 +1,113 @@ +/** + * Summary: library of generic URI related routines + * Description: library of generic URI related routines + * Implements RFC 2396 + * + * Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Daniel Veillard shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from him. + * + * Author: Daniel Veillard + ** + * Copyright (C) 2007 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: + * Richard W.M. Jones + * + * Utility functions to help parse and assemble query strings. + */ + +#ifndef QEMU_URI_H +#define QEMU_URI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * URI: + * + * A parsed URI reference. This is a struct containing the various fields + * as described in RFC 2396 but separated for further processing. + */ +typedef struct URI { + char *scheme; /* the URI scheme */ + char *opaque; /* opaque part */ + char *authority; /* the authority part */ + char *server; /* the server part */ + char *user; /* the user part */ + int port; /* the port number */ + char *path; /* the path string */ + char *fragment; /* the fragment identifier */ + int cleanup; /* parsing potentially unclean URI */ + char *query; /* the query string (as it appears in the URI) */ +} URI; + +URI *uri_new(void); +char *uri_resolve(const char *URI, const char *base); +char *uri_resolve_relative(const char *URI, const char *base); +URI *uri_parse(const char *str); +URI *uri_parse_raw(const char *str, int raw); +int uri_parse_into(URI *uri, const char *str); +char *uri_to_string(URI *uri); +char *uri_string_escape(const char *str, const char *list); +char *uri_string_unescape(const char *str, int len, char *target); +void uri_free(URI *uri); + +/* Single web service query parameter 'name=value'. */ +typedef struct QueryParam { + char *name; /* Name (unescaped). */ + char *value; /* Value (unescaped). */ + int ignore; /* Ignore this field in qparam_get_query */ +} QueryParam; + +/* Set of parameters. */ +typedef struct QueryParams { + int n; /* number of parameters used */ + int alloc; /* allocated space */ + QueryParam *p; /* array of parameters */ +} QueryParams; + +struct QueryParams *query_params_new (int init_alloc); +int query_param_append (QueryParams *ps, const char *name, const char *value); +extern char *query_param_to_string (const QueryParams *ps); +extern QueryParams *query_params_parse (const char *query); +extern void query_params_free (QueryParams *ps); + +#ifdef __cplusplus +} +#endif +#endif /* QEMU_URI_H */ diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h new file mode 100644 index 0000000000..f910d96eaf --- /dev/null +++ b/include/qemu/xattr.h @@ -0,0 +1,30 @@ +/* + * Host xattr.h abstraction + * + * Copyright 2011 Red Hat Inc. and/or its affiliates + * + * Authors: + * Avi Kivity + * + * This work is licensed under the terms of the GNU GPL, version 2, or any + * later version. See the COPYING file in the top-level directory. + * + */ +#ifndef QEMU_XATTR_H +#define QEMU_XATTR_H + +/* + * Modern distributions (e.g. Fedora 15, have no libattr.so, place attr.h + * in /usr/include/sys, and don't have ENOATTR. + */ + +#include "config-host.h" + +#ifdef CONFIG_LIBATTR +# include +#else +# define ENOATTR ENODATA +# include +#endif + +#endif diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9682dd59ed..9e9d044bdf 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -21,7 +21,7 @@ #define QEMU_CPU_H #include "qom/object.h" -#include "qemu-thread.h" +#include "qemu/thread.h" /** * SECTION:cpu diff --git a/include/qom/object.h b/include/qom/object.h index ed1f47f050..abe9691cb7 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -17,7 +17,7 @@ #include #include #include -#include "qemu-queue.h" +#include "qemu/queue.h" struct Visitor; struct Error; diff --git a/include/ui/console.h b/include/ui/console.h index 3db6635b0a..fc23baa06b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -3,7 +3,7 @@ #include "ui/qemu-pixman.h" #include "qapi/qmp/qdict.h" -#include "notify.h" +#include "qemu/notify.h" #include "monitor/monitor.h" #include "trace.h" #include "qapi-types.h" diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 3e08be06bf..73422adeee 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -22,8 +22,8 @@ #include -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "monitor/monitor.h" extern int using_spice; diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 928e0a1bae..a0d1a50487 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -19,7 +19,7 @@ #include #include -#include "qemu-thread.h" +#include "qemu/thread.h" #include "ui/qemu-pixman.h" #include "sysemu.h" diff --git a/int128.h b/int128.h deleted file mode 100644 index b3864b6cd4..0000000000 --- a/int128.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef INT128_H -#define INT128_H - -typedef struct Int128 Int128; - -struct Int128 { - uint64_t lo; - int64_t hi; -}; - -static inline Int128 int128_make64(uint64_t a) -{ - return (Int128) { a, 0 }; -} - -static inline uint64_t int128_get64(Int128 a) -{ - assert(!a.hi); - return a.lo; -} - -static inline Int128 int128_zero(void) -{ - return int128_make64(0); -} - -static inline Int128 int128_one(void) -{ - return int128_make64(1); -} - -static inline Int128 int128_2_64(void) -{ - return (Int128) { 0, 1 }; -} - -static inline Int128 int128_add(Int128 a, Int128 b) -{ - Int128 r = { a.lo + b.lo, a.hi + b.hi }; - r.hi += (r.lo < a.lo) || (r.lo < b.lo); - return r; -} - -static inline Int128 int128_neg(Int128 a) -{ - a.lo = ~a.lo; - a.hi = ~a.hi; - return int128_add(a, int128_one()); -} - -static inline Int128 int128_sub(Int128 a, Int128 b) -{ - return int128_add(a, int128_neg(b)); -} - -static inline bool int128_nonneg(Int128 a) -{ - return a.hi >= 0; -} - -static inline bool int128_eq(Int128 a, Int128 b) -{ - return a.lo == b.lo && a.hi == b.hi; -} - -static inline bool int128_ne(Int128 a, Int128 b) -{ - return !int128_eq(a, b); -} - -static inline bool int128_ge(Int128 a, Int128 b) -{ - return int128_nonneg(int128_sub(a, b)); -} - -static inline bool int128_lt(Int128 a, Int128 b) -{ - return !int128_ge(a, b); -} - -static inline bool int128_le(Int128 a, Int128 b) -{ - return int128_ge(b, a); -} - -static inline bool int128_gt(Int128 a, Int128 b) -{ - return !int128_le(a, b); -} - -static inline bool int128_nz(Int128 a) -{ - return a.lo || a.hi; -} - -static inline Int128 int128_min(Int128 a, Int128 b) -{ - return int128_le(a, b) ? a : b; -} - -static inline Int128 int128_max(Int128 a, Int128 b) -{ - return int128_ge(a, b) ? a : b; -} - -static inline void int128_addto(Int128 *a, Int128 b) -{ - *a = int128_add(*a, b); -} - -static inline void int128_subfrom(Int128 *a, Int128 b) -{ - *a = int128_sub(*a, b); -} - -#endif diff --git a/iohandler.c b/iohandler.c index cf8276dffc..2523adc11d 100644 --- a/iohandler.c +++ b/iohandler.c @@ -24,9 +24,9 @@ #include "config-host.h" #include "qemu-common.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/aio.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifndef _WIN32 #include diff --git a/iov.c b/iov.c index a81eedcedb..419e419969 100644 --- a/iov.c +++ b/iov.c @@ -16,7 +16,7 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "iov.h" +#include "qemu/iov.h" #ifdef _WIN32 # include diff --git a/iov.h b/iov.h deleted file mode 100644 index d06f8b9ce3..0000000000 --- a/iov.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Helpers for using (partial) iovecs. - * - * Copyright (C) 2010 Red Hat, Inc. - * - * Author(s): - * Amit Shah - * Michael Tokarev - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -#ifndef IOV_H -#define IOV_H - -#include "qemu-common.h" - -/** - * count and return data size, in bytes, of an iovec - * starting at `iov' of `iov_cnt' number of elements. - */ -size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt); - -/** - * Copy from single continuous buffer to scatter-gather vector of buffers - * (iovec) and back like memcpy() between two continuous memory regions. - * Data in single continuous buffer starting at address `buf' and - * `bytes' bytes long will be copied to/from an iovec `iov' with - * `iov_cnt' number of elements, starting at byte position `offset' - * within the iovec. If the iovec does not contain enough space, - * only part of data will be copied, up to the end of the iovec. - * Number of bytes actually copied will be returned, which is - * min(bytes, iov_size(iov)-offset) - * `Offset' must point to the inside of iovec. - * It is okay to use very large value for `bytes' since we're - * limited by the size of the iovec anyway, provided that the - * buffer pointed to by buf has enough space. One possible - * such "large" value is -1 (sinice size_t is unsigned), - * so specifying `-1' as `bytes' means 'up to the end of iovec'. - */ -size_t iov_from_buf(const struct iovec *iov, unsigned int iov_cnt, - size_t offset, const void *buf, size_t bytes); -size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, - size_t offset, void *buf, size_t bytes); - -/** - * Set data bytes pointed out by iovec `iov' of size `iov_cnt' elements, - * starting at byte offset `start', to value `fillc', repeating it - * `bytes' number of times. `Offset' must point to the inside of iovec. - * If `bytes' is large enough, only last bytes portion of iovec, - * up to the end of it, will be filled with the specified value. - * Function return actual number of bytes processed, which is - * min(size, iov_size(iov) - offset). - * Again, it is okay to use large value for `bytes' to mean "up to the end". - */ -size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, - size_t offset, int fillc, size_t bytes); - -/* - * Send/recv data from/to iovec buffers directly - * - * `offset' bytes in the beginning of iovec buffer are skipped and - * next `bytes' bytes are used, which must be within data of iovec. - * - * r = iov_send_recv(sockfd, iov, iovcnt, offset, bytes, true); - * - * is logically equivalent to - * - * char *buf = malloc(bytes); - * iov_to_buf(iov, iovcnt, offset, buf, bytes); - * r = send(sockfd, buf, bytes, 0); - * free(buf); - * - * For iov_send_recv() _whole_ area being sent or received - * should be within the iovec, not only beginning of it. - */ -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, - size_t offset, size_t bytes, bool do_send); -#define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \ - iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false) -#define iov_send(sockfd, iov, iov_cnt, offset, bytes) \ - iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, true) - -/** - * Produce a text hexdump of iovec `iov' with `iov_cnt' number of elements - * in file `fp', prefixing each line with `prefix' and processing not more - * than `limit' data bytes. - */ -void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, - FILE *fp, const char *prefix, size_t limit); - -/* - * Partial copy of vector from iov to dst_iov (data is not copied). - * dst_iov overlaps iov at a specified offset. - * size of dst_iov is at most bytes. dst vector count is returned. - */ -unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, - const struct iovec *iov, unsigned int iov_cnt, - size_t offset, size_t bytes); - -#endif diff --git a/kvm-all.c b/kvm-all.c index c2588594e1..41ea3aa6ee 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -21,18 +21,18 @@ #include #include "qemu-common.h" -#include "qemu-barrier.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/atomic.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "sysemu.h" #include "hw/hw.h" #include "hw/pci/msi.h" #include "exec/gdbstub.h" #include "kvm.h" -#include "bswap.h" +#include "qemu/bswap.h" #include "exec/memory.h" #include "exec/address-spaces.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" /* This check must be after config-host.h is included */ #ifdef CONFIG_EVENTFD diff --git a/kvm.h b/kvm.h index 72d866a966..131d2bdc15 100644 --- a/kvm.h +++ b/kvm.h @@ -16,7 +16,7 @@ #include #include "config-host.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #ifdef CONFIG_KVM #include diff --git a/libcacard/event.c b/libcacard/event.c index 61923761c9..2d7500fac0 100644 --- a/libcacard/event.c +++ b/libcacard/event.c @@ -6,7 +6,7 @@ */ #include "qemu-common.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "vcard.h" #include "vreader.h" diff --git a/libcacard/vreader.c b/libcacard/vreader.c index 96d2407e78..313349b656 100644 --- a/libcacard/vreader.c +++ b/libcacard/vreader.c @@ -6,7 +6,7 @@ */ #include "qemu-common.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "vcard.h" #include "vcard_emul.h" diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c index b64c93dd69..2fce52bed5 100644 --- a/libcacard/vscclient.c +++ b/libcacard/vscclient.c @@ -13,8 +13,8 @@ #include #include "qemu-common.h" -#include "qemu-thread.h" -#include "qemu_socket.h" +#include "qemu/thread.h" +#include "qemu/sockets.h" #include "vscard_common.h" diff --git a/libfdt_env.h b/libfdt_env.h index 90d7f3b162..7938d73fae 100644 --- a/libfdt_env.h +++ b/libfdt_env.h @@ -19,7 +19,7 @@ #ifndef _LIBFDT_ENV_H #define _LIBFDT_ENV_H -#include "bswap.h" +#include "qemu/bswap.h" #ifdef HOST_WORDS_BIGENDIAN #define fdt32_to_cpu(x) (x) diff --git a/linux-user/main.c b/linux-user/main.c index 25e35cd3dc..f6c4c8d7a3 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -28,11 +28,11 @@ #include "qemu.h" #include "qemu-common.h" -#include "cache-utils.h" +#include "qemu/cache-utils.h" #include "cpu.h" #include "tcg.h" -#include "qemu-timer.h" -#include "envlist.h" +#include "qemu/timer.h" +#include "qemu/envlist.h" #include "elf.h" #define DEBUG_LOGFILE "/tmp/qemu.log" diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 2af883bf74..8a3538c631 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -18,7 +18,7 @@ #include "syscall.h" #include "target_signal.h" #include "exec/gdbstub.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #if defined(CONFIG_USE_NPTL) #define THREAD __thread @@ -217,7 +217,7 @@ unsigned long init_guest_space(unsigned long host_start, unsigned long guest_start, bool fixed); -#include "qemu-log.h" +#include "qemu/log.h" /* syscall.c */ int host_to_target_waitstatus(int status); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 31d5276465..7c304e92de 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -72,7 +72,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #endif #ifdef CONFIG_ATTR -#include "qemu-xattr.h" +#include "qemu/xattr.h" #endif #define termios host_termios diff --git a/main-loop.c b/main-loop.c index f9006118ad..54f38ae1ae 100644 --- a/main-loop.c +++ b/main-loop.c @@ -23,14 +23,14 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "slirp/slirp.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "block/aio.h" #ifndef _WIN32 -#include "compatfd.h" +#include "qemu/compatfd.h" /* If we have signalfd, we mask out the signals we want to handle and then * use signalfd to listen for them. We rely on whatever the current signal diff --git a/main-loop.h b/main-loop.h deleted file mode 100644 index e8059c3d0a..0000000000 --- a/main-loop.h +++ /dev/null @@ -1,306 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_MAIN_LOOP_H -#define QEMU_MAIN_LOOP_H 1 - -#include "block/aio.h" - -#define SIG_IPI SIGUSR1 - -/** - * qemu_init_main_loop: Set up the process so that it can run the main loop. - * - * This includes setting up signal handlers. It should be called before - * any other threads are created. In addition, threads other than the - * main one should block signals that are trapped by the main loop. - * For simplicity, you can consider these signals to be safe: SIGUSR1, - * SIGUSR2, thread signals (SIGFPE, SIGILL, SIGSEGV, SIGBUS) and real-time - * signals if available. Remember that Windows in practice does not have - * signals, though. - * - * In the case of QEMU tools, this will also start/initialize timers. - */ -int qemu_init_main_loop(void); - -/** - * main_loop_wait: Run one iteration of the main loop. - * - * If @nonblocking is true, poll for events, otherwise suspend until - * one actually occurs. The main loop usually consists of a loop that - * repeatedly calls main_loop_wait(false). - * - * Main loop services include file descriptor callbacks, bottom halves - * and timers (defined in qemu-timer.h). Bottom halves are similar to timers - * that execute immediately, but have a lower overhead and scheduling them - * is wait-free, thread-safe and signal-safe. - * - * It is sometimes useful to put a whole program in a coroutine. In this - * case, the coroutine actually should be started from within the main loop, - * so that the main loop can run whenever the coroutine yields. To do this, - * you can use a bottom half to enter the coroutine as soon as the main loop - * starts: - * - * void enter_co_bh(void *opaque) { - * QEMUCoroutine *co = opaque; - * qemu_coroutine_enter(co, NULL); - * } - * - * ... - * QEMUCoroutine *co = qemu_coroutine_create(coroutine_entry); - * QEMUBH *start_bh = qemu_bh_new(enter_co_bh, co); - * qemu_bh_schedule(start_bh); - * while (...) { - * main_loop_wait(false); - * } - * - * (In the future we may provide a wrapper for this). - * - * @nonblocking: Whether the caller should block until an event occurs. - */ -int main_loop_wait(int nonblocking); - -/** - * qemu_notify_event: Force processing of pending events. - * - * Similar to signaling a condition variable, qemu_notify_event forces - * main_loop_wait to look at pending events and exit. The caller of - * main_loop_wait will usually call it again very soon, so qemu_notify_event - * also has the side effect of recalculating the sets of file descriptors - * that the main loop waits for. - * - * Calling qemu_notify_event is rarely necessary, because main loop - * services (bottom halves and timers) call it themselves. One notable - * exception occurs when using qemu_set_fd_handler2 (see below). - */ -void qemu_notify_event(void); - -#ifdef _WIN32 -/* return TRUE if no sleep should be done afterwards */ -typedef int PollingFunc(void *opaque); - -/** - * qemu_add_polling_cb: Register a Windows-specific polling callback - * - * Currently, under Windows some events are polled rather than waited for. - * Polling callbacks do not ensure that @func is called timely, because - * the main loop might wait for an arbitrarily long time. If possible, - * you should instead create a separate thread that does a blocking poll - * and set a Win32 event object. The event can then be passed to - * qemu_add_wait_object. - * - * Polling callbacks really have nothing Windows specific in them, but - * as they are a hack and are currently not necessary under POSIX systems, - * they are only available when QEMU is running under Windows. - * - * @func: The function that does the polling, and returns 1 to force - * immediate completion of main_loop_wait. - * @opaque: A pointer-size value that is passed to @func. - */ -int qemu_add_polling_cb(PollingFunc *func, void *opaque); - -/** - * qemu_del_polling_cb: Unregister a Windows-specific polling callback - * - * This function removes a callback that was registered with - * qemu_add_polling_cb. - * - * @func: The function that was passed to qemu_add_polling_cb. - * @opaque: A pointer-size value that was passed to qemu_add_polling_cb. - */ -void qemu_del_polling_cb(PollingFunc *func, void *opaque); - -/* Wait objects handling */ -typedef void WaitObjectFunc(void *opaque); - -/** - * qemu_add_wait_object: Register a callback for a Windows handle - * - * Under Windows, the iohandler mechanism can only be used with sockets. - * QEMU must use the WaitForMultipleObjects API to wait on other handles. - * This function registers a #HANDLE with QEMU, so that it will be included - * in the main loop's calls to WaitForMultipleObjects. When the handle - * is in a signaled state, QEMU will call @func. - * - * @handle: The Windows handle to be observed. - * @func: A function to be called when @handle is in a signaled state. - * @opaque: A pointer-size value that is passed to @func. - */ -int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); - -/** - * qemu_del_wait_object: Unregister a callback for a Windows handle - * - * This function removes a callback that was registered with - * qemu_add_wait_object. - * - * @func: The function that was passed to qemu_add_wait_object. - * @opaque: A pointer-size value that was passed to qemu_add_wait_object. - */ -void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); -#endif - -/* async I/O support */ - -typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); -typedef int IOCanReadHandler(void *opaque); - -/** - * qemu_set_fd_handler2: Register a file descriptor with the main loop - * - * This function tells the main loop to wake up whenever one of the - * following conditions is true: - * - * 1) if @fd_write is not %NULL, when the file descriptor is writable; - * - * 2) if @fd_read is not %NULL, when the file descriptor is readable. - * - * @fd_read_poll can be used to disable the @fd_read callback temporarily. - * This is useful to avoid calling qemu_set_fd_handler2 every time the - * client becomes interested in reading (or dually, stops being interested). - * A typical example is when @fd is a listening socket and you want to bound - * the number of active clients. Remember to call qemu_notify_event whenever - * the condition may change from %false to %true. - * - * The callbacks that are set up by qemu_set_fd_handler2 are level-triggered. - * If @fd_read does not read from @fd, or @fd_write does not write to @fd - * until its buffers are full, they will be called again on the next - * iteration. - * - * @fd: The file descriptor to be observed. Under Windows it must be - * a #SOCKET. - * - * @fd_read_poll: A function that returns 1 if the @fd_read callback - * should be fired. If the function returns 0, the main loop will not - * end its iteration even if @fd becomes readable. - * - * @fd_read: A level-triggered callback that is fired if @fd is readable - * at the beginning of a main loop iteration, or if it becomes readable - * during one. - * - * @fd_write: A level-triggered callback that is fired when @fd is writable - * at the beginning of a main loop iteration, or if it becomes writable - * during one. - * - * @opaque: A pointer-sized value that is passed to @fd_read_poll, - * @fd_read and @fd_write. - */ -int qemu_set_fd_handler2(int fd, - IOCanReadHandler *fd_read_poll, - IOHandler *fd_read, - IOHandler *fd_write, - void *opaque); - -/** - * qemu_set_fd_handler: Register a file descriptor with the main loop - * - * This function tells the main loop to wake up whenever one of the - * following conditions is true: - * - * 1) if @fd_write is not %NULL, when the file descriptor is writable; - * - * 2) if @fd_read is not %NULL, when the file descriptor is readable. - * - * The callbacks that are set up by qemu_set_fd_handler are level-triggered. - * If @fd_read does not read from @fd, or @fd_write does not write to @fd - * until its buffers are full, they will be called again on the next - * iteration. - * - * @fd: The file descriptor to be observed. Under Windows it must be - * a #SOCKET. - * - * @fd_read: A level-triggered callback that is fired if @fd is readable - * at the beginning of a main loop iteration, or if it becomes readable - * during one. - * - * @fd_write: A level-triggered callback that is fired when @fd is writable - * at the beginning of a main loop iteration, or if it becomes writable - * during one. - * - * @opaque: A pointer-sized value that is passed to @fd_read and @fd_write. - */ -int qemu_set_fd_handler(int fd, - IOHandler *fd_read, - IOHandler *fd_write, - void *opaque); - -#ifdef CONFIG_POSIX -/** - * qemu_add_child_watch: Register a child process for reaping. - * - * Under POSIX systems, a parent process must read the exit status of - * its child processes using waitpid, or the operating system will not - * free some of the resources attached to that process. - * - * This function directs the QEMU main loop to observe a child process - * and call waitpid as soon as it exits; the watch is then removed - * automatically. It is useful whenever QEMU forks a child process - * but will find out about its termination by other means such as a - * "broken pipe". - * - * @pid: The pid that QEMU should observe. - */ -int qemu_add_child_watch(pid_t pid); -#endif - -/** - * qemu_mutex_lock_iothread: Lock the main loop mutex. - * - * This function locks the main loop mutex. The mutex is taken by - * qemu_init_main_loop and always taken except while waiting on - * external events (such as with select). The mutex should be taken - * by threads other than the main loop thread when calling - * qemu_bh_new(), qemu_set_fd_handler() and basically all other - * functions documented in this file. - * - * NOTE: tools currently are single-threaded and qemu_mutex_lock_iothread - * is a no-op there. - */ -void qemu_mutex_lock_iothread(void); - -/** - * qemu_mutex_unlock_iothread: Unlock the main loop mutex. - * - * This function unlocks the main loop mutex. The mutex is taken by - * qemu_init_main_loop and always taken except while waiting on - * external events (such as with select). The mutex should be unlocked - * as soon as possible by threads other than the main loop thread, - * because it prevents the main loop from processing callbacks, - * including timers and bottom halves. - * - * NOTE: tools currently are single-threaded and qemu_mutex_unlock_iothread - * is a no-op there. - */ -void qemu_mutex_unlock_iothread(void); - -/* internal interfaces */ - -void qemu_fd_register(int fd); -void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds); -void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int rc); - -QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque); -void qemu_bh_schedule_idle(QEMUBH *bh); - -#endif diff --git a/memory.c b/memory.c index d40193d474..d44200335b 100644 --- a/memory.c +++ b/memory.c @@ -16,7 +16,7 @@ #include "exec/memory.h" #include "exec/address-spaces.h" #include "exec/ioport.h" -#include "bitops.h" +#include "qemu/bitops.h" #include "kvm.h" #include diff --git a/memory_mapping.h b/memory_mapping.h index d5ba46c7e7..1256125963 100644 --- a/memory_mapping.h +++ b/memory_mapping.h @@ -14,7 +14,7 @@ #ifndef MEMORY_MAPPING_H #define MEMORY_MAPPING_H -#include "qemu-queue.h" +#include "qemu/queue.h" /* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping { diff --git a/migration-exec.c b/migration-exec.c index 784486d2fc..68f36f41f1 100644 --- a/migration-exec.c +++ b/migration-exec.c @@ -16,7 +16,7 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration-fd.c b/migration-fd.c index ab5abe2aa5..ea121bc0d6 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -14,12 +14,12 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "monitor/monitor.h" #include "buffered_file.h" #include "block/block.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" //#define DEBUG_MIGRATION_FD diff --git a/migration-tcp.c b/migration-tcp.c index a36e637ffd..3c4c315052 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration-unix.c b/migration-unix.c index 9debc952da..d5f986853f 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration.c b/migration.c index 0456983bad..8c5c5670d8 100644 --- a/migration.c +++ b/migration.c @@ -19,7 +19,7 @@ #include "buffered_file.h" #include "sysemu.h" #include "block/block.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/block.h" #include "qmp-commands.h" diff --git a/module.c b/module.c index c3a6da7a86..7acc33d076 100644 --- a/module.c +++ b/module.c @@ -14,8 +14,8 @@ */ #include "qemu-common.h" -#include "qemu-queue.h" -#include "module.h" +#include "qemu/queue.h" +#include "qemu/module.h" typedef struct ModuleEntry { diff --git a/module.h b/module.h deleted file mode 100644 index c4ccd57166..0000000000 --- a/module.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * QEMU Module Infrastructure - * - * Copyright IBM, Corp. 2009 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_MODULE_H -#define QEMU_MODULE_H - -/* This should not be used directly. Use block_init etc. instead. */ -#define module_init(function, type) \ -static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \ - register_module_init(function, type); \ -} - -typedef enum { - MODULE_INIT_BLOCK, - MODULE_INIT_MACHINE, - MODULE_INIT_QAPI, - MODULE_INIT_QOM, - MODULE_INIT_MAX -} module_init_type; - -#define block_init(function) module_init(function, MODULE_INIT_BLOCK) -#define machine_init(function) module_init(function, MODULE_INIT_MACHINE) -#define qapi_init(function) module_init(function, MODULE_INIT_QAPI) -#define type_init(function) module_init(function, MODULE_INIT_QOM) - -void register_module_init(void (*fn)(void), module_init_type type); - -void module_call_init(module_init_type type); - -#endif diff --git a/monitor.c b/monitor.c index 46fdc008f4..878b2317af 100644 --- a/monitor.c +++ b/monitor.c @@ -43,10 +43,10 @@ #include "audio/audio.h" #include "disas/disas.h" #include "balloon.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "migration/migration.h" #include "kvm.h" -#include "acl.h" +#include "qemu/acl.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qfloat.h" #include "qapi/qmp/qlist.h" @@ -55,7 +55,7 @@ #include "qapi/qmp/qjson.h" #include "qapi/qmp/json-streamer.h" #include "qapi/qmp/json-parser.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "cpu.h" #include "trace.h" #include "trace/control.h" @@ -66,7 +66,7 @@ #include "exec/memory.h" #include "qmp-commands.h" #include "hmp.h" -#include "qemu-thread.h" +#include "qemu/thread.h" /* for pic/irq_info */ #if defined(TARGET_SPARC) diff --git a/nbd.c b/nbd.c index 04ff0a1d44..0698a023ad 100644 --- a/nbd.c +++ b/nbd.c @@ -36,8 +36,8 @@ #include #endif -#include "qemu_socket.h" -#include "qemu-queue.h" +#include "qemu/sockets.h" +#include "qemu/queue.h" //#define DEBUG_NBD diff --git a/net/dump.c b/net/dump.c index e0a5d74644..4119721720 100644 --- a/net/dump.c +++ b/net/dump.c @@ -24,9 +24,9 @@ #include "clients.h" #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-log.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/log.h" +#include "qemu/timer.h" #include "hub.h" typedef struct DumpState { diff --git a/net/hub.c b/net/hub.c index 81a73b54a7..5adfce444b 100644 --- a/net/hub.c +++ b/net/hub.c @@ -16,7 +16,7 @@ #include "net/net.h" #include "clients.h" #include "hub.h" -#include "iov.h" +#include "qemu/iov.h" /* * A hub broadcasts incoming packets to all its ports except the source port. diff --git a/net/net.c b/net/net.c index e4d85a9cfa..dbf3e1b003 100644 --- a/net/net.c +++ b/net/net.c @@ -31,11 +31,11 @@ #include "monitor/monitor.h" #include "qemu-common.h" -#include "qemu_socket.h" -#include "qemu-config.h" +#include "qemu/sockets.h" +#include "qemu/config-file.h" #include "qmp-commands.h" #include "hw/qdev.h" -#include "iov.h" +#include "qemu/iov.h" #include "qapi-visit.h" #include "qapi/opts-visitor.h" #include "qapi/dealloc-visitor.h" diff --git a/net/queue.c b/net/queue.c index 542c549b1a..6eaf5b63c0 100644 --- a/net/queue.c +++ b/net/queue.c @@ -22,7 +22,7 @@ */ #include "net/queue.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "net/net.h" /* The delivery handler may only return zero if it will call diff --git a/net/slirp.c b/net/slirp.c index c37a5ef959..87bdc9d031 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -33,7 +33,7 @@ #include "clients.h" #include "hub.h" #include "monitor/monitor.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "slirp/libslirp.h" #include "qemu-char.h" diff --git a/net/socket.c b/net/socket.c index bc2b951832..396dc8c0b1 100644 --- a/net/socket.c +++ b/net/socket.c @@ -27,10 +27,10 @@ #include "clients.h" #include "monitor/monitor.h" #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-option.h" -#include "qemu_socket.h" -#include "iov.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/sockets.h" +#include "qemu/iov.h" typedef struct NetSocketState { NetClientState nc; diff --git a/net/tap-bsd.c b/net/tap-bsd.c index a1c55ad3de..b48182f678 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -25,7 +25,7 @@ #include "tap_int.h" #include "qemu-common.h" #include "sysemu.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #ifdef __NetBSD__ #include diff --git a/net/tap-linux.c b/net/tap-linux.c index 3de7b3b6ce..dd4b915243 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -32,7 +32,7 @@ #include "sysemu.h" #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #define PATH_NET_TUN "/dev/net/tun" diff --git a/net/tap-solaris.c b/net/tap-solaris.c index f228fffb6d..3d5fee5542 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -38,7 +38,7 @@ #include #include #include -#include "qemu-error.h" +#include "qemu/error-report.h" ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) { diff --git a/net/tap-win32.c b/net/tap-win32.c index e37d8ee458..1ddd6fa6e6 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -32,7 +32,7 @@ #include "clients.h" /* net_init_tap */ #include "net/net.h" #include "sysemu.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include #include #include diff --git a/net/tap.c b/net/tap.c index 9a677e9864..d34ff13398 100644 --- a/net/tap.c +++ b/net/tap.c @@ -38,7 +38,7 @@ #include "monitor/monitor.h" #include "sysemu.h" #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "net/tap.h" diff --git a/net/vde.c b/net/vde.c index 52d4f19fba..754a141543 100644 --- a/net/vde.c +++ b/net/vde.c @@ -28,7 +28,7 @@ #include "net/net.h" #include "clients.h" #include "qemu-common.h" -#include "qemu-option.h" +#include "qemu/option.h" typedef struct VDEState { NetClientState nc; diff --git a/notify.c b/notify.c index 12282a6745..7b7692acb2 100644 --- a/notify.c +++ b/notify.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "notify.h" +#include "qemu/notify.h" void notifier_list_init(NotifierList *list) { diff --git a/notify.h b/notify.h deleted file mode 100644 index 03cf26c0b6..0000000000 --- a/notify.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Notifier lists - * - * Copyright IBM, Corp. 2010 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_NOTIFY_H -#define QEMU_NOTIFY_H - -#include "qemu-queue.h" - -typedef struct Notifier Notifier; - -struct Notifier -{ - void (*notify)(Notifier *notifier, void *data); - QLIST_ENTRY(Notifier) node; -}; - -typedef struct NotifierList -{ - QLIST_HEAD(, Notifier) notifiers; -} NotifierList; - -#define NOTIFIER_LIST_INITIALIZER(head) \ - { QLIST_HEAD_INITIALIZER((head).notifiers) } - -void notifier_list_init(NotifierList *list); - -void notifier_list_add(NotifierList *list, Notifier *notifier); - -void notifier_remove(Notifier *notifier); - -void notifier_list_notify(NotifierList *list, void *data); - -#endif diff --git a/osdep.c b/osdep.c index 807e90cf97..5b51a0322e 100644 --- a/osdep.c +++ b/osdep.c @@ -47,7 +47,7 @@ extern int madvise(caddr_t, size_t, int); #include "qemu-common.h" #include "trace.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "monitor/monitor.h" static bool fips_enabled = false; diff --git a/osdep.h b/osdep.h deleted file mode 100644 index 87d3b9cfa8..0000000000 --- a/osdep.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef QEMU_OSDEP_H -#define QEMU_OSDEP_H - -#include -#include -#include -#ifdef __OpenBSD__ -#include -#include -#endif - -#include - -#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10 -/* [u]int_fast*_t not in */ -typedef unsigned char uint_fast8_t; -typedef unsigned int uint_fast16_t; -typedef signed int int_fast16_t; -#endif - -#ifndef glue -#define xglue(x, y) x ## y -#define glue(x, y) xglue(x, y) -#define stringify(s) tostring(s) -#define tostring(s) #s -#endif - -#ifndef likely -#if __GNUC__ < 3 -#define __builtin_expect(x, n) (x) -#endif - -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#endif - -#ifndef container_of -#define container_of(ptr, type, member) ({ \ - const typeof(((type *) 0)->member) *__mptr = (ptr); \ - (type *) ((char *) __mptr - offsetof(type, member));}) -#endif - -/* Convert from a base type to a parent type, with compile time checking. */ -#ifdef __GNUC__ -#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ - char __attribute__((unused)) offset_must_be_zero[ \ - -offsetof(type, field)]; \ - container_of(dev, type, field);})) -#else -#define DO_UPCAST(type, field, dev) container_of(dev, type, field) -#endif - -#define typeof_field(type, field) typeof(((type *)0)->field) -#define type_check(t1,t2) ((t1*)0 - (t2*)0) - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#endif - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -#ifndef always_inline -#if !((__GNUC__ < 3) || defined(__APPLE__)) -#ifdef __OPTIMIZE__ -#undef inline -#define inline __attribute__ (( always_inline )) __inline__ -#endif -#endif -#else -#undef inline -#define inline always_inline -#endif - -#define qemu_printf printf - -int qemu_daemon(int nochdir, int noclose); -void *qemu_memalign(size_t alignment, size_t size); -void *qemu_vmalloc(size_t size); -void qemu_vfree(void *ptr); - -#define QEMU_MADV_INVALID -1 - -#if defined(CONFIG_MADVISE) - -#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 -#ifdef MADV_DONTDUMP -#define QEMU_MADV_DONTDUMP MADV_DONTDUMP -#else -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#endif -#ifdef MADV_HUGEPAGE -#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE -#else -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID -#endif - -#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 -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID - -#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 -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID - -#endif - -int qemu_madvise(void *addr, size_t len, int advice); - -int qemu_open(const char *name, int flags, ...); -int qemu_close(int fd); - -#if defined(__HAIKU__) && defined(__i386__) -#define FMT_pid "%ld" -#elif defined(WIN64) -#define FMT_pid "%" PRId64 -#else -#define FMT_pid "%d" -#endif - -int qemu_create_pidfile(const char *filename); -int qemu_get_thread_id(void); - -#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 - -void qemu_set_cloexec(int fd); - -void qemu_set_version(const char *); -const char *qemu_get_version(void); - -void fips_set_state(bool requested); -bool fips_get_state(void); - -#endif diff --git a/oslib-posix.c b/oslib-posix.c index 9db9c3d8af..a737d6e0e3 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -51,7 +51,7 @@ extern int daemon(int, int); #include "config-host.h" #include "sysemu.h" #include "trace.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #if defined(CONFIG_VALGRIND) static int running_on_valgrind = -1; diff --git a/oslib-win32.c b/oslib-win32.c index 51b33e8b20..7f0dd07e5f 100644 --- a/oslib-win32.c +++ b/oslib-win32.c @@ -28,9 +28,9 @@ #include #include "config-host.h" #include "sysemu.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "trace.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" void *qemu_oom_check(void *ptr) { diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index f8149ce455..174bd8bdb0 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -13,8 +13,8 @@ #include "qemu-common.h" #include "qapi/qmp/qerror.h" #include "qapi/opts-visitor.h" -#include "qemu-queue.h" -#include "qemu-option-internal.h" +#include "qemu/queue.h" +#include "qemu/option_int.h" #include "qapi/visitor-impl.h" diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index 98f2a58efd..1334de33cc 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -12,7 +12,7 @@ */ #include "qapi/dealloc-visitor.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/types.h" #include "qapi/visitor-impl.h" diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index 8087909036..67fb127050 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -13,7 +13,7 @@ #include "qapi/qmp-input-visitor.h" #include "qapi/visitor-impl.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/types.h" #include "qapi/qmp/qerror.h" diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 8015e3f88d..74a5684ed3 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -13,7 +13,7 @@ #include "qapi/qmp-output-visitor.h" #include "qapi/visitor-impl.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/types.h" #include "qapi/qmp/qerror.h" diff --git a/qdict.c b/qdict.c index fa7a62cff4..7543ccc10f 100644 --- a/qdict.c +++ b/qdict.c @@ -16,7 +16,7 @@ #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qobject.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" static void qdict_destroy_obj(QObject *obj); diff --git a/qemu-barrier.h b/qemu-barrier.h deleted file mode 100644 index faa83d265e..0000000000 --- a/qemu-barrier.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __QEMU_BARRIER_H -#define __QEMU_BARRIER_H 1 - -/* Compiler barrier */ -#define barrier() asm volatile("" ::: "memory") - -#if defined(__i386__) - -#include "compiler.h" /* QEMU_GNUC_PREREQ */ - -/* - * Because of the strongly ordered x86 storage model, wmb() and rmb() are nops - * on x86(well, a compiler barrier only). Well, at least as long as - * qemu doesn't do accesses to write-combining memory or non-temporal - * load/stores from C code. - */ -#define smp_wmb() barrier() -#define smp_rmb() barrier() -/* - * We use GCC builtin if it's available, as that can use - * mfence on 32 bit as well, e.g. if built with -march=pentium-m. - * However, on i386, there seem to be known bugs as recently as 4.3. - * */ -#if QEMU_GNUC_PREREQ(4, 4) -#define smp_mb() __sync_synchronize() -#else -#define smp_mb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory") -#endif - -#elif defined(__x86_64__) - -#define smp_wmb() barrier() -#define smp_rmb() barrier() -#define smp_mb() asm volatile("mfence" ::: "memory") - -#elif defined(_ARCH_PPC) - -/* - * We use an eieio() for wmb() on powerpc. This assumes we don't - * need to order cacheable and non-cacheable stores with respect to - * each other - */ -#define smp_wmb() asm volatile("eieio" ::: "memory") - -#if defined(__powerpc64__) -#define smp_rmb() asm volatile("lwsync" ::: "memory") -#else -#define smp_rmb() asm volatile("sync" ::: "memory") -#endif - -#define smp_mb() asm volatile("sync" ::: "memory") - -#else - -/* - * For (host) platforms we don't have explicit barrier definitions - * for, we use the gcc __sync_synchronize() primitive to generate a - * full barrier. This should be safe on all platforms, though it may - * be overkill for wmb() and rmb(). - */ -#define smp_wmb() __sync_synchronize() -#define smp_mb() __sync_synchronize() -#define smp_rmb() __sync_synchronize() - -#endif - -#endif diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c index 652eec99fd..287bfd5e38 100644 --- a/qemu-bridge-helper.c +++ b/qemu-bridge-helper.c @@ -39,7 +39,7 @@ #include #endif -#include "qemu-queue.h" +#include "qemu/queue.h" #include "net/tap-linux.h" diff --git a/qemu-char.c b/qemu-char.c index 16021c5a43..5a8d8f75a4 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -25,7 +25,7 @@ #include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" #include "hw/usb.h" #include "hw/baum.h" @@ -94,7 +94,7 @@ #endif #endif -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "ui/qemu-spice.h" #define READ_BUF_LEN 4096 diff --git a/qemu-char.h b/qemu-char.h index 5ff1b2ba91..baa5d035fd 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -2,13 +2,13 @@ #define QEMU_CHAR_H #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/queue.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "block/aio.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /* character device */ diff --git a/qemu-common.h b/qemu-common.h index e67478607b..40cd198fc1 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -12,9 +12,9 @@ #ifndef QEMU_COMMON_H #define QEMU_COMMON_H -#include "compiler.h" +#include "qemu/compiler.h" #include "config-host.h" -#include "qemu-types.h" +#include "qemu/typedefs.h" #if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__) #define WORDS_ALIGNED @@ -122,8 +122,8 @@ extern int use_icount; /* FIXME: Remove NEED_CPU_H. */ #ifndef NEED_CPU_H -#include "osdep.h" -#include "bswap.h" +#include "qemu/osdep.h" +#include "qemu/bswap.h" #else @@ -408,7 +408,7 @@ static inline bool is_power_of_2(uint64_t value) /* round down to the nearest power of 2*/ int64_t pow2floor(int64_t value); -#include "module.h" +#include "qemu/module.h" /* * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128) diff --git a/qemu-config.c b/qemu-config.c index ceec6bd155..2188c3e5ec 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -1,7 +1,7 @@ #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "hw/qdev.h" #include "qapi/error.h" diff --git a/qemu-config.h b/qemu-config.h deleted file mode 100644 index 584491a29b..0000000000 --- a/qemu-config.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QEMU_CONFIG_H -#define QEMU_CONFIG_H - -#include -#include "qemu-option.h" -#include "qapi/error.h" -#include "qemu-option.h" - -extern QemuOptsList qemu_fsdev_opts; -extern QemuOptsList qemu_virtfs_opts; -extern QemuOptsList qemu_spice_opts; -extern QemuOptsList qemu_sandbox_opts; - -QemuOptsList *qemu_find_opts(const char *group); -QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); -void qemu_add_opts(QemuOptsList *list); -int qemu_set_option(const char *str); -int qemu_global_option(const char *str); -void qemu_add_globals(void); - -void qemu_config_write(FILE *fp); -int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname); - -int qemu_read_config_file(const char *filename); - -/* Read default QEMU config files - */ -int qemu_read_default_config_files(bool userconfig); - -#endif /* QEMU_CONFIG_H */ diff --git a/qemu-coroutine-io.c b/qemu-coroutine-io.c index 5fae9c7d47..e8ad1a4011 100644 --- a/qemu-coroutine-io.c +++ b/qemu-coroutine-io.c @@ -23,9 +23,9 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "block/coroutine.h" -#include "iov.h" +#include "qemu/iov.h" ssize_t coroutine_fn qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt, diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c index c3939ac6ef..97ef01c796 100644 --- a/qemu-coroutine-lock.c +++ b/qemu-coroutine-lock.c @@ -25,7 +25,7 @@ #include "qemu-common.h" #include "block/coroutine.h" #include "block/coroutine_int.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/aio.h" #include "trace.h" diff --git a/qemu-coroutine-sleep.c b/qemu-coroutine-sleep.c index 26e6dac2eb..169ce5ccc9 100644 --- a/qemu-coroutine-sleep.c +++ b/qemu-coroutine-sleep.c @@ -12,7 +12,7 @@ */ #include "block/coroutine.h" -#include "qemu-timer.h" +#include "qemu/timer.h" typedef struct CoSleepCB { QEMUTimer *ts; diff --git a/qemu-error.h b/qemu-error.h deleted file mode 100644 index c902cc10de..0000000000 --- a/qemu-error.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Error reporting - * - * Copyright (C) 2010 Red Hat Inc. - * - * Authors: - * Markus Armbruster , - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef QEMU_ERROR_H -#define QEMU_ERROR_H - -#include - -typedef struct Location { - /* all members are private to qemu-error.c */ - enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind; - int num; - const void *ptr; - struct Location *prev; -} Location; - -Location *loc_push_restore(Location *loc); -Location *loc_push_none(Location *loc); -Location *loc_pop(Location *loc); -Location *loc_save(Location *loc); -void loc_restore(Location *loc); -void loc_set_none(void); -void loc_set_cmdline(char **argv, int idx, int cnt); -void loc_set_file(const char *fname, int lno); - -void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); -void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -void error_print_loc(void); -void error_set_progname(const char *argv0); -void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -const char *error_get_progname(void); - -#endif diff --git a/qemu-img.c b/qemu-img.c index 2e5ca5c964..4c8e2f3849 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -25,9 +25,9 @@ #include "qapi/qmp-output-visitor.h" #include "qapi/qmp/qjson.h" #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-error.h" -#include "osdep.h" +#include "qemu/option.h" +#include "qemu/error-report.h" +#include "qemu/osdep.h" #include "sysemu.h" #include "block/block_int.h" #include diff --git a/qemu-io.c b/qemu-io.c index e0e47423d7..61880932b3 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -15,7 +15,7 @@ #include #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "block/block_int.h" #include "cmd.h" #include "trace/control.h" diff --git a/qemu-log.c b/qemu-log.c index a4c3d1f2e3..b655b305ea 100644 --- a/qemu-log.c +++ b/qemu-log.c @@ -18,7 +18,7 @@ */ #include "qemu-common.h" -#include "qemu-log.h" +#include "qemu/log.h" #ifdef WIN32 static const char *logfilename = "qemu.log"; diff --git a/qemu-log.h b/qemu-log.h deleted file mode 100644 index 58f69cb494..0000000000 --- a/qemu-log.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef QEMU_LOG_H -#define QEMU_LOG_H - -#include -#ifdef NEED_CPU_H -#include "disas/disas.h" -#endif - -/* Private global variables, don't use */ -extern FILE *qemu_logfile; -extern int qemu_loglevel; - -/* - * The new API: - * - */ - -/* Log settings checking macros: */ - -/* Returns true if qemu_log() will really write somewhere - */ -static inline bool qemu_log_enabled(void) -{ - return qemu_logfile != NULL; -} - -#define CPU_LOG_TB_OUT_ASM (1 << 0) -#define CPU_LOG_TB_IN_ASM (1 << 1) -#define CPU_LOG_TB_OP (1 << 2) -#define CPU_LOG_TB_OP_OPT (1 << 3) -#define CPU_LOG_INT (1 << 4) -#define CPU_LOG_EXEC (1 << 5) -#define CPU_LOG_PCALL (1 << 6) -#define CPU_LOG_IOPORT (1 << 7) -#define CPU_LOG_TB_CPU (1 << 8) -#define CPU_LOG_RESET (1 << 9) -#define LOG_UNIMP (1 << 10) -#define LOG_GUEST_ERROR (1 << 11) - -/* Returns true if a bit is set in the current loglevel mask - */ -static inline bool qemu_loglevel_mask(int mask) -{ - return (qemu_loglevel & mask) != 0; -} - -/* Logging functions: */ - -/* main logging function - */ -void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...); - -/* vfprintf-like logging function - */ -static inline void GCC_FMT_ATTR(1, 0) -qemu_log_vprintf(const char *fmt, va_list va) -{ - if (qemu_logfile) { - vfprintf(qemu_logfile, fmt, va); - } -} - -/* log only if a bit is set on the current loglevel mask - */ -void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...); - - -/* Special cases: */ - -#ifdef NEED_CPU_H -/* cpu_dump_state() logging functions: */ -static inline void log_cpu_state(CPUArchState *env1, int flags) -{ - if (qemu_log_enabled()) { - cpu_dump_state(env1, qemu_logfile, fprintf, flags); - } -} - -static inline void log_cpu_state_mask(int mask, CPUArchState *env1, int flags) -{ - if (qemu_loglevel & mask) { - log_cpu_state(env1, flags); - } -} - -/* disas() and target_disas() to qemu_logfile: */ -static inline void log_target_disas(CPUArchState *env, target_ulong start, - target_ulong len, int flags) -{ - target_disas(qemu_logfile, env, start, len, flags); -} - -static inline void log_disas(void *code, unsigned long size) -{ - disas(qemu_logfile, code, size); -} - -#if defined(CONFIG_USER_ONLY) -/* page_dump() output to the log file: */ -static inline void log_page_dump(void) -{ - page_dump(qemu_logfile); -} -#endif -#endif - - -/* Maintenance: */ - -/* fflush() the log file */ -static inline void qemu_log_flush(void) -{ - fflush(qemu_logfile); -} - -/* Close the log file */ -static inline void qemu_log_close(void) -{ - fclose(qemu_logfile); - qemu_logfile = NULL; -} - -/* Set up a new log file */ -static inline void qemu_log_set_file(FILE *f) -{ - qemu_logfile = f; -} - -/* Set up a new log file, only if none is set */ -static inline void qemu_log_try_set_file(FILE *f) -{ - if (!qemu_logfile) { - qemu_logfile = f; - } -} - -/* define log items */ -typedef struct CPULogItem { - int mask; - const char *name; - const char *help; -} CPULogItem; - -extern const CPULogItem cpu_log_items[]; - -void qemu_set_log(int log_flags, bool use_own_buffers); - -static inline void cpu_set_log(int log_flags) -{ -#ifdef CONFIG_USER_ONLY - qemu_set_log(log_flags, true); -#else - qemu_set_log(log_flags, false); -#endif -} - -void cpu_set_log_filename(const char *filename); -int cpu_str_to_log_mask(const char *str); - -#endif diff --git a/qemu-option-internal.h b/qemu-option-internal.h deleted file mode 100644 index 77899b082d..0000000000 --- a/qemu-option-internal.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Commandline option parsing functions - * - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2009 Kevin Wolf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_OPTIONS_INTERNAL_H -#define QEMU_OPTIONS_INTERNAL_H - -#include "qemu-option.h" -#include "qemu-error.h" - -struct QemuOpt { - const char *name; - const char *str; - - const QemuOptDesc *desc; - union { - bool boolean; - uint64_t uint; - } value; - - QemuOpts *opts; - QTAILQ_ENTRY(QemuOpt) next; -}; - -struct QemuOpts { - char *id; - QemuOptsList *list; - Location loc; - QTAILQ_HEAD(QemuOptHead, QemuOpt) head; - QTAILQ_ENTRY(QemuOpts) next; -}; - -#endif diff --git a/qemu-option.c b/qemu-option.c index ebd3537063..f532b765a0 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -27,11 +27,11 @@ #include #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qapi/qmp/types.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" -#include "qemu-option-internal.h" +#include "qemu/option_int.h" /* * Extracts the name of an option from the parameter string (p points at the diff --git a/qemu-option.h b/qemu-option.h deleted file mode 100644 index ca0dc041dd..0000000000 --- a/qemu-option.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Commandline option parsing functions - * - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2009 Kevin Wolf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_OPTIONS_H -#define QEMU_OPTIONS_H - -#include -#include "qemu-queue.h" -#include "qapi/error.h" -#include "qapi/qmp/qdict.h" - -enum QEMUOptionParType { - OPT_FLAG, - OPT_NUMBER, - OPT_SIZE, - OPT_STRING, -}; - -typedef struct QEMUOptionParameter { - const char *name; - enum QEMUOptionParType type; - union { - uint64_t n; - char* s; - } value; - const char *help; -} QEMUOptionParameter; - - -const char *get_opt_name(char *buf, int buf_size, const char *p, char delim); -const char *get_opt_value(char *buf, int buf_size, const char *p); -int get_next_param_value(char *buf, int buf_size, - const char *tag, const char **pstr); -int get_param_value(char *buf, int buf_size, - const char *tag, const char *str); -int check_params(char *buf, int buf_size, - const char * const *params, const char *str); - - -/* - * The following functions take a parameter list as input. This is a pointer to - * the first element of a QEMUOptionParameter array which is terminated by an - * entry with entry->name == NULL. - */ - -QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list, - const char *name); -int set_option_parameter(QEMUOptionParameter *list, const char *name, - const char *value); -int set_option_parameter_int(QEMUOptionParameter *list, const char *name, - uint64_t value); -QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest, - QEMUOptionParameter *list); -QEMUOptionParameter *parse_option_parameters(const char *param, - QEMUOptionParameter *list, QEMUOptionParameter *dest); -void free_option_parameters(QEMUOptionParameter *list); -void print_option_parameters(QEMUOptionParameter *list); -void print_option_help(QEMUOptionParameter *list); - -/* ------------------------------------------------------------------ */ - -typedef struct QemuOpt QemuOpt; -typedef struct QemuOpts QemuOpts; -typedef struct QemuOptsList QemuOptsList; - -enum QemuOptType { - QEMU_OPT_STRING = 0, /* no parsing (use string as-is) */ - QEMU_OPT_BOOL, /* on/off */ - QEMU_OPT_NUMBER, /* simple number */ - QEMU_OPT_SIZE, /* size, accepts (K)ilo, (M)ega, (G)iga, (T)era postfix */ -}; - -typedef struct QemuOptDesc { - const char *name; - enum QemuOptType type; - const char *help; -} QemuOptDesc; - -struct QemuOptsList { - const char *name; - const char *implied_opt_name; - bool merge_lists; /* Merge multiple uses of option into a single list? */ - QTAILQ_HEAD(, QemuOpts) head; - QemuOptDesc desc[]; -}; - -const char *qemu_opt_get(QemuOpts *opts, const char *name); -/** - * qemu_opt_has_help_opt: - * @opts: options to search for a help request - * - * Check whether the options specified by @opts include one of the - * standard strings which indicate that the user is asking for a - * list of the valid values for a command line option (as defined - * by is_help_option()). - * - * Returns: true if @opts includes 'help' or equivalent. - */ -bool qemu_opt_has_help_opt(QemuOpts *opts); -bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval); -uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval); -uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval); -int qemu_opt_set(QemuOpts *opts, const char *name, const char *value); -void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value, - Error **errp); -int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val); -int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val); -typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque); -int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, - int abort_on_failure); - -QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id); -QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, - int fail_if_exists, Error **errp); -QemuOpts *qemu_opts_create_nofail(QemuOptsList *list); -void qemu_opts_reset(QemuOptsList *list); -void qemu_opts_loc_restore(QemuOpts *opts); -int qemu_opts_set(QemuOptsList *list, const char *id, - const char *name, const char *value); -const char *qemu_opts_id(QemuOpts *opts); -void qemu_opts_del(QemuOpts *opts); -void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp); -int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname); -QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev); -void qemu_opts_set_defaults(QemuOptsList *list, const char *params, - int permit_abbrev); -QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, - Error **errp); -QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict); - -typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque); -int qemu_opts_print(QemuOpts *opts, void *dummy); -int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, - int abort_on_failure); - -#endif diff --git a/qemu-progress.c b/qemu-progress.c index 5f1b8dfb97..08d67949a1 100644 --- a/qemu-progress.c +++ b/qemu-progress.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "sysemu.h" #include diff --git a/qemu-queue.h b/qemu-queue.h deleted file mode 100644 index 9288cd8e82..0000000000 --- a/qemu-queue.h +++ /dev/null @@ -1,414 +0,0 @@ -/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */ - -/* - * QEMU version: Copy from netbsd, removed debug code, removed some of - * the implementations. Left in singly-linked lists, lists, simple - * queues, and tail queues. - */ - -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 - */ - -#ifndef QEMU_SYS_QUEUE_H_ -#define QEMU_SYS_QUEUE_H_ - -/* - * This file defines four types of data structures: singly-linked lists, - * lists, simple queues, and tail queues. - * - * A singly-linked list is headed by a single forward pointer. The - * elements are singly linked for minimum space and pointer manipulation - * overhead at the expense of O(n) removal for arbitrary elements. New - * elements can be added to the list after an existing element or at the - * head of the list. Elements being removed from the head of the list - * should use the explicit macro for this purpose for optimum - * efficiency. A singly-linked list may only be traversed in the forward - * direction. Singly-linked lists are ideal for applications with large - * datasets and few or no removals or for implementing a LIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. - * - * A simple queue is headed by a pair of pointers, one the head of the - * list and the other to the tail of the list. The elements are singly - * linked to save space, so elements can only be removed from the - * head of the list. New elements can be added to the list after - * an existing element, at the head of the list, or at the end of the - * list. A simple queue may only be traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * For details on the use of these macros, see the queue(3) manual page. - */ - -#include "qemu-barrier.h" /* for smp_wmb() */ - -/* - * List definitions. - */ -#define QLIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define QLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define QLIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List functions. - */ -#define QLIST_INIT(head) do { \ - (head)->lh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_AFTER(listelm, elm, field) do { \ - if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ - (listelm)->field.le_next->field.le_prev = \ - &(elm)->field.le_next; \ - (listelm)->field.le_next = (elm); \ - (elm)->field.le_prev = &(listelm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - (elm)->field.le_next = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &(elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.le_next = (head)->lh_first) != NULL) \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ - (head)->lh_first = (elm); \ - (elm)->field.le_prev = &(head)->lh_first; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_HEAD_RCU(head, elm, field) do { \ - (elm)->field.le_prev = &(head)->lh_first; \ - (elm)->field.le_next = (head)->lh_first; \ - smp_wmb(); /* fill elm before linking it */ \ - if ((head)->lh_first != NULL) { \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next; \ - } \ - (head)->lh_first = (elm); \ - smp_wmb(); \ -} while (/* CONSTCOND*/0) - -#define QLIST_REMOVE(elm, field) do { \ - if ((elm)->field.le_next != NULL) \ - (elm)->field.le_next->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define QLIST_FOREACH(var, head, field) \ - for ((var) = ((head)->lh_first); \ - (var); \ - (var) = ((var)->field.le_next)) - -#define QLIST_FOREACH_SAFE(var, head, field, next_var) \ - for ((var) = ((head)->lh_first); \ - (var) && ((next_var) = ((var)->field.le_next), 1); \ - (var) = (next_var)) - -/* - * List access methods. - */ -#define QLIST_EMPTY(head) ((head)->lh_first == NULL) -#define QLIST_FIRST(head) ((head)->lh_first) -#define QLIST_NEXT(elm, field) ((elm)->field.le_next) - - -/* - * Singly-linked List definitions. - */ -#define QSLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define QSLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define QSLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List functions. - */ -#define QSLIST_INIT(head) do { \ - (head)->slh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define QSLIST_INSERT_AFTER(slistelm, elm, field) do { \ - (elm)->field.sle_next = (slistelm)->field.sle_next; \ - (slistelm)->field.sle_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSLIST_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.sle_next = (head)->slh_first; \ - (head)->slh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSLIST_REMOVE_HEAD(head, field) do { \ - (head)->slh_first = (head)->slh_first->field.sle_next; \ -} while (/*CONSTCOND*/0) - -#define QSLIST_REMOVE_AFTER(slistelm, field) do { \ - (slistelm)->field.sle_next = \ - QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \ -} while (/*CONSTCOND*/0) - -#define QSLIST_FOREACH(var, head, field) \ - for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) - -#define QSLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = QSLIST_FIRST((head)); \ - (var) && ((tvar) = QSLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -/* - * Singly-linked List access methods. - */ -#define QSLIST_EMPTY(head) ((head)->slh_first == NULL) -#define QSLIST_FIRST(head) ((head)->slh_first) -#define QSLIST_NEXT(elm, field) ((elm)->field.sle_next) - - -/* - * Simple queue definitions. - */ -#define QSIMPLEQ_HEAD(name, type) \ -struct name { \ - struct type *sqh_first; /* first element */ \ - struct type **sqh_last; /* addr of last next element */ \ -} - -#define QSIMPLEQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).sqh_first } - -#define QSIMPLEQ_ENTRY(type) \ -struct { \ - struct type *sqe_next; /* next element */ \ -} - -/* - * Simple queue functions. - */ -#define QSIMPLEQ_INIT(head) do { \ - (head)->sqh_first = NULL; \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (head)->sqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.sqe_next = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (listelm)->field.sqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_REMOVE_HEAD(head, field) do { \ - if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_REMOVE(head, elm, type, field) do { \ - if ((head)->sqh_first == (elm)) { \ - QSIMPLEQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->sqh_first; \ - while (curelm->field.sqe_next != (elm)) \ - curelm = curelm->field.sqe_next; \ - if ((curelm->field.sqe_next = \ - curelm->field.sqe_next->field.sqe_next) == NULL) \ - (head)->sqh_last = &(curelm)->field.sqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->sqh_first); \ - (var); \ - (var) = ((var)->field.sqe_next)) - -#define QSIMPLEQ_FOREACH_SAFE(var, head, field, next) \ - for ((var) = ((head)->sqh_first); \ - (var) && ((next = ((var)->field.sqe_next)), 1); \ - (var) = (next)) - -#define QSIMPLEQ_CONCAT(head1, head2) do { \ - if (!QSIMPLEQ_EMPTY((head2))) { \ - *(head1)->sqh_last = (head2)->sqh_first; \ - (head1)->sqh_last = (head2)->sqh_last; \ - QSIMPLEQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_LAST(head, type, field) \ - (QSIMPLEQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->sqh_last) - offsetof(struct type, field)))) - -/* - * Simple queue access methods. - */ -#define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) -#define QSIMPLEQ_FIRST(head) ((head)->sqh_first) -#define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) - - -/* - * Tail queue definitions. - */ -#define Q_TAILQ_HEAD(name, type, qual) \ -struct name { \ - qual type *tqh_first; /* first element */ \ - qual type *qual *tqh_last; /* addr of last next element */ \ -} -#define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,) - -#define QTAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } - -#define Q_TAILQ_ENTRY(type, qual) \ -struct { \ - qual type *tqe_next; /* next element */ \ - qual type *qual *tqe_prev; /* address of previous next element */\ -} -#define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,) - -/* - * Tail queue functions. - */ -#define QTAILQ_INIT(head) do { \ - (head)->tqh_first = NULL; \ - (head)->tqh_last = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.tqe_next = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_REMOVE(head, elm, field) do { \ - if (((elm)->field.tqe_next) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->tqh_first); \ - (var); \ - (var) = ((var)->field.tqe_next)) - -#define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \ - for ((var) = ((head)->tqh_first); \ - (var) && ((next_var) = ((var)->field.tqe_next), 1); \ - (var) = (next_var)) - -#define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ - (var); \ - (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) - -/* - * Tail queue access methods. - */ -#define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL) -#define QTAILQ_FIRST(head) ((head)->tqh_first) -#define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define QTAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) -#define QTAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - -#endif /* !QEMU_SYS_QUEUE_H_ */ diff --git a/qemu-seccomp.h b/qemu-seccomp.h index b2fc3f8c3c..1189fa241d 100644 --- a/qemu-seccomp.h +++ b/qemu-seccomp.h @@ -16,7 +16,7 @@ #define QEMU_SECCOMP_H #include -#include "osdep.h" +#include "qemu/osdep.h" int seccomp_start(void); #endif diff --git a/qemu-sockets.c b/qemu-sockets.c index cea0a4b8ac..3537bf3d45 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -23,9 +23,9 @@ #include #include "monitor/monitor.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "qemu-common.h" /* for qemu_isdigit */ -#include "main-loop.h" +#include "qemu/main-loop.h" #ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0 diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c index 4ef9c7b3f8..7be292ed68 100644 --- a/qemu-thread-posix.c +++ b/qemu-thread-posix.c @@ -20,7 +20,7 @@ #include #include #include -#include "qemu-thread.h" +#include "qemu/thread.h" static void error_exit(int err, const char *msg) { diff --git a/qemu-thread-posix.h b/qemu-thread-posix.h deleted file mode 100644 index 380bae209b..0000000000 --- a/qemu-thread-posix.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __QEMU_THREAD_POSIX_H -#define __QEMU_THREAD_POSIX_H 1 -#include "pthread.h" -#include - -struct QemuMutex { - pthread_mutex_t lock; -}; - -struct QemuCond { - pthread_cond_t cond; -}; - -struct QemuSemaphore { -#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) - pthread_mutex_t lock; - pthread_cond_t cond; - int count; -#else - sem_t sem; -#endif -}; - -struct QemuThread { - pthread_t thread; -}; - -#endif diff --git a/qemu-thread-win32.c b/qemu-thread-win32.c index 4b3db60f5c..8037b39045 100644 --- a/qemu-thread-win32.c +++ b/qemu-thread-win32.c @@ -11,7 +11,7 @@ * */ #include "qemu-common.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include #include #include diff --git a/qemu-thread-win32.h b/qemu-thread-win32.h deleted file mode 100644 index 13adb958f0..0000000000 --- a/qemu-thread-win32.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __QEMU_THREAD_WIN32_H -#define __QEMU_THREAD_WIN32_H 1 -#include "windows.h" - -struct QemuMutex { - CRITICAL_SECTION lock; - LONG owner; -}; - -struct QemuCond { - LONG waiters, target; - HANDLE sema; - HANDLE continue_event; -}; - -struct QemuSemaphore { - HANDLE sema; -}; - -typedef struct QemuThreadData QemuThreadData; -struct QemuThread { - QemuThreadData *data; - unsigned tid; -}; - -/* Only valid for joinable threads. */ -HANDLE qemu_thread_get_handle(QemuThread *thread); - -#endif diff --git a/qemu-thread.h b/qemu-thread.h deleted file mode 100644 index 3ee2f6b1f9..0000000000 --- a/qemu-thread.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __QEMU_THREAD_H -#define __QEMU_THREAD_H 1 - -#include -#include - -typedef struct QemuMutex QemuMutex; -typedef struct QemuCond QemuCond; -typedef struct QemuSemaphore QemuSemaphore; -typedef struct QemuThread QemuThread; - -#ifdef _WIN32 -#include "qemu-thread-win32.h" -#else -#include "qemu-thread-posix.h" -#endif - -#define QEMU_THREAD_JOINABLE 0 -#define QEMU_THREAD_DETACHED 1 - -void qemu_mutex_init(QemuMutex *mutex); -void qemu_mutex_destroy(QemuMutex *mutex); -void qemu_mutex_lock(QemuMutex *mutex); -int qemu_mutex_trylock(QemuMutex *mutex); -void qemu_mutex_unlock(QemuMutex *mutex); - -#define rcu_read_lock() do { } while (0) -#define rcu_read_unlock() do { } while (0) - -void qemu_cond_init(QemuCond *cond); -void qemu_cond_destroy(QemuCond *cond); - -/* - * IMPORTANT: The implementation does not guarantee that pthread_cond_signal - * and pthread_cond_broadcast can be called except while the same mutex is - * held as in the corresponding pthread_cond_wait calls! - */ -void qemu_cond_signal(QemuCond *cond); -void qemu_cond_broadcast(QemuCond *cond); -void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex); - -void qemu_sem_init(QemuSemaphore *sem, int init); -void qemu_sem_post(QemuSemaphore *sem); -void qemu_sem_wait(QemuSemaphore *sem); -int qemu_sem_timedwait(QemuSemaphore *sem, int ms); -void qemu_sem_destroy(QemuSemaphore *sem); - -void qemu_thread_create(QemuThread *thread, - void *(*start_routine)(void *), - void *arg, int mode); -void *qemu_thread_join(QemuThread *thread); -void qemu_thread_get_self(QemuThread *thread); -bool qemu_thread_is_self(QemuThread *thread); -void qemu_thread_exit(void *retval); - -#endif diff --git a/qemu-timer-common.c b/qemu-timer-common.c index 755e300bc9..16f5e758b2 100644 --- a/qemu-timer-common.c +++ b/qemu-timer-common.c @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu-timer.h" +#include "qemu/timer.h" /***********************************************************/ /* real time host monotonic timer */ diff --git a/qemu-timer.c b/qemu-timer.c index 8e0dccc087..80b3f2eb31 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -28,7 +28,7 @@ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CONFIG_POSIX #include #endif @@ -477,7 +477,7 @@ static void host_alarm_handler(int host_signum) #if defined(__linux__) -#include "compatfd.h" +#include "qemu/compatfd.h" static int dynticks_start_timer(struct qemu_alarm_timer *t) { diff --git a/qemu-timer.h b/qemu-timer.h deleted file mode 100644 index da7e97cd5a..0000000000 --- a/qemu-timer.h +++ /dev/null @@ -1,310 +0,0 @@ -#ifndef QEMU_TIMER_H -#define QEMU_TIMER_H - -#include "qemu-common.h" -#include "main-loop.h" -#include "notify.h" - -#ifdef __FreeBSD__ -#include -#endif - -/* timers */ - -#define SCALE_MS 1000000 -#define SCALE_US 1000 -#define SCALE_NS 1 - -typedef struct QEMUClock QEMUClock; -typedef void QEMUTimerCB(void *opaque); - -/* The real time clock should be used only for stuff which does not - change the virtual machine state, as it is run even if the virtual - machine is stopped. The real time clock has a frequency of 1000 - Hz. */ -extern QEMUClock *rt_clock; - -/* The virtual clock is only run during the emulation. It is stopped - when the virtual machine is stopped. Virtual timers use a high - precision clock, usually cpu cycles (use ticks_per_sec). */ -extern QEMUClock *vm_clock; - -/* The host clock should be use for device models that emulate accurate - real time sources. It will continue to run when the virtual machine - is suspended, and it will reflect system time changes the host may - undergo (e.g. due to NTP). The host clock has the same precision as - the virtual clock. */ -extern QEMUClock *host_clock; - -int64_t qemu_get_clock_ns(QEMUClock *clock); -int64_t qemu_clock_has_timers(QEMUClock *clock); -int64_t qemu_clock_expired(QEMUClock *clock); -int64_t qemu_clock_deadline(QEMUClock *clock); -void qemu_clock_enable(QEMUClock *clock, bool enabled); -void qemu_clock_warp(QEMUClock *clock); - -void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier); -void qemu_unregister_clock_reset_notifier(QEMUClock *clock, - Notifier *notifier); - -QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale, - QEMUTimerCB *cb, void *opaque); -void qemu_free_timer(QEMUTimer *ts); -void qemu_del_timer(QEMUTimer *ts); -void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time); -void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time); -bool qemu_timer_pending(QEMUTimer *ts); -bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); -uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts); - -void qemu_run_timers(QEMUClock *clock); -void qemu_run_all_timers(void); -void configure_alarms(char const *opt); -void init_clocks(void); -int init_timer_alarm(void); - -int64_t cpu_get_ticks(void); -void cpu_enable_ticks(void); -void cpu_disable_ticks(void); - -static inline QEMUTimer *qemu_new_timer_ns(QEMUClock *clock, QEMUTimerCB *cb, - void *opaque) -{ - return qemu_new_timer(clock, SCALE_NS, cb, opaque); -} - -static inline QEMUTimer *qemu_new_timer_ms(QEMUClock *clock, QEMUTimerCB *cb, - void *opaque) -{ - return qemu_new_timer(clock, SCALE_MS, cb, opaque); -} - -static inline int64_t qemu_get_clock_ms(QEMUClock *clock) -{ - return qemu_get_clock_ns(clock) / SCALE_MS; -} - -static inline int64_t get_ticks_per_sec(void) -{ - return 1000000000LL; -} - -/* real time host monotonic timer */ -static inline int64_t get_clock_realtime(void) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000); -} - -/* Warning: don't insert tracepoints into these functions, they are - also used by simpletrace backend and tracepoints would cause - an infinite recursion! */ -#ifdef _WIN32 -extern int64_t clock_freq; - -static inline int64_t get_clock(void) -{ - LARGE_INTEGER ti; - QueryPerformanceCounter(&ti); - return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq); -} - -#else - -extern int use_rt_clock; - -static inline int64_t get_clock(void) -{ -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ - || defined(__DragonFly__) || defined(__FreeBSD_kernel__) - if (use_rt_clock) { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec * 1000000000LL + ts.tv_nsec; - } else -#endif - { - /* XXX: using gettimeofday leads to problems if the date - changes, so it should be avoided. */ - return get_clock_realtime(); - } -} -#endif - -void qemu_get_timer(QEMUFile *f, QEMUTimer *ts); -void qemu_put_timer(QEMUFile *f, QEMUTimer *ts); - -/* icount */ -int64_t cpu_get_icount(void); -int64_t cpu_get_clock(void); - -/*******************************************/ -/* host CPU ticks (if available) */ - -#if defined(_ARCH_PPC) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t retval; -#ifdef _ARCH_PPC64 - /* This reads timebase in one 64bit go and includes Cell workaround from: - http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html - */ - __asm__ __volatile__ ("mftb %0\n\t" - "cmpwi %0,0\n\t" - "beq- $-8" - : "=r" (retval)); -#else - /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */ - unsigned long junk; - __asm__ __volatile__ ("mfspr %1,269\n\t" /* mftbu */ - "mfspr %L0,268\n\t" /* mftb */ - "mfspr %0,269\n\t" /* mftbu */ - "cmpw %0,%1\n\t" - "bne $-16" - : "=r" (retval), "=r" (junk)); -#endif - return retval; -} - -#elif defined(__i386__) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t val; - asm volatile ("rdtsc" : "=A" (val)); - return val; -} - -#elif defined(__x86_64__) - -static inline int64_t cpu_get_real_ticks(void) -{ - uint32_t low,high; - int64_t val; - asm volatile("rdtsc" : "=a" (low), "=d" (high)); - val = high; - val <<= 32; - val |= low; - return val; -} - -#elif defined(__hppa__) - -static inline int64_t cpu_get_real_ticks(void) -{ - int val; - asm volatile ("mfctl %%cr16, %0" : "=r"(val)); - return val; -} - -#elif defined(__ia64) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t val; - asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory"); - return val; -} - -#elif defined(__s390__) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t val; - asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc"); - return val; -} - -#elif defined(__sparc__) - -static inline int64_t cpu_get_real_ticks (void) -{ -#if defined(_LP64) - uint64_t rval; - asm volatile("rd %%tick,%0" : "=r"(rval)); - return rval; -#else - /* We need an %o or %g register for this. For recent enough gcc - there is an "h" constraint for that. Don't bother with that. */ - union { - uint64_t i64; - struct { - uint32_t high; - uint32_t low; - } i32; - } rval; - asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1" - : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1"); - return rval.i64; -#endif -} - -#elif defined(__mips__) && \ - ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__)) -/* - * binutils wants to use rdhwr only on mips32r2 - * but as linux kernel emulate it, it's fine - * to use it. - * - */ -#define MIPS_RDHWR(rd, value) { \ - __asm__ __volatile__ (".set push\n\t" \ - ".set mips32r2\n\t" \ - "rdhwr %0, "rd"\n\t" \ - ".set pop" \ - : "=r" (value)); \ - } - -static inline int64_t cpu_get_real_ticks(void) -{ - /* On kernels >= 2.6.25 rdhwr , $2 and $3 are emulated */ - uint32_t count; - static uint32_t cyc_per_count = 0; - - if (!cyc_per_count) { - MIPS_RDHWR("$3", cyc_per_count); - } - - MIPS_RDHWR("$2", count); - return (int64_t)(count * cyc_per_count); -} - -#elif defined(__alpha__) - -static inline int64_t cpu_get_real_ticks(void) -{ - uint64_t cc; - uint32_t cur, ofs; - - asm volatile("rpcc %0" : "=r"(cc)); - cur = cc; - ofs = cc >> 32; - return cur - ofs; -} - -#else -/* The host CPU doesn't have an easily accessible cycle counter. - Just return a monotonically increasing value. This will be - totally wrong, but hopefully better than nothing. */ -static inline int64_t cpu_get_real_ticks (void) -{ - static int64_t ticks = 0; - return ticks++; -} -#endif - -#ifdef CONFIG_PROFILER -static inline int64_t profile_getclock(void) -{ - return cpu_get_real_ticks(); -} - -extern int64_t qemu_time, qemu_time_start; -extern int64_t tlb_flush_time; -extern int64_t dev_time; -#endif - -#endif diff --git a/qemu-tls.h b/qemu-tls.h deleted file mode 100644 index b92ea9d7da..0000000000 --- a/qemu-tls.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Abstraction layer for defining and using TLS variables - * - * Copyright (c) 2011 Red Hat, Inc - * Copyright (c) 2011 Linaro Limited - * - * Authors: - * Paolo Bonzini - * Peter Maydell - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - */ - -#ifndef QEMU_TLS_H -#define QEMU_TLS_H - -/* Per-thread variables. Note that we only have implementations - * which are really thread-local on Linux; the dummy implementations - * define plain global variables. - * - * This means that for the moment use should be restricted to - * per-VCPU variables, which are OK because: - * - the only -user mode supporting multiple VCPU threads is linux-user - * - TCG system mode is single-threaded regarding VCPUs - * - KVM system mode is multi-threaded but limited to Linux - * - * TODO: proper implementations via Win32 .tls sections and - * POSIX pthread_getspecific. - */ -#ifdef __linux__ -#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) -#define DEFINE_TLS(type, x) __thread __typeof__(type) tls__##x -#define tls_var(x) tls__##x -#else -/* Dummy implementations which define plain global variables */ -#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) -#define DEFINE_TLS(type, x) __typeof__(type) tls__##x -#define tls_var(x) tls__##x -#endif - -#endif diff --git a/qemu-tool.c b/qemu-tool.c index d1f46222ee..8ac45ff39b 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -15,12 +15,12 @@ #include "qemu-common.h" #include "monitor/monitor.h" -#include "qemu-timer.h" -#include "qemu-log.h" +#include "qemu/timer.h" +#include "qemu/log.h" #include "migration/migration.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "sysemu.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "slirp/libslirp.h" #include diff --git a/qemu-types.h b/qemu-types.h deleted file mode 100644 index fd532a268d..0000000000 --- a/qemu-types.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef QEMU_TYPEDEFS_H -#define QEMU_TYPEDEFS_H - -/* A load of opaque types so that device init declarations don't have to - pull in all the real definitions. */ -typedef struct QEMUTimer QEMUTimer; -typedef struct QEMUFile QEMUFile; -typedef struct QEMUBH QEMUBH; - -struct Monitor; -typedef struct Monitor Monitor; -typedef struct MigrationParams MigrationParams; - -typedef struct Property Property; -typedef struct PropertyInfo PropertyInfo; -typedef struct CompatProperty CompatProperty; -typedef struct DeviceState DeviceState; -typedef struct BusState BusState; -typedef struct BusClass BusClass; - -typedef struct NICInfo NICInfo; -typedef struct HCIInfo HCIInfo; -typedef struct AudioState AudioState; -typedef struct BlockDriverState BlockDriverState; -typedef struct DriveInfo DriveInfo; -typedef struct DisplayState DisplayState; -typedef struct DisplayChangeListener DisplayChangeListener; -typedef struct DisplaySurface DisplaySurface; -typedef struct PixelFormat PixelFormat; -typedef struct QemuConsole QemuConsole; -typedef struct CharDriverState CharDriverState; -typedef struct MACAddr MACAddr; -typedef struct NetClientState NetClientState; -typedef struct i2c_bus i2c_bus; -typedef struct ISABus ISABus; -typedef struct ISADevice ISADevice; -typedef struct SMBusDevice SMBusDevice; -typedef struct PCIHostState PCIHostState; -typedef struct PCIExpressHost PCIExpressHost; -typedef struct PCIBus PCIBus; -typedef struct PCIDevice PCIDevice; -typedef struct PCIExpressDevice PCIExpressDevice; -typedef struct PCIBridge PCIBridge; -typedef struct PCIEAERMsg PCIEAERMsg; -typedef struct PCIEAERLog PCIEAERLog; -typedef struct PCIEAERErr PCIEAERErr; -typedef struct PCIEPort PCIEPort; -typedef struct PCIESlot PCIESlot; -typedef struct MSIMessage MSIMessage; -typedef struct SerialState SerialState; -typedef struct PCMCIACardState PCMCIACardState; -typedef struct MouseTransformInfo MouseTransformInfo; -typedef struct uWireSlave uWireSlave; -typedef struct I2SCodec I2SCodec; -typedef struct SSIBus SSIBus; -typedef struct EventNotifier EventNotifier; -typedef struct VirtIODevice VirtIODevice; -typedef struct QEMUSGList QEMUSGList; -typedef struct SHPCDevice SHPCDevice; - -#endif /* QEMU_TYPEDEFS_H */ diff --git a/qemu-xattr.h b/qemu-xattr.h deleted file mode 100644 index f910d96eaf..0000000000 --- a/qemu-xattr.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Host xattr.h abstraction - * - * Copyright 2011 Red Hat Inc. and/or its affiliates - * - * Authors: - * Avi Kivity - * - * This work is licensed under the terms of the GNU GPL, version 2, or any - * later version. See the COPYING file in the top-level directory. - * - */ -#ifndef QEMU_XATTR_H -#define QEMU_XATTR_H - -/* - * Modern distributions (e.g. Fedora 15, have no libattr.so, place attr.h - * in /usr/include/sys, and don't have ENOATTR. - */ - -#include "config-host.h" - -#ifdef CONFIG_LIBATTR -# include -#else -# define ENOATTR ENODATA -# include -#endif - -#endif diff --git a/qemu_socket.h b/qemu_socket.h deleted file mode 100644 index 42899fe138..0000000000 --- a/qemu_socket.h +++ /dev/null @@ -1,77 +0,0 @@ -/* headers to use the BSD sockets */ -#ifndef QEMU_SOCKET_H -#define QEMU_SOCKET_H - -#ifdef _WIN32 -#include -#include -#include - -#define socket_error() WSAGetLastError() - -int inet_aton(const char *cp, struct in_addr *ia); - -#else - -#include -#include -#include -#include -#include -#include -#include - -#define socket_error() errno -#define closesocket(s) close(s) - -#endif /* !_WIN32 */ - -#include "qemu-option.h" -#include "qapi/error.h" -#include "qapi/qmp/qerror.h" - -/* misc helpers */ -int qemu_socket(int domain, int type, int protocol); -int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); -int socket_set_cork(int fd, int v); -void socket_set_block(int fd); -void socket_set_nonblock(int fd); -int send_all(int fd, const void *buf, int len1); - -/* callback function for nonblocking connect - * valid fd on success, negative error code on failure - */ -typedef void NonBlockingConnectHandler(int fd, void *opaque); - -int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp); -int inet_listen(const char *str, char *ostr, int olen, - int socktype, int port_offset, Error **errp); -int inet_connect_opts(QemuOpts *opts, Error **errp, - NonBlockingConnectHandler *callback, void *opaque); -int inet_connect(const char *str, Error **errp); -int inet_nonblocking_connect(const char *str, - NonBlockingConnectHandler *callback, - void *opaque, Error **errp); - -int inet_dgram_opts(QemuOpts *opts, Error **errp); -const char *inet_strfamily(int family); - -int unix_listen_opts(QemuOpts *opts, Error **errp); -int unix_listen(const char *path, char *ostr, int olen, Error **errp); -int unix_connect_opts(QemuOpts *opts, Error **errp, - NonBlockingConnectHandler *callback, void *opaque); -int unix_connect(const char *path, Error **errp); -int unix_nonblocking_connect(const char *str, - NonBlockingConnectHandler *callback, - void *opaque, Error **errp); - -SocketAddress *socket_parse(const char *str, Error **errp); -int socket_connect(SocketAddress *addr, Error **errp, - NonBlockingConnectHandler *callback, void *opaque); -int socket_listen(SocketAddress *addr, Error **errp); - -/* Old, ipv4 only bits. Don't use for new code. */ -int parse_host_port(struct sockaddr_in *saddr, const char *str); -int socket_init(void); - -#endif /* QEMU_SOCKET_H */ diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 769a559456..d4fd628907 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -4,8 +4,8 @@ #include #include #include -#include "osdep.h" -#include "qemu_socket.h" +#include "qemu/osdep.h" +#include "qemu/sockets.h" #include "qga/channel.h" #ifdef CONFIG_SOLARIS diff --git a/qga/commands-posix.c b/qga/commands-posix.c index cedf2ccf28..a657201e7a 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -18,8 +18,8 @@ #include "qga/guest-agent-core.h" #include "qga-qmp-commands.h" #include "qapi/qmp/qerror.h" -#include "qemu-queue.h" -#include "host-utils.h" +#include "qemu/queue.h" +#include "qemu/host-utils.h" #ifndef CONFIG_HAS_ENVIRON #ifdef __APPLE__ diff --git a/qga/main.c b/qga/main.c index ead58cc11f..ba5fa1c778 100644 --- a/qga/main.c +++ b/qga/main.c @@ -25,7 +25,7 @@ #include "qapi/qmp/qint.h" #include "qapi/qmp/qjson.h" #include "qga/guest-agent-core.h" -#include "module.h" +#include "qemu/module.h" #include "signal.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/dispatch.h" diff --git a/qlist.c b/qlist.c index c5ac2115af..1ced0de58e 100644 --- a/qlist.c +++ b/qlist.c @@ -12,7 +12,7 @@ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qobject.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" static void qlist_destroy_obj(QObject *obj); diff --git a/qom/container.c b/qom/container.c index ceb0f0186d..5270a5ee9c 100644 --- a/qom/container.c +++ b/qom/container.c @@ -11,7 +11,7 @@ */ #include "qom/object.h" -#include "module.h" +#include "qemu/module.h" #include static TypeInfo container_info = { diff --git a/range.h b/range.h deleted file mode 100644 index 350237212b..0000000000 --- a/range.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QEMU_RANGE_H -#define QEMU_RANGE_H - -/* Get last byte of a range from offset + length. - * Undefined for ranges that wrap around 0. */ -static inline uint64_t range_get_last(uint64_t offset, uint64_t len) -{ - return offset + len - 1; -} - -/* Check whether a given range covers a given byte. */ -static inline int range_covers_byte(uint64_t offset, uint64_t len, - uint64_t byte) -{ - return offset <= byte && byte <= range_get_last(offset, len); -} - -/* Check whether 2 given ranges overlap. - * Undefined if ranges that wrap around 0. */ -static inline int ranges_overlap(uint64_t first1, uint64_t len1, - uint64_t first2, uint64_t len2) -{ - uint64_t last1 = range_get_last(first1, len1); - uint64_t last2 = range_get_last(first2, len2); - - return !(last2 < first1 || last1 < first2); -} - -#endif diff --git a/savevm.c b/savevm.c index a5205a09c3..ea01e9baf6 100644 --- a/savevm.c +++ b/savevm.c @@ -75,17 +75,17 @@ #include "net/net.h" #include "monitor/monitor.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "audio/audio.h" #include "migration/migration.h" -#include "qemu_socket.h" -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/sockets.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "cpus.h" #include "exec/memory.h" #include "qmp-commands.h" #include "trace.h" -#include "bitops.h" +#include "qemu/bitops.h" #define SELF_ANNOUNCE_ROUNDS 5 diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index eccc28daee..e06332bd55 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -367,7 +367,7 @@ def gen_command_def_prologue(prefix="", proxy=False): */ #include "qemu-common.h" -#include "module.h" +#include "qemu/module.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/types.h" #include "qapi/qmp/dispatch.h" diff --git a/slirp/if.c b/slirp/if.c index 533295dd07..dcd5fafe5d 100644 --- a/slirp/if.c +++ b/slirp/if.c @@ -6,7 +6,7 @@ */ #include -#include "qemu-timer.h" +#include "qemu/timer.h" static void ifs_insque(struct mbuf *ifm, struct mbuf *ifmhead) diff --git a/slirp/ip_input.c b/slirp/ip_input.c index 6f4cff8fdd..880bdfd3cc 100644 --- a/slirp/ip_input.c +++ b/slirp/ip_input.c @@ -39,7 +39,7 @@ */ #include -#include +#include #include "ip_icmp.h" static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp); diff --git a/slirp/sbuf.c b/slirp/sbuf.c index 637f8fea3d..08ec2b4f44 100644 --- a/slirp/sbuf.c +++ b/slirp/sbuf.c @@ -6,7 +6,7 @@ */ #include -#include +#include static void sbappendsb(struct sbuf *sb, struct mbuf *m); diff --git a/slirp/slirp.c b/slirp/slirp.c index 3395d509a2..4b51a67e7d 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" #include "slirp.h" #include "hw/hw.h" diff --git a/slirp/slirp.h b/slirp/slirp.h index 0107b07e66..dfc3e3a2b8 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -133,8 +133,8 @@ void free(void *ptr); #include "debug.h" -#include "qemu-queue.h" -#include "qemu_socket.h" +#include "qemu/queue.h" +#include "qemu/sockets.h" #include "libslirp.h" #include "ip.h" diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 5f95c937f3..41b1657ccd 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -5,7 +5,7 @@ #include #include -#include "osdep.h" +#include "qemu/osdep.h" #define dprintf(_scd, _level, _fmt, ...) \ do { \ diff --git a/stubs/fd-register.c b/stubs/fd-register.c index 813b6dd7c0..d0c34fd2a3 100644 --- a/stubs/fd-register.c +++ b/stubs/fd-register.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" void qemu_fd_register(int fd) { diff --git a/stubs/set-fd-handler.c b/stubs/set-fd-handler.c index 4807b5dc22..fc874d33fe 100644 --- a/stubs/set-fd-handler.c +++ b/stubs/set-fd-handler.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" int qemu_set_fd_handler2(int fd, IOCanReadHandler *fd_read_poll, diff --git a/sysemu.h b/sysemu.h index 1b6add2dc3..8eaa4707a0 100644 --- a/sysemu.h +++ b/sysemu.h @@ -2,13 +2,13 @@ #define SYSEMU_H /* Misc. things related to the system emulator. */ -#include "qemu-types.h" -#include "qemu-option.h" -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/typedefs.h" +#include "qemu/option.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "qapi-types.h" -#include "notify.h" -#include "main-loop.h" +#include "qemu/notify.h" +#include "qemu/main-loop.h" /* vl.c */ diff --git a/target-alpha/int_helper.c b/target-alpha/int_helper.c index 1d832f0b57..c9b42b6ed4 100644 --- a/target-alpha/int_helper.c +++ b/target-alpha/int_helper.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" uint64_t helper_umulh(uint64_t op1, uint64_t op2) diff --git a/target-alpha/sys_helper.c b/target-alpha/sys_helper.c index 40ca49c883..2bc2b02815 100644 --- a/target-alpha/sys_helper.c +++ b/target-alpha/sys_helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "helper.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" uint64_t helper_load_pcc(CPUAlphaState *env) diff --git a/target-alpha/translate.c b/target-alpha/translate.c index 2d0d891128..c94126737f 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "disas/disas.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "tcg-op.h" #include "helper.h" diff --git a/target-arm/helper.c b/target-arm/helper.c index 1f7a3c04c3..eef2acd18a 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -1,9 +1,9 @@ #include "cpu.h" #include "exec/gdbstub.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "sysemu.h" -#include "bitops.h" +#include "qemu/bitops.h" #ifndef CONFIG_USER_ONLY static inline int get_phys_addr(CPUARMState *env, uint32_t address, diff --git a/target-arm/translate.c b/target-arm/translate.c index 988b5428d4..724e00f7cf 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -27,7 +27,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-cris/helper.c b/target-cris/helper.c index 324fe052f5..8407a6d880 100644 --- a/target-cris/helper.c +++ b/target-cris/helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "mmu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" //#define CRIS_HELPER_DEBUG diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c index cd0e17e099..79bff38663 100644 --- a/target-cris/op_helper.c +++ b/target-cris/op_helper.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "mmu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" //#define CRIS_OP_HELPER_DEBUG diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 150c4dfb0c..8abc5561e9 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -24,8 +24,8 @@ #include "cpu.h" #include "kvm.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qapi/qmp/qerror.h" #include "qapi/visitor.h" diff --git a/target-i386/excp_helper.c b/target-i386/excp_helper.c index aaa5ca2090..64c8346d3b 100644 --- a/target-i386/excp_helper.c +++ b/target-i386/excp_helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "sysemu.h" #include "helper.h" diff --git a/target-i386/int_helper.c b/target-i386/int_helper.c index f39747e806..84b812dcca 100644 --- a/target-i386/int_helper.c +++ b/target-i386/int_helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" //#define DEBUG_MULDIV diff --git a/target-i386/kvm.c b/target-i386/kvm.c index f7c95d5424..340ed3f33e 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -26,8 +26,8 @@ #include "kvm_i386.h" #include "cpu.h" #include "exec/gdbstub.h" -#include "host-utils.h" -#include "qemu-config.h" +#include "qemu/host-utils.h" +#include "qemu/config-file.h" #include "hw/pc.h" #include "hw/apic.h" #include "exec/ioport.h" diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index be795d71eb..c2a99ee9bc 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helper.h" //#define DEBUG_PCALL diff --git a/target-lm32/helper.c b/target-lm32/helper.c index 0ed7cfda18..d76ea3fe09 100644 --- a/target-lm32/helper.c +++ b/target-lm32/helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" int cpu_lm32_handle_mmu_fault(CPULM32State *env, target_ulong address, int rw, int mmu_idx) diff --git a/target-lm32/op_helper.c b/target-lm32/op_helper.c index 27b3cef25c..53410b176e 100644 --- a/target-lm32/op_helper.c +++ b/target-lm32/op_helper.c @@ -1,7 +1,7 @@ #include #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "hw/lm32_pic.h" #include "hw/lm32_juart.h" diff --git a/target-m68k/translate.c b/target-m68k/translate.c index 1c9b5ec8d4..e763195f86 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helpers.h" #define GEN_HELPER 1 diff --git a/target-microblaze/helper.c b/target-microblaze/helper.c index 530e0b5fb0..97aedc52bb 100644 --- a/target-microblaze/helper.c +++ b/target-microblaze/helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #define D(x) #define DMMU(x) diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c index 343dcc15e7..1c62f3c68f 100644 --- a/target-microblaze/op_helper.c +++ b/target-microblaze/op_helper.c @@ -21,7 +21,7 @@ #include #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #define D(x) diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c index 157f59e6bf..e85edce6fa 100644 --- a/target-mips/op_helper.c +++ b/target-mips/op_helper.c @@ -18,7 +18,7 @@ */ #include #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" diff --git a/target-openrisc/int_helper.c b/target-openrisc/int_helper.c index 2fdfd27712..20f9837e6a 100644 --- a/target-openrisc/int_helper.c +++ b/target-openrisc/int_helper.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "helper.h" #include "exception.h" -#include "host-utils.h" +#include "qemu/host-utils.h" target_ulong HELPER(ff1)(target_ulong x) { diff --git a/target-openrisc/interrupt.c b/target-openrisc/interrupt.c index 226ce43513..7f2c025da2 100644 --- a/target-openrisc/interrupt.c +++ b/target-openrisc/interrupt.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "qemu-common.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" #endif diff --git a/target-openrisc/mmu.c b/target-openrisc/mmu.c index 4eee44434f..836465259a 100644 --- a/target-openrisc/mmu.c +++ b/target-openrisc/mmu.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "qemu-common.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" #endif diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c index 5883347fa7..1e1b30cdcb 100644 --- a/target-openrisc/translate.c +++ b/target-openrisc/translate.c @@ -23,9 +23,9 @@ #include "disas/disas.h" #include "tcg-op.h" #include "qemu-common.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "config.h" -#include "bitops.h" +#include "qemu/bitops.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c index f39b4f682a..783079d995 100644 --- a/target-ppc/int_helper.c +++ b/target-ppc/int_helper.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include "helper_regs.h" diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 3f5df5772f..2546c577f6 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -23,7 +23,7 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "kvm.h" #include "kvm_ppc.h" diff --git a/target-ppc/kvm_ppc.c b/target-ppc/kvm_ppc.c index a2e49cd423..2de59fd43b 100644 --- a/target-ppc/kvm_ppc.c +++ b/target-ppc/kvm_ppc.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "kvm_ppc.h" #include "device_tree.h" diff --git a/target-ppc/mem_helper.c b/target-ppc/mem_helper.c index 2d7a349c32..902b1cd823 100644 --- a/target-ppc/mem_helper.c +++ b/target-ppc/mem_helper.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include "helper_regs.h" diff --git a/target-ppc/translate.c b/target-ppc/translate.c index a74d76b5a6..798b7acfc9 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 619b202b92..249f063d94 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -22,7 +22,7 @@ #include "cpu.h" #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* CPUClass::reset() */ diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 6e9b209713..8e135457a3 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifndef CONFIG_USER_ONLY #include "sysemu.h" #endif diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c index f202a7e1da..b683709860 100644 --- a/target-s390x/int_helper.c +++ b/target-s390x/int_helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" /* #define DEBUG_HELPER */ diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 94de764264..dc70699919 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -25,7 +25,7 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "kvm.h" #include "cpu.h" diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c index a3336e16b0..2e73d30756 100644 --- a/target-s390x/misc_helper.c +++ b/target-s390x/misc_helper.c @@ -20,11 +20,11 @@ #include "cpu.h" #include "exec/memory.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include #include "kvm.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CONFIG_KVM #include #endif diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 28e61c54b8..9e34741311 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -32,7 +32,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" /* global register indexes */ static TCGv_ptr cpu_env; diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 0ed511a399..04b6659909 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -3,7 +3,7 @@ #include "config.h" #include "qemu-common.h" -#include "bswap.h" +#include "qemu/bswap.h" #if !defined(TARGET_SPARC64) #define TARGET_LONG_BITS 32 diff --git a/target-sparc/helper.c b/target-sparc/helper.c index 3c8e865eef..e0d78f3852 100644 --- a/target-sparc/helper.c +++ b/target-sparc/helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include "sysemu.h" diff --git a/target-sparc/machine.c b/target-sparc/machine.c index eb4d87f158..a353dabdd9 100644 --- a/target-sparc/machine.c +++ b/target-sparc/machine.c @@ -1,6 +1,6 @@ #include "hw/hw.h" #include "hw/boards.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "cpu.h" diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index 2adbd1675d..ff4f628404 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -12,7 +12,7 @@ #include "cpu.h" #include "exec/gdbstub.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "ui/console.h" #undef DEBUG_UC32 diff --git a/target-unicore32/translate.c b/target-unicore32/translate.c index 218e95eaca..f4498bcb14 100644 --- a/target-unicore32/translate.c +++ b/target-unicore32/translate.c @@ -17,7 +17,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-xtensa/core-dc232b.c b/target-xtensa/core-dc232b.c index d1a594cda2..0bfcf2414c 100644 --- a/target-xtensa/core-dc232b.c +++ b/target-xtensa/core-dc232b.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "core-dc232b/core-isa.h" #include "overlay_tool.h" diff --git a/target-xtensa/core-dc233c.c b/target-xtensa/core-dc233c.c index ead6b3b128..11acbf3580 100644 --- a/target-xtensa/core-dc233c.c +++ b/target-xtensa/core-dc233c.c @@ -29,7 +29,7 @@ #include "exec/exec-all.h" #include "exec/gdbstub.h" #include "qemu-common.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "core-dc233c/core-isa.h" #include "overlay_tool.h" diff --git a/target-xtensa/core-fsf.c b/target-xtensa/core-fsf.c index a387aeeca5..d4660edde9 100644 --- a/target-xtensa/core-fsf.c +++ b/target-xtensa/core-fsf.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "core-fsf/core-isa.h" #include "overlay_tool.h" diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c index 3d7a399008..94c03a1d3c 100644 --- a/target-xtensa/helper.c +++ b/target-xtensa/helper.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" #endif diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c index a93abcb1dd..3813a72626 100644 --- a/target-xtensa/op_helper.c +++ b/target-xtensa/op_helper.c @@ -27,7 +27,7 @@ #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" static void do_unaligned_access(CPUXtensaState *env, target_ulong addr, int is_write, int is_user, uintptr_t retaddr); diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c index 3c2d1853d6..f61a497d21 100644 --- a/target-xtensa/translate.c +++ b/target-xtensa/translate.c @@ -34,7 +34,7 @@ #include "exec/exec-all.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "sysemu.h" #include "helper.h" diff --git a/target-xtensa/xtensa-semi.c b/target-xtensa/xtensa-semi.c index 851ff546f0..5fe0361c02 100644 --- a/target-xtensa/xtensa-semi.c +++ b/target-xtensa/xtensa-semi.c @@ -31,7 +31,7 @@ #include #include "cpu.h" #include "helper.h" -#include "qemu-log.h" +#include "qemu/log.h" enum { TARGET_SYS_exit = 1, diff --git a/tcg/tcg.c b/tcg/tcg.c index cb193f2683..ede51a3960 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -37,9 +37,9 @@ #endif #include "qemu-common.h" -#include "cache-utils.h" -#include "host-utils.h" -#include "qemu-timer.h" +#include "qemu/cache-utils.h" +#include "qemu/host-utils.h" +#include "qemu/timer.h" /* Note: the long term plan is to reduce the dependancies on the QEMU CPU definitions. Currently they are used for qemu_ld/st diff --git a/tests/libqtest.c b/tests/libqtest.c index 71b84c12dd..913fa0535c 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -26,8 +26,8 @@ #include #include -#include "compiler.h" -#include "osdep.h" +#include "qemu/compiler.h" +#include "qemu/osdep.h" #define MAX_IRQ 256 diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/test-i386-fprem.c index 8c7a4d1ff4..e91fb1ae93 100644 --- a/tests/tcg/test-i386-fprem.c +++ b/tests/tcg/test-i386-fprem.c @@ -22,8 +22,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ -#include "compiler.h" -#include "osdep.h" +#include "qemu/compiler.h" +#include "qemu/osdep.h" #include #include diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c index 40392ac51d..6dc730d882 100644 --- a/tests/tcg/test-i386.c +++ b/tests/tcg/test-i386.c @@ -17,7 +17,7 @@ * along with this program; if not, see . */ #define _GNU_SOURCE -#include "compiler.h" +#include "qemu/compiler.h" #include #include #include diff --git a/tests/test-iov.c b/tests/test-iov.c index cbe7a8955c..a480bc8725 100644 --- a/tests/test-iov.c +++ b/tests/test-iov.c @@ -1,7 +1,7 @@ #include #include "qemu-common.h" -#include "iov.h" -#include "qemu_socket.h" +#include "qemu/iov.h" +#include "qemu/sockets.h" /* create a randomly-sized iovec with random vectors */ static void iov_random(struct iovec **iovp, unsigned *iov_cntp) diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 61b533a071..5a3e82a854 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -3,7 +3,7 @@ #include "qapi/qmp/types.h" #include "test-qmp-commands.h" #include "qapi/qmp/dispatch.h" -#include "module.h" +#include "qemu/module.h" #include "qapi/qmp-input-visitor.h" #include "tests/test-qapi-types.h" #include "tests/test-qapi-visit.h" diff --git a/thread-pool.c b/thread-pool.c index 4c73a7db97..e3ca64d790 100644 --- a/thread-pool.c +++ b/thread-pool.c @@ -15,13 +15,13 @@ * GNU GPL, version 2 or (at your option) any later version. */ #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-thread.h" -#include "osdep.h" +#include "qemu/queue.h" +#include "qemu/thread.h" +#include "qemu/osdep.h" #include "block/coroutine.h" #include "trace.h" #include "block/block_int.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "block/thread-pool.h" static void do_spawn_thread(void); diff --git a/trace/simple.c b/trace/simple.c index d83681b227..ce17d64bd7 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -16,7 +16,7 @@ #include #include #endif -#include "qemu-timer.h" +#include "qemu/timer.h" #include "trace.h" #include "trace/control.h" diff --git a/translate-all.c b/translate-all.c index e0cdad38c7..b621748ec0 100644 --- a/translate-all.c +++ b/translate-all.c @@ -35,7 +35,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/memory.h" #include "exec/address-spaces.h" #if defined(CONFIG_USER_ONLY) diff --git a/ui/console.c b/ui/console.c index 60bfb72ac2..a4bff8ce8a 100644 --- a/ui/console.c +++ b/ui/console.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qmp-commands.h" #include "qemu-char.h" diff --git a/ui/sdl_zoom.c b/ui/sdl_zoom.c index a986c7c14c..122027cb36 100644 --- a/ui/sdl_zoom.c +++ b/ui/sdl_zoom.c @@ -12,7 +12,7 @@ */ #include "sdl_zoom.h" -#include "osdep.h" +#include "qemu/osdep.h" #include #include diff --git a/ui/spice-core.c b/ui/spice-core.c index 962475de6b..8727bf49ca 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -23,17 +23,17 @@ #include "qemu-common.h" #include "ui/qemu-spice.h" -#include "qemu-thread.h" -#include "qemu-timer.h" -#include "qemu-queue.h" +#include "qemu/thread.h" +#include "qemu/timer.h" +#include "qemu/queue.h" #include "qemu-x509.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "qmp-commands.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" -#include "notify.h" +#include "qemu/notify.h" #include "migration/migration.h" #include "monitor/monitor.h" #include "hw/hw.h" diff --git a/ui/spice-display.c b/ui/spice-display.c index 56ebf80805..a19b3d95fb 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -17,8 +17,8 @@ #include "qemu-common.h" #include "ui/qemu-spice.h" -#include "qemu-timer.h" -#include "qemu-queue.h" +#include "qemu/timer.h" +#include "qemu/queue.h" #include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" diff --git a/ui/vnc-auth-sasl.h b/ui/vnc-auth-sasl.h index ee243a9d64..8091d689cb 100644 --- a/ui/vnc-auth-sasl.h +++ b/ui/vnc-auth-sasl.h @@ -32,7 +32,7 @@ typedef struct VncStateSASL VncStateSASL; typedef struct VncDisplaySASL VncDisplaySASL; -#include "acl.h" +#include "qemu/acl.h" struct VncStateSASL { sasl_conn_t *conn; diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index 09199ef584..4ddea7d4f5 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -44,7 +44,7 @@ #include #endif -#include "bswap.h" +#include "qemu/bswap.h" #include "qapi/qmp/qint.h" #include "vnc.h" #include "vnc-enc-tight.h" diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c index 57c091683b..0bfc0c5485 100644 --- a/ui/vnc-jobs.c +++ b/ui/vnc-jobs.c @@ -28,7 +28,7 @@ #include "vnc.h" #include "vnc-jobs.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" /* * Locking: diff --git a/ui/vnc-palette.h b/ui/vnc-palette.h index bfc7fe642e..d02f0236c1 100644 --- a/ui/vnc-palette.h +++ b/ui/vnc-palette.h @@ -30,7 +30,7 @@ #define VNC_PALETTE_H #include "qapi/qmp/qlist.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include #include diff --git a/ui/vnc-tls.c b/ui/vnc-tls.c index a7f7d07ac8..56292636d7 100644 --- a/ui/vnc-tls.c +++ b/ui/vnc-tls.c @@ -26,7 +26,7 @@ #include "qemu-x509.h" #include "vnc.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2 /* Very verbose, so only enabled for _VNC_DEBUG >= 2 */ diff --git a/ui/vnc-tls.h b/ui/vnc-tls.h index 2b93633896..36a2227fec 100644 --- a/ui/vnc-tls.h +++ b/ui/vnc-tls.h @@ -31,7 +31,7 @@ #include #include -#include "acl.h" +#include "qemu/acl.h" enum { VNC_WIREMODE_CLEAR, diff --git a/ui/vnc.c b/ui/vnc.c index dad2ddee29..d9e5315e79 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -27,12 +27,12 @@ #include "vnc.h" #include "vnc-jobs.h" #include "sysemu.h" -#include "qemu_socket.h" -#include "qemu-timer.h" -#include "acl.h" +#include "qemu/sockets.h" +#include "qemu/timer.h" +#include "qemu/acl.h" #include "qapi/qmp/types.h" #include "qmp-commands.h" -#include "osdep.h" +#include "qemu/osdep.h" #define VNC_REFRESH_INTERVAL_BASE 30 #define VNC_REFRESH_INTERVAL_INC 50 diff --git a/ui/vnc.h b/ui/vnc.h index e5c043ff45..8b40f09117 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -28,12 +28,12 @@ #define __QEMU_VNC_H #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-thread.h" +#include "qemu/queue.h" +#include "qemu/thread.h" #include "ui/console.h" #include "monitor/monitor.h" #include "audio/audio.h" -#include "bitmap.h" +#include "qemu/bitmap.h" #include #include diff --git a/uri.c b/uri.c index 138547b821..4238729b83 100644 --- a/uri.c +++ b/uri.c @@ -55,7 +55,7 @@ #include #include -#include "uri.h" +#include "qemu/uri.h" static void uri_clean(URI *uri); diff --git a/uri.h b/uri.h deleted file mode 100644 index de99b3bd4b..0000000000 --- a/uri.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Summary: library of generic URI related routines - * Description: library of generic URI related routines - * Implements RFC 2396 - * - * Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Daniel Veillard shall not - * be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from him. - * - * Author: Daniel Veillard - ** - * Copyright (C) 2007 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Authors: - * Richard W.M. Jones - * - * Utility functions to help parse and assemble query strings. - */ - -#ifndef QEMU_URI_H -#define QEMU_URI_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * URI: - * - * A parsed URI reference. This is a struct containing the various fields - * as described in RFC 2396 but separated for further processing. - */ -typedef struct URI { - char *scheme; /* the URI scheme */ - char *opaque; /* opaque part */ - char *authority; /* the authority part */ - char *server; /* the server part */ - char *user; /* the user part */ - int port; /* the port number */ - char *path; /* the path string */ - char *fragment; /* the fragment identifier */ - int cleanup; /* parsing potentially unclean URI */ - char *query; /* the query string (as it appears in the URI) */ -} URI; - -URI *uri_new(void); -char *uri_resolve(const char *URI, const char *base); -char *uri_resolve_relative(const char *URI, const char *base); -URI *uri_parse(const char *str); -URI *uri_parse_raw(const char *str, int raw); -int uri_parse_into(URI *uri, const char *str); -char *uri_to_string(URI *uri); -char *uri_string_escape(const char *str, const char *list); -char *uri_string_unescape(const char *str, int len, char *target); -void uri_free(URI *uri); - -/* Single web service query parameter 'name=value'. */ -typedef struct QueryParam { - char *name; /* Name (unescaped). */ - char *value; /* Value (unescaped). */ - int ignore; /* Ignore this field in qparam_get_query */ -} QueryParam; - -/* Set of parameters. */ -typedef struct QueryParams { - int n; /* number of parameters used */ - int alloc; /* allocated space */ - QueryParam *p; /* array of parameters */ -} QueryParams; - -struct QueryParams *query_params_new (int init_alloc); -int query_param_append (QueryParams *ps, const char *name, const char *value); -extern char *query_param_to_string (const QueryParams *ps); -extern QueryParams *query_params_parse (const char *query); -extern void query_params_free (QueryParams *ps); - -#ifdef __cplusplus -} -#endif -#endif /* QEMU_URI_H */ diff --git a/vl.c b/vl.c index 2debde0a4a..9b80e7abc4 100644 --- a/vl.c +++ b/vl.c @@ -28,7 +28,7 @@ #include #include #include -#include "bitmap.h" +#include "qemu/bitmap.h" /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" @@ -133,9 +133,9 @@ int main(int argc, char **argv) #include "ui/console.h" #include "sysemu.h" #include "exec/gdbstub.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" -#include "cache-utils.h" +#include "qemu/cache-utils.h" #include "blockdev.h" #include "hw/block-common.h" #include "migration/block.h" @@ -144,11 +144,11 @@ int main(int argc, char **argv) #include "migration/migration.h" #include "kvm.h" #include "qapi/qmp/qjson.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qemu-options.h" #include "qmp-commands.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifdef CONFIG_VIRTFS #include "fsdev/qemu-fsdev.h" #endif @@ -156,16 +156,16 @@ int main(int argc, char **argv) #include "disas/disas.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "slirp/libslirp.h" #include "trace.h" #include "trace/control.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "cpus.h" #include "arch_init.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "ui/qemu-spice.h" #include "qapi/string-input-visitor.h" diff --git a/xen-all.c b/xen-all.c index 95d383f41f..6965626db8 100644 --- a/xen-all.c +++ b/xen-all.c @@ -16,7 +16,7 @@ #include "hw/xen_backend.h" #include "qmp-commands.h" -#include "range.h" +#include "qemu/range.h" #include "xen-mapcache.h" #include "trace.h" #include "exec/address-spaces.h" diff --git a/xen-mapcache.c b/xen-mapcache.c index 31c06dc950..8f4648cc32 100644 --- a/xen-mapcache.c +++ b/xen-mapcache.c @@ -14,7 +14,7 @@ #include "hw/xen_backend.h" #include "blockdev.h" -#include "bitmap.h" +#include "qemu/bitmap.h" #include #include -- cgit v1.2.3-55-g7522