[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2] libxl: free ifname on libxlDomainMigrationPrepareDef
Commit d2e5538b1 changes virDomainDef to include ifnames that autogenerated by libxl, and that are also cleared on domain cleanup. One place that's missing is on migration, when domain xml is sent to dst libvirtd and would contain ifnames from the source libvirtd. This would lead to erronous behaviour (as seen in osstest CI) such as failing to migrate when a vif with the same name existed (belonging to another domain) on destination. This patch adds a helper libxlDomainFreeIfaceNames for clearing ifnames on both migration prepare phase and domain cleanup. It is done on prepare phase so that we don't affect source domain (specially in cases when the migration fails), while still allowing interface stats to be consulted during the migration. Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx> --- Changes since v1: - Commit message is changed - Clear ifnames on prepare phase as opposed to begin phase. --- src/libxl/libxl_domain.c | 32 ++++++++++++++++++++++---------- src/libxl/libxl_domain.h | 3 +++ src/libxl/libxl_migration.c | 2 ++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index ef92974..487589d 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -728,16 +728,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, } } - if ((vm->def->nnets)) { - size_t i; - - for (i = 0; i < vm->def->nnets; i++) { - virDomainNetDefPtr net = vm->def->nets[i]; - - if (STRPREFIX(net->ifname, "vif")) - VIR_FREE(net->ifname); - } - } + libxlDomainFreeIfaceNames(vm->def); if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name) > 0) { if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR) @@ -923,6 +914,27 @@ libxlDomainCreateIfaceNames(virDomainDefPtr def, libxl_domain_config *d_config) } } +/* + * Removes autogenerated interface names for the network devices in + * parameter def. User-provided interface names are skipped. + */ +void +libxlDomainFreeIfaceNames(virDomainDefPtr def) +{ + size_t i; + + for (i = 0; i < def->nnets; i++) { + virDomainNetDefPtr net = def->nets[i]; + + if (!net->ifname) + continue; + + if (STRPREFIX(net->ifname, "vif")) + VIR_FREE(net->ifname); + } +} + + /* * Start a domain through libxenlight. diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h index 44b3e0b..70c139c 100644 --- a/src/libxl/libxl_domain.h +++ b/src/libxl/libxl_domain.h @@ -135,6 +135,9 @@ int libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm); +void +libxlDomainFreeIfaceNames(virDomainDefPtr def); + int libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm, diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 0d23e5f..1ca31ab 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -288,6 +288,8 @@ libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver, VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto cleanup; + libxlDomainFreeIfaceNames(def); + if (dname) { name = def->name; if (VIR_STRDUP(def->name, dname) < 0) { -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |