On Fri, 3 Jul 2026 at 12:35, Michal Prívozník <[email protected]> wrote:
> On 6/19/26 10:56, Radosław Śmigielski via Devel wrote: > > From: Radoslaw Smigielski <[email protected]> > > > > LXC domains did not assign device aliases to filesystem and network > > interface during domain startup. Only console devices received > > aliases. > > > > This change introduces two new functions: > > - virLXCAssignDeviceNetAlias() > > - virLXCAssignDeviceFSAlias() > > > > These functions scan existing devices to find the next available > > device index. Also ensure correct alias assignment after network > > and block device hotplug/unplug operations when a gap can > > be introduced in device numbering. > > > > The new functions are called during: > > - domain startup virLXCProcessStart() > > - device hotplug lxcDomainAttachDeviceNetLive() > > > > Signed-off-by: Radoslaw Smigielski <[email protected]> > > --- > > src/lxc/lxc_domain.c | 59 +++++++++++++++++++++++++++++++++++++++++++ > > src/lxc/lxc_domain.h | 8 ++++++ > > src/lxc/lxc_driver.c | 3 +++ > > src/lxc/lxc_process.c | 8 ++++++ > > 4 files changed, 78 insertions(+) > > > > diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c > > index afd8d6e9805f..5326c9852073 100644 > > --- a/src/lxc/lxc_domain.c > > +++ b/src/lxc/lxc_domain.c > > @@ -25,6 +25,7 @@ > > > > #include "virlog.h" > > #include "virerror.h" > > +#include "virstring.h" > > #include "virtime.h" > > #include "virsystemd.h" > > #include "virinitctl.h" > > @@ -375,3 +376,61 @@ virLXCDomainSetRunlevel(virDomainObj *vm, > > g_clear_pointer(&data.st_valid, g_free); > > return ret; > > } > > + > > + > > +void > > +virLXCAssignDeviceNetAlias(virDomainDef *def, > > + virDomainNetDef *net) > > +{ > > + size_t i; > > + int idx = 0; > > + > > + if (net->info.alias) > > + return; > > + > > + for (i = 0; i < def->nnets; i++) { > > + int thisidx; > > + > > + if (!def->nets[i]->info.alias) > > + continue; > > + if (!STRPREFIX(def->nets[i]->info.alias, "net")) > > + continue; > > + > > + if (virStrToLong_i(def->nets[i]->info.alias + 3, NULL, 10, > &thisidx) < 0) > > + continue; > > There's a macro that combines STRPREFIX() + this offsetting of a string: > STRSKIP(). > > > + > > + if (thisidx >= idx) > > + idx = thisidx + 1; > > + } > > + > > + net->info.alias = g_strdup_printf("net%d", idx); > > +} > > > Reviewed-by: Michal Privoznik <[email protected]> > > and merged. > > Michal > > Shall we add this to v12.6.0 (unreleased) NEWS.rst file? ---------------------- < Tℏanks | Radek >
