virtio-pci: fix bus master work around on load
PATCH 1/1 virtio-pci: fix bus master work around on load
Commit c81131db15dd1844d0db1d51f3cd7a105cfd2cf3 detects old guests by comparing virtio and PCI status. It attempts to do this on load, as well, but load_config callback in a binding is invoked too early and so the virtio status isn't set yet.
We could add yet another callback to the binding, to invoke after load, but it seems easier to reuse the existing vmstate callback.
--- hw/virtio-pci.c | 13 ++++++------- hw/virtio.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-)
hw/virtio-pci.c +6 -7
@@ -160,13 +160,6 @@ static int virtio_pci_load_config(void * opaque, QEMUFile *f)if (proxy->vdev->config_vector !=VIRTIO_NO_VECTOR ) {return msix_vector_use (&proxy->pci_dev, proxy->vdev->config_vector); } - -/* Try to find out if the guest has bus master disabled, but is -in ready state. Then we have a buggy guest OS. */ -if ((proxy->vdev->status &VIRTIO_CONFIG_S_DRIVER_OK ) && - !(proxy->pci_dev.config[PCI_COMMAND ] &PCI_COMMAND_MASTER )) { - proxy->flags |=VIRTIO_PCI_FLAG_BUS_MASTER_BUG ; - }return 0 ; }
@@ -651,6 +644,12 @@ static void virtio_pci_vmstate_change(void *opaque, bool running)VirtIOPCIProxy *proxy = opaque;if (running) { +/* Try to find out if the guest has bus master disabled, but is +in ready state. Then we have a buggy guest OS. */ +if ((proxy->vdev->status &VIRTIO_CONFIG_S_DRIVER_OK ) && + !(proxy->pci_dev.config[PCI_COMMAND ] &PCI_COMMAND_MASTER )) { + proxy->flags |=VIRTIO_PCI_FLAG_BUS_MASTER_BUG ; + }virtio_pci_start_ioeventfd (proxy); }else {virtio_pci_stop_ioeventfd (proxy);
Signature · 1 line
1.7.3.2.91.g446ac
Quoted 7 lines · Michael S. Tsirkin
Commit
c81131db15dd1844d0db1d51f3cd7a105cfd2cf3detects old guests by comparing virtio and PCI status. It attempts to do this on load, as well, butload_configcallback in a binding is invoked too early and so the virtio status isn't set yet.
Quoted 7 lines
We could add yet another callback to the binding, to invoke after load, but it seems easier to reuse the existing vmstate callback.
Signed-off-by Michael S. Tsirkin <[email protected]>Cc Alexander Graf <[email protected]>
Looks good to me. I assume you have tested the code by running an old guest?
Alex