[libvirt] [PATCH 2/8] RNG updates, new xml parser/formatter code for forward mode=hostdev-hybrid

Shradha Shah sshah at solarflare.com
Fri Sep 7 16:15:09 UTC 2012


This patch introduces the new forward mode='hostdev-hybrid' along with attribute managed
Includes updates to the network RNG and new xml parser/formatter code.
---
 docs/formatnetwork.html.in                    |   46 +++++++++++++++++++++++++
 docs/schemas/network.rng                      |    1 +
 src/conf/network_conf.c                       |    9 +++--
 src/conf/network_conf.h                       |    1 +
 tests/networkxml2xmlin/hostdev-hybrid-pf.xml  |    7 ++++
 tests/networkxml2xmlin/hostdev-hybrid.xml     |   10 +++++
 tests/networkxml2xmlout/hostdev-hybrid-pf.xml |    7 ++++
 tests/networkxml2xmlout/hostdev-hybrid.xml    |   10 +++++
 tests/networkxml2xmltest.c                    |    2 +
 9 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index 49206dd..5a5392c 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -259,6 +259,22 @@
             with <code><forward mode='hostdev'/></code>.
             </p>
           </dd>
+          <dt><code>hostdev-hybrid</code></dt>
+          <dd>
+            Libvirt later than 0.10.0 also supports "intelligent
+            passthrough" of VF in the hybrid mode. This is done by
+            using the <interface type='hostdev-hybrid'/>
+            functionality. Similar to <interface type='hostdev'/>
+            the device's MAC address is first optionally configured and
+            the device is optionally associated with an 802.1Qbh capable
+            switch using an optionally specified <virtualport>
+            element (see the examples of virtualport given above for
+            type='direct' network devices). The Vf is passed into the
+            guest as a PCI device and at the same time a virtual interface
+            with type='direct' mode='bridge' is created in the guest. This
+            hybrid mode of intelligent passthrough makes Live migration
+            possible.
+          </dd>
         </dl>
         As mentioned above, a <code><forward></code> element can
         have multiple <code><interface></code> subelements, each
@@ -341,6 +357,36 @@
 ...
         </pre>
 
