[PATCHv2 3/3] tests and docs for new forward mode 'vlan'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Shi Lei <shilei.massclouds@xxxxxxx>
---
 docs/formatnetwork.html.in                         | 27 +++++++++++++++++++++-
 docs/schemas/network.rng                           |  1 +
 tests/networkxml2confdata/vlan-network.conf        | 16 +++++++++++++
 tests/networkxml2confdata/vlan-network.xml         | 13 +++++++++++
 tests/networkxml2conftest.c                        |  1 +
 .../vlan-network-multi-vlan-tag.xml                | 11 +++++++++
 .../vlan-network-no-forward-dev.xml                | 10 ++++++++
 tests/networkxml2xmlin/vlan-network-with-dhcp.xml  | 15 ++++++++++++
 tests/networkxml2xmlin/vlan-network.xml            | 10 ++++++++
 tests/networkxml2xmlout/vlan-network-with-dhcp.xml | 17 ++++++++++++++
 tests/networkxml2xmlout/vlan-network.xml           | 12 ++++++++++
 tests/networkxml2xmltest.c                         |  5 ++++
 12 files changed, 137 insertions(+), 1 deletion(-)
 create mode 100644 tests/networkxml2confdata/vlan-network.conf
 create mode 100644 tests/networkxml2confdata/vlan-network.xml
 create mode 100644 tests/networkxml2xmlin/vlan-network-multi-vlan-tag.xml
 create mode 100644 tests/networkxml2xmlin/vlan-network-no-forward-dev.xml
 create mode 100644 tests/networkxml2xmlin/vlan-network-with-dhcp.xml
 create mode 100644 tests/networkxml2xmlin/vlan-network.xml
 create mode 100644 tests/networkxml2xmlout/vlan-network-with-dhcp.xml
 create mode 100644 tests/networkxml2xmlout/vlan-network.xml

diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index 363a72b..294256c 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -156,7 +156,7 @@
 
       <dt><code>mtu</code></dt>
       <dd>
-        The <code>size</code> attribute of the <code>mtu></code>
+        The <code>size</code> attribute of the <code>mtu</code>
         element specifies the Maximum Transmission Unit (MTU) for the
         network. <span class="since">Since 3.1.0</span>. In the case
         of a libvirt-managed network (one with forward mode
@@ -299,6 +299,31 @@
             <span class="since">Since 2.2.0</span>
           </dd>
 
+          <dt><code>vlan</code></dt>
+          <dd>
+            All guests linked to this network will belong to a VLan.
+            Guests communicate with each other directly and communicate
+            with outside network via this network. Egress traffic from
+            this network will be tagged transparently by the VLan-Tag;
+            ingress traffic will be untagged and transport into this
+            network only if traffic has the same VLan-Tag, or be dropped.
+            The <code>dev</code> attribute must be set to specify the
+            host's interface which forwards traffice between this network
+            and outside. The <code>vlan</code> element and its <code>tag</code>
+            element must be one and only, and the <code>id</code> attribute
+            specifies the tag of this VLan. The <code>bridge</code> element
+            can be ignored since it is a internal bridge. This network
+            supports <code>ip</code> and <code>dhcp</code>.
+            <span class="since">Since 4.7.0</span>
+            <pre>
+...
+  &lt;forward mode='vlan' dev='eth1'/&gt;
+  &lt;vlan&gt;
+    &lt;tag id="20"/&gt;
+  &lt;/vlan&gt;
+...</pre>
+          </dd>
+
           <dt><code>bridge</code></dt>
           <dd>
             This network describes either 1) an existing host bridge
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index f37c422..046f6dd 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -114,6 +114,7 @@
                   <value>private</value>
                   <value>vepa</value>
                   <value>hostdev</value>
+                  <value>vlan</value>
                 </choice>
               </attribute>
             </optional>
diff --git a/tests/networkxml2confdata/vlan-network.conf b/tests/networkxml2confdata/vlan-network.conf
new file mode 100644
index 0000000..5d1d091
--- /dev/null
+++ b/tests/networkxml2confdata/vlan-network.conf
@@ -0,0 +1,16 @@
+##WARNING:  THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
+##OVERWRITTEN AND LOST.  Changes to this configuration should be made using:
+##    virsh net-edit vlanB
+## or other application using the libvirt API.
+##
+## dnsmasq conf file created by libvirt
+strict-order
+except-interface=lo
+bind-dynamic
+interface=virbr1
+dhcp-range=192.168.126.60,192.168.126.69
+dhcp-no-override
+dhcp-authoritative
+dhcp-lease-max=10
+dhcp-hostsfile=/var/lib/libvirt/dnsmasq/vlanB.hostsfile
+addn-hosts=/var/lib/libvirt/dnsmasq/vlanB.addnhosts
diff --git a/tests/networkxml2confdata/vlan-network.xml b/tests/networkxml2confdata/vlan-network.xml
new file mode 100644
index 0000000..0faa7bb
--- /dev/null
+++ b/tests/networkxml2confdata/vlan-network.xml
@@ -0,0 +1,13 @@
+<network>
+  <name>vlanB</name>
+  <forward mode="vlan" dev="p5p1"/>
+  <bridge name='virbr1'/>
+  <vlan>
+    <tag id="20"/>
+  </vlan>
+  <ip address="192.168.126.2" netmask="255.255.255.0">
+    <dhcp>
+      <range start="192.168.126.60" end="192.168.126.69"/>
+    </dhcp>
+  </ip>
+</network>
diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index 8e7751e..d106c6a 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -144,6 +144,7 @@ mymain(void)
     DO_TEST("dhcp6-nat-network", dhcpv6);
     DO_TEST("dhcp6host-routed-network", dhcpv6);
     DO_TEST("ptr-domains-auto", dhcpv6);
