• L
    Restructure domain struct interface "driver" data for easier expansion · b670a412
    Laine Stump 提交于
    When the <driver> element (and its "name" attribute) was added to the
    domain XML's interface element, a "backend" enum was simply added to
    the toplevel of the virDomainNetDef struct.
    
    Ignoring the naming inconsistency ("name" vs. "backend"), this is fine
    when there's only a single item contained in the driver element of the
    XML, but doesn't scale well as we add more attributes that apply to
    the backend of the virtio-net driver, or add attributes applicable to
    other drivers.
    
    This patch changes virDomainNetDef in two ways:
    
    1) Rename the item in the struct from "backend" to "name", so that
       it's the same in the XML and in the struct, hopefully avoiding
       confusion for someone unfamiliar with the function of the
       attribute.
    
    2) Create a "driver" union within virDomainNetDef, and a "virtio"
       struct in that struct, which contains the "name" enum value.
    
    3) Move around the virDomainNetParse and virDomainNetFormat functions
       to allow for simple plugin of new attributes without disturbing
       existing code. (you'll note that this results in a seemingly
       redundant if() in the format function, but that will no longer be
       the case as soon as a 2nd attribute is added).
    
    In the future, new attributes for the virtio driver backend can be
    added to the "virtio" struct, and any other network device backend that
    needs an attribute will have its own struct added to the "driver"
    union.
    b670a412
domain_conf.h 40.4 KB