qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Functions bus_foreach and device_find from libq


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] Functions bus_foreach and device_find from libqos virtio API
Date: Thu, 26 Jun 2014 17:09:12 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

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 via email to

[Prev in Thread] Current Thread [Next in Thread]