From 8f59905330ce6dbaf929e1ad1784c5e3ed7e69b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 11 Mar 2019 11:27:12 +0100 Subject: hw/net/pcnet: Use qemu_log_mask(GUEST_ERROR) instead of printf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid to clutter stdout until explicitly requested (with -d guest_errors): $ qemu-system-mips -M malta -m 512 -kernel vmlinux-3.2.0-4-4kc-malta Bad SWSTYLE=0x04 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Message-Id: <20190311102712.8572-1-philmd@redhat.com> Signed-off-by: Laurent Vivier --- hw/net/pcnet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index d9ba04bdfc..16683091c9 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -36,6 +36,7 @@ */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "hw/qdev.h" #include "net/net.h" #include "net/eth.h" @@ -1501,7 +1502,8 @@ static void pcnet_bcr_writew(PCNetState *s, uint32_t rap, uint32_t val) val |= 0x0300; break; default: - printf("Bad SWSTYLE=0x%02x\n", val & 0xff); + qemu_log_mask(LOG_GUEST_ERROR, "pcnet: Bad SWSTYLE=0x%02x\n", + val & 0xff); val = 0x0200; break; } -- cgit v1.2.3 From 6ac1fca4ef29d8deaea50b0c7a45e0e9e59ff656 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Mon, 4 Mar 2019 15:16:30 +0800 Subject: CODING_STYLE: specify the indent rule for multiline code We didn't specify the indent rule for multiline code here, which may mislead users. And in current code, the code use various styles. Add this rule in CODING_STYLE to make sure this is clear to every one. Signed-off-by: Wei Yang Suggested-by: Igor Mammedov Reviewed-by: Igor Mammedov Reviewed-by: Stefano Garzarella Message-Id: <20190304071631.27567-2-richardw.yang@linux.intel.com> Signed-off-by: Laurent Vivier --- CODING_STYLE | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/CODING_STYLE b/CODING_STYLE index ec075dedc4..90321e9c28 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -29,6 +29,45 @@ Spaces of course are superior to tabs because: Do not leave whitespace dangling off the ends of lines. +1.1 Multiline Indent + +There are several places where indent is necessary: + + - if/else + - while/for + - function definition & call + +When breaking up a long line to fit within line width, we need a proper indent +for the following lines. + +In case of if/else, while/for, align the secondary lines just after the +opening parenthesis of the first. + +For example: + + if (a == 1 && + b == 2) { + + while (a == 1 && + b == 2) { + +In case of function, there are several variants: + + * 4 spaces indent from the beginning + * align the secondary lines just after the opening parenthesis of the + first + +For example: + + do_something(x, y, + z); + + do_something(x, y, + z); + + do_something(x, do_another(y, + z)); + 2. Line width Lines should be 80 characters; try not to make them longer. -- cgit v1.2.3 From 25d68ffb6bca333ce8496eca7f438d5a93f9cd06 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Mon, 4 Mar 2019 15:16:31 +0800 Subject: CODING_STYLE: indent example code as all others MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All the example code are indented with four spaces except this one. Fix this by adding four spaces here. Signed-off-by: Wei Yang Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Igor Mammedov Reviewed-by: Stefano Garzarella Message-Id: <20190304071631.27567-3-richardw.yang@linux.intel.com> Signed-off-by: Laurent Vivier --- CODING_STYLE | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CODING_STYLE b/CODING_STYLE index 90321e9c28..cb8edcbb36 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -147,10 +147,10 @@ block to a separate function altogether. When comparing a variable for (in)equality with a constant, list the constant on the right, as in: -if (a == 1) { - /* Reads like: "If a equals 1" */ - do_something(); -} + if (a == 1) { + /* Reads like: "If a equals 1" */ + do_something(); + } Rationale: Yoda conditions (as in 'if (1 == a)') are awkward to read. Besides, good compilers already warn users when '==' is mis-typed as '=', -- cgit v1.2.3 From e8338fdbbbda84e6f8df83bfccc162f868f8faa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 26 Nov 2018 14:51:25 +0400 Subject: doc: fix the configuration path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a CONFDIR variable to show the configured sysconf path in the generated documentations (html, man pages etc). Related to: https://bugzilla.redhat.com/show_bug.cgi?id=1644985 Signed-off-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20181126105125.30973-1-marcandre.lureau@redhat.com> Signed-off-by: Laurent Vivier --- Makefile | 9 ++++++--- qemu-ga.texi | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1211e78c91..43a7a047b4 100644 --- a/Makefile +++ b/Makefile @@ -899,11 +899,14 @@ ui/shader.o: $(SRC_PATH)/ui/shader.c \ MAKEINFO=makeinfo MAKEINFOINCLUDES= -I docs -I $( $@,"GEN","$@") +docs/version.texi: $(SRC_PATH)/VERSION config-host.mak + $(call quiet-command,(\ + echo "@set VERSION $(VERSION)" && \ + echo "@set CONFDIR $(qemu_confdir)" \ + )> $@,"GEN","$@") %.html: %.texi docs/version.texi $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \ diff --git a/qemu-ga.texi b/qemu-ga.texi index 4c7a8fd163..f00ad830f2 100644 --- a/qemu-ga.texi +++ b/qemu-ga.texi @@ -30,7 +30,7 @@ set user's password @end itemize qemu-ga will read a system configuration file on startup (located at -@file{/etc/qemu/qemu-ga.conf} by default), then parse remaining +@file{@value{CONFDIR}/qemu-ga.conf} by default), then parse remaining configuration options on the command line. For the same key, the last option wins, but the lists accumulate (see below for configuration file format). @@ -58,7 +58,7 @@ file format). Enable fsfreeze hook. Accepts an optional argument that specifies script to run on freeze/thaw. Script will be called with 'freeze'/'thaw' arguments accordingly (default is - @samp{/etc/qemu/fsfreeze-hook}). If using -F with an argument, do + @samp{@value{CONFDIR}/fsfreeze-hook}). If using -F with an argument, do not follow -F with a space (for example: @samp{-F/var/run/fsfreezehook.sh}). -- cgit v1.2.3 From 66e1155a693e44adcd75ac644269c046cd8672c5 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Mon, 11 Mar 2019 16:32:34 +0800 Subject: qom: use object_new_with_type in object_new_with_propv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Function object_new_with_propv already get the Type of the object, so we could leverage object_new_with_type here. Signed-off-by: Wei Yang Reviewed-by: Marc-André Lureau Reviewed-by: Stefano Garzarella Message-Id: <20190311083234.20841-1-richardw.yang@linux.intel.com> Signed-off-by: Laurent Vivier --- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qom/object.c b/qom/object.c index e3206d6799..d3412e7fdc 100644 --- a/qom/object.c +++ b/qom/object.c @@ -679,7 +679,7 @@ Object *object_new_with_propv(const char *typename, error_setg(errp, "object type '%s' is abstract", typename); return NULL; } - obj = object_new(typename); + obj = object_new_with_type(klass->type); if (object_set_propv(obj, &local_err, vargs) < 0) { goto error; -- cgit v1.2.3 From 9c9642d09afa65b93f6fdcbd9decf13fab1d1099 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Thu, 4 Apr 2019 10:17:25 +0100 Subject: configure: fix pam test warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pam test generates a warning on Fedora 29 with -O3 compilation because the headers declare that the pam_conversation pointer to pam_start must be non-NULL. Change it to use the same 0 initialised structure as we actually use in qauthz. Signed-off-by: Dr. David Alan Gilbert Acked-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20190404091725.20595-1-dgilbert@redhat.com> Signed-off-by: Laurent Vivier --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 60719ddcc5..a2607afb34 100755 --- a/configure +++ b/configure @@ -2940,9 +2940,9 @@ if test "$auth_pam" != "no"; then int main(void) { const char *service_name = "qemu"; const char *user = "frank"; - const struct pam_conv *pam_conv = NULL; + const struct pam_conv pam_conv = { 0 }; pam_handle_t *pamh = NULL; - pam_start(service_name, user, pam_conv, &pamh); + pam_start(service_name, user, &pam_conv, &pamh); return 0; } EOF -- cgit v1.2.3 From e0048b5e7438c234cb90a06a1a6d5a93629ed43e Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 9 Apr 2019 07:33:20 +0200 Subject: Update configure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last *.aml file was removed in commit 13b1881aacc7e5018773bd545bbaf8d5476699ee. Signed-off-by: Stefan Weil Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20190409053320.14612-1-sw@weilnetz.de> Signed-off-by: Laurent Vivier --- configure | 1 - 1 file changed, 1 deletion(-) diff --git a/configure b/configure index a2607afb34..14f02452f9 100755 --- a/configure +++ b/configure @@ -7880,7 +7880,6 @@ LINKS="$LINKS python" for bios_file in \ $source_path/pc-bios/*.bin \ $source_path/pc-bios/*.lid \ - $source_path/pc-bios/*.aml \ $source_path/pc-bios/*.rom \ $source_path/pc-bios/*.dtb \ $source_path/pc-bios/*.img \ -- cgit v1.2.3 From 8603172889ccbb7b567eec54c03d9709877cc760 Mon Sep 17 00:00:00 2001 From: Aruna Jayasena Date: Tue, 9 Apr 2019 21:26:35 +0530 Subject: Header cleanups Removed unwanted includes from cpu-common.h This task was under https://wiki.qemu.org/Contribute/BiteSizedTasks Signed-off-by: Aruna Jayasena Reviewed-by: Peter Maydell Reviewed-by: Thomas Huth Message-Id: <20190409155635.10276-1-aruna.15@cse.mrt.ac.lk> [lv: fix conflict on rebase] Signed-off-by: Laurent Vivier --- include/exec/cpu-common.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 848a4b94ab..f7dbe75fbc 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -7,9 +7,6 @@ #include "exec/hwaddr.h" #endif -#include "qemu/bswap.h" -#include "qemu/queue.h" - /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ void qemu_init_cpu_list(void); void cpu_list_lock(void); -- cgit v1.2.3 From 7b71e03af98fd7b5e125d7c10f02c804fcc5e5af Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 23 Apr 2019 18:06:08 +0200 Subject: net: Print output of "-net nic, model=help" to stdout instead of stderr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are printing all other help output to stdout already (e.g. "-help", "-cpu help" and "-machine help" output). So the "-net nic,model=help" output should go to stdout instead of stderr, too. And while we're at it, also print the NICs line by line, like we do it e.g. with the "-cpu help" or "-M help" output, too. Buglink: https://bugs.launchpad.net/qemu/+bug/1574327 Signed-off-by: Thomas Huth Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20190423160608.7519-1-thuth@redhat.com> Signed-off-by: Laurent Vivier --- net/net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/net.c b/net/net.c index f3a3c5444c..2cf5e76469 100644 --- a/net/net.c +++ b/net/net.c @@ -837,9 +837,10 @@ int qemu_show_nic_models(const char *arg, const char *const *models) return 0; } - fprintf(stderr, "qemu: Supported NIC models: "); - for (i = 0 ; models[i]; i++) - fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n'); + printf("Supported NIC models:\n"); + for (i = 0 ; models[i]; i++) { + printf("%s\n", models[i]); + } return 1; } -- cgit v1.2.3 From 59100753886bcdc50e076a6d19647b8f91b1cc02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 27 Apr 2019 18:13:22 +0200 Subject: Makefile: Let the 'clean' rule remove qemu-ga.exe on Windows hosts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 48ff7a625b36 added the QEMU Guest Agent tool with the optional ".exe" suffix for Windows hosts, but forgot to use this suffix in the 'clean' rule. Calling this rule let a dangling executable in the build directory. Correct this by using the proper optional suffix. Fixes: 48ff7a625b36 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Weil Message-Id: <20190427161322.24642-1-philmd@redhat.com> Signed-off-by: Laurent Vivier --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 43a7a047b4..e223bfe2a3 100644 --- a/Makefile +++ b/Makefile @@ -639,7 +639,7 @@ clean: ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \ -exec rm {} + rm -f $(edk2-decompressed) - rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ + rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga$(EXESUF) TAGS cscope.* *.pod *~ */*~ rm -f fsdev/*.pod scsi/*.pod rm -f qemu-img-cmds.h rm -f ui/shader/*-vert.h ui/shader/*-frag.h -- cgit v1.2.3 From 9176a58018642080ec1910b2be255c2f81f1e8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sat, 27 Apr 2019 18:29:21 +0200 Subject: hw/sparc/leon3: Allow load of uImage firmwares MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the Leon3 machine doesn't allow to load legacy u-boot images: $ qemu-system-sparc -M leon3_generic -d in_asm \ -kernel HelenOS-0.6.0-sparc32-leon3.bin qemu-system-sparc: could not load kernel 'HelenOS-0.6.0-sparc32-leon3.bin' $ file HelenOS-0.6.0-sparc32-leon3.bin HelenOS-0.6.0-sparc32-leon3.bin: u-boot legacy uImage, HelenOS-0.6.0,\ Linux/ARM, OS Kernel Image (Not compressed), 2424229 bytes,\ Sun Dec 21 19:18:09 2014,\ Load Address: 0x40000000, Entry Point: 0x40000000,\ Header CRC: 0x8BCFA236, Data CRC: 0x37AD87DF Since QEMU can load uImages, add the necessary code, so the Leon3 machine can load these images: $ qemu-system-sparc -M leon3_generic -d in_asm \ -kernel HelenOS-0.6.0-sparc32-leon3.bin ---------------- IN: 0x40000000: b 0x400007a8 0x40000004: nop ---------------- IN: 0x400007a8: save %sp, -136, %sp 0x400007ac: call 0x40000020 0x400007b0: sethi %hi(0x4000b800), %i1 ... Tested with the following firmware: http://www.helenos.org/releases/HelenOS-0.6.0-sparc32-leon3.bin Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: KONRAD Frederic Tested-by: KONRAD Frederic Message-Id: <20190427162922.4207-1-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/sparc/leon3.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index 774639af33..0383b17c29 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -193,6 +193,10 @@ static void leon3_generic_hw_init(MachineState *machine) kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &entry, NULL, NULL, 1 /* big endian */, EM_SPARC, 0, 0); + if (kernel_size < 0) { + kernel_size = load_uimage(kernel_filename, NULL, &entry, + NULL, NULL, NULL); + } if (kernel_size < 0) { error_report("could not load kernel '%s'", kernel_filename); exit(1); -- cgit v1.2.3 From 2d2023c3b99edb33ad4bb9791f70456ea1a1c049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 1 May 2019 15:50:52 +0100 Subject: sockets: avoid string truncation warnings when copying UNIX path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In file included from /usr/include/string.h:494, from include/qemu/osdep.h:101, from util/qemu-sockets.c:18: In function ‘strncpy’, inlined from ‘unix_connect_saddr.isra.0’ at util/qemu-sockets.c:925:5: /usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Wstringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function ‘strncpy’, inlined from ‘unix_listen_saddr.isra.0’ at util/qemu-sockets.c:880:5: /usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Wstringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We are already validating the UNIX socket path length earlier in the functions. If we save this string length when we first check it, then we can simply use memcpy instead of strcpy later, avoiding the gcc truncation warnings. Signed-off-by: Daniel P. Berrangé Reviewed-by: Eric Blake Reviewed-by: Stefano Garzarella Message-Id: <20190501145052.12579-1-berrange@redhat.com> Signed-off-by: Laurent Vivier --- util/qemu-sockets.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 9705051690..ba6335e71a 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -830,6 +830,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, int sock, fd; char *pathbuf = NULL; const char *path; + size_t pathlen; sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { @@ -845,7 +846,8 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX", tmpdir); } - if (strlen(path) > sizeof(un.sun_path)) { + pathlen = strlen(path); + if (pathlen > sizeof(un.sun_path)) { error_setg(errp, "UNIX socket path '%s' is too long", path); error_append_hint(errp, "Path must be less than %zu bytes\n", sizeof(un.sun_path)); @@ -877,7 +879,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, memset(&un, 0, sizeof(un)); un.sun_family = AF_UNIX; - strncpy(un.sun_path, path, sizeof(un.sun_path)); + memcpy(un.sun_path, path, pathlen); if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) { error_setg_errno(errp, errno, "Failed to bind socket to %s", path); @@ -901,6 +903,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) { struct sockaddr_un un; int sock, rc; + size_t pathlen; if (saddr->path == NULL) { error_setg(errp, "unix connect: no path specified"); @@ -913,7 +916,8 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) return -1; } - if (strlen(saddr->path) > sizeof(un.sun_path)) { + pathlen = strlen(saddr->path); + if (pathlen > sizeof(un.sun_path)) { error_setg(errp, "UNIX socket path '%s' is too long", saddr->path); error_append_hint(errp, "Path must be less than %zu bytes\n", sizeof(un.sun_path)); @@ -922,7 +926,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) memset(&un, 0, sizeof(un)); un.sun_family = AF_UNIX; - strncpy(un.sun_path, saddr->path, sizeof(un.sun_path)); + memcpy(un.sun_path, saddr->path, pathlen); /* connect to peer */ do { -- cgit v1.2.3