From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58868 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOGiZ-0007zk-KQ for qemu-devel@nongnu.org; Mon, 14 Jun 2010 16:57:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOGiY-0007r9-Ey for qemu-devel@nongnu.org; Mon, 14 Jun 2010 16:57:15 -0400 Received: from mail-iw0-f173.google.com ([209.85.214.173]:56474) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOGiY-0007ly-Af for qemu-devel@nongnu.org; Mon, 14 Jun 2010 16:57:14 -0400 Received: by mail-iw0-f173.google.com with SMTP id 10so4582648iwn.4 for ; Mon, 14 Jun 2010 13:57:14 -0700 (PDT) Message-ID: <4C1697AB.9090805@codemonkey.ws> Date: Mon, 14 Jun 2010 15:57:15 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] qdev: Revert the hack to let -net nic and pci_add set qdev ID References: <1275998044-2715-1-git-send-email-armbru@redhat.com> In-Reply-To: <1275998044-2715-1-git-send-email-armbru@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, kraxel@redhat.com On 06/08/2010 06:54 AM, Markus Armbruster wrote: > 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 > Applied. Thanks. Regards, Anthony Liguori > --- > hw/pci.c | 2 -- > 1 files changed, 0 insertions(+), 2 deletions(-) > > diff --git a/hw/pci.c b/hw/pci.c > index cbbd1dd..fab8c09 100644 > --- 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; >