Re: Example of using virtio network interfaces from application code

2017-04-18 Thread Rick Payne (Offshore)

> On 13 Apr 2017, at 05:46, Nadav Har'El  wrote:
> 
> It's not exactly what Rick asked for (virtio), but maybe it's good enough.

The pfil_add_hook() functionality may be sufficient, thanks! I’ll give it a go.

Cheers,
Rick

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Example of using virtio network interfaces from application code

2017-04-13 Thread Nadav Har'El
On Wed, Apr 12, 2017 at 8:36 PM, Dor Laor  wrote:

> We did hack memcache to get packets directly from the device. You can
> search for this example, it might be good enough for you
>
>
What Dor is referring to is https://github.com/vladzcloudius/osv-memcached
(you can build it with "scripts/build image=osv-memcached")

It uses the pfil_add_hook() function to add a picket filtering hook, which
recieves all packets, and ifn->if_transmit() to transmit the return packet.

It's not exactly what Rick asked for (virtio), but maybe it's good enough.

This code too hasn't been used in a very long time, so I hope it hasn't
rotted too much.

Nadav.

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Example of using virtio network interfaces from application code

2017-04-12 Thread Dor Laor
We did hack memcache to get packets directly from the device. You can
search for this example, it might be good enough for you

On Apr 12, 2017 7:12 AM, "Nadav Har'El"  wrote:

>
> On Mon, Apr 10, 2017 at 1:05 AM, Rick Payne (Offshore) <
> ri...@rossfell.co.uk> wrote:
>
>> Hi,
>>
>> Is there a good example that uses the virtio network interfaces direct?
>> ie. an application that uses ‘assign-net’ and talks directly to the network
>> interface code in OSv?
>>
>> I’m looking for a sample I can learn from.
>>
>
> Unfortunately, we never documented the "assigned virtio" API.
>
> Basically, the "assigned virtio" idea was to allow OSv to set up the
> virtio-net device, and then give the application an API to control it
> directly.
> Before a virtio device can be assigned to the application, OSv needs to
> know not to use it itself. The boot-time option --assign-net  tells OSv
> *not* to use a virtio-net device given to it by the host (if any), and
> instead assign it to the application.
>
> You can see see include/osv/virtio-assign.hh for the full API.
> For example, the application can then use osv::assigned_virtio::get() to
> get access to this device, and properly set it up and use it. Then the
> application can use this API to access the rings, to kick, and to get
> notifications.
>
> The only place we ever used this API (and even that we haven't tested in a
> long time, so I hope it didn't rot too much...) was in Seastar. Check out
> commit f497299f446846767eda74a7265411b573b5a280 for how we used it in
> Seastar
>
> It would be nice to turn this feature into something more lively and used,
> and better documented.
>
> Nadav.
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osv-dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Example of using virtio network interfaces from application code

2017-04-12 Thread Nadav Har'El
On Mon, Apr 10, 2017 at 1:05 AM, Rick Payne (Offshore)  wrote:

> Hi,
>
> Is there a good example that uses the virtio network interfaces direct?
> ie. an application that uses ‘assign-net’ and talks directly to the network
> interface code in OSv?
>
> I’m looking for a sample I can learn from.
>

Unfortunately, we never documented the "assigned virtio" API.

Basically, the "assigned virtio" idea was to allow OSv to set up the
virtio-net device, and then give the application an API to control it
directly.
Before a virtio device can be assigned to the application, OSv needs to
know not to use it itself. The boot-time option --assign-net  tells OSv
*not* to use a virtio-net device given to it by the host (if any), and
instead assign it to the application.

You can see see include/osv/virtio-assign.hh for the full API.
For example, the application can then use osv::assigned_virtio::get() to
get access to this device, and properly set it up and use it. Then the
application can use this API to access the rings, to kick, and to get
notifications.

The only place we ever used this API (and even that we haven't tested in a
long time, so I hope it didn't rot too much...) was in Seastar. Check out
commit f497299f446846767eda74a7265411b573b5a280 for how we used it in
Seastar

It would be nice to turn this feature into something more lively and used,
and better documented.

Nadav.

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Example of using virtio network interfaces from application code

2017-04-10 Thread Dor Laor
On Sun, Apr 9, 2017 at 3:05 PM, Rick Payne (Offshore) 
wrote:

> Hi,
>
> Is there a good example that uses the virtio network interfaces direct?
> ie. an application that uses ‘assign-net’ and talks directly to the network
> interface code in OSv?
>

Not that I know of. It was a cool idea but most of the OSv applications are
just standard, unmodified apps
in Linux. If one writes a special app for OSv it's possible.
In the seastar project we actually wrote a virtio backend to extract
packets from the kernel but it wasn't the
device itself.


>
> I’m looking for a sample I can learn from.
>
> Cheers,
> Rick
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osv-dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.