Backend in user space, how is its kernel dev unregistered?
There's a curious asymmetry in how Xen backend devices are registered and unregistered.
Registering is the job of xenbus_probe.c: it watches xenstore, and when a device node shows up, it calls device_register().
Unregistering is the device driver's job: it watches xenstore, and when it sees the front end shut down, it calls device_unregister().
But what if the device driver is in user space? vfb and vkbd are. I can't see how their kernel devices can ever get unregistered.
If that is true, any ideas on how to plug the leak?
Quoted 7 lines · Markus Armbruster
Unregistering is the device driver's job: it watches xenstore, and when it sees the front end shut down, it calls
device_unregister().But what if the device driver is in user space? vfb and vkbd are. I can't see how their kernel devices can ever get unregistered.
If that is true, any ideas on how to plug the leak?
Backends also tear down when their xenstore directory is removed. I think that's the job of xenbus_cleanup_devices() in the 2.6.18 tree.
-- Keir
Quoted 2 lines · Markus Armbruster
But what if the device driver is in user space? vfb and vkbd are. I can't see how their kernel devices can ever get unregistered.
Presumably these should watch xenstore themselves and tear down state when they see state changes from the frontend, or the corresponding xenstore directory disappear completely. Just like in the kernel's xenbus_probe.c.
-- Keir
Quoted 10 lines · Keir Fraser
Quoted 2 lines · Markus Armbruster
But what if the device driver is in user space? vfb and vkbd are. I can't see how their kernel devices can ever get unregistered.
Presumably these should watch xenstore themselves and tear down state when they see state changes from the frontend, or the corresponding xenstore directory disappear completely. Just like in the kernel's
xenbus_probe.c.-- Keir
Stupid question: how can a user space driver get *kernel* devices unregistered?
Quoted 11 lines · Markus Armbruster
Quoted 8 lines
Quoted 2 lines
But what if the device driver is in user space? vfb and vkbd are. I can't see how their kernel devices can ever get unregistered.
Presumably these should watch xenstore themselves and tear down state when they see state changes from the frontend, or the corresponding xenstore directory disappear completely. Just like in the kernel's
xenbus_probe.c.-- Keir
Stupid question: how can a user space driver get *kernel* devices unregistered?
Maybe I misunderstand the problem. I don't know much about pvfb or pvkbd.
-- Keir
Quoted 9 lines · Keir Fraser
Quoted 7 lines · Markus Armbruster
Quoted 7 lines
Quoted 2 lines
But what if the device driver is in user space? vfb and vkbd are. I can't see how their kernel devices can ever get unregistered.
Presumably these should watch xenstore themselves and tear down state when they see state changes from the frontend, or the corresponding xenstore directory disappear completely. Just like in the kernel's
xenbus_probe.c.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
-- Keir
Stupid question: how can a user space driver get *kernel* devices unregistered?
Maybe I misunderstand the problem. I don't know much about pvfb or pvkbd.
-- Keir
Let me elaborate.
Backend device registration is split between xenbus_probe.c (registering) and the backend device driver (unregistering). When a device node shows up in xenstore, xenbus_probe_node() calls device_register(). When the backend driver sees the frontend shut down, it calls device_unregister(). For an example see frontend_changed() in drivers/xen/blkback/xenbus.c.
The vfb and vkbd backends live in user space, i.e. there is no backend driver in the kernel. device_unregister() never gets called. This is a resource leak.
Does this explain the problem sufficienctly?
Quoted 3 lines
The vfb and vkbd backends live in user space, i.e. there is no backend driver in the kernel.
device_unregister()never gets called. This is a resource leak.
When a domain shuts down xend will cleanup the backend device entries in xenstore, which in turn kills the devices. At least they disappear from sysfs on my box ...
cheers,
Gerd
Quoted 9 lines · Markus Armbruster
Let me elaborate.
Backend device registration is split between
xenbus_probe.c(registering) and the backend device driver (unregistering). When a device node shows up in xenstore,xenbus_probe_node()callsdevice_register(). When the backend driver sees the frontend shut down, it callsdevice_unregister(). For an example seefrontend_changed()indrivers/xen/blkback/xenbus.c.
Quoted 5 lines
The vfb and vkbd backends live in user space, i.e. there is no backend driver in the kernel.
device_unregister()never gets called. This is a resource leak.Does this explain the problem sufficienctly?
Ah yes, I think that makes sense. Does xenbus_probe really do a device_register() despite not finding a backend kernel driver to handles the device? That would sound like the source of the problem, to me.
-- Keir
Quoted 6 lines · Markus Armbruster
Quoted 4 lines · Keir Fraser
Quoted 2 lines · Markus Armbruster
But what if the device driver is in user space? vfb and vkbd are. I can't see how their kernel devices can ever get unregistered.
Quoted 7 lines
Quoted 5 lines
Presumably these should watch xenstore themselves and tear down state when they see state changes from the frontend, or the corresponding xenstore directory disappear completely. Just like in the kernel's
xenbus_probe.c.-- Keir
Stupid question: how can a user space driver get *kernel* devices unregistered?
/me is confused.
Which kernel device you are talking about?
Frontend? That one lives in guest kernel space and should work like all other frontends.
Backend? There is no kernel device in the first place.
cheers,
Gerd