From nobody Tue May 14 17:24:25 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=1644854316; cv=none; d=zohomail.com; s=zohoarc; b=it+KOGqBgseJWQfrMJSE7trMwTxdbFQXkaxcHhEtyMuvQk6tKbgdZWzAByp/NT5aETyXdiP0hDqBhfZSXeHJkJVmWz9DI0DU2uX22ruKpAIWFRNRNwXTlc1LWsNhOm6rFI5713DcT9aET9whqcmmIU6yLwi18Pgmt4Px1nHs6c4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644854316; 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=eP4Aco3jjENNDXVh9j8r+A+fsg1HnYFipK8+tTRMjgs=; b=YwSxyzlMB2jJxUuoGJVwt65UsiQBiisT1ryzythJ5dD78XYGXmsZ+B5PHwNqOSSmFd6hTQhoOePnlTNlm5hQ62fgRqWHi6+4vQ6j8hFXMKWTYSjgjHR/IDhfAscqvSt4E3w087iKbmO4Lu1gKPh/jRWQSku8YFjKmaqHFn8Ey48= 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 1644854316326148.81223122133792; Mon, 14 Feb 2022 07:58:36 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-658-eOu1xFenOlSA3w-wTdeEXw-1; Mon, 14 Feb 2022 10:58:33 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29A7F1091DA8; Mon, 14 Feb 2022 15:58:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C28475535; Mon, 14 Feb 2022 15:58:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A7A5218077BC; Mon, 14 Feb 2022 15:58:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21EFwDNl021418 for ; Mon, 14 Feb 2022 10:58:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 67988108C7; Mon, 14 Feb 2022 15:58:13 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id C06CB2A199 for ; Mon, 14 Feb 2022 15:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644854315; 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=eP4Aco3jjENNDXVh9j8r+A+fsg1HnYFipK8+tTRMjgs=; b=hsybyMUbq3z1WkUWWAzXiJccqjfN4qjKDzYgd5WxR2A0Us2KemN5+Nnked1sHrYk6zFl2l MKlF7lkQATvDQrWiKC5UBqfn1p/uOxJC+7nxKmQ9/8oS6KfrUQPXCrLu3NYHDCfoInhe7F e4R6Eb6vsZm35zr1p+cdQjiFnsA64sk= X-MC-Unique: eOu1xFenOlSA3w-wTdeEXw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/6] qemu: monitor: Drop old monitor fields from 'struct _qemuMonitorMessage' Date: Mon, 14 Feb 2022 16:58:02 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1644854316937100001 Content-Type: text/plain; charset="utf-8" The fields are no longer used since we've deleted support for HMP-only qemus. The HMP command pass-through works via a QMP command. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 4c22394972..12005ac624 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -43,15 +43,10 @@ struct _qemuMonitorMessage { int txOffset; int txLength; - /* Used by the text monitor reply / error */ - char *rxBuffer; - int rxLength; /* Used by the JSON monitor to hold reply / error */ void *rxObject; - /* True if rxBuffer / rxObject are ready, or a - * fatal error occurred on the monitor channel - */ + /* True if rxObject is ready, or a fatal error occurred on the monitor= channel */ bool finished; }; --=20 2.34.1 From nobody Tue May 14 17:24:25 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=1644854305; cv=none; d=zohomail.com; s=zohoarc; b=HZMmhLU71PLlFBk9gRNQvLTmMb6EAscNxIXlU+HY9pgUpbV1BTU8lgqRnNM8Ht66N/esCv8hotKR7aY0u209wp0TElodVj6XGPcaNqMtb3sat8SqbWJP7tig1U594Bs4Hoc4uQd2hJPD2bT7FO7rQ8fMzjlGvP88YAZarHtE1pM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644854305; 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=gZe5MSxi/gCHt/U1YeGhH7MEocF1PjhQ/2U9nG6CTLo=; b=CF9r8lFQdmvV4xyRhgrEZlD2RbLLbsSvuuDOn1GgFVlk8nzUKHnP2vWLihUm0uoMJrZpR6dgmYFdad1cWcNCASyYNnw6BKebjdYYVriMa2TofA1AKDNKR92RCaFivWk0VBXpRietUnc09ksibLNQjnaw+9V4QiCKkvzLoWTGTX0= 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 16448543057481023.5456534449471; Mon, 14 Feb 2022 07:58:25 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-354-vvKFsgrnPl-cInUGq_-jVA-1; Mon, 14 Feb 2022 10:58:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2200F1006AA3; Mon, 14 Feb 2022 15:58:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1BAB7CD68; Mon, 14 Feb 2022 15:58:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A53974BB7C; Mon, 14 Feb 2022 15:58:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21EFwEdM021442 for ; Mon, 14 Feb 2022 10:58:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8EA3F2B4B9; Mon, 14 Feb 2022 15:58:14 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7BD62A199 for ; Mon, 14 Feb 2022 15:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644854304; 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=gZe5MSxi/gCHt/U1YeGhH7MEocF1PjhQ/2U9nG6CTLo=; b=FGl8aXPD5kh30HWi6uaA7eJqVMpZJJ73OeelpNATtoPZXrHir3sJyYSuDDQDUUsRXtAKp4 EP9IxhFNRJCIN3fQTXbdOT2hLjCz22FFvJ8D3xhu/OC+ejFiK2C78R4SPP0ZkEYT3yvIay 1OiXAE/lWZeT/GDHldlj5dxr2YHOgtA= X-MC-Unique: vvKFsgrnPl-cInUGq_-jVA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/6] qemu: Privatize 'struct _qemuMonitorMessage' Date: Mon, 14 Feb 2022 16:58:03 +0100 Message-Id: <4c521ee11cd7c1acbc50d56bcb75fddf0639e471.1644854180.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: 1644854306824100003 Content-Type: text/plain; charset="utf-8" Move the declaration of the struct into 'qemu_monitor_priv.h' as other code has no business in peeking into the monitor messages. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.h | 14 -------------- src/qemu/qemu_monitor_json.c | 3 +++ src/qemu/qemu_monitor_priv.h | 16 ++++++++++++++++ tests/qemucapsprobemock.c | 3 +++ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 12005ac624..1d21183d82 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -34,21 +34,7 @@ #include "virenum.h" typedef struct _qemuMonitor qemuMonitor; - typedef struct _qemuMonitorMessage qemuMonitorMessage; -struct _qemuMonitorMessage { - int txFD; - - const char *txBuffer; - int txOffset; - int txLength; - - /* Used by the JSON monitor to hold reply / error */ - void *rxObject; - - /* True if rxObject is ready, or a fatal error occurred on the monitor= channel */ - bool finished; -}; typedef enum { QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE =3D 0, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5bc1b2342c..1de932f638 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -44,6 +44,9 @@ # include "libvirt_qemu_probes.h" #endif +#define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW +#include "qemu_monitor_priv.h" + #define VIR_FROM_THIS VIR_FROM_QEMU VIR_LOG_INIT("qemu.qemu_monitor_json"); diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h index 31bb3526b9..6115f830de 100644 --- a/src/qemu/qemu_monitor_priv.h +++ b/src/qemu/qemu_monitor_priv.h @@ -24,5 +24,21 @@ #include "qemu_monitor.h" + +struct _qemuMonitorMessage { + int txFD; + + const char *txBuffer; + int txOffset; + int txLength; + + /* Used by the JSON monitor to hold reply / error */ + void *rxObject; + + /* True if rxObject is ready, or a fatal error occurred on the monitor= channel */ + bool finished; +}; + + void qemuMonitorResetCommandID(qemuMonitor *mon); diff --git a/tests/qemucapsprobemock.c b/tests/qemucapsprobemock.c index 915036d178..2717ed5d84 100644 --- a/tests/qemucapsprobemock.c +++ b/tests/qemucapsprobemock.c @@ -25,6 +25,9 @@ #include "qemu/qemu_monitor.h" #include "qemu/qemu_monitor_json.h" +#define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW +#include "qemu/qemu_monitor_priv.h" + #define REAL_SYM(realFunc) \ do { \ if (!realFunc && !(realFunc =3D dlsym(RTLD_NEXT, __FUNCTION__))) {= \ --=20 2.34.1 From nobody Tue May 14 17:24:25 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=1644854314; cv=none; d=zohomail.com; s=zohoarc; b=PRw7oPAVgn6KExU7Q/QKkr6+SVlgstqRKQpa6gEvYjj+Nni6K+JSAoQTi3OHrhC8dejlTWxMNxp7bfv+z2wABLCpg26rr66Z+zoxaVm02tBJRW1S+RNzaTPfn5lArhcA6xzc8/q3kPer49TWp3Fxoznt3iSb3Aqq8Y78UAtDUJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644854314; 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=ebZc4eTAGG4rA2B0Bu4cNMoF6+IC3Lq2OEJ8ZOf76Uk=; b=de9f48l6cli8BvFgk8QEy9gkXW0tlMEl3+I0T1CDKN9jhktfm65aMcBv8N/JAEuRJaBuW3EtzJv0xEPR13r5iN3fDxhsfH5IwI2fUhZgXfui1GO7OtEzkX0Vcs58nkE8D6EUbdg1C3kRrs7RjwwMK0jhWH5aeCjGVLCvlAph1cE= 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 1644854314942581.7332281379895; Mon, 14 Feb 2022 07:58:34 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-284-sdZGkpbONr-A2CtwJcARUQ-1; Mon, 14 Feb 2022 10:58:32 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2ADC7189DF44; Mon, 14 Feb 2022 15:58:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 095D610A33C3; Mon, 14 Feb 2022 15:58:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A40914A7CB; Mon, 14 Feb 2022 15:58:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21EFwFkV021450 for ; Mon, 14 Feb 2022 10:58:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id DCF7C2B6ED; Mon, 14 Feb 2022 15:58:15 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 162EB2B6E9 for ; Mon, 14 Feb 2022 15:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644854313; 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=ebZc4eTAGG4rA2B0Bu4cNMoF6+IC3Lq2OEJ8ZOf76Uk=; b=XPqSv+ZgSlquixuE1/wqOg2cycbYKRixxNv6nWuupR89x8pz3XsbMlqAH3udDu9ZFIW/he e9OAWAIBwdCar3QpPFhjApyDxAvX4zAdUVEJBGwaOLSNqLxsNlSHACcMH0Hcw6qPZVEm/Y 8n5kFADvlx+zSlu1AU/dlpMyTeZzj4U= X-MC-Unique: sdZGkpbONr-A2CtwJcARUQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/6] qemu: monitor: Move declaration of struct _qemuMonitor to qemu_monitor_priv.h Date: Mon, 14 Feb 2022 16:58:04 +0100 Message-Id: <58e87df05ed2035dd40cdee7437f482f6620659e.1644854180.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1644854316955100003 Content-Type: text/plain; charset="utf-8" In order to mock the SCM_RIGHTS sendmsg to simulate sending filedescriptors to fake qemu in tests we need access to some fields of 'struct _qemuMonitor'. Move it's declaration to the private header file. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 50 --------------------------------- src/qemu/qemu_monitor_priv.h | 54 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 50 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 3de04eb1cc..327d6d978a 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -65,56 +65,6 @@ VIR_LOG_INIT("qemu.qemu_monitor"); */ #define QEMU_MONITOR_MAX_RESPONSE (10 * 1024 * 1024) -struct _qemuMonitor { - virObjectLockable parent; - - virCond notify; - - int fd; - - GMainContext *context; - GSocket *socket; - GSource *watch; - - virDomainObj *vm; - char *domainName; - - qemuMonitorCallbacks *cb; - void *callbackOpaque; - - /* If there's a command being processed this will be - * non-NULL */ - qemuMonitorMessage *msg; - - /* Buffer incoming data ready for Text/QMP monitor - * code to process & find message boundaries */ - size_t bufferOffset; - size_t bufferLength; - char *buffer; - - /* If anything went wrong, this will be fed back - * the next monitor msg */ - virError lastError; - - /* Set to true when EOF is detected on the monitor */ - bool goteof; - - int nextSerial; - - bool waitGreeting; - - /* If found, path to the virtio memballoon driver */ - char *balloonpath; - bool ballooninit; - - /* Log file context of the qemu process to dig for usable info */ - qemuMonitorReportDomainLogError logFunc; - void *logOpaque; - virFreeCallback logDestroy; - - /* true if qemu no longer wants 'props' sub-object of object-add */ - bool objectAddNoWrap; -}; /** * QEMU_CHECK_MONITOR_FULL: diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h index 6115f830de..606aa79fbd 100644 --- a/src/qemu/qemu_monitor_priv.h +++ b/src/qemu/qemu_monitor_priv.h @@ -24,6 +24,8 @@ #include "qemu_monitor.h" +#include + struct _qemuMonitorMessage { int txFD; @@ -40,5 +42,57 @@ struct _qemuMonitorMessage { }; +struct _qemuMonitor { + virObjectLockable parent; + + virCond notify; + + int fd; + + GMainContext *context; + GSocket *socket; + GSource *watch; + + virDomainObj *vm; + char *domainName; + + qemuMonitorCallbacks *cb; + void *callbackOpaque; + + /* If there's a command being processed this will be + * non-NULL */ + qemuMonitorMessage *msg; + + /* Buffer incoming data ready for Text/QMP monitor + * code to process & find message boundaries */ + size_t bufferOffset; + size_t bufferLength; + char *buffer; + + /* If anything went wrong, this will be fed back + * the next monitor msg */ + virError lastError; + + /* Set to true when EOF is detected on the monitor */ + bool goteof; + + int nextSerial; + + bool waitGreeting; + + /* If found, path to the virtio memballoon driver */ + char *balloonpath; + bool ballooninit; + + /* Log file context of the qemu process to dig for usable info */ + qemuMonitorReportDomainLogError logFunc; + void *logOpaque; + virFreeCallback logDestroy; + + /* true if qemu no longer wants 'props' sub-object of object-add */ + bool objectAddNoWrap; +}; + + void qemuMonitorResetCommandID(qemuMonitor *mon); --=20 2.34.1 From nobody Tue May 14 17:24:25 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=1644854307; cv=none; d=zohomail.com; s=zohoarc; b=SDkPZ2pbFWi3gE4o58pHhStAo1QKT72ePVf+Cm0PJmHncVaywODU/FhCBeSuRHwT7yPON7MDHe9bqo/wPC4n5z/GmAukjIhUI0ahNAryz1Hkj5uupZrRS3pUXLmWUfapIXTww9JfXGjEWlTdE/JwvW5y1CGS+qfDS/sYFql+BSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644854307; 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=aJ/l7s23SvQTGR4/sWn39CNM7dXldGEPRR/fRLKkDlY=; b=Y9gAbrldI5w14GG3oYDxNmJynCESXw5FnUNdeeoaqz/vwhe1exejAntnDD+8384r7ujU1jwqxlbPif0+EYbzsjAMD6rKrrhXI1GYxajjme4ar4ChDuPVYwbRzAleNhZZjL4uvwucxx3kjzOeHs0hvPEjwsQH+X1TyAjo7uHFFO8= 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 1644854307135309.1272503430463; Mon, 14 Feb 2022 07:58:27 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-92-vluG4oOgOWGqmOV1hjmw-A-1; Mon, 14 Feb 2022 10:58:25 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F07C814246; Mon, 14 Feb 2022 15:58:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F1B8752DF; Mon, 14 Feb 2022 15:58:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 304531809CBA; Mon, 14 Feb 2022 15:58:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21EFwHSx021458 for ; Mon, 14 Feb 2022 10:58:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 40F302B6E9; Mon, 14 Feb 2022 15:58:17 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DBFB2B6FA for ; Mon, 14 Feb 2022 15:58:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644854307; 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=aJ/l7s23SvQTGR4/sWn39CNM7dXldGEPRR/fRLKkDlY=; b=RlgjGdAWsMK/HQ6pXG5ufnYQp4L6/iQ2eJZ8/qtk1hOtu8fLoTGRyDUDE5SBYHPYt07jMX TiUWDBxFJzrLKIjp7EAtVgauAd42HgZHa2YAA1ldCmDa7CaKizFYd2M1wN1pt/XSnKIzuJ JGQhYnZ4GKfKeaYeCTDKNai+B1IvHYA= X-MC-Unique: vluG4oOgOWGqmOV1hjmw-A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/6] syntax-check: sc_avoid_write: Don't use blanket file exceptions Date: Mon, 14 Feb 2022 16:58:05 +0100 Message-Id: <67a45fd4d237dee6f039fc4eb2f0c6ad5f5e14fb.1644854180.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1644854308892100006 Content-Type: text/plain; charset="utf-8" Adding an exception for the whole file usually defeats the purpose of a syntax check and is also likely to get forgotten once the file is removed. In case of the suggestion of using 'safewrite' instead of write even the comment for safewrite states that the function needs to be used only in certain cases. Remove the blanket exceptions for files and use an exclude string instead. The only instance where we keep the full file exception is for src/libvirt-stream.c as there are multiple uses in example code in comments where I couldn't find a nicer targetted wapproach. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- build-aux/syntax-check.mk | 6 ++---- src/locking/lock_daemon.c | 4 ++-- src/logging/log_daemon.c | 4 ++-- src/lxc/lxc_controller.c | 2 +- src/qemu/qemu_monitor.c | 2 +- src/remote/remote_ssh_helper.c | 2 +- src/rpc/virnetsocket.c | 4 ++-- src/util/vircommand.c | 4 ++-- src/util/virfdstream.c | 2 +- src/util/virfile.c | 10 +++++----- tests/shunloadtest.c | 2 +- tests/vircgroupmock.c | 2 +- tests/virnettlssessiontest.c | 2 +- tools/virsh-console.c | 2 +- 14 files changed, 23 insertions(+), 25 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index b96d126bdc..9407581d0e 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -116,6 +116,7 @@ VC_LIST_ALWAYS_EXCLUDE_REGEX =3D \ # the safewrite wrapper. sc_avoid_write: @prohibit=3D'\msg->txBuffer + mon->msg->txOffset; len =3D mon->msg->txLength - mon->msg->txOffset; if (mon->msg->txFD =3D=3D -1) - done =3D write(mon->fd, buf, len); + done =3D write(mon->fd, buf, len); /* sc_avoid_write */ else done =3D qemuMonitorIOWriteWithFD(mon, buf, len, mon->msg->txFD); diff --git a/src/remote/remote_ssh_helper.c b/src/remote/remote_ssh_helper.c index 6403fe1761..b4735027be 100644 --- a/src/remote/remote_ssh_helper.c +++ b/src/remote/remote_ssh_helper.c @@ -255,7 +255,7 @@ virRemoteSSHHelperEventOnStdout(int watch G_GNUC_UNUSED, if (events & VIR_EVENT_HANDLE_WRITABLE && proxy->sockToTerminal.offset) { ssize_t done; - done =3D write(fd, + done =3D write(fd, /* sc_avoid_write */ proxy->sockToTerminal.data, proxy->sockToTerminal.offset); if (done < 0) { diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 51cab4f80c..1af2778b97 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -1623,7 +1623,7 @@ static ssize_t virNetSocketTLSSessionWrite(const char= *buf, void *opaque) { virNetSocket *sock =3D opaque; - return write(sock->fd, buf, len); + return write(sock->fd, buf, len); /* sc_avoid_write */ } @@ -1818,7 +1818,7 @@ static ssize_t virNetSocketWriteWire(virNetSocket *so= ck, const char *buf, size_t VIR_NET_TLS_HANDSHAKE_COMPLETE) { ret =3D virNetTLSSessionWrite(sock->tlsSession, buf, len); } else { - ret =3D write(sock->fd, buf, len); + ret =3D write(sock->fd, buf, len); /* sc_avoid_write */ } if (ret < 0) { diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 3b8c1c65c1..41cf552d7b 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1794,7 +1794,7 @@ virCommandSendBuffersHandlePoll(virCommand *cmd, if (i =3D=3D virCommandGetNumSendBuffers(cmd)) return 0; - done =3D write(fds->fd, + done =3D write(fds->fd, /* sc_avoid_write */ cmd->sendBuffers[i].buffer + cmd->sendBuffers[i].offset, cmd->sendBuffers[i].buflen - cmd->sendBuffers[i].offset); if (done < 0) { @@ -2306,7 +2306,7 @@ virCommandProcessIO(virCommand *cmd) fds[i].fd =3D=3D cmd->inpipe) { int done; - done =3D write(cmd->inpipe, cmd->inbuf + inoff, + done =3D write(cmd->inpipe, cmd->inbuf + inoff, /* sc_avoi= d_write */ inlen - inoff); if (done < 0) { if (errno =3D=3D EPIPE) { diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index e2c6461ded..b596659702 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -850,7 +850,7 @@ static int virFDStreamWrite(virStreamPtr st, const char= *bytes, size_t nbytes) ret =3D nbytes; } else { retry: - ret =3D write(fdst->fd, bytes, nbytes); + ret =3D write(fdst->fd, bytes, nbytes); /* sc_avoid_write */ if (ret < 0) { VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR if (errno =3D=3D EAGAIN || errno =3D=3D EWOULDBLOCK) { diff --git a/src/util/virfile.c b/src/util/virfile.c index 5d6f14ba7e..a04f888e06 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1112,17 +1112,17 @@ saferead(int fd, void *buf, size_t count) return nread; } -/* Like write(), but restarts after EINTR. Doesn't play - * nicely with nonblocking FD and EAGAIN, in which case - * you want to use bare write(). Or even use virSocket() - * if the FD is related to a socket rather than a plain +/* Like write(), but restarts after EINTR. Encouraged by sc_avoid_write. + * Doesn't play nicely with nonblocking FD and EAGAIN, in which case + * you want to use bare write() and mark it's use with sc_avoid_write. + * Or even use virSocket() if the FD is related to a socket rather than a = plain * file or pipe. */ ssize_t safewrite(int fd, const void *buf, size_t count) { size_t nwritten =3D 0; while (count > 0) { - ssize_t r =3D write(fd, buf, count); + ssize_t r =3D write(fd, buf, count); /* sc_avoid_write */ if (r < 0 && errno =3D=3D EINTR) continue; diff --git a/tests/shunloadtest.c b/tests/shunloadtest.c index d4ab3cd5ac..724532a3ea 100644 --- a/tests/shunloadtest.c +++ b/tests/shunloadtest.c @@ -81,7 +81,7 @@ static void *threadMain(void *arg) static void sigHandler(int sig) { - ignore_value(write(STDERR_FILENO, "FAIL\n", 5)); + ignore_value(write(STDERR_FILENO, "FAIL\n", 5)); /* sc_avoid_write */ signal(sig, SIG_DFL); raise(sig); } diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index a67c0d95d7..cebf1912f7 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -83,7 +83,7 @@ static int make_file(const char *path, if ((fd =3D real_open(filepath, O_CREAT|O_WRONLY, 0600)) < 0) goto cleanup; - if (write(fd, value, strlen(value)) !=3D strlen(value)) + if (write(fd, value, strlen(value)) !=3D strlen(value)) /* sc_avoid_wr= ite */ goto cleanup; ret =3D 0; diff --git a/tests/virnettlssessiontest.c b/tests/virnettlssessiontest.c index b9249cca56..9e0d6a46e6 100644 --- a/tests/virnettlssessiontest.c +++ b/tests/virnettlssessiontest.c @@ -54,7 +54,7 @@ static ssize_t testWrite(const char *buf, size_t len, voi= d *opaque) { int *fd =3D opaque; - return write(*fd, buf, len); + return write(*fd, buf, len); /* sc_avoid_write */ } static ssize_t testRead(char *buf, size_t len, void *opaque) diff --git a/tools/virsh-console.c b/tools/virsh-console.c index 67ee608706..b8780c714d 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -316,7 +316,7 @@ virConsoleEventOnStdout(int watch G_GNUC_UNUSED, con->streamToTerminal.offset) { ssize_t done; size_t avail; - done =3D write(fd, + done =3D write(fd, /* sc_avoid_write */ con->streamToTerminal.data, con->streamToTerminal.offset); if (done < 0) { --=20 2.34.1 From nobody Tue May 14 17:24:25 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=1644854315; cv=none; d=zohomail.com; s=zohoarc; b=ZKSCWNASvdswACzv94Q28iVLPS/sYnt983ff/r126l9dK+xO2FgPm4d/8Y0UqlCZrwxue9lDzKMkXR8STlFdJfMzmNK/mEAb9fscLWTPSLtC29/LhLxU5e8Cu7LH7hsurJUIuMai2t5oHK2dldukhj0/nX3ZD85VxzhtktwIlJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644854315; 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=kS2F2CIwHxkXYOLxRCN+qyyYDtHofWdlHtZtI+7RwbY=; b=UVqoOp7N5xIdEikPIHd3u5CNFa+8cdNFFoyrU9n30ev3xGChA1y6vX4Ot7LO9iSE3BawfqgzMlxORPmICG+UkWa5DiC3ck0QsGJEzYD7/KU7Qa2PuR2ZMcsh41A96LlGKfbrYrfaLoEzDZ9oCOZEjZs3LGWB49KlIybqxKatJ6M= 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 1644854315081664.1467589782715; Mon, 14 Feb 2022 07:58:35 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-z2yrogNzP2u-9UvFDyQENA-1; Mon, 14 Feb 2022 10:58:32 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA7FB2F4C; Mon, 14 Feb 2022 15:58:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 677C627CAC; Mon, 14 Feb 2022 15:58:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3804B4A7C8; Mon, 14 Feb 2022 15:58:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21EFwIZ2021470 for ; Mon, 14 Feb 2022 10:58:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5926C108C7; Mon, 14 Feb 2022 15:58:18 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id B83362BCD8 for ; Mon, 14 Feb 2022 15:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644854314; 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=kS2F2CIwHxkXYOLxRCN+qyyYDtHofWdlHtZtI+7RwbY=; b=QkXT6MeibHbzybWkQy/gzxQRqeQBx55YWHXYF1u9F5cls6400/sAR4dHEHN4Zh7AT4j10V 8qMlkiU8G0eK7MAbXBZNKgPkFswYb18E8+JYWZHJY7/XJY5angsUDn6YYq7nRzEx3yKUAw HTqiFlgYynha9CeEcGY9AnJ//IveKj8= X-MC-Unique: z2yrogNzP2u-9UvFDyQENA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/6] qemuhotplugmock: Mock fd passing to qemu via 'SCM_RIGHTS' Date: Mon, 14 Feb 2022 16:58:06 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644854316950100002 Content-Type: text/plain; charset="utf-8" We don't want to be dealing with real FDs thus we mock 'qemuMonitorIOWriteWithFD' to do the same thing as when no FD is being passed. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor_priv.h | 7 +++++++ tests/qemuhotplugmock.c | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index f514998ba5..dc81e41783 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -288,7 +288,7 @@ qemuMonitorIOProcess(qemuMonitor *mon) /* Call this function while holding the monitor lock. */ -static int +int qemuMonitorIOWriteWithFD(qemuMonitor *mon, const char *data, size_t len, diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h index 606aa79fbd..70f5f16e72 100644 --- a/src/qemu/qemu_monitor_priv.h +++ b/src/qemu/qemu_monitor_priv.h @@ -96,3 +96,10 @@ struct _qemuMonitor { void qemuMonitorResetCommandID(qemuMonitor *mon); + +int +qemuMonitorIOWriteWithFD(qemuMonitor *mon, + const char *data, + size_t len, + int fd) + G_GNUC_NO_INLINE; diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c index e3f0715058..d618ff9d06 100644 --- a/tests/qemuhotplugmock.c +++ b/tests/qemuhotplugmock.c @@ -28,6 +28,9 @@ #include "virmock.h" #include +#define LIBVIRT_QEMU_MONITOR_PRIV_H_ALLOW +#include "qemu/qemu_monitor_priv.h" + static bool (*real_virFileExists)(const char *path); static void @@ -107,3 +110,14 @@ qemuProcessPrepareHostBackendChardevHotplug(virDomainO= bj *vm, testQemuPrepareHostBac= kendChardevOne, vm); } + + +/* we don't really want to send fake FDs across the monitor */ +int +qemuMonitorIOWriteWithFD(qemuMonitor *mon, + const char *data, + size_t len, + int fd G_GNUC_UNUSED) +{ + return write(mon->fd, data, len); /* sc_avoid_write */ +} --=20 2.34.1 From nobody Tue May 14 17:24:25 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=1644854330; cv=none; d=zohomail.com; s=zohoarc; b=RMHr0rIzd4zDKkjmmFHPEOJoqofWKu2zA/O/c51TvUqG65vSKr44Te5LehrHkQGWpCWiWbADdNNRDWf9d4Vk1lan2h043UMBHCpAMfgtbpvLo3IfpE58Z6iDSjpJ0yP2xGIDIAwSuKBvloQlDfg5PFTl1IXcHKLJKe3Va8nUId0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644854330; 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=JlN2E5Pi+emHLdpcO58j5/eu0B3Ukl7JKYibYLRLFa8=; b=lOpq2liMFJUAmXYyt6LEMLruh+mIilcFVlIuEYSOqpcr7lNCml2dnqyZcSYq1Yvz5XswOC34P71vzNA5qPt2GByWmzPM3YR58fFIAkscT8zfsWng16V4VLIt2JEPwSZWcXFnPKst2UMTbTK2UgkdYsUKUMm3Rui1h78aawiA/yc= 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 1644854330597950.1125101231689; Mon, 14 Feb 2022 07:58:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-NHJaxvGyOjyCs5co5nitNg-1; Mon, 14 Feb 2022 10:58:41 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D02FF189DF5E; Mon, 14 Feb 2022 15:58:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AFB932B6ED; Mon, 14 Feb 2022 15:58:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7C1681806D1D; Mon, 14 Feb 2022 15:58:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21EFwJAb021486 for ; Mon, 14 Feb 2022 10:58:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A46D27CAC; Mon, 14 Feb 2022 15:58:19 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF313108C7 for ; Mon, 14 Feb 2022 15:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644854330; 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=JlN2E5Pi+emHLdpcO58j5/eu0B3Ukl7JKYibYLRLFa8=; b=RiCiHEHsjyXu03ZjqFIJHyO8OJSVkeu1O2I/tqwQQxCAq59jCq5TdPOgPXftiEIiw7yjij HMG5Gin2O49W5pm0yXOYr6GfO99buEQDTUjv3T+4lQZE4f8AoHHXRG3sPb9epo5KHs1NIL ScqFKSgBN2WE4HRxUYV9JgRhz9wIezY= X-MC-Unique: NHJaxvGyOjyCs5co5nitNg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/6] qemuhotplugtest: Assume QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE Date: Mon, 14 Feb 2022 16:58:07 +0100 Message-Id: <9d09980b47b90eaec58f92770bb9547060d10e9b.1644854180.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1644854341684100001 Content-Type: text/plain; charset="utf-8" All modern QEMU versions use FD passing for listening unix sockets so the test should reflect this. This will later help when removing the legacy code paths when we drop support for old QEMUs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemuhotplugtest.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index ce215da099..eb7f5ed961 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -95,6 +95,7 @@ qemuHotplugCreateObjects(virDomainXMLOption *xmlopt, virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_SCSI_BLOCK); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_KBD); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_NETDEV_VHOST_VDPA); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE); if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0) return -1; @@ -764,6 +765,7 @@ mymain(void) "object-del", QMP_OK); DO_TEST_ATTACH("base-live", "qemu-agent", false, true, + "getfd", QMP_OK, "chardev-add", QMP_OK, "device_add", QMP_OK); DO_TEST_DETACH("base-live", "qemu-agent-detach", false, false, @@ -856,6 +858,7 @@ mymain(void) "device_del", QMP_DEVICE_DELETED("ua-UserWatchdog") QMP= _OK); DO_TEST_ATTACH("base-live", "guestfwd", false, true, + "getfd", QMP_OK, "chardev-add", QMP_OK, "netdev_add", QMP_OK); DO_TEST_DETACH("base-live", "guestfwd", false, false, --=20 2.34.1