From c88930a6866e74953e931ae749781e98e486e5c8 Mon Sep 17 00:00:00 2001 From: Li Liu Date: Tue, 9 Sep 2014 19:19:48 +0800 Subject: [PATCH 1/9] qemu-char: Permit only a single "stdio" character device When more than one is used, the terminal settings aren't restored correctly on exit. Fixable. However, such usage makes no sense, because the users race for input, so outlaw it instead. If you want to connect multiple things to stdio, use the mux chardev. Signed-off-by: Li Liu Reviewed-by: Markus Armbruster Signed-off-by: Michael Tokarev --- qemu-char.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qemu-char.c b/qemu-char.c index 2a3cb9fb05..8623c70964 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1017,6 +1017,7 @@ static CharDriverState *qemu_chr_open_pipe(ChardevHostdev *opts) /* init terminal so that we can grab keys */ static struct termios oldtty; static int old_fd0_flags; +static bool stdio_in_use; static bool stdio_allow_signal; static void term_exit(void) @@ -1060,8 +1061,15 @@ static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts) error_report("cannot use stdio with -daemonize"); return NULL; } + + if (stdio_in_use) { + error_report("cannot use stdio by multiple character devices"); + exit(1); + } + + stdio_in_use = true; old_fd0_flags = fcntl(0, F_GETFL); - tcgetattr (0, &oldtty); + tcgetattr(0, &oldtty); qemu_set_nonblock(0); atexit(term_exit); From 9d632f5f688e1cbb8ef9e54dfc671518dfe677aa Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Wed, 10 Sep 2014 19:29:07 +0800 Subject: [PATCH 2/9] Fix typos and misspellings in comments formated -> formatted gaurantee -> guarantee shear -> sheer Signed-off-by: zhanghailiang Signed-off-by: Michael Tokarev --- hw/ppc/spapr.c | 2 +- libcacard/vcard_emul_nss.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 2ab4460f04..2becc9ff07 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -541,7 +541,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base, _FDT((fdt_property_cell(fdt, "rtas-error-log-max", RTAS_ERROR_LOG_MAX))); /* - * According to PAPR, rtas ibm,os-term, does not gaurantee a return + * According to PAPR, rtas ibm,os-term does not guarantee a return * back to the guest cpu. * * While an additional ibm,extended-os-term property indicates that diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c index f1bba57c2f..07b446481e 100644 --- a/libcacard/vcard_emul_nss.c +++ b/libcacard/vcard_emul_nss.c @@ -286,10 +286,10 @@ vcard_emul_rsa_op(VCard *card, VCardKey *key, } } if ((i < buffer_size) && (buffer[i] == 0)) { - /* yes, we have a properly formated PKCS #1 signature */ + /* yes, we have a properly formatted PKCS #1 signature */ /* * NOTE: even if we accidentally got an encrypt buffer, which - * through shear luck started with 00, 01, ff, 00, it won't matter + * through sheer luck started with 00, 01, ff, 00, it won't matter * because the resulting Sign operation will effectively decrypt * the real buffer. */ From 971ae6ef4772efe2adda3d773f334b9476ffa594 Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Fri, 12 Sep 2014 14:03:14 +0800 Subject: [PATCH 3/9] rdma: Fix incorrect description in comments Since we have supported memory hotplug, VM's ram include pc.ram and hotplug-memory. Fix the confused description for rdma migration: pc.ram -> VM's ram Signed-off-by: zhanghailiang Signed-off-by: Michael Tokarev --- docs/rdma.txt | 6 +++--- migration-rdma.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/rdma.txt b/docs/rdma.txt index 1f5d9e9fe4..2bdd0a5be0 100644 --- a/docs/rdma.txt +++ b/docs/rdma.txt @@ -18,7 +18,7 @@ Contents: * RDMA Migration Protocol Description * Versioning and Capabilities * QEMUFileRDMA Interface -* Migration of pc.ram +* Migration of VM's ram * Error handling * TODO @@ -149,7 +149,7 @@ The only difference between a SEND message and an RDMA message is that SEND messages cause notifications to be posted to the completion queue (CQ) on the infiniband receiver side, whereas RDMA messages (used -for pc.ram) do not (to behave like an actual DMA). +for VM's ram) do not (to behave like an actual DMA). Messages in infiniband require two things: @@ -355,7 +355,7 @@ If the buffer is empty, then we follow the same steps listed above and issue another "QEMU File" protocol command, asking for a new SEND message to re-fill the buffer. -Migration of pc.ram: +Migration of VM's ram: ==================== At the beginning of the migration, (migration-rdma.c), diff --git a/migration-rdma.c b/migration-rdma.c index d99812c451..b32dbdfccd 100644 --- a/migration-rdma.c +++ b/migration-rdma.c @@ -2523,7 +2523,7 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp) /* * QEMUFile interface to the control channel. * SEND messages for control only. - * pc.ram is handled with regular RDMA messages. + * VM's ram is handled with regular RDMA messages. */ static int qemu_rdma_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int size) @@ -2539,7 +2539,7 @@ static int qemu_rdma_put_buffer(void *opaque, const uint8_t *buf, /* * Push out any writes that - * we're queued up for pc.ram. + * we're queued up for VM's ram. */ ret = qemu_rdma_write_flush(f, rdma); if (ret < 0) { From 6c5b0c0ac0be8cc618dfeb7bb29d113a078dcd71 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Thu, 4 Sep 2014 22:32:46 +0800 Subject: [PATCH 4/9] xen-hvm.c: Always return -1 when failure occurs in xen_hvm_init() When failure occurs, it need to use "return -1" instead of exit(1), so an upper layer has a chance to print failure information, too. For simplicity, in xen_hvm_init(), also use '-1' instead of all '-errno', since all related upper callers always exit(1) on failure. It is not a normal function, it does not release related resources when return -1, so need give related comments for it. It passes common check: "./configure --enable-xen && make && make check" "echo $? == 0" Signed-off-by: Chen Gang Acked-by: Stefano Stabellini Signed-off-by: Michael Tokarev --- xen-hvm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xen-hvm.c b/xen-hvm.c index 38059f34ba..05e522cd73 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -979,6 +979,7 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data) xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); } +/* return 0 means OK, or -1 means critical issue -- will exit(1) */ int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size, MemoryRegion **ram_memory) { @@ -992,15 +993,13 @@ int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size, state->xce_handle = xen_xc_evtchn_open(NULL, 0); if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) { perror("xen: event channel open"); - g_free(state); - return -errno; + return -1; } state->xenstore = xs_daemon_open(); if (state->xenstore == NULL) { perror("xen: xenstore open"); - g_free(state); - return -errno; + return -1; } state->exit.notify = xen_exit_notifier; @@ -1070,7 +1069,7 @@ int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size, /* Initialize backend core & drivers */ if (xen_be_init() != 0) { fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__); - exit(1); + return -1; } xen_be_register("console", &xen_console_ops); xen_be_register("vkbd", &xen_kbdmouse_ops); From 2d5361f2a9dc17071328846dae0df0304483a34f Mon Sep 17 00:00:00 2001 From: Gonglei Date: Sat, 20 Sep 2014 15:33:18 +0800 Subject: [PATCH 5/9] configure: trivial fixes Make them consistent with the others. Cc: qemu-trivial@nongnu.org Signed-off-by: Gonglei Signed-off-by: Michael Tokarev --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 6c3d6cde14..eb9cbcdc3a 100755 --- a/configure +++ b/configure @@ -1350,7 +1350,7 @@ Advanced options (experts only): --enable-linux-aio enable Linux AIO support --disable-cap-ng disable libcap-ng support --enable-cap-ng enable libcap-ng support - --disable-attr disables attr and xattr support + --disable-attr disable attr and xattr support --enable-attr enable attr and xattr support --disable-blobs disable installing provided firmware blobs --enable-docs enable documentation build @@ -1381,7 +1381,7 @@ Advanced options (experts only): --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb) --disable-seccomp disable seccomp support - --enable-seccomp enables seccomp support + --enable-seccomp enable seccomp support --with-coroutine=BACKEND coroutine backend. Supported options: gthread, ucontext, sigaltstack, windows --disable-coroutine-pool disable coroutine freelist (worse performance) @@ -1396,7 +1396,7 @@ Advanced options (experts only): --enable-tpm enable TPM support --disable-libssh2 disable ssh block device support --enable-libssh2 enable ssh block device support - --disable-vhdx disables support for the Microsoft VHDX image format + --disable-vhdx disable support for the Microsoft VHDX image format --enable-vhdx enable support for the Microsoft VHDX image format --disable-quorum disable quorum block filter support --enable-quorum enable quorum block filter support From 4d63322cd4b3b5eba911ea98bf2050c939e432e3 Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Tue, 16 Sep 2014 18:45:36 +0800 Subject: [PATCH 6/9] vl: Print maxmem in hex format for error message In error message, maxmem is printed in Dec but ram_size in Hex. It is better to print them in same format. Also use error_report instead of fprintf. Reviewed-By: Igor Mammedov Signed-off-by: zhanghailiang Signed-off-by: Michael Tokarev --- vl.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/vl.c b/vl.c index dc792fe08b..2695842a37 100644 --- a/vl.c +++ b/vl.c @@ -3358,34 +3358,34 @@ int main(int argc, char **argv, char **envp) sz = qemu_opt_get_size(opts, "maxmem", 0); if (sz < ram_size) { - fprintf(stderr, "qemu: invalid -m option value: maxmem " - "(%" PRIu64 ") <= initial memory (" - RAM_ADDR_FMT ")\n", sz, ram_size); + error_report("invalid -m option value: maxmem " + "(0x%" PRIx64 ") <= initial memory (0x" + RAM_ADDR_FMT ")", sz, ram_size); exit(EXIT_FAILURE); } slots = qemu_opt_get_number(opts, "slots", 0); if ((sz > ram_size) && !slots) { - fprintf(stderr, "qemu: invalid -m option value: maxmem " - "(%" PRIu64 ") more than initial memory (" + error_report("invalid -m option value: maxmem " + "(0x%" PRIx64 ") more than initial memory (0x" RAM_ADDR_FMT ") but no hotplug slots where " - "specified\n", sz, ram_size); + "specified", sz, ram_size); exit(EXIT_FAILURE); } if ((sz <= ram_size) && slots) { - fprintf(stderr, "qemu: invalid -m option value: %" + error_report("invalid -m option value: %" PRIu64 " hotplug slots where specified but " - "maxmem (%" PRIu64 ") <= initial memory (" - RAM_ADDR_FMT ")\n", slots, sz, ram_size); + "maxmem (0x%" PRIx64 ") <= initial memory (0x" + RAM_ADDR_FMT ")", slots, sz, ram_size); exit(EXIT_FAILURE); } maxram_size = sz; ram_slots = slots; } else if ((!maxmem_str && slots_str) || (maxmem_str && !slots_str)) { - fprintf(stderr, "qemu: invalid -m option value: missing " - "'%s' option\n", slots_str ? "maxmem" : "slots"); + error_report("invalid -m option value: missing " + "'%s' option", slots_str ? "maxmem" : "slots"); exit(EXIT_FAILURE); } break; From a011898d25b8a26a311d56dfe37e8d3a4374ec65 Mon Sep 17 00:00:00 2001 From: Adelina Tuvenie Date: Thu, 18 Sep 2014 18:17:44 +0300 Subject: [PATCH 7/9] block: allow creation of fixed vhdx images When trying to create a fixed vhd image qemu-img will return the following error: qemu-img: test.vhdx: Could not create image: Cannot allocate memory This happens because of a incorrect check in vhdx.c. Specifficaly, in vhdx_create_bat(), after allocating memory for the BAT entry, there is a check to determine if the allocation was unsuccsessful. The error comes from the fact that it checks if s->bat isn't NULL, which is true in case of succsessful allocation, and exits with error ENOMEM. Signed-off-by: Adelina Tuvenie Acked-by: Kevin Wolf Signed-off-by: Michael Tokarev --- block/vhdx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/vhdx.c b/block/vhdx.c index 796b7bd884..5bf292e33d 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1593,7 +1593,7 @@ static int vhdx_create_bat(BlockDriverState *bs, BDRVVHDXState *s, bdrv_has_zero_init(bs) == 0) { /* for a fixed file, the default BAT entry is not zero */ s->bat = g_try_malloc0(length); - if (length && s->bat != NULL) { + if (length && s->bat == NULL) { ret = -ENOMEM; goto exit; } From e0bcc42ee723dcb973167658f9e67536fa009591 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 19 Sep 2014 22:49:03 +0200 Subject: [PATCH 8/9] pc: Add missing 'static' attribute This fixes a warning from smatch (static code analysis). Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- hw/i386/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2c2e9dcbf4..82a7daa188 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -75,7 +75,7 @@ /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables * (128K) and other BIOS datastructures (less than 4K reported to be used at * the moment, 32K should be enough for a while). */ -unsigned acpi_data_size = 0x20000 + 0x8000; +static unsigned acpi_data_size = 0x20000 + 0x8000; void pc_set_legacy_acpi_data_size(void) { acpi_data_size = 0x10000; From 7e3d523883202396ae7ff8bafcc796c86e026adc Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Sun, 21 Sep 2014 12:07:21 +0100 Subject: [PATCH 9/9] arch_init: Setting QEMU_ARCH enum straight Every QEMU_ARCH is now in (1 << n) notation, instead of a mixture of decimal and hexadecimal. Signed-off-by: Bastian Koppelmann Signed-off-by: Michael Tokarev --- include/sysemu/arch_init.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index 8939233f37..769ec069b7 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -6,23 +6,23 @@ enum { QEMU_ARCH_ALL = -1, - QEMU_ARCH_ALPHA = 1, - QEMU_ARCH_ARM = 2, - QEMU_ARCH_CRIS = 4, - QEMU_ARCH_I386 = 8, - QEMU_ARCH_M68K = 16, - QEMU_ARCH_LM32 = 32, - QEMU_ARCH_MICROBLAZE = 64, - QEMU_ARCH_MIPS = 128, - QEMU_ARCH_PPC = 256, - QEMU_ARCH_S390X = 512, - QEMU_ARCH_SH4 = 1024, - QEMU_ARCH_SPARC = 2048, - QEMU_ARCH_XTENSA = 4096, - QEMU_ARCH_OPENRISC = 8192, - QEMU_ARCH_UNICORE32 = 0x4000, - QEMU_ARCH_MOXIE = 0x8000, - QEMU_ARCH_TRICORE = 0x10000, + QEMU_ARCH_ALPHA = (1 << 0), + QEMU_ARCH_ARM = (1 << 1), + QEMU_ARCH_CRIS = (1 << 2), + QEMU_ARCH_I386 = (1 << 3), + QEMU_ARCH_M68K = (1 << 4), + QEMU_ARCH_LM32 = (1 << 5), + QEMU_ARCH_MICROBLAZE = (1 << 6), + QEMU_ARCH_MIPS = (1 << 7), + QEMU_ARCH_PPC = (1 << 8), + QEMU_ARCH_S390X = (1 << 9), + QEMU_ARCH_SH4 = (1 << 10), + QEMU_ARCH_SPARC = (1 << 11), + QEMU_ARCH_XTENSA = (1 << 12), + QEMU_ARCH_OPENRISC = (1 << 13), + QEMU_ARCH_UNICORE32 = (1 << 14), + QEMU_ARCH_MOXIE = (1 << 15), + QEMU_ARCH_TRICORE = (1 << 16), }; extern const uint32_t arch_type;