[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC] Introduce module API to QEMU

From: Anthony Liguori
Subject: Re: [Qemu-devel] [RFC] Introduce module API to QEMU
Date: Fri, 03 Apr 2009 07:57:07 -0500
User-agent: Thunderbird (X11/20090320)

Paul Brook wrote:
This patch introduces a module API similar to what's in the Linux kernel. This includes module_init/module_exit functions that register functions
that are run at init and exit respectively.

Wouldn't it be much simpler to just have a list of device names, and assume the each device is implemented in $devicename., and provides $devicename_register ?

It's then an extremely simple shell script to collate and call these.

It doesn't generalize very well. For instance, the VNC server is not a device but it needs to be able to register as a DisplayState backend.

The other way to do this typically is to have module_init() functions that turn a function into a non-static function with some sort of annotation that disappears at compile time. For instance:


Would become:

int qemu__module__init__virtnet_init(void)
    return virtnet_init();

with #define qemu__init__function

You then have something that searches for these functions. The problem with this approach is that virtnet_init must be a unique name because it's a non-static. You can add some uniqueness by playing with __LINE__ but that doesn't make any guarantees.

This is doable but IMHO a worse solution. I'd rather use __attribute__((constructor)) for now and introduce the above only if we ever support something other than GCC.


Anthony Liguori

reply via email to

[Prev in Thread] Current Thread [Next in Thread]