<br><tt><font size=2>libvir-list-bounces@redhat.com wrote on 05/08/2010
03:05:29 AM:<br>
<br>
<br>
> From: Scott Feldman <scofeldm@cisco.com><br>
> <br>
> This fleshes out the port profile ID proof-of-concept patch posted
earlier<br>
> by David Allan, referenced here:<br>
> <br>
>   </font></tt><a href="https://www.redhat.com/archives/libvir-list/2010-March/msg01401.html"><tt><font size=2>https://www.redhat.com/archives/libvir-list/2010-March/msg01401.html</font></tt></a><tt><font size=2><br>
> <br>
> It uses the new IFLA_VF_PORT_PROFILE netlink msg to set/unset the
port-<br>
> profile for the virtual switch port backing the VM device.  The
new netlink<br>
> msg is being discussed on the netdev kernel mailing list here:<br>
> <br>
>   </font></tt><a href="http://marc.info/?l=linux-netdev&m=127312092712543&w=2"><tt><font size=2>http://marc.info/?l=linux-netdev&m=127312092712543&w=2</font></tt></a><tt><font size=2><br>
>   </font></tt><a href="http://marc.info/?l=linux-netdev&m=127312093412556&w=2"><tt><font size=2>http://marc.info/?l=linux-netdev&m=127312093412556&w=2</font></tt></a><tt><font size=2><br>
> <br>
> IFLA_VF_PORT_PROFILE is sent using RTM_SETLINK, and retrieved using<br>
> RTM_GETLINK.  IFLA_VF_PORT_PROFILE is sent using netlink multicast
send<br>
> with RTNLGRP_LINK so the receiver of the msg can be in user-space
or<br>
> kernel-space.<br>
> <br>
> The device XML is:<br>
> <br>
>     <interface type='direct'><br>
>         <source dev='eth2' mode='private' profileid='dc_test'/><br>
>         <mac address='00:16:3e:1a:b3:4b'/><br>
>     </interface><br>
> <br>
> The port-profile ID msg is sent to source dev.</font></tt>
<br>
<br><tt><font size=2>Great. Now we have two competing implementations where
the underlying technology is supposed</font></tt>
<br><tt><font size=2>to be VEPA in both but the parameters to set it up
are vastly different -- if you compare</font></tt>
<br><tt><font size=2>against Vivek's post yesterfa. Above you are providing
a profile id in form of a string. </font></tt>
<br><tt><font size=2>Is that string above just a dummy example or a real-world
parameter that can actually be passed?</font></tt>
<br><tt><font size=2>Vivek posted a message yesterday showing now 4 different
parameters... are these somehow encoded</font></tt>
<br><tt><font size=2>in the profileid in your case or you simply don't
need them? I see you are getting the host UUID</font></tt>
<br><tt><font size=2>vid dmidecode, so there are still3 parameters left.
Anyway, I let you guys figure that out.</font></tt>
<br>
<br><tt><font size=2>I suppose in your case we would use the external daemon
to derive eth0 from eth0.100 where the</font></tt>
<br><tt><font size=2>macvtap would be connected on along with the vlan
id in eth0.100. So the functions I posted</font></tt>
<br><tt><font size=2>yesterday may need to go into that code then.</font></tt>
<br>
<br>
<br><tt><font size=2><br>
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c<br>
> index 5fa8c0a..aff6f28 100644<br>
> --- a/src/qemu/qemu_conf.c<br>
> +++ b/src/qemu/qemu_conf.c<br>
> @@ -1479,6 +1479,11 @@ qemudPhysIfaceConnect(virConnectPtr conn,<br>
>          net->model && STREQ(net->model,
"virtio"))<br>
>          vnet_hdr = 1;<br>
>  <br>
> +    if (!STREQ(net->data.direct.profileid, ""))<br>
> +        setPortProfileId(net->data.direct.linkdev,<br>
> +                    
    net->data.direct.profileid,<br>
> +                    
    net->mac);<br>
> +</font></tt>
<br>
<br><tt><font size=2>Since setting up a port profile seems to be a step
tightly connected</font></tt>
<br><tt><font size=2>to opening the macvtap I'd push this into the openMactapTap
function.</font></tt>
<br>
<br><tt><font size=2><br>
>      rc = openMacvtapTap(net->ifname, net->mac,
linkdev, brmode,<br>
>                    
     &res_ifname, vnet_hdr);<br>
