• L
    domain: include portgroup in interface status xml · 89d26890
    Laine Stump 提交于
    Prior to commit 7d5bf484 (first appearing in libvirt 1.2.2), the
    status XML of a domain's interface was missing a lot of important
    information; mainly it just output the config of the interface, plus
    the name of the tap device and qemu device alias. Commit 7d5bf484
    changed the status XML to include many important bits of information
    that were required to make network "hook" scripts useful - bandwidth
    information, vlan tag, the name of the bridge (or physical device in
    the case of macvtap) that the tap/macvtap device was attached to - the
    commit log for 7d5bf484 has a very detailed explanation of the
    change. For quick reference - in the example given there, prior to the
    change, status XML looked like figure [C]:
    
          <interface type='network'>
            <source network='testnet' portgroup='admin'/>
            <target dev='macvtap0'/>
            <alias name='net0'/>
            <address type='pci' domain='0x0000' bus='0x00'
                     slot='0x03' function='0x0'/>
          </interface>
    
    and after the change, it looked like figure [E]:
    
          <interface type='direct'>
            <source dev='p4p1_0' mode='bridge'/>
            <bandwidth>
                <inbound average='1000' peak='5000' burst='1024'/>
                <outbound average='128' peak='256' burst='256'/>
            </bandwidth>
            <target dev='macvtap0'/>
            <alias name='net0'/>
            <address type='pci' domain='0x0000' bus='0x00'
                     slot='0x03' function='0x0'/>
          </interface>
    
    You'll notice that bandwidth info, physdev, and macvtap mode have been
    added, but the network and portgroup names are now missing - I didn't
    think that this information was of any use once the needed
    bandwidth/vlan/etc config had been pulled from the network/portgroup.
    
    I was wrong.
    
    A few months after that change a user on IRC asked what happened to
    portgroup in the status XML and described how he used it (more or less
    as a tag to decide what external information to use in a hook script
    that was run at startup/migration time - see
    http://wiki.libvirt.org/page/OVS_and_PVLANS ). At that time I planned
    to make a patch to re-add portgroup, but life intervened as that was
    just prior to a transatlantic move involving several weeks of
    "vacation". During this time I somehow forgot to make the patch, and
    also mistakenly remembered that I *had* made it.
    
    Subsequent to this, as a part of mprivozn's work to add support for
    network-specific hooks, I did re-add the output of the network name in
    status XML, but once again completely forgot about portgroup. This was
    in commit a3609121 (first appearing in libvirt 1.2.11). This made the
    status XML from the above example look like this:
    
          <interface type='direct'>
            <source network='testnet' dev='p4p1_0' mode='bridge'/>
            <bandwidth>
                <inbound average='1000' peak='5000' burst='1024'/>
                <outbound average='128' peak='256' burst='256'/>
            </bandwidth>
            <target dev='macvtap0'/>
            <alias name='net0'/>
            <address type='pci' domain='0x0000' bus='0x00'
                     slot='0x03' function='0x0'/>
          </interface>
    
    *This* patch just adds the portgroup back to the status XML, so the
     same example interface will look like this:
    
          <interface type='direct'>
            <source network='testnet' portgroup='admin'
                    dev='p4p1_0' mode='bridge'/>
            <bandwidth>
                <inbound average='1000' peak='5000' burst='1024'/>
                <outbound average='128' peak='256' burst='256'/>
            </bandwidth>
            <target dev='macvtap0'/>
            <alias name='net0'/>
            <address type='pci' domain='0x0000' bus='0x00'
                     slot='0x03' function='0x0'/>
          </interface>
    
    The result is that the status XML now contains all information about
    how the interface is setup (bandwidth, physical device, tap device,
    etc), in addition to pointers to its origin (the network and
    portgroup).
    89d26890
domain_conf.c 708.6 KB