All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Marc Marí" <marc.mari.barcelo@gmail.com>, qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] Functions bus_foreach and device_find from libqos virtio API
Date: Thu, 26 Jun 2014 17:09:12 +0200	[thread overview]
Message-ID: <53AC3798.50302@redhat.com> (raw)
In-Reply-To: <1403793280-4353-1-git-send-email-marc.mari.barcelo@gmail.com>

Il 26/06/2014 16:34, Marc Marí ha scritto:
> +static void qvirtio_pci_foreach(uint16_t device_type,
> +                void (*func)(QVirtioDevice *d, void *data), void *data)
> +{
> +    QVirtioPCIForeachData d = { .func = func,
> +                                .device_type = device_type,
> +                                .user_data = data };
> +
> +    if (!bus) {
> +        bus = qpci_init_pc();

Why not pass this as an argument?  .bus_foreach and .device_find need 
not be part of QVirtioBus.

> +    }
> +
> +    qpci_device_foreach(bus, QVIRTIO_VENDOR_ID, -1,
> +                                qvirtio_pci_foreach_callback, &d);
> +}
> +
> +static QVirtioDevice *qvirtio_pci_device_find(uint16_t device_type)

(Also here, qvirtio_pci_device_find would just forward the bus to 
qvirtio_pci_foreach).

> +    fprintf(stderr, "Device position: %x. Device type: %x\n",
> +                                    dev->pdev->devfn, dev->vdev.device_type);

You can change these to assertions, and get your first testcase too. :)

You can set the address in the qtest_start argument (like "-device 
virtio-blk-pci,...,addr=0x0a.0") so you know the expected value.

Otherwise looks good!

Paolo

> +{
> +    QVirtioPCIDevice *dev;
> +
> +    dev = g_malloc0(sizeof(*dev));
> +    qvirtio_pci_foreach(device_type, qvirtio_pci_assign_device, dev);
> +
> +    return (QVirtioDevice *)dev;
> +}

  reply	other threads:[~2014-06-26 15:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 14:34 [Qemu-devel] [PATCH] Functions bus_foreach and device_find from libqos virtio API Marc Marí
2014-06-26 15:09 ` Paolo Bonzini [this message]
2014-06-26 15:27   ` Marc Marí
2014-06-26 15:35     ` Paolo Bonzini
2014-06-26 16:44 ` Fam Zheng
2014-06-30  7:50 ` Stefan Hajnoczi

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=53AC3798.50302@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=marc.mari.barcelo@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.