[libvirt] [PATCH RFC 2/2] libxl: set net device prefix

Joao Martins joao.m.martins at oracle.com
Wed Jan 20 23:41:27 UTC 2016


Use the newly added virCapabilitiesSetNetPrefix to set
the network prefix for the driver. This in return will
be use by NetDefFormat() and NetDefParseXML() routines
to free any interface name that start with the registered
prefix.

Signed-off-by: Joao Martins <joao.m.martins at oracle.com>
---
 src/libxl/libxl_conf.c | 3 +++
 src/libxl/libxl_conf.h | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 6320421..d7fb533 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -183,6 +183,9 @@ libxlCapsInitHost(libxl_ctx *ctx, virCapsPtr caps)
         virCapabilitiesAddHostFeature(caps, "pae") < 0)
         return -1;
 
+    if (virCapabilitiesSetNetPrefix(caps, LIBXL_GENERATED_PREFIX_XEN) < 0)
+        return -1;
+
     return 0;
 }
 
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 7c68b2b..6ad9ad3 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -47,6 +47,10 @@
 # define LIBXL_MIGRATION_PORT_MIN  49152
 # define LIBXL_MIGRATION_PORT_MAX  49216
 
+/* Used for prefix of ifname of any network name generated dynamically
+ * by libvirt for Xen, and cannot be used for a persistent network name.  */
+# define LIBXL_GENERATED_PREFIX_XEN "vif"
+
 # define LIBXL_CONFIG_BASE_DIR SYSCONFDIR "/libvirt"
 # define LIBXL_CONFIG_DIR SYSCONFDIR "/libvirt/libxl"
 # define LIBXL_AUTOSTART_DIR LIBXL_CONFIG_DIR "/autostart"
-- 
2.1.4




More information about the libvir-list mailing list