Subject: Re: [vserver] Device drivers
From: Herbert Poetzl <herbert@13thfloor.at>
Date: Thu, 1 Jul 2010 16:14:19 +0200

On Wed, Jun 30, 2010 at 05:10:48PM -0700, Siv wrote:
> 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).

or simply vx_check(0, VS_ADMIN)

> Now, from check.h

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

yes, for now the host context 0 is also the admin context

> (mode & VS_WATCH) && (cid == 1) ->  Where is VS_WATCH used ?

this is for the spectator context, which sees all
processes regardless of the context id

> Just curious.

HTC,
Herbert

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