From nobody Tue May 7 09:19:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1558448793; cv=none; d=zoho.com; s=zohoarc; b=JhA6c/kr3NxkYBDbP6j1zkdiAlRyx4MMeKHIvbgwTH++jGvs0XXWnJL5hsmff6lPUDBP04reEVu9tJpJaLY2aW/AC56DT/RHHu0hBSUheZWMOPQy5MSAJ/CUakXCSc7X4qu1CsVVBHVUumizIIt0+gbVjIQIdZ3dBjLwIt7yEus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558448793; 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:ARC-Authentication-Results; bh=4gODH3uPIjB2tgeFb6UhTZStCjEwLGNNDR0IqoSvqQY=; b=XTwrGOcivyleq1ANctFxcFvz+xOTreM8SV/84iFHxXlivN9ckNV9gZs3Aj1WHdx0FQA+eC6e56r6L4V/RY5OJjo7YPPcyzbiNUYR5bhm0/AMdVx2Mtwp8d6vOU+LwRuC8JRg74Tw7VpnlUTfP9voAmrjSB0HSdYxQ5oPwXpkEHw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558448793286881.1575249968113; Tue, 21 May 2019 07:26:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0665330832EF; Tue, 21 May 2019 14:26:15 +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 AFE0A1001F5B; Tue, 21 May 2019 14:26:10 +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 4B6775B425; Tue, 21 May 2019 14:26:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4LEQ6KN011942 for ; Tue, 21 May 2019 10:26:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2A6266844; Tue, 21 May 2019 14:26:06 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D35B66842 for ; Tue, 21 May 2019 14:26:06 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 21 May 2019 16:25:59 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] Introduce virDomainDeviceIterate 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 21 May 2019 14:26:27 +0000 (UTC) A counterpart to virDomainDeviceInfoIterate that will iterate over all devices, not just those with an info. Use it in places where we intend to process all devices with callbacks that do not depend on DeviceInfo being present: * virDomainDefPostParse * virDomainDefValidate Signed-off-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 28 +++++++++++++++++++--------- src/conf/domain_conf.h | 3 +++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a3a514136b..fb1256f640 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4297,6 +4297,19 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr d= ef, } =20 =20 +int +virDomainDeviceIterate(virDomainDefPtr def, + virDomainDeviceInfoCallback cb, + void *opaque) +{ + return virDomainDeviceInfoIterateInternal(def, + cb, + DOMAIN_DEVICE_ITERATE_ALL_CO= NSOLES | + DOMAIN_DEVICE_ITERATE_GRAPHI= CS, + opaque); +} + + int virDomainDeviceInfoIterate(virDomainDefPtr def, virDomainDeviceInfoCallback cb, @@ -5793,10 +5806,9 @@ virDomainDefPostParse(virDomainDefPtr def, } =20 /* iterate the devices */ - ret =3D virDomainDeviceInfoIterateInternal(def, - virDomainDefPostParseDeviceIt= erator, - DOMAIN_DEVICE_ITERATE_ALL_CON= SOLES, - &data); + ret =3D virDomainDeviceIterate(def, + virDomainDefPostParseDeviceIterator, + &data); =20 if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) goto cleanup; @@ -6923,11 +6935,9 @@ virDomainDefValidate(virDomainDefPtr def, return -1; =20 /* iterate the devices */ - if (virDomainDeviceInfoIterateInternal(def, - virDomainDefValidateDeviceItera= tor, - (DOMAIN_DEVICE_ITERATE_ALL_CONS= OLES | - DOMAIN_DEVICE_ITERATE_GRAPHICS= ), - &data) < 0) + if (virDomainDeviceIterate(def, + virDomainDefValidateDeviceIterator, + &data) < 0) return -1; =20 if (virDomainDefValidateInternal(def, xmlopt) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index fa0756b634..15ecdac6f7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2869,6 +2869,9 @@ typedef int (*virDomainDeviceInfoCallback)(virDomainD= efPtr def, virDomainDeviceInfoPtr info, void *opaque); =20 +int virDomainDeviceIterate(virDomainDefPtr def, + virDomainDeviceInfoCallback cb, + void *opaque); int virDomainDeviceInfoIterate(virDomainDefPtr def, virDomainDeviceInfoCallback cb, void *opaque); --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 09:19:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1558448791; cv=none; d=zoho.com; s=zohoarc; b=KS6eVi6vQBwNKudvUtCU16buIhLPHMqmzHUrGuOCNI9znRi9keoGpCuoreguBwko2MdqTJ1ziNsDTH/SF3foHmDwgztYswXk2XAy1JUIzI0mGSlTrzIG63f4Ars245qcH5kcyWTjjThlgoEMnKoYuzKqpQHI0kzXljthi3wACF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558448791; 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:ARC-Authentication-Results; bh=0sHZUWf9dJ79nhzLVkrqUZEe8jq4/PCKdwVS/IPUMIM=; b=FuOGSv/RC25Nsq2U4ROnHXsharEfHtI+AzaCLLdtM4vr7dJgQ/p/PV08WRceyAXalLEVsH7TTnG1Yy6WO2eFSG4IP7q8Oq/AhVPTfr9j43tUIjBvCbEa0NoxZuSjVfPyUPje3NGyB9g5Nw6CZ0DyNXVCE9V0zzJbbt077dBC1K4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558448791062875.5170970248349; Tue, 21 May 2019 07:26:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D79CE3007149; Tue, 21 May 2019 14:26:15 +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 A97B31017E36; Tue, 21 May 2019 14:26:11 +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 6278A5B428; Tue, 21 May 2019 14:26:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4LEQ7Cd011950 for ; Tue, 21 May 2019 10:26:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9334C66846; Tue, 21 May 2019 14:26:07 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BD4F66842 for ; Tue, 21 May 2019 14:26:06 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 21 May 2019 16:26:00 +0200 Message-Id: <0377e5660aa7310b0e63f1331f7b884588414260.1558448715.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] Introduce DOMAIN_DEVICE_ITERATE_MISSING_INFO 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 21 May 2019 14:26:29 +0000 (UTC) Rename the DOMAIN_DEVICE_ITERATE_GRAPHICS flag. It was introduced by commit dd45c2710f6fd2d4f8a47f97960532d0e0091e7d with the intention to run the Validate callback even on the graphics device. However, enumerating every single device in virDomainDeviceIterateFlags is unsustainable and what really was special about the graphics device was the lack of DeviceInfo. Rename the flag and iterate over more info-less devices. (and leases) Signed-off-by: J=C3=A1n Tomko Inspired-by: Andrea Bolognani --- src/conf/domain_conf.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fb1256f640..0fe440a2cf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4077,7 +4077,7 @@ virDomainSkipBackcompatConsole(virDomainDefPtr def, =20 enum { DOMAIN_DEVICE_ITERATE_ALL_CONSOLES =3D 1 << 0, - DOMAIN_DEVICE_ITERATE_GRAPHICS =3D 1 << 1 + DOMAIN_DEVICE_ITERATE_MISSING_INFO =3D 1 << 1, } virDomainDeviceIterateFlags; =20 /* @@ -4243,15 +4243,26 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr = def, return rc; } =20 - /* If the flag below is set, make sure @cb can handle @info being NULL= , as - * graphics don't have any boot info */ - if (iteratorFlags & DOMAIN_DEVICE_ITERATE_GRAPHICS) { + /* If the flag below is set, make sure @cb can handle @info being NULL= */ + if (iteratorFlags & DOMAIN_DEVICE_ITERATE_MISSING_INFO) { device.type =3D VIR_DOMAIN_DEVICE_GRAPHICS; for (i =3D 0; i < def->ngraphics; i++) { device.data.graphics =3D def->graphics[i]; if ((rc =3D cb(def, &device, NULL, opaque)) !=3D 0) return rc; } + device.type =3D VIR_DOMAIN_DEVICE_LEASE; + for (i =3D 0; i < def->nleases; i++) { + device.data.lease =3D def->leases[i]; + if ((rc =3D cb(def, &device, NULL, opaque)) !=3D 0) + return rc; + } + device.type =3D VIR_DOMAIN_DEVICE_IOMMU; + if (def->iommu) { + device.data.iommu =3D def->iommu; + if ((rc =3D cb(def, &device, NULL, opaque)) !=3D 0) + return rc; + } } =20 /* Coverity is not very happy with this - all dead_error_condition */ @@ -4305,7 +4316,7 @@ virDomainDeviceIterate(virDomainDefPtr def, return virDomainDeviceInfoIterateInternal(def, cb, DOMAIN_DEVICE_ITERATE_ALL_CO= NSOLES | - DOMAIN_DEVICE_ITERATE_GRAPHI= CS, + DOMAIN_DEVICE_ITERATE_MISSIN= G_INFO, opaque); } =20 --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list