From nobody Tue Mar 3 04:55:51 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=1772183159; cv=none; d=zohomail.com; s=zohoarc; b=CQ9T7wM06gEqDnrgGvqfqvHTHhVStvrf6/uZePHo286BTKpjg/m7fwhvBGFXYfuz7VeYbQPAdWVbGJ7ClfaQfD6F7ozPPmbFgNoJZVuoKTjsLLvrJBG7mGovvAzAVL2telD6O53n6bjGXDi8Z2ruOSzON/hiVwRW/eyMT/qiEzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772183159; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=rL12Ok5bYeYMePRYrkg96cC9GzTx4QbyVhgNC3ypJGA=; b=c90ky3LuxCDv1JNA4G/MluZ1c/XnMcheuaCCQSAiacgaJix+tj23Q7zgnlf+vuh+COoR3AbnGrXvaAy4df2wTV4LkAJQa8yPy1j17UegKRiBJnndNqsWJiLJyUQf55wNj2sphhuQIyPHc1P017PIqOAbrvlrcLV1CkRAHOXuDdE= 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 1772183159465898.3754310835833; Fri, 27 Feb 2026 01:05:59 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id ADB8041D42; Fri, 27 Feb 2026 04:05:58 -0500 (EST) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id CB24442412; Fri, 27 Feb 2026 04:03:23 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id D46BB41D8D; Fri, 27 Feb 2026 04:03:19 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 C1A8941D19 for ; Fri, 27 Feb 2026 04:03:10 -0500 (EST) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-68-KFqw9Md_MeeGkra6UfG0-Q-1; Fri, 27 Feb 2026 04:03:07 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 962721956059 for ; Fri, 27 Feb 2026 09:03:06 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 054C619560B5 for ; Fri, 27 Feb 2026 09:03:05 +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=0.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772182990; 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: in-reply-to:in-reply-to:references:references; bh=rL12Ok5bYeYMePRYrkg96cC9GzTx4QbyVhgNC3ypJGA=; b=IDUYViLLoz94A+4UaFi2FXTZotxs8iwGz5+hyDaQJgqzsAgJgUkna9PSJXbGZyy7Iiuy2C SACGvcWaWUvyMPs11R0pLdjFSyxSaDiyNchc0SdHUjdfZWhLvxSh4YeVXj4QOvqQgSjHTY yyMI6SGs+uGRv0F0TEkGepB7rPEtP+8= X-MC-Unique: KFqw9Md_MeeGkra6UfG0-Q-1 X-Mimecast-MFC-AGG-ID: KFqw9Md_MeeGkra6UfG0-Q_1772182986 To: devel@lists.libvirt.org Subject: [PATCH 2/4] virpcimock: Create net/ subdir for devices Date: Fri, 27 Feb 2026 10:02:57 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: oPvfmNlpabI3BSyewG1NVLRgLlAaSauTncQw3JFXQdg_1772182986 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5I5K6HXT6QCZOLDOC7UQH6XNQCIGSNK5 X-Message-ID-Hash: 5I5K6HXT6QCZOLDOC7UQH6XNQCIGSNK5 X-MailFrom: mprivozn@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: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1772183160559158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik A PCI device that is a network interface card also has 'net/' subdir with interface name it corresponds to. For instance: # ls -l /sys/bus/pci/devices/0000\:00\:1f.6/net/ total 0 drwxr-xr-x 5 root root 0 Feb 26 16:51 eth0 Allow setting interface name for PCI devices. Now, in real life the net/$IFNAME/ is a directory, but since our code opens net/ dir and then just reads dentries creating file instead of full blown dir is okay. Signed-off-by: Michal Privoznik --- tests/virpcimock.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index c59359b889..22d2354ebe 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -144,6 +144,7 @@ struct pciDevice { int sriovTotalvfs; unsigned int virtfnCount; const char *physfn; + const char *netName; struct pciDriver *driver; /* Driver attached. NULL if attached to no= driver */ struct pciVPD vpd; }; @@ -590,6 +591,18 @@ pci_device_new_from_stub(const struct pciDevice *data) register_vf(dev); } =20 + if (dev->netName) { + if (g_snprintf(tmp, sizeof(tmp), "%s/net", devpath) < 0) { + ABORT("@tmp overflow"); + } + + if (g_mkdir_with_parents(tmp, 0777) < 0) + ABORT("Unable to create: %s", tmp); + + /* In real sysfs this is a dir, but for test purposes a file is ok= ay. */ + make_file(tmp, dev->netName, dev->netName, -1); + } + if (dev->vpd.data && dev->vpd.vpd_len) make_file(devpath, "vpd", dev->vpd.data, dev->vpd.vpd_len); =20 @@ -1072,8 +1085,10 @@ init_env(void) pci_device_new_from_stub(&dev); \ } while (0) =20 - MAKE_PCI_DEVICE("0000:00:00.0", 0x8086, 0x0044, 0); - MAKE_PCI_DEVICE("0000:00:01.0", 0x8086, 0x0044, 1); + MAKE_PCI_DEVICE("0000:00:00.0", 0x8086, 0x0044, 0, + .netName =3D "wlan0"); + MAKE_PCI_DEVICE("0000:00:01.0", 0x8086, 0x0044, 1, + .netName =3D "wlan1"); MAKE_PCI_DEVICE("0000:00:02.0", 0x8086, 0x0046, 2); MAKE_PCI_DEVICE("0000:00:03.0", 0x8086, 0x0048, 3); MAKE_PCI_DEVICE("0001:00:00.0", 0x1014, 0x03b9, 4, .klass =3D 0x060400= ); @@ -1088,15 +1103,18 @@ init_env(void) MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048, 8); MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048, 8); MAKE_PCI_DEVICE("0000:06:12.0", 0x8086, 0x0047, 9, - .sriovTotalvfs =3D 7); + .sriovTotalvfs =3D 7, .netName =3D "enp1s0f0"); MAKE_PCI_DEVICE("0000:06:12.1", 0x8086, 0x0047, 10, - .physfn =3D "0000:06:12.0"); /* Virtual Function */ + .physfn =3D "0000:06:12.0", /* Virtual Function */ + .netName =3D "enp1s0f1"); MAKE_PCI_DEVICE("0000:06:12.2", 0x8086, 0x0047, 11, - .physfn =3D "0000:06:12.0"); /* Virtual Function */ + .physfn =3D "0000:06:12.0", /* Virtual Function */ + .netName =3D "enp1s0f2"); MAKE_PCI_DEVICE("0021:de:1f.0", 0x8086, 0x0047, 12, - .sriovTotalvfs =3D 7); + .sriovTotalvfs =3D 7, .netName =3D "enp2s0f0"); MAKE_PCI_DEVICE("0021:de:1f.1", 0x8086, 0x0047, 13, - .physfn =3D "0021:de:1f.0"); /* Virtual Function */ + .physfn =3D "0021:de:1f.0", /* Virtual Function */ + .netName =3D "enp2s0f1"); =20 MAKE_PCI_DEVICE("0000:01:00.0", 0x1cc1, 0x8201, 14, .klass =3D 0x01080= 2); MAKE_PCI_DEVICE("0000:02:00.0", 0x1cc1, 0x8201, 15, .klass =3D 0x01080= 2); --=20 2.52.0