From nobody Mon Feb 9 03:51:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1607358881; cv=none; d=zohomail.com; s=zohoarc; b=TQ127LJQ8XSxrNt9ek6CtikYJYaG4J/anX8Q7Prlz9W7j/1RCKmw47WtGYZhpdf0zXqaR9IeFKOAYbl62SjpIwENkGgwSAX0Hc/kA6sh2ykZ6n++IucQS4hhoKwd3DMn50pwCvOJxge0PxCfCuy77QGf7N5WA98FGctSsWxX33c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607358881; 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=WeNZKeQf4rHwM+/UxkZWUtM/Fmcp9wPNRjWhKYXw1Bs=; b=HCFQEHPp2t4nWDjfy2T4zKDJegk/TlwwpuS5eODhALnJk7CXMNjcDKHAavp+Wq12ODqG9JO1QN73LMl+jcB9egxRvxfHZii/OkmbomaeEkVXbTjVLmkaGF9tP3qBQie+amalzIBMXt+P4BbTfVSJfTY4RfXuV1nYUdXAPo0daBY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607358880850836.6119444843407; Mon, 7 Dec 2020 08:34:40 -0800 (PST) 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-179-UnKPYI9gNVimw7AC6aW5Qw-1; Mon, 07 Dec 2020 11:34:36 -0500 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 C338ABBEFC; Mon, 7 Dec 2020 16:34:29 +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 39A8B5C1A3; Mon, 7 Dec 2020 16:34:29 +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 A11CE4A7C7; Mon, 7 Dec 2020 16:34:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B7GYOG3029089 for ; Mon, 7 Dec 2020 11:34:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id AC8835D6AD; Mon, 7 Dec 2020 16:34:24 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id E96495D6AB for ; Mon, 7 Dec 2020 16:34:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607358878; 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=WeNZKeQf4rHwM+/UxkZWUtM/Fmcp9wPNRjWhKYXw1Bs=; b=UQZt4cJtC6wRwYJl5FfGoZSOfJJVC88C5/pw8FbFJNNbDM2CNC3k8YnBWJVbYqZ4iYw2l+ hk2oYWpLUJg8AkglQpBOUpXOEgMq6m+Fj1nHrMs+Tl8KNuphvpqQToURYUdOlnj4nWJV43 ueHTRNZ9/kQCJZ+v976RG3fXrHnekKE= X-MC-Unique: UnKPYI9gNVimw7AC6aW5Qw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/8] qemuDomainGetStorageSourceByDevstr: Use virDomainDiskByTarget Date: Mon, 7 Dec 2020 17:34:11 +0100 Message-Id: <6c86571b2c4aabaa13132a288835c5e44c145b03.1607358804.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function replaces the open-coded block. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f5d4e468ce..e56351333c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9954,7 +9954,6 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, virStorageSourcePtr src =3D NULL; g_autofree char *target =3D NULL; unsigned int idx; - size_t i; if (virStorageFileParseBackingStoreStr(devstr, &target, &idx) < 0) { virReportError(VIR_ERR_INVALID_ARG, @@ -9962,14 +9961,7 @@ qemuDomainGetStorageSourceByDevstr(const char *devst= r, return NULL; } - for (i =3D 0; i < def->ndisks; i++) { - if (STREQ(target, def->disks[i]->dst)) { - disk =3D def->disks[i]; - break; - } - } - - if (!disk) { + if (!(disk =3D virDomainDiskByTarget(def, target))) { virReportError(VIR_ERR_INVALID_ARG, _("failed to find disk '%s'"), target); return NULL; --=20 2.28.0