diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-11-03 14:55:17 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-11-03 14:55:17 +0000 |
commit | 7135781f65f1267a72bf554ee2b7bd605f9e59aa (patch) | |
tree | 403f29f7852bf516c8df05fec487281a12b9834e | |
parent | f67d23b1ae32b97064fa8f05330efbb09e5d4b07 (diff) | |
parent | f18a768efb990d9cd02911159de02e8ff5475239 (diff) | |
download | qemu-7135781f65f1267a72bf554ee2b7bd605f9e59aa.zip |
Merge remote-tracking branch 'remotes/mjt/tags/pull-trivial-patches-2014-11-02' into staging
trivial patches for 2014-11-02
# gpg: Signature made Sun 02 Nov 2014 11:54:43 GMT using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg: aka "Michael Tokarev <mjt@corpit.ru>"
# gpg: aka "Michael Tokarev <mjt@debian.org>"
* remotes/mjt/tags/pull-trivial-patches-2014-11-02: (23 commits)
vdi: wrapped uuid_unparse() in #ifdef
tap: fix possible fd leak in net_init_tap
tap: do not close(fd) in net_init_tap_one
target-i386: Remove unused model_features_t struct
tap_int.h: remove repeating NETWORK_SCRIPT defines
os-posix: reorder parent notification for -daemonize
pidfile: stop making pidfile error a special case
os-posix: replace goto again with a proper loop
os-posix: use global daemon_pipe instead of cryptic fds[1]
dump: Fix dump-guest-memory termination and use-after-close
virtio-9p-proxy: improve error messages in connect_namedsocket()
virtio-9p-proxy: fix error return in proxy_init()
virtio-9p-proxy: Fix sockfd leak
target-tricore: check return value before using it
net/slirp: specify logbase for smbd
Revert "os-posix: report error message when lock file failed"
util: Improve os_mem_prealloc error message
sparse: fix build
target-arm: A64: remove redundant store
target-xtensa: mark XtensaConfig structs as unused
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | block/vdi.c | 2 | ||||
-rwxr-xr-x | configure | 1 | ||||
-rw-r--r-- | dump.c | 11 | ||||
-rw-r--r-- | hw/9pfs/virtio-9p-proxy.c | 11 | ||||
-rw-r--r-- | hw/tricore/tricore_testboard.c | 2 | ||||
-rw-r--r-- | include/qemu-common.h | 1 | ||||
-rw-r--r-- | include/qemu/bitmap.h | 6 | ||||
-rw-r--r-- | include/qemu/bitops.h | 4 | ||||
-rw-r--r-- | net/slirp.c | 4 | ||||
-rw-r--r-- | net/tap.c | 4 | ||||
-rw-r--r-- | net/tap_int.h | 3 | ||||
-rw-r--r-- | os-posix.c | 66 | ||||
-rw-r--r-- | os-win32.c | 5 | ||||
-rw-r--r-- | target-arm/translate-a64.c | 1 | ||||
-rw-r--r-- | target-i386/cpu.c | 8 | ||||
-rw-r--r-- | target-xtensa/core-dc232b.c | 2 | ||||
-rw-r--r-- | target-xtensa/core-dc233c.c | 2 | ||||
-rw-r--r-- | target-xtensa/core-fsf.c | 2 | ||||
-rw-r--r-- | tests/test-bitops.c | 1 | ||||
-rw-r--r-- | util/oslib-posix.c | 3 | ||||
-rw-r--r-- | vl.c | 2 |
21 files changed, 59 insertions, 82 deletions
diff --git a/block/vdi.c b/block/vdi.c index 19701ee00d..e1d211c9f7 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -137,12 +137,14 @@ static inline int uuid_is_null(const uuid_t uu) return memcmp(uu, null_uuid, sizeof(uuid_t)) == 0; } +# if defined(CONFIG_VDI_DEBUG) static inline void uuid_unparse(const uuid_t uu, char *out) { snprintf(out, 37, UUID_FMT, uu[0], uu[1], uu[2], uu[3], uu[4], uu[5], uu[6], uu[7], uu[8], uu[9], uu[10], uu[11], uu[12], uu[13], uu[14], uu[15]); } +# endif #endif typedef struct { @@ -4908,6 +4908,7 @@ echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak if test "$sparse" = "yes" ; then echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak + echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak fi @@ -604,10 +604,9 @@ static void dump_iterate(DumpState *s, Error **errp) { GuestPhysBlock *block; int64_t size; - int ret; Error *local_err = NULL; - while (1) { + do { block = s->next_block; size = block->target_end - block->target_start; @@ -623,11 +622,9 @@ static void dump_iterate(DumpState *s, Error **errp) return; } - ret = get_next_block(s, block); - if (ret == 1) { - dump_completed(s); - } - } + } while (!get_next_block(s, block)); + + dump_completed(s); } static void create_vmcore(DumpState *s, Error **errp) diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c index b57966d9d8..59c7445dea 100644 --- a/hw/9pfs/virtio-9p-proxy.c +++ b/hw/9pfs/virtio-9p-proxy.c @@ -1104,14 +1104,15 @@ static int connect_namedsocket(const char *path) sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd < 0) { - fprintf(stderr, "socket %s\n", strerror(errno)); + fprintf(stderr, "failed to create socket: %s\n", strerror(errno)); return -1; } strcpy(helper.sun_path, path); helper.sun_family = AF_UNIX; size = strlen(helper.sun_path) + sizeof(helper.sun_family); if (connect(sockfd, (struct sockaddr *)&helper, size) < 0) { - fprintf(stderr, "socket error\n"); + fprintf(stderr, "failed to connect to %s: %s\n", path, strerror(errno)); + close(sockfd); return -1; } @@ -1154,10 +1155,12 @@ static int proxy_init(FsContext *ctx) sock_id = atoi(ctx->fs_root); if (sock_id < 0) { fprintf(stderr, "socket descriptor not initialized\n"); - g_free(proxy); - return -1; } } + if (sock_id < 0) { + g_free(proxy); + return -1; + } g_free(ctx->fs_root); ctx->fs_root = NULL; diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c index eeb4922c4c..a059a20a30 100644 --- a/hw/tricore/tricore_testboard.c +++ b/hw/tricore/tricore_testboard.c @@ -71,11 +71,11 @@ static void tricore_testboard_init(MachineState *machine, int board_id) machine->cpu_model = "tc1796"; } cpu = cpu_tricore_init(machine->cpu_model); - env = &cpu->env; if (!cpu) { error_report("Unable to find CPU definition"); exit(1); } + env = &cpu->env; memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram", 2*1024*1024, &error_abort); vmstate_register_ram_global(ext_cram); memory_region_init_ram(ext_dram, NULL, "powerlink_ext_d.ram", 4*1024*1024, &error_abort); diff --git a/include/qemu-common.h b/include/qemu-common.h index b87e9c2d8b..f8622141a8 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -357,7 +357,6 @@ char *qemu_find_file(int type, const char *name); void os_setup_early_signal_handling(void); char *os_find_datadir(void); void os_parse_cmd_args(int index, const char *optarg); -void os_pidfile_error(void); /* Convert a byte between binary and BCD. */ static inline uint8_t to_bcd(uint8_t val) diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h index edf4f17d9c..f0273c965f 100644 --- a/include/qemu/bitmap.h +++ b/include/qemu/bitmap.h @@ -12,7 +12,11 @@ #ifndef BITMAP_H #define BITMAP_H -#include "qemu-common.h" +#include <glib.h> +#include <string.h> +#include <stdlib.h> + +#include "qemu/osdep.h" #include "qemu/bitops.h" /* diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h index 7e2d5c996e..181bd46063 100644 --- a/include/qemu/bitops.h +++ b/include/qemu/bitops.h @@ -12,7 +12,9 @@ #ifndef BITOPS_H #define BITOPS_H -#include "qemu-common.h" +#include <stdint.h> +#include <assert.h> + #include "host-utils.h" #define BITS_PER_BYTE CHAR_BIT diff --git a/net/slirp.c b/net/slirp.c index c171119dad..920af30bda 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -549,8 +549,8 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, ); fclose(f); - snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s", - CONFIG_SMBD_COMMAND, smb_conf); + snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -l %s -s %s", + CONFIG_SMBD_COMMAND, s->smb_dir, smb_conf); if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0 || slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 445) < 0) { @@ -598,7 +598,6 @@ static int net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, s = net_tap_fd_init(peer, model, name, fd, vnet_hdr); if (!s) { - close(fd); return -1; } @@ -797,6 +796,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, if (net_init_tap_one(tap, peer, "bridge", name, ifname, script, downscript, vhostfdname, vnet_hdr, fd)) { + close(fd); return -1; } } else { @@ -824,6 +824,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, if (queues > 1 && i == 0 && !tap->has_ifname) { if (tap_fd_get_ifname(fd, ifname)) { error_report("Fail to get ifname"); + close(fd); return -1; } } @@ -832,6 +833,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, i >= 1 ? "no" : script, i >= 1 ? "no" : downscript, vhostfdname, vnet_hdr, fd)) { + close(fd); return -1; } } diff --git a/net/tap_int.h b/net/tap_int.h index 86bb224bc8..79afdf2d58 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -29,9 +29,6 @@ #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, int mq_required); diff --git a/os-posix.c b/os-posix.c index 4898ebf4a2..ba091f1530 100644 --- a/os-posix.c +++ b/os-posix.c @@ -47,7 +47,7 @@ static struct passwd *user_pwd; static const char *chroot_dir; static int daemonize; -static int fds[2]; +static int daemon_pipe; void os_setup_early_signal_handling(void) { @@ -205,6 +205,7 @@ void os_daemonize(void) { if (daemonize) { pid_t pid; + int fds[2]; if (pipe(fds) == -1) { exit(1); @@ -217,26 +218,21 @@ void os_daemonize(void) close(fds[1]); - again: - len = read(fds[0], &status, 1); - if (len == -1 && (errno == EINTR)) { - goto again; - } - if (len != 1) { - exit(1); - } - else if (status == 1) { - fprintf(stderr, "Could not acquire pidfile\n"); - exit(1); - } else { - exit(0); - } - } else if (pid < 0) { - exit(1); - } + do { + len = read(fds[0], &status, 1); + } while (len < 0 && errno == EINTR); + + /* only exit successfully if our child actually wrote + * a one-byte zero to our pipe, upon successful init */ + exit(len == 1 && status == 0 ? 0 : 1); + + } else if (pid < 0) { + exit(1); + } close(fds[0]); - qemu_set_cloexec(fds[1]); + daemon_pipe = fds[1]; + qemu_set_cloexec(daemon_pipe); setsid(); @@ -259,17 +255,6 @@ void os_setup_post(void) int fd = 0; if (daemonize) { - uint8_t status = 0; - ssize_t len; - - again1: - len = write(fds[1], &status, 1); - if (len == -1 && (errno == EINTR)) { - goto again1; - } - if (len != 1) { - exit(1); - } if (chdir("/")) { perror("not able to chdir to /"); exit(1); @@ -284,23 +269,22 @@ void os_setup_post(void) change_process_uid(); if (daemonize) { + uint8_t status = 0; + ssize_t len; + dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); close(fd); - } -} -void os_pidfile_error(void) -{ - if (daemonize) { - uint8_t status = 1; - if (write(fds[1], &status, 1) != 1) { - perror("daemonize. Writing to pipe\n"); + do { + len = write(daemon_pipe, &status, 1); + } while (len < 0 && errno == EINTR); + if (len != 1) { + exit(1); } - } else - fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno)); + } } void os_set_line_buffering(void) @@ -319,8 +303,6 @@ int qemu_create_pidfile(const char *filename) return -1; } if (lockf(fd, F_TLOCK, 0) == -1) { - fprintf(stderr, "lock file '%s' failed: %s\n", - filename, strerror(errno)); close(fd); return -1; } diff --git a/os-win32.c b/os-win32.c index 5f95caac15..c0daf8e189 100644 --- a/os-win32.c +++ b/os-win32.c @@ -104,11 +104,6 @@ void os_parse_cmd_args(int index, const char *optarg) return; } -void os_pidfile_error(void) -{ - fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno)); -} - int qemu_create_pidfile(const char *filename) { char buffer[128]; diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index 3a3c48acf4..80d2c07e82 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -748,7 +748,6 @@ static void do_fp_st(DisasContext *s, int srcidx, TCGv_i64 tcg_addr, int size) } else { TCGv_i64 tcg_hiaddr = tcg_temp_new_i64(); tcg_gen_qemu_st_i64(tmp, tcg_addr, get_mem_index(s), MO_TEQ); - tcg_gen_qemu_st64(tmp, tcg_addr, get_mem_index(s)); tcg_gen_ld_i64(tmp, cpu_env, fp_reg_hi_offset(s, srcidx)); tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8); tcg_gen_qemu_st_i64(tmp, tcg_hiaddr, get_mem_index(s), MO_TEQ); diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e1946016ad..e4ccee133a 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -442,14 +442,6 @@ const char *get_register_name_32(unsigned int reg) return x86_reg_info_32[reg].name; } -/* collects per-function cpuid data - */ -typedef struct model_features_t { - uint32_t *guest_feat; - uint32_t *host_feat; - FeatureWord feat_word; -} model_features_t; - /* KVM-specific features that are automatically added to all CPU models * when KVM is enabled. */ diff --git a/target-xtensa/core-dc232b.c b/target-xtensa/core-dc232b.c index c51e11e6d7..a3b914bad4 100644 --- a/target-xtensa/core-dc232b.c +++ b/target-xtensa/core-dc232b.c @@ -33,7 +33,7 @@ #include "core-dc232b/core-isa.h" #include "overlay_tool.h" -static const XtensaConfig dc232b = { +static const XtensaConfig dc232b __attribute__((unused)) = { .name = "dc232b", .gdb_regmap = { .num_regs = 120, diff --git a/target-xtensa/core-dc233c.c b/target-xtensa/core-dc233c.c index 42dd64f031..ac745d106f 100644 --- a/target-xtensa/core-dc233c.c +++ b/target-xtensa/core-dc233c.c @@ -34,7 +34,7 @@ #include "core-dc233c/core-isa.h" #include "overlay_tool.h" -static const XtensaConfig dc233c = { +static const XtensaConfig dc233c __attribute__((unused)) = { .name = "dc233c", .gdb_regmap = { .num_regs = 121, diff --git a/target-xtensa/core-fsf.c b/target-xtensa/core-fsf.c index 6859bee062..cfcc840255 100644 --- a/target-xtensa/core-fsf.c +++ b/target-xtensa/core-fsf.c @@ -33,7 +33,7 @@ #include "core-fsf/core-isa.h" #include "overlay_tool.h" -static const XtensaConfig fsf = { +static const XtensaConfig fsf __attribute__((unused)) = { .name = "fsf", /* GDB for this core is not supported currently */ .clock_freq_khz = 10000, diff --git a/tests/test-bitops.c b/tests/test-bitops.c index 8238eb5f6b..47b5d3ed9a 100644 --- a/tests/test-bitops.c +++ b/tests/test-bitops.c @@ -8,6 +8,7 @@ #include <glib.h> #include <stdint.h> +#include "qemu/osdep.h" #include "qemu/bitops.h" typedef struct { diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 016a047cfc..8c9d80e9fe 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -390,7 +390,8 @@ void os_mem_prealloc(int fd, char *area, size_t memory) pthread_sigmask(SIG_UNBLOCK, &set, &oldset); if (sigsetjmp(sigjump, 1)) { - fprintf(stderr, "os_mem_prealloc: failed to preallocate pages\n"); + fprintf(stderr, "os_mem_prealloc: Insufficient free host memory " + "pages available to allocate guest RAM\n"); exit(1); } else { int i; @@ -4008,7 +4008,7 @@ int main(int argc, char **argv, char **envp) #endif if (pid_file && qemu_create_pidfile(pid_file) != 0) { - os_pidfile_error(); + fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno)); exit(1); } |