From nobody Sun Feb 8 18:32:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633504581; cv=none; d=zohomail.com; s=zohoarc; b=fSoeOx+dCoxciysBAco2dseguozYBwJ0XchSYYBNL79dx1zTkH2QEHozbu0m5TTuEG+fyt2rEBgqQYfLRLSketoPh1TFsNqCZi8PaHFz5MudqQTowGMzwsU2P4HEhF6ScVdHbGws6uboUL8SXM1JlfusL9KLd4nQfujXoI7G6dQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633504581; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BR2BWCrD/k3cQifhoa+0l8uG89ioeZzFawLvmj7v61s=; b=HPeK1laI7IofcBf2vyoqdrS2dN/IaE4USRTYGzUxIcrS/k9l0xexJwhvfkCOMoGsB0JliNvNsXLKKt2LfXkendWOTd2sVa45qc2EHg/pXzd3hWpAlHL7pjtYad6u9ZQIQuzLdf3kJpC9Xrs6+1wRnrUHCcpujSKURurF/czZBFw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1633504581415337.04148869187225; Wed, 6 Oct 2021 00:16:21 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-158-ohO5cvU6MhGwrnp8w-baOQ-1; Wed, 06 Oct 2021 03:16:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BCBB68015C7; Wed, 6 Oct 2021 07:16:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99BC59AA3F; Wed, 6 Oct 2021 07:16:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5B5E54E58F; Wed, 6 Oct 2021 07:16:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1967Flhb007500 for ; Wed, 6 Oct 2021 03:15:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5CFB60622; Wed, 6 Oct 2021 07:15:47 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4638460853 for ; Wed, 6 Oct 2021 07:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633504580; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BR2BWCrD/k3cQifhoa+0l8uG89ioeZzFawLvmj7v61s=; b=Ers17aNw376+pP+WVG8mXhahcF1/rocSPkM2WJy14o0aIFND9tENGiCAjVgfqFBp1u10yU fCnsUlFTtP2K26mE7pG5wZ6uFaMYmc4NM8RaxUoAWi9SA3cMJe03/AfH/GBDtrlZG4OhWd 7VRXc/c3HxXwRfy8+9fzuPaIMAZWWP0= X-MC-Unique: ohO5cvU6MhGwrnp8w-baOQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/16] qemu: alias: prepare qemuAssignDeviceFSAlias for disjunct ranges Date: Wed, 6 Oct 2021 09:15:16 +0200 Message-Id: <877ce9bf245198b1b4a44f93758df4534bb42fe5.1633504466.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633504583245100001 Iterate through the array to find the first free index. Signed-off-by: J=C3=A1n Tomko --- 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, =20 =20 static int -qemuAssignDeviceFSAlias(virDomainFSDef *fss, - int idx) +qemuAssignDeviceFSAlias(virDomainDef *def, + virDomainFSDef *fss) { + size_t i; + int maxidx =3D 0; + if (fss->info.alias) return 0; =20 - fss->info.alias =3D g_strdup_printf("fs%d", idx); + for (i =3D 0; i < def->nfss; i++) { + int idx; + + if ((idx =3D qemuDomainDeviceAliasIndex(&def->fss[i]->info, "fs"))= >=3D maxidx) + maxidx =3D idx + 1; + } + + fss->info.alias =3D g_strdup_printf("fs%d", maxidx); return 0; } =20 @@ -634,7 +644,7 @@ qemuAssignDeviceAliases(virDomainDef *def, virQEMUCaps = *qemuCaps) } =20 for (i =3D 0; i < def->nfss; i++) { - if (qemuAssignDeviceFSAlias(def->fss[i], i) < 0) + if (qemuAssignDeviceFSAlias(def, def->fss[i]) < 0) return -1; } for (i =3D 0; i < def->nsounds; i++) { --=20 2.31.1