Subject: Re: kqemu: driver(9)/filedesc(9) questions
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-kern
Date: 04/17/2007 02:23:06
In article <20070417002706.GA13951@olix0r.net>,
Oliver Gould <ogould@olix0r.net> wrote:
>-=-=-=-=-=-
>
>Hello again-
>
>I'm trying to wrap up my work on KQEMU. I've ported most of the
>interfaces to NetBSD, but I am left with a few questions regarding
>driver(9)..
>
> o Does a CFATTACH_DECL(...) make any sense in an LKM? If not, how
> does the device attach? Both net/tap and dev/vnd use
> CFDRIVER_DECL(...); will this be of any use to me? I haven't found
> sufficient documentation (if it exists, please point me to it).
dunno
> o /dev/kqemu is the external interface to the module. In order to
> clone the device, I am trying to mimick bpf(4), and e.g. using
> fileops / fdclone(9). I maintain a LIST (from QUEUE(9)) of
> (locally-defined) kqemu_instance structures.
>
> I'd like a sanity-check on some of this, though.
>
> As it is currently, the only function passed into kqemu_cdevsw is
> for 'open'. Both fileops and cdevsw have close and ioctl function
> pointers- which should actually be used? Perhaps I need to
> better-understand how these interfaces differ. Can anyone describe
> this concisely?
the fileops are the ones used. cdevsw close and ioctl should not be needed
> Also, I can't think of any use for the read or write fileops, are
> they necessary? There's no (apparent) stub (fnullop_read or
> fnullop_write), but I don't expect a NULL value to work either-
> suggestions?
You should make them invalid.
> o Also, I'm running into some silly compile errors- particularly,
> conflicts between /usr/include/sys and /usr/include/machine. I
> would imagine that this is something obvious and avoidable:
>
> In file included from /usr/include/sys/endian.h:107,
> from /usr/include/machine/endian.h:3,
> from /usr/include/sys/types.h:98,
> [...]
> from /usr/include/sys/buf.h:79,
> from kqemu-netbsd.c:9:
> /usr/include/machine/bswap.h:14:1: error: "bswap16" redefined
> In file included from /usr/include/machine/bswap.h:9,
> from /usr/include/sys/endian.h:107,
> from /usr/include/machine/endian.h:3,
> from /usr/include/sys/types.h:98,
> [...]
> from /usr/include/sys/buf.h:79,
> from kqemu-netbsd.c:9:
> /usr/include/sys/bswap.h:70:1: error: this is the location of the
> previous definition
>
> Any easy way around this?
that is weird. perhaps you are including machine/bswap.h directly instead
of <sys/endian.h>?
christos