qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Marc Marí" <marc.mari.barcelo@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4] tests: Functions bus_foreach and device_find from libqos virtio API
Date: Wed, 9 Jul 2014 10:57:00 +0200	[thread overview]
Message-ID: <20140709085700.GD5152@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1404427009-15815-1-git-send-email-marc.mari.barcelo@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 924 bytes --]

On Fri, Jul 04, 2014 at 12:36:49AM +0200, Marc Marí wrote:
> +static void qvirtio_pci_foreach_callback(
> +                        QPCIDevice *dev, int devfn, void *data)
> +{
> +    QVirtioPCIForeachData *d = data;
> +    QVirtioPCIDevice *vpcidev = qpcidevice_to_qvirtiodevice(dev);
> +
> +    if (vpcidev->vdev.device_type == d->device_type) {
> +        d->func(&vpcidev->vdev, d->user_data);
> +    }
> +
> +    g_free(vpcidev);

Fine for now but eventually I think we need to pass ownership of vpcidev
to ->func() and only free vpcidev if the device type didn't match.

> +QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type)
> +{
> +    QVirtioPCIDevice *dev;
> +
> +    dev = g_malloc0(sizeof(*dev));
> +    qvirtio_pci_foreach(bus, device_type, qvirtio_pci_assign_device, dev);
> +
> +    return dev;
> +}

What if the device is not found, should we return NULL?

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

      reply	other threads:[~2014-07-09  8:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-03 22:36 [Qemu-devel] [PATCH v4] tests: Functions bus_foreach and device_find from libqos virtio API Marc Marí
2014-07-09  8:57 ` Stefan Hajnoczi [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=20140709085700.GD5152@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=marc.mari.barcelo@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).