Blame 0005-virtio-pci-remove-vdev-field.patch

bacd9b
From 3dfc39e3dcdf006d3aef8b8be1f3947f9393b90f Mon Sep 17 00:00:00 2001
298366
From: Paolo Bonzini <pbonzini@redhat.com>
298366
Date: Fri, 20 Sep 2013 16:57:51 +0200
298366
Subject: [PATCH] virtio-pci: remove vdev field
298366
298366
The vdev field is complicated to synchronize.  Just access the
298366
BusState's list of children.
298366
298366
Cc: qemu-stable@nongnu.org
298366
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
298366
---
298366
 hw/s390x/virtio-ccw.h  |   1 -
298366
 hw/virtio/virtio-pci.c | 107 +++++++++++++++++++++++++++++--------------------
298366
 hw/virtio/virtio-pci.h |   1 -
298366
 3 files changed, 63 insertions(+), 46 deletions(-)
298366
298366
diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
298366
index 96d6f5d..00932c7 100644
298366
--- a/hw/s390x/virtio-ccw.h
298366
+++ b/hw/s390x/virtio-ccw.h
298366
@@ -77,7 +77,6 @@ typedef struct VirtIOCCWDeviceClass {
298366
 struct VirtioCcwDevice {
298366
     DeviceState parent_obj;
298366
     SubchDev *sch;
298366
-    VirtIODevice *vdev;
298366
     char *bus_id;
298366
     uint32_t host_features[VIRTIO_CCW_FEATURE_SIZE];
298366
     VirtioBusState bus;
298366
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
45bdef
index 76b7652..be18e92 100644
298366
--- a/hw/virtio/virtio-pci.c
298366
+++ b/hw/virtio/virtio-pci.c
45bdef
@@ -113,31 +113,39 @@ static inline VirtIOPCIProxy *to_virtio_pci_proxy_fast(DeviceState *d)
298366
 static void virtio_pci_notify(DeviceState *d, uint16_t vector)
298366
 {
298366
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy_fast(d);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+
298366
     if (msix_enabled(&proxy->pci_dev))
298366
         msix_notify(&proxy->pci_dev, vector);
298366
     else
45bdef
-        pci_set_irq(&proxy->pci_dev, proxy->vdev->isr & 1);
45bdef
+        pci_set_irq(&proxy->pci_dev, vdev->isr & 1);
298366
 }
298366
 
298366
 static void virtio_pci_save_config(DeviceState *d, QEMUFile *f)
298366
 {
298366
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+
298366
     pci_device_save(&proxy->pci_dev, f);
298366
     msix_save(&proxy->pci_dev, f);
298366
     if (msix_present(&proxy->pci_dev))
298366
-        qemu_put_be16(f, proxy->vdev->config_vector);
298366
+        qemu_put_be16(f, vdev->config_vector);
298366
 }
298366
 
298366
 static void virtio_pci_save_queue(DeviceState *d, int n, QEMUFile *f)
298366
 {
298366
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+
298366
     if (msix_present(&proxy->pci_dev))
298366
-        qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n));
298366
+        qemu_put_be16(f, virtio_queue_vector(vdev, n));
298366
 }
298366
 
298366
 static int virtio_pci_load_config(DeviceState *d, QEMUFile *f)
298366
 {
298366
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+
298366
     int ret;
298366
     ret = pci_device_load(&proxy->pci_dev, f);
298366
     if (ret) {
45bdef
@@ -146,12 +154,12 @@ static int virtio_pci_load_config(DeviceState *d, QEMUFile *f)
298366
     msix_unuse_all_vectors(&proxy->pci_dev);
298366
     msix_load(&proxy->pci_dev, f);
298366
     if (msix_present(&proxy->pci_dev)) {
298366
-        qemu_get_be16s(f, &proxy->vdev->config_vector);
298366
+        qemu_get_be16s(f, &vdev->config_vector);
298366
     } else {
298366
-        proxy->vdev->config_vector = VIRTIO_NO_VECTOR;
298366
+        vdev->config_vector = VIRTIO_NO_VECTOR;
298366
     }
298366
-    if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) {
298366
-        return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector);
298366
+    if (vdev->config_vector != VIRTIO_NO_VECTOR) {
298366
+        return msix_vector_use(&proxy->pci_dev, vdev->config_vector);
298366
     }
298366
     return 0;
298366
 }
45bdef
@@ -159,13 +167,15 @@ static int virtio_pci_load_config(DeviceState *d, QEMUFile *f)
298366
 static int virtio_pci_load_queue(DeviceState *d, int n, QEMUFile *f)
