]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Restructure domain struct interface "driver" data for easier expansion
authorLaine Stump <laine@laine.org>
Thu, 3 Feb 2011 18:52:08 +0000 (13:52 -0500)
committerLaine Stump <laine@laine.org>
Thu, 17 Feb 2011 16:07:45 +0000 (11:07 -0500)
commitb670a41206701f6e1365b83dd5be704864aec9a7
treeb1156bd178931aaac736d066753def3b32a7da07
parent85e601f8a59c128e39594f9866b54541ba9edbc2
Restructure domain struct interface "driver" data for easier expansion

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.
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c