summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure6
-rw-r--r--hw/arm_timer.c4
-rw-r--r--hw/omap_intc.c6
-rw-r--r--hw/pl061.c2
-rw-r--r--hw/pxa2xx.c4
-rw-r--r--hw/tc58128.c6
-rw-r--r--linux-user/elfload.c5
-rw-r--r--linux-user/linuxload.c2
-rw-r--r--migration.c12
-rw-r--r--os-posix.c3
-rw-r--r--posix-aio-compat.c1
-rw-r--r--qemu-char.c19
-rw-r--r--qemu-sockets.c1
-rw-r--r--ui/keymaps.c12
-rw-r--r--vl.c10
15 files changed, 63 insertions, 30 deletions
diff --git a/configure b/configure
index 8d85d232c1..6c77fbb1a5 100755
--- a/configure
+++ b/configure
@@ -1963,13 +1963,17 @@ if test "$attr" != "no" ; then
cat > $TMPC <<EOF
#include <stdio.h>
#include <sys/types.h>
+#ifdef CONFIG_LIBATTR
+#include <attr/xattr.h>
+#else
#include <sys/xattr.h>
+#endif
int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
EOF
if compile_prog "" "" ; then
attr=yes
# Older distros have <attr/xattr.h>, and need -lattr:
- elif sed -i s,sys/xattr,attr/xattr, $TMPC && compile_prog "" "-lattr" ; then
+ elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
attr=yes
LIBS="-lattr $LIBS"
libattr=yes
diff --git a/hw/arm_timer.c b/hw/arm_timer.c
index 09a4b247bd..66db81d5b7 100644
--- a/hw/arm_timer.c
+++ b/hw/arm_timer.c
@@ -269,7 +269,7 @@ static uint64_t icp_pit_read(void *opaque, target_phys_addr_t offset,
/* ??? Don't know the PrimeCell ID for this device. */
n = offset >> 8;
- if (n > 3) {
+ if (n > 2) {
hw_error("sp804_read: Bad timer %d\n", n);
}
@@ -283,7 +283,7 @@ static void icp_pit_write(void *opaque, target_phys_addr_t offset,
int n;
n = offset >> 8;
- if (n > 3) {
+ if (n > 2) {
hw_error("sp804_write: Bad timer %d\n", n);
}
diff --git a/hw/omap_intc.c b/hw/omap_intc.c
index 0f7fd9dd4c..45efa25109 100644
--- a/hw/omap_intc.c
+++ b/hw/omap_intc.c
@@ -398,6 +398,9 @@ static uint64_t omap2_inth_read(void *opaque, target_phys_addr_t addr,
if (bank_no < s->nbanks) {
offset &= ~0x60;
bank = &s->bank[bank_no];
+ } else {
+ OMAP_BAD_REG(addr);
+ return 0;
}
}
@@ -476,6 +479,9 @@ static void omap2_inth_write(void *opaque, target_phys_addr_t addr,
if (bank_no < s->nbanks) {
offset &= ~0x60;
bank = &s->bank[bank_no];
+ } else {
+ OMAP_BAD_REG(addr);
+ return;
}
}
diff --git a/hw/pl061.c b/hw/pl061.c
index d13746cfe5..cf5adbe1fb 100644
--- a/hw/pl061.c
+++ b/hw/pl061.c
@@ -103,7 +103,7 @@ static void pl061_update(pl061_state *s)
s->old_data = out;
for (i = 0; i < 8; i++) {
mask = 1 << i;
- if ((changed & mask) && s->out) {
+ if (changed & mask) {
DPRINTF("Set output %d = %d\n", i, (out & mask) != 0);
qemu_set_irq(s->out[i], (out & mask) != 0);
}
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index bfc28a999b..d38b922924 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -114,7 +114,9 @@ static void pxa2xx_pm_write(void *opaque, target_phys_addr_t addr,
switch (addr) {
case PMCR:
- s->pm_regs[addr >> 2] &= 0x15 & ~(value & 0x2a);
+ /* Clear the write-one-to-clear bits... */
+ s->pm_regs[addr >> 2] &= ~(value & 0x2a);
+ /* ...and set the plain r/w bits */
s->pm_regs[addr >> 2] |= value & 0x15;
break;
diff --git a/hw/tc58128.c b/hw/tc58128.c
index ee3ecad51a..4ce80b18f3 100644
--- a/hw/tc58128.c
+++ b/hw/tc58128.c
@@ -30,12 +30,8 @@ static void init_dev(tc58128_dev * dev, const char *filename)
int ret, blocks;
dev->state = WAIT;
- dev->flash_contents = g_malloc0(FLASH_SIZE);
+ dev->flash_contents = g_malloc(FLASH_SIZE);
memset(dev->flash_contents, 0xff, FLASH_SIZE);
- if (!dev->flash_contents) {
- fprintf(stderr, "could not alloc memory for flash\n");
- exit(1);
- }
if (filename) {
/* Load flash image skipping the first block */
ret = load_image(filename, dev->flash_contents + 528 * 32);
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index a4139763f4..4635bb2e5d 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1105,8 +1105,7 @@ static abi_ulong copy_elf_strings(int argc,char ** argv, void **page,
offset = p % TARGET_PAGE_SIZE;
pag = (char *)page[p/TARGET_PAGE_SIZE];
if (!pag) {
- pag = (char *)malloc(TARGET_PAGE_SIZE);
- memset(pag, 0, TARGET_PAGE_SIZE);
+ pag = g_try_malloc0(TARGET_PAGE_SIZE);
page[p/TARGET_PAGE_SIZE] = pag;
if (!pag)
return 0;
@@ -1164,7 +1163,7 @@ static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm,
info->rss++;
/* FIXME - check return value of memcpy_to_target() for failure */
memcpy_to_target(stack_base, bprm->page[i], TARGET_PAGE_SIZE);
- free(bprm->page[i]);
+ g_free(bprm->page[i]);
}
stack_base += TARGET_PAGE_SIZE;
}
diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c
index 62ebc7ed41..b47025f08a 100644
--- a/linux-user/linuxload.c
+++ b/linux-user/linuxload.c
@@ -178,7 +178,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp,
/* Something went wrong, return the inode and free the argument pages*/
for (i=0 ; i<MAX_ARG_PAGES ; i++) {
- free(bprm->page[i]);
+ g_free(bprm->page[i]);
}
return(retval);
}
diff --git a/migration.c b/migration.c
index 4b17566857..41c3c24e09 100644
--- a/migration.c
+++ b/migration.c
@@ -155,7 +155,6 @@ MigrationInfo *qmp_query_migrate(Error **errp)
static void migrate_fd_monitor_suspend(MigrationState *s, Monitor *mon)
{
- s->mon = mon;
if (monitor_suspend(mon) == 0) {
DPRINTF("suspending monitor\n");
} else {
@@ -383,7 +382,12 @@ static MigrationState *migrate_init(Monitor *mon, int detach, int blk, int inc)
s->bandwidth_limit = bandwidth_limit;
s->blk = blk;
s->shared = inc;
- s->mon = NULL;
+
+ /* s->mon is used for two things:
+ - pass fd in fd migration
+ - suspend/resume monitor for not detached migration
+ */
+ s->mon = mon;
s->bandwidth_limit = bandwidth_limit;
s->state = MIG_STATE_SETUP;
@@ -435,6 +439,10 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
return ret;
}
+ if (detach) {
+ s->mon = NULL;
+ }
+
notifier_list_notify(&migration_state_notifiers, s);
return 0;
}
diff --git a/os-posix.c b/os-posix.c
index dbf3b240f7..dc4a6bb3ff 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -372,13 +372,16 @@ int qemu_create_pidfile(const char *filename)
return -1;
}
if (lockf(fd, F_TLOCK, 0) == -1) {
+ close(fd);
return -1;
}
len = snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid());
if (write(fd, buffer, len) != len) {
+ close(fd);
return -1;
}
+ close(fd);
return 0;
}
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index d3c1174ebf..0c0035cb18 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -667,6 +667,7 @@ int paio_init(void)
s->first_aio = NULL;
if (qemu_pipe(fds) == -1) {
fprintf(stderr, "failed to create pipe\n");
+ g_free(s);
return -1;
}
diff --git a/qemu-char.c b/qemu-char.c
index 9fd94d1bb4..b562bf88a7 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -985,7 +985,7 @@ static int qemu_chr_open_pty(QemuOpts *opts, CharDriverState **_chr)
CharDriverState *chr;
PtyCharDriver *s;
struct termios tty;
- int slave_fd, len;
+ int master_fd, slave_fd, len;
#if defined(__OpenBSD__) || defined(__DragonFly__)
char pty_name[PATH_MAX];
#define q_ptsname(x) pty_name
@@ -994,10 +994,7 @@ static int qemu_chr_open_pty(QemuOpts *opts, CharDriverState **_chr)
#define q_ptsname(x) ptsname(x)
#endif
- chr = g_malloc0(sizeof(CharDriverState));
- s = g_malloc0(sizeof(PtyCharDriver));
-
- if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) {
+ if (openpty(&master_fd, &slave_fd, pty_name, NULL, NULL) < 0) {
return -errno;
}
@@ -1007,17 +1004,21 @@ static int qemu_chr_open_pty(QemuOpts *opts, CharDriverState **_chr)
tcsetattr(slave_fd, TCSAFLUSH, &tty);
close(slave_fd);
- len = strlen(q_ptsname(s->fd)) + 5;
+ chr = g_malloc0(sizeof(CharDriverState));
+
+ len = strlen(q_ptsname(master_fd)) + 5;
chr->filename = g_malloc(len);
- snprintf(chr->filename, len, "pty:%s", q_ptsname(s->fd));
- qemu_opt_set(opts, "path", q_ptsname(s->fd));
- fprintf(stderr, "char device redirected to %s\n", q_ptsname(s->fd));
+ snprintf(chr->filename, len, "pty:%s", q_ptsname(master_fd));
+ qemu_opt_set(opts, "path", q_ptsname(master_fd));
+ fprintf(stderr, "char device redirected to %s\n", q_ptsname(master_fd));
+ s = g_malloc0(sizeof(PtyCharDriver));
chr->opaque = s;
chr->chr_write = pty_chr_write;
chr->chr_update_read_handler = pty_chr_update_read_handler;
chr->chr_close = pty_chr_close;
+ s->fd = master_fd;
s->timer = qemu_new_timer_ms(rt_clock, pty_chr_timer, chr);
*_chr = chr;
diff --git a/qemu-sockets.c b/qemu-sockets.c
index 183a9cbbd2..61b2247077 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -572,6 +572,7 @@ int unix_connect_opts(QemuOpts *opts)
snprintf(un.sun_path, sizeof(un.sun_path), "%s", path);
if (connect(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
fprintf(stderr, "connect(unix:%s): %s\n", path, strerror(errno));
+ close(sock);
return -1;
}
diff --git a/ui/keymaps.c b/ui/keymaps.c
index f54a11437b..f55a2aa464 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -92,15 +92,17 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
int len;
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
-
- if (!k)
- k = g_malloc0(sizeof(kbd_layout_t));
- if (!(filename && (f = fopen(filename, "r")))) {
+ f = filename ? fopen(filename, "r") : NULL;
+ g_free(filename);
+ if (!f) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return NULL;
}
- g_free(filename);
+
+ if (!k)
+ k = g_malloc0(sizeof(kbd_layout_t));
+
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;
diff --git a/vl.c b/vl.c
index f169aac1f9..f5afed4c49 100644
--- a/vl.c
+++ b/vl.c
@@ -3089,6 +3089,11 @@ int main(int argc, char **argv, char **envp)
data_dir = CONFIG_QEMU_DATADIR;
}
+ if (machine == NULL) {
+ fprintf(stderr, "No machine found.\n");
+ exit(1);
+ }
+
/*
* Default to max_cpus = smp_cpus, in case the user doesn't
* specify a max_cpus value.
@@ -3226,6 +3231,11 @@ int main(int argc, char **argv, char **envp)
fprintf(stderr, "could not initialize alarm timer\n");
exit(1);
}
+
+ if (icount_option && (kvm_enabled() || xen_enabled())) {
+ fprintf(stderr, "-icount is not allowed with kvm or xen\n");
+ exit(1);
+ }
configure_icount(icount_option);
if (net_init_clients() < 0) {