[libvirt] [PATCH 2/3 v3] Schema and docs for the midonet virtualport type

Laine Stump laine at laine.org
Tue Mar 17 16:29:51 UTC 2015


On 02/23/2015 03:54 PM, Antoni Segura Puimedon wrote:
> Midonet is an opensource virtual networking that over lays the IP
> network between hypervisors. Currently, such networks can be made
> with the openvswitch virtualport type.
>
> This patch, defines the schema and documentation that will serve
> as basis for the follow up patches that will add support to libvirt
> for using Midonet virtual ports for its interfaces. The schema
> definition requires that the port profile expresses its interfaceid
> as part of the port profile. For that reason, this is part of the
> patch too.

As we discussed on IRC just now, libvirt's parsers don't enforce the
schemas in the RNG files by default, so a small extra bit is necessary
to make sure that an interfaceid is always present. I've squashed the
following small bit into virNetDevVPortProfileCheckComplete() before
pushing:


diff --git a/src/util/virnetdevvportprofile.c
b/src/util/virnetdevvportprofile.c
index 09acb52..547894c 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -189,6 +189,11 @@
virNetDevVPortProfileCheckComplete(virNetDevVPortProfilePtr virtport,
             }
         }
         break;
+
+    case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
+       if (!virtport->interfaceID_specified)
+          missing = "interfaceid";
+       break;
     }
 
     if (missing) {

ACK with that change along with the couple small grammar fixes I point
out below. I've squashed these all in and will be pushing as soon as I
look through 3/3.

>
> Signed-off-by: Antoni Segura Puimedon <toni+libvirt at midokura.com>
> ---
>  docs/formatdomain.html.in                          | 34 +++++++++++++++++++++
>  docs/schemas/networkcommon.rng                     | 12 ++++++++
>  src/conf/netdev_vport_profile_conf.c               |  3 +-
>  .../qemuxml2argvdata/qemuxml2argv-net-midonet.xml  | 35 ++++++++++++++++++++++
>  tests/qemuxml2xmltest.c                            |  1 +
>  5 files changed, 84 insertions(+), 1 deletion(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-midonet.xml
>
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index f6477c2..1c2bb45 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -3652,6 +3652,40 @@
>    </devices>
>    ...</pre>
>  
> +    <p>
> +      On hosts that support Open vSwitch on the kernel side and that have the

s/that have/have/

> +      Midonet Host Agent configured, it is also possible to connect to the
> +      'midonet' bridge device by adding a
> +      <code><virtualport type='midonet'/></code> to the
> +      interface definition.  (<span class="since">Since
> +      1.2.13</span>). The Midonet virtualport type requires an
> +      <code>interfaceid</code> attribute to its
> +      <code><parameters></code> element.

s/to its/in its/

>  This interface id is the UUID
> +      that specifies which port in the virtual network topology will be bound
> +      to the interface.
> +    </p>
> +<pre>
> +  ...
> +  <devices>
> +    ...
> +    <interface type='bridge'>
> +      <source bridge='br0'/>
> +    </interface>
> +    <interface type='bridge'>
> +      <source bridge='br1'/>
> +      <target dev='vnet7'/>
> +      <mac address="00:11:22:33:44:55"/>
> +    </interface>
> +    <interface type='bridge'>
> +      <source bridge='midonet'/>
> +      <virtualport type='midonet'>
> +        <parameters interfaceid='0b2d64da-3d0e-431e-afdd-804415d6ebbb'/>
> +      </virtualport>
> +    </interface>
> +    ...
> +  </devices>
> +  ...</pre>
> +
>      <h5><a name="elementsNICSSlirp">Userspace SLIRP stack</a></h5>
>  
>      <p>
> diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
> index 162ea3d..cc8b1dc 100644
> --- a/docs/schemas/networkcommon.rng
> +++ b/docs/schemas/networkcommon.rng
> @@ -79,6 +79,18 @@
>          </element>
>        </group>
>        <group>
> +        <element name="virtualport">
> +          <attribute name="type">
> +            <value>midonet</value>
> +          </attribute>
> +          <element name="parameters">
> +            <attribute name="interfaceid">
> +              <ref name="UUID"/>
> +            </attribute>
> +          </element>
> +        </element>
> +      </group>
> +      <group>
>          <!-- use this when no type attribute is present -->
>          <element name="virtualport">
>            <optional>
> diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_conf.c
> index 8da0838..1641a3e 100644
> --- a/src/conf/netdev_vport_profile_conf.c
> +++ b/src/conf/netdev_vport_profile_conf.c
> @@ -260,7 +260,8 @@ virNetDevVPortProfileFormat(virNetDevVPortProfilePtr virtPort,
>          virBufferAsprintf(buf, " instanceid='%s'", uuidstr);
>      }
>      if (virtPort->interfaceID_specified &&
> -        (type == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH ||
> +        (type == VIR_NETDEV_VPORT_PROFILE_MIDONET ||
> +         type == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH ||
>           type == VIR_NETDEV_VPORT_PROFILE_NONE)) {
>          char uuidstr[VIR_UUID_STRING_BUFLEN];
>  
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-midonet.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-midonet.xml
> new file mode 100644
> index 0000000..ae5a174
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-midonet.xml
> @@ -0,0 +1,35 @@
> +<domain type='qemu'>
> +  <name>QEMUGuest1</name>
> +  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
> +  <memory unit='KiB'>219136</memory>
> +  <currentMemory unit='KiB'>219136</currentMemory>
> +  <vcpu placement='static'>1</vcpu>
> +  <os>
> +    <type arch='i686' machine='pc'>hvm</type>
> +    <boot dev='hd'/>
> +  </os>
> +  <clock offset='utc'/>
> +  <on_poweroff>destroy</on_poweroff>
> +  <on_reboot>restart</on_reboot>
> +  <on_crash>destroy</on_crash>
> +  <devices>
> +    <emulator>/usr/bin/qemu</emulator>
> +    <disk type='block' device='disk'>
> +      <source dev='/dev/HostVG/QEMUGuest1'/>
> +      <target dev='hda' bus='ide'/>
> +      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
> +    </disk>
> +    <controller type='usb' index='0'/>
> +    <controller type='ide' index='0'/>
> +    <controller type='pci' index='0' model='pci-root'/>
> +    <interface type='bridge'>
> +      <mac address='00:11:22:33:44:55'/>
> +      <source bridge='midonet'/>
> +      <virtualport type='midonet'>
> +        <parameters interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
> +      </virtualport>
> +      <model type='virtio'/>
> +    </interface>
> +    <memballoon model='virtio'/>
> +  </devices>
> +</domain>
> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
> index 99d4629..ba1157c 100644
> --- a/tests/qemuxml2xmltest.c
> +++ b/tests/qemuxml2xmltest.c
> @@ -275,6 +275,7 @@ mymain(void)
>      DO_TEST("net-virtio-network-portgroup");
>      DO_TEST("net-hostdev");
>      DO_TEST("net-hostdev-vfio");
> +    DO_TEST("net-midonet");

Yay! A test case! (and you didn't forget to add it to the list in the .c
file like I always do :-)

>      DO_TEST("net-openvswitch");
>      DO_TEST("sound");
>      DO_TEST("sound-device");




More information about the libvir-list mailing list