On Wed, 2010-05-12 at 12:13 -0400, Stefan Berger wrote:
I'd suggest to use this patch as a base for triggering the setup
protocol with the 802.1Qb{g|h} switch.
Here is a RFC patch, which demonstrates how libvirt could communicate
with lldpad via the lldptool for the 802.1Qbg case. Please note, that
there is currently no public available version of lldptool which accepts
this command line. This is also work in progress.
This applies on top of the patch Stefan just posted.
Signed-off-by: Gerhard Stenzel <gerhard.stenzel(a)de.ibm.com>
Index: libvirt/src/util/macvtap.c
===================================================================
--- libvirt.orig/src/util/macvtap.c
+++ libvirt/src/util/macvtap.c
@@ -750,6 +750,107 @@ configMacvtapTap(int tapfd, int vnet_hdr
return 0;
}
+# define ASSOCIATE 0x02
+# define DEASSOCIATE 0x03
+# define LLDPTOOL_NAME "lldptool"
+
+static int
+setPortProfileId(const char *linkdev,
+ const unsigned char *mac,
+ int mode,
+ const virVSIProfileDefPtr vsi)
+{
+ char macaddr[VIR_MAC_STRING_BUFLEN];
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ char rootifname[IFNAMSIZ];
+ static char *lldptool;
+ char *modestr = NULL;
+ int vlanid = 0;
+ int rc;
+ int status = 0;
+# define NUM_PARAMS 8
+ const char *argv[NUM_PARAMS] = {NULL, };
+ int argc = 0;
+
+ virFormatMacAddr(mac, macaddr);
+
+ rc = ifaceGetRootIface(-1, linkdev, rootifname);
+ if (rc != 0) {
+ macvtapError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot get root interface for %s"),
+ linkdev);
+ return rc;
+ }
+ VIR_DEBUG("root iface of %s is %s\n", linkdev, rootifname);
+
+ ifaceGetVlanID(linkdev, &vlanid);
+ VIR_DEBUG("vlan id of %s is %d\n", linkdev, vlanid);
+
+ if (lldptool == NULL) {
+ lldptool = virFindFileInPath(LLDPTOOL_NAME);
+ if (lldptool == NULL) {
+ macvtapError(VIR_ERR_INTERNAL_ERROR,
+ _("unable to find %s"), LLDPTOOL_NAME);
+ return -1;
+ }
+ }
+
+ virFormatMacAddr(mac, macaddr);
+ virUUIDFormat(vsi->u.vsi8021Qbg.instanceID, uuidstr);
+
+ VIR_DEBUG("setting port profile id '%p' with mode %d on physical
device '%s' mac '%s' vlan '%d'\n",
+ vsi, mode, rootifname, macaddr, vlanid);
+
+ /* example syntax:
+ * lldptool -T -i eth2 -V vdp \
+ *
mode=<mode>,<mgrid>,<typeid>,<typeidversion>,<uuid>
+ */
+
+ if ((virAsprintf(&modestr, "mode=%d,%d,%d,%d,%s,%s,%d", mode,
+
vsi->u.vsi8021Qbg.managerID,
+
vsi->u.vsi8021Qbg.typeID,
+
vsi->u.vsi8021Qbg.typeIDVersion,
+ uuidstr,
+ macaddr,
+ vlanid) < 0 )) {
+ rc = -1;
+ goto err_exit;
+ }
+
+ argv[argc++] = lldptool;
+ argv[argc++] = "-T";
+ argv[argc++] = "-i";
+ argv[argc++] = rootifname;
+ argv[argc++] = "-V";
+ argv[argc++] = "vdp";
+ argv[argc++] = modestr;
+ argv[argc ] = NULL;
+
+ VIR_DEBUG("argc = %d\n", argc);
+ if (argc >= NUM_PARAMS) {
+ macvtapError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("too many parameters in array"));
+ rc = 1;
+ goto err_exit;
+ }
+# undef NUM_PARAMS
+
+ rc = virRun(argv, &status);
+ status >>= 8;
+
+ VIR_DEBUG("Result from running %s: rc = %d, status = %d\n",
+ lldptool, rc, status);
+
+err_exit:
+ VIR_FREE(modestr);
+
+ if (rc)
+ return rc;
+
+ return status;
+
+}
+
/**
* associatePortProfile
@@ -791,7 +892,10 @@ associatePortProfileId(const char *linkd
break;
case VIR_VSI_8021QBG:
- rc = -1;
+ rc = setPortProfileId(linkdev,
+ mac,
+ ASSOCIATE,
+ vsi);
break;
case VIR_VSI_8021QBH:
@@ -829,7 +933,10 @@ disassociatePortProfileId(const char *li
break;
case VIR_VSI_8021QBG:
- rc = -1;
+ rc = setPortProfileId(linkdev,
+ mac,
+ DEASSOCIATE,
+ vsi);
break;
case VIR_VSI_8021QBH:
--
Best regards,
Gerhard Stenzel,
-----------------------------------------------------------------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294