summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaine Stump <laine@laine.org>2012-07-31 14:36:51 -0400
committerLaine Stump <laine@laine.org>2012-08-14 15:47:50 -0400
commit4af3cbafdd0e31c5c5b20d57c4aaeb19efcb98bc (patch)
tree4f9cfceab09e26012e11e6905742d3baccb9e348 /tests/networkxml2xmlin
parentconf: simplify Buffer Indentation in virDomainNetDefFormat (diff)
downloadlibvirt-4af3cbafdd0e31c5c5b20d57c4aaeb19efcb98bc.tar.gz
libvirt-4af3cbafdd0e31c5c5b20d57c4aaeb19efcb98bc.tar.bz2
libvirt-4af3cbafdd0e31c5c5b20d57c4aaeb19efcb98bc.zip
conf: support partially-specified <virtualport> in parser and formatter
Until now, all attributes in a <virtualport> parameter list that were acceptable for a particular type, were also required. There were no optional attributes. One of the aims of supporting <virtualport> in libvirt's virtual networks and portgroups is to allow specifying the group-wide parameters in the network's virtualport, and merge that with the interface's virtualport, which will have the instance-specific info (i.e. the interfaceid or instanceid). Additionally, the guest's interface XML shouldn't need to know what type of network connection will be used prior to runtime - it could be openvswitch, 802.1Qbh, 802.1Qbg, or none of the above - but should still be able to specify instance-specific info just in case it turns out to be applicable. Finally, up to now, the parser for virtualport has always generated a random instanceid/interfaceid when appropriate, making it impossible to leave it blank (which is what's required for virtualports within a network/portprofile definition). This patch modifies the parser and formatter of the <virtualport> element in the following ways: * because most of the attributes in a virNetDevVPortProfile are fixed size binary data with no reserved values, there is no way to embed a "this value wasn't specified" sentinel into the existing data. To solve this problem, the new *_specified fields in the virNetDevVPortProfile object that were added in a previous patch of this series are now set when the corresponding attribute is present during the parse. * allow parsing/formatting a <virtualport> that has no type set. In this case, all fields are settable, but all are also optional. * add a GENERATE_MISSING_DEFAULTS flag to the parser - if this flag is set and an instanceid/interfaceid is expected but not provided, a random one will be generated. This was previously the default behavior, but is now done only for virtualports inside an <interface> definition, not for those in <network> or <portgroup>. * add a REQUIRE_ALL_ATTRIBUTES flag to the parser - if this flag is set the parser will call the new virNetDevVPortProfileCheckComplete() functions at the end of the parser to check for any missing attributes (based on type), and return failure if anything is missing. This used to be default behavior. Now it is only used for the virtualport defined inside an interface's <actual> element (by the time you've figured out the contents of <actual>, you should have all the necessary data to fill in the entire virtualport) * add a REQUIRE_TYPE flag to the parser - if this flag is set, the parser will return an error if the virtualport has no type attribute. This also was previously the default behavior, but isn't needed in the case of the virtualport for a type='network' interface (i.e. the exact type isn't yet known), or the virtualport of a portgroup (i.e. the portgroup just has modifiers for the network's virtualport, which *does* require a type) - in those cases, the check will be done at domain startup, once the final virtualport is assembled (this is handled in the next patch).
Diffstat (limited to 'tests/networkxml2xmlin')
-rw-r--r--tests/networkxml2xmlin/openvswitch-net.xml16
-rw-r--r--tests/networkxml2xmlin/vepa-net.xml6
2 files changed, 19 insertions, 3 deletions
diff --git a/tests/networkxml2xmlin/openvswitch-net.xml b/tests/networkxml2xmlin/openvswitch-net.xml
new file mode 100644
index 000000000..8aa1897ab
--- /dev/null
+++ b/tests/networkxml2xmlin/openvswitch-net.xml
@@ -0,0 +1,16 @@
+<network>
+ <name>openvswitch-net</name>
+ <uuid>81ff0d90-c92e-6742-64da-4a736edb9a8b</uuid>
+ <forward mode='bridge'/>
+ <virtualport type='openvswitch'/>
+ <portgroup name='bob' default='yes'>
+ <virtualport>
+ <parameters profileid='bob-profile'/>
+ </virtualport>
+ </portgroup>
+ <portgroup name='alice'>
+ <virtualport>
+ <parameters profileid='alice-profile'/>
+ </virtualport>
+ </portgroup>
+</network>
diff --git a/tests/networkxml2xmlin/vepa-net.xml b/tests/networkxml2xmlin/vepa-net.xml
index b1a40c6e5..030c1d162 100644
--- a/tests/networkxml2xmlin/vepa-net.xml
+++ b/tests/networkxml2xmlin/vepa-net.xml
@@ -7,16 +7,16 @@
<interface dev="eth3"/>
</forward>
<virtualport type="802.1Qbg">
- <parameters managerid="11" typeid="1193047" typeidversion="2" instanceid="b153fa89-1b87-9719-ec12-99e0054fb844"/>
+ <parameters managerid="11" typeid="1193047" typeidversion="2"/>
</virtualport>
<portgroup name="bob" default="yes">
<virtualport type="802.1Qbg">
- <parameters managerid="12" typeid="2193047" typeidversion="3" instanceid="5d00e0ba-e15c-959c-fbb6-b595b0655735"/>
+ <parameters typeid="2193047" typeidversion="3"/>
</virtualport>
</portgroup>
<portgroup name="alice">
<virtualport type="802.1Qbg">
- <parameters managerid="13" typeid="3193047" typeidversion="4" instanceid="70bf45f9-01a8-f5ee-3c0f-e25a0a2e44a6"/>
+ <parameters managerid="13"/>
</virtualport>
</portgroup>
</network>