From nobody Tue Apr 16 22:26:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1593071362; cv=none; d=zohomail.com; s=zohoarc; b=Gf8HpTbFs0toFA5E0LidIAmAmiZaE6MIHG8j6sPQfuf0W1eKbXbuAcJFNuXX9PArmvX7qsxfO2IaqrH+0yx9b0ZzGE/CTEivEZUWZX/n9jQiZZvvRxIyEQbYawYhevbfxfOStWH0SeafdIPwQ1NTBGuGYHgFuePYAwa/Ee2l6UM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593071362; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lwvt3LDJVOMIV5ZScJLwpVJR9Hq2UUp+uu6BoBSqSko=; b=O0ntZP4oduLcP6OatPqhOOFZ9AWVtGQfaUPjEN+BD3AGX4sRKQUFPrYeWFcnRnfaB1kN6QFnktE8odK4mAGB/SPYppLaBjjt6vldqGKdD2KFHW9kKMLVjuRFV0pL1Yln1ugVEnnU3NNu04vWs7wofoiOdk0WMC9Qmo3AQHIlB5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1593071362830684.4663512776938; Thu, 25 Jun 2020 00:49:22 -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-53-u7dFld3NOv2izZdRrKgFmA-1; Thu, 25 Jun 2020 03:49:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C375F800C60; Thu, 25 Jun 2020 07:49:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 870945D9C5; Thu, 25 Jun 2020 07:49: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 0614D1809547; Thu, 25 Jun 2020 07:49:06 +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 05P7n5iA030883 for ; Thu, 25 Jun 2020 03:49:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id E01248FF97; Thu, 25 Jun 2020 07:49:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56E13A09BF for ; Thu, 25 Jun 2020 07:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593071361; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lwvt3LDJVOMIV5ZScJLwpVJR9Hq2UUp+uu6BoBSqSko=; b=KVwXA4nHAelU4ypbVnZT0A8ugkCKTXWXmT+kA9YHi8kX9dw6+frrnPFtD7WFV5M40cPJKt D5deAjTfI3gljUxEJVigBMjHWn0ZfVFgnTIJNFGj9muKCVHB0SUzBcJwoxn8aetjdmM8RG p9oeBOCBS/YPHQszUbCZn2kJ1KAqQCI= X-MC-Unique: u7dFld3NOv2izZdRrKgFmA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemuDomainDeviceNetDefPostParse: Switch order of conditions Date: Thu, 25 Jun 2020 09:48:56 +0200 Message-Id: <1a935749004bcf3dd3eab3671ee13057eda82996.1593071091.git.mprivozn@redhat.com> 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.14 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" A few commits back (in v6.4.0-131-gbdb8f2e418) the post parse function for domain interface was changed so that it doesn't fill in model for hostdev types of interfaces (including network type interfaces which would end up hostdevs). While the idea is sound, the execution can be a bit better: virDomainNetResolveActualType() which is used to determine runtime type of given interface is heavy gun - it connects to network driver, fetches network XML, parses it. This all is followed by check whether the interface doesn't already have model set (from domain XML). If we switch the order of these two checks then the short circuit evaluation will ensure the expensive check is done only if really needed. This commit in fact fixes qemuxml2xmltest which due to lacking fake network driver tries to connect to network:///session and start the virtnetworkd. Fortunately, because of v6.3.0-25-gf28fbb05d3 it fails to do so and virDomainNetResolveActualType() returns -1. The only reason we don't see the test failing is because our input XMLs have model and thus we are saved by the latter (now former) check. Signed-off-by: Michal Privoznik Reviewed-by: Laine Stump --- While this patch is technically correct (the best way to be correct), it can also be viewed as papering over the real issue. Question is, how to address that. Nor xml2xml test nor xml2argv test are creating fake network driver. Is mocking virDomainNetResolveActualType() the way to go then? Or should we create the fake network driver with networks and everything? src/qemu/qemu_domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2efbf1a4b3..c5b8d91f9a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5230,8 +5230,8 @@ qemuDomainDeviceNetDefPostParse(virDomainNetDefPtr ne= t, virQEMUCapsPtr qemuCaps) { if (net->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && - virDomainNetResolveActualType(net) !=3D VIR_DOMAIN_NET_TYPE_HOSTDE= V && - !virDomainNetGetModelString(net)) + !virDomainNetGetModelString(net) && + virDomainNetResolveActualType(net) !=3D VIR_DOMAIN_NET_TYPE_HOSTDE= V) net->model =3D qemuDomainDefaultNetModel(def, qemuCaps); =20 return 0; --=20 2.26.2