From nobody Mon Feb 9 03:47:51 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=1654264463; cv=none; d=zohomail.com; s=zohoarc; b=e/dAFfEplSEG5ajSee5XDRFeixSjrqzOj5bChf6iaVMZ0erNvN/qleNYNEQKmhBxzWfAo96mhA/VP84EpjbTwYM1DWcp2qNvozSfnupoTTrTiiGdzhNkGt8/Ar0xWtBbG6LCx6r8sIzmoN7RLYaCKGKVaZU8932JYf2lBvdHiFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654264463; 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=7bdnMcNamMuIrqoTj0gy9BYqiXKDDjdsrdysbYtYtEU=; b=hlCGtGQH0R3LlRi8CHaKx92SfBr4CNUKICR/SocmVmHq1m/M4n+cG/YbITpElDMjRrskp7jLfg3g+TB2mms6B7zO4oIN7VZSpmBfVlJqOJu6SR2319UeSusD3F0Ishf59GfpBPAo4sY54O/oxJGbD9H86DhWL54nILLw0WNWJoM= 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 1654264463623421.45912859732414; Fri, 3 Jun 2022 06:54:23 -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-590-QZs2w7knPVWNC1QJZp6Yeg-1; Fri, 03 Jun 2022 09:54:19 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4432833975; Fri, 3 Jun 2022 13:54: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 171DD492C3B; Fri, 3 Jun 2022 13:54:16 +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 CC2381947052; Fri, 3 Jun 2022 13:54:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 63705194704D for ; Fri, 3 Jun 2022 13:54:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 300D1C2810E; Fri, 3 Jun 2022 13:54:14 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4CD3C28101 for ; Fri, 3 Jun 2022 13:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654264462; 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=7bdnMcNamMuIrqoTj0gy9BYqiXKDDjdsrdysbYtYtEU=; b=IMKlAO6idZLUB5IEJWzV/UiE9uLDCsu0tNQUiBeC6HLNYbrkSL+bNYBl993ZAKQojwfqaA Zbe+/TbTtZK1szAHHghEw7j5PMjcnc5A4yG+Ax+klk3JU2ChJyRbJmnTQAsqkpSIffwk+s vNf2avJ6xfQ8EVPwlQqN4PtyjxFWpIk= X-MC-Unique: QZs2w7knPVWNC1QJZp6Yeg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] qemu: fd: Fix monitor usage of qemuFDPassDirectGetPath Date: Fri, 3 Jun 2022 15:54:12 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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.85 on 10.11.54.9 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: 1654264465634100001 Content-Type: text/plain; charset="utf-8" We need to use the 'name' variable and just overwrite it with the FD number when FDs are passed on the monitor. Otherwise we will read NULL path if the FD is accessed before being passed on the monitor. The idea of this helper is to simplify the monitor code so it would be counterproductive to have other behaviour. Fixes the following symptom: $ virsh attach-interface cd network default --model virtio error: Failed to attach interface error: internal error: unable to execute QEMU command 'netdev_add': File d= escriptor named '(null)' has not been found Fixes: bca9047906fd73fd30f275dd45b64998fbbcf6de Resolves: https://gitlab.com/libvirt/libvirt/-/issues/318 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2092856 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_fd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c index 6311161657..51a8133fde 100644 --- a/src/qemu/qemu_fd.c +++ b/src/qemu/qemu_fd.c @@ -235,7 +235,6 @@ qemuFDPassGetPath(qemuFDPass *fdpass) struct _qemuFDPassDirect { int fd; - char *path; char *name; bool passed; /* passed to qemu via monitor */ @@ -251,7 +250,6 @@ qemuFDPassDirectFree(qemuFDPassDirect *fdpass) VIR_FORCE_CLOSE(fdpass->fd); g_free(fdpass->name); - g_free(fdpass->path); g_free(fdpass); } @@ -295,7 +293,8 @@ qemuFDPassDirectTransferCommand(qemuFDPassDirect *fdpas= s, return; virCommandPassFD(cmd, fdpass->fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); - fdpass->path =3D g_strdup_printf("%d", fdpass->fd); + g_free(fdpass->name); + fdpass->name =3D g_strdup_printf("%d", fdpass->fd); fdpass->fd =3D -1; } @@ -318,7 +317,6 @@ qemuFDPassDirectTransferMonitor(qemuFDPassDirect *fdpas= s, if (qemuMonitorSendFileHandle(mon, fdpass->name, fdpass->fd) < 0) return -1; - fdpass->path =3D g_strdup(fdpass->name); VIR_FORCE_CLOSE(fdpass->fd); fdpass->passed =3D true; @@ -358,5 +356,5 @@ qemuFDPassDirectGetPath(qemuFDPassDirect *fdpass) if (!fdpass) return NULL; - return fdpass->path; + return fdpass->name; } --=20 2.35.3