summaryrefslogtreecommitdiff
path: root/hw/virtio-pci.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-10-21 15:25:35 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-27 12:28:40 -0500
commit97b156213e0e38b29da4480a32d4ec33d14d3012 (patch)
tree051ed08c9332b8d80e852051176d0b28228eae03 /hw/virtio-pci.c
parent254111ecc80501a7d5c0e82f78bfa5ca8749ae20 (diff)
virtio: use qdev properties for configuration.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-pci.c')
-rw-r--r--hw/virtio-pci.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index e07a2a77e2..1665b59baa 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -20,6 +20,7 @@
#include "sysemu.h"
#include "msix.h"
#include "net.h"
+#include "loader.h"
/* from Linux's linux/virtio_pci.h */
@@ -90,6 +91,7 @@ typedef struct {
uint32_t class_code;
uint32_t nvectors;
DriveInfo *dinfo;
+ NICConf nic;
} VirtIOPCIProxy;
/* virtio device */
@@ -493,14 +495,9 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
VirtIODevice *vdev;
- vdev = virtio_net_init(&pci_dev->qdev);
-
- /* set nvectors from property, unless the user specified something
- * via -net nic,model=virtio,vectors=n command line option */
- if (pci_dev->qdev.nd->nvectors == NIC_NVECTORS_UNSPECIFIED)
- if (proxy->nvectors != NIC_NVECTORS_UNSPECIFIED)
- vdev->nvectors = proxy->nvectors;
+ vdev = virtio_net_init(&pci_dev->qdev, &proxy->nic);
+ vdev->nvectors = proxy->nvectors;
virtio_init_pci(proxy, vdev,
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_NET,
@@ -509,9 +506,25 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
/* make the actual value visible */
proxy->nvectors = vdev->nvectors;
+
+ if (!pci_dev->qdev.hotplugged) {
+ static int loaded = 0;
+ if (!loaded) {
+ rom_add_option("pxe-virtio.bin");
+ loaded = 1;
+ }
+ }
return 0;
}
+static int virtio_net_exit_pci(PCIDevice *pci_dev)
+{
+ VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+
+ virtio_net_exit(proxy->vdev);
+ return virtio_exit_pci(pci_dev);
+}
+
static int virtio_balloon_init_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
@@ -543,10 +556,10 @@ static PCIDeviceInfo virtio_info[] = {
.qdev.name = "virtio-net-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
.init = virtio_net_init_pci,
- .exit = virtio_exit_pci,
+ .exit = virtio_net_exit_pci,
.qdev.props = (Property[]) {
- DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
- NIC_NVECTORS_UNSPECIFIED),
+ DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
+ DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,