298366
 {
298366
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+
298366
     uint16_t vector;
298366
     if (msix_present(&proxy->pci_dev)) {
298366
         qemu_get_be16s(f, &vector);
298366
     } else {
298366
         vector = VIRTIO_NO_VECTOR;
298366
     }
298366
-    virtio_queue_set_vector(proxy->vdev, n, vector);
298366
+    virtio_queue_set_vector(vdev, n, vector);
298366
     if (vector != VIRTIO_NO_VECTOR) {
298366
         return msix_vector_use(&proxy->pci_dev, vector);
298366
     }
45bdef
@@ -175,7 +185,8 @@ static int virtio_pci_load_queue(DeviceState *d, int n, QEMUFile *f)
298366
 static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy,
298366
                                                  int n, bool assign, bool set_handler)
298366
 {
298366
-    VirtQueue *vq = virtio_get_queue(proxy->vdev, n);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+    VirtQueue *vq = virtio_get_queue(vdev, n);
298366
     EventNotifier *notifier = virtio_queue_get_host_notifier(vq);
298366
     int r = 0;
298366
 
45bdef
@@ -200,6 +211,7 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy,
298366
 
298366
 static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy)
298366
 {
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     int n, r;
298366
 
298366
     if (!(proxy->flags & VIRTIO_PCI_FLAG_USE_IOEVENTFD) ||
45bdef
@@ -209,7 +221,7 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy)
298366
     }
298366
 
298366
     for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
298366
-        if (!virtio_queue_get_num(proxy->vdev, n)) {
298366
+        if (!virtio_queue_get_num(vdev, n)) {
298366
             continue;
298366
         }
298366
 
45bdef
@@ -223,7 +235,7 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy)
298366
 
298366
 assign_error:
