[Spice-devel] creating devices on the fly (smartcard ccid readers)

Gerd Hoffmann kraxel at redhat.com
Tue Aug 31 00:57:53 PDT 2010


   Hi,

> SpiceCoreInterface doesn't allow creation/removal of devices and
> chardevs.

I don't think allowing spice client add/remove guest devices is a good idea.

> Right now it seems to be the right direction - add some
> calls (two) for that, following qemu API closely (exactly).

Following qemu API certainly is *not* a good idea.  We had way too much 
of this in spice.  Unfortunately still have because I've missed a few 
places.

Depending on qemu *internal* APIs is just asking for trouble because 
those APIs can change and we'll be screwed then.  The number one example 
for this is the monitor.  The way it used to work in spice 0.4 clashes 
quite badly with the introduction of the QMP monitor in qemu.

> Another
> option would be using QMP, not sure if it is possible to create and
> destroy devices and chardev's that way.

It is, but again giving spice client access to QMP isn't going happen. 
The management app could do this.  I don't think this is useful though.

> The other option would be to create a bunch of devices the usual way,
> via -chardev spicevmc,id=smartcard,name=smartcard -device
> usb-ccid,chardev=smartcard, but have them dormant on start until they
> get some message to activate. This would not require any changes to
> SpiceCoreInteraface, but would be uglier obviously (requiring device
> changes specifically for spice).

That is the way to go IMHO.  qemu usb bus code already has everything 
you need.  usb devices can be present but detached (i.e. unplugged).  By 
default usb devices are attached automatically.  But you can prevent 
that by setting USBDevice->auto_attach to '0' in your init function and 
then call usb_device_{attach,detach}() as you like, i.e. attach if a 
spice client with card reader connects and detach on spice client 
disconnect.  usb passthrough works that way too, check usb-linux.c.

cheers,
   Gerd


More information about the Spice-devel mailing list