qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qdev: Revert the hack to let -net nic and pci_add set qdev ID
Date: Mon, 14 Jun 2010 15:57:15 -0500	[thread overview]
Message-ID: <4C1697AB.9090805@codemonkey.ws> (raw)
In-Reply-To: <1275998044-2715-1-git-send-email-armbru@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<armbru@redhat.com>
>    

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;
>    

      reply	other threads:[~2010-06-14 20:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-08 11:54 [Qemu-devel] [PATCH] qdev: Revert the hack to let -net nic and pci_add set qdev ID Markus Armbruster
2010-06-14 20:57 ` Anthony Liguori [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C1697AB.9090805@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).