On Tue, Sep 12, 2023 at 01:04:11PM +0000, Sánta, Márton (ext) wrote:
>>Dear Users,
>>
>>I use KVM with libvirt 9.0.0. The host and guest OS-es are also AGL needlefish
images. I am currently trying to virtualize a CAN driver and provide virtual machines
access to the physical CAN channels.
>>
>>I started with the virtual network handling as CAN interface is a network
interface, I tried to find analogies, solutions like "traditional" network
handling but it did not work.
>>I also tried out to define a nodedev device via .xml config file. The interesting
thing is, that when I list all the available nodedev devices with 'virsh
nodedev-list', I can see 'net_can0' and 'net_can1' on the output as
'net' type device but I cannot attach these devices to the guests, and I do not
know how to define it in the guest .xml file. I tried out many different things, but when
I try to add it as a 'hostdev' device with different mode and type settings, I
always get an error (e.g. not a PCI device or not supported device type etc.). It would be
long to write down all the configurations I tried out, so my first question would be that
does anybody know how could I provide access to guests to the physical CAN interfaces? The
aim is to be able to send CAN messages from guest OS-es. If no direct access is possible,
it would be also OK to have access to virtual CAN interfaces on the host and then transfer
messages to the physical CAN channel.
>>
>Hi. CAN devices need a couple more specifications for how the device should be
created and even though your analogy went the right way libvirt does not (yet) support CAN
device emulation for any hypervisor driver. I had a plan to write it at some point, but I
saw nobody requesting that and did not have enough free time to do that.
Thank you very much for your feedback. Is there any other solutions you know about? Maybe
any QEMU passthrough argument which could help to virtualize CAN driver?
You can definitely use passthrough for that:
https://libvirt.org/drvqemu.html#pass-through-of-arbitrary-qemu-commands
I don't know about many other options for now.
>For completeness sake; the fact that you see the devices in
nodedev-list is a consequence of us not filtering the devices at all, just reporting on
what we find on the host.
>Patches would be appreciated, I myself won't probably get to adding such support
any time soon.
>Have a nice day,
>Martin
Thank you!
Márton
-----Original Message-----
From: Martin Kletzander <mkletzan(a)redhat.com>
Sent: Tuesday, August 29, 2023 9:16 AM
To: Sánta, Márton (ext) <Marton.Santa(a)knorr-bremse.com>
Cc: libvirt-users(a)redhat.com
Subject: Re: CAN virtualization
On Wed, Aug 23, 2023 at 01:15:36PM +0000, Sánta, Márton (ext) wrote:
>Dear Users,
>
>I use KVM with libvirt 9.0.0. The host and guest OS-es are also AGL needlefish images.
I am currently trying to virtualize a CAN driver and provide virtual machines access to
the physical CAN channels.
>
>I started with the virtual network handling as CAN interface is a network interface, I
tried to find analogies, solutions like "traditional" network handling but it
did not work.
>I also tried out to define a nodedev device via .xml config file. The interesting
thing is, that when I list all the available nodedev devices with 'virsh
nodedev-list', I can see 'net_can0' and 'net_can1' on the output as
'net' type device but I cannot attach these devices to the guests, and I do not
know how to define it in the guest .xml file. I tried out many different things, but when
I try to add it as a 'hostdev' device with different mode and type settings, I
always get an error (e.g. not a PCI device or not supported device type etc.). It would be
long to write down all the configurations I tried out, so my first question would be that
does anybody know how could I provide access to guests to the physical CAN interfaces? The
aim is to be able to send CAN messages from guest OS-es. If no direct access is possible,
it would be also OK to have access to virtual CAN interfaces on the host and then transfer
messages to the physical CAN channel.
>
Hi. CAN devices need a couple more specifications for how the device should be created
and even though your analogy went the right way libvirt does not (yet) support CAN device
emulation for any hypervisor driver. I had a plan to write it at some point, but I saw
nobody requesting that and did not have enough free time to do that.
For completeness sake; the fact that you see the devices in nodedev-list is a consequence
of us not filtering the devices at all, just reporting on what we find on the host.
Patches would be appreciated, I myself won't probably get to adding such support any
time soon.
Have a nice day,
Martin
>Thank you in advance for an early reply!
>
>Best regard,
>
>Márton Sánta
>
>
>This transmission is intended solely for the addressee and contains confidential
information.
>If you are not the intended recipient, please immediately inform the sender and delete
the message and any attachments from your system.
>Furthermore, please do not copy the message or disclose the contents to anyone unless
agreed otherwise. To the extent permitted by law we shall in no way be liable for any
damages, whatever their nature, arising out of transmission failures, viruses, external
influence, delays and the like.
This transmission is intended solely for the addressee and contains confidential
information.
If you are not the intended recipient, please immediately inform the sender and delete the
message and any attachments from your system.
Furthermore, please do not copy the message or disclose the contents to anyone unless
agreed otherwise. To the extent permitted by law we shall in no way be liable for any
damages, whatever their nature, arising out of transmission failures, viruses, external
influence, delays and the like.