conf: add net device prefix to capabilities

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>
This commit is contained in:
Joao Martins 2016-02-03 21:40:33 +00:00 committed by Daniel P. Berrange
parent 6221b8944e
commit 819d1d9438
3 changed files with 27 additions and 0 deletions

View File

@ -221,6 +221,7 @@ virCapabilitiesDispose(void *object)
virCapabilitiesClearSecModel(&caps->host.secModels[i]); virCapabilitiesClearSecModel(&caps->host.secModels[i]);
VIR_FREE(caps->host.secModels); VIR_FREE(caps->host.secModels);
VIR_FREE(caps->host.netprefix);
VIR_FREE(caps->host.pagesSize); VIR_FREE(caps->host.pagesSize);
virCPUDefFree(caps->host.cpu); virCPUDefFree(caps->host.cpu);
} }
@ -269,6 +270,23 @@ virCapabilitiesAddHostMigrateTransport(virCapsPtr caps,
return 0; 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: * virCapabilitiesAddHostNUMACell:
@ -913,6 +931,10 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virBufferAddLit(&buf, "</migration_features>\n"); virBufferAddLit(&buf, "</migration_features>\n");
} }
if (caps->host.netprefix)
virBufferAsprintf(&buf, "<netprefix>%s</netprefix>\n",
caps->host.netprefix);
if (caps->host.nnumaCell && if (caps->host.nnumaCell &&
virCapabilitiesFormatNUMATopology(&buf, caps->host.nnumaCell, virCapabilitiesFormatNUMATopology(&buf, caps->host.nnumaCell,
caps->host.numaCell) < 0) caps->host.numaCell) < 0)

View File

@ -160,6 +160,7 @@ struct _virCapsHost {
size_t nsecModels; size_t nsecModels;
virCapsHostSecModelPtr secModels; virCapsHostSecModelPtr secModels;
char *netprefix;
virCPUDefPtr cpu; virCPUDefPtr cpu;
int nPagesSize; /* size of pagesSize array */ int nPagesSize; /* size of pagesSize array */
unsigned int *pagesSize; /* page sizes support on the system */ unsigned int *pagesSize; /* page sizes support on the system */
@ -219,6 +220,9 @@ extern int
virCapabilitiesAddHostMigrateTransport(virCapsPtr caps, virCapabilitiesAddHostMigrateTransport(virCapsPtr caps,
const char *name); const char *name);
extern int
virCapabilitiesSetNetPrefix(virCapsPtr caps,
const char *prefix);
extern int extern int
virCapabilitiesAddHostNUMACell(virCapsPtr caps, virCapabilitiesAddHostNUMACell(virCapsPtr caps,

View File

@ -59,6 +59,7 @@ virCapabilitiesGetCpusForNodemask;
virCapabilitiesHostSecModelAddBaseLabel; virCapabilitiesHostSecModelAddBaseLabel;
virCapabilitiesNew; virCapabilitiesNew;
virCapabilitiesSetHostCPU; virCapabilitiesSetHostCPU;
virCapabilitiesSetNetPrefix;
# conf/cpu_conf.h # conf/cpu_conf.h