CDEmu daemon
About
CDEmu daemon is the userspace daemon part of the cdemu suite.
It receives SCSI commands from kernel module and processes them, passing the requested data back to the kernel.
Daemon implements the actual virtual device; one instance per each device registered by kernel module. It uses libMirage, an image access library that is part of cdemu suite, for the image access (e.g. sector reading).
Daemon is controlled through methods that are exposed via D-BUS. It is written in C and based on GLib (and thus GObjects), but being controlled over D-BUS, it allows for different clients written in different languages.
Features
- Written in C, based on GLib and GObjects
- D-BUS interface for communication with clients
- Implemens a set of packet commands specified by MMC-3, therefore emulating real optical device
- Can register itself either on session or system bus
- Local and daemon mode
- Debugging; on-fly change of debug traces verbosity
Requirements
- GLib 2.6 or newer
- D-BUS and D-BUS GLib bindings, 6.01 or newer
- libdaemon 0.10 or newer
- libsysfs
- libao 0.8.0 or newer
- libmirage 1.2.0 or newer (part of the suite)
- VHBA module 1.2.1 or newer (part of the suite)
System bus vs. Session bus
CDEmu daemon registers a D-BUS interface that can be used by clients to communicate with it; the interface can be registered either on system or session bus.
A session bus instance is created for every user session, and is visible only within that session. On the other hand, there's only one instance of system bus, which is visible system-wide.
This means that when session bus is used, every user can run its own instance of CDEmu daemon, as long as device number limit of VHBA module is not reached. There can be only one instance of the daemon running on system bus, but it is visible to all users. Also, a single instance of daemon on system bus and multiple instances on session busses can be running at the same time.
Note that running on system bus requires special permissions; to this end, CDEmu daemon installs a D-BUS config file which by default allows root to run daemon on system bus. Session bus requires no such permissions, but the user running the daemon must have read/write permissions to VHBA character control device.
Daemon mode vs. Local mode
CDEmu daemon can be run in two different modes; local and daemon.
When local mode is used, the daemon runs as a normal console applicaton; i.e. it runs in the foreground and its output is displayed in the console. When in local mode, daemon can use either system or session bus.
When run in daemon mode, the process is forked and daemon runs in background. All the output from the daemon is logged via system logger (i.e. syslogd). Running in daemon mode automatically implies the use of system bus.
Packaging guidelines
There are no special considerations when packaging the daemon, except maybe for
D-BUS configuration file; this one is needed only if daemon is going to be run with
system bus. By default it allows the daemon to be run as root; should you wish to
use another use, please edit the file. Also, note that the file should be installed
in appropriate directory; on most systems, this is /etc/dbus-1/system.d. Due to the
way autotools are used, the system dir path gets prefixed, therefore you need to
either specify --sysconfdir=/etc or use
--with-dbus-config-dir=/etc/dbus-1/system.d when running configure.
If daemon is not intended to be run on system bus, the config file needs not to
be included.
And a word on starting the daemon and initscripts...
To start the daemon on session bus, the user should run the daemon manually, or add appropriate command to the list of session startup programs.
As far as initscripts go... Unlike previous (experimental snapshot) releases, this release of CDEmu daemon does not provide initscripts. After some thought it was decided it was too much hassle to write initscripts for different distributions, especially with alternatives to SysV init system becoming more and more popular. Packagers are welcome to add initscripts specific to distribution they are packaging for, of course. Please bear in mind, though, that daemon started by initscripts should be run in daemon mode (and therefore use system bus).