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/schemas/network.rng | 1 + src/conf/network_conf.c | 12 ++++++++---- src/conf/network_conf.h | 1 + tests/networkxml2xmlin/hostdev-hybrid-pf.xml | 11 +++++++++++ tests/networkxml2xmlin/hostdev-hybrid.xml | 10 ++++++++++ tests/networkxml2xmlout/hostdev-hybrid-pf.xml | 7 +++++++ tests/networkxml2xmlout/hostdev-hybrid.xml | 10 ++++++++++ tests/networkxml2xmltest.c | 2 ++ 8 files changed, 50 insertions(+), 4 deletions(-) diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng index d1297cd..0118b96 100644 --- a/docs/schemas/network.rng +++ b/docs/schemas/network.rng @@ -83,6 +83,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 294939d..f299a3d 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -49,7 +49,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, @@ -173,7 +173,8 @@ void virNetworkDefFree(virNetworkDefPtr def) VIR_FREE(def->forwardPfs); for (ii = 0 ; ii < def->nForwardIfs && def->forwardIfs ; ii++) { - if (def->forwardType != VIR_NETWORK_FORWARD_HOSTDEV) + if ((def->forwardType != VIR_NETWORK_FORWARD_HOSTDEV) && + (def->forwardType != VIR_NETWORK_FORWARD_HOSTDEV_HYBRID)) virNetworkForwardIfDefClear(&def->forwardIfs[ii]); } VIR_FREE(def->forwardIfs); @@ -1274,6 +1275,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')"), @@ -1559,7 +1561,8 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags) } virBufferAddLit(&buf, " <forward"); virBufferEscapeString(&buf, " dev='%s'", dev); - 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 @@ -1576,7 +1579,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'/>\n", def->forwardIfs[ii].device.dev); else { diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index a57db36..3348877 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -47,6 +47,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..c4d2f93 --- /dev/null +++ b/tests/networkxml2xmlin/hostdev-hybrid-pf.xml @@ -0,0 +1,11 @@ +<network> + <name>hostdev-hybrid</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <forward mode="hostdev-hybrid" managed="yes"> + <pf dev='eth2'/> + <address type='pci' domain='0' bus='3' slot='0' function='1'/> + <address type='pci' domain='0' bus='3' slot='0' function='2'/> + <address type='pci' domain='0' bus='3' slot='0' function='3'/> + <address type='pci' domain='0' bus='3' slot='0' function='4'/> + </forward> +</network> diff --git a/tests/networkxml2xmlin/hostdev-hybrid.xml b/tests/networkxml2xmlin/hostdev-hybrid.xml new file mode 100644 index 0000000..29960aa --- /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='0' bus='3' slot='0' function='1'/> + <address type='pci' domain='0' bus='3' slot='0' function='2'/> + <address type='pci' domain='0' bus='3' slot='0' function='3'/> + <address type='pci' domain='0' bus='3' slot='0' function='4'/> + </forward> +</network> diff --git a/tests/networkxml2xmlout/hostdev-hybrid-pf.xml b/tests/networkxml2xmlout/hostdev-hybrid-pf.xml new file mode 100644 index 0000000..0a0e2b4 --- /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..29960aa --- /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='0' bus='3' slot='0' function='1'/> + <address type='pci' domain='0' bus='3' slot='0' function='2'/> + <address type='pci' domain='0' bus='3' slot='0' function='3'/> + <address type='pci' domain='0' bus='3' slot='0' function='4'/> + </forward> +</network> diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index c9c8311..bd08db5 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -107,6 +107,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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list