提交 819d1d94 编写于 作者: J Joao Martins 提交者: Daniel P. Berrange

conf: add net device prefix to capabilities

In the reverted commit d2e5538b, 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: NJoao Martins <joao.m.martins@oracle.com>
上级 6221b894
......@@ -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)
......
......@@ -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,
......
......@@ -59,6 +59,7 @@ virCapabilitiesGetCpusForNodemask;
virCapabilitiesHostSecModelAddBaseLabel;
virCapabilitiesNew;
virCapabilitiesSetHostCPU;
virCapabilitiesSetNetPrefix;
# conf/cpu_conf.h
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册