+    DO_TEST("vlan-network", full);
 
     virObjectUnref(dhcpv6);
     virObjectUnref(full);
diff --git a/tests/networkxml2xmlin/vlan-network-multi-vlan-tag.xml b/tests/networkxml2xmlin/vlan-network-multi-vlan-tag.xml
new file mode 100644
index 0000000..328e9a4
--- /dev/null
+++ b/tests/networkxml2xmlin/vlan-network-multi-vlan-tag.xml
@@ -0,0 +1,11 @@
+<network>
+  <name>vlanB</name>
+  <uuid>d29b765a-896c-450c-b94a-1b6b21c340db</uuid>
+  <forward mode="vlan" dev="eth1"/>
+  <bridge name='virbr1'/>
+  <mac address='12:34:56:78:9A:BC'/>
+  <vlan>
+    <tag id="20"/>
+    <tag id="30"/>
+  </vlan>
+</network>
diff --git a/tests/networkxml2xmlin/vlan-network-no-forward-dev.xml b/tests/networkxml2xmlin/vlan-network-no-forward-dev.xml
new file mode 100644
index 0000000..c8384cf
--- /dev/null
+++ b/tests/networkxml2xmlin/vlan-network-no-forward-dev.xml
@@ -0,0 +1,10 @@
+<network>
+  <name>vlanB</name>
+  <uuid>d29b765a-896c-450c-b94a-1b6b21c340db</uuid>
+  <forward mode="vlan"/>
+  <bridge name='virbr1'/>
+  <mac address='12:34:56:78:9A:BC'/>
+  <vlan>
+    <tag id="20"/>
+  </vlan>
+</network>
diff --git a/tests/networkxml2xmlin/vlan-network-with-dhcp.xml b/tests/networkxml2xmlin/vlan-network-with-dhcp.xml
new file mode 100644
index 0000000..e51eaeb
--- /dev/null
+++ b/tests/networkxml2xmlin/vlan-network-with-dhcp.xml
@@ -0,0 +1,15 @@
+<network>
+  <name>vlanB</name>
+  <uuid>d29b765a-896c-450c-b94a-1b6b21c340db</uuid>
+  <forward mode="vlan" dev="eth1"/>
+  <bridge name='virbr1'/>
+  <mac address='12:34:56:78:9A:BC'/>
+  <vlan>
+    <tag id="20"/>
+  </vlan>
+  <ip address="192.168.126.2" netmask="255.255.255.0">
+    <dhcp>
+      <range start="192.168.126.60" end="192.168.126.69"/>
+    </dhcp>
+  </ip>
+</network>
diff --git a/tests/networkxml2xmlin/vlan-network.xml b/tests/networkxml2xmlin/vlan-network.xml
new file mode 100644
index 0000000..3bf075a
--- /dev/null
+++ b/tests/networkxml2xmlin/vlan-network.xml
@@ -0,0 +1,10 @@
+<network>
+  <name>vlanB</name>
+  <uuid>d29b765a-896c-450c-b94a-1b6b21c340db</uuid>
+  <forward mode="vlan" dev="eth1"/>
+  <bridge name='virbr1'/>
+  <mac address='12:34:56:78:9A:BC'/>
+  <vlan>
+    <tag id="20"/>
+  </vlan>
+</network>
diff --git a/tests/networkxml2xmlout/vlan-network-with-dhcp.xml b/tests/networkxml2xmlout/vlan-network-with-dhcp.xml
new file mode 100644
index 0000000..58ab96d
--- /dev/null
+++ b/tests/networkxml2xmlout/vlan-network-with-dhcp.xml
@@ -0,0 +1,17 @@
+<network>
+  <name>vlanB</name>
+  <uuid>d29b765a-896c-450c-b94a-1b6b21c340db</uuid>
+  <forward dev='eth1' mode='vlan'>
+    <interface dev='eth1'/>
+  </forward>
+  <bridge name='virbr1' stp='on' delay='0'/>
+  <mac address='12:34:56:78:9a:bc'/>
+  <vlan>
+    <tag id='20'/>
+  </vlan>
+  <ip address='192.168.126.2' netmask='255.255.255.0'>
+    <dhcp>
+      <range start='192.168.126.60' end='192.168.126.69'/>
+    </dhcp>
+  </ip>
+</network>
diff --git a/tests/networkxml2xmlout/vlan-network.xml b/tests/networkxml2xmlout/vlan-network.xml
new file mode 100644
index 0000000..e19ce49
--- /dev/null
+++ b/tests/networkxml2xmlout/vlan-network.xml
@@ -0,0 +1,12 @@
+<network>
+  <name>vlanB</name>
+  <uuid>d29b765a-896c-450c-b94a-1b6b21c340db</uuid>
+  <forward dev='eth1' mode='vlan'>
+    <interface dev='eth1'/>
+  </forward>
+  <bridge name='virbr1' stp='on' delay='0'/>
+  <mac address='12:34:56:78:9a:bc'/>
+  <vlan>
+    <tag id='20'/>
+  </vlan>
+</network>
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index eb7db76..72957c7 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -44,6 +44,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
         result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_FORMAT;
         goto cleanup;
     }
+
     if (expectResult == TEST_COMPARE_NET_XML2XML_RESULT_FAIL_FORMAT)
         goto cleanup;
 
@@ -160,6 +161,10 @@ mymain(void)
     DO_TEST_PARSE_ERROR("passthrough-duplicate");
     DO_TEST("metadata");
     DO_TEST("set-mtu");
+    DO_TEST("vlan-network");
+    DO_TEST("vlan-network-with-dhcp");
+    DO_TEST_PARSE_ERROR("vlan-network-no-forward-dev");
+    DO_TEST_PARSE_ERROR("vlan-network-multi-vlan-tag");
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux