summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* pxb: cleanupCao jin2019-11-292-4/+4
| | | | | | | 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: Marcel Apfelbaum <marcel@redhat.com>
* qemu-char: make tcp_chr_disconnect() reentrant-safeMarc-André Lureau2019-11-291-0/+4
| | | | | | | | | During CHR_EVENT_CLOSED, the function could be reentered, make this case safe. 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>
* qemu-char: remove all msgfds on disconnectMarc-André Lureau2019-11-291-0/+1
| | | | | | | | Disconnect should reset context. 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>
* qemu-char: avoid potential double-freeMarc-André Lureau2019-11-291-0/+1
| | | | | | | | | If tcp_set_msgfds() is called several time with NULL fds, this could lead to double-free. 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>
* vhost-user: remove useless is_server fieldMarc-André Lureau2019-11-291-2/+0
| | | | | | 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>
* vhost-user: fix use after freeMarc-André Lureau2019-11-291-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "name" is freed after visiting options, instead use the first NetClientState name. Adds a few assert() for clarifying and checking some impossible states. READ of size 1 at 0x602000000990 thread T0 #0 0x7f6b251c570c (/lib64/libasan.so.2+0x4770c) #1 0x5566dc380600 in qemu_find_net_clients_except net/net.c:824 #2 0x5566dc39bac7 in net_vhost_user_event net/vhost-user.c:193 #3 0x5566dbee862a in qemu_chr_be_event /home/elmarco/src/qemu/qemu-char.c:201 #4 0x5566dbef2890 in tcp_chr_disconnect /home/elmarco/src/qemu/qemu-char.c:2790 #5 0x5566dbef2d0b in tcp_chr_sync_read /home/elmarco/src/qemu/qemu-char.c:2835 #6 0x5566dbee8a99 in qemu_chr_fe_read_all /home/elmarco/src/qemu/qemu-char.c:295 #7 0x5566dc39b964 in net_vhost_user_watch net/vhost-user.c:180 #8 0x5566dc5a06c7 in qio_channel_fd_source_dispatch io/channel-watch.c:70 #9 0x7f6b1aa2ab87 in g_main_dispatch /home/elmarco/src/gnome/glib/glib/gmain.c:3154 #10 0x7f6b1aa2b9cb in g_main_context_dispatch /home/elmarco/src/gnome/glib/glib/gmain.c:3769 #11 0x5566dc475ed4 in glib_pollfds_poll /home/elmarco/src/qemu/main-loop.c:212 #12 0x5566dc476029 in os_host_main_loop_wait /home/elmarco/src/qemu/main-loop.c:257 #13 0x5566dc476165 in main_loop_wait /home/elmarco/src/qemu/main-loop.c:505 #14 0x5566dbf08d31 in main_loop /home/elmarco/src/qemu/vl.c:1932 #15 0x5566dbf16783 in main /home/elmarco/src/qemu/vl.c:4646 #16 0x7f6b180bb57f in __libc_start_main (/lib64/libc.so.6+0x2057f) #17 0x5566dbbf5348 in _start (/home/elmarco/src/qemu/x86_64-softmmu/qemu-system-x86_64+0x3f9348) 0x602000000990 is located 0 bytes inside of 5-byte region [0x602000000990,0x602000000995) freed by thread T0 here: #0 0x7f6b2521666a in __interceptor_free (/lib64/libasan.so.2+0x9866a) #1 0x7f6b1aa332a4 in g_free /home/elmarco/src/gnome/glib/glib/gmem.c:189 #2 0x5566dc5f416f in qapi_dealloc_type_str qapi/qapi-dealloc-visitor.c:134 #3 0x5566dc5f3268 in visit_type_str qapi/qapi-visit-core.c:196 #4 0x5566dc5ced58 in visit_type_Netdev_fields /home/elmarco/src/qemu/qapi-visit.c:5936 #5 0x5566dc5cef71 in visit_type_Netdev /home/elmarco/src/qemu/qapi-visit.c:5960 #6 0x5566dc381a8d in net_visit net/net.c:1049 #7 0x5566dc381c37 in net_client_init net/net.c:1076 #8 0x5566dc3839e2 in net_init_netdev net/net.c:1473 #9 0x5566dc63cc0a in qemu_opts_foreach util/qemu-option.c:1112 #10 0x5566dc383b36 in net_init_clients net/net.c:1499 #11 0x5566dbf15d86 in main /home/elmarco/src/qemu/vl.c:4397 #12 0x7f6b180bb57f in __libc_start_main (/lib64/libc.so.6+0x2057f) 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>
* nvdimm acpi: emulate dsm methodXiao Guangrong2019-11-292-0/+64
| | | | | | | | | | | Emulate dsm method after IO VM-exit Currently, we only introduce the framework and no function is actually supported Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* nvdimm acpi: let qemu handle _DSM methodXiao Guangrong2019-11-291-5/+115
| | | | | | | | | | | | If dsm memory is successfully patched, we let qemu fully emulate the dsm method This patch saves _DSM input parameters into dsm memory, tell dsm memory address to QEMU, then fetch the result from the dsm memory Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* nvdimm acpi: introduce patched dsm memoryXiao Guangrong2019-11-291-3/+17
| | | | | | | | | | | | The dsm memory is used to save the input parameters and store the dsm result which is filled by QEMU. The address of dsm memory is decided by bios and patched into int32 object named "MEMA" Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* nvdimm acpi: initialize the resource used by NVDIMM ACPIXiao Guangrong2019-11-298-16/+78
| | | | | | | | | | | | | 32 bits IO port starting from 0x0a18 in guest is reserved for NVDIMM ACPI emulation. The table, NVDIMM_DSM_MEM_FILE, will be patched into NVDIMM ACPI binary code OSPM uses this port to tell QEMU the final address of the DSM memory and notify QEMU to emulate the DSM method Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pci-ids: add virtio 1.0 ids to specGerd Hoffmann2019-11-291-7/+17
| | | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* acpi-test-data: add _DIS methodsMichael S. Tsirkin2019-11-292-0/+0
| | | | | | | | | | commit c82f503dd5c3f0a01a9e63741f1f875652669867 ("hw/acpi: fix Q35 support for legacy Windows OS") added _DIS for all link devices. Update expected test files accordingly. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* hw/acpi: fix Q35 support for legacy Windows OSMarcel Apfelbaum2019-11-291-0/+6
| | | | | | | | | | | | | Legacy Windows operating systems like Windows XP and Windows 2003 require _DIS method to be present for all interrupt links. PC machines already have a no-op implemented for GSI links, add it also in Q35. Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
* ich9lpc: fix typoCao jin2019-11-292-19/+20
| | | | | | | | | | change some "rbca" to "rcrb"(root complex register block) while the other to "rcba"(root complex base address). Bonus: add more comments and fix some indentation. 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>
* msi_supported -> msi_nonbrokenMichael S. Tsirkin2019-11-2913-16/+29
| | | | | | | Rename controller flag to make it clearer what it means. Add some documentation as well. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio-pci: call pci reset variant when guest requests reset.Gerd Hoffmann2019-11-291-7/+4
| | | | | | | | | | | | Actually fixes linux not finding virtio 1.0 device virtqueues after reboot. Which is new I think, any chance linux kernel virtio code became more strict in 4.3? Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Tested-by: Fam Zheng <famz@redhat.com>
* i386: update expected DSDTMichael S. Tsirkin2019-11-294-0/+0
| | | | | | | | | | DSDT was changed by: commit 27b9fc54d23acd8f6829e850a027b3b3878cba37 ("i386: populate floppy drive information in DSDT"). Update expected files accordingly. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* i386: populate floppy drive information in DSDTRoman Kagan2019-11-291-3/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | On x86-based systems Linux determines the presence and the type of floppy drives via a query of a CMOS field. So does SeaBIOS when populating the return data for int 0x13 function 0x08. However Windows doesn't do it. Instead, it requests this information from BIOS via int 0x13/0x08 or through ACPI objects _FDE (Floppy Drive Enumerate) and _FDI (Floppy Drive Information) of the floppy controller object. On UEFI systems only ACPI-based detection is supported. QEMU doesn't provide those objects in its ACPI tables and as a result floppy drives are invisible to Windows on UEFI/OVMF. This patch adds those objects to the floppy controller in DSDT, populating them with the information from respective QEMU objects. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Marcel Apfelbaum <marcel@redhat.com> Cc: John Snow <jsnow@redhat.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Kevin O'Connor <kevin@koconnor.net> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* fdc: add function to determine drive chs limitsRoman Kagan2019-11-292-0/+25
| | | | | | | | | | | | | | | | | | | | When populating ACPI objects for floppy drives one needs to provide the maximum values for cylinder, sector, and head number the drive supports. This patch adds a function that iterates through the array of predefined floppy drive formats and returns the maximum values of c, h, s, out of those matching the given floppy drive type. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Marcel Apfelbaum <marcel@redhat.com> Cc: John Snow <jsnow@redhat.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Kevin O'Connor <kevin@koconnor.net> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
* i386: expose floppy drive CMOS typeRoman Kagan2019-11-292-1/+2
| | | | | | | | | | | | | | | | | | Make it possible to query the CMOS type of a floppy drive outside of the source file where it's defined. It will allow to properly populate the corresponding ACPI objects and thus enable Windows on BIOS-less systems to access the floppy drives. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Marcel Apfelbaum <marcel@redhat.com> Cc: John Snow <jsnow@redhat.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Kevin O'Connor <kevin@koconnor.net> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* i386/acpi: make floppy controller object dynamicRoman Kagan2019-11-291-24/+3
| | | | | | | | | | | | | | | | | | | | | Instead of statically declaring the floppy controller in DSDT, with its _STA method depending on some obscure bit in the parent ISA bridge, add the object dynamically to DSDT via AML API only when the controller is present. The _STA method is no longer necessary and is therefore dropped. So are the declarations of the fields indicating whether the contoller is enabled. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: John Snow <jsnow@redhat.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Kevin O'Connor <kevin@koconnor.net> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* pc-dimm: fix error handling in pc_dimm_check_memdev_is_busy()Igor Mammedov2019-11-291-3/+10
| | | | | | | | | | | | | | | | | | | | | | If host_memory_backend_get_memory() were to return error and NULL MemoryRegion, pc_dimm_check_memdev_is_busy() would crash dereferencing NULL pointer in memory_region_is_mapped(). But if error is set and non NULL MemoryRegion is returned then error_setg() will fail with "error already set" assertion in error_setv() To avoid above issues use typical error handling pattern for property setters: Error *local_error = NULL; ... error_propagate(errp, local_err); Reported-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost-user: verify that number of queues is less than MAX_QUEUE_NUMIlya Maximets2019-11-291-2/+3
| | | | | | | | | | Fix QEMU crash when -netdev vhost-user,queues=n is passed with number of queues greater than MAX_QUEUE_NUM. 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> Acked-by: Jason Wang <jasowang@redhat.com>
* virtio-balloon: add 'available' counterDenis V. Lunev2019-11-292-1/+3
| | | | | | | | | | | | | | | | | | The patch for the kernel part is in linux-next already: commit ac88e7c908b920866e529862f2b2f0129b254ab2 Author: Igor Redko <redkoi@virtuozzo.com> Date: Thu Feb 18 09:23:01 2016 +1100 virtio_balloon: export 'available' memory to balloon statistics Add a new field, VIRTIO_BALLOON_S_AVAIL, to virtio_balloon memory statistics protocol, corresponding to 'Available' in /proc/meminfo. Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Igor Redko <redkoi@virtuozzo.com> CC: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* hw/virtio: group virtio flags into an enumMarcel Apfelbaum2019-11-291-7/+10
| | | | | | | | | | | Minimizes the possibility to assign the same bit to different features. Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
* hw/virtio: fix double use of a virtio flagMarcel Apfelbaum2019-11-291-1/+1
| | | | | | | | | | | | | | Commits 1811e64c and a6df8adf use the same virtio feature bit 4 for different features. Fix it by using different bits. Reported-by: Laurent Vivier <lvivier@redhat.com> Tested-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
* balloon: fix segfault and harden the stats queueLadi Prosek2019-11-291-2/+22
| | | | | | | | | | | | | | | | | The segfault here is triggered by the driver notifying the stats queue twice after adding a buffer to it. This effectively resets stats_vq_elem back to NULL and QEMU crashes on the next stats timer tick in balloon_stats_poll_cb. This is a regression introduced in 51b19ebe4320f3dc, although admittedly the device assumed too much about the stats queue protocol even before that commit. This commit adds a few more checks and ensures that the one stats buffer gets deallocated on device reset. Cc: qemu-stable@nongnu.org Signed-off-by: Ladi Prosek <lprosek@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* acpi: add build_append_named_dword, returning an offset in bufferMichael S. Tsirkin2019-11-292-0/+31
| | | | | | | | | | | | | | | This is a very limited form of support for runtime patching - similar in functionality to what we can do with ACPI_EXTRACT macros in python, but implemented in C. This is to allow ACPI code direct access to data tables - which is exactly what DataTableRegion is there for, except no known windows release so far implements DataTableRegion. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* acpi: allow using object as offset for OperationRegionXiao Guangrong2019-11-293-18/+19
| | | | | | | | | Extend aml_operation_region() to use object as offset Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* acpi: add aml_concatenate()Xiao Guangrong2019-11-292-0/+8
| | | | | | | | It will be used by nvdimm acpi Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* acpi: add aml_create_field()Xiao Guangrong2019-11-292-0/+16
| | | | | | | | It will be used by nvdimm acpi Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* postcopy: Remove the x-Dr. David Alan Gilbert2019-11-295-11/+11
| | | | | | | | | | | | Postcopy seems to have survived a cycle with only a few fixes, and Jiri has the current libvirt wired up and working ( https://www.redhat.com/archives/libvir-list/2016-March/msg00080.html ) so remove the experimental tag. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1457690016-9070-3-git-send-email-dgilbert@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
* postcopy: listen thread is never joinedDr. David Alan Gilbert2019-11-291-1/+1
| | | | | | | | | | | We don't join the listen thread, it does its own cleanup. Mark as detached not joinable. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reported-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1457690016-9070-2-git-send-email-dgilbert@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
* migration: fix use-after-free in loadvm_postcopy_handle_run_bhDenis V. Lunev2019-11-291-4/+12
| | | | | | | | | | | | MigrationState is destroyed before we can come into bottom half. Signed-off-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> CC: Juan Quintela <quintela@redhat.com> CC: Amit Shah <amit.shah@redhat.com> CC: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <1457537708-8622-1-git-send-email-den@openvz.org> Signed-off-by: Amit Shah <amit.shah@redhat.com>
* migration: fix warning for source_return_path_threadPeter Xu2019-11-291-3/+2
| | | | | | | | | max_len is not necessary, while it brings a warning during compilation when specify "-Wstack-usage=1000000". Replacing using sizeof(). Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <1457503932-31763-1-git-send-email-peterx@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
* MAINTAINERS: Add entry for the include/hw/vfio/ folderThomas Huth2019-11-291-0/+1
| | | | | | | | The headers in include/hw/vfio/ should be listed in the VFIO section of the MAINTAINERS file. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
* vfio/pci: replace fixed string limit by g_strdup_printfNeo Jia2019-11-291-2/+3
| | | | | | | | | A trivial change to remove string limit by using g_strdup_printf Tested-by: Neo Jia <cjia@nvidia.com> Signed-off-by: Neo Jia <cjia@nvidia.com> Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
* vfio/pci: Split out VGA setupAlex Williamson2019-11-292-34/+50
| | | | | | | This could be setup later by device specific code, such as IGD initialization. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
* vfio/pci: Fixup PCI option ROMsAlex Williamson2019-11-291-0/+30
| | | | | | | | | | Devices like Intel graphics are known to not only have bad checksums, but also the wrong device ID. This is not so surprising given that the video BIOS is typically part of the system firmware image rather that embedded into the device and needs to support any IGD device installed into the system. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
* vfio/pci: Convert all MemoryRegion to dynamic alloc and consistent functionsAlex Williamson2019-11-293-91/+71
| | | | | | | | Match common vfio code with setup, exit, and finalize functions for BAR, quirk, and VGA management. VGA is also changed to dynamic allocation to match the other MemoryRegions. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
* vfio: Generalize region supportAlex Williamson2019-11-297-190/+283
| | | | | | | | | | | | | | | | | Both platform and PCI vfio drivers create a "slow", I/O memory region with one or more mmap memory regions overlayed when supported by the device. Generalize this to a set of common helpers in the core that pulls the region info from vfio, fills the region data, configures slow mapping, and adds helpers for comleting the mmap, enable/disable, and teardown. This can be immediately used by the PCI MSI-X code, which needs to mmap around the MSI-X vector table. This also changes VFIORegion.mem to be dynamically allocated because otherwise we don't know how the caller has allocated VFIORegion and therefore don't know whether to unreference it to destroy the MemoryRegion or not. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
* osdep: remove use of socket_error() from all codeDaniel P. Berrange2019-11-2911-63/+46
| | | | | | | | | | Now that QEMU wraps the Win32 sockets methods to automatically set errno upon failure, there is no reason for callers to use the socket_error() method. They can rely on accessing errno even on Win32. Remove all use of socket_error() from general code, leaving it as a static method in oslib-win32.c only. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* osdep: add wrappers for socket functionsDaniel P. Berrange2019-11-297-19/+291
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The windows socket functions look identical to the normal POSIX sockets functions, but instead of setting errno, the caller needs to call WSAGetLastError(). QEMU has tried to deal with this incompatibility by defining a socket_error() method that callers must use that abstracts the difference between WSAGetLastError() and errno. This approach is somewhat error prone though - many callers of the sockets functions are just using errno directly because it is easy to forget the need use a QEMU specific wrapper. It is not always immediately obvious that a particular function will in fact call into Windows sockets functions, so the dev may not even realize they need to use socket_error(). This introduces an alternative approach to portability inspired by the way GNULIB fixes portability problems. We use a macro to redefine the original socket function names to refer to a QEMU wrapper function. The wrapper function calls the original Win32 sockets method and then sets errno from the WSAGetLastError() value. Thus all code can simply call the normal POSIX sockets APIs are have standard errno reporting on error, even on Windows. This makes the socket_error() method obsolete. We also bring closesocket & ioctlsocket into this approach. Even though they are non-standard Win32 names, we can't wrap the normal close/ioctl methods since there's no reliable way to distinguish between a file descriptor and HANDLE in Win32. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* char: remove qemu_chr_open_socket_fd methodDaniel P. Berrange2019-11-291-35/+24
| | | | | | | | | | | | | | | The qemu_chr_open_socket_fd method takes care of either doing a synchronous socket connect, or creating a listener socket. Part of the work when creating the listener socket is to register a watch for incoming clients. The caller of qemu_chr_open_socket_fd may not want this watch created, as it might be doing a synchronous wait for the first client. Rather than passing yet more parameters into qemu_chr_open_socket_fd to let it handle this, just remove the qemu_chr_open_socket_fd method an inline its functionality into the caller. This allows for a clearer control flow and shorter code. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* char: remove socket_try_connect methodDaniel P. Berrange2019-11-291-15/+10
| | | | | | | | | | | | | | The qemu_chr_open_socket_fd() method multiplexes three different actions into one method. The socket_try_connect() method is one of its callers, but it only ever want one specific action performed. By inlining that action into socket_try_connect() we see that there is not in fact any failure scenario, so there is not even any reason for socket_try_connect to exist. Just inline the asynchronous connection attempts directly at the places that need them. This shortens & clarifies the code. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* char: remove qemu_chr_finish_socket_connection methodDaniel P. Berrange2019-11-291-17/+7
| | | | | | | | | | The qemu_chr_finish_socket_connection method is multiplexing two different actions into one method. Each caller of it though, only wants one specific action. The code is shorter & clearer if we thus remove the method and just inline the specific actions where needed. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* io: implement socket watch for win32 using WSAEventSelect+selectPaolo Bonzini2019-11-294-7/+170
| | | | | | | | | | | | | On Win32 we cannot directly poll on socket handles. Instead we create a Win32 event object and associate the socket handle with the event. When the event signals readyness we then have to use select to determine which events are ready. Creating Win32 events is moderately heavyweight, so we don't want todo it every time we create a GSource, so this associates a single event with a QIOChannel. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* io: remove checking of EWOULDBLOCKDaniel P. Berrange2019-11-293-12/+6
| | | | | | | Since we now canonicalize WSAEWOULDBLOCK into EAGAIN there is no longer any need to explicitly check EWOULDBLOCK for Win32. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* io: use qemu_accept to ensure SOCK_CLOEXEC is setDaniel P. Berrange2019-11-291-2/+2
| | | | | | | The QIOChannelSocket code mistakenly uses the bare accept() function which does not set SOCK_CLOEXEC. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* io: introduce qio_channel_create_socket_watchPaolo Bonzini2019-11-293-4/+37
| | | | | | | | Sockets are not in the same namespace as file descriptors on Windows. As an initial step, introduce separate APIs for file descriptor and socket watches. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud