qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Converting PCIDevice to VirtIODevice


From: Laszlo Ersek
Subject: Re: [Qemu-devel] Converting PCIDevice to VirtIODevice
Date: Wed, 26 Sep 2018 19:50:56 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 09/26/18 17:33, Sameeh Jubran wrote:
> Hi All,
> 
> I have used the function "pci_qdev_find_device" to find a device using
> it's id. This is a virtio device and I'm trying to convert it to
> VirtIODevice.
> 
> What's the best way to do this? Simply converting it to DeviceState
> doesn't work and I think I should access the underlying virtio pci bus
> and through it access the virtio-device, but couldn't find any elegant
> way of doing so.

pci_qdev_find_device() produces a pointer-to-PCIDevice.

In virtio_pci_realize() [hw/virtio/virtio-pci.c] we see that the
following works:

    VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev);

And in virtio_pci_pre_plugged() [hw/virtio/virtio-pci.c], we find:

    VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);

Hope this helps (in fact, I hope it *works*! :) )
Laszlo



reply via email to

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