From nobody Tue May 14 06:04:04 2024 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=1647964948; cv=none; d=zohomail.com; s=zohoarc; b=XgEEIdOup7aH4bJDP9ljnx0ux2I9hux5uYF7ErfJKOSKUCZgdmpMREVQQXZGRbD3bZ42DxW7PoPIEIWmoiAtXu4m0g+H0SI/e1cH7A/ZeCjA0DCRXfrb/A0DfkjAQkJ64Z9LlU5E19wfEiSm4LKcvpYf+EXaS1EKPUj5VFi8V8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647964948; 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=/PRXQMdL0ICVLzJrMPtHIpHTpIGb3D+yaxSNSezJtZE=; b=lAlxGf7fgxbzoiqhD+L2VjmBdA/5xcRYAzzxQ6fBVZSe+6+bPgoHpDPUPEsw2kKM7OYUJGj5uqRlj3Dd+GZbPjF//Fhf0ezC6gOrAozjuzrfEe96IyOm0DHk+TYUh7XRUhlPYBqKlQZyQM2QtBg3XKj3AT9bqw/dgwyNbKkChy4= 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 1647964948160640.5242256221014; Tue, 22 Mar 2022 09:02:28 -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-622-XJjoNz8FOViXil-ahk8tIg-1; Tue, 22 Mar 2022 12:02:24 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDC1483396D; Tue, 22 Mar 2022 16:02:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4B4C401E86; Tue, 22 Mar 2022 16:02:15 +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 B7B571940357; Tue, 22 Mar 2022 16:02:12 +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 199EB1947BBC for ; Tue, 22 Mar 2022 16:02:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E81CEC23DC6; Tue, 22 Mar 2022 16:02:11 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DD72C23DC3 for ; Tue, 22 Mar 2022 16:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647964946; 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=/PRXQMdL0ICVLzJrMPtHIpHTpIGb3D+yaxSNSezJtZE=; b=QNL6Se4JX922C8LLfTAgj2iA0gG+DdSU3zP4PPBXH7GkW9uzzUZIUDSsEqlYr/VRmgdocy obS0qqmBmb5xJAosHiKlzJWtrD7DTICMezn7AlmW8XHz7kUdabr3zbStgVcwXSfHFX1sLF lm/Wa2pZhgnCUOlh3bs6ZDIhoDvhbRE= X-MC-Unique: XJjoNz8FOViXil-ahk8tIg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/7] qemu_tpm: Do async IO when starting swtpm emulator Date: Tue, 22 Mar 2022 17:02:00 +0100 Message-Id: In-Reply-To: References: 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.10 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1647965853798100001 When vTPM is secured via virSecret libvirt passes the secret value via an FD when swtpm is started (arguments --key and --migration-key). The writing of the secret into the FDs is handled via virCommand, specifically qemu_tpm calls virCommandSetSendBuffer()) and then virCommandRunAsync() spawns a thread to handle writing into the FD via virCommandDoAsyncIOHelper. But the thread is not created unless VIR_EXEC_ASYNC_IO flag is set, which it isn't. In order to fix it, virCommandDoAsyncIO() must be called. The credit goes to Marc-Andr=C3=A9 Lureau who has done all the debugging and proposed fix in the bugzilla. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2064115 Fixes: a9c500d2b50c5c041a1bb6ae9724402cf1cec8fe Signed-off-by: Michal Privoznik --- src/qemu/qemu_tpm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 50f9caabf3..56bccee128 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -899,6 +899,7 @@ qemuTPMEmulatorStart(virQEMUDriver *driver, if (!(pidfile =3D qemuTPMEmulatorPidFileBuildPath(cfg->swtpmStateDir, = shortName))) return -1; =20 + virCommandDoAsyncIO(cmd); virCommandDaemonize(cmd); virCommandSetPidFile(cmd, pidfile); virCommandSetErrorFD(cmd, &errfd); --=20 2.34.1 From nobody Tue May 14 06:04:04 2024 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=1647964982; cv=none; d=zohomail.com; s=zohoarc; b=hLUCBqtySt/T4RiWZ0x+p6zU1V/OuzCMxJeirBEfFudnnyNJYEjZn7+s8p8jMxnjdN7VI7jDxXh75WB/uNRASztc+ylDsnF9ZHAoN3yBmMqp4c2Zd2ULo8G/3RNxpCybj2V41QfilSZ5xw4uF4GtXXn+rLnbnrNKW6+yrAmmAnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647964982; 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=e66alCK6FBCCSZR1llz/wbEX2ce6YXN4Azco4WI4J0Y=; b=NSIQGCFwcS5RUAidA/qLWtM8zBX/nj7HxROcFH7TlGHyu41euvQokX97bUoATGHXZ4g5K8WABIaei9smGGyHBSNrhe0dj/QB3hUhauzWxIAlKreO5bEXA1/4fYn8QJuMxoIhZjP40MgmMjCi/eXxM4X7B6g4YF88fhu2DvVXmyI= 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 1647964982966406.2082350110428; Tue, 22 Mar 2022 09:03:02 -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-201-0gZYUxxFNfaTTRks2HVnvA-1; Tue, 22 Mar 2022 12:02:23 -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 5A0E08556F8; Tue, 22 Mar 2022 16:02:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 868B340E8116; Tue, 22 Mar 2022 16:02: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 EC6161940366; Tue, 22 Mar 2022 16:02:13 +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 9B5BF1940352 for ; Tue, 22 Mar 2022 16:02:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8770DC23DC3; Tue, 22 Mar 2022 16:02:12 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E4E1C07F5B for ; Tue, 22 Mar 2022 16:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647964981; 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=e66alCK6FBCCSZR1llz/wbEX2ce6YXN4Azco4WI4J0Y=; b=cTFQIrD3ozzSG1kI7YJQf5TT1firLgeEq1Tk9NxI2brkZhhisNg1sinigFMixVpGElK8q7 4laC4EBY/0UY24gPOIpLtSN75ZvBbkHNhMK3kX6wgLNdAEe4BUdfT9NE7OS8UaQhDFp7QO py9cxKaKzBHuLh3TT+zOyMJY4WqY6Tc= X-MC-Unique: 0gZYUxxFNfaTTRks2HVnvA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/7] vircommand: Document virCommandSetSendBuffer() behaviour wrt daemonize Date: Tue, 22 Mar 2022 17:02:01 +0100 Message-Id: In-Reply-To: References: 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.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: 1647964983846100001 Content-Type: text/plain; charset="utf-8" When virCommandSetSendBuffer() is used over a virCommand that is (or will be) daemonized, then VIR_EXEC_ASYNC_IO the command must have VIR_EXEC_ASYNC_IO flag set no later than at virCommandRunAsync() phase so that the thread that's doing IO is spawned and thus buffers can be sent to the process. Signed-off-by: Michal Privoznik --- src/util/vircommand.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 41cf552d7b..5f22bd0ac3 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1719,6 +1719,9 @@ virCommandFreeSendBuffers(virCommand *cmd) * @buffer is always stolen regardless of the return value. This function * doesn't raise a libvirt error, but rather propagates the error via virC= ommand. * Thus callers don't need to take a special action if -1 is returned. + * + * When the @cmd is daemonized via virCommandDaemonize() remember to reque= st + * asynchronous IO via virCommandDoAsyncIO(). */ int virCommandSetSendBuffer(virCommand *cmd, --=20 2.34.1 From nobody Tue May 14 06:04:04 2024 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=1647964948; cv=none; d=zohomail.com; s=zohoarc; b=CvSSmGn1TWvbtACx62B7vO7aRAaaRQz7eW0YEGVz05+dHAjhzmCdZvLuHgq3eScFTCpEbtH2mbeYB2L+wYTw5YcxCFzlwAn9BXhT+vcOkg0TrKzozO0UatRwWdzmd+nnCRhAQGfzetYVclLPtbtbZtsoIlmPc6AS1rXOW9M7pHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647964948; 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=kOPek/c0Vu2h2Rd0GQ8qA6mL08CW+C1APeXHYB0sZ7Q=; b=h0tHkqlaUTPoEOrmZTgLsEttNMvL4qEkzYReW2qnLeFsxWfw0JTFYcaxxxVUXYmd+MA1cir4s3UsMqnYqtoAKUI+q8MUpy8zMrSLUr3RZ3OqCKCYaAIZv1ERaMLLmAiv7r7YnQuhyBCUhncy4Xmu5mOS92dvXDKmf/I9IDKOhNY= 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 1647964948291923.4779093569119; Tue, 22 Mar 2022 09:02:28 -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-644-s9GVC8S7NtW8kDiXXek88g-1; Tue, 22 Mar 2022 12:02:24 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C28B3805901; Tue, 22 Mar 2022 16:02:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BB5E40317E; Tue, 22 Mar 2022 16:02: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 07210193F6DF; Tue, 22 Mar 2022 16:02: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 339701940364 for ; Tue, 22 Mar 2022 16:02:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 25690C23DC6; Tue, 22 Mar 2022 16:02:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1E28C23DC3 for ; Tue, 22 Mar 2022 16:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647964946; 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=kOPek/c0Vu2h2Rd0GQ8qA6mL08CW+C1APeXHYB0sZ7Q=; b=I6viqLzDrZq3vrCLVzAVRh0FZgZeIbxG2OLv0AZGDg2V8pAf9lidKh58GvKNAKtgATk1bN thSezmDNWYRCAc69gTCwuwT0sLm5+DyR/CSI1tvKB9f4loOlDU6Bm3XW57QEOHZnt2M+ul ht1mOdT5ekx9w07QUGSYkz85JcAWvPQ= X-MC-Unique: s9GVC8S7NtW8kDiXXek88g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 3/7] vircommand: Don't set nonblocking FDs in virCommandDoAsyncIO() Date: Tue, 22 Mar 2022 17:02:02 +0100 Message-Id: In-Reply-To: References: 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.10 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: 1647964949538100003 Content-Type: text/plain; charset="utf-8" Back in 2013 (v1.0.3-rc1~235) when I introduced virCommandDoAsyncIO() things were way different than today. We had one event loop for everything and asynchronous IO for virCommand was handled by the event loop. Therefore, it made sense to enable VIR_EXEC_NONBLOCK flag alongside with VIR_EXEC_ASYNC_IO. Well, sort of - a blocking FD can still be put into poll(). Anyway, this was reimplemented in v1.0.3-rc1~127 when a separate thread is created that handles IO. Therefore, there's no need to enable VIR_EXEC_NONBLOCK flag anymore. There's a separate API to request that flag: virCommandNonblockingFDs(). Signed-off-by: Michal Privoznik --- src/util/vircommand.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 5f22bd0ac3..ebd986cb13 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -3105,7 +3105,6 @@ virCommandFree(virCommand *cmd) * ... * * - * The libvirt's event loop is used for handling stdios of @cmd. * Since current implementation uses strlen to determine length * of data to be written to @cmd's stdin, don't pass any binary * data. If you want to re-run command, you need to call this and @@ -3117,7 +3116,7 @@ virCommandDoAsyncIO(virCommand *cmd) if (virCommandHasError(cmd)) return; =20 - cmd->flags |=3D VIR_EXEC_ASYNC_IO | VIR_EXEC_NONBLOCK; + cmd->flags |=3D VIR_EXEC_ASYNC_IO; } =20 =20 --=20 2.34.1 From nobody Tue May 14 06:04:04 2024 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=1647964953; cv=none; d=zohomail.com; s=zohoarc; b=XibS7EgIbXDQCGp4iNCxhcxktV9MeH41TDasKF11H4CCqxC9t4XVDukeHPL1c8eC6/snyFGqirhoc0uL698tBsUpK7Q/R7GWC1xT/Zv76WO8I0pfkHwccD/73Bgf3/PHayKw4lX+O9YSmjZuUiiwFOMsfPMPPt3xoKRSoYquD9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647964953; 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=8pNBo5qd1uIcI7tXaewG9M6+OSKnRJ6WPxHeg6qB31s=; b=DLNDFImv8CebiT0m7W31yZEp1DWD4NOTxLl+O7msK74t2R/iC7z6LbwokD0QVI44qKb+cCFBUK+pplgz43HdVyxPSzsm9FpZ7WyuvKlHgdla3ZHuUWGsZWgbHoB2EBZUVPgXXfL+eOyjzbZMC/XetAFQe9WlJ8THRkMiDac+6tU= 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 1647964953028244.81110134183382; Tue, 22 Mar 2022 09:02:33 -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-586-nV7JjK7-NxuuDR9923T7rg-1; Tue, 22 Mar 2022 12:02:24 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4FCAA811E84; Tue, 22 Mar 2022 16:02:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35179C27E9B; Tue, 22 Mar 2022 16:02: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 818B6194035D; Tue, 22 Mar 2022 16:02:16 +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 D63131940364 for ; Tue, 22 Mar 2022 16:02:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B750FC23DC6; Tue, 22 Mar 2022 16:02:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F7D2C23DC3 for ; Tue, 22 Mar 2022 16:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647964951; 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=8pNBo5qd1uIcI7tXaewG9M6+OSKnRJ6WPxHeg6qB31s=; b=YIYfkBiU350eouKXDEpVXmfOC8EdOZDofpw710VZkBNy5BfUZjLwl4mEVNfrkR44ZdgdJX 6LR50FIZdqS+Ryf4DkpeJqqJlPpqJIdFmbIJ8LckjGuLwdHikrTM8nwH8OOmNiR8ftzvyD RQUJErxO0i/zHWFRvhBgFM6A8ltZawE= X-MC-Unique: nV7JjK7-NxuuDR9923T7rg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 4/7] commandtest: Use unsigned char in test27() Date: Tue, 22 Mar 2022 17:02:03 +0100 Message-Id: <1b6675086df743bac072971e00f231fb28e33023.1647964841.git.mprivozn@redhat.com> In-Reply-To: References: 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.8 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: 1647964953610100011 Content-Type: text/plain; charset="utf-8" In test27() the virCommandSetSendBuffer() is used, which expects unsigned char. Use that type for variables which are passed to the function. Signed-off-by: Michal Privoznik --- tests/commandtest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index 74e60a072b..9d4de151f0 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -1043,8 +1043,8 @@ static int test27(const void *unused G_GNUC_UNUSED) int buf2fd; size_t buflen =3D 1024 * 128; g_autofree char *buffer0 =3D NULL; - g_autofree char *buffer1 =3D NULL; - g_autofree char *buffer2 =3D NULL; + g_autofree unsigned char *buffer1 =3D NULL; + g_autofree unsigned char *buffer2 =3D NULL; g_autofree char *outactual =3D NULL; g_autofree char *erractual =3D NULL; g_autofree char *outexpect =3D NULL; @@ -1057,8 +1057,8 @@ static int test27(const void *unused G_GNUC_UNUSED) "END STDERR\n" =20 buffer0 =3D g_new0(char, buflen); - buffer1 =3D g_new0(char, buflen); - buffer2 =3D g_new0(char, buflen); + buffer1 =3D g_new0(unsigned char, buflen); + buffer2 =3D g_new0(unsigned char, buflen); =20 memset(buffer0, 'H', buflen - 2); buffer0[buflen - 2] =3D '\n'; @@ -1077,8 +1077,8 @@ static int test27(const void *unused G_GNUC_UNUSED) errexpect =3D g_strdup_printf(TEST27_ERREXPECT_TEMP, buffer0, buffer1, buffer2); =20 - buf1fd =3D virCommandSetSendBuffer(cmd, (unsigned char *) g_steal_poin= ter(&buffer1), buflen - 1); - buf2fd =3D virCommandSetSendBuffer(cmd, (unsigned char *) g_steal_poin= ter(&buffer2), buflen - 1); + buf1fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer1), buf= len - 1); + buf2fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer2), buf= len - 1); =20 virCommandAddArg(cmd, "--readfd"); virCommandAddArgFormat(cmd, "%d", buf1fd); --=20 2.34.1 From nobody Tue May 14 06:04:04 2024 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=1647964948; cv=none; d=zohomail.com; s=zohoarc; b=fzZHiE1jnpiPuBC9rKq5JewOq5k/iLrUJ3aJ3ys4Lm2Iug8nVOUfU3HYfIb8jYzo40y090v00tsL3llb3CxgGul4CveEFiUB1N2ZSq0i4yI3QALEQtB5qAgORxtF4qR8lY6n6t+8fre45DaEAoJokN0FQKz3M3yyjZlz/UWEiVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647964948; 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=vcBHG5ovwg1uumo49bsDYZQImDHDjRSQb5yf1APnUzU=; b=fT77FKWphd3MImwXdSN/ETivyOPQfe/w5UJtvMZpCAYGtHEb6wEztMVc5LEob8a6dy/M4RGxL6N27P0sQmWuyuVMl8z9pBSKDLjQoaY5gURWr6t0T9AjlwXEX8KQoIGgSrP/Z9dc4JpqZQYBN5p3nFdVP0Qdvj3iHnFOCWzT+xY= 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 1647964948373450.50060499080416; Tue, 22 Mar 2022 09:02:28 -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-154-6kHEc-gfPfmqJ5RDX4GGgQ-1; Tue, 22 Mar 2022 12:02:25 -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 DD141805904; Tue, 22 Mar 2022 16:02:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6E37454D80; Tue, 22 Mar 2022 16:02: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 3AEB21940352; Tue, 22 Mar 2022 16:02:16 +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 60C0D193F6DF for ; Tue, 22 Mar 2022 16:02:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 55233C27E9B; Tue, 22 Mar 2022 16:02:14 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1683C23DC3 for ; Tue, 22 Mar 2022 16:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647964947; 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=vcBHG5ovwg1uumo49bsDYZQImDHDjRSQb5yf1APnUzU=; b=OP0NU1hEJvFNU7Gzxo6r+wxem1jCoF/q8LeyTMSMjggir91XXPKdYOYlfJDsKufsa8k12H VlkvKo3gV1mXFJPEg122GCLo6O32f6JzxDwJufQGVdb3wlw+mxT1DxY/f+tpOJwXADWjo2 ZvWwkVpjUGgQ8hT7cjtbFbmDzwiqhGM= X-MC-Unique: 6kHEc-gfPfmqJ5RDX4GGgQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 5/7] virCommandSetSendBuffer: Take double pointer of @buffer Date: Tue, 22 Mar 2022 17:02:04 +0100 Message-Id: <8cd829a1555dc88c400e3ef631af6ea1e610a66a.1647964841.git.mprivozn@redhat.com> In-Reply-To: References: 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: 1647965853799100002 Content-Type: text/plain; charset="utf-8"; x-default="true" The virCommandSetSendBuffer() function consumes passed @buffer, but takes it only as plain pointer. Switch to a double pointer to make this obvious. This allows us then to drop all g_steal_pointer() in callers. Signed-off-by: Michal Privoznik --- src/qemu/qemu_tpm.c | 2 +- src/util/vircommand.c | 6 +++--- src/util/vircommand.h | 2 +- tests/commandtest.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 56bccee128..28d2b07903 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -265,7 +265,7 @@ qemuTPMSetupEncryption(const unsigned char *secretuuid, &secret, &secret_len) < 0) return -1; =20 - return virCommandSetSendBuffer(cmd, g_steal_pointer(&secret), secret_l= en); + return virCommandSetSendBuffer(cmd, &secret, secret_len); } =20 =20 diff --git a/src/util/vircommand.c b/src/util/vircommand.c index ebd986cb13..ff0e60936b 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1725,10 +1725,10 @@ virCommandFreeSendBuffers(virCommand *cmd) */ int virCommandSetSendBuffer(virCommand *cmd, - unsigned char *buffer, + unsigned char **buffer, size_t buflen) { - g_autofree unsigned char *localbuf =3D g_steal_pointer(&buffer); + g_autofree unsigned char *localbuf =3D g_steal_pointer(buffer); int pipefd[2] =3D { -1, -1 }; size_t i; =20 @@ -2927,7 +2927,7 @@ int virCommandHandshakeNotify(virCommand *cmd) #else /* WIN32 */ int virCommandSetSendBuffer(virCommand *cmd, - unsigned char *buffer G_GNUC_UNUSED, + unsigned char **buffer G_GNUC_UNUSED, size_t buflen G_GNUC_UNUSED) { if (virCommandHasError(cmd)) diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 600806a987..63ae9b8a61 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -140,7 +140,7 @@ void virCommandSetWorkingDirectory(virCommand *cmd, const char *pwd) ATTRIBUTE_NONNULL(2); =20 int virCommandSetSendBuffer(virCommand *cmd, - unsigned char *buffer, + unsigned char **buffer, size_t buflen) ATTRIBUTE_NONNULL(2); =20 diff --git a/tests/commandtest.c b/tests/commandtest.c index 9d4de151f0..10a051124d 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -1077,8 +1077,8 @@ static int test27(const void *unused G_GNUC_UNUSED) errexpect =3D g_strdup_printf(TEST27_ERREXPECT_TEMP, buffer0, buffer1, buffer2); =20 - buf1fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer1), buf= len - 1); - buf2fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer2), buf= len - 1); + buf1fd =3D virCommandSetSendBuffer(cmd, &buffer1, buflen - 1); + buf2fd =3D virCommandSetSendBuffer(cmd, &buffer2, buflen - 1); =20 virCommandAddArg(cmd, "--readfd"); virCommandAddArgFormat(cmd, "%d", buf1fd); --=20 2.34.1 From nobody Tue May 14 06:04:04 2024 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=1647964949; cv=none; d=zohomail.com; s=zohoarc; b=eAMisg16QO4KK9MFRHJYrL4N8Z7dca29eYnNl2TaCIwzck7e5mDeR+n6KZFGRKzEJ+vyjxtwJUKIgGiqTFSEkpTiXqeXESWfl6E9XFLxomV60FUSgqT67mLzVnxmh5OSg9wFlSMbTQE1glisoEe+o0g7WNCxIGuFBFU9PEdtbTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647964949; 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=0nF/0YECQrHOh1U1UdPUZh/93f+PbAjMKMShRkJQTRw=; b=GX9YSzicsKaapAJV3vI95tlT3GqDrDjJK2psQSJLhl/GWfa1Z+7hKB/bdeWWjaVUM8RPkk3w8Gm40G0SR3cq80QndEiqS10l0sIycXvodsp3myfoViZ401hs69wgl+6H/jzVnRJKko/arNMoG1LqoQ7hukM61ZXSoquzgphTOb0= 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 1647964949345983.2381080052165; Tue, 22 Mar 2022 09:02:29 -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-45-ooDUvWOnPkegBMz7CGIUug-1; Tue, 22 Mar 2022 12:02:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7F928339C8; Tue, 22 Mar 2022 16:02:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DBD740CF900; Tue, 22 Mar 2022 16:02: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 D1F55193F50F; Tue, 22 Mar 2022 16:02:16 +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 07E43193F6E1 for ; Tue, 22 Mar 2022 16:02:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E7AA3C07F5B; Tue, 22 Mar 2022 16:02:14 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F975C27E9B for ; Tue, 22 Mar 2022 16:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647964948; 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=0nF/0YECQrHOh1U1UdPUZh/93f+PbAjMKMShRkJQTRw=; b=ToBATPAfEVCQ1PUxdl+VblubXd8vyqcPBICuQR4ttigBr99fcRcwtbbDcrB3dI+q6e0XZ4 ij23IgVu+VQ18hIbPd/kw5JlKLy/qoQxiom0Lt2+q4R9jH4pldTYbjWd5sQrdfPvr3G9kK 6ZxKINkOY5LKZvzay4fBHtS0cKROqL8= X-MC-Unique: ooDUvWOnPkegBMz7CGIUug-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 6/7] commandtest: Test virCommandSetSendBuffer() with virCommandDoAsyncIO() Date: Tue, 22 Mar 2022 17:02:05 +0100 Message-Id: <977c7bc5a11e3d23312c875d1ae8775aa1f51ac4.1647964841.git.mprivozn@redhat.com> In-Reply-To: References: 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.84 on 10.11.54.1 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: 1647964951635100009 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduce a test case which ensures that a daemonized process can work with virCommandSetSendBuffer() when async IO is enabled. Signed-off-by: Michal Privoznik --- tests/commanddata/test29.log | 19 ++++++++ tests/commandtest.c | 84 ++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 tests/commanddata/test29.log diff --git a/tests/commanddata/test29.log b/tests/commanddata/test29.log new file mode 100644 index 0000000000..49993a4947 --- /dev/null +++ b/tests/commanddata/test29.log @@ -0,0 +1,19 @@ +ARG:--close-stdin +ARG:--readfd +ARG:3 +ENV:DISPLAY=3D:0.0 +ENV:HOME=3D/home/test +ENV:HOSTNAME=3Dtest +ENV:LANG=3DC +ENV:LOGNAME=3Dtest +ENV:PATH=3D/usr/bin:/bin +ENV:TMPDIR=3D/tmp +ENV:USER=3Dtest +FD:0 +FD:1 +FD:2 +FD:3 +FD:6 +DAEMON:yes +CWD:/ +UMASK:0022 diff --git a/tests/commandtest.c b/tests/commandtest.c index 10a051124d..573a4f250d 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -25,6 +25,7 @@ #include #ifndef WIN32 # include +# include #endif #include =20 @@ -1157,6 +1158,88 @@ test28(const void *unused G_GNUC_UNUSED) } =20 =20 +static int +test29(const void *unused G_GNUC_UNUSED) +{ + g_autoptr(virCommand) cmd =3D virCommandNew(abs_builddir "/commandhelp= er"); + g_autofree char *pidfile =3D virPidFileBuildPath(abs_builddir, "comman= dhelper"); + pid_t pid; + int buffd; + VIR_AUTOCLOSE outfd =3D -1; + size_t buflen =3D 1024 * 10; + g_autofree unsigned char *buffer =3D NULL; + g_autofree char *outactual =3D NULL; + g_autofree char *outexpect =3D NULL; + size_t i; + size_t outactuallen =3D 0; + int ret =3D -1; + + if (!pidfile) + return -1; + + buffer =3D g_new0(unsigned char, buflen + 1); + for (i =3D 0; i < buflen; i++) { + buffer[i] =3D 'a' + i % ('z' - 'a' + 1); + } + buffer[buflen] =3D '\0'; + + outexpect =3D g_strdup_printf("BEGIN STDOUT\n%sEND STDOUT\n", buffer); + + buffd =3D virCommandSetSendBuffer(cmd, &buffer, buflen); + + virCommandAddArg(cmd, "--close-stdin"); + virCommandAddArg(cmd, "--readfd"); + virCommandAddArgFormat(cmd, "%d", buffd); + + virCommandSetOutputFD(cmd, &outfd); + virCommandSetPidFile(cmd, pidfile); + virCommandDaemonize(cmd); + virCommandDoAsyncIO(cmd); + + if (virCommandRun(cmd, NULL) < 0) { + fprintf(stderr, "Cannot run child %s\n", virGetLastErrorMessage()); + goto cleanup; + } + + if (virPidFileReadPath(pidfile, &pid) < 0) { + fprintf(stderr, "cannot read pidfile: %s\n", pidfile); + goto cleanup; + } + + while (1) { + char buf[1024] =3D { 0 }; + int rc =3D 0; + + rc =3D read(outfd, buf, sizeof(buf)); + if (rc < 0) { + fprintf(stderr, "cannot read from output pipe: errno=3D%d\n", = errno); + goto cleanup; + } + + if (rc =3D=3D 0) + break; + + outactual =3D g_renew(char, outactual, outactuallen + rc + 1); + memcpy(outactual + outactuallen, buf, rc); + outactuallen +=3D rc; + outactual[outactuallen] =3D '\0'; + } + + if (STRNEQ_NULLABLE(outactual, outexpect)) { + virTestDifference(stderr, outexpect, outactual); + goto cleanup; + } + + ret =3D checkoutput("test29"); + + cleanup: + if (pidfile) + unlink(pidfile); + + return ret; +} + + static int mymain(void) { @@ -1254,6 +1337,7 @@ mymain(void) DO_TEST(test26); DO_TEST(test27); DO_TEST(test28); + DO_TEST(test29); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.34.1 From nobody Tue May 14 06:04:04 2024 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=1647964985; cv=none; d=zohomail.com; s=zohoarc; b=RvDb7n7RAcRz/bjiS2rMigJp0OZJO6kRbdPQprajBZPBbbgbhwojGm/MEGdO/Ds0rCbF1A3tm5UAs4ooPEEMxSmOCm7hhXNiG0RrElaP5b1qOAVuntkYzSFeyv9JBmpJRKSmcS8KSvZuKJoHIdX9JernY1gXKmYiZT1B6kVjWKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647964985; 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=FCJFovmdkLsoE5Vh9+AdDvNI+m4I+PFdtfZQZdkSd/k=; b=Hm7ucEQtVLs7tcettrIyScGg654A+hBNHjjjHiYRXw1qiF2An62EE4dyCB42LRE987lsEe+B8Ze2axBPz3/xLebVuQ+7aDEwWDcKzKegYZ+EMaDIxBHaacrpLWQ3hw/l6IMJL6D8Exy9i09d5pzHLkBmtI6xvWcpsceXCh0DlrA= 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 1647964985907848.0191419424348; Tue, 22 Mar 2022 09:03:05 -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-453-Qb3ByHPQNj674DMpBwlc5Q-1; Tue, 22 Mar 2022 12:02:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 47D4A805900; Tue, 22 Mar 2022 16:02:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BC6540CF918; Tue, 22 Mar 2022 16:02:19 +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 400941940364; Tue, 22 Mar 2022 16:02:17 +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 A6D70193F6ED for ; Tue, 22 Mar 2022 16:02:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 869CCC27EA0; Tue, 22 Mar 2022 16:02:15 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DE3FC23DC3 for ; Tue, 22 Mar 2022 16:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647964984; 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=FCJFovmdkLsoE5Vh9+AdDvNI+m4I+PFdtfZQZdkSd/k=; b=QcATDcnpwGljbz+qHgMa65iN/NfYGo7xBAm1KRrpMy2OTHbi7aY+lL98V00WdpF+epqgzv EQ13LXKIwGIpRSrudDn6X6YwEi//OF3rfz3KN+G6sWu75wwf8p+DeMhnUB4IDq1DDso4/t wo7m2aM3mK08XRCDaiNvpihDAVBs2C0= X-MC-Unique: Qb3ByHPQNj674DMpBwlc5Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 7/7] commandtest: Use virTestCompareToFile() in checkoutput() Date: Tue, 22 Mar 2022 17:02:06 +0100 Message-Id: In-Reply-To: References: 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.84 on 10.11.54.1 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: 1647964987843100001 Content-Type: text/plain; charset="utf-8" In the commandtest there is checkoutput() function which checks the latest log of commandhelper (containing things like cmd line arguments, env vars, FDs, CWD, etc.) and compares that against expected output. Well, the way this function implements that is effectively by open coding virTestCompareToFile() except for the nice feature that the virTestCompareToFile() has: VIR_TEST_OUTPUT_REGENERATE. Signed-off-by: Michal Privoznik --- tests/commandtest.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index 573a4f250d..60daf6e48f 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -60,29 +60,18 @@ static int checkoutput(const char *testname) { int ret =3D -1; g_autofree char *expectname =3D NULL; - g_autofree char *expectlog =3D NULL; g_autofree char *actualname =3D NULL; g_autofree char *actuallog =3D NULL; =20 expectname =3D g_strdup_printf("%s/commanddata/%s.log", abs_srcdir, te= stname); actualname =3D g_strdup_printf("%s/commandhelper.log", abs_builddir); =20 - if (virFileReadAll(expectname, 1024*64, &expectlog) < 0) { - fprintf(stderr, "cannot read %s\n", expectname); - goto cleanup; - } - if (virFileReadAll(actualname, 1024*64, &actuallog) < 0) { fprintf(stderr, "cannot read %s\n", actualname); goto cleanup; } =20 - if (STRNEQ(expectlog, actuallog)) { - virTestDifference(stderr, expectlog, actuallog); - goto cleanup; - } - - ret =3D 0; + ret =3D virTestCompareToFile(actuallog, expectname); =20 cleanup: if (actualname) @@ -1281,6 +1270,7 @@ mymain(void) * since we're about to reset 'environ' */ ignore_value(virTestGetDebug()); ignore_value(virTestGetVerbose()); + ignore_value(virTestGetRegenerate()); =20 /* Make sure to not leak fd's */ virinitret =3D virInitialize(); --=20 2.34.1