Subject: Re: [vserver] Device drivers
From: Siv <punumaa@gmail.com>
Date: Wed, 30 Jun 2010 17:10:48 -0700
Wed, 30 Jun 2010 17:10:48 -0700
On Wed, Jun 30, 2010 at 3:25 AM, Herbert Poetzl <herbert@13thfloor.at>wrote:

> On Tue, Jun 29, 2010 at 04:01:13PM -0700, Siv wrote:
> > On Mon, Jun 28, 2010 at 5:18 PM, Herbert Poetzl <herbert@13thfloor.at
> >wrote:
> > > On Mon, Jun 28, 2010 at 10:12:07AM -0700, Siv wrote:
> > > > Hi,
>
> > > > I have been looking at http://linux-vserver.org/USB_Devices to
> > > > access usb device from my guest (I can't get it to work yet,
> > > > but that calls for a separate discussion).
>
> > > > My question is - while I have steps for USB, what about other
> > > > devices (say scsi drives or SD/pcmcia cards) ?
>
> > > basically it all boils down to the right set of
> > > permissions and the proper device nodes inside
> > > the guest
>
> > > > Do they need some special handling to be visible under guest ?
>
> > > there might be certain devices or drivers which
> > > require more than the usual set of capabilities
>
> > > > Also, I may need to add user space device drivers in future
> > > > and can I do it from the guest (and host would not see it) ?
>
> > > user space device drivers sound interesting for
> > > a linux kernel, but as long as the required
> > > kernel interface is available inside the guest,
> > > I don't see a problem with them ...
>
> > > > I hope so but wanted to confirm.
>
> > > give it a try and let us know :)
>
> > Sure, will let you know when I try :)
> > With the usual kernel space driver, say I open /dev/driver
>         make that 'device' or 'device node'     ~~~~~~~~~~~~
> > from host and guest, my driver needs to restrict/limit
> > accesses based on the requestor (basically host requests
> > will have more privileges).
>
> > Can kernel can distinguish requests from host and the
> > guest ?
>
> yes, the kernel knows (vx_check(), vx_task_xid(current))
>
> best,
> Herbert
>

Thanks. I see that host xid is always 0. vx_check(0, VS_IDENT) helps to find
if it is host or guest. I think I can also do vx_check(vx_task_xid(current),
VS_HOSTID).
Now, from check.h

(mode & VS_ADMIN) && (cid == 0))  -> Does this assume host is always the
ADMIN ?
(mode & VS_WATCH) && (cid == 1) ->  Where is VS_WATCH used ?

Just curious.

--Siv--

>
> > --Siv--
> >
> > >
> > > best,
> > > Herbert
> > >
> > > > --Siv--
> > >
>




On Wed, Jun 30, 2010 at 3:25 AM, Herbert Poetzl <herbert@13thfloor.at> wrote:
On Tue, Jun 29, 2010 at 04:01:13PM -0700, Siv wrote:
> On Mon, Jun 28, 2010 at 5:18 PM, Herbert Poetzl <herbert@13thfloor.at>wrote:
> > On Mon, Jun 28, 2010 at 10:12:07AM -0700, Siv wrote:
> > > Hi,

> > > I have been looking at http://linux-vserver.org/USB Devices to
> > > access usb device from my guest (I can't get it to work yet,
> > > but that calls for a separate discussion).

> > > My question is - while I have steps for USB, what about other
> > > devices (say scsi drives or SD/pcmcia cards) ?

> > basically it all boils down to the right set of
> > permissions and the proper device nodes inside
> > the guest

> > > Do they need some special handling to be visible under guest ?

> > there might be certain devices or drivers which
> > require more than the usual set of capabilities

> > > Also, I may need to add user space device drivers in future
> > > and can I do it from the guest (and host would not see it) ?

> > user space device drivers sound interesting for
> > a linux kernel, but as long as the required
> > kernel interface is available inside the guest,
> > I don't see a problem with them ...

> > > I hope so but wanted to confirm.

> > give it a try and let us know :)

> Sure, will let you know when I try :)
> With the usual kernel space driver, say I open /dev/driver
       make that 'device' or 'device node'     ~~~~~~~~~~~~
> from host and guest, my driver needs to restrict/limit
> accesses based on the requestor (basically host requests
> will have more privileges).

> Can kernel can distinguish requests from host and the
> guest ?

yes, the kernel knows (vx check(), vx task xid(current))

best,
Herbert

Thanks. I see that host xid is always 0. vx check(0, VS IDENT) helps to find if it is host or guest. I think I can also do vx check(vx task xid(current), VS HOSTID).
Now, from check.h

(mode & VS ADMIN) && (cid == 0))  -> Does this assume host is always the ADMIN ?
(mode & VS WATCH) && (cid == 1) ->  Where is VS WATCH used ?

Just curious.

--Siv-- 

> --Siv--
>
> >
> > best,
> > Herbert
> >
> > > --Siv--
> >