From b5369dd841b55aa24dd107223e0a08d8624d1b19 Mon Sep 17 00:00:00 2001 From: Amos Kong Date: Tue, 25 Nov 2014 16:05:56 +0800 Subject: [PATCH 01/20] qmp: fix typo in input-send-event examples Lack of two closed bracket in json commands. Signed-off-by: Amos Kong Reviewed-by: Markus Armbruster Signed-off-by: Michael Tokarev --- qmp-commands.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qmp-commands.hx b/qmp-commands.hx index 718dd92f6a..47bcf87ee6 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3820,13 +3820,13 @@ Press left mouse button. -> { "execute": "x-input-send-event", "arguments": { "console": 0, "events": [ { "type": "btn", - "data" : { "down": true, "button": "Left" } } } } + "data" : { "down": true, "button": "Left" } } ] } } <- { "return": {} } -> { "execute": "x-input-send-event", "arguments": { "console": 0, "events": [ { "type": "btn", - "data" : { "down": false, "button": "Left" } } } } + "data" : { "down": false, "button": "Left" } } ] } } <- { "return": {} } Example (2): From 1a71992376792a0d11ea27688bd1a21cdffd1826 Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Mon, 24 Nov 2014 10:47:45 +0800 Subject: [PATCH 02/20] target-s390x: fix possible out of bounds read Array index starts at 0, so the valid index of ext_queue array, io_queue array, mchk_queue array should be MAX_EXT_QUEUE - 1, MAX_IO_QUEUE - 1, MAX_MCHK_QUEUE - 1. The original checks missed the invalid bound value, which will lead possible out of bounds read in the follow codes. Signed-off-by: zhanghailiang Signed-off-by: Michael Tokarev --- target-s390x/helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 09aec7b42e..96a4f22734 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -648,7 +648,7 @@ static void do_ext_interrupt(CPUS390XState *env) cpu_abort(CPU(cpu), "Ext int w/o ext mask\n"); } - if (env->ext_index < 0 || env->ext_index > MAX_EXT_QUEUE) { + if (env->ext_index < 0 || env->ext_index >= MAX_EXT_QUEUE) { cpu_abort(CPU(cpu), "Ext queue overrun: %d\n", env->ext_index); } @@ -696,7 +696,7 @@ static void do_io_interrupt(CPUS390XState *env) if (env->io_index[isc] < 0) { continue; } - if (env->io_index[isc] > MAX_IO_QUEUE) { + if (env->io_index[isc] >= MAX_IO_QUEUE) { cpu_abort(CPU(cpu), "I/O queue overrun for isc %d: %d\n", isc, env->io_index[isc]); } @@ -754,7 +754,7 @@ static void do_mchk_interrupt(CPUS390XState *env) cpu_abort(CPU(cpu), "Machine check w/o mchk mask\n"); } - if (env->mchk_index < 0 || env->mchk_index > MAX_MCHK_QUEUE) { + if (env->mchk_index < 0 || env->mchk_index >= MAX_MCHK_QUEUE) { cpu_abort(CPU(cpu), "Mchk queue overrun: %d\n", env->mchk_index); } From fcf55f580d4c4755dfacabd7ac86501ebbb4167e Mon Sep 17 00:00:00 2001 From: Gonglei Date: Thu, 13 Nov 2014 10:59:36 +0800 Subject: [PATCH 03/20] acpi-build: adjust indention 8 -> 4 spaces Signed-off-by: Gonglei Signed-off-by: Michael Tokarev --- hw/i386/acpi-build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index b37a397820..76dfaea880 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -273,12 +273,12 @@ build_header(GArray *linker, GArray *table_data, static inline GArray *build_alloc_array(void) { - return g_array_new(false, true /* clear */, 1); + return g_array_new(false, true /* clear */, 1); } static inline void build_free_array(GArray *array) { - g_array_free(array, true); + g_array_free(array, true); } static inline void build_prepend_byte(GArray *array, uint8_t val) From 8b310fc4f9eb2570bfb92a725bd094ce203800da Mon Sep 17 00:00:00 2001 From: Gonglei Date: Thu, 13 Nov 2014 10:59:37 +0800 Subject: [PATCH 04/20] acpi-build: Make DPRINTF working for acpi-build Signed-off-by: Gonglei Signed-off-by: Michael Tokarev --- hw/i386/acpi-build.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 76dfaea880..a4d0c0c8bf 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -68,6 +68,14 @@ #define ACPI_BUILD_TABLE_SIZE 0x20000 +/* #define DEBUG_ACPI_BUILD */ +#ifdef DEBUG_ACPI_BUILD +#define ACPI_BUILD_DPRINTF(fmt, ...) \ + do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0) +#else +#define ACPI_BUILD_DPRINTF(fmt, ...) +#endif + typedef struct AcpiCpuInfo { DECLARE_BITMAP(found_cpus, ACPI_CPU_HOTPLUG_ID_LIMIT); } AcpiCpuInfo; @@ -246,8 +254,6 @@ static void acpi_get_pci_info(PcPciInfo *info) #define ACPI_BUILD_APPNAME6 "BOCHS " #define ACPI_BUILD_APPNAME4 "BXPC" -#define ACPI_BUILD_DPRINTF(level, fmt, ...) do {} while (0) - #define ACPI_BUILD_TABLE_FILE "etc/acpi/tables" #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp" #define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log" @@ -1569,7 +1575,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) table_offsets = g_array_new(false, true /* clear */, sizeof(uint32_t)); - ACPI_BUILD_DPRINTF(3, "init ACPI tables\n"); + ACPI_BUILD_DPRINTF("init ACPI tables\n"); bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE, 64 /* Ensure FACS is aligned */, @@ -1750,17 +1756,17 @@ void acpi_setup(PcGuestInfo *guest_info) AcpiBuildState *build_state; if (!guest_info->fw_cfg) { - ACPI_BUILD_DPRINTF(3, "No fw cfg. Bailing out.\n"); + ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n"); return; } if (!guest_info->has_acpi_build) { - ACPI_BUILD_DPRINTF(3, "ACPI build disabled. Bailing out.\n"); + ACPI_BUILD_DPRINTF("ACPI build disabled. Bailing out.\n"); return; } if (!acpi_enabled) { - ACPI_BUILD_DPRINTF(3, "ACPI disabled. Bailing out.\n"); + ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n"); return; } From 2c80ab15e218a0438627c2a79d74d5a13b864e15 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Thu, 13 Nov 2014 10:39:32 +0800 Subject: [PATCH 05/20] virtio-bus: avoid breaking build when open DEBUG switch Signed-off-by: Gonglei Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael Tokarev --- hw/virtio/virtio-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index eb77019267..dfd2d8c772 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -58,7 +58,7 @@ void virtio_bus_reset(VirtioBusState *bus) { VirtIODevice *vdev = virtio_bus_get_device(bus); - DPRINTF("%s: reset device.\n", qbus->name); + DPRINTF("%s: reset device.\n", BUS(bus)->name); if (vdev != NULL) { virtio_reset(vdev); } From 7251711472a8b406640a62f25f860628d3056bb1 Mon Sep 17 00:00:00 2001 From: lijun Date: Wed, 19 Nov 2014 14:57:43 +0800 Subject: [PATCH 06/20] usb: delete redundant brackets in usb_host_handle_control() When see usb codes, find there are redundant brackets !((udev->port->speedmask & USB_SPEED_MASK_SUPER)) here. So delete it. Signed-off-by: Jun Li Reviewed-by: Fam Zheng Signed-off-by: Michael Tokarev --- hw/usb/host-libusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index a5f9dab0cd..cff4f7cd51 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1237,7 +1237,7 @@ static void usb_host_handle_control(USBDevice *udev, USBPacket *p, /* Fix up USB-3 ep0 maxpacket size to allow superspeed connected devices * to work redirected to a not superspeed capable hcd */ if (udev->speed == USB_SPEED_SUPER && - !((udev->port->speedmask & USB_SPEED_MASK_SUPER)) && + !(udev->port->speedmask & USB_SPEED_MASK_SUPER) && request == 0x8006 && value == 0x100 && index == 0) { r->usb3ep0quirk = true; } From 4ad608803c46c0acc09114a2e8352742ffd20b6b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 3 Dec 2014 11:28:02 +0100 Subject: [PATCH 07/20] Drop superfluous conditionals around qemu_opts_del() Signed-off-by: Markus Armbruster Reviewed-by: Paolo Bonzini Reviewed-by: Gonglei Signed-off-by: Michael Tokarev --- hw/core/qdev.c | 4 +--- qemu-char.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 35fd00d26c..901f289860 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1141,9 +1141,7 @@ static void device_finalize(Object *obj) NamedGPIOList *ngl, *next; DeviceState *dev = DEVICE(obj); - if (dev->opts) { - qemu_opts_del(dev->opts); - } + qemu_opts_del(dev->opts); QLIST_FOREACH_SAFE(ngl, &dev->gpios, node, next) { QLIST_REMOVE(ngl, node); diff --git a/qemu-char.c b/qemu-char.c index a8b01da3ee..ef84b53681 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3825,9 +3825,7 @@ void qemu_chr_delete(CharDriverState *chr) } g_free(chr->filename); g_free(chr->label); - if (chr->opts) { - qemu_opts_del(chr->opts); - } + qemu_opts_del(chr->opts); g_free(chr); } From 24588100ab39afead7b9a0e9c61182a02320a1b9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 4 Dec 2014 10:26:55 +0100 Subject: [PATCH 08/20] Drop superfluous conditionals around g_strdup() Signed-off-by: Markus Armbruster Reviewed-by: Fam Zheng Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- backends/rng-random.c | 6 +----- hw/tpm/tpm_passthrough.c | 4 +--- util/uri.c | 43 ++++++++++++++++------------------------ 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/backends/rng-random.c b/backends/rng-random.c index 601d9dc0c2..4f85a8ea49 100644 --- a/backends/rng-random.c +++ b/backends/rng-random.c @@ -88,11 +88,7 @@ static char *rng_random_get_filename(Object *obj, Error **errp) { RndRandom *s = RNG_RANDOM(obj); - if (s->filename) { - return g_strdup(s->filename); - } - - return NULL; + return g_strdup(s->filename); } static void rng_random_set_filename(Object *obj, const char *filename, diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 56e9e0f8a2..2bf3c6fd61 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -400,9 +400,7 @@ static int tpm_passthrough_handle_device_opts(QemuOpts *opts, TPMBackend *tb) const char *value; value = qemu_opt_get(opts, "cancel-path"); - if (value) { - tb->cancel_path = g_strdup(value); - } + tb->cancel_path = g_strdup(value); value = qemu_opt_get(opts, "path"); if (!value) { diff --git a/util/uri.c b/util/uri.c index e348c1768c..bbf2832b3c 100644 --- a/util/uri.c +++ b/util/uri.c @@ -1736,24 +1736,21 @@ uri_resolve(const char *uri, const char *base) { goto done; if ((ref->scheme == NULL) && (ref->path == NULL) && ((ref->authority == NULL) && (ref->server == NULL))) { - if (bas->scheme != NULL) - res->scheme = g_strdup(bas->scheme); + res->scheme = g_strdup(bas->scheme); if (bas->authority != NULL) res->authority = g_strdup(bas->authority); else if (bas->server != NULL) { - res->server = g_strdup(bas->server); - if (bas->user != NULL) - res->user = g_strdup(bas->user); - res->port = bas->port; + res->server = g_strdup(bas->server); + res->user = g_strdup(bas->user); + res->port = bas->port; } - if (bas->path != NULL) - res->path = g_strdup(bas->path); - if (ref->query != NULL) + res->path = g_strdup(bas->path); + if (ref->query != NULL) { res->query = g_strdup (ref->query); - else if (bas->query != NULL) - res->query = g_strdup(bas->query); - if (ref->fragment != NULL) - res->fragment = g_strdup(ref->fragment); + } else { + res->query = g_strdup(bas->query); + } + res->fragment = g_strdup(ref->fragment); goto step_7; } @@ -1767,13 +1764,10 @@ uri_resolve(const char *uri, const char *base) { val = uri_to_string(ref); goto done; } - if (bas->scheme != NULL) - res->scheme = g_strdup(bas->scheme); + res->scheme = g_strdup(bas->scheme); - if (ref->query != NULL) - res->query = g_strdup(ref->query); - if (ref->fragment != NULL) - res->fragment = g_strdup(ref->fragment); + res->query = g_strdup(ref->query); + res->fragment = g_strdup(ref->fragment); /* * 4) If the authority component is defined, then the reference is a @@ -1787,20 +1781,17 @@ uri_resolve(const char *uri, const char *base) { res->authority = g_strdup(ref->authority); else { res->server = g_strdup(ref->server); - if (ref->user != NULL) - res->user = g_strdup(ref->user); + res->user = g_strdup(ref->user); res->port = ref->port; } - if (ref->path != NULL) - res->path = g_strdup(ref->path); + res->path = g_strdup(ref->path); goto step_7; } if (bas->authority != NULL) res->authority = g_strdup(bas->authority); else if (bas->server != NULL) { - res->server = g_strdup(bas->server); - if (bas->user != NULL) - res->user = g_strdup(bas->user); + res->server = g_strdup(bas->server); + res->user = g_strdup(bas->user); res->port = bas->port; } From 44c2286b5df1f50fc9fedabd7b1a5a8022e583fc Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 4 Dec 2014 15:00:01 +0100 Subject: [PATCH 09/20] util: Drop superfluous conditionals around g_free() Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Fam Zheng Signed-off-by: Michael Tokarev --- util/uri.c | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/util/uri.c b/util/uri.c index bbf2832b3c..01dc09effb 100644 --- a/util/uri.c +++ b/util/uri.c @@ -225,7 +225,7 @@ rfc3986_parse_scheme(URI *uri, const char **str) { while (ISA_ALPHA(cur) || ISA_DIGIT(cur) || (*cur == '+') || (*cur == '-') || (*cur == '.')) cur++; if (uri != NULL) { - if (uri->scheme != NULL) g_free(uri->scheme); + g_free(uri->scheme); uri->scheme = g_strndup(*str, cur - *str); } *str = cur; @@ -262,8 +262,7 @@ rfc3986_parse_fragment(URI *uri, const char **str) ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) NEXT(cur); if (uri != NULL) { - if (uri->fragment != NULL) - g_free(uri->fragment); + g_free(uri->fragment); if (uri->cleanup & 2) uri->fragment = g_strndup(*str, cur - *str); else @@ -298,8 +297,7 @@ rfc3986_parse_query(URI *uri, const char **str) ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) NEXT(cur); if (uri != NULL) { - if (uri->query != NULL) - g_free (uri->query); + g_free(uri->query); uri->query = g_strndup (*str, cur - *str); } *str = cur; @@ -360,7 +358,7 @@ rfc3986_parse_user_info(URI *uri, const char **str) NEXT(cur); if (*cur == '@') { if (uri != NULL) { - if (uri->user != NULL) g_free(uri->user); + g_free(uri->user); if (uri->cleanup & 2) uri->user = g_strndup(*str, cur - *str); else @@ -473,9 +471,9 @@ not_ipv4: NEXT(cur); found: if (uri != NULL) { - if (uri->authority != NULL) g_free(uri->authority); + g_free(uri->authority); uri->authority = NULL; - if (uri->server != NULL) g_free(uri->server); + g_free(uri->server); if (cur != host) { if (uri->cleanup & 2) uri->server = g_strndup(host, cur - host); @@ -585,7 +583,7 @@ rfc3986_parse_path_ab_empty(URI *uri, const char **str) if (ret != 0) return(ret); } if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); if (*str != cur) { if (uri->cleanup & 2) uri->path = g_strndup(*str, cur - *str); @@ -631,7 +629,7 @@ rfc3986_parse_path_absolute(URI *uri, const char **str) } } if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); if (cur != *str) { if (uri->cleanup & 2) uri->path = g_strndup(*str, cur - *str); @@ -673,7 +671,7 @@ rfc3986_parse_path_rootless(URI *uri, const char **str) if (ret != 0) return(ret); } if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); if (cur != *str) { if (uri->cleanup & 2) uri->path = g_strndup(*str, cur - *str); @@ -715,7 +713,7 @@ rfc3986_parse_path_no_scheme(URI *uri, const char **str) if (ret != 0) return(ret); } if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); if (cur != *str) { if (uri->cleanup & 2) uri->path = g_strndup(*str, cur - *str); @@ -769,7 +767,7 @@ rfc3986_parse_hier_part(URI *uri, const char **str) } else { /* path-empty is effectively empty */ if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); uri->path = NULL; } } @@ -812,7 +810,7 @@ rfc3986_parse_relative_ref(URI *uri, const char *str) { } else { /* path-empty is effectively empty */ if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); uri->path = NULL; } } @@ -1285,21 +1283,21 @@ static void uri_clean(URI *uri) { if (uri == NULL) return; - if (uri->scheme != NULL) g_free(uri->scheme); + g_free(uri->scheme); uri->scheme = NULL; - if (uri->server != NULL) g_free(uri->server); + g_free(uri->server); uri->server = NULL; - if (uri->user != NULL) g_free(uri->user); + g_free(uri->user); uri->user = NULL; - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); uri->path = NULL; - if (uri->fragment != NULL) g_free(uri->fragment); + g_free(uri->fragment); uri->fragment = NULL; - if (uri->opaque != NULL) g_free(uri->opaque); + g_free(uri->opaque); uri->opaque = NULL; - if (uri->authority != NULL) g_free(uri->authority); + g_free(uri->authority); uri->authority = NULL; - if (uri->query != NULL) g_free(uri->query); + g_free(uri->query); uri->query = NULL; } @@ -1711,10 +1709,8 @@ uri_resolve(const char *uri, const char *base) { /* * the base fragment must be ignored */ - if (bas->fragment != NULL) { - g_free(bas->fragment); - bas->fragment = NULL; - } + g_free(bas->fragment); + bas->fragment = NULL; val = uri_to_string(bas); goto done; } From 9be71be5bda27b068176ab9b982cf3d7d41a4acd Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 4 Dec 2014 15:00:02 +0100 Subject: [PATCH 10/20] util: Fuse g_malloc(); memset() into g_new0() Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Fam Zheng Signed-off-by: Michael Tokarev --- util/uri.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/uri.c b/util/uri.c index 01dc09effb..918d23516d 100644 --- a/util/uri.c +++ b/util/uri.c @@ -1004,8 +1004,7 @@ URI * uri_new(void) { URI *ret; - ret = (URI *) g_malloc(sizeof(URI)); - memset(ret, 0, sizeof(URI)); + ret = g_new0(URI, 1); return(ret); } From e1cf5582644ef63528993fb2b88dd3b43b9914c6 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 4 Dec 2014 15:00:03 +0100 Subject: [PATCH 11/20] util: Use g_new() & friends where that makes obvious sense g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Fam Zheng Signed-off-by: Michael Tokarev --- util/hbitmap.c | 4 ++-- util/iov.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/util/hbitmap.c b/util/hbitmap.c index b3060e6976..ab139717f5 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -373,7 +373,7 @@ void hbitmap_free(HBitmap *hb) HBitmap *hbitmap_alloc(uint64_t size, int granularity) { - HBitmap *hb = g_malloc0(sizeof (struct HBitmap)); + HBitmap *hb = g_new0(struct HBitmap, 1); unsigned i; assert(granularity >= 0 && granularity < 64); @@ -384,7 +384,7 @@ HBitmap *hbitmap_alloc(uint64_t size, int granularity) hb->granularity = granularity; for (i = HBITMAP_LEVELS; i-- > 0; ) { size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1); - hb->levels[i] = g_malloc0(size * sizeof(unsigned long)); + hb->levels[i] = g_new0(unsigned long, size); } /* We necessarily have free bits in level 0 due to the definition diff --git a/util/iov.c b/util/iov.c index 24566c8789..2fb18e6654 100644 --- a/util/iov.c +++ b/util/iov.c @@ -253,7 +253,7 @@ unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint) { - qiov->iov = g_malloc(alloc_hint * sizeof(struct iovec)); + qiov->iov = g_new(struct iovec, alloc_hint); qiov->niov = 0; qiov->nalloc = alloc_hint; qiov->size = 0; @@ -277,7 +277,7 @@ void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len) if (qiov->niov == qiov->nalloc) { qiov->nalloc = 2 * qiov->nalloc + 1; - qiov->iov = g_realloc(qiov->iov, qiov->nalloc * sizeof(struct iovec)); + qiov->iov = g_renew(struct iovec, qiov->iov, qiov->nalloc); } qiov->iov[qiov->niov].iov_base = base; qiov->iov[qiov->niov].iov_len = len; From 8ccefb91bf0b4be7a7434c55dae77ed3acb39f68 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Thu, 4 Dec 2014 14:18:16 +0800 Subject: [PATCH 12/20] configure: Replace which(1) with "has" Using "has" is more slick because which(1) is not always there. Signed-off-by: Fam Zheng Reviewed-by: Stefan Weil Reviewed-by: Amos Kong Signed-off-by: Michael Tokarev --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 47048f0086..cae588c128 100755 --- a/configure +++ b/configure @@ -2727,7 +2727,7 @@ fi if test "$modules" = yes; then shacmd_probe="sha1sum sha1 shasum" for c in $shacmd_probe; do - if which $c >/dev/null 2>&1; then + if has $c; then shacmd="$c" break fi From 80b57dda897f541dcaa66369241eebc6f2a18a78 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 22 Oct 2014 14:28:38 +0200 Subject: [PATCH 13/20] get_maintainer.pl: Remove the --git-chief-penguins option Linus likely does not want to get e-mails about QEMU, so let's just remove this option. Suggested-by: Michael S. Tsirkin Signed-off-by: Thomas Huth Reviewed-by: Don Slutz Signed-off-by: Michael Tokarev --- scripts/get_maintainer.pl | 45 +-------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index af68c6c92d..f39630eb3d 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -23,7 +23,6 @@ my $email_usename = 1; my $email_maintainer = 1; my $email_list = 1; my $email_subscriber_list = 0; -my $email_git_penguin_chiefs = 0; my $email_git = 0; my $email_git_all_signature_types = 0; my $email_git_blame = 0; @@ -60,21 +59,6 @@ my $exit = 0; my %commit_author_hash; my %commit_signer_hash; -my @penguin_chief = (); -push(@penguin_chief, "Linus Torvalds:torvalds\@linux-foundation.org"); -#Andrew wants in on most everything - 2009/01/14 -#push(@penguin_chief, "Andrew Morton:akpm\@linux-foundation.org"); - -my @penguin_chief_names = (); -foreach my $chief (@penguin_chief) { - if ($chief =~ m/^(.*):(.*)/) { - my $chief_name = $1; - my $chief_addr = $2; - push(@penguin_chief_names, $chief_name); - } -} -my $penguin_chiefs = "\(" . join("|", @penguin_chief_names) . "\)"; - # Signature types of people who are either # a) responsible for the code in question, or # b) familiar enough with it to give relevant feedback @@ -187,7 +171,6 @@ if (!GetOptions( 'git-blame!' => \$email_git_blame, 'git-blame-signatures!' => \$email_git_blame_signatures, 'git-fallback!' => \$email_git_fallback, - 'git-chief-penguins!' => \$email_git_penguin_chiefs, 'git-min-signatures=i' => \$email_git_min_signatures, 'git-max-maintainers=i' => \$email_git_max_maintainers, 'git-min-percent=i' => \$email_git_min_percent, @@ -256,7 +239,7 @@ if ($sections) { if ($email && ($email_maintainer + $email_list + $email_subscriber_list + - $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) { + $email_git + $email_git_blame) == 0) { die "$P: Please select at least 1 email option\n"; } @@ -671,19 +654,6 @@ sub get_maintainers { } } - foreach my $chief (@penguin_chief) { - if ($chief =~ m/^(.*):(.*)/) { - my $email_address; - - $email_address = format_email($1, $2, $email_usename); - if ($email_git_penguin_chiefs) { - push(@email_to, [$email_address, 'chief penguin']); - } else { - @email_to = grep($_->[0] !~ /${email_address}/, @email_to); - } - } - } - foreach my $email (@file_emails) { my ($name, $address) = parse_email($email); @@ -740,7 +710,6 @@ MAINTAINER field selection options: --git-all-signature-types => include signers regardless of signature type or use only ${signature_pattern} signers (default: $email_git_all_signature_types) --git-fallback => use git when no exact MAINTAINERS pattern (default: $email_git_fallback) - --git-chief-penguins => include ${penguin_chiefs} --git-min-signatures => number of signatures required (default: $email_git_min_signatures) --git-max-maintainers => maximum maintainers to add (default: $email_git_max_maintainers) --git-min-percent => minimum percentage of commits required (default: $email_git_min_percent) @@ -1281,10 +1250,6 @@ sub vcs_find_signers { save_commits_by_author(@lines) if ($interactive); save_commits_by_signer(@lines) if ($interactive); - if (!$email_git_penguin_chiefs) { - @signatures = grep(!/${penguin_chiefs}/i, @signatures); - } - my ($types_ref, $signers_ref) = extract_formatted_signatures(@signatures); return ($commits, @$signers_ref); @@ -1296,10 +1261,6 @@ sub vcs_find_author { @lines = &{$VCS_cmds{"execute_cmd"}}($cmd); - if (!$email_git_penguin_chiefs) { - @lines = grep(!/${penguin_chiefs}/i, @lines); - } - return @lines if !@lines; my @authors = (); @@ -1925,10 +1886,6 @@ sub vcs_file_blame { @lines = &{$VCS_cmds{"execute_cmd"}}($cmd); - if (!$email_git_penguin_chiefs) { - @lines = grep(!/${penguin_chiefs}/i, @lines); - } - last if !@lines; my @authors = (); From d504fb4cecdb7c6f3b18c4d83296e84b6e970595 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Mon, 8 Dec 2014 19:52:41 +0800 Subject: [PATCH 14/20] fw_cfg: remove superfluous blank line Signed-off-by: Gonglei Signed-off-by: Michael Tokarev --- hw/nvram/fw_cfg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index a7122ee56b..c4b78ed36c 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -621,7 +621,6 @@ static void fw_cfg_realize(DeviceState *dev, Error **errp) FWCfgState *s = FW_CFG(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - if (s->ctl_iobase + 1 == s->data_iobase) { sysbus_add_io(sbd, s->ctl_iobase, &s->comb_iomem); } else { From 1c854067b31a7764fa346ea74e0f0fa0ae718458 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Mon, 8 Dec 2014 19:40:19 +0800 Subject: [PATCH 15/20] qapi-schema: fix typo about change-vnc-password Signed-off-by: Gonglei Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- qapi-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi-schema.json b/qapi-schema.json index 9ffdcf8e85..563b4ad98a 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1533,7 +1533,7 @@ # # Change the VNC server password. # -# @target: the new password to use with VNC authentication +# @password: the new password to use with VNC authentication # # Since: 1.1 # From 7766aa0c0e9e1b84c80c3a8168c6d97c4a3d49b8 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Tue, 9 Dec 2014 10:09:22 +0800 Subject: [PATCH 16/20] virtio: remove useless declaration of virtio_net_init() commit 1773d9ee (virtio-net: cleanup: init and exit function) removed the definition of virtio_net_init(), but didn't remove its declaration in the header. Clean that up. Cc: Markus Armbruster Signed-off-by: Gonglei Reviewed-by: Markus Armbruster Signed-off-by: Michael Tokarev --- include/hw/virtio/virtio.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 0726d76f49..f24997d218 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -230,9 +230,6 @@ int virtio_set_features(VirtIODevice *vdev, uint32_t val); /* Base devices. */ typedef struct VirtIOBlkConf VirtIOBlkConf; struct virtio_net_conf; -VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf, - struct virtio_net_conf *net, - uint32_t host_features); typedef struct virtio_serial_conf virtio_serial_conf; typedef struct VirtIOSCSIConf VirtIOSCSIConf; typedef struct VirtIORNGConf VirtIORNGConf; From b196d969efa3987148994f0f8da79a10ebda7641 Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Tue, 9 Dec 2014 15:15:59 +0800 Subject: [PATCH 17/20] vt82c686: fix coverity warning about out-of-bounds write Refactor superio_ioport_writeb to fix the out of bounds write warning. In addition, fix two typos: s/chage/change/ Signed-off-by: zhanghailiang Signed-off-by: Michael Tokarev --- hw/isa/vt82c686.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index e0c235c3c2..223b947939 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -50,13 +50,13 @@ typedef struct VT82C686BState { static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data, unsigned size) { - int can_write; SuperIOConfig *superio_conf = opaque; DPRINTF("superio_ioport_writeb address 0x%x val 0x%x\n", addr, data); if (addr == 0x3f0) { superio_conf->index = data & 0xff; } else { + bool can_write = true; /* 0x3f1 */ switch (superio_conf->index) { case 0x00 ... 0xdf: @@ -68,30 +68,27 @@ static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data, case 0xf7: case 0xf9 ... 0xfb: case 0xfd ... 0xff: - can_write = 0; + can_write = false; + break; + case 0xe7: + if ((data & 0xff) != 0xfe) { + DPRINTF("change uart 1 base. unsupported yet\n"); + can_write = false; + } + break; + case 0xe8: + if ((data & 0xff) != 0xbe) { + DPRINTF("change uart 2 base. unsupported yet\n"); + can_write = false; + } break; default: - can_write = 1; + break; - if (can_write) { - switch (superio_conf->index) { - case 0xe7: - if ((data & 0xff) != 0xfe) { - DPRINTF("chage uart 1 base. unsupported yet\n"); - } - break; - case 0xe8: - if ((data & 0xff) != 0xbe) { - DPRINTF("chage uart 2 base. unsupported yet\n"); - } - break; - - default: - superio_conf->config[superio_conf->index] = data & 0xff; - } - } } - superio_conf->config[superio_conf->index] = data & 0xff; + if (can_write) { + superio_conf->config[superio_conf->index] = data & 0xff; + } } } From df6f93182a898c295d90dd502d49818c6bb98200 Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Sun, 7 Dec 2014 21:20:45 +0300 Subject: [PATCH 18/20] pflash_cfi02.c: associate "cfi.pflash02" to "Storage devices" category Signed-off-by: Antony Pavlov Signed-off-by: Michael Tokarev --- hw/block/pflash_cfi02.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index 8513a17e9f..389b4aa1f4 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -744,6 +744,7 @@ static void pflash_cfi02_class_init(ObjectClass *klass, void *data) dc->realize = pflash_cfi02_realize; dc->props = pflash_cfi02_properties; + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } static const TypeInfo pflash_cfi02_info = { From 97c61fb78ad22bbedc34da2af1db2fd9aa1cbff9 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Thu, 11 Dec 2014 09:18:29 +0000 Subject: [PATCH 19/20] hpet: increase spelling precision Signed-off-by: Stefan Hajnoczi Signed-off-by: Michael Tokarev --- hw/timer/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index e160e8facc..d8bc231e5b 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -1,5 +1,5 @@ /* - * High Precisition Event Timer emulation + * High Precision Event Timer emulation * * Copyright (c) 2007 Alexander Graf * Copyright (c) 2008 IBM Corporation From 64baadc2726ae929660dd0c61a42e8d9f3ba1828 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Thu, 11 Dec 2014 11:46:36 +0000 Subject: [PATCH 20/20] Sort include/qemu/typedefs.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mainly to make it less likely to conflict during merges. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Alex Bennée Signed-off-by: Michael Tokarev --- include/qemu/typedefs.h | 107 +++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 34751778a3..57ff47f284 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -3,80 +3,75 @@ /* 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 QEMUTimerListGroup QEMUTimerListGroup; -typedef struct QEMUFile QEMUFile; -typedef struct QEMUBH QEMUBH; - -typedef struct AioContext AioContext; - -typedef struct Visitor Visitor; - 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; +/* Please keep this list in alphabetical order */ +typedef struct AdapterInfo AdapterInfo; typedef struct AddressSpace AddressSpace; -typedef struct MemoryRegion MemoryRegion; -typedef struct MemoryRegionSection MemoryRegionSection; -typedef struct MemoryListener MemoryListener; - -typedef struct MemoryMappingList MemoryMappingList; - -typedef struct QEMUMachine QEMUMachine; -typedef struct MachineClass MachineClass; -typedef struct MachineState MachineState; -typedef struct NICInfo NICInfo; -typedef struct HCIInfo HCIInfo; +typedef struct AioContext AioContext; typedef struct AudioState AudioState; typedef struct BlockBackend BlockBackend; 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 BusClass BusClass; +typedef struct BusState BusState; typedef struct CharDriverState CharDriverState; -typedef struct MACAddr MACAddr; -typedef struct NetClientState NetClientState; +typedef struct CompatProperty CompatProperty; +typedef struct DeviceState DeviceState; +typedef struct DisplayChangeListener DisplayChangeListener; +typedef struct DisplayState DisplayState; +typedef struct DisplaySurface DisplaySurface; +typedef struct DriveInfo DriveInfo; +typedef struct EventNotifier EventNotifier; +typedef struct FWCfgState FWCfgState; +typedef struct HCIInfo HCIInfo; typedef struct I2CBus I2CBus; +typedef struct I2SCodec I2SCodec; typedef struct ISABus ISABus; typedef struct ISADevice ISADevice; -typedef struct SMBusDevice SMBusDevice; -typedef struct PCIHostState PCIHostState; -typedef struct PCIExpressHost PCIExpressHost; +typedef struct MACAddr MACAddr; +typedef struct MachineClass MachineClass; +typedef struct MachineState MachineState; +typedef struct MemoryListener MemoryListener; +typedef struct MemoryMappingList MemoryMappingList; +typedef struct MemoryRegion MemoryRegion; +typedef struct MemoryRegionSection MemoryRegionSection; +typedef struct MigrationParams MigrationParams; +typedef struct Monitor Monitor; +typedef struct MouseTransformInfo MouseTransformInfo; +typedef struct MSIMessage MSIMessage; +typedef struct NetClientState NetClientState; +typedef struct NICInfo NICInfo; +typedef struct PcGuestInfo PcGuestInfo; +typedef struct PCIBridge PCIBridge; 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 PCIEAERLog PCIEAERLog; +typedef struct PCIEAERMsg PCIEAERMsg; typedef struct PCIEPort PCIEPort; typedef struct PCIESlot PCIESlot; -typedef struct MSIMessage MSIMessage; -typedef struct SerialState SerialState; +typedef struct PCIExpressDevice PCIExpressDevice; +typedef struct PCIExpressHost PCIExpressHost; +typedef struct PCIHostState PCIHostState; 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 PixelFormat PixelFormat; +typedef struct PropertyInfo PropertyInfo; +typedef struct Property Property; +typedef struct QEMUBH QEMUBH; +typedef struct QemuConsole QemuConsole; +typedef struct QEMUFile QEMUFile; +typedef struct QEMUMachine QEMUMachine; typedef struct QEMUSGList QEMUSGList; typedef struct QEMUSizedBuffer QEMUSizedBuffer; -typedef struct SHPCDevice SHPCDevice; -typedef struct FWCfgState FWCfgState; -typedef struct PcGuestInfo PcGuestInfo; +typedef struct QEMUTimerListGroup QEMUTimerListGroup; +typedef struct QEMUTimer QEMUTimer; typedef struct Range Range; -typedef struct AdapterInfo AdapterInfo; +typedef struct SerialState SerialState; +typedef struct SHPCDevice SHPCDevice; +typedef struct SMBusDevice SMBusDevice; +typedef struct SSIBus SSIBus; +typedef struct uWireSlave uWireSlave; +typedef struct VirtIODevice VirtIODevice; +typedef struct Visitor Visitor; #endif /* QEMU_TYPEDEFS_H */