Patchwork [RfC,v3,08/10] prepare pci nic init path for qdev conversion

login
register
mail settings
Submitter Gerd Hoffmann
Date Oct. 16, 2009, 1:42 p.m.
Message ID <1255700523-15270-9-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/36221/
State New
Headers show

Comments

Gerd Hoffmann - Oct. 16, 2009, 1:42 p.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/pci.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

Patch

diff --git a/hw/pci.c b/hw/pci.c
index abf07ca..fe8e939 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -859,10 +859,20 @@  PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
     dev = &pci_dev->qdev;
     if (nd->name)
         dev->id = qemu_strdup(nd->name);
-    dev->nd = nd;
+    if (qdev_prop_exists(dev, "mac")) {
+        /* qdev-ified */
+        qdev_prop_set_macaddr(dev, "mac", nd->macaddr);
+        if (nd->vlan)
+            qdev_prop_set_vlan(dev, "vlan", nd->vlan);
+        if (nd->netdev)
+            qdev_prop_set_netdev(dev, "netdev", nd->netdev);
+    } else {
+        /* legacy */
+        dev->nd = nd;
+        nd->private = dev;
+    }
     if (qdev_init(dev) < 0)
         return NULL;
-    nd->private = dev;
     return pci_dev;
 }