qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Assigning a new virtio block device (-drive)


From: Markus Armbruster
Subject: Re: [Qemu-devel] Assigning a new virtio block device (-drive)
Date: Fri, 28 Oct 2011 09:09:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

"Leib, David" <address@hidden> writes:

> Hi,
> I am trying to assign a new virtio block device in addition to a normal 
> virtio block device who are accessing exactly the same cdrom drive 
> ("/dev/sr0") because I additionaly want to access the block device in my way 
> by manually calling the virtqueue_pop and virtqueue_push and not the normal 
> way they are called.
> At the kvm startup I am assigning this additional qemu rblock device in the 
> vm_config_groups by adding a new QemuOptsList:
>
> static QemuOptsList qemu_ablock_opts = {
>     .name = "ablock",
>     .head = QTAILQ_HEAD_INITIALIZER(qemu_ablock_opts.head),
>     .desc = {
>                         ..... normal options like the original virtio block 
> device .....
>         { /* end of list */ }
>     },
> };
>
> and insert the same data like the normal virtio block device ("file=/dev/sr0" 
> and "if=virtio") in qemu_config.c.
> After that I am calling the normal drive_init_func  ("vl.c") with this 
> command :
>
> qemu_opts_foreach(qemu_find_opts("ablock"), drive_init_func, 
> &machine->use_scsi, 1);

Your new qemu_ablock_opts won't do a thing without something that writes
configuration data to it.  For qemu_drive_opts, that's drive_def(),
which runs on behalf of -drive and drive hot plug.

> I also added PCIDeviceInfo to the virtio_info array who looks like this:
>     {
>                 .qdev.name = "additional_blk_pci",
>                 .qdev.alias = "additional-blk",
>                 .qdev.size = sizeof(VirtIOPCIProxy),
>                 .init      = virtio_blk_init_pci_additional,
>                 .exit      = virtio_blk_exit_pci,
>                 .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
>                 .device_id = PCI_DEVICE_ID_VIRTIO_BLOCK,
>                 .revision  = VIRTIO_PCI_ABI_VERSION,
>                 .class_id  = PCI_CLASS_STORAGE_SCSI,
>                 .qdev.props = (Property[]) {
>                         DEFINE_PROP_HEX32("class", VirtIOPCIProxy, 
> class_code, 0),
>                         DEFINE_BLOCK_PROPERTIES(VirtIOPCIProxy, block),
>                         DEFINE_PROP_STRING("serial", VirtIOPCIProxy, 
> block_serial),
>                         DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
>                                                         
> VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
>                         DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, 
> nvectors, 2),
>                         DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, 
> host_features),
>                         DEFINE_PROP_END_OF_LIST(),
>                 },
>                 .qdev.reset = virtio_pci_reset,
>         },
> It is completely the same like the normal "virtio-blk-pci" except the .init 
> function that I replaced with my own init-function.
> My problem now is that this init-function is never called when I am starting 
> up the kvm. It only calling the the init-function of "virtio-blk-pci" two 
> times and my PCIDeviceInfo init-function is completely ignored.
> The initialisation of all virtio_info's in "virtio-pci.c" works fine but my 
> init-function is never used.
> I tried to initialise only my "additional-virtio-blk-pci" device but is still 
> calling the init-function from "virtio-blk-pci".
> I hope somebody can give me idea where the problem is.

Try -device additional_blk_pci.  Check out docs/qdev-device-use.txt for
how to go from -drive if=virtio (which doesn't use your device) to
-device (which should be able to use your device).



reply via email to

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