2122cf3 network: include plugged interface XML in "plugged" network hook

Authored and Committed by Laine Stump 10 years ago
    network: include plugged interface XML in "plugged" network hook
    
    The network hook script gets called whenever an interface is plugged
    into or unplugged from a network, but even though the full XML of both
    the network and the domain is included, there is no reasonable way to
    determine what exact resources the plugged interface is using:
    
    1) Prior to a recent patch which modified the status XML of interfaces
    to include the information about actual hardware resources used, it
    would be possible to scan through the domain XML output sent to the
    hook, and from there find the correct interface, but that interface
    definition would not include any runtime info (e.g. bandwidth or vlan
    taken from a portgroup, or which physdev was used in case of a macvtap
    network).
    
    2) After the patch modifying the status XML of interfaces, the network
    name would no longer be included in the domain XML, so it would be
    completely impossible to determine which interface was the one being
    plugged.
    
    To solve that problem, this patch includes a single <interface>
    element at the beginning of the XML sent to the network hook for
    "plugged" and "unplugged" (just inside <hookData>) that is the status
    XML of the interface being plugged. This XML will include all info
    gathered from the chosen network and portgroup.
    
    NB: due to hardcoded spaces in all of the device *Format() functions,
    the <interface> element inside the <hookData> will be indented by 6
    spaces rather than 2. I had intended to fix this, but it turns out
    that to make virDomainNetDefFormat() indentation relative, I would
    have to do the same to virDomainDeviceInfoFormat(), and that function
    is called from 19 places - making that a prerequisite of this patch
    would cause too many merge difficulties if we needed to backport
    network hooks, so I chose to ignore the problem here and fix the
    problem for *all* devices in a followup later.
    
        
file modified
+32 -16