+        Similarly hostdev-hybrid mode can be used to support PCI-
+        passthrough of VF in hybrid mode as described above. The
+        interface pool can be specified with a list of
+        <code><address></code> elements, each of which has
+        <code>< type></code> (must always be <code>'pci'</code>,
+        <code><domain></code>, <code><bus></code>,
+        <code><slot></code>, and <code><function></code>
+        attributes or the interface pool can also be defined using a
+        single physical function  <code><pf></code> subelement to
+        call out the  corresponding physical interface associated with
+        multiple virtual interfaces (similar to passthrough mode).
+
+        <pre>
+...
+  <forward mode='hostdev-hybrid' managed='yes'>
+    <address type='pci' domain='0' bus='4' slot='0' function='1'/>
+    <address type='pci' domain='0' bus='4' slot='0' function='2'/>
+    <address type='pci' domain='0' bus='4' slot='0' function='3'/>
+  </forward>
+...
+        </pre>
+
+        <pre>
+...
+  <forward mode='hostdev-hybrid' managed='yes'>
+    <pf dev='eth0'/>
+  </forward>
+...
+        </pre>
+
       </dd>
     </dl>
     <h5><a name="elementQoS">Quality of service</a></h5>
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 4abfd91..1f2136a 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -88,6 +88,7 @@
                   <value>private</value>
                   <value>vepa</value>
                   <value>hostdev</value>
+                  <value>hostdev-hybrid</value>
                 </choice>
               </attribute>
             </optional>
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 9d53d8e..443b060 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -50,7 +50,7 @@
 
 VIR_ENUM_IMPL(virNetworkForward,
               VIR_NETWORK_FORWARD_LAST,
-              "none", "nat", "route", "bridge", "private", "vepa", "passthrough", "hostdev")
+              "none", "nat", "route", "bridge", "private", "vepa", "passthrough", "hostdev", "hostdev-hybrid")
 
 VIR_ENUM_DECL(virNetworkForwardHostdevDevice)
 VIR_ENUM_IMPL(virNetworkForwardHostdevDevice,
@@ -1289,6 +1289,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
         case VIR_NETWORK_FORWARD_VEPA:
         case VIR_NETWORK_FORWARD_PASSTHROUGH:
         case VIR_NETWORK_FORWARD_HOSTDEV:
+        case VIR_NETWORK_FORWARD_HOSTDEV_HYBRID:
             if (def->bridge) {
                 virReportError(VIR_ERR_XML_ERROR,
                                _("bridge name not allowed in %s mode (network '%s')"),
@@ -1590,7 +1591,8 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags)
         virBufferAddLit(&buf, "<forward");
         virBufferEscapeString(&buf, " dev='%s'", dev);
         virBufferAsprintf(&buf, " mode='%s'", mode);
-        if (def->forwardType == VIR_NETWORK_FORWARD_HOSTDEV) {
+        if (def->forwardType == VIR_NETWORK_FORWARD_HOSTDEV ||
+            def->forwardType == VIR_NETWORK_FORWARD_HOSTDEV_HYBRID) {
             if (def->managed == 1)
                 virBufferAddLit(&buf, " managed='yes'");
             else
@@ -1608,7 +1610,8 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags)
         if (def->nForwardIfs &&
             (!def->nForwardPfs || !(flags & VIR_NETWORK_XML_INACTIVE))) {
             for (ii = 0; ii < def->nForwardIfs; ii++) {
-                if (def->forwardType != VIR_NETWORK_FORWARD_HOSTDEV) {
+                if (def->forwardType != VIR_NETWORK_FORWARD_HOSTDEV &&
+                    def->forwardType != VIR_NETWORK_FORWARD_HOSTDEV_HYBRID) {
                     virBufferEscapeString(&buf, "<interface dev='%s'",
                                           def->forwardIfs[ii].device.dev);
                     if (!(flags & VIR_NETWORK_XML_INACTIVE) &&
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index f49c367..a9d8b12 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -48,6 +48,7 @@ enum virNetworkForwardType {
     VIR_NETWORK_FORWARD_VEPA,
     VIR_NETWORK_FORWARD_PASSTHROUGH,
     VIR_NETWORK_FORWARD_HOSTDEV,
+    VIR_NETWORK_FORWARD_HOSTDEV_HYBRID,
 
     VIR_NETWORK_FORWARD_LAST,
 };
diff --git a/tests/networkxml2xmlin/hostdev-hybrid-pf.xml b/tests/networkxml2xmlin/hostdev-hybrid-pf.xml
new file mode 100644
index 0000000..f8b8f9b
--- /dev/null
+++ b/tests/networkxml2xmlin/hostdev-hybrid-pf.xml
@@ -0,0 +1,7 @@
+<network>
+  <name>hostdev-hybrid</name>
+  <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+  <forward mode='hostdev-hybrid' managed='yes'>
+    <pf dev='eth2'/>
+  </forward>
+</network>
diff --git a/tests/networkxml2xmlin/hostdev-hybrid.xml b/tests/networkxml2xmlin/hostdev-hybrid.xml
new file mode 100644
index 0000000..94c9d65
--- /dev/null
+++ b/tests/networkxml2xmlin/hostdev-hybrid.xml
@@ -0,0 +1,10 @@
+<network>
+  <name>hostdev-hybrid</name>
+  <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+  <forward mode='hostdev-hybrid' managed='yes'>
+    <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
+    <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x2'/>
+    <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x3'/>
+    <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x4'/>
+  </forward>
+</network>
diff --git a/tests/networkxml2xmlout/hostdev-hybrid-pf.xml b/tests/networkxml2xmlout/hostdev-hybrid-pf.xml
new file mode 100644
index 0000000..f8b8f9b
--- /dev/null
+++ b/tests/networkxml2xmlout/hostdev-hybrid-pf.xml
@@ -0,0 +1,7 @@
+<network>
+  <name>hostdev-hybrid</name>
+  <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+  <forward mode='hostdev-hybrid' managed='yes'>
+    <pf dev='eth2'/>
+  </forward>
+</network>
diff --git a/tests/networkxml2xmlout/hostdev-hybrid.xml b/tests/networkxml2xmlout/hostdev-hybrid.xml
new file mode 100644
index 0000000..94c9d65
--- /dev/null
+++ b/tests/networkxml2xmlout/hostdev-hybrid.xml
@@ -0,0 +1,10 @@
+<network>
+  <name>hostdev-hybrid</name>
+  <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+  <forward mode='hostdev-hybrid' managed='yes'>
+    <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
+    <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x2'/>
+    <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x3'/>
+    <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x4'/>
+  </forward>
+</network>
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index e57d190..d8da37a 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -108,6 +108,8 @@ mymain(void)
     DO_TEST_FULL("passthrough-pf", VIR_NETWORK_XML_INACTIVE);
     DO_TEST("hostdev");
     DO_TEST_FULL("hostdev-pf", VIR_NETWORK_XML_INACTIVE);
+    DO_TEST("hostdev-hybrid");
+    DO_TEST_FULL("hostdev-hybrid-pf", VIR_NETWORK_XML_INACTIVE);
 
     return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
1.7.4.4





More information about the libvir-list mailing list