From 6295b98d7b767c377d88fa787ca62603a8ca6adb Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Fri, 14 Mar 2014 10:21:05 +0800 Subject: [PATCH 1/4] rules.mak: Fix per object libs extraction Don't sort the extracted options, sort the objects. Reported-by: Christian Mahnke Signed-off-by: Fam Zheng Signed-off-by: Paolo Bonzini --- rules.mak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules.mak b/rules.mak index 9dda9f760f..5c454d80d5 100644 --- a/rules.mak +++ b/rules.mak @@ -23,8 +23,8 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d QEMU_INCLUDES += -I$( Date: Fri, 14 Mar 2014 18:10:54 +0100 Subject: [PATCH 2/4] qemu-nbd: Fix coverity issues There are two issues in qemu-nbd: a missing return value check after calling accept(), and file descriptor leaks in nbd_client_thread. Reviewed-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- qemu-nbd.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index bdac1f3f1f..899e67cfd7 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -288,19 +288,19 @@ static void *nbd_client_thread(void *arg) ret = nbd_receive_negotiate(sock, NULL, &nbdflags, &size, &blocksize); if (ret < 0) { - goto out; + goto out_socket; } fd = open(device, O_RDWR); if (fd < 0) { /* Linux-only, we can use %m in printf. */ fprintf(stderr, "Failed to open %s: %m", device); - goto out; + goto out_socket; } ret = nbd_init(fd, sock, nbdflags, size, blocksize); if (ret < 0) { - goto out; + goto out_fd; } /* update partition table */ @@ -316,12 +316,16 @@ static void *nbd_client_thread(void *arg) ret = nbd_client(fd); if (ret) { - goto out; + goto out_fd; } close(fd); kill(getpid(), SIGTERM); return (void *) EXIT_SUCCESS; +out_fd: + close(fd); +out_socket: + closesocket(sock); out: kill(getpid(), SIGTERM); return (void *) EXIT_FAILURE; @@ -355,6 +359,11 @@ static void nbd_accept(void *opaque) socklen_t addr_len = sizeof(addr); int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len); + if (fd < 0) { + perror("accept"); + return; + } + if (state >= TERMINATE) { close(fd); return; From 83d1c8ae881e88d70cf23bc8007cf5739313d23c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sat, 15 Mar 2014 19:33:15 +0100 Subject: [PATCH 3/4] target-alpha: fix subl and s8subl indentation Two missing braces, one close and one open, fabulously let the code compile. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target-alpha/translate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target-alpha/translate.c b/target-alpha/translate.c index a9ef1a7507..e7e319b31d 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -1927,6 +1927,7 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) else { tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]); tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]); + } } } break; @@ -1991,7 +1992,7 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) } else { if (islit) tcg_gen_movi_i64(cpu_ir[rc], -lit); - else + else { tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]); tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]); } From 025172d56e11ba3d86d0937933a23aab3b8606b1 Mon Sep 17 00:00:00 2001 From: Miroslav Rezanina Date: Fri, 14 Mar 2014 13:06:54 +0100 Subject: [PATCH 4/4] vl.c: Output error on invalid machine type Output error message using qemu's error_report() function when user provides the invalid machine type on the command line. This also saves time to find what issue is when you downgrade from one version of qemu to another that doesn't support required machine type yet (the version user downgraded to have to have this patch applied too, of course). Signed-off-by: Miroslav Rezanina [Replace printf with error_printf, suggested by Markus Armbruster. - Paolo] Signed-off-by: Paolo Bonzini --- vl.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/vl.c b/vl.c index 842e897d75..b363a21779 100644 --- a/vl.c +++ b/vl.c @@ -2651,15 +2651,20 @@ static MachineClass *machine_parse(const char *name) if (mc) { return mc; } - printf("Supported machines are:\n"); - for (el = machines; el; el = el->next) { - MachineClass *mc = el->data; - QEMUMachine *m = mc->qemu_machine; - if (m->alias) { - printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name); + if (name && !is_help_option(name)) { + error_report("Unsupported machine type"); + error_printf("Use -machine help to list supported machines!\n"); + } else { + printf("Supported machines are:\n"); + for (el = machines; el; el = el->next) { + MachineClass *mc = el->data; + QEMUMachine *m = mc->qemu_machine; + if (m->alias) { + printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name); + } + printf("%-20s %s%s\n", m->name, m->desc, + m->is_default ? " (default)" : ""); } - printf("%-20s %s%s\n", m->name, m->desc, - m->is_default ? " (default)" : ""); } g_slist_free(machines);