From nobody Tue Mar 3 03:24:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1772099119; cv=none; d=zohomail.com; s=zohoarc; b=DLTmNvA2NmOaEUUvNkJKT+TmYpaFJPcXOY7WAV48XpED5CvpzaNDlxyoWNVNrl2kXkjeH0dAqNExgE4GoreNuCFaRCYXpia0Xx9iMzVwHqqGH3MvH73FeUaAheXGDFCMrJKsOOayo/ovBRQgvhWqu/XZ6DqDiUQebgfMWgmaQks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772099119; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id:Cc; bh=8Oehh7aKxyUD4sWyARxPGgjdvzX4hptHFvcHxCvqv04=; b=Jpv4kd4/cVf6x7fQx8keWIs3MH0vUVzXr2RY/iK5Gu8REt4Jm3rf50eSVgciNoVNSwOhFHqFiOlSltXPP0ONHt+hrdV8vi/7wTr2EuCqjnxFnC4BRbRT6geqQc2m5/3j90qrRFLcOAdrjJBpF55NUp2dVE2eeqaPI8LstKgKOsc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 177209911948731.036132021069307; Thu, 26 Feb 2026 01:45:19 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 71D8E4402E; Thu, 26 Feb 2026 04:45:18 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 093484404A; Thu, 26 Feb 2026 04:44:41 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 4F4FA43EBF; Thu, 26 Feb 2026 04:44:37 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id AD6D843E90 for ; Thu, 26 Feb 2026 04:44:35 -0500 (EST) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-mZhqv7hYONKwh36ranbLsw-1; Thu, 26 Feb 2026 04:44:33 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ED5761800266 for ; Thu, 26 Feb 2026 09:44:31 +0000 (UTC) Received: from antique-work.lan.rosnicka.net (unknown [10.44.34.87]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 326E819540CC for ; Thu, 26 Feb 2026 09:44:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772099075; h=from:from: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; bh=8Oehh7aKxyUD4sWyARxPGgjdvzX4hptHFvcHxCvqv04=; b=OMTBv7iag7JuFiaCMojVIClqXGsCJcASP9nSG1lY+3Zh+9k9c+CA4qoa0tqtsgV5MKJrOt 3BSerDPdA0zy+8xP1flENhenV2A1ibuClmqz4tQtopwZdnuES7ZQH4aukicWYOpOEBNa/z Z31E0RHIK4c08PCls0Kp5PWoHmbw+R8= X-MC-Unique: mZhqv7hYONKwh36ranbLsw-1 X-Mimecast-MFC-AGG-ID: mZhqv7hYONKwh36ranbLsw_1772099072 To: devel@lists.libvirt.org Subject: [libvirt PATCH for 12.1.0] domain_conf: initialize network hostdev private data Date: Thu, 26 Feb 2026 10:44:29 +0100 Message-ID: <151202ef28b801175aeb91b3b63abcf8e625e8e9.1772099023.git.phrdina@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: d1_gWb51QzmrtsH9mBeIBgZX8YAkbr7AjaZtDqqGrR0_1772099072 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YQHQGHVWTV3JPVI46SDBSUMAHHTBNTSG X-Message-ID-Hash: YQHQGHVWTV3JPVI46SDBSUMAHHTBNTSG X-MailFrom: phrdina@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pavel Hrdina via Devel Reply-To: Pavel Hrdina X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1772099121575158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Pavel Hrdina Currently virDomainNetDef and virDomainActualNetDef use virDomainHostdevDef directly as structure and the code doesn't call virDomainHostdevDefNew() that would initialize private data. This is hackish quick fix to solve a crash that happens in two scenarios: 1. attaching any interface with hostdev backend 0x0000fffbfc0e2a90 in qemuDomainAttachHostPCIDevice (driver=3D0xfffbb400675= 0, vm=3D0xfffbf001f790, hostdev=3D0xfffbf400b150) at ../src/qemu/qemu_hotpl= ug.c:1652 1652 if ((ret =3D qemuFDPassDirectTransferMonitor(hostdevPriv->vfioDeviceFd= , priv->mon)) < 0) 2. starting VM with interface with hostdev backend using iommufd 0x00007f6638d5b9ca in qemuProcessOpenVfioDeviceFd (hostdev=3Dhostdev@entry= =3D0x7f6634425ee0) at ../src/qemu/qemu_process.c:7719 7719 hostdevPriv->vfioDeviceFd =3D qemuFDPassDirectNew(name, &vfioDevic= eFd); Proper fix for this issue is to refactor network code to use pointer and to use virDomainHostdevDefNew(). Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3528b90742..8090becdcf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3517,6 +3517,20 @@ void virDomainVideoDefFree(virDomainVideoDef *def) } =20 =20 +static int +virDomainHostdevDefPrivateDataNew(virDomainHostdevDef *def, + virDomainXMLOption *xmlopt) +{ + if (!xmlopt || !xmlopt->privateData.hostdevNew) + return 0; + + if (!(def->privateData =3D xmlopt->privateData.hostdevNew())) + return -1; + + return 0; +} + + virDomainHostdevDef * virDomainHostdevDefNew(virDomainXMLOption *xmlopt) { @@ -3526,8 +3540,7 @@ virDomainHostdevDefNew(virDomainXMLOption *xmlopt) =20 def->info =3D g_new0(virDomainDeviceInfo, 1); =20 - if (xmlopt && xmlopt->privateData.hostdevNew && - !(def->privateData =3D xmlopt->privateData.hostdevNew())) { + if (virDomainHostdevDefPrivateDataNew(def, xmlopt) < 0) { VIR_FREE(def->info); VIR_FREE(def); return NULL; @@ -9739,6 +9752,9 @@ virDomainActualNetDefParseXML(xmlNodePtr node, virDomainHostdevDef *hostdev =3D &actual->data.hostdev.def; int type; =20 + if (virDomainHostdevDefPrivateDataNew(hostdev, xmlopt) < 0) + goto error; + hostdev->parentnet =3D parent; hostdev->info =3D &parent->info; /* The helper function expects type to already be found and @@ -10432,6 +10448,9 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *addrtype =3D virXPathString("string(./source/addr= ess/@type)", ctxt); int type; =20 + if (virDomainHostdevDefPrivateDataNew(&def->data.hostdev.def, xmlo= pt) < 0) + return NULL; + def->data.hostdev.def.parentnet =3D def; def->data.hostdev.def.info =3D &def->info; def->data.hostdev.def.mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; --=20 2.53.0