>      if (rc >= 0) {<br>
> @@ -1501,6 +1506,8 @@ qemudPhysIfaceConnect(virConnectPtr conn,<br>
>                  close(rc);<br>
>                  rc =
-1;<br>
>                  delMacvtap(net->ifname);<br>
> +                if (!STREQ(net->data.direct.profileid,
""))<br>
> +                    unsetPortProfileId(net->data.direct.linkdev);<br>
>              }</font></tt>
<br>
<br><tt><font size=2>Same here, push it into the delMacvtap function.</font></tt>
<br>
<br><tt><font size=2><br>
>          }<br>
>      }<br>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c<br>
> index bb1079e..6ea37d4 100644<br>
> --- a/src/qemu/qemu_driver.c<br>
> +++ b/src/qemu/qemu_driver.c<br>
> @@ -3586,8 +3586,11 @@ static void qemudShutdownVMDaemon(struct <br>
> qemud_driver *driver,<br>
>      for (i = 0; i < def->nnets; i++) {<br>
>          virDomainNetDefPtr net = def->nets[i];<br>
>          if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT)
{<br>
> -            if (net->ifname)<br>
> +            if (net->ifname) {<br>
>                  delMacvtap(net->ifname);<br>
> +                if (!STREQ(net->data.direct.profileid,
""))<br>
> +                    unsetPortProfileId(net->data.direct.linkdev);<br>
> +            }</font></tt>
<br>
<br><tt><font size=2>Same.</font></tt>
<br><tt><font size=2><br>
>          }<br>
>      }<br>
>  #endif<br>
> @@ -8147,8 +8150,11 @@ qemudDomainDetachNetDevice(struct qemud_driver
*driver,<br>
>  <br>
>  #if WITH_MACVTAP<br>
>      if (detach->type == VIR_DOMAIN_NET_TYPE_DIRECT)
{<br>
> -        if (detach->ifname)<br>
> +        if (detach->ifname) {<br>
>              delMacvtap(detach->ifname);<br>
> +            if (!STREQ(detach->data.direct.profileid,
""))<br>
> +                unsetPortProfileId(detach->data.direct.linkdev);<br>
> +        }</font></tt>
<br>
<br><tt><font size=2>Same.</font></tt>
<br><tt><font size=2><br>
<br>
<br>
> +<br>
> +int setPortProfileId(const char *linkdev,<br>
> +                    
const char *profileid,<br>
> +                    
unsigned char *macaddress)<br>
> +{<br>
> +    int rc = 0;<br>
> +    struct ifla_vf_port_profile ivp;<br>
> +    char host_uuid[IFLA_VF_UUID_MAX] = "\0";<br>
> +<br>
> +    if (!profileid)<br>
> +        return -EINVAL;<br>
> +<br>
> +    memset(&ivp, 0, sizeof(struct ifla_vf_port_profile));<br>
> +    ivp.vf = -1;<br>
> +    strncpy((char *)ivp.port_profile, profileid, sizeof(ivp.port_profile));</font></tt>
<br>
<br><tt><font size=2>use the libvirt function to copy string</font></tt>
<br><tt><font size=2><br>
> +    ivp.port_profile[sizeof(ivp.port_profile)-1] = '\0';<br>
> +    memcpy(ivp.mac, macaddress, sizeof(ivp.mac));<br>
> +    get_host_uuid(host_uuid, IFLA_VF_UUID_MAX);</font></tt>
<br>
<br>
<br><tt><font size=2>check for error</font></tt>
<br>
<br><tt><font size=2><br>
> +    if (strlen(host_uuid)) {<br>
> +        strncpy((char *)ivp.host_uuid, host_uuid,
sizeof(ivp.host_uuid));</font></tt>
<br>
<br><tt><font size=2>use libvirt function to copy string</font></tt>
<br><tt><font size=2><br>
> +        ivp.port_profile[sizeof(ivp.port_profile)-1]
= '\0';<br>
> +    }<br>
> +<br>
> +    if(!(rc = sendPortProfileMulticastMsg(linkdev, &ivp)))
{<br>
> +       rc = ifaceUp(linkdev);<br>
> +       if (rc != 0) {<br>
> +           virReportSystemError(errno,<br>
> +                    
          ("cannot 'up' interface %s"),<br>
> +                    
          linkdev);<br>
> +           // Should we error out of here
?<br>
> +           //rc = -1;<br>
> +       }<br>
> +    }<br>
> +<br>
> +    return rc;<br>
> +}<br>
>  <br>
>  /**<br>
>   * openMacvtapTap:<br>
> diff --git a/src/util/macvtap.h b/src/util/macvtap.h<br>
> index 5d4ea5e..7f58a13 100644<br>
> --- a/src/util/macvtap.h<br>
> +++ b/src/util/macvtap.h<br>
> @@ -37,6 +37,12 @@ int openMacvtapTap(const char *ifname,<br>
>  <br>
>  void delMacvtap(const char *ifname);<br>
>  <br>
> +int setPortProfileId(const char *linkdev,<br>
> +                    
const char *profileid,<br>
> +                    
unsigned char *macaddress);<br>
> +<br>
> +int unsetPortProfileId(const char *linkdev);<br>
> +</font></tt>
<br>
<br><tt><font size=2>Remove after pushing the function into open* and del*
functions.</font></tt>
<br>
<br><tt><font size=2>Regards,</font></tt>
<br><tt><font size=2>   Stefan</font></tt>
<br>
<br><tt><font size=2><br>
>  # endif /* WITH_MACVTAP */<br>
>  <br>
>  # define MACVTAP_MODE_PRIVATE_STR  "private"<br>
> <br>
> --<br>
> libvir-list mailing list<br>
> libvir-list@redhat.com<br>
> </font></tt><a href="https://www.redhat.com/mailman/listinfo/libvir-list"><tt><font size=2>https://www.redhat.com/mailman/listinfo/libvir-list</font></tt></a>