On a Wednesday in 2021, Peter Krempa wrote:
On Wed, Oct 06, 2021 at 09:15:16 +0200, Ján Tomko wrote:
> Iterate through the array to find the first free index.
>
> Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
> ---
> src/qemu/qemu_alias.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
> index 81a1e7eeed..4153050bec 100644
> --- a/src/qemu/qemu_alias.c
> +++ b/src/qemu/qemu_alias.c
> @@ -336,13 +336,23 @@ qemuAssignDeviceNetAlias(virDomainDef *def,
>
>
> static int
> -qemuAssignDeviceFSAlias(virDomainFSDef *fss,
> - int idx)
> +qemuAssignDeviceFSAlias(virDomainDef *def,
> + virDomainFSDef *fss)
> {
> + size_t i;
> + int maxidx = 0;
> +
> if (fss->info.alias)
> return 0;
>
> - fss->info.alias = g_strdup_printf("fs%d", idx);
> + for (i = 0; i < def->nfss; i++) {
> + int idx;
> +
> + if ((idx = qemuDomainDeviceAliasIndex(&def->fss[i]->info,
"fs")) >= maxidx)
> + maxidx = idx + 1;
> + }
> +
> + fss->info.alias = g_strdup_printf("fs%d", maxidx);
> return 0;
> }
>
> @@ -634,7 +644,7 @@ qemuAssignDeviceAliases(virDomainDef *def, virQEMUCaps
*qemuCaps)
> }
>
> for (i = 0; i < def->nfss; i++) {
> - if (qemuAssignDeviceFSAlias(def->fss[i], i) < 0)
> + if (qemuAssignDeviceFSAlias(def, def->fss[i]) < 0)
> return -1;
Are other devices also n^2 during startup of the VM?
For the alias assingment, many of the hotpluggable ones are.
Don't know about the rest of the startup code.
Jano