Anthony Liguori wrote: > Avi Kivity wrote: > >>+int net_init_bridge(QemuOpts *opts, Monitor *mon, const char *name, > >>VLANState *vlan); > >>+ > >> > > > >Don't we need to tear the interface down after shutdown? > > net_init_bridge calls net_tap_fd_init which registers tap_cleanup. That > closes the fd and frees associated memory. > > The helper does not allocate a persistent tap device so closing the file > descriptor is sufficient for cleanup.
I think you should at least have the option to call a/the helper when cleaning up too. For the same reason that -net downscript= was added. (From the names I get the impression that was added later than -net script=, perhaps due to the same kind of oversight ;-) A user-supplied helper (I'm thinking of my needs) would create per-tap iptables/ebtables rules and perhaps routing table entries, in addition to creating the tap interface itself. Routing table entries are automatically deleted when the interface is, but iptables/ebtables rules are not. (Although it would be a nice little kernel addition if they could be flagged to be.) But now, thinking a bit more clearly... why is the helper separate from "-net script="? Overall, I envisage this happening (sorry for making up the name tap-up-helper, as I seem to have lost your patch mails): tap-up-helper= # Sets up tap interface, adds to bridge if needed. script= # Sets up IP config ....QEMU runs.... downscript= # Removes IP config tap-down-helper= # If only for symmetry! We does tap-up-helper need to be separate from script? Does QEMU need to do something in between calling the two? If not, then the existing "-net script=" script could just send the tap descriptor as well as anything else it does, couldn't it? -- Jamie