From: Radoslaw Smigielski <rsmigiel@redhat.com> LXC domains did not assign device aliases to network interface devices during domain startup. This change assigns aliases in the format 'net0', 'net1', etc. to all network interfaces during domain startup, following the same pattern used for console and filesystem devices. Before this patch, virsh dumpxml showed network interfaces without aliases: <interface type='network'> <mac address='52:54:00:12:34:56'/> <source network='default'/> </interface> After this patch, network interfaces have auto-generated aliases: <interface type='network'> <mac address='52:54:00:12:34:56'/> <source network='default'/> <alias name='net0'/> </interface> This ensures all LXC device types (consoles, filesystems, and network interfaces) have consistent alias assigned. Signed-off-by: Radoslaw Smigielski <rsmigiel@redhat.com> --- src/lxc/lxc_process.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index aae9fcc9dfd1..f93f3f05c394 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1356,6 +1356,12 @@ int virLXCProcessStart(virLXCDriver * driver, vm->def->fss[i]->info.alias = g_strdup_printf("fs%zu", i); } + VIR_DEBUG("Setting up network interface aliases"); + for (i = 0; i < vm->def->nnets; i++) { + g_free(vm->def->nets[i]->info.alias); + vm->def->nets[i]->info.alias = g_strdup_printf("net%zu", i); + } + VIR_DEBUG("Setting up Interfaces"); if (virLXCProcessSetupInterfaces(driver, vm->def, &veths) < 0) goto cleanup; -- 2.54.0