Add support for <interface type='network'> in the libxl driver.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_conf.c | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index cec37d6..6efcea6 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -908,7 +908,44 @@ libxlMakeNic(virDomainDefPtr def,
if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
return -1;
break;
- default:
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ {
+ bool error = true;
+ char *brname = NULL;
+ virNetworkPtr network = NULL;
+ virConnectPtr conn;
+
+ if (!(conn = virConnectOpen("xen:///system")))
+ return -1;
+
+ if (!(network =
+ virNetworkLookupByName(conn, l_nic->data.network.name)))
+ goto cleanup_net;
+
+ if (!(brname = virNetworkGetBridgeName(network)))
+ goto cleanup_net;
+
+ if (VIR_STRDUP(x_nic->bridge, brname) < 0)
+ goto cleanup_net;
+
+ error = false;
+
+ cleanup_net:
+ VIR_FREE(brname);
+ virNetworkFree(network);
+ virObjectUnref(conn);
+ if (error)
+ return -1;
+ break;
+ }
+ case VIR_DOMAIN_NET_TYPE_USER:
+ case VIR_DOMAIN_NET_TYPE_SERVER:
+ case VIR_DOMAIN_NET_TYPE_CLIENT:
+ case VIR_DOMAIN_NET_TYPE_MCAST:
+ case VIR_DOMAIN_NET_TYPE_INTERNAL:
+ case VIR_DOMAIN_NET_TYPE_DIRECT:
+ case VIR_DOMAIN_NET_TYPE_HOSTDEV:
+ case VIR_DOMAIN_NET_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight does not support network device type %s"),
virDomainNetTypeToString(l_nic->type));
@@ -919,7 +956,7 @@ libxlMakeNic(virDomainDefPtr def,
}
static int
-libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
{
virDomainNetDefPtr *l_nics = def->nets;
size_t nnics = def->nnets;
--
1.8.0.1