]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: add net device prefix to capabilities
authorJoao Martins <joao.m.martins@oracle.com>
Wed, 3 Feb 2016 21:40:33 +0000 (21:40 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 4 Feb 2016 11:15:51 +0000 (11:15 +0000)
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@oracle.com>
src/conf/capabilities.c
src/conf/capabilities.h
src/libvirt_private.syms

index 86ea212fa9dabecccc3b69e24ab4a35ae144141d..9ab343bc65508ca905558fd8f74b59144c6041c0 100644 (file)
@@ -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)
index 1754b1326919da503bdb8adec1693d17618d8a03..2767f4807d41e32583a2e59b70fbdf7d9c03df16 100644 (file)
@@ -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,
index 69be352d6eb16a32460a52e1121eb6785fd88cd6..f118d979eec7fbe2a5ed3953c678973cc97c26d6 100644 (file)
@@ -59,6 +59,7 @@ virCapabilitiesGetCpusForNodemask;
 virCapabilitiesHostSecModelAddBaseLabel;
 virCapabilitiesNew;
 virCapabilitiesSetHostCPU;
+virCapabilitiesSetNetPrefix;
 
 
 # conf/cpu_conf.h