summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-08-03vnc: don't crash getting server info if lsock is NULLDaniel P. Berrange1-0/+5
When VNC is started with '-vnc none' there will be no listener socket present. When we try to populate the VncServerInfo we'll crash accessing a NULL 'lsock' field. #0 qio_channel_socket_get_local_address (ioc=0x0, errp=errp@entry=0x7ffd5b8aa0f0) at io/channel-socket.c:33 #1 0x00007f4b9a297d6f in vnc_init_basic_info_from_server_addr (errp=0x7ffd5b8aa0f0, info=0x7f4b9d425460, ioc=<optimized out>) at ui/vnc.c:146 #2 vnc_server_info_get (vd=0x7f4b9e858000) at ui/vnc.c:223 #3 0x00007f4b9a29d318 in vnc_qmp_event (vs=0x7f4b9ef82000, vs=0x7f4b9ef82000, event=QAPI_EVENT_VNC_CONNECTED) at ui/vnc.c:279 #4 vnc_connect (vd=vd@entry=0x7f4b9e858000, sioc=sioc@entry=0x7f4b9e8b3a20, skipauth=skipauth@entry=true, websocket=websocket @entry=false) at ui/vnc.c:2994 #5 0x00007f4b9a29e8c8 in vnc_display_add_client (id=<optimized out>, csock=<optimized out>, skipauth=<optimized out>) at ui/v nc.c:3825 #6 0x00007f4b9a18d8a1 in qmp_marshal_add_client (args=<optimized out>, ret=<optimized out>, errp=0x7ffd5b8aa230) at qmp-marsh al.c:123 #7 0x00007f4b9a0b53f5 in handle_qmp_command (parser=<optimized out>, tokens=<optimized out>) at /usr/src/debug/qemu-2.6.0/mon itor.c:3922 #8 0x00007f4b9a348580 in json_message_process_token (lexer=0x7f4b9c78dfe8, input=0x7f4b9c7350e0, type=JSON_RCURLY, x=111, y=5 9) at qobject/json-streamer.c:94 #9 0x00007f4b9a35cfeb in json_lexer_feed_char (lexer=lexer@entry=0x7f4b9c78dfe8, ch=125 '}', flush=flush@entry=false) at qobj ect/json-lexer.c:310 #10 0x00007f4b9a35d0ae in json_lexer_feed (lexer=0x7f4b9c78dfe8, buffer=<optimized out>, size=<optimized out>) at qobject/json -lexer.c:360 #11 0x00007f4b9a348679 in json_message_parser_feed (parser=<optimized out>, buffer=<optimized out>, size=<optimized out>) at q object/json-streamer.c:114 #12 0x00007f4b9a0b3a1b in monitor_qmp_read (opaque=<optimized out>, buf=<optimized out>, size=<optimized out>) at /usr/src/deb ug/qemu-2.6.0/monitor.c:3938 #13 0x00007f4b9a186751 in tcp_chr_read (chan=<optimized out>, cond=<optimized out>, opaque=0x7f4b9c7add40) at qemu-char.c:2895 #14 0x00007f4b92b5c79a in g_main_context_dispatch () from /lib64/libglib-2.0.so.0 #15 0x00007f4b9a2bb0c0 in glib_pollfds_poll () at main-loop.c:213 #16 os_host_main_loop_wait (timeout=<optimized out>) at main-loop.c:258 #17 main_loop_wait (nonblocking=<optimized out>) at main-loop.c:506 #18 0x00007f4b9a0835cf in main_loop () at vl.c:1934 #19 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4667 Do an upfront check for a NULL lsock and report an error to the caller, which matches behaviour from before commit 04d2529da27db512dcbd5e99d0e26d333f16efcc Author: Daniel P. Berrange <berrange@redhat.com> Date: Fri Feb 27 16:20:57 2015 +0000 ui: convert VNC server to use QIOChannelSocket where getsockname() would be given a FD value -1 and thus report an error to the caller. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1470134726-15697-2-git-send-email-berrange@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2016-08-01MAINTAINERS: Update the Xilinx maintainersAlistair Francis1-16/+14
Update the Xilinx maintainers documentation to simplify what we maintain and cover all of our upstream code. Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-08-01Fix bsd-user build errors after 8642c1b81e0418df066a7960a7426d85a923a253Sean Bruno1-2/+2
LINK sparc-bsd-user/qemu-sparc bsd-user/main.o: In function `cpu_loop': /home/sbruno/bsd/qemu/bsd-user/main.c:515: undefined reference to `cpu_sparc_exec' c++: error: linker command failed with exit code 1 (use -v to see invocation) gmake[1]: *** [Makefile:197: qemu-sparc] Error 1 gmake: *** [Makefile:204: subdir-sparc-bsd-user] Error 2 LINK i386-bsd-user/qemu-i386 bsd-user/main.o: In function `cpu_loop': /home/sbruno/bsd/qemu/bsd-user/main.c:174: undefined reference to `cpu_x86_exec' c++: error: linker command failed with exit code 1 (use -v to see invocation) gmake[1]: *** [Makefile:197: qemu-i386] Error 1 gmake: *** [Makefile:204: subdir-i386-bsd-user] Error 2 Signed-off-by: Sean Bruno <sbruno@freebsd.org> Message-id: 20160729160235.64525-1-sbruno@freebsd.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-29Update version for v2.7.0-rc1 releasePeter Maydell1-1/+1
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-29avx2 configure: Disable if static buildAaron Lindsay1-7/+10
This avoids a segfault like the following for at least some 4.8 versions of gcc when configured with --static if avx2 instructions are also enabled: Program received signal SIGSEGV, Segmentation fault. buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333 333 { (gdb) bt #0 buffer_find_nonzero_offset_ifunc () at ./util/cutils.c:333 #1 0x0000000000939c58 in __libc_start_main () #2 0x0000000000419337 in _start () Signed-off-by: Aaron Lindsay <alindsay@codeaurora.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-29Unbreak FreeBSD build after optionrom update.Sean Bruno1-0/+4
Update the build flags appropriately for FreeBSD and add the correct LD_EMULATION type for the FreeBSD build case. Fixes FreeBSD build error: ld: unrecognised emulation mode: elf_i386 Supported emulations: elf_x86_64_fbsd elf_i386_fbsd gmake[1]: *** [Makefile:51: linuxboot_dma.img] Error 1 gmake: *** [Makefile:229: romsubdir-optionrom] Error 2 Signed-off-by: Sean Bruno <sbruno@freebsd.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-29optionrom: fix detection of -Wa,-32Paolo Bonzini2-1/+3
The cc-option macro runs $(CC) in -S mode (generate assembly) to avoid a pointless run of the assembler. However, this does not work when you want to detect support for cc->as option passthrough. clang ignores -Wa unless -c is provided, and exits successfully even if the -Wa,-32 option is not supported. Reported-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1469043409-14033-1-git-send-email-pbonzini@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-29Merge remote-tracking branch 'remotes/lalrae/tags/mips-20160729' into stagingPeter Maydell2-1/+2
MIPS patches 2016-07-29 Changes: * bug fixes # gpg: Signature made Fri 29 Jul 2016 09:44:13 BST # gpg: using RSA key 0x52118E3C0B29DA6B # gpg: Good signature from "Leon Alrae <leon.alrae@imgtec.com>" # Primary key fingerprint: 8DD3 2F98 5495 9D66 35D4 4FC0 5211 8E3C 0B29 DA6B * remotes/lalrae/tags/mips-20160729: target-mips: fix EntryHi.EHINV being cleared on TLB exception hw/mips_malta: Fix YAMON API print routine Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-29Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.7-20160729' ↵Peter Maydell5-48/+122
into staging ppc patch queue 2016-07-29 Here are the current pending ppc and spapr related patches for qemu-2.7. Given the freeze status, these are all bugfixes, with two exceptions: * There's some final rework of the vcpu hotplug model. Specifically we add spapr specific code on the generic basis Igor established to make cpu_index stable for pseries-2.7 and later machine types. - This allows us to remove the limitation that cpu cores had to be inserted in linear order, and removed in LIFO order. - This is worth merging this late in 2.7 because it will avoid considerable future grief with management layers needing to discover whether out-of-order hotplug is possible, amongst other things. - For now we do add a constraint that the initial cpu cannot be unplugged. * We add two extra testcases to make check, for postcopy and drive_del on ppc64. - Not strictly bugfixes, but safe, because they don't affect the actual code, and increase test coverage. # gpg: Signature made Fri 29 Jul 2016 05:50:02 BST # gpg: using RSA key 0x6C38CACA20D9B392 # gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>" # gpg: aka "David Gibson (Red Hat) <dgibson@redhat.com>" # gpg: aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>" # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 75F4 6586 AE61 A66C C44E 87DC 6C38 CACA 20D9 B392 * remotes/dgibson/tags/ppc-for-2.7-20160729: tests: add drive_del-test to ppc/ppc64 spapr: Prevent boot CPU core removal ppc: Fix fault PC reporting for lve*/stve* VMX instructions test: port postcopy test to ppc64 Revert "spapr: Ensure CPU cores are added contiguously and removed in LIFO order" spapr: init CPUState->cpu_index with index relative to core-id Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-29Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into stagingPeter Maydell24-252/+486
pc, pci, virtio: cleanups, fixes a bunch of bugfixes and a couple of cleanups making these easier and/or making debugging easier Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Fri 29 Jul 2016 04:11:01 BST # gpg: using RSA key 0x281F0DB8D28D5469 # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" # gpg: aka "Michael S. Tsirkin <mst@redhat.com>" # Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67 # Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469 * remotes/mst/tags/for_upstream: (41 commits) mptsas: Fix a migration compatible issue vhost: do not update last avail idx on get_vring_base() failure vhost: add vhost_net_set_backend() vhost-user: add error report in vhost_user_write() tests: fix vhost-user-test leak tests: plug some leaks in virtio-net-test vhost-user: wait until backend init is completed char: add and use tcp_chr_wait_connected char: add chr_wait_connected callback vhost: add assert() to check runtime behaviour vhost-net: vhost_migration_done is vhost-user specific Revert "vhost-net: do not crash if backend is not present" vhost-user: add get_vhost_net() assertions vhost-user: keep vhost_net after a disconnection vhost-user: check vhost_user_{read,write}() return value vhost-user: check qemu_chr_fe_set_msgfds() return value vhost-user: call set_msgfds unconditionally qemu-char: fix qemu_chr_fe_set_msgfds() crash when disconnected vhost: use error_report() instead of fprintf(stderr,...) vhost: add missing VHOST_OPS_DEBUG ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-29Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into stagingPeter Maydell1-0/+1
# gpg: Signature made Thu 28 Jul 2016 23:50:37 BST # gpg: using RSA key 0x7DEF8106AAFC390E # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" # Primary key fingerprint: FAEB 9711 A12C F475 812F 18F2 88A9 064D 1835 61EB # Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76 CBD0 7DEF 8106 AAFC 390E * remotes/jnsnow/tags/ide-pull-request: ide: fix halted IO segfault at reset Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-07-29tests: add drive_del-test to ppc/ppc64Laurent Vivier2-1/+4
Signed-off-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-29mptsas: Fix a migration compatible issueCao jin1-1/+1
My previous commit 2e2aa316 removed internal flag msi_in_use, which exists in vmstate, use VMSTATE_UNUSED for migration compatibility. Reported-by: Amit Shah <amit.shah@redhat.com> Suggested-by: Amit Shah <amit.shah@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Cc: Marcel Apfelbaum <marcel@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Amit Shah <amit.shah@redhat.com> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Amit Shah <amit.shah@redhat.com>
2016-07-29vhost: do not update last avail idx on get_vring_base() failureMarc-André Lureau1-1/+2
The state.num value will probably be 0 in this case, but that doesn't make sense to update. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29spapr: Prevent boot CPU core removalBharata B Rao1-0/+5
Boot CPU is assumed to be always present in QEMU code. So until that assumptions are gone, deny removal request. In another words, QEMU won't support boot CPU core hot-unplug. Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com> [dwg: Tweaked error message for clarity] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-29ppc: Fix fault PC reporting for lve*/stve* VMX instructionsBenjamin Herrenschmidt1-10/+11
We forgot to do gen_update_nip() for these like we do with other helpers. Fix this, but in a more efficient way by passing the RA to the accessors instead so the overhead is only taken on faults. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-29test: port postcopy test to ppc64lvivier@redhat.com2-19/+98
As userfaultfd syscall is available on powerpc, migration postcopy can be used. This patch adds the support needed to test this on powerpc, instead of using a bootsector to run code to modify memory, we use a FORTH script in "boot-command" property. As spapr machine doesn't support "-prom-env" argument (the nvram is initialized by SLOF and not by QEMU), "boot-command" is provided to SLOF via a file mapped nvram (with "-drive file=...,if=pflash") Signed-off-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-29Revert "spapr: Ensure CPU cores are added contiguously and removed in LIFO ↵David Gibson1-19/+1
order" This reverts commit 5cbc64de25973e9129c5a7897734a06ac64b9aff. Now that we have stable cpu_index values for pseries-2.7 (and future) machine types, we can now safely allow hotplug and unplug in any order. Conflicts: hw/ppc/spapr_cpu_core.c Some conflicts on revert due to some small changes in the inserted code since the original commit. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-29spapr: init CPUState->cpu_index with index relative to core-idIgor Mammedov1-0/+4
It will enshure that cpu_index for a given cpu stays the same regardless of the order cpus has been created/deleted and so it would be possible to migrate QEMU instance with out of order created CPU. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-28ide: fix halted IO segfault at resetJohn Snow1-0/+1
If one attempts to perform a system_reset after a failed IO request that causes the VM to enter a paused state, QEMU will segfault trying to free up the pending IO requests. These requests have already been completed and freed, though, so all we need to do is NULL them before we enter the paused state. Existing AHCI tests verify that halted requests are still resumed successfully after a STOP event. Analyzed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1469635201-11918-2-git-send-email-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2016-07-29vhost: add vhost_net_set_backend()Marc-André Lureau3-6/+17
Not all vhost-user backends support ops->vhost_net_set_backend(). It is a nicer to provide an assert/error than to crash trying to call. Furthermore, it improves a bit the code by hiding vhost_ops details. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: add error report in vhost_user_write()Marc-André Lureau1-3/+10
Similar to vhost_user_read() error report, it is useful to have early error report. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29tests: fix vhost-user-test leakMarc-André Lureau1-0/+1
Spotted by valgrind. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29tests: plug some leaks in virtio-net-testMarc-André Lureau1-3/+9
Found thanks to valgrind. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: wait until backend init is completedMarc-André Lureau1-2/+16
The chardev waits for an initial connection before starting qemu, and vhost-user should wait for the backend negotiation to be completed before starting qemu too. vhost-user is started in the net_vhost_user_event callback, which is synchronously called after the socket is connected. Use a VhostUserState.started flag to indicate vhost-user init completed successfully and qemu can be started. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29char: add and use tcp_chr_wait_connectedMarc-André Lureau1-19/+44
Add a chr_wait_connected for the tcp backend, and use it in the open_socket() function. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29char: add chr_wait_connected callbackMarc-André Lureau2-0/+17
A function to wait on the backend to be connected, to be used in the following patches. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: add assert() to check runtime behaviourMarc-André Lureau1-0/+9
All these functions must be called only after the backend is connected. They are called from virtio-net.c, after either virtio or link status change. The check for nc->peer->link_down should ensure vhost_net_{start,stop}() are always called between vhost_user_{start,stop}(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-net: vhost_migration_done is vhost-user specificMarc-André Lureau1-5/+3
Either the callback is mandatory to implement, in which case an assert() is more appropriate, or it's not and we can't tell much whether the function should fail or not (given it's name, I guess it should silently success by default). Instead, make the implementation mandatory and vhost-user specific to be more clear about its usage. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29Revert "vhost-net: do not crash if backend is not present"Marc-André Lureau1-6/+1
Now that get_vhost_net() returns non-null after a successful vhost_net_init(), we no longer need to check this case. This reverts commit ecd34898596c60f79886061618dd7e01001113ad. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: add get_vhost_net() assertionsMarc-André Lureau2-0/+3
Add a few assertions to be more explicit about the runtime behaviour after the previous patch: get_vhost_net() is non-null after net_vhost_user_init(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: keep vhost_net after a disconnectionMarc-André Lureau3-18/+20
Many code paths assume get_vhost_net() returns non-null. Keep VhostUserState.vhost_net after a successful vhost_net_init(), instead of freeing it in vhost_net_cleanup(). VhostUserState.vhost_net is thus freed before after being recreated or on final vhost_user_cleanup() and there is no need to save the acked features. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: check vhost_user_{read,write}() return valueMarc-André Lureau1-16/+34
The vhost-user code is quite inconsistent with error handling. Instead of ignoring some return values of read/write and silently going on with invalid state (invalid read for example), break the code flow when the error happened. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: check qemu_chr_fe_set_msgfds() return valueMarc-André Lureau1-1/+3
Check qemu_chr_fe_set_msgfds() for errors, to make sure the message to be sent is correct. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: call set_msgfds unconditionallyMarc-André Lureau1-3/+1
It is fine to call set_msgfds() with 0 fd, and ensures any previous fd array is cleared. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29qemu-char: fix qemu_chr_fe_set_msgfds() crash when disconnectedMarc-André Lureau1-4/+6
Calling qemu_chr_fe_set_msgfds() on unconnected socket leads to crash since s->ioc is NULL in this case. Return an error earlier instead. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: use error_report() instead of fprintf(stderr,...)Marc-André Lureau1-10/+9
Let's use qemu proper error reporting API, this ensures the error is reported at the right place (stderr or monitor), with a conventional format. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: add missing VHOST_OPS_DEBUGMarc-André Lureau1-2/+15
Add missing VHOST_OPS_DEBUG() logs, for completeness. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: do not assert() on vhost_ops failureMarc-André Lureau1-17/+32
Calling a vhost operation may fail, for example with disconnected vhost-user backend, but qemu shouldn't abort in this case. Log an error instead, except on error and cleanup code paths where it can be mostly ignored. Let's use a VHOST_OPS_DEBUG macro to easily disable those messages once disconnected backend stabilizes. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: fix calling vhost_dev_cleanup() after vhost_dev_init()Marc-André Lureau1-11/+6
vhost_net_init() calls vhost_dev_init() and in case of failure, calls vhost_dev_cleanup() directly. However, the structure is already partially cleaned on error. Calling vhost_dev_cleanup() again will call vhost_virtqueue_cleanup() on already clean queues, and causing potential double-close. Instead, adjust dev->nvqs and simplify vhost_dev_init() code to not call vhost_virtqueue_cleanup() but vhost_dev_cleanup() instead. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-net: always call vhost_dev_cleanup() on failureMarc-André Lureau1-3/+3
vhost_dev_init(), calling vhost backend initialization, should be cleaned up after failure too. Call vhost_dev_cleanup() in all failure cases. First, it needs to zero-alloc the struct to avoid the initial garbage. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: make vhost_dev_cleanup() idempotentMarc-André Lureau1-1/+6
It is called on multiple code path, so make it safe to call several times (note: I don't remember a reproducer here, but a function called 'cleanup' should probably be idempotent in my book) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: fix cleanup on not fully initialized deviceMarc-André Lureau1-3/+6
If vhost_dev_init() failed, caller may still call vhost_dev_cleanup() later. However, vhost_dev_cleanup() tries to remove the device from the list even if it wasn't yet added, which may lead to crashes. Similarly for the memory listener. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: assert the log was cleaned upMarc-André Lureau1-0/+1
Make sure the log was released on cleanup, or it will leak (the alternative is to call vhost_log_put() unconditionally, but it may hide some dev state issues). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: make vhost_log_put() idempotentMarc-André Lureau1-5/+2
Although not strictly required, it is nice to have vhost_log_put() safely callable multiple times. Clear dev->log* when calling vhost_log_put() to make the function idempotent. This also simplifies a bit the caller work. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost: don't assume opaque is a fd, use backend cleanupMarc-André Lureau1-9/+7
vhost-dev opaque isn't necessarily an fd, it can be a chardev when using vhost-user. Goto fail, so vhost_backend_cleanup() is called to handle backend cleanup appropriately. vhost_set_backend_type() should never fail, use an assert(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: disconnect on HUPMarc-André Lureau1-5/+1
In some cases, qemu_chr_fe_read_all() on HUP event doesn't raise CHR_EVENT_CLOSED because the read/recv function returns -1 on disconnected peers (for example with tch_chr_recv, an ECONNRESET errno overwritten as EIO). It is simpler to explicitely disconnect on HUP, rising CHR_EVENT_CLOSED if it wasn't disconnected already. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29vhost-user: minor simplificationMarc-André Lureau1-2/+1
Shorten the code and make it more clear by using the specialized function g_str_has_prefix(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29misc: indentationMarc-André Lureau1-1/+1
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-07-29virtio: check vring descriptor buffer lengthPrasad J Pandit1-0/+5
virtio back end uses set of buffers to facilitate I/O operations. An infinite loop unfolds in virtqueue_pop() if a buffer was of zero size. Add check to avoid it. Reported-by: Li Qiang <liqiang6-s@360.cn> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>