[PATCH RFC v2 1/5] conf: add net device prefix to capabilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the reverted commit d2e5538b1, the libxl driver was changed to copy
interface names autogenerated by libxl to the corresponding network def
in the domain's virDomainDef object. The copied name is freed when the
domain transitions to the shutoff state. But when migrating a domain,
the autogenerated name is included in the XML sent to the destination
host.  It is possible an interface with the same name already exists on
the destination host, causing migration to fail.

This patch defines a new capability for setting the network device
prefix that will be used in the driver. Valid prefixes are
VIR_NET_GENERATED_PREFIX or the one announced by the driver.

Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
---
Changes since v1:
 - free netprefix in virCapabilitiesDispose()
---
 src/conf/capabilities.c  | 22 ++++++++++++++++++++++
 src/conf/capabilities.h  |  4 ++++
 src/libvirt_private.syms |  1 +
 3 files changed, 27 insertions(+)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 86ea212..9ab343b 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -221,6 +221,7 @@ virCapabilitiesDispose(void *object)
         virCapabilitiesClearSecModel(&caps->host.secModels[i]);
     VIR_FREE(caps->host.secModels);
 
+    VIR_FREE(caps->host.netprefix);
     VIR_FREE(caps->host.pagesSize);
     virCPUDefFree(caps->host.cpu);
 }
@@ -269,6 +270,23 @@ virCapabilitiesAddHostMigrateTransport(virCapsPtr caps,
     return 0;
 }
 
+/**
+ * virCapabilitiesSetNetPrefix:
+ * @caps: capabilities to extend
+ * @name: prefix for host generated network interfaces
+ *
+ * Registers the prefix that is used for generated network interfaces
+ */
+int
+virCapabilitiesSetNetPrefix(virCapsPtr caps,
+                            const char *prefix)
+{
+    if (VIR_STRDUP(caps->host.netprefix, prefix) < 0)
+        return -1;
+
+    return 0;
+}
+
 
 /**
  * virCapabilitiesAddHostNUMACell:
@@ -913,6 +931,10 @@ virCapabilitiesFormatXML(virCapsPtr caps)
         virBufferAddLit(&buf, "</migration_features>\n");
     }
 
+    if (caps->host.netprefix)
+        virBufferAsprintf(&buf, "<netprefix>%s</netprefix>\n",
+                          caps->host.netprefix);
+
     if (caps->host.nnumaCell &&
         virCapabilitiesFormatNUMATopology(&buf, caps->host.nnumaCell,
                                           caps->host.numaCell) < 0)
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 1754b13..2767f48 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -160,6 +160,7 @@ struct _virCapsHost {
     size_t nsecModels;
     virCapsHostSecModelPtr secModels;
 
+    char *netprefix;
     virCPUDefPtr cpu;
     int nPagesSize;             /* size of pagesSize array */
     unsigned int *pagesSize;    /* page sizes support on the system */
@@ -219,6 +220,9 @@ extern int
 virCapabilitiesAddHostMigrateTransport(virCapsPtr caps,
                                        const char *name);
 
+extern int
+virCapabilitiesSetNetPrefix(virCapsPtr caps,
+                            const char *prefix);
 
 extern int
 virCapabilitiesAddHostNUMACell(virCapsPtr caps,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3d0ec9d..4f94e42 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -59,6 +59,7 @@ virCapabilitiesGetCpusForNodemask;
 virCapabilitiesHostSecModelAddBaseLabel;
 virCapabilitiesNew;
 virCapabilitiesSetHostCPU;
+virCapabilitiesSetNetPrefix;
 
 
 # conf/cpu_conf.h
-- 
2.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]