]> git.proxmox.com Git - qemu.git/commitdiff
qdev: Revert the hack to let -net nic and pci_add set qdev ID
authorMarkus Armbruster <armbru@redhat.com>
Tue, 8 Jun 2010 11:54:04 +0000 (13:54 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 14 Jun 2010 20:46:28 +0000 (15:46 -0500)
Setting the ID in pci_nic_init() is a blatant violation of the
DeviceState abstraction.  Which even carries a comment advising
against this:

/* This structure should not be accessed directly.  We declare it here
   so that it can be embedded in individual device state structures.  */

What's worse, it bypasses the code ensuring unique qdev IDs: "-device
virtio-net-pci,id=foo -net nic,id=foo -net nic,name=foo" happily
creates three qdevs with ID "foo".  That's because qdev relies on
qemu_opts_create() to ensure unique IDs, but -net nic uses a different
QemuOptsList, which means id is in a different namespace.  And its
name is not checked for uniqueness at all.

-net nic and pci_add are legacy.  Use -device and device_add if you
want a NIC with a qdev ID.

This reverts what's still left of commit eb54b6dc "qdev: add id=
support for pci nics."

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/pci.c

index cd7ce8d9c86a96685950be31b455a5023abeb95c..7787005bdb61aa12b151b7a43cdc479f6d399c1c 100644 (file)
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1446,8 +1446,6 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
 
     pci_dev = pci_create(bus, devfn, pci_nic_names[i]);
     dev = &pci_dev->qdev;
-    if (nd->name)
-        dev->id = qemu_strdup(nd->name);
     qdev_set_nic_properties(dev, nd);
     if (qdev_init(dev) < 0)
         return NULL;