aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-03-07qos-test: virtio-blk test nodePaolo Bonzini
Convert tests/virtio-blk-test in qgraph test node, virtio-blk-test. This test consumes a virtio-blk interface and checks that its function return the expected values. Some functions are implemented only for virtio-blk-pci, so they don't consume virtio-blk, but virtio-blk-pci Note that this test does not allocate any virtio-blk structure, it's all done by the qtest walking graph mechanism. The allocator is also provided by qgraph; remove malloc-generic.c and malloc-generic.h which are not used anymore. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: virtio-blk driver and interface nodesEmanuele Giuseppe Esposito
Add qgraph nodes for virtio-blk-pci and virtio-blk-device. Both nodes produce virtio-blk, but virtio-blk-pci receives a pci-bus and uses virtio-pci QOSGraphObject and functions, while virtio-blk-device receives a virtio and implements its own functions Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07qos-test: virtio-rng test nodeEmanuele Giuseppe Esposito
Convert tests/virtio-rng-test in qgraph test node, virtio-rng-test. This test consumes a virtio-rng interface and checks that its function return the expected values. Some functions are implemented only for virtio-rng-pci, so they don't consume virtio-rng, but virtio-rng-pci Note that this test does not allocate any virtio-rng structure, it's all done by the qtest walking graph mechanism Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: virtio-rng driver and interface nodesEmanuele Giuseppe Esposito
Add qgraph nodes for virtio-rng-pci and virtio-rng-device. Both nodes produce virtio-rng, but virtio-rng-pci receives a pci-bus and uses virtio-pci QOSGraphObject and functions, while virtio-rng-device receives a virtio and implements its own functions Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/qgraph: remove virtio-balloon-testEmanuele Giuseppe Esposito
The tests/virtio-balloon-test is covered by generic virtio tests, so remove it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
2019-03-07tests/libqos: virtio-balloon driver and interface nodesEmanuele Giuseppe Esposito
Add qgraph nodes for virtio-balloon-pci and virtio-balloon-device. Both nodes produce virtio-balloon, but virtio-balloon-pci receives a pci-bus and uses virtio-pci QOSGraphObject and functions, while virtio-balloon-device receives a virtio and implements its own functions Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07qos-test: virtio-9p test nodeEmanuele Giuseppe Esposito
Convert tests/virtio-9p-test into a qgraph test node. This test consumes a virtio-9p interface and checks that its functions return the expected values. Note that this test does not allocate any virtio-9p structure, it's all done by the qtest walking graph mechanism Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: virtio-9p driver and interface nodesEmanuele Giuseppe Esposito
Add qgraph nodes for virtio-9p-pci and virtio-9p-device. Both nodes produce virtio-9p, but virtio-9p-pci receives a pci-bus and overrides virtio-pci QOSGraphObject and its functions, while virtio-9p-device receives a virtio and implements its own functions Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07qos-test: virtio-console and virtio-serial test nodeEmanuele Giuseppe Esposito
Convert tests/virtio-console-test and tests/virtio-serial-test in qgraph test node. This test consumes a virtio-serial interface and checks that its function return the expected values. Note that this test does not allocate any virtio-console or virtio-serial structure, it's all done by the qtest walking graph mechanism Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: virtio-serial driver and interface nodesEmanuele Giuseppe Esposito
Add qgraph nodes for virtio-serial-pci and virtio-serial-device. Both nodes produce virtio-serial, but virtio-serial-pci receives a pci-bus and uses virtio-pci QOSGraphObject and functions, while virtio-serial-device receives a virtio-bus and implements its own functions Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/qgraph: add generic virtio testcasesPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: arm/virt machine nodeEmanuele Giuseppe Esposito
Add arm/virt machine to the graph. This machine contains virtio-mmio, so its constructor must take care of setting it properly when called. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: virtio-mmio driver and interface nodesEmanuele Giuseppe Esposito
Add virtio-mmio node in qgraph framework. virtio-mmio produces virtio-bus, the interface consumed by all virtio-*-device nodes. Being a memory-mapped device, it doesn't have to provide a constructor to qgraph, since it's always "contained" inside some other nodes. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: remove global_qtest from virtio endianness checksPaolo Bonzini
This is needed to support migration tests with qgraph. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: virtio-pci driver and interface nodesEmanuele Giuseppe Esposito
Add QOSGraphObject to QVirtioPCIDevice structure, with a basic constructor. virtio-pci is not present in qgraph, since it will be used as starting point by its subclasses (virtio-*-pci) Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07qos-test: e1000e test nodeEmanuele Giuseppe Esposito
Convert tests/e1000e-test in qgraph test node, e1000e-test. This test consumes an e1000e interface and checks that its function return the expected values. Note that this test does not allocate any e1000e structure, it's all done by the qtest walking graph mechanism Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: e1000e driver and interface nodesEmanuele Giuseppe Esposito
Add qgraph nodes for virtio-e1000e. It consumes a pci-bus, and it's directly used by tests (e1000e is pci based). Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: has_buggy_msi flagEmanuele Giuseppe Esposito
The Qgraph framework makes any test using pci bus run the same function using pci-pci and pci-spapr bus. However, some tests are not ready to use the spapr bus, due to a MSI bug. Until it does not get fixed, this flag allows them to skip the test Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/qgraph: ppc64/pseries machine nodeEmanuele Giuseppe Esposito
Add pseries machine for the ppc64 QEMU binary. This machine contains a spapr-pci-host-bridge driver, that contains itself a pci-bus-spapr that produces the pci-bus interface. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: pci-spapr driver and interface nodesEmanuele Giuseppe Esposito
Add pci-bus-spapr node, that produces pci-bus. Move QPCIBusSPAPR struct declaration in its header (since it will be needed by other drivers) and introduce a setter method for drivers that do not need to allocate but have to initialize QPCIBusSPAPR. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/qgraph: add generic PCI testcasesPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07qos-test: sdhci test nodeEmanuele Giuseppe Esposito
Convert tests/sdhci-test in first qgraph test node, sdhci-test. This test consumes an sdhci interface and checks that its function return the expected values. Note that this test does not allocate any sdhci structure, it's all done by the qtest walking graph mechanism Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: aarch64/xlnx-zcu102 machine nodeEmanuele Giuseppe Esposito
Add xlnx-zcu102 machine to the graph. This machine contains generic-sdhci, so its constructor must take care of setting it properly when called. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: arm/xilinx-zynq-a9 machine nodeEmanuele Giuseppe Esposito
Add xilinx-zynq-a9 machine to the graph. This machine contains generic-sdhci, so its constructor must take care of setting it properly when called. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: arm/sabrelite machine nodeEmanuele Giuseppe Esposito
Add arm/sabrelite machine to the graph. This machine contains generic-sdhci, so its constructor must take care of setting it properly when called. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: arm/smdkc210 machine nodeEmanuele Giuseppe Esposito
Add arm/smdkc210 machine machine to the graph. This machine contains generic-sdhci, so its constructor must take care of setting it properly when called. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: arm/raspi2 machine nodeEmanuele Giuseppe Esposito
Add arm/raspi2 machine to the graph. This machine contains a generic-sdhci, so its constructor must take care of setting it properly when called. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: sdhci driver and interface nodesEmanuele Giuseppe Esposito
Add qgraph nodes for sdhci-pci and generic-sdhci (memory mapped) drivers. Both drivers implement (produce) the same interface sdhci, that provides the readw - readq - writeq functions. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: x86_64/pc machine nodeEmanuele Giuseppe Esposito
Add pc machine for the x86_64 QEMU binary. This machine contains an i440FX-pcihost driver, that contains itself a pci-bus-pc that produces the pci-bus interface. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: pci-pc driver and interface nodesEmanuele Giuseppe Esposito
Add pci-bus-pc node, move QPCIBusPC struct declaration in its header (since it will be needed by other drivers) and introduce a setter method for drivers that do not need to allocate but have to initialize QPCIBusPC. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests: qgraph API for the qtest driver frameworkEmanuele Giuseppe Esposito
Add qgraph API that allows to add/remove nodes and edges from the graph, implementation of Depth First Search to discover the paths and basic unit test to check correctness of the API. Included also a main executable that takes care of starting the framework, create the nodes, set the available drivers/machines, discover the path and run tests. graph.h provides the public API to manage the graph nodes/edges graph_extra.h provides a more private API used successively by the gtest integration part qos-test.c provides the main executable Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> [Paolo's changes compared to the Google Summer of Code submission: * added subprocess to test options * refactored object creation to support live migration tests * removed driver .before callback (unused) * removed test .after callbacks (replaced by GTest destruction queue)] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: embed allocators instead of malloc-ing them separatelyPaolo Bonzini
qgraph will embed these objects instead of allocating them in a separate object. Expose a new API "generic_alloc_init" and "generic_alloc_destroy" for that, and rename the existing API with s/init/new/ and s/uninit/free/. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: rename qpci_init_pc and qpci_init_spapr functionsEmanuele Giuseppe Esposito
Rename qpci_init_pc in qpci_pc_new and qpci_init_spapr in qpci_spapr_new, since these function actually allocate a new pci struct and initialize it (compare to object_new and object_initialize). Changed QOSOps field name from qpci_init to qpci_new. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07tests/libqos: introduce virtio_start_deviceEmanuele Giuseppe Esposito
This function is intended to group all the qvirtio_* functions that start the qvirtio devices. Applied in all tests using this combination of functions. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07chardev-socket: do not blindly reset handlers when switching GMainContextPaolo Bonzini
If the socket is connecting or connected, tcp_chr_update_read_handler will be called but it should not set the NetListener's callbacks again. Otherwise, tcp_chr_accept is invoked while the socket is in connected state and you get an assertion failure. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-03-07Merge remote-tracking branch 'remotes/kraxel/tags/usb-20190307-pull-request' ↵Peter Maydell
into staging usb: mtp fixes, guest-reset switch for usb-host. # gpg: Signature made Thu 07 Mar 2019 09:53:55 GMT # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/usb-20190307-pull-request: Introduce new "no_guest_reset" parameter for usb-host device usb-mtp: prevent null dereference while deleting objects usb-mtp: fix some usb_mtp_write_data return paths usb-mtp: return incomplete transfer on a lstat failure Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2019-03-07Introduce new "no_guest_reset" parameter for usb-host deviceAlexander Kappner
With certain USB devices passed through via usb-host, a guest attempting to reset a usb-host device can trigger a reset loop that renders the USB device unusable. In my use case, the device was an iPhone XR that was passed through to a Mac OS X Mojave guest. Upon connecting the device, the following happens: 1) Guest recognizes new device, sends reset to emulated USB host 2) QEMU's USB host sends reset to host kernel 3) Host kernel resets device 4) After reset, host kernel determines that some part of the device descriptor has changed ("device firmware changed" in dmesg), so host kernel decides to re-enumerate the device. 5) Re-enumeration causes QEMU to disconnect and reconnect the device in the guest. 6) goto 1) Here's from the host kernel (note the "device firmware changed" lines") [3677704.473050] usb 1-1.3: new high-speed USB device number 53 using ehci-pci [3677704.555594] usb 1-1.3: New USB device found, idVendor=05ac, idProduct=12a8, bcdDevice=11.08 [3677704.555599] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [3677704.555602] usb 1-1.3: Product: iPhone [3677704.555605] usb 1-1.3: Manufacturer: Apple Inc. [3677704.555607] usb 1-1.3: SerialNumber: [[removed]] [3677709.401040] usb 1-1.3: reset high-speed USB device number 53 using ehci-pci [3677709.479486] usb 1-1.3: device firmware changed [3677709.479842] usb 1-1.3: USB disconnect, device number 53 [3677709.546039] usb 1-1.3: new high-speed USB device number 54 using ehci-pci [3677709.627471] usb 1-1.3: New USB device found, idVendor=05ac, idProduct=12a8, bcdDevice=11.08 [3677709.627476] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [3677709.627479] usb 1-1.3: Product: iPhone [3677709.627481] usb 1-1.3: Manufacturer: Apple Inc. [3677709.627483] usb 1-1.3: SerialNumber: [[removed]] [3677762.320044] usb 1-1.3: reset high-speed USB device number 54 using ehci-pci [3677762.615630] usb 1-1.3: USB disconnect, device number 54 [3677762.787043] usb 1-1.3: new high-speed USB device number 55 using ehci-pci [3677762.869016] usb 1-1.3: New USB device found, idVendor=05ac, idProduct=12a8, bcdDevice=11.08 [3677762.869024] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [3677762.869028] usb 1-1.3: Product: iPhone [3677762.869032] usb 1-1.3: Manufacturer: Apple Inc. [3677762.869035] usb 1-1.3: SerialNumber: [[removed]] [3677815.662036] usb 1-1.3: reset high-speed USB device number 55 using ehci-pci Here's from QEMU: libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/005/022: No such file or directory libusb: error [udev_hotplug_event] ignoring udev action bind libusb: error [udev_hotplug_event] ignoring udev action bind libusb: error [_open_sysfs_attr] open /sys/bus/usb/devices/5-1/bConfigurationValue failed ret=-1 errno=2 libusb: error [_get_usbfs_fd] File doesn't exist, wait 10 ms and try again libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/005/024: No such file or directory libusb: error [udev_hotplug_event] ignoring udev action bind libusb: error [udev_hotplug_event] ignoring udev action bind libusb: error [_open_sysfs_attr] open /sys/bus/usb/devices/5-1/bConfigurationValue failed ret=-1 errno=2 libusb: error [_get_usbfs_fd] File doesn't exist, wait 10 ms and try again libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/005/026: No such file or directory The result of this is that the device remains permanently unusable in the guest. The same problem has been previously reported for an iPad: https://stackoverflow.com/questions/52617634/how-do-i-get-qemu-usb-passthrough-to-work-for-ipad-iphone This problem can be elegantly solved by interrupting step 2) above. Instead of passing through the reset, QEMU simply ignores it. To allow this to be configured on a per-device level, a new parameter "no_guest_reset" is introduced for the usb-host device. I can confirm that the configuration described above (iPhone XS + Mojave guest) works flawlessly with no_guest_reset=True specified. Working command line for my scenario: device_add usb-host,vendorid=0x05ac,productid=0x12a8,no_guest_reset=True,id=iphone Best regards Alexander Signed-off-by: Alexander Kappner <agk@godking.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20190128140027.9448-1-kraxel@redhat.com [ kraxel: rename parameter to "guest-reset" ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-07usb-mtp: prevent null dereference while deleting objectsBandan Das
Spotted by Coverity: CID 1399144 Signed-off-by: Bandan Das <bsd@redhat.com> Message-id: 20190306210409.14842-4-bsd@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-07usb-mtp: fix some usb_mtp_write_data return pathsBandan Das
During a write, free up the "path" before getting more data. Also, while we at it, remove the confusing usage of d->fd for storing mkdir status Spotted by Coverity: CID 1398642 Signed-off-by: Bandan Das <bsd@redhat.com> Message-id: 20190306210409.14842-3-bsd@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-07usb-mtp: return incomplete transfer on a lstat failureBandan Das
MTP writes objects in small chunks and at the end gets the real file size to update the object metadata. If this fails for any reason, return an INCOMPLETE_TRANSFER to the initiator Spotted by Coverity: CID 1398651 Signed-off-by: Bandan Das <bsd@redhat.com> Message-id: 20190306210409.14842-2-bsd@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-06Merge remote-tracking branch ↵Peter Maydell
'remotes/ehabkost/tags/machine-next-pull-request' into staging Machine queue, 2019-03-06 * qdev: Hotplug handler chaining (David Hildenbrand) * qdev: fix qbus_is_full() (Tony Krowiak) * hostmem: fix crash when querying empty host-nodes property via QMP (Igor Mammedov) # gpg: Signature made Wed 06 Mar 2019 18:39:29 GMT # gpg: using RSA key 2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/machine-next-pull-request: qdev: Provide qdev_get_bus_hotplug_handler() qdev: Let machine hotplug handler to override bus hotplug handler qdev: Let the hotplug_handler_unplug() caller delete the device hostmem: fix crash when querying empty host-nodes property via QMP qdev/core: fix qbus_is_full() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2019-03-06qdev: Provide qdev_get_bus_hotplug_handler()David Hildenbrand
Let's use a wrapper instead of looking it up manually. This function can than be reused when we explicitly want to have the bus hotplug handler (e.g. when the bus hotplug handler was overwritten by the machine hotplug handler). Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20190228122849.4296-4-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-03-06qdev: Let machine hotplug handler to override bus hotplug handlerIgor Mammedov
it will allow to return another hotplug handler than the default one for a specific bus based device type. Which is needed to handle non trivial plug/unplug sequences that need the access to resources configured outside of bus where device is attached. That will allow for returned hotplug handler to orchestrate wiring in arbitrary order, by chaining other hotplug handlers when it's needed. PS: It could be used for hybrid virtio-mem and virtio-pmem devices where it will return machine as hotplug handler which will do necessary wiring at machine level and then pass control down the chain to bus specific hotplug handler. Example of top level hotplug handler override and custom plug sequence: some_machine_get_hotplug_handler(machine){ if (object_dynamic_cast(OBJECT(dev), TYPE_SOME_BUS_DEVICE)) { return HOTPLUG_HANDLER(machine); } return NULL; } some_machine_device_plug(hotplug_dev, dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_SOME_BUS_DEVICE)) { /* do machine specific initialization */ some_machine_init_special_device(dev) /* pass control to bus specific handler */ hotplug_handler_plug(dev->parent_bus->hotplug_handler, dev) } } Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20190228122849.4296-3-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-03-06qdev: Let the hotplug_handler_unplug() caller delete the deviceDavid Hildenbrand
When unplugging a device, at one point the device will be destroyed via object_unparent(). This will, one the one hand, unrealize the removed device hierarchy, and on the other hand, destroy/free the device hierarchy. When chaining hotplug handlers, we want to overwrite a bus hotplug handler by the machine hotplug handler, to be able to perform some part of the plug/unplug and to forward the calls to the bus hotplug handler. For now, the bus hotplug handler would trigger an object_unparent(), not allowing us to perform some unplug action on a device after we forwarded the call to the bus hotplug handler. The device would be gone at that point. machine_unplug_handler(dev) /* eventually do unplug stuff */ bus_unplug_handler(dev) /* dev is gone, we can't do more unplug stuff */ So move the object_unparent() to the original caller of the unplug. For now, keep the unrealize() at the original places of the object_unparent(). For implicitly chained hotplug handlers (e.g. pc code calling acpi hotplug handlers), the object_unparent() has to be done by the outermost caller. So when calling hotplug_handler_unplug() from inside an unplug handler, nothing is to be done. hotplug_handler_unplug(dev) -> calls machine_unplug_handler() machine_unplug_handler(dev) { /* eventually do unplug stuff */ bus_unplug_handler(dev) -> calls unrealize(dev) /* we can do more unplug stuff but device already unrealized */ } object_unparent(dev) In the long run, every unplug action should be factored out of the unrealize() function into the unplug handler (especially for PCI). Then we can get rid of the additonal unrealize() calls and object_unparent() will properly unrealize the device hierarchy after the device has been unplugged. hotplug_handler_unplug(dev) -> calls machine_unplug_handler() machine_unplug_handler(dev) { /* eventually do unplug stuff */ bus_unplug_handler(dev) -> only unplugs, does not unrealize /* we can do more unplug stuff */ } object_unparent(dev) -> will unrealize The original approach was suggested by Igor Mammedov for the PCI part, but I extended it to all hotplug handlers. I consider this one step into the right direction. To summarize: - object_unparent() on synchronous unplugs is done by common code -- "Caller of hotplug_handler_unplug" - object_unparent() on asynchronous unplugs ("unplug requests") has to be done manually -- "Caller of hotplug_handler_unplug" Reviewed-by: Igor Mammedov <imammedo@redhat.com> Acked-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20190228122849.4296-2-david@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-03-06hostmem: fix crash when querying empty host-nodes property via QMPIgor Mammedov
QEMU will crashes with qapi/qobject-output-visitor.c:210: qobject_output_complete: Assertion `qov->root && ((&qov->stack)->slh_first == ((void *)0))' failed when trying to get value of not set hostmem's "host-nodes" property, HostMemoryBackend::host_nodes bitmap doesn't have any bits set in it, which leads to find_first_bit() returning MAX_NODES and consequently to an early return from host_memory_backend_get_host_nodes() without calling visitor. Fix it by calling visitor even if "host-nodes" property wasn't set before exiting from property getter to return valid empty list. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20190214105733.25643-1-imammedo@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-03-06qdev/core: fix qbus_is_full()Tony Krowiak
The qbus_is_full(BusState *bus) function (qdev_monitor.c) compares the max_index value of the BusState structure with the max_dev value of the BusClass structure to determine whether the maximum number of children has been reached for the bus. The problem is, the max_index field of the BusState structure does not necessarily reflect the number of devices that have been plugged into the bus. Whenever a child device is plugged into the bus, the bus's max_index value is assigned to the child device and then incremented. If the child is subsequently unplugged, the value of the max_index does not change and no longer reflects the number of children. When the bus's max_index value reaches the maximum number of devices allowed for the bus (i.e., the max_dev field in the BusClass structure), attempts to plug another device will be rejected claiming that the bus is full -- even if the bus is actually empty. To resolve the problem, a new 'num_children' field is being added to the BusState structure to keep track of the number of children plugged into the bus. It will be incremented when a child is plugged, and decremented when a child is unplugged. Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com> Reviewed-by: Pierre Morel<pmorel@linux.ibm.com> Reviewed-by: Halil Pasic <pasic@linux.ibm.com> Message-Id: <1545062250-7573-1-git-send-email-akrowiak@linux.ibm.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-03-06Merge remote-tracking branch ↵Peter Maydell
'remotes/dgilbert/tags/pull-migration-20190306a' into staging Migation pull 2019-03-06 (This replaces the pull sent yesterday) a) 4 small fixes including the cancel problem that caused the ahci migration test to fail intermittently b) Yury's ignore-shared feature c) Juan's extra tests d) Wei Wang's free page hinting e) Some Colo fixes from Zhang Chen Diff from yesterdays pull: 1) A missing fix of mine (cleanup during exit) 2) Changes from Eric/Markus on 'Create socket-address parameter' # gpg: Signature made Wed 06 Mar 2019 11:39:53 GMT # gpg: using RSA key 0516331EBC5BFDE7 # gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" [full] # Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A 9FA9 0516 331E BC5B FDE7 * remotes/dgilbert/tags/pull-migration-20190306a: (22 commits) qapi/migration.json: Remove a variable that doesn't exist in example Migration/colo.c: Make COLO node running after failover Migration/colo.c: Fix double close bug when occur COLO failover virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT migration/ram.c: add the free page optimization enable flag migration/ram.c: add a notifier chain for precopy migration: API to clear bits of guest free pages from the dirty bitmap migration: use bitmap_mutex in migration_bitmap_clear_dirty bitmap: bitmap_count_one_with_offset bitmap: fix bitmap_count_one tests: Add basic migration precopy tcp test migration: Create socket-address parameter tests: Add migration xbzrle test migration: Add capabilities validation tests/migration-test: Add a test for ignore-shared capability migration: Add an ability to ignore shared RAM blocks migration: Introduce ignore-shared capability exec: Change RAMBlockIterFunc definition migration/rdma: clang compilation fix migration: Cleanup during exit ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2019-03-06Merge remote-tracking branch ↵Peter Maydell
'remotes/vivier2/tags/trivial-branch-pull-request' into staging trivial patches pull request (20190206) - acpi: remove unused functions/variables - tests: remove useless architecture checks - some typo fixes and documentation update - flash_cfi02: fix memory leak # gpg: Signature made Wed 06 Mar 2019 11:05:12 GMT # gpg: using RSA key F30C38BD3F2FBE3C # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [full] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full] # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * remotes/vivier2/tags/trivial-branch-pull-request: thunk: fix of malloc to g_new hostmem-file: simplify ifdef-s in file_backend_memory_alloc() build: Correct explanation of unnest-vars example bswap: Fix accessors syntax in comment doc: fix typos for documents in tree block/pflash_cfi02: Fix memory leak and potential use-after-free hw/acpi: remove unnecessary variable acpi_table_builtin hw/acpi: remove unused function acpi_table_add_builtin() hw/i386/pc.c: remove unused function pc_acpi_init() tests: Remove (mostly) useless architecture checks Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2019-03-06qapi/migration.json: Remove a variable that doesn't exist in exampleZhang Chen
Remove the "active" variable in example for query-colo-status. It is a doc bug from commit f56c0065 Signed-off-by: Zhang Chen <chen.zhang@intel.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190303145021.2962-6-chen.zhang@intel.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2019-03-06Migration/colo.c: Make COLO node running after failoverZhang Chen
Delay to close COLO for auto start VM after failover. Signed-off-by: Zhang Chen <chen.zhang@intel.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20190303145021.2962-4-chen.zhang@intel.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>