From nobody Mon Feb 9 01:01:37 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=1633622718; cv=none; d=zohomail.com; s=zohoarc; b=YQtRZvGIO0DD6UOZa2cVypyafw8hrFCx9RjKq3Cs2QFjKqqNySsOBGN9kXY4dsyLNHFx9owGWHGZPFZFrAt1pWYEQFx3A5ol3ksJtLOGWkjz9OLHD2sJjxY9ouh4WrWhDHnD0Qg9VZtZ2TPHeaIomtYiXuAcsPQPEPkhp4InwDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633622718; 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=zL6UrDCgOlw5SWC8SciWuUmYvF3m/b2iHPf2uT4dlv8=; b=gPEInOU5SLr+sgASla+Iw+isYmcTp6lwYKmxX2TlMyaqUygut/MIWYq8+xoImrQ+s7J3JKXfA9iUdnijf/xTM84iLtbhnmhGRtFp0Ql4kD3aeDPbMQJFglE3LBKTO/ZpBd4/L8d6NtCrST+nTe8kaBpGeh5FtNUKBQVL+TqL+Vw= 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 163362271815672.21278287716893; Thu, 7 Oct 2021 09:05:18 -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-376-5XGP2D7MOFmtkNiI2SFD1Q-1; Thu, 07 Oct 2021 12:05:15 -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 AA213C67811; Thu, 7 Oct 2021 15:46: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 485701B6F20; Thu, 7 Oct 2021 15:46: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 0B9684EA30; Thu, 7 Oct 2021 15:46:29 +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 197FJRud023982 for ; Thu, 7 Oct 2021 11:19:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 486B35F4E7; Thu, 7 Oct 2021 15:19:27 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2D245D740 for ; Thu, 7 Oct 2021 15:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633622717; 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=zL6UrDCgOlw5SWC8SciWuUmYvF3m/b2iHPf2uT4dlv8=; b=GpHyHwGqhRbly5QpOaGWvuA/3qK+gI3QfJrnDhh7ygCHcdVlwDbwsRZg+cVzV5pVIedo43 YyKIEa6yT8B6CAqYwjxV10U4hy7/5uNU+kJkR4XLuRhcXrFIVpU+T5UyDEqmvGU7eLnP3M hgtzIbvRl99u438vYF/yBWEMYWsjCf8= X-MC-Unique: 5XGP2D7MOFmtkNiI2SFD1Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 047/103] qemu: Use 'effectiveBootIndex' to handle Date: Thu, 7 Oct 2021 17:17:35 +0200 Message-Id: <953ec2b836d68d22ed1564dd40266ac0ba647b6b.1633619630.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.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) X-ZM-MESSAGEID: 1633622719380100003 Content-Type: text/plain; charset="utf-8" Fill in the effective boot index for network devices (or hostdev-backed network devices via 'qemuProcessPrepareDeviceBootorder'. This patch doesn't clean up the cruft to make it more obvious what's happening. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 14 ++++++-------- src/qemu/qemu_process.c | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 07a8f104f4..bb91098c76 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3699,7 +3699,7 @@ qemuBuildLegacyNicStr(virDomainNetDef *net) char * qemuBuildNicDevStr(virDomainDef *def, virDomainNetDef *net, - unsigned int bootindex, + unsigned int bootindex G_GNUC_UNUSED, size_t vhostfdSize, virQEMUCaps *qemuCaps) { @@ -3834,8 +3834,8 @@ qemuBuildNicDevStr(virDomainDef *def, return NULL; if (qemuBuildRomStr(&buf, &net->info) < 0) return NULL; - if (bootindex) - virBufferAsprintf(&buf, ",bootindex=3D%u", bootindex); + if (net->info.effectiveBootIndex > 0) + virBufferAsprintf(&buf, ",bootindex=3D%u", net->info.effectiveBoot= Index); return virBufferContentAndReset(&buf); } @@ -4621,7 +4621,7 @@ qemuBuildVideoCommandLine(virCommand *cmd, char * qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDef *dev, - unsigned int bootIndex, /* used iff dev->info->b= ootIndex =3D=3D 0 */ + unsigned int bootIndex G_GNUC_UNUSED, virQEMUCaps *qemuCaps G_GNUC_UNUSED) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; @@ -4653,10 +4653,8 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def, pcisrc->addr.slot, pcisrc->addr.function); virBufferAsprintf(&buf, ",id=3D%s", dev->info->alias); - if (dev->info->bootIndex) - bootIndex =3D dev->info->bootIndex; - if (bootIndex) - virBufferAsprintf(&buf, ",bootindex=3D%u", bootIndex); + if (dev->info->effectiveBootIndex > 0) + virBufferAsprintf(&buf, ",bootindex=3D%u", dev->info->effectiveBoo= tIndex); if (qemuBuildDeviceAddressStr(&buf, def, dev->info) < 0) return NULL; if (qemuBuildRomStr(&buf, dev->info) < 0) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 58fbb38c5e..c3e994b1a2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6270,6 +6270,7 @@ qemuProcessPrepareDeviceBootorder(virDomainDef *def) unsigned int bootCD =3D 0; unsigned int bootFloppy =3D 0; unsigned int bootDisk =3D 0; + unsigned int bootNetwork =3D 0; if (def->os.nBootDevs =3D=3D 0) return; @@ -6289,7 +6290,9 @@ qemuProcessPrepareDeviceBootorder(virDomainDef *def) break; case VIR_DOMAIN_BOOT_NET: - /* network boot is handled in network device formatting code */ + bootNetwork =3D i + 1; + break; + case VIR_DOMAIN_BOOT_LAST: default: break; @@ -6321,6 +6324,28 @@ qemuProcessPrepareDeviceBootorder(virDomainDef *def) break; } } + + if (def->nnets > 0 && bootNetwork > 0) { + /* If network boot is enabled, the first network device gets enabl= ed. If + * that one is backed by a host device, then we need to find the f= irst + * corresponding host device */ + if (virDomainNetGetActualType(def->nets[0]) =3D=3D VIR_DOMAIN_NET_= TYPE_HOSTDEV) { + for (i =3D 0; i < def->nhostdevs; i++) { + virDomainHostdevDef *hostdev =3D def->hostdevs[i]; + virDomainHostdevSubsys *subsys =3D &hostdev->source.subsys; + + if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + subsys->type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI= && + hostdev->info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYP= E_UNASSIGNED && + hostdev->parentnet) { + hostdev->info->effectiveBootIndex =3D bootNetwork; + break; + } + } + } else { + def->nets[0]->info.effectiveBootIndex =3D bootNetwork; + } + } } --=20 2.31.1