--- docs/schemas/domain.rng | 8 ++++++++ src/conf/domain_conf.c | 12 ++++++++++++ src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 3 +++ src/qemu/qemu_conf.c | 12 ++++++++++++ src/util/macvtap.c | 13 +++++++++++++ src/util/macvtap.h | 4 ++++ 7 files changed, 53 insertions(+), 0 deletions(-) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index d804301..5917f60 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -794,6 +794,11 @@ <ref name="bridgeMode"/> </attribute> </optional> + <optional> + <attribute name="profileid"> + <ref name="profileID"/> + </attribute> + </optional> <empty/> </element> <ref name="interface-options"/> @@ -1647,6 +1652,9 @@ <param name="pattern">(vepa|bridge|private)</param> </data> </define> + <define name="profileID"> + <data type="string"/> + </define> <define name="addrMAC"> <data type="string"> <param name="pattern">([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}</param> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 66aa53e..ea2f8dd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -479,6 +479,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def) case VIR_DOMAIN_NET_TYPE_DIRECT: VIR_FREE(def->data.direct.linkdev); + VIR_FREE(def->data.direct.profileid); break; case VIR_DOMAIN_NET_TYPE_USER: @@ -1801,6 +1802,7 @@ virDomainNetDefParseXML(virCapsPtr caps, char *internal = NULL; char *devaddr = NULL; char *mode = NULL; + char *profileid = NULL; virNWFilterHashTablePtr filterparams = NULL; if (VIR_ALLOC(def) < 0) { @@ -1843,6 +1845,7 @@ virDomainNetDefParseXML(virCapsPtr caps, xmlStrEqual(cur->name, BAD_CAST "source")) { dev = virXMLPropString(cur, "dev"); mode = virXMLPropString(cur, "mode"); + profileid = virXMLPropString(cur, "profileid"); } else if ((network == NULL) && ((def->type == VIR_DOMAIN_NET_TYPE_SERVER) || (def->type == VIR_DOMAIN_NET_TYPE_CLIENT) || @@ -2018,6 +2021,10 @@ virDomainNetDefParseXML(virCapsPtr caps, } else def->data.direct.mode = VIR_DOMAIN_NETDEV_MACVTAP_MODE_VEPA; + if (profileid != NULL) { + def->data.direct.profileid = profileid; + } + def->data.direct.linkdev = dev; dev = NULL; @@ -2083,6 +2090,7 @@ cleanup: VIR_FREE(internal); VIR_FREE(devaddr); VIR_FREE(mode); + VIR_FREE(profileid); virNWFilterHashTableFree(filterparams); return def; @@ -5080,6 +5088,10 @@ virDomainNetDefFormat(virBufferPtr buf, def->data.direct.linkdev); virBufferVSprintf(buf, " mode='%s'", virDomainNetdevMacvtapTypeToString(def->data.direct.mode)); + if (def->data.direct.profileid) { + virBufferEscapeString(buf, " profileid='%s'", + def->data.direct.profileid); + } virBufferAddLit(buf, "/>\n"); break; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ed1a4ad..4c23a23 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -289,6 +289,7 @@ struct _virDomainNetDef { struct { char *linkdev; int mode; + char *profileid; } direct; } data; char *ifname; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cc943f8..a14b114 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -702,3 +702,6 @@ virXPathLongLong; virXPathULongLong; virXPathLongHex; virXPathULongHex; + +# macvtap.h +sendPortProfileId; diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 8f6f7ec..f2880d3 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1469,6 +1469,18 @@ qemudPhysIfaceConnect(virConnectPtr conn, net->model && STREQ(net->model, "virtio")) vnet_hdr = 1; + /* Failure here is equivalent to the failure to plug in a physical + * network port. + * + * If this operation is non-blocking we will have a race between + * the VM starting and the interface coming up. + * + * If any of the subsequent operations fail, will we need to + * unwind the sending of the port profile id? */ + sendPortProfileId(net->data.direct.linkdev, + net->data.direct.mode, + net->data.direct.profileid); + rc = openMacvtapTap(conn, net->ifname, net->mac, linkdev, brmode, &res_ifname, vnet_hdr); if (rc >= 0) { diff --git a/src/util/macvtap.c b/src/util/macvtap.c index 999e670..585e56b 100644 --- a/src/util/macvtap.c +++ b/src/util/macvtap.c @@ -43,6 +43,7 @@ # include "util.h" # include "memory.h" +# include "logging.h" # include "macvtap.h" # include "conf/domain_conf.h" # include "virterror_internal.h" @@ -673,6 +674,18 @@ configMacvtapTap(int tapfd, int vnet_hdr) } +int +sendPortProfileId(const char *linkdev, + int mode, + const char *profileid) +{ + VIR_DEBUG("Sending port profile id '%s' on physical device '%s' mode %d", + profileid, linkdev, mode); + + return 0; +} + + /** * openMacvtapTap: * Create an instance of a macvtap device and open its tap character diff --git a/src/util/macvtap.h b/src/util/macvtap.h index bd5f4d6..6cd7621 100644 --- a/src/util/macvtap.h +++ b/src/util/macvtap.h @@ -38,6 +38,10 @@ int openMacvtapTap(virConnectPtr conn, void delMacvtap(const char *ifname); +int sendPortProfileId(const char *linkdev, + int mode, + const char *profileid); + # endif /* WITH_MACVTAP */ # define MACVTAP_MODE_PRIVATE_STR "private" -- 1.7.0.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list