Skip to content
Snippets Groups Projects
Commit 6f162b36 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by Aurelien Jarno
Browse files

virtio-pci: fix bus master work around on load


Commit c81131db
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.

Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Cc: Alexander Graf <agraf@suse.de>
(cherry picked from commit 89c473fd)
parent b25a1bbc
No related branches found
No related tags found
No related merge requests found
...@@ -160,13 +160,6 @@ static int virtio_pci_load_config(void * opaque, QEMUFile *f) ...@@ -160,13 +160,6 @@ static int virtio_pci_load_config(void * opaque, QEMUFile *f)
if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) { if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) {
return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_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; return 0;
} }
...@@ -651,6 +644,12 @@ static void virtio_pci_vmstate_change(void *opaque, bool running) ...@@ -651,6 +644,12 @@ static void virtio_pci_vmstate_change(void *opaque, bool running)
VirtIOPCIProxy *proxy = opaque; VirtIOPCIProxy *proxy = opaque;
if (running) { 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); virtio_pci_start_ioeventfd(proxy);
} else { } else {
virtio_pci_stop_ioeventfd(proxy); virtio_pci_stop_ioeventfd(proxy);
......
...@@ -92,6 +92,7 @@ typedef struct { ...@@ -92,6 +92,7 @@ typedef struct {
void (*save_queue)(void * opaque, int n, QEMUFile *f); void (*save_queue)(void * opaque, int n, QEMUFile *f);
int (*load_config)(void * opaque, QEMUFile *f); int (*load_config)(void * opaque, QEMUFile *f);
int (*load_queue)(void * opaque, int n, QEMUFile *f); int (*load_queue)(void * opaque, int n, QEMUFile *f);
int (*load_done)(void * opaque, QEMUFile *f);
unsigned (*get_features)(void * opaque); unsigned (*get_features)(void * opaque);
bool (*query_guest_notifiers)(void * opaque); bool (*query_guest_notifiers)(void * opaque);
int (*set_guest_notifiers)(void * opaque, bool assigned); int (*set_guest_notifiers)(void * opaque, bool assigned);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment