From nobody Sat Feb 7 13:04:49 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=1655126353; cv=none; d=zohomail.com; s=zohoarc; b=RLvijsjRaRYMuMx9RdK2In882wnzs6GspGGSAlit/faxSa4lRiCjmr4hrQXXFpQ1DlkP83u35hm67j2MY2T68VsNIr15HhIBrZy6gH18+w9XF80FAUwFPioGf9GIoH18PNb9tjRFWQ2G5kSElit+qG4T51gSIUp/1dNVI43xp3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655126353; 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=S6smBZ0HAP0G/KhRW7pW+avdkD6/mDlGWWpi6g6B7go=; b=VIgtyAQAj0AVQwd7NjqpDzzY28MhFhSHvuXBVXOqW+fjwE6w80Lm195ho/GQN+xMZ+sjspieR+YUSv/XtTuxBgwu4tBjsBbLm3SMxK10jrLTkXUHbUSLhZ10V6JQb9BSU0MWmoYVkZNva85wjkDdWWupAcQIUXssfGEtCOZFhmc= 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 165512635337250.69493163876757; Mon, 13 Jun 2022 06:19:13 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-392-UT1FKixHONeSdtv6bNkeAw-1; Mon, 13 Jun 2022 09:19:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8C383C23B6E; Mon, 13 Jun 2022 13:18:17 +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 A4A5340D2962; Mon, 13 Jun 2022 13:18:17 +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 958BB1947060; Mon, 13 Jun 2022 13:18:17 +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 2D453194705B for ; Mon, 13 Jun 2022 13:18:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0C7BB40CFD20; Mon, 13 Jun 2022 13:18:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id A778740CFD10 for ; Mon, 13 Jun 2022 13:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655126351; 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=S6smBZ0HAP0G/KhRW7pW+avdkD6/mDlGWWpi6g6B7go=; b=Lm/lCpOkB2NC8YyIaubxVOuXUxAi7Tzg9SuJGwz4SwYVSi199J0q679S5NxDZ35zWSfI0G 29HbmT+OIaAjGMCjAY+RFveCCsLs8dtxz+kFZVArapNdyWmyhCaswOruPDP2/RKz/9ezsP xKqVJXTLn9nwBQVdFt3rXih/PsQytpY= X-MC-Unique: UT1FKixHONeSdtv6bNkeAw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] virNetDevSaveNetConfig: Pass mode to virFileWriteStr() Date: Mon, 13 Jun 2022 15:18:13 +0200 Message-Id: <9b551b6af7b6eb6028f69f8fafef0557dc1ed694.1655126182.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 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 2.84 on 10.11.54.2 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: 1655126355770100001 Content-Type: text/plain; charset="utf-8"; x-default="true" For some types of SRIOV interfaces we create a temporary file where the state of the interface is saved before we start modifying it. The file is used then to restore the original configuration when the interface is no longer associated with any guest. For writing the file virFileWriteStr() is used. However, it's given wrong argument: the last argument is supposed to be mode to create the file with but virNetDevSaveNetConfig() passes open(2) flags (O_CREAT|O_TRUNC|O_WRONLY). We need the file to be writable and readable by root only (0600). Therefore, pass that mode instead of gibberish. Signed-off-by: Michal Privoznik Reviewed-by: Laine Stump Reviewed-by: Peter Krempa --- src/util/virnetdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 93f836cd92..6c6f6dee42 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1977,7 +1977,7 @@ virNetDevSaveNetConfig(const char *linkdev, int vf, if (!(fileStr =3D virJSONValueToString(configJSON, true))) return -1; =20 - if (virFileWriteStr(filePath, fileStr, O_CREAT|O_TRUNC|O_WRONLY) < 0) { + if (virFileWriteStr(filePath, fileStr, 0600) < 0) { virReportSystemError(errno, _("Unable to preserve mac/vlan tag " "for device =3D %s, vf =3D %d"), lin= kdev, vf); return -1; --=20 2.35.1 From nobody Sat Feb 7 13:04:49 2026 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=1655126350; cv=none; d=zohomail.com; s=zohoarc; b=QbAkqQA/n/vzTRSxP5lBU9OTQki2+okaiCbhRaCzv7WxILsETykuxGR9GSsScLollXvna2j4KS+VAXEVe49hvuRY5Wk/IBZ8iuwafLNXQjKvbaXgSG2LBRobetnqrXL/XqnuZoS6E8QL/GJeLOAAYyFbA3KaehiLLBhThzUCSPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655126350; 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=NtCfH3PmeJfSJJ9gBvTadJXuHF1idfalPJQ8dsPS8N0=; b=H3NONFXh06Q1z00F+PhWiRMcZ8Wh68qtb1b0yBuevzRX5oU7wW2+RtzoTYXjSV/76XChCXewbo+Od3SfYugHrZWSINkJF26NPOna/To4EtaHLI0BkdHbYB66dp0S2KisbaRgVH+73qjRkucY9hY0BGmF502MM3qkfO2tUzTDBdo= 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 165512635057281.95464774557615; Mon, 13 Jun 2022 06:19:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-497-5sYpZe5EPxKZYm-mi3ezwg-1; Mon, 13 Jun 2022 09:19:07 -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 631C91E7DCCE; Mon, 13 Jun 2022 13:18:18 +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 435E92166B2D; Mon, 13 Jun 2022 13:18:18 +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 EFBC7194706E; Mon, 13 Jun 2022 13:18:17 +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 B0C9A194705B for ; Mon, 13 Jun 2022 13:18:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A1CF840CF8EB; Mon, 13 Jun 2022 13:18:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AA7B40D0189 for ; Mon, 13 Jun 2022 13:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655126349; 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=NtCfH3PmeJfSJJ9gBvTadJXuHF1idfalPJQ8dsPS8N0=; b=hm4f3SOaPr1zV8WLTRV4PndhOAYBuRPMF8beQYWEo7IiutJqtSxMouRVKinC5xCNUjoTdU AYs6fLZqPz6yWjKWg/S9LwBr9ZXLa1hfHiOcvMww/ifwh3YKE5fmMGlnOk8Iv8o2y8sDvw uV7920uLbweqAsxe/BvVDilpCJ9Xjho= X-MC-Unique: 5sYpZe5EPxKZYm-mi3ezwg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] qemuBuildInterfaceConnect: Initialize @tapfd array Date: Mon, 13 Jun 2022 15:18:14 +0200 Message-Id: <86dcc52a58e3a4c42868c2f5e4eca14c919b2214.1655126182.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 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 2.78 on 10.11.54.6 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: 1655126351723100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When creating a TAP interface we can end up with multiple FDs, each representing one queue. However, these FDs must be relabelled as they are then passed to QEMU. In case of qemuBuildInterfaceConnect() we allocate the array for the FDs and then let function corresponding to the type to fill the array with FDs. When any of the functions meets an error, it's also responsible for closing previously opened FDs. However, the functions take a shortcut: iterate through each member of the array and close it (if it's non-negative). This assumes that the array is initialized to negative values, which use to be the case before rewrite in v8.4.0-rc1~170 but after it it's no longer the case. Subsequently, "random" FDs are closed (okay, not that random since the array is allocated via g_new0(), but hey - FD 0 is still valid FD and might be valuable, actually). Fixes: 7a38d3946bc1a7ef0206f36dfe3dbf422fb8d578 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_command.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index be20053c0d..ecfe6020f3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8736,6 +8736,8 @@ qemuBuildInterfaceConnect(virDomainObj *vm, size_t tapfdSize =3D net->driver.virtio.queues; g_autofree int *tapfd =3D g_new0(int, tapfdSize + 1); =20 + memset(tapfd, -1, (tapfdSize + 1) * sizeof(*tapfd)); + if (tapfdSize =3D=3D 0) tapfdSize =3D 1; =20 --=20 2.35.1