Commit e6da76800041f9aadd0a3607bed99aaf59794560

Authored by Michael S. Tsirkin
Committed by Anthony Liguori
1 parent 72755a70

qemu/virtio: mark msi vectors used on load

Usage of msi vectors is controlled by the guest and so needs to be
restored on load. Do this for msi vectors used by the virtio device.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 1 changed file with 17 additions and 5 deletions
hw/virtio-pci.c
@@ -126,11 +126,18 @@ static int virtio_pci_load_config(void * opaque, QEMUFile *f) @@ -126,11 +126,18 @@ static int virtio_pci_load_config(void * opaque, QEMUFile *f)
126 VirtIOPCIProxy *proxy = opaque; 126 VirtIOPCIProxy *proxy = opaque;
127 int ret; 127 int ret;
128 ret = pci_device_load(&proxy->pci_dev, f); 128 ret = pci_device_load(&proxy->pci_dev, f);
129 - if (ret) 129 + if (ret) {
130 return ret; 130 return ret;
  131 + }
131 msix_load(&proxy->pci_dev, f); 132 msix_load(&proxy->pci_dev, f);
132 - if (msix_present(&proxy->pci_dev)) 133 + if (msix_present(&proxy->pci_dev)) {
133 qemu_get_be16s(f, &proxy->vdev->config_vector); 134 qemu_get_be16s(f, &proxy->vdev->config_vector);
  135 + } else {
  136 + proxy->vdev->config_vector = VIRTIO_NO_VECTOR;
  137 + }
  138 + if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) {
  139 + return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector);
  140 + }
134 return 0; 141 return 0;
135 } 142 }
136 143
@@ -138,10 +145,15 @@ static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f) @@ -138,10 +145,15 @@ static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f)
138 { 145 {
139 VirtIOPCIProxy *proxy = opaque; 146 VirtIOPCIProxy *proxy = opaque;
140 uint16_t vector; 147 uint16_t vector;
141 - if (!msix_present(&proxy->pci_dev))  
142 - return 0;  
143 - qemu_get_be16s(f, &vector); 148 + if (msix_present(&proxy->pci_dev)) {
  149 + qemu_get_be16s(f, &vector);
  150 + } else {
  151 + vector = VIRTIO_NO_VECTOR;
  152 + }
144 virtio_queue_set_vector(proxy->vdev, n, vector); 153 virtio_queue_set_vector(proxy->vdev, n, vector);
  154 + if (vector != VIRTIO_NO_VECTOR) {
  155 + return msix_vector_use(&proxy->pci_dev, vector);
  156 + }
145 return 0; 157 return 0;
146 } 158 }
147 159