298366
     while (--n >= 0) {
298366
-        if (!virtio_queue_get_num(proxy->vdev, n)) {
298366
+        if (!virtio_queue_get_num(vdev, n)) {
298366
             continue;
298366
         }
298366
 
45bdef
@@ -236,6 +248,7 @@ assign_error:
298366
 
298366
 static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
298366
 {
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     int r;
298366
     int n;
298366
 
45bdef
@@ -244,7 +257,7 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
298366
     }
298366
 
298366
     for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
298366
-        if (!virtio_queue_get_num(proxy->vdev, n)) {
298366
+        if (!virtio_queue_get_num(vdev, n)) {
298366
             continue;
298366
         }
298366
 
45bdef
@@ -257,7 +270,7 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
298366
 static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
298366
 {
298366
     VirtIOPCIProxy *proxy = opaque;
298366
-    VirtIODevice *vdev = proxy->vdev;
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     hwaddr pa;
298366
 
298366
     switch (addr) {
45bdef
@@ -272,7 +285,7 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
298366
         pa = (hwaddr)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT;
298366
         if (pa == 0) {
298366
             virtio_pci_stop_ioeventfd(proxy);
298366
-            virtio_reset(proxy->vdev);
298366
+            virtio_reset(vdev);
298366
             msix_unuse_all_vectors(&proxy->pci_dev);
298366
         }
298366
         else
45bdef
@@ -299,7 +312,7 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
298366
         }
298366
 
298366
         if (vdev->status == 0) {
298366
-            virtio_reset(proxy->vdev);
298366
+            virtio_reset(vdev);
298366
             msix_unuse_all_vectors(&proxy->pci_dev);
298366
         }
298366
 
45bdef
@@ -335,7 +348,7 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
298366
 
298366
 static uint32_t virtio_ioport_read(VirtIOPCIProxy *proxy, uint32_t addr)
298366
 {
298366
-    VirtIODevice *vdev = proxy->vdev;
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     uint32_t ret = 0xFFFFFFFF;
298366
 
298366
     switch (addr) {
45bdef
@@ -381,6 +394,7 @@ static uint64_t virtio_pci_config_read(void *opaque, hwaddr addr,
298366
                                        unsigned size)
298366
 {
298366
     VirtIOPCIProxy *proxy = opaque;
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev);
298366
     uint64_t val = 0;
298366
     if (addr < config) {
45bdef
@@ -390,16 +404,16 @@ static uint64_t virtio_pci_config_read(void *opaque, hwaddr addr,
298366
 
298366
     switch (size) {
298366
     case 1:
298366
-        val = virtio_config_readb(proxy->vdev, addr);
298366
+        val = virtio_config_readb(vdev, addr);
298366
         break;
298366
     case 2:
298366
-        val = virtio_config_readw(proxy->vdev, addr);
298366
+        val = virtio_config_readw(vdev, addr);
298366
         if (virtio_is_big_endian()) {
298366
             val = bswap16(val);
298366
         }
298366
         break;
298366
     case 4:
298366
-        val = virtio_config_readl(proxy->vdev, addr);
298366
+        val = virtio_config_readl(vdev, addr);
298366
         if (virtio_is_big_endian()) {
298366
             val = bswap32(val);
298366
         }
45bdef
@@ -413,6 +427,7 @@ static void virtio_pci_config_write(void *opaque, hwaddr addr,
298366
 {
298366
     VirtIOPCIProxy *proxy = opaque;
298366
     uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     if (addr < config) {
298366
         virtio_ioport_write(proxy, addr, val);
298366
         return;
45bdef
@@ -424,19 +439,19 @@ static void virtio_pci_config_write(void *opaque, hwaddr addr,
298366
      */
298366
     switch (size) {
298366
     case 1:
298366
-        virtio_config_writeb(proxy->vdev, addr, val);
298366
+        virtio_config_writeb(vdev, addr, val);
298366
         break;
298366
     case 2:
298366
         if (virtio_is_big_endian()) {
298366
             val = bswap16(val);
298366
         }
298366
-        virtio_config_writew(proxy->vdev, addr, val);
298366
+        virtio_config_writew(vdev, addr, val);
298366
         break;
298366
     case 4:
298366
         if (virtio_is_big_endian()) {
298366
             val = bswap32(val);
298366
         }
298366
-        virtio_config_writel(proxy->vdev, addr, val);
298366
+        virtio_config_writel(vdev, addr, val);
298366
         break;
298366
     }
298366
 }
45bdef
@@ -455,6 +470,7 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
298366
                                 uint32_t val, int len)
298366
 {
298366
     VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
 
298366
     pci_default_write_config(pci_dev, address, val, len);
298366
 
45bdef
@@ -462,8 +478,7 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
298366
         !(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER) &&
298366
         !(proxy->flags & VIRTIO_PCI_FLAG_BUS_MASTER_BUG)) {
298366
         virtio_pci_stop_ioeventfd(proxy);
298366
-        virtio_set_status(proxy->vdev,
298366
-                          proxy->vdev->status & ~VIRTIO_CONFIG_S_DRIVER_OK);
298366
+        virtio_set_status(vdev, vdev->status & ~VIRTIO_CONFIG_S_DRIVER_OK);
298366
     }
298366
 }
298366
 
45bdef
@@ -506,7 +521,8 @@ static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy,
298366
                                  unsigned int vector)
298366
 {
298366
     VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
298366
-    VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+    VirtQueue *vq = virtio_get_queue(vdev, queue_no);
298366
     EventNotifier *n = virtio_queue_get_guest_notifier(vq);
298366
     int ret;
45bdef
     ret = kvm_irqchip_add_irqfd_notifier(kvm_state, n, NULL, irqfd->virq);
45bdef
@@ -517,7 +533,8 @@ static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy,
298366
                                       unsigned int queue_no,
298366
                                       unsigned int vector)
298366
 {
298366
-    VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+    VirtQueue *vq = virtio_get_queue(vdev, queue_no);
298366
     EventNotifier *n = virtio_queue_get_guest_notifier(vq);
298366
     VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
298366
     int ret;
45bdef
@@ -529,7 +546,7 @@ static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy,
298366
 static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs)
298366
 {
298366
     PCIDevice *dev = &proxy->pci_dev;
298366
-    VirtIODevice *vdev = proxy->vdev;
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
298366
     unsigned int vector;
298366
     int ret, queue_no;
45bdef
@@ -578,7 +595,7 @@ undo:
298366
 static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs)
298366
 {
298366
     PCIDevice *dev = &proxy->pci_dev;
298366
-    VirtIODevice *vdev = proxy->vdev;
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     unsigned int vector;
298366
     int queue_no;
298366
     VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
45bdef
@@ -606,8 +623,9 @@ static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
298366
                                        unsigned int vector,
298366
                                        MSIMessage msg)
298366
 {
298366
-    VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(proxy->vdev);
298366
-    VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+    VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
298366
+    VirtQueue *vq = virtio_get_queue(vdev, queue_no);
298366
     EventNotifier *n = virtio_queue_get_guest_notifier(vq);
298366
     VirtIOIRQFD *irqfd;
298366
     int ret = 0;
45bdef
@@ -626,10 +644,10 @@ static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
298366
      * Otherwise, set it up now.
298366
      */
298366
     if (k->guest_notifier_mask) {
298366
-        k->guest_notifier_mask(proxy->vdev, queue_no, false);
298366
+        k->guest_notifier_mask(vdev, queue_no, false);
298366
         /* Test after unmasking to avoid losing events. */
298366
         if (k->guest_notifier_pending &&
298366
-            k->guest_notifier_pending(proxy->vdev, queue_no)) {
298366
+            k->guest_notifier_pending(vdev, queue_no)) {
298366
             event_notifier_set(n);
298366
         }
298366
     } else {
45bdef
@@ -642,13 +660,14 @@ static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *proxy,
298366
                                              unsigned int queue_no,
298366
                                              unsigned int vector)
298366
 {
298366
-    VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(proxy->vdev);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+    VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
298366
 
298366
     /* If guest supports masking, keep irqfd but mask it.
298366
      * Otherwise, clean it up now.
298366
      */ 
298366
     if (k->guest_notifier_mask) {
298366
-        k->guest_notifier_mask(proxy->vdev, queue_no, true);
298366
+        k->guest_notifier_mask(vdev, queue_no, true);
298366
     } else {
298366
         kvm_virtio_pci_irqfd_release(proxy, queue_no, vector);
298366
     }
45bdef
@@ -658,7 +677,7 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector,
298366
                                     MSIMessage msg)
298366
 {
298366
     VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
298366
-    VirtIODevice *vdev = proxy->vdev;
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     int ret, queue_no;
298366
 
298366
     for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) {
45bdef
@@ -688,7 +707,7 @@ undo:
298366
 static void virtio_pci_vector_mask(PCIDevice *dev, unsigned vector)
298366
 {
298366
     VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
298366
-    VirtIODevice *vdev = proxy->vdev;
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     int queue_no;
298366
 
298366
     for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) {
45bdef
@@ -707,7 +726,7 @@ static void virtio_pci_vector_poll(PCIDevice *dev,
298366
                                    unsigned int vector_end)
298366
 {
298366
     VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
298366
-    VirtIODevice *vdev = proxy->vdev;
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
298366
     int queue_no;
298366
     unsigned int vector;
45bdef
@@ -739,8 +758,9 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
298366
                                          bool with_irqfd)
298366
 {
298366
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
298366
-    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(proxy->vdev);
298366
-    VirtQueue *vq = virtio_get_queue(proxy->vdev, n);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
298366
+    VirtQueue *vq = virtio_get_queue(vdev, n);
298366
     EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
298366
 
298366
     if (assign) {
45bdef
@@ -755,7 +775,7 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
298366
     }
298366
 
298366
     if (!msix_enabled(&proxy->pci_dev) && vdc->guest_notifier_mask) {
298366
-        vdc->guest_notifier_mask(proxy->vdev, n, !assign);
298366
+        vdc->guest_notifier_mask(vdev, n, !assign);
298366
     }
298366
 
298366
     return 0;
45bdef
@@ -770,7 +790,7 @@ static bool virtio_pci_query_guest_notifiers(DeviceState *d)
298366
 static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign)
298366
 {
298366
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
298366
-    VirtIODevice *vdev = proxy->vdev;
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
     VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
298366
     int r, n;
298366
     bool with_irqfd = msix_enabled(&proxy->pci_dev) &&
45bdef
@@ -864,11 +884,12 @@ static int virtio_pci_set_host_notifier(DeviceState *d, int n, bool assign)
298366
 static void virtio_pci_vmstate_change(DeviceState *d, bool running)
298366
 {
298366
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
298366
+    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
298366
 
298366
     if (running) {
298366
         /* Try to find out if the guest has bus master disabled, but is
298366
            in ready state. Then we have a buggy guest OS. */
298366
-        if ((proxy->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) &&
298366
+        if ((vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) &&
298366
             !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {
298366
             proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
298366
         }
45bdef
@@ -943,8 +964,6 @@ static void virtio_pci_device_plugged(DeviceState *d)
298366
     uint8_t *config;
298366
     uint32_t size;
298366
 
298366
-    proxy->vdev = virtio_bus_get_device(bus);
298366
-
298366
     config = proxy->pci_dev.config;
298366
     if (proxy->class_code) {
298366
         pci_config_set_class(config, proxy->class_code);
298366
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
298366
index 917bcc5..dc332ae 100644
298366
--- a/hw/virtio/virtio-pci.h
298366
+++ b/hw/virtio/virtio-pci.h
298366
@@ -82,7 +82,6 @@ typedef struct VirtioPCIClass {
298366
 
298366
 struct VirtIOPCIProxy {
298366
     PCIDevice pci_dev;
298366
-    VirtIODevice *vdev;
298366
     MemoryRegion bar;
298366
     uint32_t flags;
298366
     uint32_t class_code;