All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Assigning a new virtio block device (-drive)
@ 2011-10-27 12:47 Leib, David
  2011-10-27 15:14 ` Paolo Bonzini
  2011-10-28  7:09 ` Markus Armbruster
  0 siblings, 2 replies; 3+ messages in thread
From: Leib, David @ 2011-10-27 12:47 UTC (permalink / raw)
  To: qemu-devel

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

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);

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.
Many thanks,


David Leib
SAP Research Belfast
SAP (UK) Limited   I   The Concourse   I   Queen's Road   I   Queen's Island   I   Belfast BT3 9DT

mailto: david.leib@sap.com<mailto:mary.clarke@sap.com>  I   www.sap.com/research<http://www.sap.com/research>

--------------------------------------------------------------------------------------------------------------------------
This communication contains information which is confidential and may also be privileged. It is for the exclusive use of the addressee. If you are not the addressee please contact us immediately and also delete the communication from your computer. Steps have been taken to ensure this e-mail is free from computer viruses but the recipient is responsible for ensuring that it is actually virus free before opening it or any attachments. Any views and/or opinions expressed in this e-mail are of the author only and do not represent the views of SAP.

SAP (UK) Limited, Registered in England No. 2152073. Registered Office: Clockhouse Place, Bedfont Road, Feltham, Middlesex, TW14 8HD
---------------------------------------------------------------------------------------------------------------------------




[-- Attachment #2: Type: text/html, Size: 8674 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Assigning a new virtio block device (-drive)
  2011-10-27 12:47 [Qemu-devel] Assigning a new virtio block device (-drive) Leib, David
@ 2011-10-27 15:14 ` Paolo Bonzini
  2011-10-28  7:09 ` Markus Armbruster
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2011-10-27 15:14 UTC (permalink / raw)
  To: Leib, David; +Cc: qemu-devel

On 10/27/2011 02:47 PM, Leib, David wrote:
> and insert the same data like the normal virtio block device
> (“file=/dev/sr0” and “if=virtio”) in qemu_config.c.

I'm not sure what you are doing wrong exactly, but try using if=none and 
creating the device separately with -device.  You shouldn't need the new 
"ablock" QemuOpts.

Paolo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Assigning a new virtio block device (-drive)
  2011-10-27 12:47 [Qemu-devel] Assigning a new virtio block device (-drive) Leib, David
  2011-10-27 15:14 ` Paolo Bonzini
@ 2011-10-28  7:09 ` Markus Armbruster
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2011-10-28  7:09 UTC (permalink / raw)
  To: Leib, David; +Cc: qemu-devel

"Leib, David" <david.leib@sap.com> 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).

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-28  7:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-27 12:47 [Qemu-devel] Assigning a new virtio block device (-drive) Leib, David
2011-10-27 15:14 ` Paolo Bonzini
2011-10-28  7:09 ` Markus Armbruster

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.