Skip to contentSkip to conversation

Triggering hotplug scripts multiple times

DISCUSSION Jacob Gorm Hansen 2 participants 6 messages Mar 30, 2007

lore
Share & tools
lore
#0 lore raw

hi list,

I am not sure how much of a problem this is in real life, but since the changes to support kexec went in, it has been possible for a domU to trigger its hotplug scripts over and over, by repeatedly changing the frontend state of a virtual device.

This is only a problem if a hotplug script has a leak, for instance by adding an iptables rule and not deleting it when the vif goes offline, in which case it is probably possible to exhaust the dom0 kernel's memory by filling it up with iptables entries (iptables does not seem to enforce any upper limit). Another potential issue is that a high CPU load in dom0 can be created by repeated hotplugging of devices.

I am not sure what the correct workaround is, other than paying attention to the quality of hotplug scripts. Somehow it feels wrong that a guest domain is able to arbitrarily trigger scripts in dom0, though the ability to restart devices is a necessity for unprivileged boot-loaders. Perhaps the hotplug scripts should only be triggered once, the first time the frontend is configured?

regards,
Jacob

#1 lore raw
Quoted 6 lines · Jacob Gorm Hansen

I am not sure what the correct workaround is, other than paying attention to the quality of hotplug scripts. Somehow it feels wrong that a guest domain is able to arbitrarily trigger scripts in dom0, though the ability to restart devices is a necessity for unprivileged boot-loaders. Perhaps the hotplug scripts should only be triggered once, the first time the frontend is configured?

I thought the scripts only triggered when the backend device was first created. I don't think they should need to execute on frontend state transitions.

-- Keir

#2 lore raw
Quoted 12 lines · Keir Fraser
Quoted 6 lines · Jacob Gorm Hansen

I am not sure what the correct workaround is, other than paying attention to the quality of hotplug scripts. Somehow it feels wrong that a guest domain is able to arbitrarily trigger scripts in dom0, though the ability to restart devices is a necessity for unprivileged boot-loaders. Perhaps the hotplug scripts should only be triggered once, the first time the frontend is configured?

Quoted 3 lines

I thought the scripts only triggered when the backend device was first created. I don't think they should need to execute on frontend state transitions.

Problem is that if the domain disconnects from the netif, which it has to when handing over the device to the domU kernel from a bootloader, the netif is destroyed, and when the new one is created the hotplug script gets kicked, e.g.:

case XenbusStateInitialising:

if (dev->state == XenbusStateClosed) {
	printk("%s: %s: prepare for reconnect\n", __FUNCTION__, dev->nodename);
	if (be->netif) {
		netif_disconnect(be->netif);
		be->netif = NULL;
	}
	xenbus_switch_state(dev, XenbusStateInitWait);
}

I suppose one could postpone freeing the netif until the domain has gone away.

Another problem with how this currently works is that vifs don't get garbage collected properly if the domain is killed without a proper shutdown.

Jacob

#3 lore raw
Quoted 11 lines · Jacob Gorm Hansen

Problem is that if the domain disconnects from the netif, which it has to when handing over the device to the domU kernel from a bootloader, the netif is destroyed, and when the new one is created the hotplug script gets kicked, e.g.:

I suppose one could postpone freeing the netif until the domain has gone away.

Another problem with how this currently works is that vifs don't get garbage collected properly if the domain is killed without a proper shutdown.

I would classify these behaviours as bugs. :-) We shouldn;t be device unregistering until the online status is set to 0 or the directory in xenstore is removed entirely.

-- Keir

#4 lore raw
Quoted 9 lines · Keir Fraser
Quoted 3 lines · Jacob Gorm Hansen

Another problem with how this currently works is that vifs don't get garbage collected properly if the domain is killed without a proper shutdown.

I would classify these behaviours as bugs. :-) We shouldn;t be device unregistering until the online status is set to 0 or the directory in xenstore is removed entirely.

I agree, I had a look at the netback xenbus code and tried various workarounds, but did not come up with anything that works better than the current stuff. There are some thorny issues with regards to unmapping/remapping the rx/tx rings and so on that must be dealt with correctly, if this is to work.

For now, I will create a bug in bugzilla, and have a go at fixing it later, unless someone beats me to it.

Regards,
Jacob

#5 lore raw
Quoted 4 lines · Jacob Gorm Hansen
Quoted 3 lines

I would classify these behaviours as bugs. :-) We shouldn;t be device unregistering until the online status is set to 0 or the directory in xenstore is removed entirely.

Quoted 8 lines

I agree, I had a look at the netback xenbus code and tried various workarounds, but did not come up with anything that works better than the current stuff. There are some thorny issues with regards to unmapping/remapping the rx/tx rings and so on that must be dealt with correctly, if this is to work.

For now, I will create a bug in bugzilla, and have a go at fixing it later, unless someone beats me to it.

Thanks!

K.