From nobody Fri May 3 06:48:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1685626016; cv=none; d=zohomail.com; s=zohoarc; b=jwrps6AnkYBuh8P08gJN+aQPYqXOZPHTwAYoWHzEjOkHEemY120PUzPW9VtBT2nbixJCxqyOoVtPCBTrF8XXRhM0vNlzpBEemmxbspZ0LXjhFEksmyxmKChRI8U+037fbNv8hrUjwKbt2jMoOMEMlcTNytgHWyXKpnvoMR5TV70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685626016; 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=Q0ykdVHaP6ABUiAbbDf2VMhWfKpwuQM/Zq3wyhGulqQ=; b=CVj0FscSKV1ZnMS2eXnGsTddk1aLaocA81yeCPxNGGYldDxNNmS9Ai4z1kFyxZ4eo7VyK7hRDCtx+sSWzrnFc8Zd/RKfMeiqYcb3CHuY5+6q95WKkqfLXUuQxWlIQcTU9be7c7Rsz0bgofEWOC9K4AUdI7l9pl/fQ8xdfghb1nM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1685626016807440.427895130514; Thu, 1 Jun 2023 06:26:56 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-Ml8Nuq2ZNoya8AIxGRMUKQ-1; Thu, 01 Jun 2023 09:26:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E806E85A5BE; Thu, 1 Jun 2023 13:26:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC10B2166B27; Thu, 1 Jun 2023 13:26:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5DA501946595; Thu, 1 Jun 2023 13:26:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B0E84194658C for ; Thu, 1 Jun 2023 13:26:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 85C9E4097564; Thu, 1 Jun 2023 13:26:46 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7704E4097563 for ; Thu, 1 Jun 2023 13:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685626015; 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=Q0ykdVHaP6ABUiAbbDf2VMhWfKpwuQM/Zq3wyhGulqQ=; b=cxt7EeeKVyu4NYKQZ2w6K1AtAhlXE99GQpNCXOIuANQffMNwe5vSe8+L7mqu56LjCUOO/o yWK92peWwQVkH+w8oYcXn65AvcJrEt1JnCZkaMuyycb/cTMTQAselvoWwuPlFTj2nLfsGN 9JSKqhJXzbf95a0nBSjInm4iz+GXQfQ= X-MC-Unique: Ml8Nuq2ZNoya8AIxGRMUKQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu: Set proper PCI backend for -s that are actually hostdevs Date: Thu, 1 Jun 2023 15:26:40 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685626017964100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When starting a domain, it's done so in two steps (actually more, but lets focus on just the following two): 1) qemuProcessPrepareDomain(), followed by 2) qemuProcessPrepareHost(). Now, in the first step (PrepareDomain()), PCI backends for all hostdevs is set (qemuProcessPrepareDomain() -> qemuProcessPrepareDomainHostdevs() -> qemuDomainPrepareHostdev() -> qemuDomainPrepareHostdevPCI()). Perfect. But then, additional hostdevs may appear, because in the host prepare phase we may insert some hostdevs into domain definition (qemuProcessPrepareHost() -> qemuProcessNetworkPrepareDevices()). Now, these additional hostdevs don't undergo the same prepare as hostdevs that were already present in the domain definition (i.e. in qemuProcessPrepareDomain() phase). Therefore, we have to call corresponding prepare function explicitly. NB, the interface hotplug code (qemuDomainAttachNetDevice()) does not suffer from this problem, because it calls top level qemuDomainAttachHostDevice() which is used to hotplug regular hostdevs too and as such calls qemuDomainPrepareHostdev(). Fixes: 3b87709c768480e085556e06bd8d08f62270d42d Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2209853 Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/qemu/qemu_process.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 730e59eb7e..1431fa8310 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5834,6 +5834,13 @@ qemuProcessNetworkPrepareDevices(virQEMUDriver *driv= er, net->data.network.name, def->name); return -1; } + + /* For hostdev present in qemuProcessPrepareDomain() phase thi= s was + * done already, but this code runs after that, so we have to = call + * it ourselves. */ + if (qemuDomainPrepareHostdevPCI(hostdev, priv) < 0) + return -1; + if (virDomainHostdevInsert(def, hostdev) < 0) return -1; } else if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_USER && --=20 2.39.3