[libvirt] [PATCH] Add some missing hook functions

Laine Stump laine at laine.org
Sun Jun 10 04:04:39 UTC 2012


On 05/28/2012 10:20 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> A core use case of the hook scripts is to be able to do things
> to a guest's network configuration. It is possible to hook into
> the 'start' operation for a QEMU guest which runs just before
> the guest is started. The TAP devices will exist at this point,
> but the QEMU process will not. It can be desirable to have a
> 'started' hook too, which runs once QEMU has started.
>
> If libvirtd is restarted it will re-populate firewall rules,
> but there is no QEMU hook to trigger for existing domains.
> This is solved with a 'reconnect' hook.

As a test of its usefulness, I applied this patch to my tree and tried
it out with a modified version of


  http://wiki.libvirt.org/page/Networking#Forwarding_Incoming_Connections

which deletes and re-adds the DNAT and FORWARD rules when libvirtd is
restarted. As expected, the port forwarding to the guest continues to
work across restarts of libvirtd, so having these new hooks is a
definite win.

I also applied the final patch in Stefan's dhcp snooping series, and
checked out the xml handed to the hook script for presence of the
guest's learned IP address. It turns out that (for Fedora 14 guest
anyway) the IP address *is* present in the domain XML by the time the
"started" hook is called, but I believe this is just a coincidence. As I
mentioned in the thread about libvirt-1.0, I think it would be really
useful for odd networking setups if there was a hook that was called any
time something notable in the network setup of a guest changed (such as
a new DHCP lease acquisition being detected) (really, in the general
sense, it would be nice to have a hook called any time something
happened which made any actionable change in the contents of a dumpxml
of the domain).

None of that should detract from the usefulness of this patch as it
stands, though - it definitely has my "functional ACK" :-)




More information about the libvir-list mailing list