From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422569; cv=none; d=zohomail.com; s=zohoarc; b=ACHTKzeCnotyTIawNqfbACyAQgCZ+5IaBksXMzZlrKKAoATybybVMx2VWF2VA254GkTYwuf0zQBHn0jmjcpBZorSpojNIkIYCdRScLxc2ONP/x9/cSTaJQYErRFsgYa+naoGwAzhYREOEi9k3GM3iNZkFGtoxY+rFc62dkynEdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422569; 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=oQeMLbGlMb9YruoNZnD4yx42TijivH7cybPvE+0A/V8=; b=GYggfHJnfZKh66DuADwOBWJ98VG/I4jCL+g381ux1JjGXGsBmYZUk1ocYg8xTEV4mSYepo/MEWxXuZyfC9D+SJxr0nfwSebSoqQu6SaIXrTlYCv1uhlvIK4zVdPAIiggdVeWdztxYetFk8XNmfd+iJ68uJgwscZgoQR5hChZV1w= 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 1644422569213397.69974035837276; Wed, 9 Feb 2022 08:02:49 -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-56-zpE3M48TMmKrWk_n00sWVA-1; Wed, 09 Feb 2022 11:02:45 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10CEF344DC; Wed, 9 Feb 2022 16:02:40 +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 5A66284A2C; Wed, 9 Feb 2022 16:02:38 +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 5291F4CA9B; Wed, 9 Feb 2022 16:02:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2YwM012215 for ; Wed, 9 Feb 2022 11:02:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8793A7DE52; Wed, 9 Feb 2022 16:02:34 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id C97007DE4D for ; Wed, 9 Feb 2022 16:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422566; 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=oQeMLbGlMb9YruoNZnD4yx42TijivH7cybPvE+0A/V8=; b=S/weyjcV316Q762uyf2C7wunaDPZqYr5rsi5G0SXed9M0SsI6LT0W3fqHl0lAOVwY+t1Gv usaTiLsdKbphTQm03mM66D4LFt7SW/E0LF/nzNwsv0lzPeFx1qzBKbDAtc35f4LKhP8B0M YKfIi/cn/D+9Qht/7gYV5wqP1ZcPY0I= X-MC-Unique: zpE3M48TMmKrWk_n00sWVA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/27] scripts/moc-noinline: Use full name of the required annotation in error message Date: Wed, 9 Feb 2022 17:01:53 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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: 1644422571931100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- scripts/mock-noinline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mock-noinline.py b/scripts/mock-noinline.py index 69cf0b4b99..712550cb7a 100644 --- a/scripts/mock-noinline.py +++ b/scripts/mock-noinline.py @@ -73,7 +73,7 @@ warned =3D False for func in mocked.keys(): if func not in noninlined: warned =3D True - print("%s is mocked at %s but missing noinline annotation" % + print("%s is mocked at %s but missing 'G_GNUC_NO_INLINE' annotatio= n" % (func, mocked[func]), file=3Dsys.stderr) if warned: --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422582; cv=none; d=zohomail.com; s=zohoarc; b=UHaz6eWu2Z4MzYu4YHabcAHbsogQIZqUHMIDOhfDcFfSAHVCOFKcrXxAzwFwaT1rQ28o7cjodlH+fbROWZvTJkcA9zcXE9lvGmGy9nevyAoZy0hdMFHTndmPJzkrBCkw73Cv1GdF55T8eEByi/4KT9+zmotAnmGAJtTdmRvkXuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422582; 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=GLImDwq03ouHPnp/nWoB9am2ZsslPxX8VHU0UFcUs0U=; b=aWXVU9zP2FSmy6bigoX/rbTZWQVX+LK8ayC8mt2acy2XrPxiF/7mBXa7dKQBYmQOGdCIjgxIoCMlh+h+gcRfIglWWk5I1UlpYBaRFV9jHwvi0FlFAzsPevhR+WINT190ddQC/cnowgt1IoJ8bXInC9soiKcXrHmJdhQP1jxwCGI= 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 1644422582802124.2732580100917; Wed, 9 Feb 2022 08:03:02 -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-615-Je0kwpn7Mha4yR8HqGRTdQ-1; Wed, 09 Feb 2022 11:02:45 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD4CD1091DA7; Wed, 9 Feb 2022 16:02:38 +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 52B3584729; Wed, 9 Feb 2022 16:02:38 +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 A965A1809CB8; Wed, 9 Feb 2022 16:02:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2Zud012222 for ; Wed, 9 Feb 2022 11:02:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8CE097DE42; Wed, 9 Feb 2022 16:02:35 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF80E7DE4B for ; Wed, 9 Feb 2022 16:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422582; 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=GLImDwq03ouHPnp/nWoB9am2ZsslPxX8VHU0UFcUs0U=; b=h7DFGakA9MhSX8h41VVBJoK36C58QlMoJShE5Dc6REvXTKS9o6vgX0kVdpKGkPlWyI1/sC g+8A+QdM0iQutPi0x3pRCPOxgld9PuI67LWGinCrrJtlfG4XDe0wIupiOQlp0OUYFjuXQ+ 3CU5Dre5zjZ6EMGty0N1OOYAdHTAhTI= X-MC-Unique: Je0kwpn7Mha4yR8HqGRTdQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/27] qemuProcessPrepareHostBackendChardevFileHelper: Always use FD passing Date: Wed, 9 Feb 2022 17:01:54 +0100 Message-Id: <359956c179b4acf9b2f8b2ba932f889d4cbd39f3.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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: 1644422589407100005 Content-Type: text/plain; charset="utf-8" Code paths which don't wish to use FD passing are supposed to not call the function which sets up the chardev for FD passing. This is ensured by calling it only in the host prepare step. Signed-off-by: Peter Krempa --- src/qemu/qemu_process.c | 11 ----------- tests/qemuxml2argvdata/aarch64-pci-serial.args | 3 ++- .../name-escape.x86_64-2.11.0.args | 3 ++- tests/qemuxml2argvdata/serial-file-chardev.args | 3 ++- tests/qemuxml2argvdata/serial-file-log.args | 4 +++- tests/qemuxml2argvdata/serial-many-chardev.args | 3 ++- tests/qemuxml2argvtest.c | 16 ++++++---------- 7 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 24873f6fb7..169d9d1755 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6758,18 +6758,9 @@ qemuProcessPrepareHostBackendChardevFileHelper(const= char *path, int *fd, virLogManager *logManager, virSecurityManager *secMana= ger, - virQEMUCaps *qemuCaps, virQEMUDriverConfig *cfg, const virDomainDef *def) { - /* Technically, to pass an FD via /dev/fdset we don't need - * any capability check because X_QEMU_CAPS_ADD_FD is already - * assumed. But keeping the old style is still handy when - * building a standalone command line (e.g. for tests). */ - if (!logManager && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE)) - return 0; - if (logManager) { int flags =3D 0; @@ -6867,7 +6858,6 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDevi= ceDef *dev, &charpriv->fd, data->logManage= r, data->secManage= r, - data->qemuCaps, data->cfg, data->def) < 0) return -1; @@ -6908,7 +6898,6 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDevi= ceDef *dev, &charpriv->logf= d, data->logManage= r, data->secManage= r, - data->qemuCaps, data->cfg, data->def) < 0) return -1; diff --git a/tests/qemuxml2argvdata/aarch64-pci-serial.args b/tests/qemuxml= 2argvdata/aarch64-pci-serial.args index b4f84cf778..aca88e8e60 100644 --- a/tests/qemuxml2argvdata/aarch64-pci-serial.args +++ b/tests/qemuxml2argvdata/aarch64-pci-serial.args @@ -29,6 +29,7 @@ QEMU_AUDIO_DRV=3Dnone \ -device i82801b11-bridge,id=3Dpci.1,bus=3Dpcie.0,addr=3D0x1 \ -device pci-bridge,chassis_nr=3D2,id=3Dpci.2,bus=3Dpci.1,addr=3D0x0 \ -device pcie-root-port,port=3D16,chassis=3D3,id=3Dpci.3,bus=3Dpcie.0,addr= =3D0x2 \ --chardev pty,id=3Dcharserial0,logfile=3D/tmp/log,logappend=3Don \ +-add-fd set=3D0,fd=3D1751 \ +-chardev pty,id=3Dcharserial0,logfile=3D/dev/fdset/0,logappend=3Don \ -device pci-serial,chardev=3Dcharserial0,id=3Dserial0,bus=3Dpci.2,addr=3D0= x1 \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args b/tests/= qemuxml2argvdata/name-escape.x86_64-2.11.0.args index a246c08b12..6d4c5bff6e 100644 --- a/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args +++ b/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args @@ -33,7 +33,8 @@ QEMU_AUDIO_DRV=3Dspice \ -device ccid-card-emulated,backend=3Dcertificates,cert1=3Dcert1,,foo,cert2= =3Dcert2,cert3=3Dcert3,db=3D/etc/pki/nssdb,,foo,id=3Dsmartcard0,bus=3Dccid0= .0 \ -chardev tty,id=3Dcharserial0,path=3D/dev/ttyS2,,foo \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0,index=3D1 \ --chardev file,id=3Dcharserial1,path=3D/tmp/serial.log,,foo,append=3Don \ +-add-fd set=3D0,fd=3D1750 \ +-chardev file,id=3Dcharserial1,path=3D/dev/fdset/0,append=3Don \ -device isa-serial,chardev=3Dcharserial1,id=3Dserial1,index=3D0 \ -chardev pipe,id=3Dcharchannel0,path=3D/tmp/guestfwd,,foo \ -netdev user,guestfwd=3Dtcp:10.0.2.1:4600-chardev:charchannel0,id=3Dchanne= l0 \ diff --git a/tests/qemuxml2argvdata/serial-file-chardev.args b/tests/qemuxm= l2argvdata/serial-file-chardev.args index 4ec07d9b1f..7df5c2a115 100644 --- a/tests/qemuxml2argvdata/serial-file-chardev.args +++ b/tests/qemuxml2argvdata/serial-file-chardev.args @@ -29,7 +29,8 @@ QEMU_AUDIO_DRV=3Dnone \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --chardev file,id=3Dcharserial0,path=3D/tmp/serial.log,append=3Don \ +-add-fd set=3D0,fd=3D1750 \ +-chardev file,id=3Dcharserial0,path=3D/dev/fdset/0,append=3Don \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0,index=3D0 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/serial-file-log.args b/tests/qemuxml2ar= gvdata/serial-file-log.args index 1ffa30d207..72d7c49298 100644 --- a/tests/qemuxml2argvdata/serial-file-log.args +++ b/tests/qemuxml2argvdata/serial-file-log.args @@ -29,6 +29,8 @@ QEMU_AUDIO_DRV=3Dnone \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --chardev file,id=3Dcharserial0,path=3D/tmp/serial.log,logfile=3D/var/lib/l= ibvirt/qemu/demo-serial.log,logappend=3Doff \ +-add-fd set=3D0,fd=3D1750 \ +-add-fd set=3D1,fd=3D1751 \ +-chardev file,id=3Dcharserial0,path=3D/dev/fdset/0,append=3Don,logfile=3D/= dev/fdset/1,logappend=3Don \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0,index=3D0 \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/serial-many-chardev.args b/tests/qemuxm= l2argvdata/serial-many-chardev.args index e0005656ea..5e80348d11 100644 --- a/tests/qemuxml2argvdata/serial-many-chardev.args +++ b/tests/qemuxml2argvdata/serial-many-chardev.args @@ -31,7 +31,8 @@ QEMU_AUDIO_DRV=3Dnone \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ -chardev pty,id=3Dcharserial0 \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0,index=3D0 \ --chardev file,id=3Dcharserial1,path=3D/tmp/serial.log \ +-add-fd set=3D0,fd=3D1750 \ +-chardev file,id=3Dcharserial1,path=3D/dev/fdset/0,append=3Don \ -device isa-serial,chardev=3Dcharserial1,id=3Dserial1,index=3D1 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6cf35a0ebf..b2d6606d6e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -416,11 +416,9 @@ testPrepareHostBackendChardevOne(virDomainDeviceDef *d= ev, break; case VIR_DOMAIN_CHR_TYPE_FILE: - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE= )) { - if (fcntl(1750, F_GETFD) !=3D -1) - abort(); - charpriv->fd =3D 1750; - } + if (fcntl(1750, F_GETFD) !=3D -1) + abort(); + charpriv->fd =3D 1750; break; case VIR_DOMAIN_CHR_TYPE_UNIX: @@ -440,11 +438,9 @@ testPrepareHostBackendChardevOne(virDomainDeviceDef *d= ev, } if (chardev->logfile) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE= )) { - if (fcntl(1751, F_GETFD) !=3D -1) - abort(); - charpriv->logfd =3D 1751; - } + if (fcntl(1751, F_GETFD) !=3D -1) + abort(); + charpriv->logfd =3D 1751; } return 0; --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422588; cv=none; d=zohomail.com; s=zohoarc; b=j4qoDnz4/TRDkwMpGSt2MifHMsG22iXAHnKU0+ytQZVshVH03nurloZAgnN50ZmcZmdc6t8gCkyF+w5zMS4Ay83K7z9gzO7r+p2GSmdttg0dOSpv7Sn/OjEJdqwTsctpFeU4GypOw3DbtO4sfi/mV1KLec+EfazdCcGlO6z/mgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422588; 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=/AXxql+hmV63situG60Ltcj/mhqLniN5Q4f1Rk8gYGs=; b=j7W2B9CQAKcQWvmndQv+0hadR5znxiDxlMxM0kV4lb/89kcFwdS8PnKLFI+1kQN7L51XYjzoYJJhq/vlKu4aQdReT+vlion8tioLBdmcJgjLywsqMWJPnH1w8UD+Bizi6N34bwsdytaQsvMOmSoTfQNPsIp8m2ZXtixy8zORg6M= 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 1644422588850678.5219081337667; Wed, 9 Feb 2022 08:03:08 -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-156-PGnNIBioNzCFm0m8d25hBg-1; Wed, 09 Feb 2022 11:03:07 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8BDF184B9AF; Wed, 9 Feb 2022 16:02:57 +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 3284E84A29; Wed, 9 Feb 2022 16:02:57 +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 EA6581802E34; Wed, 9 Feb 2022 16:02:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2ar1012232 for ; Wed, 9 Feb 2022 11:02:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9820F7DE40; Wed, 9 Feb 2022 16:02:36 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECA607DE4B for ; Wed, 9 Feb 2022 16:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422588; 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=/AXxql+hmV63situG60Ltcj/mhqLniN5Q4f1Rk8gYGs=; b=WvFjD3ufvrhcpAWArkvsK+u502OotqB7fa0ukDJ23yBCdQh4/+R44bsn0BpATn/XvcVY7B SQUpXUFcvclG9PgWpNbacpvpZqg0XS1J9Mgo8pQ8j8wZJZs2jUpbZmx0M/9CPBpGnp2sFH rMrQ8qbEjJfexO6eH7EH2mZ4X1dGfHg= X-MC-Unique: PGnNIBioNzCFm0m8d25hBg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/27] qemuProcessPrepareHostBackendChardev: Drop unneeded arguments Date: Wed, 9 Feb 2022 17:01:55 +0100 Message-Id: <790789743bebee7d365ff45018c5b4591be57966.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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: 1644422591957100011 Content-Type: text/plain; charset="utf-8" Caller passes 'driver->securityManager', and 'priv->qemuCaps' as arguments along with 'vm', but both aforementioned objects are accessible directly from 'vm'. Signed-off-by: Peter Krempa --- src/qemu/qemu_process.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 169d9d1755..0e17e1bf94 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6805,9 +6805,8 @@ qemuProcessPrepareHostBackendChardevFileHelper(const = char *path, struct qemuProcessPrepareHostBackendChardevData { - virQEMUCaps *qemuCaps; + qemuDomainObjPrivate *priv; virLogManager *logManager; - virSecurityManager *secManager; virQEMUDriverConfig *cfg; virDomainDef *def; }; @@ -6857,7 +6856,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDevi= ceDef *dev, chardev->data.f= ile.append, &charpriv->fd, data->logManage= r, - data->secManage= r, + data->priv->dri= ver->securityManager, data->cfg, data->def) < 0) return -1; @@ -6866,14 +6865,14 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDe= viceDef *dev, case VIR_DOMAIN_CHR_TYPE_UNIX: if (chardev->data.nix.listen && - virQEMUCapsGet(data->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMA= NDLINE)) { + virQEMUCapsGet(data->priv->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS= _COMMANDLINE)) { - if (qemuSecuritySetSocketLabel(data->secManager, data->def) < = 0) + if (qemuSecuritySetSocketLabel(data->priv->driver->securityMan= ager, data->def) < 0) return -1; charpriv->fd =3D qemuOpenChrChardevUNIXSocket(chardev); - if (qemuSecurityClearSocketLabel(data->secManager, data->def) = < 0) { + if (qemuSecurityClearSocketLabel(data->priv->driver->securityM= anager, data->def) < 0) { VIR_FORCE_CLOSE(charpriv->fd); return -1; } @@ -6897,7 +6896,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDevi= ceDef *dev, chardev->logapp= end, &charpriv->logf= d, data->logManage= r, - data->secManage= r, + data->priv->dri= ver->securityManager, data->cfg, data->def) < 0) return -1; @@ -6911,16 +6910,13 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDe= viceDef *dev, * serial/parallel/channel chardevs, vhost-user disks, vhost-user network * interfaces, smartcards, shared memory, and redirdevs */ static int -qemuProcessPrepareHostBackendChardev(virDomainObj *vm, - virQEMUCaps *qemuCaps, - virSecurityManager *secManager) +qemuProcessPrepareHostBackendChardev(virDomainObj *vm) { qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv->dr= iver); struct qemuProcessPrepareHostBackendChardevData data =3D { - .qemuCaps =3D qemuCaps, + .priv =3D priv, .logManager =3D NULL, - .secManager =3D secManager, .cfg =3D cfg, .def =3D vm->def, }; @@ -6998,9 +6994,7 @@ qemuProcessPrepareHost(virQEMUDriver *driver, return -1; VIR_DEBUG("Preparing chr device backends"); - if (qemuProcessPrepareHostBackendChardev(vm, - priv->qemuCaps, - driver->securityManager) < 0) + if (qemuProcessPrepareHostBackendChardev(vm) < 0) return -1; if (qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, true) < 0) --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422587; cv=none; d=zohomail.com; s=zohoarc; b=KVI2TfOTnSjQPkrSFSMKbGO3oQxVY3SdEzm2oZwvS9IH9gv/V70lDh7YD48Yw4eaPvDl42Rjqi7hFB/4QXTIs50Ya2yy7Ivu7PDgUcQzfEgdXncfzVnEqJUjgNVqlmvsO9NzjFaPo6kd5O6nU6/y50Y8oHq/yjPW6JEHSWDKkbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422587; 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=SbputVpnnoKWGd6xWBqQCPoAY+m0P+V4FA0QN4lcqxM=; b=d9Al8JRC7hv2zln9xfW/cf+6KvMjRlCxdYI1tzOP7/vpm9YvNj8AsoakrtHfy5PxOVgizJCkmhP/mgmrortT2wagDx1IfqvuPQh9AqLNgYjZVs+CfCR2ftf4cfQKYpDFQj7mb//zSt0TMfku4Rf1+ah+4ULgyuUK2NSGqMaxbBQ= 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 1644422587573739.8577896082033; Wed, 9 Feb 2022 08:03:07 -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-321-11Attoo7N1qzfGd_7Sd59g-1; Wed, 09 Feb 2022 11:03:04 -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 AAE3B363BF; Wed, 9 Feb 2022 16:02:56 +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 595612B6EB; Wed, 9 Feb 2022 16:02:56 +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 2545E4A7CB; Wed, 9 Feb 2022 16:02:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2b0S012242 for ; Wed, 9 Feb 2022 11:02:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id A05707DE4A; Wed, 9 Feb 2022 16:02:37 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CF857DE40 for ; Wed, 9 Feb 2022 16:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422586; 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=SbputVpnnoKWGd6xWBqQCPoAY+m0P+V4FA0QN4lcqxM=; b=TRwtQ9nFGSLTM3jdXhVk+goCYMXZAnzUfQ95Slxyep7kk7D8IqFqAJfLmhL5kFuIQfY8Rc sHbg7unLNUXsBWQ6+j0fcu1UXRtG2KoZOHKu3pLlbKEwp1E+RqyR5nl1HVT1x4Esyz+HB5 xMCHAsOBVgWP1m1KRha+0mvvZbWbBkY= X-MC-Unique: 11Attoo7N1qzfGd_7Sd59g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/27] qemuMonitorJSONQueryFdsetsParse: Don't check value passed to g_strdup Date: Wed, 9 Feb 2022 17:01:56 +0100 Message-Id: <6cc6a133136ed8d672f509bfc7f13b51668d98cc.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422591532100008 Content-Type: text/plain; charset="utf-8" 'g_strdup()' is NULL-tolerant. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor_json.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8e1501d91f..69ecc8a2d1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3695,7 +3695,6 @@ qemuMonitorJSONQueryFdsetsParse(virJSONValue *msg, for (i =3D 0; i < ninfo; i++) { size_t j; - const char *tmp; virJSONValue *fdarray; qemuMonitorFdsetInfo *fdsetinfo =3D &sets->fdsets[i]; @@ -3734,9 +3733,7 @@ qemuMonitorJSONQueryFdsetsParse(virJSONValue *msg, } /* opaque is optional and may be missing */ - tmp =3D virJSONValueObjectGetString(fdentry, "opaque"); - if (tmp) - fdinfo->opaque =3D g_strdup(tmp); + fdinfo->opaque =3D g_strdup(virJSONValueObjectGetString(fdentr= y, "opaque")); } } --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422595; cv=none; d=zohomail.com; s=zohoarc; b=eK5qSMcEpw8Edw/1zR2Mx4nUILiJTS6T/MVnSr3Gha2pCNb4sQGu/JFYteOD7iCnU5V8sVDhNAtNbwWEUHTNvAT/O1howhikuuxRDh2VMI3hfCNBREujATQ1R2fyUdYW8AlmBShJgLO6j40N8OvvAM0mfw5RM/fdPac0JuK7h3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422595; 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=7I8Peg9LPt/S3ZLsn5BnQ0/iHWLev2BEktVa6WgIbGo=; b=me31qIuJVnQgpoUO/rnWJN4qRSCarGnuR0kdsXxuG00iU1OwKyOKLLuy+f5oBIuz7Nf9Q1dnziNS2+CVdjF1gwo5nahS3eg4+T7YvqDm/aJ0Muwcpr3A5GOgX8QbgCi1TqjZpKhw/J7utGSn6cE8f9ez9+siSNg7tcHnq1z3eAU= 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 1644422595729978.2925644969736; Wed, 9 Feb 2022 08:03:15 -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-498-wtgF9MbJP_m5U557x0Fqdg-1; Wed, 09 Feb 2022 11:03:08 -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 04636193249A; Wed, 9 Feb 2022 16:03:00 +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 D58B42BCC0; Wed, 9 Feb 2022 16:02:59 +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 2C67F1806D1D; Wed, 9 Feb 2022 16:02:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2cQo012247 for ; Wed, 9 Feb 2022 11:02:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id B42F77DE49; Wed, 9 Feb 2022 16:02:38 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1777F7DE42 for ; Wed, 9 Feb 2022 16:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422591; 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=7I8Peg9LPt/S3ZLsn5BnQ0/iHWLev2BEktVa6WgIbGo=; b=I9WrCOxf8W8LsZ2XnhD9pYD78EHoU4TtjxAcOAYUUUS9OK8BRlzF6fVock0kz+bIzxt2vA tprv4i73s1FnISXhwZAiDONffc+zXqNuQ5iCNjJgKKXA/bc4ADCTNFjQBdvbXsVgkr7mP7 1u1mB+NgJn+zuyL01s9o/bJ3baaCwbE= X-MC-Unique: wtgF9MbJP_m5U557x0Fqdg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/27] qemuMonitorRemoveFdset: Convert @fdset to unsigned int to avoid error Date: Wed, 9 Feb 2022 17:01:57 +0100 Message-Id: <6a1a5a317819637db7a2024a7e2d2f9fca1482b6.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422598337100002 Content-Type: text/plain; charset="utf-8" 'qemuMonitorRemoveFdset' validatest that the 'fdset' argument isn't less than 0. We can turn it to unsigned and thus avoid the error message completely. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 14 ++++---------- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 4 ++-- src/qemu/qemu_monitor_json.h | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fcd39b80c6..7915729cbb 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2556,24 +2556,18 @@ qemuMonitorAddFileHandleToSet(qemuMonitor *mon, /** * qemuMonitorRemoveFdset: * @mon: monitor object - * @fdset: the fdset to remove + * @fdset: id of the fdset to remove * - * Attempts to remove a fdset from qemu and close associated file descript= ors + * Attempts to remove @fdset from qemu and close associated file descripto= rs * Returns 0 if ok, and -1 on failure */ int qemuMonitorRemoveFdset(qemuMonitor *mon, - int fdset) + unsigned int fdset) { - VIR_DEBUG("fdset=3D%d", fdset); + VIR_DEBUG("fdset=3D%u", fdset); QEMU_CHECK_MONITOR(mon); - if (fdset < 0) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("fdset must be valid")); - return -1; - } - return qemuMonitorJSONRemoveFdset(mon, fdset); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index efc4721ea9..27e288c724 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -974,7 +974,7 @@ qemuMonitorAddFileHandleToSet(qemuMonitor *mon, int qemuMonitorRemoveFdset(qemuMonitor *mon, - int fdset); + unsigned int fdset); typedef struct _qemuMonitorFdsetFdInfo qemuMonitorFdsetFdInfo; struct _qemuMonitorFdsetFdInfo { diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 69ecc8a2d1..acecdc3943 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3766,11 +3766,11 @@ int qemuMonitorJSONQueryFdsets(qemuMonitor *mon, int qemuMonitorJSONRemoveFdset(qemuMonitor *mon, - int fdset) + unsigned int fdset) { g_autoptr(virJSONValue) reply =3D NULL; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("remove-fd", - "i:fdset-id",= fdset, + "u:fdset-id",= fdset, NULL); if (!cmd) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 309d1fb409..eea3478af0 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -257,7 +257,7 @@ qemuMonitorJSONAddFileHandleToSet(qemuMonitor *mon, int qemuMonitorJSONRemoveFdset(qemuMonitor *mon, - int fdset); + unsigned int fdset); int qemuMonitorJSONQueryFdsets(qemuMonitor *mon, --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422596; cv=none; d=zohomail.com; s=zohoarc; b=ZAZr9wZ2H+OXqmYFWk3A/2EdvcWQZpssoexWvXpd5Ba3SHVRN59g55OQFah20YRVcJyeVgEXvjfWwMKagpcuCGRgpW0Bm0c3DjD3ektP2wpaRy0XYYzccVkcRWjyxEBqoKZeGn5XTVCr4tHgMxyhqVnPGT7Kt61P9znA3XQlyRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422596; 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=dnEzkcGfsXfXGXSQL06qOFrc83dbMt4moTtGtoD4daA=; b=MTYe2biYtowbSFweamkHHt+tWr/qnkW91xi/zqTB0rd801J3Q/Yl//5FYcVoaMCtThgsCBXfZqNf3rvPr7Q7BGexCsZf3kFJnurLQuvm/zsA7qKV4Gt0TgwmjsUqSmZRA9ht6yYkOV5cDEtqSce7vBt//2UFWIjlRQcNMkZlOMU= 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 1644422596567520.6969031096489; Wed, 9 Feb 2022 08:03:16 -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-78-ESbEzyeuOdWoVc94YJ4lYg-1; Wed, 09 Feb 2022 11:03:09 -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 2AB3463ACF; Wed, 9 Feb 2022 16:03:00 +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 0518E2BCDA; Wed, 9 Feb 2022 16:03:00 +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 B8E371806D2E; Wed, 9 Feb 2022 16:02:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2d8E012262 for ; Wed, 9 Feb 2022 11:02:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id C14907DE40; Wed, 9 Feb 2022 16:02:39 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ED767DE57 for ; Wed, 9 Feb 2022 16:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422595; 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=dnEzkcGfsXfXGXSQL06qOFrc83dbMt4moTtGtoD4daA=; b=Wn761rLjT8oergqO1ccsBo8jJURuiJ9EC/rLvydJiCHj6w4qRaRm4KEmVQG2YCHbpsCBlC 5PSdQGXJxrM9vpRQM6yl4iFGE+IBcOuyZ/UxFl7E4A9nUwsfAMdwe8swyTYNVHnW2555eX CvyUM2NAREVhWSygs+vcGiOtCwupe0M= X-MC-Unique: ESbEzyeuOdWoVc94YJ4lYg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/27] qemu: monitor: Make 'id' in 'struct _qemuMonitorFdsetInfo' unsigned Date: Wed, 9 Feb 2022 17:01:58 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422598305100001 Content-Type: text/plain; charset="utf-8" Similarly to the 'qemuMonitorRemoveFdset', it doesn't make sense to store it as signed when only unsigned values are expected. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 27e288c724..4c22394972 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -983,7 +983,7 @@ struct _qemuMonitorFdsetFdInfo { }; typedef struct _qemuMonitorFdsetInfo qemuMonitorFdsetInfo; struct _qemuMonitorFdsetInfo { - int id; + unsigned int id; qemuMonitorFdsetFdInfo *fds; int nfds; }; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index acecdc3943..e5425daf05 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3704,7 +3704,7 @@ qemuMonitorJSONQueryFdsetsParse(virJSONValue *msg, return -1; } - if (virJSONValueObjectGetNumberInt(entry, "fdset-id", &fdsetinfo->= id) < 0) { + if (virJSONValueObjectGetNumberUint(entry, "fdset-id", &fdsetinfo-= >id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-fdsets reply was missing 'fdset-id'")); return -1; --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422587; cv=none; d=zohomail.com; s=zohoarc; b=V+rlJRXQCRLFUoLxc+/pgKnh8h/zG6c0C+V7Z7Q+DTutmtS15ZX0W3zXOQW3wN8pfwlmvR0wKSnqZW4j1Dr+aTDDY6tdOzYQcu6nM4qZO6tYycEfxW24DbLxBFg+MaVWBiZ6/c5ZEVf03EKKXSp/NO03H2zGcXOZCGrgYPlbj4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422587; 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=QqoQ7lhvV+6ebYlOoUFmlk7rXZ8BolNWIVeom0q1wCE=; b=T4/kvYlORgkRw/dl8oEKcOvkK2xa5IrG5B1H34jKBLhv8H4InKO0cECLnkofYTn2h1qBqDPHepbDTXfYf1fTToTzDUHP048RLAljuBAhF7kJCQ3RpAxeszVhAYyAKDixxXnnrS1AAip4QDVdHi2uiR/gDJaSaVR7nzC9CIXSh3w= 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 1644422587089392.89858983074555; Wed, 9 Feb 2022 08:03:07 -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-54-AY4ImpE4MUSk9smlTLDQeQ-1; Wed, 09 Feb 2022 11:03:04 -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 4876C1050444; Wed, 9 Feb 2022 16:02:57 +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 282181091EE9; Wed, 9 Feb 2022 16:02:57 +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 ED92318077BC; Wed, 9 Feb 2022 16:02:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2eTe012270 for ; Wed, 9 Feb 2022 11:02:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id CAD757DE40; Wed, 9 Feb 2022 16:02:40 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EFE57DE42 for ; Wed, 9 Feb 2022 16:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422586; 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=QqoQ7lhvV+6ebYlOoUFmlk7rXZ8BolNWIVeom0q1wCE=; b=CE9dDpw7vR63QwxIFv0P8kw6JfBvjK1B0d+rR1iaSKniTedjjcOKr2rInk5sRT/tQG88QT KGYm8OOJb+c7aHcCbfStkchOMGSQQXiCErsCgPoVqykKmyV61Caup/gcVL18UG00iC3ztD dQs7c3rs3gBRaPpy6t+R1197BNTzIHM= X-MC-Unique: AY4ImpE4MUSk9smlTLDQeQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/27] qemu: domain: Move and unexport 'qemuDomainStorageIdReset' Date: Wed, 9 Feb 2022 17:01:59 +0100 Message-Id: <20d8dec2c91d5121a188381f611cbcfd200eaeb2.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422591494100007 Content-Type: text/plain; charset="utf-8" It's used only inside qemu_domain.c. Move it before it's usage, along with the qemuDomainStorageIdNew counterpart and unexport it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 54 +++++++++++++++++++++--------------------- src/qemu/qemu_domain.h | 1 - 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c764f6296c..64be39d49f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -656,6 +656,33 @@ qemuDomainMasterKeyCreate(virDomainObj *vm) } +/** + * qemuDomainStorageIdNew: + * @priv: qemu VM private data object. + * + * Generate a new unique id for a storage object. Useful for node name gen= eration. + */ +unsigned int +qemuDomainStorageIdNew(qemuDomainObjPrivate *priv) +{ + return ++priv->nodenameindex; +} + + +/** + * qemuDomainStorageIdReset: + * @priv: qemu VM private data object. + * + * Resets the data for the node name generator. The node names need to be = unique + * for a single instance, so can be reset on VM shutdown. + */ +static void +qemuDomainStorageIdReset(qemuDomainObjPrivate *priv) +{ + priv->nodenameindex =3D 0; +} + + static void qemuDomainSecretInfoClear(qemuDomainSecretInfo *secinfo, bool keepAlias) @@ -10889,33 +10916,6 @@ qemuDomainGetManagedPRSocketPath(qemuDomainObjPriv= ate *priv) } -/** - * qemuDomainStorageIdNew: - * @priv: qemu VM private data object. - * - * Generate a new unique id for a storage object. Useful for node name gen= eration. - */ -unsigned int -qemuDomainStorageIdNew(qemuDomainObjPrivate *priv) -{ - return ++priv->nodenameindex; -} - - -/** - * qemuDomainStorageIdReset: - * @priv: qemu VM private data object. - * - * Resets the data for the node name generator. The node names need to be = unique - * for a single instance, so can be reset on VM shutdown. - */ -void -qemuDomainStorageIdReset(qemuDomainObjPrivate *priv) -{ - priv->nodenameindex =3D 0; -} - - virDomainEventResumedDetailType qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 8bf1c91049..7ec337e9ae 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -970,7 +970,6 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPr= ivate *priv); bool qemuDomainDefHasManagedPR(virDomainObj *vm); unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivate *priv); -void qemuDomainStorageIdReset(qemuDomainObjPrivate *priv); virDomainEventResumedDetailType qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason); --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422718; cv=none; d=zohomail.com; s=zohoarc; b=DhUSoOG6PQQJee0RC53JwO/cQwhQis+k3mTWcqcsp/BRbfJnyz8ek7Ea3c+fbGcdyf6itc7jOzGbdZjswERaDqE85kvq2hp94KMxXpTfQPeawMOkUyuQ/BAkNm5HXyugohb+66ZO4+Z1sfkWE2KrT5nentU6Vv0Y8yrobPRNXbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422718; 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=Wm7FrGVImJ4G8WfPx6n0eSWfJXFysN+ano23/nnapLI=; b=LwE4UnYUa/wQu2/Rf4aIrNKAhicO7qbXpdvnpPoE0ugfArPiun0lW/sFeI6sPkzFcx0J8szrgYweWW6E7nsM4LBQDilX3pnu4VSyi6eyNYKoUDbffZ1P1IgfGDMM4h5e+UNzmdLFh9ZHQWz1QShlGV3ktN2TXoAxl+P+rznZUTA= 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 1644422718174988.8448024441165; Wed, 9 Feb 2022 08:05:18 -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-496-iBqVz1DtOJS8eXHq5msXww-1; Wed, 09 Feb 2022 11:03:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0B5683DE6D; Wed, 9 Feb 2022 16:03:05 +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 8BDF37DE40; Wed, 9 Feb 2022 16:03:05 +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 581581802FE9; Wed, 9 Feb 2022 16:03:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2fAS012277 for ; Wed, 9 Feb 2022 11:02:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id DF8AE7DE42; Wed, 9 Feb 2022 16:02:41 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 500367DE40 for ; Wed, 9 Feb 2022 16:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422717; 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=Wm7FrGVImJ4G8WfPx6n0eSWfJXFysN+ano23/nnapLI=; b=HlL3j/sGo5okV3DfLnYgCXgKLgPGUF8T1t+ASstMTltIJvwa+GBG1esTxwDPNMfunJ7Cxm Gg0WJLcLc0sTgdgrlezZVs3zhG3a20qjtRxtkeMQ15w0gGT2r12+tiyp+DMOCS2Q+7JqF/ SKckH/X8ragDv21uhrS1z8LRDRFrrKI= X-MC-Unique: iBqVz1DtOJS8eXHq5msXww-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/27] qemu: domain: Add helper for generating 'fdset' ids for VM startup Date: Wed, 9 Feb 2022 17:02:00 +0100 Message-Id: <4038fc826722f1be992f1dc77070ea6a0a7104f4.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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: 1644422719974100003 Content-Type: text/plain; charset="utf-8" When starting a VM we must assign unique IDs for fdsets we add via '-add-fd'. For now it was done by using the index of the filedescriptor passed to the virCommand. That approach is not very flexible, because you need to have already passed the 'fd' to virCommand before generating the fdset path, and also won't nicely work with fdsets containing two or more fds. This patch introduces a counter into the private data of a qemu domain so that we can allocate unique ids without relying on virCommand. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 29 +++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 64be39d49f..d0abf76e4a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -683,6 +683,33 @@ qemuDomainStorageIdReset(qemuDomainObjPrivate *priv) } +/** + * qemuDomainFDSetIdNew: + * @priv: qemu VM private data object. + * + * Generate a new unique id for a fdset. Note that this is necessary only = for + * startup. When running qemu auto-assigns id for added fdset. + */ +unsigned int +qemuDomainFDSetIdNew(qemuDomainObjPrivate *priv) +{ + return ++priv->fdsetindex; +} + + +/** + * qemuDomainFDSetIdReset: + * @priv: qemu VM private data object. + * + * Resets the data for the fdset ID generator. + */ +static void +qemuDomainFDSetIdReset(qemuDomainObjPrivate *priv) +{ + priv->fdsetindex =3D 0; +} + + static void qemuDomainSecretInfoClear(qemuDomainSecretInfo *secinfo, bool keepAlias) @@ -1683,6 +1710,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *p= riv) /* reset node name allocator */ qemuDomainStorageIdReset(priv); + qemuDomainFDSetIdReset(priv); + priv->dbusDaemonRunning =3D false; if (priv->dbusVMStateIds) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 7ec337e9ae..b7d0f5d2d5 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -207,6 +207,9 @@ struct _qemuDomainObjPrivate { /* counter for generating node names for qemu disks */ unsigned long long nodenameindex; + /* counter for generating IDs of fdsets - only relevant during startup= */ + unsigned int fdsetindex; + /* qemuProcessStartCPUs stores the reason for starting vCPUs here for = the * RESUME event handler to use it */ virDomainRunningReason runningReason; @@ -970,6 +973,7 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPr= ivate *priv); bool qemuDomainDefHasManagedPR(virDomainObj *vm); unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivate *priv); +unsigned int qemuDomainFDSetIdNew(qemuDomainObjPrivate *priv); virDomainEventResumedDetailType qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason); --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422708; cv=none; d=zohomail.com; s=zohoarc; b=j1715jIBgTyhyZRiXBn39BvkJu4xNSsLj4+r8piCUu6kizenIOhiNnF2XB4X9PKJhIIbxoZEydOL/Ukt+DwZ9UoHCs3CdtPbYWPtaun7WtS71eEL/oLHb31m8t9O+HnCdjevOcCz28WiEVXPmDb9cT5SvnE+3xcrmeVVdye8p84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422708; 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=g0rPXOyhx0eiilu+JSL/f2fvbr/iHBAcfq1QFCFnPNM=; b=mCxrapVJDpwQrZ7pNaW475xqmRIv/oiBDduAONsyp1+Jp4TSyPviBCxRljmX86Ci7/+TkNqY986z3UW33j+nlk6AwInUMtZoirHro8ziF6gB6/c5VsTpScUxup8Q8B08RMrfs6NZY5tQPY9+5ot13FNL7iHSbp1FF4uZ5Aqzn0U= 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 1644422708578906.8614184157515; Wed, 9 Feb 2022 08:05:08 -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-517-iYSbg8j6OJG--mswMQrXhw-1; Wed, 09 Feb 2022 11:03:19 -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 B9F376974E; Wed, 9 Feb 2022 16:03:02 +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 9B27F7CD69; Wed, 9 Feb 2022 16:03:02 +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 6680D4A707; Wed, 9 Feb 2022 16:03:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2g40012282 for ; Wed, 9 Feb 2022 11:02:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id EFA097DE42; Wed, 9 Feb 2022 16:02:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D7C27DE40 for ; Wed, 9 Feb 2022 16:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422707; 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=g0rPXOyhx0eiilu+JSL/f2fvbr/iHBAcfq1QFCFnPNM=; b=CSXbbAzAqYznRzxHXOeOEQwix7AuHd6aPP7vNVM0k9Vp4GjSWoF6+jmntibvWah4LwHswo 65h9aiZ5Wg2pYWkswcaKQoF1NbOet9vJJ4yIS+I1XiJ0yDeZ11syl/iC3xl8BNh9yd0/ud t5CvCYizmyoL4tgkhaIBrdTvSiXz4Pg= X-MC-Unique: iYSbg8j6OJG--mswMQrXhw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/27] qemu: Introduce helper functions for passing FDs to qemu Date: Wed, 9 Feb 2022 17:02:01 +0100 Message-Id: <6c0f3e07adc97805861c79365f74ec7e2d4e0784.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422710912100003 Content-Type: text/plain; charset="utf-8" The existing helpers we have are very clumsy and there's no integration with the monitor. This patch introduces new helpers to bridge the gap and simplify handing of fdsets and classic FD passing when generating commandline/hotplug arguments. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- po/POTFILES.in | 1 + src/qemu/meson.build | 1 + src/qemu/qemu_fd.c | 296 +++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_fd.h | 56 ++++++++ 4 files changed, 354 insertions(+) create mode 100644 src/qemu/qemu_fd.c create mode 100644 src/qemu/qemu_fd.h diff --git a/po/POTFILES.in b/po/POTFILES.in index bf0a3b3529..1fd3afdd6f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -164,6 +164,7 @@ @SRCDIR@src/qemu/qemu_domainjob.c @SRCDIR@src/qemu/qemu_driver.c @SRCDIR@src/qemu/qemu_extdevice.c +@SRCDIR@src/qemu/qemu_fd.c @SRCDIR@src/qemu/qemu_firmware.c @SRCDIR@src/qemu/qemu_hostdev.c @SRCDIR@src/qemu/qemu_hotplug.c diff --git a/src/qemu/meson.build b/src/qemu/meson.build index 3ea084cff8..39f0f615cc 100644 --- a/src/qemu/meson.build +++ b/src/qemu/meson.build @@ -15,6 +15,7 @@ qemu_driver_sources =3D [ 'qemu_domainjob.c', 'qemu_driver.c', 'qemu_extdevice.c', + 'qemu_fd.c', 'qemu_firmware.c', 'qemu_hostdev.c', 'qemu_hotplug.c', diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c new file mode 100644 index 0000000000..4052323cb0 --- /dev/null +++ b/src/qemu/qemu_fd.c @@ -0,0 +1,296 @@ +/* + * qemu_fd.c: QEMU fd and fdpass passing helpers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "qemu_fd.h" +#include "qemu_domain.h" + +#include "viralloc.h" +#include "virfile.h" +#include "virlog.h" + +#define VIR_FROM_THIS VIR_FROM_QEMU +VIR_LOG_INIT("qemu.qemu_fd"); + +struct qemuFDPassFD { + int fd; + char *opaque; +}; + +struct _qemuFDPass { + bool useFDSet; + unsigned int fdSetID; + size_t nfds; + struct qemuFDPassFD *fds; + char *prefix; + char *path; + + bool passed; /* passed to qemu via monitor */ +}; + + +void +qemuFDPassFree(qemuFDPass *fdpass) +{ + size_t i; + + if (!fdpass) + return; + + for (i =3D 0; i < fdpass->nfds; i++) { + VIR_FORCE_CLOSE(fdpass->fds[i].fd); + g_free(fdpass->fds[i].opaque); + } + + g_free(fdpass->fds); + g_free(fdpass->prefix); + g_free(fdpass->path); + g_free(fdpass); +} + + +/** + * qemuFDPassNew: + * @prefix: prefix used for naming the passed FDs + * @dompriv: qemu domain private data + * @useFDSet: Always use FD sets (/dev/fdset/N) for this instance + * + * Create a new helper object for passing FDs to qemu. If @useFDSet is fal= se + * the older approach of directly using FD number on the commandline and '= getfd' + * QMP command is used. Otherwise '-add-fd' and /dev/fdset/N is used to pa= ss the + * FD. + * + * Non-test uses must pass a valid @dompriv. + * + * @prefix is used for naming the FD if needed and is later referenced when + * removing the FDSet via monitor. + */ +qemuFDPass * +qemuFDPassNew(const char *prefix, + void *dompriv, + bool useFDSet) +{ + qemuDomainObjPrivate *priv =3D dompriv; + qemuFDPass *fdpass =3D g_new0(qemuFDPass, 1); + + fdpass->prefix =3D g_strdup(prefix); + fdpass->useFDSet =3D useFDSet; + + if (fdpass->useFDSet && priv) + fdpass->fdSetID =3D qemuDomainFDSetIdNew(priv); + + return fdpass; +} + + +/** + * qemuFDPassAddFD: + * @fdpass: The fd passing helper struct + * @fd: File descriptor to pass + * @suffix: Name suffix for the file descriptor name + * + * Adds @fd to be passed to qemu when transferring @fdpass to qemu. When @= fdpass + * is configured to use FD set mode, multiple file descriptors can be pass= ed by + * calling this function repeatedly. + * + * @suffix is used to build the name of the file descriptor by concatenati= ng + * it with @prefix passed to qemuFDPassNew. @suffix may be NULL, in which = case + * it's considered to be an empty string. + * + * Returns 0 on success, -1 on error (when attempting to pass multiple FDs= ) using + * the 'direct' method. + */ +int +qemuFDPassAddFD(qemuFDPass *fdpass, + int *fd, + const char *suffix) +{ + struct qemuFDPassFD newfd =3D { .fd =3D *fd }; + + if (newfd.fd < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid file descriptor")); + return -1; + } + + if (fdpass->nfds >=3D 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("direct FD passing supports only 1 file descripto= r")); + return -1; + } + + *fd =3D -1; + + newfd.opaque =3D g_strdup_printf("%s%s", fdpass->prefix, NULLSTR_EMPTY= (suffix)); + + VIR_APPEND_ELEMENT(fdpass->fds, fdpass->nfds, newfd); + + return 0; +} + + +/** + * qemuFDPassTransferCommand: + * @fdpass: The fd passing helper struct + * @cmd: Command to pass the filedescriptors to + * + * Pass the fds in @fdpass to a commandline object @cmd. @fdpass may be NU= LL + * in which case this is a no-op. + */ +void +qemuFDPassTransferCommand(qemuFDPass *fdpass, + virCommand *cmd) +{ + size_t i; + + if (!fdpass) + return; + + for (i =3D 0; i < fdpass->nfds; i++) { + virCommandPassFD(cmd, fdpass->fds[i].fd, VIR_COMMAND_PASS_FD_CLOSE= _PARENT); + + if (fdpass->useFDSet) { + g_autofree char *arg =3D NULL; + + arg =3D g_strdup_printf("set=3D%u,fd=3D%d,opaque=3D%s", + fdpass->fdSetID, + fdpass->fds[i].fd, + fdpass->fds[i].opaque); + + virCommandAddArgList(cmd, "-add-fd", arg, NULL); + + fdpass->path =3D g_strdup_printf("/dev/fdset/%u", fdpass->fdSe= tID); + } else { + fdpass->path =3D g_strdup_printf("%u", fdpass->fds[i].fd); + } + + fdpass->fds[i].fd =3D -1; + } +} + + +/** + * qemuFDPassTransferMonitor: + * @fdpass: The fd passing helper struct + * @mon: monitor object + * + * Pass the fds in @fdpass to qemu via the monitor. @fdpass may be NULL + * in which case this is a no-op. Caller needs to enter the monitor contex= t. + */ +int +qemuFDPassTransferMonitor(qemuFDPass *fdpass, + qemuMonitor *mon) +{ + int fdsetid =3D -1; + size_t i; + + if (!fdpass) + return 0; + + for (i =3D 0; i < fdpass->nfds; i++) { + if (fdpass->useFDSet) { + qemuMonitorAddFdInfo fdsetinfo; + + if (qemuMonitorAddFileHandleToSet(mon, + fdpass->fds[i].fd, + fdsetid, + fdpass->fds[i].opaque, + &fdsetinfo) < 0) + return -1; + + if (fdsetid =3D=3D -1) { + fdpass->fdSetID =3D fdsetid =3D fdsetinfo.fdset; + fdpass->path =3D g_strdup_printf("/dev/fdset/%u", fdsetid); + } + } else { + if (qemuMonitorSendFileHandle(mon, + fdpass->fds[i].opaque, + fdpass->fds[i].fd) < 0) + return -1; + + fdpass->path =3D g_strdup(fdpass->fds[i].opaque); + } + + fdpass->passed =3D true; + } + + return 0; +} + + +/** + * qemuFDPassTransferMonitorFake: + * @fdpass: The fd passing helper struct + * + * Simulate as if @fdpass was passed via monitor for callers which don't + * actually wish to test that code path. + */ +void +qemuFDPassTransferMonitorFake(qemuFDPass *fdpass) +{ + + if (!fdpass) + return; + + if (fdpass->useFDSet) { + fdpass->path =3D g_strdup_printf("/dev/fdset/monitor-fake"); + } else { + fdpass->path =3D g_strdup(fdpass->fds[0].opaque); + } +} + + +/** + * qemuFDPassTransferMonitorRollback: + * @fdpass: The fd passing helper struct + * @mon: monitor object + * + * Rolls back the addition of @fdpass to @mon if it was added originally. + */ +void +qemuFDPassTransferMonitorRollback(qemuFDPass *fdpass, + qemuMonitor *mon) +{ + if (!fdpass || !fdpass->passed) + return; + + if (fdpass->useFDSet) { + ignore_value(qemuMonitorRemoveFdset(mon, fdpass->fdSetID)); + } else { + ignore_value(qemuMonitorCloseFileHandle(mon, fdpass->fds[0].opaque= )); + } +} + + +/** + * qemuFDPassGetPath: + * @fdpass: The fd passing helper struct + * + * Returns the path/fd name that is used in qemu to refer to the passed FD. + * Note that it's only valid to call this function after @fdpass was alrea= dy + * transferred to the command or monitor. + */ +const char * +qemuFDPassGetPath(qemuFDPass *fdpass) +{ + if (!fdpass) + return NULL; + + return fdpass->path; +} diff --git a/src/qemu/qemu_fd.h b/src/qemu/qemu_fd.h new file mode 100644 index 0000000000..775d18fe2c --- /dev/null +++ b/src/qemu/qemu_fd.h @@ -0,0 +1,56 @@ +/* + * qemu_fd.h: QEMU fd and fdpass passing helpers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "vircommand.h" +#include "qemu_monitor.h" + +typedef struct _qemuFDPass qemuFDPass; + +void +qemuFDPassFree(qemuFDPass *fdpass); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuFDPass, qemuFDPassFree); + +qemuFDPass * +qemuFDPassNew(const char *prefix, + void *dompriv, + bool useFDSet); + +int +qemuFDPassAddFD(qemuFDPass *fdpass, + int *fd, + const char *suffix); + +void +qemuFDPassTransferCommand(qemuFDPass *fdpass, + virCommand *cmd); + +int +qemuFDPassTransferMonitor(qemuFDPass *fdpass, + qemuMonitor *mon); + +void +qemuFDPassTransferMonitorFake(qemuFDPass *fdpass); + +void +qemuFDPassTransferMonitorRollback(qemuFDPass *fdpass, + qemuMonitor *mon); + +const char * +qemuFDPassGetPath(qemuFDPass *fdpass); --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422592; cv=none; d=zohomail.com; s=zohoarc; b=QWoHK1eZuT3uKYk2yxIeTsGXUYdgTnjZakqjvQFnz+0hP7IcnNeHrw/txY7mHhaquVGJCa18GVB3+zjjhamfiWBCzfEjq76UzI3oWG7uIUGkt+f42GTtFkkBICv4onkFsfNHEHkxnD+4werq4qjes2oEDuVzSWLb5FpbesVzqpE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422592; 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=j4wSTRBAiujb4J/CsOK2A5XBMjmPUEhnAJn0TzJ8Vt8=; b=mbrfNsj2hhqDWvc+rh9KREKMDkmwoZSVTrzSvC//NaYyMFtQPTv3yK7U8IaUyNwT674CW30ycnXUaaCJdXTcvi9H89FhbMG1BRwCV0N61t91RJxCsIYtZDxxhvOKddXOmxXHGeB5aXhg2sWgT6rp8cCuFxTOUI+N/OIFoB9ln0c= 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 1644422592881135.66181243808285; Wed, 9 Feb 2022 08:03:12 -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-619-8C4v4FKlOjSCSUPBl_qNqQ-1; Wed, 09 Feb 2022 11:03:08 -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 110A2879532; Wed, 9 Feb 2022 16:03:00 +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 E48FE7CD66; Wed, 9 Feb 2022 16:02:59 +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 B4BE54BB7C; Wed, 9 Feb 2022 16:02:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2iVN012300 for ; Wed, 9 Feb 2022 11:02:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0753B7DE40; Wed, 9 Feb 2022 16:02:44 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63A9B7DE52 for ; Wed, 9 Feb 2022 16:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422591; 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=j4wSTRBAiujb4J/CsOK2A5XBMjmPUEhnAJn0TzJ8Vt8=; b=Z574LEoWdniX3y9eQvpSGCryZbuVaMkDbNya9DLLIepLjyfv+OAMyqwx48poGGRnGcgQ2+ Dw+ZH8SYhr0dyGS8QcR+GmiW8RaP3QixPzalBBiU1L746VFYsbeTsFMgQMy10glX0NJab6 qgNHw3k7qU4XBq9zAiE/EejIvlI6KgI= X-MC-Unique: 8C4v4FKlOjSCSUPBl_qNqQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/27] qemuBuildInterfaceCommandLine: Use qemuFDPass for the vdpa fd Date: Wed, 9 Feb 2022 17:02:02 +0100 Message-Id: <29a9862944f12c0668f4224aa4efb080619ee9a5.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422595183100015 Content-Type: text/plain; charset="utf-8" Use the new helpers for passing of the file descriptor needed for 'vdpa' interfaces. Apart from the simplification in this case it will allow further changes to unify all fdset handling. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 35 ++++++++----------- .../net-vdpa.x86_64-latest.args | 4 +-- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9713467aa8..839cd05e23 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -29,6 +29,7 @@ #include "qemu_security.h" #include "qemu_slirp.h" #include "qemu_block.h" +#include "qemu_fd.h" #include "viralloc.h" #include "virlog.h" #include "virarch.h" @@ -8732,6 +8733,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, size_t *nnicindexes, int **nicindexes) { + qemuDomainObjPrivate *priv =3D vm->privateData; virDomainDef *def =3D vm->def; int ret =3D -1; g_autoptr(virJSONValue) nicprops =3D NULL; @@ -8743,8 +8745,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, char **tapfdName =3D NULL; char **vhostfdName =3D NULL; g_autofree char *slirpfdName =3D NULL; - g_autofree char *vdpafdName =3D NULL; - int vdpafd =3D -1; + g_autoptr(qemuFDPass) vdpa =3D NULL; virDomainNetType actualType =3D virDomainNetGetActualType(net); const virNetDevBandwidth *actualBandwidth; bool requireNicdev =3D false; @@ -8823,9 +8824,17 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, break; - case VIR_DOMAIN_NET_TYPE_VDPA: + case VIR_DOMAIN_NET_TYPE_VDPA: { + VIR_AUTOCLOSE vdpafd =3D -1; + if ((vdpafd =3D qemuInterfaceVDPAConnect(net)) < 0) goto cleanup; + + vdpa =3D qemuFDPassNew(net->data.vdpa.devicepath, priv, true); + + if (qemuFDPassAddFD(vdpa, &vdpafd, NULL) < 0) + return -1; + } break; case VIR_DOMAIN_NET_TYPE_USER: @@ -8958,26 +8967,13 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, vhostfd[i] =3D -1; } - if (vdpafd > 0) { - g_autofree char *fdset =3D NULL; - g_autofree char *addfdarg =3D NULL; - size_t idx; - - virCommandPassFDIndex(cmd, vdpafd, VIR_COMMAND_PASS_FD_CLOSE_PAREN= T, &idx); - fdset =3D qemuBuildFDSet(vdpafd, idx); - vdpafdName =3D g_strdup_printf("/dev/fdset/%zu", idx); - /* set opaque to the devicepath so that we can look up the fdset l= ater - * if necessary */ - addfdarg =3D g_strdup_printf("%s,opaque=3D%s", fdset, - net->data.vdpa.devicepath); - virCommandAddArgList(cmd, "-add-fd", addfdarg, NULL); - vdpafd =3D -1; - } + qemuFDPassTransferCommand(vdpa, cmd); if (!(hostnetprops =3D qemuBuildHostNetProps(net, tapfdName, tapfdSize, vhostfdName, vhostfdSize, - slirpfdName, vdpafdName))) + slirpfdName, + qemuFDPassGetPath(vdpa)))) goto cleanup; if (qemuBuildNetdevCommandlineFromJSON(cmd, hostnetprops, qemuCaps) < = 0) @@ -9035,7 +9031,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, VIR_FREE(tapfdName); VIR_FREE(vhostfd); VIR_FREE(tapfd); - VIR_FORCE_CLOSE(vdpafd); return ret; } diff --git a/tests/qemuxml2argvdata/net-vdpa.x86_64-latest.args b/tests/qem= uxml2argvdata/net-vdpa.x86_64-latest.args index a56e08a4f1..0300f36314 100644 --- a/tests/qemuxml2argvdata/net-vdpa.x86_64-latest.args +++ b/tests/qemuxml2argvdata/net-vdpa.x86_64-latest.args @@ -28,8 +28,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --add-fd set=3D0,fd=3D1732,opaque=3D/dev/vhost-vdpa-0 \ --netdev vhost-vdpa,vhostdev=3D/dev/fdset/0,id=3Dhostnet0 \ +-add-fd set=3D1,fd=3D1732,opaque=3D/dev/vhost-vdpa-0 \ +-netdev vhost-vdpa,vhostdev=3D/dev/fdset/1,id=3Dhostnet0 \ -device '{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":= "52:54:00:95:db:c0","bus":"pci.0","addr":"0x2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422627; cv=none; d=zohomail.com; s=zohoarc; b=iJq5IqG0q+LCHSnfYWnBV2Y8hHJw2m4+vvVZqXCgIs+Ao36rk5x23PMjbIlEQH2vMlxCZ9mH5YX2x7/RC/upZsZ/iWyk0nu5WkCfVpKqlAZOTM4DUS4vCj9PsWO7HiG7+XOxtFT/GlUd2eVn3zfrEZNkOemQo7IciMM6mfcqjfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422627; 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=F4e+ceSzhoQOHbwV/QQoesMTH18uWxIRx9PU5nGzYMo=; b=fqzuZAEaWU8GbXPiVKbrkDazXc4DbaK/tRopg2Nf8eddT8bOqogfc+KiDC45f9hUcW26N+yiNlzyuQNow5qcMhW2hXKtJHB2HfUnqNXQlsoNIhAcE75/hDSMC6Ax3GAJZKrRR6RF1IlgpJRHNKocb8c0yr0jqDSsFbJkMrv3fKI= 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 1644422627540794.6842047277858; Wed, 9 Feb 2022 08:03:47 -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-516-sinEhz1pNTi910R1b-4Zjw-1; Wed, 09 Feb 2022 11:03:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 021DE83DEA6; Wed, 9 Feb 2022 16:03:06 +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 79EE684D00; Wed, 9 Feb 2022 16:03:05 +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 1258E18033AE; Wed, 9 Feb 2022 16:03:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2jXf012307 for ; Wed, 9 Feb 2022 11:02:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 103B77DE56; Wed, 9 Feb 2022 16:02:45 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6847C7DE40 for ; Wed, 9 Feb 2022 16:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422626; 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=F4e+ceSzhoQOHbwV/QQoesMTH18uWxIRx9PU5nGzYMo=; b=DxIcvX3bZrwdrASBRN1PIAwrOTGO2NuOurnOKZXyaFGmKjAS/KmCqQXVH4W5548Jblua+m IGD3wXE9DxaAJIILRYgWN04iJLtzpjce9UZoZ9M465HrU0pBjFfKlmJ1GkmegvGFijACYC fqeDSY1m0Rt+kNlXFQ0RoqMqgGNcCmI= X-MC-Unique: sinEhz1pNTi910R1b-4Zjw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/27] qemu: hotplug: Extract code for unplugging fdsets Date: Wed, 9 Feb 2022 17:02:03 +0100 Message-Id: <37ed7d429cd70c7312b8804797c45ec0f5f2cfee.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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: 1644422629574100005 Content-Type: text/plain; charset="utf-8" The code unplugging the fdset for a 'vdpa' network device can be later reused. Extract it into 'qemuHotplugRemoveFDSet'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 69 +++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ac2b07d940..3264f287c3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -137,6 +137,44 @@ qemuDomainDeleteDevice(virDomainObj *vm, } +/** + * qemuHotplugRemoveFDSet: + * @mon: monitor object + * @fdname: the 'opaque' string used as a name for the FD + * + * Looks up the 'fdset' by looking for a fd inside one of the fdsets which + * has the opaque string set to @fdname. Removes the whole fdset which con= tains + * the fd. + * + * Errors are logged, but this is a best-effort hot-unplug cleanup helper = so it's + * pointless to return a value. + */ +static void +qemuHotplugRemoveFDSet(qemuMonitor *mon, + const char *fdname) +{ + g_autoptr(qemuMonitorFdsets) fdsets =3D NULL; + size_t i; + + if (qemuMonitorQueryFdsets(mon, &fdsets) < 0) + return; + + for (i =3D 0; i < fdsets->nfdsets; i++) { + qemuMonitorFdsetInfo *set =3D &fdsets->fdsets[i]; + size_t j; + + for (j =3D 0; j < set->nfds; j++) { + qemuMonitorFdsetFdInfo *fdinfo =3D &set->fds[j]; + + if (STREQ_NULLABLE(fdinfo->opaque, fdname)) { + ignore_value(qemuMonitorRemoveFdset(mon, set->id)); + return; + } + } + } +} + + static int qemuDomainDetachZPCIDevice(qemuMonitor *mon, virDomainDeviceInfo *info) @@ -4761,38 +4799,9 @@ qemuDomainRemoveNetDevice(virQEMUDriver *driver, */ } } else if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_VDPA) { - int vdpafdset =3D -1; - g_autoptr(qemuMonitorFdsets) fdsets =3D NULL; - - /* query qemu for which fdset is associated with the fd that we pa= ssed - * to qemu via 'add-fd' for this vdpa device. If we don't remove t= he - * fd, qemu will keep it open */ - if (qemuMonitorQueryFdsets(priv->mon, &fdsets) =3D=3D 0) { - for (i =3D 0; i < fdsets->nfdsets && vdpafdset < 0; i++) { - size_t j; - qemuMonitorFdsetInfo *set =3D &fdsets->fdsets[i]; - - for (j =3D 0; j < set->nfds; j++) { - qemuMonitorFdsetFdInfo *fdinfo =3D &set->fds[j]; - if (STREQ_NULLABLE(fdinfo->opaque, net->data.vdpa.devi= cepath)) { - vdpafdset =3D set->id; - break; - } - } - } - } - - if (vdpafdset < 0) { - VIR_WARN("Cannot determine fdset for vdpa device"); - } else { - if (qemuMonitorRemoveFdset(priv->mon, vdpafdset) < 0) { - /* if it fails, there's not much we can do... just carry o= n */ - VIR_WARN("failed to close vdpa device"); - } - } + qemuHotplugRemoveFDSet(priv->mon, net->data.vdpa.devicepath); } - qemuDomainObjExitMonitor(driver, vm); if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422627; cv=none; d=zohomail.com; s=zohoarc; b=jOZyuV5t8d2z8zrwT98NJPJ/4JsCZ1/1eM8TucxKv2Al9EtaI80KjCpZwOeex7NdUN3QTMhF6UbqgCdaaxhc3oDA1pXRjAqhk/GYpF7yXN8ZoMHxx9EeafYTaFAmsHdj+JqSSovAk37PqQDeeOxBpdM0Sy4FQ9xhzJOT6svuj0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422627; 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=bmDTt2pVW5WO1zwcPizDA0RFFDqmASJ8m3CVqsJ33fo=; b=nzlhpVx+953FTyOAOkyQrcy5Yfby4OPdcOI7tFXDM3kvVR1LoxO6vcLT2f4Q6Wzd2XEA56Lf/WfbdX9KOEX1GBmOCFeiekR/8DCMY+NKbB1gSeTk6DWR++MZc+WKQBcj5buIrRDcbNDYbRAhykwrQyYWuSKFoMrUGmsmNF/NCgI= 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 1644422627036584.9935316966976; Wed, 9 Feb 2022 08:03:47 -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-178-DNAI_jNpPHGlRkaAVwF8jQ-1; Wed, 09 Feb 2022 11:03:40 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E2801091DC4; Wed, 9 Feb 2022 16:03:09 +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 1635284D07; Wed, 9 Feb 2022 16:03:09 +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 D95D7181844F; Wed, 9 Feb 2022 16:03:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2kHS012313 for ; Wed, 9 Feb 2022 11:02:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 216BD7DE40; Wed, 9 Feb 2022 16:02:46 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B4CB7DE4F for ; Wed, 9 Feb 2022 16:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422625; 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=bmDTt2pVW5WO1zwcPizDA0RFFDqmASJ8m3CVqsJ33fo=; b=GctaJXUabLJJGEe8HS/Z1NDsrVKzmhZdTPamfmT4EFnWz1PKOM5KVFMmulGky88Y0vZW1y w3eQhnwxyADK8Ved9YIkytxKDzYJySnaF0KVZSr34lecDdePrnqSax7rzOKER2o7HIlgqU Ra7m1uDZBAPzsrRvGtT66AwF9gsO6o0= X-MC-Unique: DNAI_jNpPHGlRkaAVwF8jQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/27] qemuHotplugRemoveFDSet: Prepare for proper FD unplug handling Date: Wed, 9 Feb 2022 17:02:04 +0100 Message-Id: <08b29cd4e56e7065d092305871e8f89f68f12c7f.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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: 1644422627584100003 Content-Type: text/plain; charset="utf-8" For now we have only one code path ('vdpa' interface) which actually cleans up the fdset after it's done, but there are more device types using fdsets. In order to unify the handling of fdsets the removal code will now be able to remove fdsets based on a prefix of the 'opaque' field, which we'll always prefix with a device alias or e.g. node name once fdsets are also used for disk backing. To keep compatibility with old qemus, retain the possibility for the VDPA interface to use the path. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3264f287c3..03b7ca30de 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -140,18 +140,21 @@ qemuDomainDeleteDevice(virDomainObj *vm, /** * qemuHotplugRemoveFDSet: * @mon: monitor object - * @fdname: the 'opaque' string used as a name for the FD + * @prefix: the prefix of FD names ('opaque' filed) to delete + * @alternate: alternate name for FD, for historical usage (may be NULL) * * Looks up the 'fdset' by looking for a fd inside one of the fdsets which - * has the opaque string set to @fdname. Removes the whole fdset which con= tains - * the fd. + * has the opaque string starting with @prefix. Removes the whole fdset wh= ich + * contains the fd. Alternatively if @alternate is specified fdsets having= a fd + * with that exact 'opaque' string is removed too. * * Errors are logged, but this is a best-effort hot-unplug cleanup helper = so it's * pointless to return a value. */ static void qemuHotplugRemoveFDSet(qemuMonitor *mon, - const char *fdname) + const char *prefix, + const char *alternate) { g_autoptr(qemuMonitorFdsets) fdsets =3D NULL; size_t i; @@ -166,9 +169,11 @@ qemuHotplugRemoveFDSet(qemuMonitor *mon, for (j =3D 0; j < set->nfds; j++) { qemuMonitorFdsetFdInfo *fdinfo =3D &set->fds[j]; - if (STREQ_NULLABLE(fdinfo->opaque, fdname)) { + if (fdinfo->opaque && + (STRPREFIX(fdinfo->opaque, prefix) || + STREQ_NULLABLE(fdinfo->opaque, alternate))) { ignore_value(qemuMonitorRemoveFdset(mon, set->id)); - return; + break; } } } @@ -4799,7 +4804,7 @@ qemuDomainRemoveNetDevice(virQEMUDriver *driver, */ } } else if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_VDPA) { - qemuHotplugRemoveFDSet(priv->mon, net->data.vdpa.devicepath); + qemuHotplugRemoveFDSet(priv->mon, net->info.alias, net->data.vdpa.= devicepath); } qemuDomainObjExitMonitor(driver, vm); --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422632; cv=none; d=zohomail.com; s=zohoarc; b=EH8IrL5dk+b4iyAILW9QDE3VsS86AEswQjVJ9Apy8Wja8r5U/wu9+YRci0OfOUKmGCxIHyNsA5eANJ6cdbVaSFZlJBHjbxvbr2VSg63g/5GzjJDKz9/guDjmEqFWEVTDYVfxECWxLSv54LlOW8+d71xQhvauuEdLYfoNseDo78U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422632; 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=tqu6roYNQ/9rbKvjdgb6N53C3m7SlPhupxd+0p/ckck=; b=XHUwjWLPXYtXMNNX6HY/IFlqml4PvfNBYts6P4KttEi2rvaXBR70SQM9YoFG6j+VT1kwVqDYcPJzr70k4fym+Cqi4nc2wa3yQYq2OoGm87Wy7WZhlYTDBCnNgsZg5yUUOZjtec0HArOSgzx4MIT2Bo4e80iZhm0UINcdZlv0Xco= 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 1644422632112356.2562913610907; Wed, 9 Feb 2022 08:03:52 -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-235-dtA_pC_2PGqWAGPg0HAWbA-1; Wed, 09 Feb 2022 11:03:46 -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 04141101511E; Wed, 9 Feb 2022 16:03:12 +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 C24C1752D6; Wed, 9 Feb 2022 16:03:11 +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 9194D4A707; Wed, 9 Feb 2022 16:03:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2lFF012332 for ; Wed, 9 Feb 2022 11:02:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 24E3A7DE4F; Wed, 9 Feb 2022 16:02:47 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FD537DE42 for ; Wed, 9 Feb 2022 16:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422631; 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=tqu6roYNQ/9rbKvjdgb6N53C3m7SlPhupxd+0p/ckck=; b=bJP6Wf9ka8CqblbJtUUIDJz8lJzqcKf1At5mA4snLlWCq3YKFAus/eoIyxnXc9a0mRzAoJ OYB+4oochF4hta+HKyp+tbFh9aec1vxDqSRhsZ5t6JvdKPdnYRqFCyMznhWJW1mH2Ko6CB g/NFU6LhlyyEhL6U2ev8C51/iTXScYM= X-MC-Unique: dtA_pC_2PGqWAGPg0HAWbA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/27] qemuBuildInterfaceCommandLine: Use new pattern for naming the VDPA fdset Date: Wed, 9 Feb 2022 17:02:05 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422633100100005 Content-Type: text/plain; charset="utf-8" Prefix the file descriptor name with the alias of the network device so that it's similar to other upcoming use. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 4 ++-- tests/qemuxml2argvdata/net-vdpa.x86_64-latest.args | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 839cd05e23..6667433616 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8830,9 +8830,9 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if ((vdpafd =3D qemuInterfaceVDPAConnect(net)) < 0) goto cleanup; - vdpa =3D qemuFDPassNew(net->data.vdpa.devicepath, priv, true); + vdpa =3D qemuFDPassNew(net->info.alias, priv, true); - if (qemuFDPassAddFD(vdpa, &vdpafd, NULL) < 0) + if (qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa") < 0) return -1; } break; diff --git a/tests/qemuxml2argvdata/net-vdpa.x86_64-latest.args b/tests/qem= uxml2argvdata/net-vdpa.x86_64-latest.args index 0300f36314..aff024af2f 100644 --- a/tests/qemuxml2argvdata/net-vdpa.x86_64-latest.args +++ b/tests/qemuxml2argvdata/net-vdpa.x86_64-latest.args @@ -28,7 +28,7 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -no-acpi \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --add-fd set=3D1,fd=3D1732,opaque=3D/dev/vhost-vdpa-0 \ +-add-fd set=3D1,fd=3D1732,opaque=3Dnet0-vdpa \ -netdev vhost-vdpa,vhostdev=3D/dev/fdset/1,id=3Dhostnet0 \ -device '{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":= "52:54:00:95:db:c0","bus":"pci.0","addr":"0x2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422706; cv=none; d=zohomail.com; s=zohoarc; b=cLX41/OFuY86ev3gVOMYHXUE5B/IOXDjZmV7CiHJujvwMhw0AMkVqoRzsVDjXv7I6C57Wu21nwCpkv55oQ8Lq0ToKZeQm0qR3cqnDR4RFQFgcysvAcLPEhHWqyZBPeepNrA380oIxhxvXEL88Robhd5jOqh/tPpJyrKlpwxzF8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422706; 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=JVOx/GakIblTkr1Moph6GjkXXR/nMSwHIz0x7evkJTE=; b=mmGSPWIWxS7j2Wz2y6Cx+FZGuqSDZGOLH30zYniFCt/VCvXcmLiEbnk/zdjV62RHUxbBZ7ppCNYxdCoGstsIkgz3sXqk9D3dcGMTJfSHizQoH31Wo8tjAnXQK8GxRzIJkRq+qq2cSwly+gIa75oVDnlcQrztqu82hv4HriUfLYE= 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 16444227066931001.1874893974197; Wed, 9 Feb 2022 08:05:06 -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-646-aWW_VzoTNia222gETiZTXw-1; Wed, 09 Feb 2022 11:03:49 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC1DC86A8C5; Wed, 9 Feb 2022 16:03:14 +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 6D4C17DE5C; Wed, 9 Feb 2022 16:03:14 +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 3828C18218AF; Wed, 9 Feb 2022 16:03:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2m91012340 for ; Wed, 9 Feb 2022 11:02:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 573987DE42; Wed, 9 Feb 2022 16:02:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F36B7DE40 for ; Wed, 9 Feb 2022 16:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422705; 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=JVOx/GakIblTkr1Moph6GjkXXR/nMSwHIz0x7evkJTE=; b=Yh+1FyVrsIgPyo3rKnUHl/kNFzaR9uHXR//1Ik9USU8LJsX63wO/n6qt1PcMeKakeyJLaW W6uEWoYlUE5sB4XhKx3jQ0YrBp6bIfIwjUT6bSV17cchMne71/5K6JiPAZRIz7JKZh5M6P kCybL2y172nx/JQeEP4SggE2xOYxvG0= X-MC-Unique: aWW_VzoTNia222gETiZTXw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/27] qemu: Rewrite chardev startup code to use qemuFDPass Date: Wed, 9 Feb 2022 17:02:06 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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: 1644422708072100003 Content-Type: text/plain; charset="utf-8" Rewrite the parts which already pass FDs via fdset or directly to use the new infrastructure. Apart from simpler code this also adds the appropriate names to the fds in the fdsets which will allow us to properly remove the fdsets won hot-unplug of chardevs, which we didn't do for now and resulted in leaking the FDs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 74 ++++--------------- src/qemu/qemu_domain.c | 11 +-- src/qemu/qemu_domain.h | 8 +- src/qemu/qemu_process.c | 42 +++++++++-- .../qemuxml2argvdata/aarch64-pci-serial.args | 4 +- .../name-escape.x86_64-2.11.0.args | 4 +- .../name-escape.x86_64-latest.args | 4 +- .../qemuxml2argvdata/serial-file-chardev.args | 4 +- .../serial-file-chardev.x86_64-latest.args | 4 +- tests/qemuxml2argvdata/serial-file-log.args | 6 +- .../serial-file-log.x86_64-latest.args | 6 +- .../qemuxml2argvdata/serial-many-chardev.args | 4 +- .../serial-many-chardev.x86_64-latest.args | 4 +- tests/qemuxml2argvtest.c | 56 ++++++++------ 14 files changed, 108 insertions(+), 123 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6667433616..9a51a373b0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -301,23 +301,6 @@ qemuBuildMasterKeyCommandLine(virCommand *cmd, } -/** - * qemuBuildFDSet: - * @fd: fd to reassign to the child - * @idx: index in the fd set - * - * Format the parameters for the -add-fd command line option - * for the given file descriptor. The file descriptor must previously - * have been 'transferred' in a virCommandPassFDIndex() call, - * and @idx is the value returned by that call. - */ -static char * -qemuBuildFDSet(int fd, size_t idx) -{ - return g_strdup_printf("set=3D%zu,fd=3D%d", idx, fd); -} - - /** * qemuVirCommandGetFDSet: * @cmd: the command to modify @@ -1362,8 +1345,8 @@ qemuBuildChardevStr(const virDomainChrSourceDef *dev, path =3D dev->data.file.path; append =3D dev->data.file.append; - if (chrSourcePriv->fdset) { - path =3D chrSourcePriv->fdset; + if (chrSourcePriv->sourcefd) { + path =3D qemuFDPassGetPath(chrSourcePriv->sourcefd); append =3D VIR_TRISTATE_SWITCH_ON; } @@ -1430,8 +1413,8 @@ qemuBuildChardevStr(const virDomainChrSourceDef *dev, case VIR_DOMAIN_CHR_TYPE_UNIX: virBufferAsprintf(&buf, "socket,id=3D%s", charAlias); - if (chrSourcePriv->passedFD !=3D -1) { - virBufferAsprintf(&buf, ",fd=3D%d", chrSourcePriv->passedFD); + if (chrSourcePriv->sourcefd) { + virBufferAsprintf(&buf, ",fd=3D%s", qemuFDPassGetPath(chrSourc= ePriv->sourcefd)); } else { virBufferAddLit(&buf, ",path=3D"); virQEMUBuildBufferEscapeComma(&buf, dev->data.nix.path); @@ -1466,8 +1449,8 @@ qemuBuildChardevStr(const virDomainChrSourceDef *dev, path =3D dev->logfile; append =3D dev->logappend; - if (chrSourcePriv->logFdset) { - path =3D chrSourcePriv->logFdset; + if (chrSourcePriv->logfd) { + path =3D qemuFDPassGetPath(chrSourcePriv->logfd); append =3D VIR_TRISTATE_SWITCH_ON; } @@ -1527,28 +1510,8 @@ qemuBuildChardevCommand(virCommand *cmd, break; case VIR_DOMAIN_CHR_TYPE_FILE: - if (chrSourcePriv->fd !=3D -1) { - g_autofree char *fdset =3D NULL; - size_t idx; - - virCommandPassFDIndex(cmd, chrSourcePriv->fd, - VIR_COMMAND_PASS_FD_CLOSE_PARENT, &idx); - fdset =3D qemuBuildFDSet(chrSourcePriv->fd, idx); - chrSourcePriv->fd =3D -1; - - virCommandAddArg(cmd, "-add-fd"); - virCommandAddArg(cmd, fdset); - - chrSourcePriv->fdset =3D g_strdup_printf("/dev/fdset/%zu", idx= ); - } - break; - case VIR_DOMAIN_CHR_TYPE_UNIX: - if (chrSourcePriv->fd !=3D -1) { - virCommandPassFD(cmd, chrSourcePriv->fd, VIR_COMMAND_PASS_FD_C= LOSE_PARENT); - chrSourcePriv->passedFD =3D chrSourcePriv->fd; - chrSourcePriv->fd =3D -1; - } + qemuFDPassTransferCommand(chrSourcePriv->sourcefd, cmd); break; case VIR_DOMAIN_CHR_TYPE_NULL: @@ -1571,20 +1534,7 @@ qemuBuildChardevCommand(virCommand *cmd, return -1; } - if (chrSourcePriv->logfd !=3D -1) { - g_autofree char *fdset =3D NULL; - size_t idx; - - virCommandPassFDIndex(cmd, chrSourcePriv->logfd, - VIR_COMMAND_PASS_FD_CLOSE_PARENT, &idx); - fdset =3D qemuBuildFDSet(chrSourcePriv->logfd, idx); - chrSourcePriv->logfd =3D -1; - - virCommandAddArg(cmd, "-add-fd"); - virCommandAddArg(cmd, fdset); - - chrSourcePriv->logFdset =3D g_strdup_printf("/dev/fdset/%zu", idx); - } + qemuFDPassTransferCommand(chrSourcePriv->logfd, cmd); if (!(charstr =3D qemuBuildChardevStr(dev, charAlias))) return -1; @@ -5001,8 +4951,12 @@ qemuBuildVideoCommandLine(virCommand *cmd, qemuDomainChrSourcePrivate *chrsrcpriv =3D QEMU_DOMAIN_CHR_SOU= RCE_PRIVATE(chrsrc); chrsrc->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - chrsrcpriv->fd =3D videopriv->vhost_user_fd; - videopriv->vhost_user_fd =3D -1; + chrsrcpriv->sourcefd =3D qemuFDPassNew(video->info.alias, priv= , false); + + if (qemuFDPassAddFD(chrsrcpriv->sourcefd, + &videopriv->vhost_user_fd, + "-vhost-user") < 0) + return -1; if (qemuBuildChardevCommand(cmd, chrsrc, chrAlias, priv->qemuC= aps) < 0) return -1; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d0abf76e4a..5483e0720f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -904,11 +904,6 @@ qemuDomainChrSourcePrivateNew(void) if (!(priv =3D virObjectNew(qemuDomainChrSourcePrivateClass))) return NULL; - priv->fd =3D -1; - priv->logfd =3D -1; - - priv->passedFD =3D -1; - return (virObject *) priv; } @@ -918,13 +913,11 @@ qemuDomainChrSourcePrivateDispose(void *obj) { qemuDomainChrSourcePrivate *priv =3D obj; - VIR_FORCE_CLOSE(priv->fd); - VIR_FORCE_CLOSE(priv->logfd); + qemuFDPassFree(priv->sourcefd); + qemuFDPassFree(priv->logfd); g_free(priv->tlsCertPath); - g_free(priv->fdset); - g_free(priv->logFdset); g_free(priv->tlsCredsAlias); g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index b7d0f5d2d5..e9901cb5c3 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -36,6 +36,7 @@ #include "qemu_capabilities.h" #include "qemu_migration_params.h" #include "qemu_slirp.h" +#include "qemu_fd.h" #include "virmdev.h" #include "virchrdev.h" #include "virobject.h" @@ -347,16 +348,13 @@ struct _qemuDomainChrSourcePrivate { * NB: *not* to be written to qemu domain object XML */ qemuDomainSecretInfo *secinfo; - int fd; /* file descriptor of the chardev source */ - int logfd; /* file descriptor of the logging source */ + qemuFDPass *sourcefd; + qemuFDPass *logfd; bool wait; /* wait for incoming connections on chardev */ char *tlsCertPath; /* path to certificates if TLS is requested */ bool tlsVerify; /* whether server should verify client certificates */ - char *fdset; /* fdset path corresponding to the passed filedescriptor = */ - char *logFdset; /* fdset path corresponding to the passed filedescript= or for logfile */ - int passedFD; /* filedescriptor number when fdset passing it directly = */ char *tlsCredsAlias; /* alias of the x509 tls credentials object */ }; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0e17e1bf94..b44e684589 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6809,6 +6809,7 @@ struct qemuProcessPrepareHostBackendChardevData { virLogManager *logManager; virQEMUDriverConfig *cfg; virDomainDef *def; + const char *fdprefix; }; @@ -6819,10 +6820,14 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDe= viceDef *dev, { struct qemuProcessPrepareHostBackendChardevData *data =3D opaque; qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PRIVAT= E(chardev); + const char *devalias =3D NULL; /* this function is also called for the monitor backend which doesn't = have * a 'dev' */ if (dev) { + virDomainDeviceInfo *info =3D virDomainDeviceGetInfo(dev); + devalias =3D info->alias; + /* vhost-user disk doesn't use FD passing */ if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) return 0; @@ -6836,6 +6841,8 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDevi= ceDef *dev, /* TPMs FD passing setup is special and handled separately */ if (dev->type =3D=3D VIR_DOMAIN_DEVICE_TPM) return 0; + } else { + devalias =3D data->fdprefix; } switch ((virDomainChrType) chardev->type) { @@ -6851,33 +6858,43 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDe= viceDef *dev, case VIR_DOMAIN_CHR_TYPE_SPICEPORT: break; - case VIR_DOMAIN_CHR_TYPE_FILE: + case VIR_DOMAIN_CHR_TYPE_FILE: { + VIR_AUTOCLOSE sourcefd =3D -1; + if (qemuProcessPrepareHostBackendChardevFileHelper(chardev->data.f= ile.path, chardev->data.f= ile.append, - &charpriv->fd, + &sourcefd, data->logManage= r, data->priv->dri= ver->securityManager, data->cfg, data->def) < 0) return -1; + charpriv->sourcefd =3D qemuFDPassNew(devalias, data->priv, true); + + if (qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source") < 0) + return -1; + } break; case VIR_DOMAIN_CHR_TYPE_UNIX: if (chardev->data.nix.listen && virQEMUCapsGet(data->priv->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS= _COMMANDLINE)) { + VIR_AUTOCLOSE sourcefd =3D -1; if (qemuSecuritySetSocketLabel(data->priv->driver->securityMan= ager, data->def) < 0) return -1; - charpriv->fd =3D qemuOpenChrChardevUNIXSocket(chardev); + sourcefd =3D qemuOpenChrChardevUNIXSocket(chardev); - if (qemuSecurityClearSocketLabel(data->priv->driver->securityM= anager, data->def) < 0) { - VIR_FORCE_CLOSE(charpriv->fd); + if (qemuSecurityClearSocketLabel(data->priv->driver->securityM= anager, data->def) < 0 || + sourcefd < 0) return -1; - } - if (charpriv->fd < 0) + /* UNIX socket use direct FD passing */ + charpriv->sourcefd =3D qemuFDPassNew(devalias, data->priv, fal= se); + + if (qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source") = < 0) return -1; } break; @@ -6892,14 +6909,21 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDe= viceDef *dev, } if (chardev->logfile) { + VIR_AUTOCLOSE logfd =3D -1; + if (qemuProcessPrepareHostBackendChardevFileHelper(chardev->logfil= e, chardev->logapp= end, - &charpriv->logf= d, + &logfd, data->logManage= r, data->priv->dri= ver->securityManager, data->cfg, data->def) < 0) return -1; + + charpriv->logfd =3D qemuFDPassNew(devalias, data->priv, true); + + if (qemuFDPassAddFD(charpriv->logfd, &logfd, "-log") < 0) + return -1; } return 0; @@ -6932,6 +6956,8 @@ qemuProcessPrepareHostBackendChardev(virDomainObj *vm) &data) < 0) return -1; + data.fdprefix =3D "monitor"; + if (qemuProcessPrepareHostBackendChardevOne(NULL, priv->monConfig, &da= ta) < 0) return -1; diff --git a/tests/qemuxml2argvdata/aarch64-pci-serial.args b/tests/qemuxml= 2argvdata/aarch64-pci-serial.args index aca88e8e60..e012ea24dd 100644 --- a/tests/qemuxml2argvdata/aarch64-pci-serial.args +++ b/tests/qemuxml2argvdata/aarch64-pci-serial.args @@ -29,7 +29,7 @@ QEMU_AUDIO_DRV=3Dnone \ -device i82801b11-bridge,id=3Dpci.1,bus=3Dpcie.0,addr=3D0x1 \ -device pci-bridge,chassis_nr=3D2,id=3Dpci.2,bus=3Dpci.1,addr=3D0x0 \ -device pcie-root-port,port=3D16,chassis=3D3,id=3Dpci.3,bus=3Dpcie.0,addr= =3D0x2 \ --add-fd set=3D0,fd=3D1751 \ --chardev pty,id=3Dcharserial0,logfile=3D/dev/fdset/0,logappend=3Don \ +-add-fd set=3D1,fd=3D1751,opaque=3Dserial0-log \ +-chardev pty,id=3Dcharserial0,logfile=3D/dev/fdset/1,logappend=3Don \ -device pci-serial,chardev=3Dcharserial0,id=3Dserial0,bus=3Dpci.2,addr=3D0= x1 \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args b/tests/= qemuxml2argvdata/name-escape.x86_64-2.11.0.args index 6d4c5bff6e..7f9677abb6 100644 --- a/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args +++ b/tests/qemuxml2argvdata/name-escape.x86_64-2.11.0.args @@ -33,8 +33,8 @@ QEMU_AUDIO_DRV=3Dspice \ -device ccid-card-emulated,backend=3Dcertificates,cert1=3Dcert1,,foo,cert2= =3Dcert2,cert3=3Dcert3,db=3D/etc/pki/nssdb,,foo,id=3Dsmartcard0,bus=3Dccid0= .0 \ -chardev tty,id=3Dcharserial0,path=3D/dev/ttyS2,,foo \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0,index=3D1 \ --add-fd set=3D0,fd=3D1750 \ --chardev file,id=3Dcharserial1,path=3D/dev/fdset/0,append=3Don \ +-add-fd set=3D1,fd=3D1750,opaque=3Dserial1-source \ +-chardev file,id=3Dcharserial1,path=3D/dev/fdset/1,append=3Don \ -device isa-serial,chardev=3Dcharserial1,id=3Dserial1,index=3D0 \ -chardev pipe,id=3Dcharchannel0,path=3D/tmp/guestfwd,,foo \ -netdev user,guestfwd=3Dtcp:10.0.2.1:4600-chardev:charchannel0,id=3Dchanne= l0 \ diff --git a/tests/qemuxml2argvdata/name-escape.x86_64-latest.args b/tests/= qemuxml2argvdata/name-escape.x86_64-latest.args index 0b3247b6bd..665a016a40 100644 --- a/tests/qemuxml2argvdata/name-escape.x86_64-latest.args +++ b/tests/qemuxml2argvdata/name-escape.x86_64-latest.args @@ -35,8 +35,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-foo=3D1,bar=3D2/.con= fig \ -device '{"driver":"ccid-card-emulated","backend":"certificates","cert1":"= cert1,foo","cert2":"cert2","cert3":"cert3","db":"/etc/pki/nssdb,foo","id":"= smartcard0","bus":"ccid0.0"}' \ -chardev tty,id=3Dcharserial0,path=3D/dev/ttyS2,,foo \ -device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","in= dex":1}' \ --add-fd set=3D0,fd=3D1750 \ --chardev file,id=3Dcharserial1,path=3D/dev/fdset/0,append=3Don \ +-add-fd set=3D1,fd=3D1750,opaque=3Dserial1-source \ +-chardev file,id=3Dcharserial1,path=3D/dev/fdset/1,append=3Don \ -device '{"driver":"isa-serial","chardev":"charserial1","id":"serial1","in= dex":0}' \ -chardev pipe,id=3Dcharchannel0,path=3D/tmp/guestfwd,,foo \ -netdev user,guestfwd=3Dtcp:10.0.2.1:4600-chardev:charchannel0,id=3Dchanne= l0 \ diff --git a/tests/qemuxml2argvdata/serial-file-chardev.args b/tests/qemuxm= l2argvdata/serial-file-chardev.args index 7df5c2a115..e4dee0033c 100644 --- a/tests/qemuxml2argvdata/serial-file-chardev.args +++ b/tests/qemuxml2argvdata/serial-file-chardev.args @@ -29,8 +29,8 @@ QEMU_AUDIO_DRV=3Dnone \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --add-fd set=3D0,fd=3D1750 \ --chardev file,id=3Dcharserial0,path=3D/dev/fdset/0,append=3Don \ +-add-fd set=3D1,fd=3D1750,opaque=3Dserial0-source \ +-chardev file,id=3Dcharserial0,path=3D/dev/fdset/1,append=3Don \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0,index=3D0 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/serial-file-chardev.x86_64-latest.args = b/tests/qemuxml2argvdata/serial-file-chardev.x86_64-latest.args index 6a28170503..568a1aaf76 100644 --- a/tests/qemuxml2argvdata/serial-file-chardev.x86_64-latest.args +++ b/tests/qemuxml2argvdata/serial-file-chardev.x86_64-latest.args @@ -31,8 +31,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ -device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1}' \ --add-fd set=3D0,fd=3D1750 \ --chardev file,id=3Dcharserial0,path=3D/dev/fdset/0,append=3Don \ +-add-fd set=3D1,fd=3D1750,opaque=3Dserial0-source \ +-chardev file,id=3Dcharserial0,path=3D/dev/fdset/1,append=3Don \ -device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","in= dex":0}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ diff --git a/tests/qemuxml2argvdata/serial-file-log.args b/tests/qemuxml2ar= gvdata/serial-file-log.args index 72d7c49298..1d237ca7c7 100644 --- a/tests/qemuxml2argvdata/serial-file-log.args +++ b/tests/qemuxml2argvdata/serial-file-log.args @@ -29,8 +29,8 @@ QEMU_AUDIO_DRV=3Dnone \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --add-fd set=3D0,fd=3D1750 \ --add-fd set=3D1,fd=3D1751 \ --chardev file,id=3Dcharserial0,path=3D/dev/fdset/0,append=3Don,logfile=3D/= dev/fdset/1,logappend=3Don \ +-add-fd set=3D1,fd=3D1750,opaque=3Dserial0-source \ +-add-fd set=3D2,fd=3D1751,opaque=3Dserial0-log \ +-chardev file,id=3Dcharserial0,path=3D/dev/fdset/1,append=3Don,logfile=3D/= dev/fdset/2,logappend=3Don \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0,index=3D0 \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/serial-file-log.x86_64-latest.args b/te= sts/qemuxml2argvdata/serial-file-log.x86_64-latest.args index c12b4b3a60..de47bad812 100644 --- a/tests/qemuxml2argvdata/serial-file-log.x86_64-latest.args +++ b/tests/qemuxml2argvdata/serial-file-log.x86_64-latest.args @@ -31,9 +31,9 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ -device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1}' \ --add-fd set=3D0,fd=3D1750 \ --add-fd set=3D1,fd=3D1751 \ --chardev file,id=3Dcharserial0,path=3D/dev/fdset/0,append=3Don,logfile=3D/= dev/fdset/1,logappend=3Don \ +-add-fd set=3D1,fd=3D1750,opaque=3Dserial0-source \ +-add-fd set=3D2,fd=3D1751,opaque=3Dserial0-log \ +-chardev file,id=3Dcharserial0,path=3D/dev/fdset/1,append=3Don,logfile=3D/= dev/fdset/2,logappend=3Don \ -device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","in= dex":0}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ diff --git a/tests/qemuxml2argvdata/serial-many-chardev.args b/tests/qemuxm= l2argvdata/serial-many-chardev.args index 5e80348d11..95a828e606 100644 --- a/tests/qemuxml2argvdata/serial-many-chardev.args +++ b/tests/qemuxml2argvdata/serial-many-chardev.args @@ -31,8 +31,8 @@ QEMU_AUDIO_DRV=3Dnone \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ -chardev pty,id=3Dcharserial0 \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0,index=3D0 \ --add-fd set=3D0,fd=3D1750 \ --chardev file,id=3Dcharserial1,path=3D/dev/fdset/0,append=3Don \ +-add-fd set=3D1,fd=3D1750,opaque=3Dserial1-source \ +-chardev file,id=3Dcharserial1,path=3D/dev/fdset/1,append=3Don \ -device isa-serial,chardev=3Dcharserial1,id=3Dserial1,index=3D1 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/serial-many-chardev.x86_64-latest.args = b/tests/qemuxml2argvdata/serial-many-chardev.x86_64-latest.args index cbdcc82052..0e5ebaf9e9 100644 --- a/tests/qemuxml2argvdata/serial-many-chardev.x86_64-latest.args +++ b/tests/qemuxml2argvdata/serial-many-chardev.x86_64-latest.args @@ -33,8 +33,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1}' \ -chardev pty,id=3Dcharserial0 \ -device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","in= dex":0}' \ --add-fd set=3D0,fd=3D1750 \ --chardev file,id=3Dcharserial1,path=3D/dev/fdset/0,append=3Don \ +-add-fd set=3D1,fd=3D1750,opaque=3Dserial1-source \ +-chardev file,id=3Dcharserial1,path=3D/dev/fdset/1,append=3Don \ -device '{"driver":"isa-serial","chardev":"charserial1","id":"serial1","in= dex":1}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b2d6606d6e..d4e518e3a1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -383,10 +383,17 @@ testPrepareHostBackendChardevOne(virDomainDeviceDef *= dev, virDomainChrSourceDef *chardev, void *opaque) { - virQEMUCaps *qemuCaps =3D opaque; + virDomainObj *vm =3D opaque; + qemuDomainObjPrivate *priv =3D vm->privateData; qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PRIVAT= E(chardev); + int fakesourcefd =3D -1; + const char *devalias =3D NULL; + bool usefdset =3D true; if (dev) { + virDomainDeviceInfo *info =3D virDomainDeviceGetInfo(dev); + devalias =3D info->alias; + /* vhost-user disk doesn't use FD passing */ if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) return 0; @@ -400,6 +407,8 @@ testPrepareHostBackendChardevOne(virDomainDeviceDef *de= v, /* TPMs FD passing setup is special and handled separately */ if (dev->type =3D=3D VIR_DOMAIN_DEVICE_TPM) return 0; + } else { + devalias =3D "monitor"; } switch ((virDomainChrType) chardev->type) { @@ -416,20 +425,15 @@ testPrepareHostBackendChardevOne(virDomainDeviceDef *= dev, break; case VIR_DOMAIN_CHR_TYPE_FILE: - if (fcntl(1750, F_GETFD) !=3D -1) - abort(); - charpriv->fd =3D 1750; + fakesourcefd =3D 1750; break; case VIR_DOMAIN_CHR_TYPE_UNIX: if (chardev->data.nix.listen && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE= )) { + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMA= NDLINE)) + fakesourcefd =3D 1729; - if (fcntl(1729, F_GETFD) !=3D -1) - abort(); - - charpriv->fd =3D 1729; - } + usefdset =3D false; break; case VIR_DOMAIN_CHR_TYPE_NMDM: @@ -437,10 +441,26 @@ testPrepareHostBackendChardevOne(virDomainDeviceDef *= dev, break; } + if (fakesourcefd !=3D -1) { + if (fcntl(fakesourcefd, F_GETFD) !=3D -1) + abort(); + + charpriv->sourcefd =3D qemuFDPassNew(devalias, priv, usefdset); + + if (qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source") = < 0) + return -1; + } + if (chardev->logfile) { - if (fcntl(1751, F_GETFD) !=3D -1) + int fd =3D 1751; + + if (fcntl(fd, F_GETFD) !=3D -1) abort(); - charpriv->logfd =3D 1751; + + charpriv->logfd =3D qemuFDPassNew(devalias, priv, true); + + if (qemuFDPassAddFD(charpriv->logfd, &fd, "-log") < 0) + return -1; } return 0; @@ -464,17 +484,11 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, if (qemuDomainDeviceBackendChardevForeach(vm->def, testPrepareHostBackendCharde= vOne, - info->qemuCaps) < 0) + vm) < 0) return NULL; - if (virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLI= NE)) { - qemuDomainChrSourcePrivate *monpriv =3D QEMU_DOMAIN_CHR_SOURCE_PRI= VATE(priv->monConfig); - - if (fcntl(1729, F_GETFD) !=3D -1) - abort(); - - monpriv->fd =3D 1729; - } + if (testPrepareHostBackendChardevOne(NULL, priv->monConfig, vm) < 0) + return NULL; for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDef *disk =3D vm->def->disks[i]; --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422622; cv=none; d=zohomail.com; s=zohoarc; b=VnguvR1947yJXPdFwKYdEpMeimPerB6tzPHscjIlrW2xxAK/k+UcuxujcJqZ4gfdd7xsOsdeiskVx8Cnztayhi1gKDN7IqKXK1xNw2HX96ePRs9OiwwRRc+e91m6YANccpGLZi8hm/u5hFNtNY1q0J83HQiB/uj2Hjm7v1wln90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422622; 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=N28Z0WPpOKJ59vp46hMOuCyovHvNWw6LuWNFUec118A=; b=C5gnmtdnX3mvP7UjCZeZxrYBflLNbgrZjJ/Q+FmfPXTAuRJPmrGpIkYUMluU/hU1oRY45ClnVUPdcRbJxk7abxaRdd0nGjpaW9wtUlnAfTHV4YU98iifV+22frtZMVh9/BsrBpXLvXZjlaYvoSfzKI1U3nQ0LlUeCzkDTuLx/Ak= 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 1644422622546477.34215858093637; Wed, 9 Feb 2022 08:03:42 -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-235-LX4kVsJjO9S9pqHjRsd7Yw-1; Wed, 09 Feb 2022 11:03:36 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D3C21937FE0; Wed, 9 Feb 2022 16:03:03 +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 93D1784A29; Wed, 9 Feb 2022 16:03:02 +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 559874A705; Wed, 9 Feb 2022 16:03:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2nBH012351 for ; Wed, 9 Feb 2022 11:02:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5D8237DE42; Wed, 9 Feb 2022 16:02:49 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4C2A7DE40 for ; Wed, 9 Feb 2022 16:02:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422621; 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=N28Z0WPpOKJ59vp46hMOuCyovHvNWw6LuWNFUec118A=; b=JbeumIFT97FbCMOm+GU0hNV59FRqwow8lu8C5Re79ZvhLlDBm+LtVZ/0FtOsFmYvnr4Gx4 w6ps6vb2QVCdNLkurYoZbSi7Oqlr8v6bNJyhaq91waA7zUuaHI1RwWiP84jzyJ3Oh9P3dH EPVqCq/Tq7Au9Jnlk7PP2HY9wnC3OE4= X-MC-Unique: LX4kVsJjO9S9pqHjRsd7Yw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/27] qemuDomainRemoveChrDevice: Detach fdset after chardev hot-unplug Date: Wed, 9 Feb 2022 17:02:07 +0100 Message-Id: <672249f632221ab0fcc0fd50cf9bc8627c1537a2.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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: 1644422624047100001 Content-Type: text/plain; charset="utf-8" Our code uses fdsets for the pipe passed from virtlogd to qemu, but the chardev hot-unplug code neglected to detach the fdset after the chardev was removed. This kept the FDs open by qemu even after they were not used any more. After the refactor to use qemuFDPass for chardevs we now configure the 'opaque' field for fdsets used for chardevs so we can use qemuHotplugRemoveFDSet to remove the unused fdset. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 1 + tests/qemuhotplugtest.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 03b7ca30de..e05edffae2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4881,6 +4881,7 @@ qemuDomainRemoveChrDevice(virQEMUDriver *driver, if (monitor) { qemuDomainObjEnterMonitor(driver, vm); rc =3D qemuMonitorDetachCharDev(priv->mon, charAlias); + qemuHotplugRemoveFDSet(priv->mon, chr->info.alias, NULL); qemuDomainObjExitMonitor(driver, vm); } diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 263a92425c..fe1b227b4e 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -708,7 +708,7 @@ mymain(void) DO_TEST_DETACH("console-compat-2-live", "console-virtio", false, false, "device_del", QMP_DEVICE_DELETED("console1") QMP_OK, - "chardev-remove", QMP_OK); + "chardev-remove", QMP_OK, "query-fdsets", "{\"return\":= []}"); DO_TEST_ATTACH("base-live", "disk-virtio", false, true, "human-monitor-command", HMP("OK\\r\\n"), @@ -768,7 +768,7 @@ mymain(void) "device_add", QMP_OK); DO_TEST_DETACH("base-live", "qemu-agent-detach", false, false, "device_del", QMP_DEVICE_DELETED("channel0") QMP_OK, - "chardev-remove", QMP_OK); + "chardev-remove", QMP_OK, "query-fdsets", "{\"return\":= []}"); DO_TEST_ATTACH("base-ccw-live", "ccw-virtio", false, true, "human-monitor-command", HMP("OK\\r\\n"), --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422646; cv=none; d=zohomail.com; s=zohoarc; b=icX5iLjF26A/jxxRwpsXv6zlAGujH634L0esrkORQnJEn+aaI9SB9FrasXWUBMabZ+ifjfOtDArtn2CDtRq7jyPlUaEB0y2NnlRf77daozOIahpJX2t93nMjjAHcAWFdV8WIcfnsOeG7Ei0FDbJyIwKYuGV0lsqc6VwpQor+sqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422646; 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=2sxakj9J8qdtMkfUsTX/HSZsmqEgG8NVMSyZta1e4G8=; b=LTes8qd5C/VdBx/KJcThY1Q6ITAO6IyUbqHx+PXZDydERHK2qpl5Jm9KhIm+sVvXaAavU6XTkSKmOBiIsFJ01tLlqpeuQx5snj44ykIKjbfHIAY1vvRnHIjRzUcCrTcxi69Lx2E2IJsVUdZtKVr8wAfbQ3zbJDXP75xqx2Liugo= 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 1644422646083328.21050157254047; Wed, 9 Feb 2022 08:04:06 -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-664-NGkE_RFcOb-V8LnSZ9G5zQ-1; Wed, 09 Feb 2022 11:03:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83390193F570; Wed, 9 Feb 2022 16:03:05 +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 63AE670F60; Wed, 9 Feb 2022 16:03:05 +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 092E41803390; Wed, 9 Feb 2022 16:03:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2oIm012364 for ; Wed, 9 Feb 2022 11:02:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 982697DE42; Wed, 9 Feb 2022 16:02:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id F20DE7DE40 for ; Wed, 9 Feb 2022 16:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422644; 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=2sxakj9J8qdtMkfUsTX/HSZsmqEgG8NVMSyZta1e4G8=; b=ErVvzSVePXrFORxKtR+XS2njG6wiEq8afOEHQiUbqclu0u9Mjs7+vsx37VC6SiUaS0eftg KyyYAl+tO6MhTl1aBlGrYCH6xqulPnsDT7oiGOmVsAF4mIfgk2OlKd9Uqhp0Oyknkbl4Xt AuNIAr96V4yvn1kPBHIiRUQD8bzHyRo= X-MC-Unique: NGkE_RFcOb-V8LnSZ9G5zQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/27] qemumonitorjsontest: chardev: Remove need to allow unused commands Date: Wed, 9 Feb 2022 17:02:08 +0100 Message-Id: <536f061d2266220525f192bb7ff1215036db437c.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.15 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: 1644422647928100001 Content-Type: text/plain; charset="utf-8" Don't add the command to the test monitor when we don't expect to invoke it rather than bypassing the test monitor. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 7987182a82..b7937a6046 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -659,9 +659,8 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption = *xmlopt, fulllabel =3D g_strdup_printf("qemuMonitorJSONTestAttachChardev(%s)", = label); - qemuMonitorTestAllowUnusedCommands(test); - - if (qemuMonitorTestAddItemExpect(test, "chardev-add", + if (expectargs && + qemuMonitorTestAddItemExpect(test, "chardev-add", expectargs, true, jsonreply) < 0) return -1; @@ -784,10 +783,10 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *= xmlopt, "data':{'type':'vdagent'}}}"); chr =3D (virDomainChrSourceDef) { .type =3D VIR_DOMAIN_CHR_TYPE_PIPE }; - CHECK("pipe", true, ""); + CHECK("pipe", true, NULL); chr =3D (virDomainChrSourceDef) { .type =3D VIR_DOMAIN_CHR_TYPE_STDIO = }; - CHECK("stdio", true, ""); + CHECK("stdio", true, NULL); #undef CHECK return ret; --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422628; cv=none; d=zohomail.com; s=zohoarc; b=cJ4qh58rAWuW7RyXOJFn8KfBDpVZHKgkHL9pHi1XpwEdnF4xFO4d4ojRNMg4bkwFoPUFh2ihqtxE1LHZgkBJ6ErXjkygrFqhsEkOc8F2RtHzMu1UMHtupsR8ZBbyWgcpLn0uer779NzuYEyZnEd+RV4VWMdPEj1UkjBMs18m/QM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422628; 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=vFPZbg5UE15vQjscwsEyBiobN29kjZxcOQQxlHWmW3A=; b=Asnc2iz/NY5nyx61ZG1pL7KcRusnDtEmpW2SQ5R2CAx9ORujml8SIAJPs0U/1ddCuRAL+LexqJhxeDOEimn6gp+SH1yG+wvf30IP/KQgPDpYrJkAjGr4vfjDUAPS4qE1Ut0BYTi3Sypyfh6Yy8OMfunJQiKFCj7mu3T//SnmGPU= 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 1644422627994943.7067970580252; Wed, 9 Feb 2022 08:03:47 -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-126-MYa6zQQgOry0n4DadgLKQA-1; Wed, 09 Feb 2022 11:03:43 -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 C38C0100D098; Wed, 9 Feb 2022 16:03:08 +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 77307798C3; Wed, 9 Feb 2022 16:03:08 +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 4644F4A705; Wed, 9 Feb 2022 16:03:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2pUP012377 for ; Wed, 9 Feb 2022 11:02:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id A595F7DE40; Wed, 9 Feb 2022 16:02:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12B237DE4A for ; Wed, 9 Feb 2022 16:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422626; 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=vFPZbg5UE15vQjscwsEyBiobN29kjZxcOQQxlHWmW3A=; b=cHD7cZ3hYB6VqxCbnGhsDY64JIBmgRW68urgb0ANuC3Gr/RqnrQqb6IaZJAUgsiiZjjYFm yElfAZRLCaxgH2npP+g76ctWK3iIE/SGEY1PD3dd7i/EkJEvyMi2G7QMv8XPRcUMIVBii+ a6eQYXm6JqBVeIyae0+2IWhXjFj5CvQ= X-MC-Unique: MYa6zQQgOry0n4DadgLKQA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/27] qemumonitorjsontest: Refactor chardev hotplug testing Date: Wed, 9 Feb 2022 17:02:09 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422629760100007 Content-Type: text/plain; charset="utf-8" The main objective of this patch is to use a proper instance of virDomainChrSourceDef allocated with the private data. To achieve this the test cases are grouped into blocks by how much they fill in the chardev definition. Some test cases are moved around so that the resulting sequence doesn't need extra clearing. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 214 +++++++++++++++++++----------------- 1 file changed, 113 insertions(+), 101 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index b7937a6046..d42ccefece 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -679,114 +679,126 @@ static int qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xmlopt, GHashTable *schema) { - virDomainChrSourceDef chr; int ret =3D 0; #define CHECK(label, fail, expectargs) \ - if (qemuMonitorJSONTestAttachOneChardev(xmlopt, schema, label, &chr, \ + if (qemuMonitorJSONTestAttachOneChardev(xmlopt, schema, label, chr, \ expectargs, NULL, NULL, fail) = < 0) \ ret =3D -1 - chr =3D (virDomainChrSourceDef) { .type =3D VIR_DOMAIN_CHR_TYPE_NULL }; - CHECK("null", false, - "{'id':'alias','backend':{'type':'null','data':{}}}"); - - chr =3D (virDomainChrSourceDef) { .type =3D VIR_DOMAIN_CHR_TYPE_VC }; - CHECK("vc", false, - "{'id':'alias','backend':{'type':'vc','data':{}}}"); - - chr =3D (virDomainChrSourceDef) { .type =3D VIR_DOMAIN_CHR_TYPE_PTY }; - if (qemuMonitorJSONTestAttachOneChardev(xmlopt, schema, "pty", &chr, - "{'id':'alias'," - "'backend':{'type':'pty'," - "'data':{}}}", - "\"pty\" : \"/dev/pts/0\"", - "/dev/pts/0", false) < 0) - ret =3D -1; + { + g_autoptr(virDomainChrSourceDef) chr =3D virDomainChrSourceDefNew(= xmlopt); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_NULL; + CHECK("null", false, + "{'id':'alias','backend':{'type':'null','data':{}}}"); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_VC; + CHECK("vc", false, + "{'id':'alias','backend':{'type':'vc','data':{}}}"); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_SPICEVMC; + CHECK("spicevmc", false, + "{'id':'alias','backend':{'type':'spicevmc'," + "'data':{'type':'vdagent'}}}"); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_PIPE; + CHECK("pipe", true, NULL); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_STDIO; + CHECK("stdio", true, NULL); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_PTY; + CHECK("pty missing path", true, + "{'id':'alias','backend':{'type':'pty','data':{}}}"); + if (qemuMonitorJSONTestAttachOneChardev(xmlopt, schema, "pty", chr, + "{'id':'alias'," + "'backend':{'type':'pty'," + "'data':{}}}", + "\"pty\" : \"/dev/pts/0\"", + "/dev/pts/0", false) < 0) + ret =3D -1; + } + + { + g_autoptr(virDomainChrSourceDef) chr =3D virDomainChrSourceDefNew(= xmlopt); + + chr->data.file.path =3D g_strdup("/test/path"); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_FILE; + CHECK("file", false, + "{'id':'alias','backend':{'type':'file','data':{'out':'/test= /path'}}}"); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_DEV; + CHECK("device", false, + "{'id':'alias','backend':{'type':'serial','data':{'device':'= /test/path'}}}"); + } + + { + g_autoptr(virDomainChrSourceDef) chr =3D virDomainChrSourceDefNew(= xmlopt); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_TCP; + chr->data.tcp.host =3D g_strdup("example.com"); + chr->data.tcp.service =3D g_strdup("1234"); + CHECK("tcp", false, + "{'id':'alias'," + "'backend':{'type':'socket'," + "'data':{'addr':{'type':'inet'," + "'data':{'host':'example.com'," + "'port':'1234'}}," + "'telnet':false," + "'server':false}}}"); + } + + { + g_autoptr(virDomainChrSourceDef) chr =3D virDomainChrSourceDefNew(= xmlopt); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_UDP; + chr->data.udp.connectHost =3D g_strdup("example.com"); + chr->data.udp.connectService =3D g_strdup("1234"); + CHECK("udp", false, + "{'id':'alias'," + "'backend':{'type':'udp'," + "'data':{'remote':{'type':'inet'," + "'data':{'host':'example.com'," + "'port':'1234'}}}}}"); + + chr->data.udp.bindService =3D g_strdup("4321"); + CHECK("udp", false, + "{'id':'alias'," + "'backend':{'type':'udp'," + "'data':{'remote':{'type':'inet'," + "'data':{'host':'example.com'," + "'port':'1234'}}," + "'local':{'type':'inet'," + "'data':{'host':''," + "'port':'4321'}}}}}"); + + chr->data.udp.bindHost =3D g_strdup("localhost"); + CHECK("udp", false, + "{'id':'alias'," + "'backend':{'type':'udp'," + "'data':{'remote':{'type':'inet'," + "'data':{'host':'example.com'," + "'port':'1234'}}," + "'local':{'type':'inet'," + "'data':{'host':'localhost'," + "'port':'4321'}}}}}"); + } + + { + g_autoptr(virDomainChrSourceDef) chr =3D virDomainChrSourceDefNew(= xmlopt); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + chr->data.nix.path =3D g_strdup("/path/to/socket"); + CHECK("unix", false, + "{'id':'alias'," + "'backend':{'type':'socket'," + "'data':{'addr':{'type':'unix'," + "'data':{'path':'/path/to/socket= '}}," + "'server':false}}}"); + } - chr =3D (virDomainChrSourceDef) { .type =3D VIR_DOMAIN_CHR_TYPE_PTY }; - CHECK("pty missing path", true, - "{'id':'alias','backend':{'type':'pty','data':{}}}"); - - memset(&chr, 0, sizeof(chr)); - chr.type =3D VIR_DOMAIN_CHR_TYPE_FILE; - chr.data.file.path =3D (char *) "/test/path"; - CHECK("file", false, - "{'id':'alias','backend':{'type':'file','data':{'out':'/test/pat= h'}}}"); - - memset(&chr, 0, sizeof(chr)); - chr.type =3D VIR_DOMAIN_CHR_TYPE_DEV; - chr.data.file.path =3D (char *) "/test/path"; - CHECK("device", false, - "{'id':'alias','backend':{'type':'serial','data':{'device':'/tes= t/path'}}}"); - - memset(&chr, 0, sizeof(chr)); - chr.type =3D VIR_DOMAIN_CHR_TYPE_TCP; - chr.data.tcp.host =3D (char *) "example.com"; - chr.data.tcp.service =3D (char *) "1234"; - CHECK("tcp", false, - "{'id':'alias'," - "'backend':{'type':'socket'," - "'data':{'addr':{'type':'inet'," - "'data':{'host':'example.com'," - "'port':'1234'}}," - "'telnet':false," - "'server':false}}}"); - - memset(&chr, 0, sizeof(chr)); - chr.type =3D VIR_DOMAIN_CHR_TYPE_UDP; - chr.data.udp.connectHost =3D (char *) "example.com"; - chr.data.udp.connectService =3D (char *) "1234"; - CHECK("udp", false, - "{'id':'alias'," - "'backend':{'type':'udp'," - "'data':{'remote':{'type':'inet'," - "'data':{'host':'example.com'," - "'port':'1234'}}}}}"); - - chr.data.udp.bindHost =3D (char *) "localhost"; - chr.data.udp.bindService =3D (char *) "4321"; - CHECK("udp", false, - "{'id':'alias'," - "'backend':{'type':'udp'," - "'data':{'remote':{'type':'inet'," - "'data':{'host':'example.com'," - "'port':'1234'}}," - "'local':{'type':'inet'," - "'data':{'host':'localhost'," - "'port':'4321'}}}}}"); - - chr.data.udp.bindHost =3D NULL; - chr.data.udp.bindService =3D (char *) "4321"; - CHECK("udp", false, - "{'id':'alias'," - "'backend':{'type':'udp'," - "'data':{'remote':{'type':'inet'," - "'data':{'host':'example.com'," - "'port':'1234'}}," - "'local':{'type':'inet'," - "'data':{'host':''," - "'port':'4321'}}}}}"); - memset(&chr, 0, sizeof(chr)); - chr.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - chr.data.nix.path =3D (char *) "/path/to/socket"; - CHECK("unix", false, - "{'id':'alias'," - "'backend':{'type':'socket'," - "'data':{'addr':{'type':'unix'," - "'data':{'path':'/path/to/socket'}}," - "'server':false}}}"); - - chr =3D (virDomainChrSourceDef) { .type =3D VIR_DOMAIN_CHR_TYPE_SPICEV= MC }; - CHECK("spicevmc", false, - "{'id':'alias','backend':{'type':'spicevmc','" - "data':{'type':'vdagent'}}}"); - - chr =3D (virDomainChrSourceDef) { .type =3D VIR_DOMAIN_CHR_TYPE_PIPE }; - CHECK("pipe", true, NULL); - - chr =3D (virDomainChrSourceDef) { .type =3D VIR_DOMAIN_CHR_TYPE_STDIO = }; - CHECK("stdio", true, NULL); #undef CHECK return ret; --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422643; cv=none; d=zohomail.com; s=zohoarc; b=fhVItWgWL59srBErkd5mkHGk+qLb4Uo0Q9Asw8oMnSdJ8mPKTaxXDLvSlYzoE0piYn39F1rLowfwrjQUG0r8xYBBFFH/PkO4uh+N4B974OFBUGGJ4NcE8juTJH0oUw5f1HRxONhlXXWrgOZD8JYk4kayXh7n3imPsaKGcfk9Klc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422643; 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=wG1txqCLPacOJOA8+P5osICl1uEzRpskjmNL8NyFwik=; b=kIfzZ0kJX1ja30EZKnR374sqqrCK8YlXcxY91tDNorqiFXLZeuVFUon/blUXZ3s/bh6vFewyktCJiHBhVK+8D5wKYbv7K0dI6Qyxmaou134pY92Pqr8D/bkZK36Jb863fKsdF3AJQJxuzLyf31ZTfYITjCSaK/IVYNOp7/YO0Rk= 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 1644422643256843.4241730593214; Wed, 9 Feb 2022 08:04:03 -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-489-wS93VTdcPZKTzjiAiEkL6A-1; Wed, 09 Feb 2022 11:03:42 -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 9DE1A1015DDC; Wed, 9 Feb 2022 16:03:08 +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 4411D798B8; Wed, 9 Feb 2022 16:03:08 +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 099621802FE8; Wed, 9 Feb 2022 16:03:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2q3e012386 for ; Wed, 9 Feb 2022 11:02:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id B1E307DE40; Wed, 9 Feb 2022 16:02:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14A107DE42 for ; Wed, 9 Feb 2022 16:02:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422642; 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=wG1txqCLPacOJOA8+P5osICl1uEzRpskjmNL8NyFwik=; b=Bogsp3Oa7qv1LQWm6oUh1GkAO1YhKI3TfzT8uDzt8emCSsHZO/JpVRJ2IlHalLSgbBn39e i3Pem994dUjADUzs25yg8p50yxrtuq06tG5cuAf6Eod2EkpflxH4WKe2oHo/yX2mI8HWQ1 fmVNIVPw6vt7FwlC4XfMAG+9O0HswIg= X-MC-Unique: wS93VTdcPZKTzjiAiEkL6A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/27] qemuMonitorJSONTestAttachChardev: Add test for TLS-secured TCP chardev Date: Wed, 9 Feb 2022 17:02:10 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422645031100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index d42ccefece..434677f25f 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -27,6 +27,7 @@ #include "qemu/qemu_block.h" #include "qemu/qemu_monitor_json.h" #include "qemu/qemu_qapi.h" +#include "qemu/qemu_alias.h" #include "virthread.h" #include "virerror.h" #include "virstring.h" @@ -736,6 +737,7 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xm= lopt, { g_autoptr(virDomainChrSourceDef) chr =3D virDomainChrSourceDefNew(= xmlopt); + qemuDomainChrSourcePrivate *chrSourcePriv =3D QEMU_DOMAIN_CHR_SOUR= CE_PRIVATE(chr); chr->type =3D VIR_DOMAIN_CHR_TYPE_TCP; chr->data.tcp.host =3D g_strdup("example.com"); @@ -748,6 +750,19 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *x= mlopt, "'port':'1234'}}," "'telnet':false," "'server':false}}}"); + + chr->data.tcp.tlscreds =3D true; + chrSourcePriv->tlsCredsAlias =3D qemuAliasTLSObjFromSrcAlias("alia= s"); + CHECK("tcp", false, + "{'id':'alias'," + "'backend':{'type':'socket'," + "'data':{'addr':{'type':'inet'," + "'data':{'host':'example.com'," + "'port':'1234'}}," + "'telnet':false," + "'server':false," + "'tls-creds':'objalias_tls0'}}}"); + } { --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422631; cv=none; d=zohomail.com; s=zohoarc; b=CvlWbgcStOlUDjT9CkaLlMUZ1twdqlnUrAUZqMqHz66gbZdz/UkAV80MSa461sMt9Z0JwHmxDgs/3d32WA4NejukmKHWnU9sFzXfyS+foQ89nlFBLNwrJRCT3R0YYS/u9WxD9De+rsUMi6r+e5hoIL6VSkERxdAH8RLnP0nUhQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422631; 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=F/w+zM1J7UHyrN+z3J76/XbprhLB+6Zk4fViEMUpoXM=; b=ZZQFrko2GIfmga4YOaHv8yE1M60zNRMDXma67sn3wsCqBbuCbbu4r93+w2z/aHZFH5Xd3m9HSo+qN8YOwYiLOOO0T3QfOjIv3b+LnCNGQL/lrASgYXXM5BhoNKb8a/AX5A1+YfzqiSzQBp2g2/x3XTO04A/4FGYVhTCyPhVDvFM= 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 1644422631556642.3032290272295; Wed, 9 Feb 2022 08:03:51 -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-570-3pZJ9vW-MtqBk6vpYzUNFA-1; Wed, 09 Feb 2022 11:03:47 -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 0F27384DA48; Wed, 9 Feb 2022 16:03: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 E385C798A5; Wed, 9 Feb 2022 16:03: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 B4AA34A708; Wed, 9 Feb 2022 16:03:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2rtI012403 for ; Wed, 9 Feb 2022 11:02:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id BF0F07DE42; Wed, 9 Feb 2022 16:02:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A7E87DE40 for ; Wed, 9 Feb 2022 16:02:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422630; 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=F/w+zM1J7UHyrN+z3J76/XbprhLB+6Zk4fViEMUpoXM=; b=fyWI3eUzeUDbl9kExXRSuC9w67JwiDzuPkmyoAXrxxonAIvGgawUL3gYcj/ZQlibYIp4wm I8jnbxKYkGsnCoTXllvNAj5UXGFkalxg3lWAFncSpnETUGokk+LX6jWl1o+0Sb9sZ1wL+T uDCI6ubpMRijiouowo4zY4cO1OcavaM= X-MC-Unique: 3pZJ9vW-MtqBk6vpYzUNFA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/27] qemuMonitorJSONTestAttachChardev: Add logfile to some tests Date: Wed, 9 Feb 2022 17:02:11 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422632908100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- tests/qemumonitorjsontest.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 434677f25f..8fbb199a59 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -726,13 +726,17 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *= xmlopt, chr->data.file.path =3D g_strdup("/test/path"); - chr->type =3D VIR_DOMAIN_CHR_TYPE_FILE; - CHECK("file", false, - "{'id':'alias','backend':{'type':'file','data':{'out':'/test= /path'}}}"); - chr->type =3D VIR_DOMAIN_CHR_TYPE_DEV; CHECK("device", false, "{'id':'alias','backend':{'type':'serial','data':{'device':'= /test/path'}}}"); + + chr->type =3D VIR_DOMAIN_CHR_TYPE_FILE; + chr->logfile =3D g_strdup("/test/logfile"); + chr->logappend =3D VIR_TRISTATE_SWITCH_OFF; + CHECK("file", false, + "{'id':'alias','backend':{'type':'file','data':{'out':'/test= /path'," + "'logfile':'/= test/logfile'," + "'logappend':= false}}}"); } { @@ -753,6 +757,7 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xm= lopt, chr->data.tcp.tlscreds =3D true; chrSourcePriv->tlsCredsAlias =3D qemuAliasTLSObjFromSrcAlias("alia= s"); + chr->logfile =3D g_strdup("/test/log"); CHECK("tcp", false, "{'id':'alias'," "'backend':{'type':'socket'," @@ -761,7 +766,8 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xm= lopt, "'port':'1234'}}," "'telnet':false," "'server':false," - "'tls-creds':'objalias_tls0'}}}"); + "'tls-creds':'objalias_tls0'," + "'logfile':'/test/log'}}}"); } --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422624; cv=none; d=zohomail.com; s=zohoarc; b=iph687fuTGTyma8l6gIJpD2wLSkadlRzhVOjFuwryMj3aSByq6kTpRSGhaieqThgmV+Kxn/JjkZg9UnzOfEWQ2EViTfHIZHb4Vm+HrpTmEpN9/xadwBBa8eJ8xNGNuWyWxtRnZbz33MClvdOVTdigrsU/17Elr8Lt6TQT1OVIaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422624; 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=mubS7TI0DaWNWOOo1r4l3G0+nLFBEDxt+CO3d+dblcs=; b=LuXX+5LJd77zp8/ylhnewWgcYIfXoc3TjGN3AMgFxZ85SgHrcA+UhiI1xOM/NV6l2gaRnWNmTa4EBjnBqfaf03KZijMSTo3svCODOQ/Ghr2gDD0OgFgwoqDR0DtGN9cKXyGaFuQCR6uzDvdujrX2RfAil6AUejV35HVqbwgMIdE= 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 164442262479238.03624061730943; Wed, 9 Feb 2022 08:03:44 -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-212-fE4-uBcJOZSlRwN2hrvMPA-1; Wed, 09 Feb 2022 11:03:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 842D99253B; Wed, 9 Feb 2022 16:03:11 +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 3FDEE7DE42; Wed, 9 Feb 2022 16:03:11 +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 0CEB84A709; Wed, 9 Feb 2022 16:03:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2sFD012415 for ; Wed, 9 Feb 2022 11:02:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id CE1B77DE42; Wed, 9 Feb 2022 16:02:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 308717DE4A for ; Wed, 9 Feb 2022 16:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422623; 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=mubS7TI0DaWNWOOo1r4l3G0+nLFBEDxt+CO3d+dblcs=; b=eGdxRSDZOAT8hg3In2dUbfZDvC7xJfQLomAhz9m/C6lIzc9zOtz0ifGHcwfyvujd+kxRnr kk+wkRUU2tEZCQt2msczBiFlviPkviNP7VmyR9HHQE5j0M6JAVkSewIKZ45av64ZZZzdJJ RweiuJIOzTwRIMjVPf2n6C0r/2AdCUg= X-MC-Unique: fE4-uBcJOZSlRwN2hrvMPA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/27] qemuMonitorJSONAttachCharDevGetProps: Properly handle private data Date: Wed, 9 Feb 2022 17:02:12 +0100 Message-Id: <8341999a47611af43c3ac8be7db352fed5f3c212.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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: 1644422626754100001 Content-Type: text/plain; charset="utf-8" FD passing and TLS is normally setup via private data for the chardev source. The monitor implementation didn't support it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor_json.c | 71 +++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e5425daf05..aac0ace7ff 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6527,6 +6527,23 @@ qemuMonitorJSONBuildUnixSocketAddress(const char *pa= th) return g_steal_pointer(&addr); } + +static virJSONValue * +qemuMonitorJSONBuildiFDSocketAddress(const char *fdname) +{ + g_autoptr(virJSONValue) addr =3D NULL; + g_autoptr(virJSONValue) data =3D NULL; + + if (virJSONValueObjectAdd(&data, "s:str", fdname, NULL) < 0) + return NULL; + + if (virJSONValueObjectAdd(&addr, + "s:type", "fd", + "a:data", &data, NULL) < 0) + return NULL; + + return g_steal_pointer(&addr); +} int qemuMonitorJSONNBDServerStart(qemuMonitor *mon, const virStorageNetHostDef *server, @@ -6683,6 +6700,7 @@ static virJSONValue * qemuMonitorJSONAttachCharDevGetProps(const char *chrID, const virDomainChrSourceDef *chr) { + qemuDomainChrSourcePrivate *chrSourcePriv =3D QEMU_DOMAIN_CHR_SOURCE_P= RIVATE(chr); g_autoptr(virJSONValue) props =3D NULL; g_autoptr(virJSONValue) backend =3D NULL; g_autoptr(virJSONValue) backendData =3D virJSONValueNewObject(); @@ -6695,14 +6713,22 @@ qemuMonitorJSONAttachCharDevGetProps(const char *ch= rID, backendType =3D virDomainChrTypeToString(chr->type); break; - case VIR_DOMAIN_CHR_TYPE_FILE: + case VIR_DOMAIN_CHR_TYPE_FILE: { + const char *path =3D chr->data.file.path; + virTristateSwitch append =3D chr->data.file.append; backendType =3D "file"; + + if (chrSourcePriv->sourcefd) { + path =3D qemuFDPassGetPath(chrSourcePriv->sourcefd); + append =3D VIR_TRISTATE_SWITCH_ON; + } + if (virJSONValueObjectAdd(&backendData, - "s:out", chr->data.file.path, - "T:append", chr->data.file.append, + "s:out", path, + "T:append", append, NULL) < 0) return NULL; - + } break; case VIR_DOMAIN_CHR_TYPE_DEV: @@ -6720,7 +6746,7 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrI= D, case VIR_DOMAIN_CHR_TYPE_UNIX: case VIR_DOMAIN_CHR_TYPE_TCP: { - g_autofree char *tlsalias =3D NULL; + const char *tlsalias =3D NULL; g_autoptr(virJSONValue) addr =3D NULL; virTristateBool waitval =3D VIR_TRISTATE_BOOL_ABSENT; virTristateBool telnet =3D VIR_TRISTATE_BOOL_ABSENT; @@ -6737,9 +6763,7 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrI= D, waitval =3D VIR_TRISTATE_BOOL_NO; } - if (chr->data.tcp.tlscreds && - !(tlsalias =3D qemuAliasTLSObjFromSrcAlias(chrID))) - return NULL; + tlsalias =3D chrSourcePriv->tlsCredsAlias; if (!(addr =3D qemuMonitorJSONBuildInetSocketAddress(chr->data= .tcp.host, chr->data.t= cp.service))) @@ -6755,13 +6779,18 @@ qemuMonitorJSONAttachCharDevGetProps(const char *ch= rID, waitval =3D VIR_TRISTATE_BOOL_NO; } - if (!(addr =3D qemuMonitorJSONBuildUnixSocketAddress(chr->data= .nix.path))) - return NULL; - - if (chr->data.nix.reconnect.enabled =3D=3D VIR_TRISTATE_BOOL_Y= ES) - reconnect =3D chr->data.tcp.reconnect.timeout; - else if (chr->data.nix.reconnect.enabled =3D=3D VIR_TRISTATE_B= OOL_NO) - reconnect =3D 0; + if (chrSourcePriv->sourcefd) { + if (!(addr =3D qemuMonitorJSONBuildiFDSocketAddress(qemuFD= PassGetPath(chrSourcePriv->sourcefd)))) + return NULL; + } else { + if (!(addr =3D qemuMonitorJSONBuildUnixSocketAddress(chr->= data.nix.path))) + return NULL; + + if (chr->data.nix.reconnect.enabled =3D=3D VIR_TRISTATE_BO= OL_YES) + reconnect =3D chr->data.tcp.reconnect.timeout; + else if (chr->data.nix.reconnect.enabled =3D=3D VIR_TRISTA= TE_BOOL_NO) + reconnect =3D 0; + } } if (virJSONValueObjectAdd(&backendData, @@ -6826,9 +6855,17 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chr= ID, } if (chr->logfile) { + const char *path =3D chr->logfile; + virTristateSwitch append =3D chr->logappend; + + if (chrSourcePriv->logfd) { + path =3D qemuFDPassGetPath(chrSourcePriv->logfd); + append =3D VIR_TRISTATE_SWITCH_ON; + } + if (virJSONValueObjectAdd(&backendData, - "s:logfile", chr->logfile, - "T:logappend", chr->logappend, + "s:logfile", path, + "T:logappend", append, NULL) < 0) return NULL; } --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422635; cv=none; d=zohomail.com; s=zohoarc; b=XMHdKq40Pbi0sIR0TtqefPfEJn3fhy4J/PjCOJguA1YL39a1qBXkn4AveKUeUWerZafB3WS27cy61NBJr2yJJzLc++oitjTqzqiMiEJ7cVZxtzLs26ubO4/QsNribvh/LUKC4ocIM0ZSUe4mYbhxhE3F2SpkUo0ootcWHEkFuTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422635; 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=y5WULjSSHogpq4Q1KikEguQPD/eAdHQS3Fi6WLvDdjs=; b=fkRAw4pnsTXJDSWDzW6lZcEduXc9ZsS2FPXiYmpWQrSKnucAmmlc/nuziyO5ahCmCEKpeMs0FXgngaGk1iRNqueZlbEnuLIaenp7jF4ZEQ6+w0pt9UkHtfpMuUfrxjma8JLeRCmXZiIqKmxjFJ26w6JS9wiHWHcm5/hwVqOONxE= 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 164442263575256.6777906871572; Wed, 9 Feb 2022 08:03:55 -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-304-6IrhDRTTPBKk95UIAHg6tg-1; Wed, 09 Feb 2022 11:03:51 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8FB62196633B; Wed, 9 Feb 2022 16:03:11 +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 6AF3F753C8; Wed, 9 Feb 2022 16:03:11 +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 36EE11818462; Wed, 9 Feb 2022 16:03:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2tUp012443 for ; Wed, 9 Feb 2022 11:02:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id D6DB37DE40; Wed, 9 Feb 2022 16:02:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 450F87DE4B for ; Wed, 9 Feb 2022 16:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422635; 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=y5WULjSSHogpq4Q1KikEguQPD/eAdHQS3Fi6WLvDdjs=; b=CtnSn4e7tt+7JYYZaeXy6RMeV39siR2pIQ1QRcwR9CTmVnlRDJWM9MfuyxsRBMzczJaa+x f+KMBRepW7NyQiY037ovuXjfe668eY2i6CBoDDhgypE1XXIgFhOYqeGTzI3zgcbqV9BFHc zH8nUWFoa1v1sjgarKGtwx1MXz/4X5Q= X-MC-Unique: 6IrhDRTTPBKk95UIAHg6tg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/27] tests: Move testPrepareHostBackendChardevOne into test utils Date: Wed, 9 Feb 2022 17:02:13 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.11 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: 1644422651589100003 Content-Type: text/plain; charset="utf-8" Move the function doing the fake setup of chardev backend for FD passing into the collection of qemu test helpers so that it can be used in qemumonitorjsontest. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemuxml2argvtest.c | 93 +--------------------------------- tests/testutilsqemu.c | 106 +++++++++++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 3 ++ 3 files changed, 111 insertions(+), 91 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d4e518e3a1..1e1d9ee9a1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -378,95 +378,6 @@ testCheckExclusiveFlags(int flags) } -static int -testPrepareHostBackendChardevOne(virDomainDeviceDef *dev, - virDomainChrSourceDef *chardev, - void *opaque) -{ - virDomainObj *vm =3D opaque; - qemuDomainObjPrivate *priv =3D vm->privateData; - qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PRIVAT= E(chardev); - int fakesourcefd =3D -1; - const char *devalias =3D NULL; - bool usefdset =3D true; - - if (dev) { - virDomainDeviceInfo *info =3D virDomainDeviceGetInfo(dev); - devalias =3D info->alias; - - /* vhost-user disk doesn't use FD passing */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) - return 0; - - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET) { - /* due to a historical bug in qemu we don't use FD passtrhough= for - * vhost-sockets for network devices */ - return 0; - } - - /* TPMs FD passing setup is special and handled separately */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_TPM) - return 0; - } else { - devalias =3D "monitor"; - } - - switch ((virDomainChrType) chardev->type) { - case VIR_DOMAIN_CHR_TYPE_NULL: - case VIR_DOMAIN_CHR_TYPE_VC: - case VIR_DOMAIN_CHR_TYPE_PTY: - case VIR_DOMAIN_CHR_TYPE_DEV: - case VIR_DOMAIN_CHR_TYPE_PIPE: - case VIR_DOMAIN_CHR_TYPE_STDIO: - case VIR_DOMAIN_CHR_TYPE_UDP: - case VIR_DOMAIN_CHR_TYPE_TCP: - case VIR_DOMAIN_CHR_TYPE_SPICEVMC: - case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - break; - - case VIR_DOMAIN_CHR_TYPE_FILE: - fakesourcefd =3D 1750; - break; - - case VIR_DOMAIN_CHR_TYPE_UNIX: - if (chardev->data.nix.listen && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMA= NDLINE)) - fakesourcefd =3D 1729; - - usefdset =3D false; - break; - - case VIR_DOMAIN_CHR_TYPE_NMDM: - case VIR_DOMAIN_CHR_TYPE_LAST: - break; - } - - if (fakesourcefd !=3D -1) { - if (fcntl(fakesourcefd, F_GETFD) !=3D -1) - abort(); - - charpriv->sourcefd =3D qemuFDPassNew(devalias, priv, usefdset); - - if (qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source") = < 0) - return -1; - } - - if (chardev->logfile) { - int fd =3D 1751; - - if (fcntl(fd, F_GETFD) !=3D -1) - abort(); - - charpriv->logfd =3D qemuFDPassNew(devalias, priv, true); - - if (qemuFDPassAddFD(charpriv->logfd, &fd, "-log") < 0) - return -1; - } - - return 0; -} - - static virCommand * testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, virDomainObj *vm, @@ -483,11 +394,11 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, return NULL; if (qemuDomainDeviceBackendChardevForeach(vm->def, - testPrepareHostBackendCharde= vOne, + testQemuPrepareHostBackendCh= ardevOne, vm) < 0) return NULL; - if (testPrepareHostBackendChardevOne(NULL, priv->monConfig, vm) < 0) + if (testQemuPrepareHostBackendChardevOne(NULL, priv->monConfig, vm) < = 0) return NULL; for (i =3D 0; i < vm->def->ndisks; i++) { diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 646ef415d1..c156a89413 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -13,6 +13,9 @@ # include "virstring.h" # include "virfilecache.h" +# include +# include + # define VIR_FROM_THIS VIR_FROM_QEMU virCPUDef *cpuDefault; @@ -979,3 +982,106 @@ testQemuInfoClear(struct testQemuInfo *info) virObjectUnref(info->qemuCaps); g_clear_pointer(&info->args.fakeCaps, virObjectUnref); } + + +/** + * testQemuPrepareHostBackendChardevOne: + * @dev: device definition object + * @chardev: chardev source object + * @opaque: Caller is expected to pass pointer to virDomainObj or NULL + * + * This helper sets up a chardev source backend for FD passing with fake + * file descriptros. It's expected to be used as callback for + * 'qemuDomainDeviceBackendChardevForeach', thus the VM object is passed v= ia + * @opaque. Callers may pass NULL if the test scope is limited. + */ +int +testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev, + virDomainChrSourceDef *chardev, + void *opaque) +{ + virDomainObj *vm =3D opaque; + qemuDomainObjPrivate *priv =3D NULL; + qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PRIVAT= E(chardev); + int fakesourcefd =3D -1; + const char *devalias =3D NULL; + bool usefdset =3D true; + + if (vm) + priv =3D vm->privateData; + + if (dev) { + virDomainDeviceInfo *info =3D virDomainDeviceGetInfo(dev); + devalias =3D info->alias; + + /* vhost-user disk doesn't use FD passing */ + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) + return 0; + + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET) { + /* due to a historical bug in qemu we don't use FD passtrhough= for + * vhost-sockets for network devices */ + return 0; + } + + /* TPMs FD passing setup is special and handled separately */ + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_TPM) + return 0; + } else { + devalias =3D "monitor"; + } + + switch ((virDomainChrType) chardev->type) { + case VIR_DOMAIN_CHR_TYPE_NULL: + case VIR_DOMAIN_CHR_TYPE_VC: + case VIR_DOMAIN_CHR_TYPE_PTY: + case VIR_DOMAIN_CHR_TYPE_DEV: + case VIR_DOMAIN_CHR_TYPE_PIPE: + case VIR_DOMAIN_CHR_TYPE_STDIO: + case VIR_DOMAIN_CHR_TYPE_UDP: + case VIR_DOMAIN_CHR_TYPE_TCP: + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: + case VIR_DOMAIN_CHR_TYPE_SPICEPORT: + break; + + case VIR_DOMAIN_CHR_TYPE_FILE: + fakesourcefd =3D 1750; + break; + + case VIR_DOMAIN_CHR_TYPE_UNIX: + if (chardev->data.nix.listen && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS_COMMA= NDLINE)) + fakesourcefd =3D 1729; + + usefdset =3D false; + break; + + case VIR_DOMAIN_CHR_TYPE_NMDM: + case VIR_DOMAIN_CHR_TYPE_LAST: + break; + } + + if (fakesourcefd !=3D -1) { + if (fcntl(fakesourcefd, F_GETFD) !=3D -1) + abort(); + + charpriv->sourcefd =3D qemuFDPassNew(devalias, priv, usefdset); + + if (qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source") = < 0) + return -1; + } + + if (chardev->logfile) { + int fd =3D 1751; + + if (fcntl(fd, F_GETFD) !=3D -1) + abort(); + + charpriv->logfd =3D qemuFDPassNew(devalias, priv, true); + + if (qemuFDPassAddFD(charpriv->logfd, &fd, "-log") < 0) + return -1; + } + + return 0; +} diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 51139e6a97..187f9b7cd3 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -143,4 +143,7 @@ void testQemuInfoSetArgs(struct testQemuInfo *info, int testQemuInfoInitArgs(struct testQemuInfo *info); void testQemuInfoClear(struct testQemuInfo *info); +int testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev, + virDomainChrSourceDef *chardev, + void *opaque); #endif --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422631; cv=none; d=zohomail.com; s=zohoarc; b=bHAHmYtP432pDne8oTj5H6tN6c20yXW07Sr7LltvaO1uE3NQeqYGIz9zoxzztkGodWyhKzDU8guLdp+N1jO761WZkMxZBpk8BYIPDuSAfMX0g1PtHySdc/8HaG7E9tIFWrPrsN+uHqFdNEbHPjVbZJ7iBhv0OBJLX9EfvK3DM7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422631; 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=FJ9kYWNpFxsgyH4sycCvoC+5qEnzTYlsERmpXKNowPs=; b=ORb8qvEUsSQRKX6KELsgAjYMfRLOTkmuO6bx63wMNUXF2+xXqafsya4rh4X33fZMApQa7z5onRfJzGh58yFlkZIqJTpoZzCkEJ6ytEjOUUBCJvvrLNURbog+ybrOw0G7tO+eKV+CCs8IEM839RVGf+QBqwIcHWNwMDItdxK5OJw= 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 1644422631681495.8132193548721; Wed, 9 Feb 2022 08:03:51 -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-646-TX_C6prQP-Gj4_NoEaLN3g-1; Wed, 09 Feb 2022 11:03:49 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E113186A8CD; Wed, 9 Feb 2022 16:03:14 +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 1ADBE84D0B; Wed, 9 Feb 2022 16:03:14 +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 D07164A707; Wed, 9 Feb 2022 16:03:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2uXF012464 for ; Wed, 9 Feb 2022 11:02:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id D9387838DF; Wed, 9 Feb 2022 16:02:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40EE57DE52 for ; Wed, 9 Feb 2022 16:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422630; 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=FJ9kYWNpFxsgyH4sycCvoC+5qEnzTYlsERmpXKNowPs=; b=RFWUIPU7Npf6O7bSZnwOCLbr0KfQMY51IrSvSEyird5AQRbSL/a4ulLdKKRbc67XiEelvS EcN34rnBxjfGvKph7YdSgaPq3Xx7gKsRlYfkujOgWV79hBOcXxiUrCL58+IbGSFbIalWGS jDivy0je8Y/k4VhyuLbh5LtYdVOI85g= X-MC-Unique: TX_C6prQP-Gj4_NoEaLN3g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/27] qemuMonitorJSONTestAttachChardev: Add tests for FD passing of file backend Date: Wed, 9 Feb 2022 17:02:14 +0100 Message-Id: <0059fb2de2eff22b77ae1dec2fb1dd2512a6be24.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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: 1644422632925100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitorjsontest.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 8fbb199a59..278d7ba765 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -680,6 +680,8 @@ static int qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xmlopt, GHashTable *schema) { + virDomainChrDef chrdev =3D { .info =3D { .alias =3D (char *) "alias" }= }; + virDomainDeviceDef dev =3D { .type =3D VIR_DOMAIN_DEVICE_CHR, .data.ch= r =3D &chrdev }; int ret =3D 0; #define CHECK(label, fail, expectargs) \ @@ -723,6 +725,7 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xm= lopt, { g_autoptr(virDomainChrSourceDef) chr =3D virDomainChrSourceDefNew(= xmlopt); + qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PR= IVATE(chr); chr->data.file.path =3D g_strdup("/test/path"); @@ -737,6 +740,16 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *x= mlopt, "{'id':'alias','backend':{'type':'file','data':{'out':'/test= /path'," "'logfile':'/= test/logfile'," "'logappend':= false}}}"); + + chrdev.source =3D chr; + ignore_value(testQemuPrepareHostBackendChardevOne(&dev, chr, NULL)= ); + qemuFDPassTransferMonitorFake(charpriv->sourcefd); + qemuFDPassTransferMonitorFake(charpriv->logfd); + CHECK("file", false, + "{'id':'alias','backend':{'type':'file','data':{'out':'/dev/= fdset/monitor-fake'," + "'append':tru= e," + "'logfile':'/= dev/fdset/monitor-fake'," + "'logappend':= true}}}"); } { --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422705; cv=none; d=zohomail.com; s=zohoarc; b=lhiLhnV7Bp7YUfOQAB317eOBDOIwOoxdYDSQbGA4K4Z0Zb1JNJTAZbnN2e2S9wl/oMNcZ+6z2/OMNnLptpKjgdKT5QHGlJe+c8/gvBW+6tleMBdHUcjYsXetAfbzIbstBvgZeNI+GHVJrp2bnVVJG6IZ8RgmeFIalM6qGjWXspQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422705; 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=L0z5E0EP444TofEn6mVlQI1s7QWJdLuwhemd7l6NZmw=; b=iVfu/uOWhkNEAm7L7Njebw9gEMWTL8oIkvUWYRE9vDrmYo/0Dw+br+WMP5XTl18dtOqKP6KBSt0lk8IWl3Q9Q7ghf5qZDWWvn67QIW976wxDZfkeS0ZkabdbNQBOw7AwrZgYDD9M60kmXWWL6oaf/YDIpAmpmVUAM2Fpub1UGjY= 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 1644422705547877.8332270716459; Wed, 9 Feb 2022 08:05:05 -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-578-Qea9Uo7iMiCAA-14kBLs2g-1; Wed, 09 Feb 2022 11:03:47 -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 0FA3384DA49; Wed, 9 Feb 2022 16:03:18 +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 E31AF79529; Wed, 9 Feb 2022 16:03: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 B33D218218B6; Wed, 9 Feb 2022 16:03:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2w6J012484 for ; Wed, 9 Feb 2022 11:02:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3ECAB7DE57; Wed, 9 Feb 2022 16:02:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B386838C6 for ; Wed, 9 Feb 2022 16:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422704; 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=L0z5E0EP444TofEn6mVlQI1s7QWJdLuwhemd7l6NZmw=; b=S7/MKulBs/9ECpaJBnzyyO1ElBpqs9usfWWXB0HqdOm7QuJNK7Vd/n1RnAbJHzJ5jhrc1P dDAPE/mrk0IzuKc1nIytfVDT/vHXmCVwqfSxGnXxhiYSVNf60adpb50hQEutrct6UIvzgd Azb640FFX4epz0txrGaMbSebxULXxR8= X-MC-Unique: Qea9Uo7iMiCAA-14kBLs2g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/27] qemu: process: Add a hotplug version of qemuProcessPrepareHostBackendChardev Date: Wed, 9 Feb 2022 17:02:15 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422707935100001 Content-Type: text/plain; charset="utf-8" When hotplugging a chardev we need the same form of setup for the character device. Export a version which takes a 'virDomainDeviceDef'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_process.h | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b44e684589..9fea72960f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6965,6 +6965,33 @@ qemuProcessPrepareHostBackendChardev(virDomainObj *v= m) } +int +qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm, + virDomainDeviceDef *dev) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv->dr= iver); + struct qemuProcessPrepareHostBackendChardevData data =3D { + .priv =3D priv, + .logManager =3D NULL, + .cfg =3D cfg, + .def =3D vm->def, + }; + g_autoptr(virLogManager) logManager =3D NULL; + + if (cfg->stdioLogD) { + if (!(logManager =3D data.logManager =3D virLogManagerNew(priv->dr= iver->privileged))) + return -1; + } + + if (qemuDomainDeviceBackendChardevForeachOne(dev, + qemuProcessPrepareHostBac= kendChardevOne, + &data) < 0) + return -1; + + return 0; +} + /** * qemuProcessPrepareHost: * @driver: qemu driver diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index f6dd3f5104..289cd74eb7 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -120,6 +120,12 @@ int qemuProcessOpenVhostVsock(virDomainVsockDef *vsock= ); int qemuProcessPrepareHostHostdev(virDomainHostdevDef *hostdev); + +int qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm, + virDomainDeviceDef *dev) + G_GNUC_NO_INLINE; + + int qemuProcessPrepareHost(virQEMUDriver *driver, virDomainObj *vm, unsigned int flags); --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422717; cv=none; d=zohomail.com; s=zohoarc; b=PHB2/bIMVxeP1X1+I7qjAm/MM7Zbpb7nyE08oe+Kq0lGFo9xRKMy6n8VHWFf9+yOF4++yupb0m7e4wLJPQI6iXNnmQX4QxvFcHLXQ1xj49U3q5n125SQvVEBEH8p+9cJAawAShAxYKW5E66UGHf3dpRrIXwS6tilahJ8ULJkAt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422717; 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=pjUoRMnKAkEUNhRpn1QTOSsHfLHkl2oxPw1ASr9DGQg=; b=ciH0udRminP7WmYYuNwV39rw+RCKHCzF3VRw5yXZv3C8wlBJSx5XIfcZp9iWW/kf3lih4mbYwBrVukPpFlMlQdNRTG9O9SBhCes7Wehv2n0+mv/GCbCnwVrulWqquNK3Zp/llVhZcQH+4csedfFA1QA1YNCxlHN28HNLzAYDBWQ= 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 1644422717642386.0856972297993; Wed, 9 Feb 2022 08:05:17 -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-329-lY3Xn6v0OrWqgPE-yySyRw-1; Wed, 09 Feb 2022 11:03:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EBEA485EE6A; Wed, 9 Feb 2022 16:03:20 +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 B70D47DE59; Wed, 9 Feb 2022 16:03: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 794D94A708; Wed, 9 Feb 2022 16:03:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2xYX012526 for ; Wed, 9 Feb 2022 11:02:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id B4E88838C3; Wed, 9 Feb 2022 16:02:59 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC988838D3 for ; Wed, 9 Feb 2022 16:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422716; 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=pjUoRMnKAkEUNhRpn1QTOSsHfLHkl2oxPw1ASr9DGQg=; b=YIiTk6OYAqfRSIwpbY8/dNKW3IeOVQzvhuKznSJjTMJZ1QUke+GnfhHNHvAsy8XhDf9ZXG 0PjtFVQjId0h9R60UZbpfomBeGmDBCPHo5TPvgSUSt4Mx3+YYneRZppyiE87KBFDfLDTpF cqA5flv/f7iVajbfAYGdjlNXiKYWlUc= X-MC-Unique: lY3Xn6v0OrWqgPE-yySyRw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 24/27] qemu: Honour 'virtlogd' use when hotplugging chardevs Date: Wed, 9 Feb 2022 17:02:16 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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: 1644422719658100001 Content-Type: text/plain; charset="utf-8" Setup the chardev similarly to how we do it on startup so that virtlogd is properly used with chardevs which are hotplugged to a VM. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 3 +-- src/qemu/qemu_hotplug.c | 25 ++++++++++++++++++++++--- src/qemu/qemu_hotplug.h | 2 +- tests/qemuhotplugmock.c | 11 +++++++++++ tests/qemuhotplugtest.c | 2 +- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9279eaf811..d6876baa34 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6730,8 +6730,7 @@ qemuDomainAttachDeviceLive(virDomainObj *vm, break; case VIR_DOMAIN_DEVICE_CHR: - ret =3D qemuDomainAttachChrDevice(driver, vm, - dev->data.chr); + ret =3D qemuDomainAttachChrDevice(driver, vm, dev); if (!ret) { alias =3D dev->data.chr->info.alias; dev->data.chr =3D NULL; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e05edffae2..01523ce508 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2180,10 +2180,14 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainObj *v= m, return 0; } -int qemuDomainAttachChrDevice(virQEMUDriver *driver, - virDomainObj *vm, - virDomainChrDef *chr) + +int +qemuDomainAttachChrDevice(virQEMUDriver *driver, + virDomainObj *vm, + virDomainDeviceDef *dev) { + virDomainChrDef *chr =3D dev->data.chr; + qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PRIVAT= E(chr->source); int ret =3D -1; qemuDomainObjPrivate *priv =3D vm->privateData; virErrorPtr orig_err; @@ -2224,6 +2228,19 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, goto cleanup; teardowncgroup =3D true; + if (qemuProcessPrepareHostBackendChardevHotplug(vm, dev) < 0) + goto cleanup; + + if (charpriv->sourcefd || charpriv->logfd) { + qemuDomainObjEnterMonitor(driver, vm); + + if (qemuFDPassTransferMonitor(charpriv->sourcefd, priv->mon) < 0 || + qemuFDPassTransferMonitor(charpriv->logfd, priv->mon) < 0) + goto exit_monitor; + + qemuDomainObjExitMonitor(driver, vm); + } + if (guestfwd) { if (!(netdevprops =3D qemuBuildChannelGuestfwdNetdevProps(chr))) goto cleanup; @@ -2286,6 +2303,8 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, /* detach associated chardev on error */ if (chardevAttached) qemuMonitorDetachCharDev(priv->mon, charAlias); + qemuFDPassTransferMonitorRollback(charpriv->sourcefd, priv->mon); + qemuFDPassTransferMonitorRollback(charpriv->logfd, priv->mon); qemuDomainObjExitMonitor(driver, vm); virErrorRestore(&orig_err); diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 244dd5278d..19c07497b5 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -117,7 +117,7 @@ int qemuDomainAttachLease(virQEMUDriver *driver, virDomainLeaseDef *lease); int qemuDomainAttachChrDevice(virQEMUDriver *driver, virDomainObj *vm, - virDomainChrDef *chr); + virDomainDeviceDef *dev); int qemuDomainAttachRNGDevice(virQEMUDriver *driver, virDomainObj *vm, virDomainRNGDef *rng); diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c index 051f2b20dc..e3f0715058 100644 --- a/tests/qemuhotplugmock.c +++ b/tests/qemuhotplugmock.c @@ -21,6 +21,7 @@ #include "qemu/qemu_hotplug.h" #include "qemu/qemu_interface.h" #include "qemu/qemu_process.h" +#include "testutilsqemu.h" #include "conf/domain_conf.h" #include "virdevmapper.h" #include "virutil.h" @@ -96,3 +97,13 @@ qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_UNU= SED) /* need a valid fd or sendmsg won't work. Just open /dev/null */ return open("/dev/null", O_RDONLY); } + + +int +qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm, + virDomainDeviceDef *dev) +{ + return qemuDomainDeviceBackendChardevForeachOne(dev, + testQemuPrepareHostBac= kendChardevOne, + vm); +} diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index fe1b227b4e..ce215da099 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -135,7 +135,7 @@ testQemuHotplugAttach(virDomainObj *vm, ret =3D qemuDomainAttachDeviceDiskLive(&driver, vm, dev); break; case VIR_DOMAIN_DEVICE_CHR: - ret =3D qemuDomainAttachChrDevice(&driver, vm, dev->data.chr); + ret =3D qemuDomainAttachChrDevice(&driver, vm, dev); break; case VIR_DOMAIN_DEVICE_SHMEM: ret =3D qemuDomainAttachShmemDevice(&driver, vm, dev->data.shmem); --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422708; cv=none; d=zohomail.com; s=zohoarc; b=NkwxFrYHCkjFtSaeqnBDU9zSkUEXRC1nHArSKKniu2anEb1o17XVGMsBXjGAWF5wXC/XopQHWBZMvsyKqJbnsv2fHPGgf6fuBx4+0GTW+3Hn7YGIOofBmKG8ln+F/O+Gw78jFoR7y/4lNeR2zbwuS/BzXMbvqY/osPA/qYrN/bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422708; 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=oYFjplOentf1E/C/6IIEB7bDZyy/gK0r9WNMbZnb7iU=; b=i+VfaSlf61mtP6MFQ8oTPQ6an551ur9aYFpdYhmOHbPVF2U+vFO5mksOyiZC87GhZmHGK0KAdYdLCrmdQrt9e7ut0+kTIaXfrF3NEwV8Cll7H6RdMClSg5QizhjHDlQ6z+f2B/0aOpO5d+8tDNPu8TYN6t2AMjJML2gVHgZfkA4= 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 164442270851540.65072990405952; Wed, 9 Feb 2022 08:05:08 -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-644-EUoYd-qcPgGNVKlhhGYx2w-1; Wed, 09 Feb 2022 11:03:49 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 651E586A8B2; Wed, 9 Feb 2022 16:03:14 +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 CC3BA8379D; Wed, 9 Feb 2022 16:03:13 +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 959071800B9E; Wed, 9 Feb 2022 16:03:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G31Fh012538 for ; Wed, 9 Feb 2022 11:03:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id D29F58276B; Wed, 9 Feb 2022 16:03:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E2117DE4D for ; Wed, 9 Feb 2022 16:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422707; 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=oYFjplOentf1E/C/6IIEB7bDZyy/gK0r9WNMbZnb7iU=; b=Oh0owNBYUtnMfaFSBkzjfnvfb3fXeeUG6gRvoIvHwqqr0tG6qeTrq4G7e6sihj7llDR4LZ T7/FYQiqiEyvy7VNB8qSVuRml+NfbdKov4WHZbkHztrWY8kmRYRGSsjaTrhHCZLkVS/gZC KXh403u81A7hAEdk7/r+4M7WqkPiG3s= X-MC-Unique: EUoYd-qcPgGNVKlhhGYx2w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/27] virTPMCreateCancelPath: Refactor value returning Date: Wed, 9 Feb 2022 17:02:17 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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: 1644422710812100001 Content-Type: text/plain; charset="utf-8" Automatically free 'path' inside the loop which fills it and return the values directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virtpm.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/util/virtpm.c b/src/util/virtpm.c index c02b42f948..8005708522 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -59,7 +59,6 @@ VIR_ENUM_IMPL(virTPMSwtpmSetupFeature, char * virTPMCreateCancelPath(const char *devpath) { - char *path =3D NULL; const char *dev; const char *prefix[] =3D {"misc/", "tpm/"}; size_t i; @@ -77,18 +76,14 @@ virTPMCreateCancelPath(const char *devpath) dev++; for (i =3D 0; i < G_N_ELEMENTS(prefix); i++) { - path =3D g_strdup_printf("/sys/class/%s%s/device/cancel", prefix[i= ], - dev); + g_autofree char *path =3D g_strdup_printf("/sys/class/%s%s/device/= cancel", + prefix[i], dev); if (virFileExists(path)) - break; - - VIR_FREE(path); + return g_steal_pointer(&path); } - if (!path) - path =3D g_strdup("/dev/null"); - return path; + return g_strdup("/dev/null"); } /* --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422632; cv=none; d=zohomail.com; s=zohoarc; b=Wel5HaZeBdZ17A88PKa8tuyXC1TBxjL8kHKAERLpj1g8633zT0ERsp5u3DGI+YMHPUTn1iAj3jYIY5yqBrupTGWcIUDIFqPI9Z80e5zdTKD+hoc3OsJUPreF3MxlUtPBPHDQOrZHxR0qYZU9WOarca3BLTW7YemFz+YXYQ90/Z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422632; 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=3gyMwW37bDCiaXT0EcSpPAGxPTodksy0xnCDIKwRhpQ=; b=FAAhM1DvYKECcCYfVCcoZ8sdfAwZOhweHDhwAwtJinxBMppQR6cb8pQKrWJoxN9as5M89eFVRFhPkfxHCBYUf3pIPgTXn3IToTFaSr+VQRIPDdLWmQA6JfoFUipan1stZJCy5232T9AtP24RLDRHiIHSzE/RSPExsYlmydaMzFo= 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 1644422632438498.3109168283688; Wed, 9 Feb 2022 08:03:52 -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-540-LvelwvQLNPan_-2JFTdTUQ-1; Wed, 09 Feb 2022 11:03:46 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 223C61091DBD; Wed, 9 Feb 2022 16:03:17 +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 F1BA47DE52; Wed, 9 Feb 2022 16:03:16 +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 568BE4A705; Wed, 9 Feb 2022 16:03:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G31qJ012549 for ; Wed, 9 Feb 2022 11:03:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id C464F7DE4A; Wed, 9 Feb 2022 16:03:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AB92838C6 for ; Wed, 9 Feb 2022 16:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422632; 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=3gyMwW37bDCiaXT0EcSpPAGxPTodksy0xnCDIKwRhpQ=; b=Hm+1IQWcdFFnw81nU3/cDeg9cnpyusliv4vb3KcEqwukG3M6dWn0bH688r/K7xQ6ofapnO 1nnwxTzyh3Hil9cbIrpQ+tnwE749OzkX3SzONNQxWfHmUTUCqVhFcne6JlTrKZajReHtgJ iC2FQnlgQ3LL3x+mdhSBU+CHbaHBtqA= X-MC-Unique: LvelwvQLNPan_-2JFTdTUQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 26/27] qemuBuildTPMOpenBackendFDs: Construct 'cancel_path' internally Date: Wed, 9 Feb 2022 17:02:18 +0100 Message-Id: <148a44a0331071b970ba3593a29052568745a624.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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: 1644422651225100001 Content-Type: text/plain; charset="utf-8" Since 'cancel_path' is constructed from the 'tpmdev' argument, we can push it down into the function opening the FDs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 15 +++++++-------- src/qemu/qemu_command.h | 4 +--- tests/qemuxml2argvmock.c | 1 - 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9a51a373b0..7169b8ff90 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9737,10 +9737,14 @@ qemuBuildTPMDevCmd(virCommand *cmd, /* this function is exported so that tests can mock the FDs */ int qemuBuildTPMOpenBackendFDs(const char *tpmdev, - const char *cancel_path, int *tpmfd, int *cancelfd) { + g_autofree char *cancel_path =3D NULL; + + if (!(cancel_path =3D virTPMCreateCancelPath(tpmdev))) + return -1; + if ((*tpmfd =3D open(tpmdev, O_RDWR)) < 0) { virReportSystemError(errno, _("Could not open TPM device %s"), tpmdev); @@ -9766,10 +9770,8 @@ qemuBuildTPMBackendStr(virCommand *cmd, int *cancelfd) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - g_autofree char *cancel_path =3D NULL; g_autofree char *devset =3D NULL; g_autofree char *cancelset =3D NULL; - const char *tpmdev; *tpmfd =3D -1; *cancelfd =3D -1; @@ -9779,11 +9781,8 @@ qemuBuildTPMBackendStr(virCommand *cmd, switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - tpmdev =3D tpm->data.passthrough.source->data.file.path; - if (!(cancel_path =3D virTPMCreateCancelPath(tpmdev))) - return NULL; - - if (qemuBuildTPMOpenBackendFDs(tpmdev, cancel_path, tpmfd, cancelf= d) < 0) + if (qemuBuildTPMOpenBackendFDs(tpm->data.passthrough.source->data.= file.path, + tpmfd, cancelfd) < 0) return NULL; virCommandPassFD(cmd, *tpmfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index b7fcf15a1e..d84de3f093 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -251,11 +251,9 @@ qemuBuildVsockDevProps(virDomainDef *def, /* this function is exported so that tests can mock the FDs */ int qemuBuildTPMOpenBackendFDs(const char *tpmdev, - const char *cancel_path, int *tpmfd, int *cancelfd) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) - ATTRIBUTE_NONNULL(4) G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) G_GNUC_= NO_INLINE; const char * qemuAudioDriverTypeToString(virDomainAudioType type); virDomainAudioType qemuAudioDriverTypeFromString(const char *str); diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index f4e2f52680..08f176667d 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -263,7 +263,6 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDe= f *dev G_GNUC_UNUSED) int qemuBuildTPMOpenBackendFDs(const char *tpmdev G_GNUC_UNUSED, - const char *cancel_path G_GNUC_UNUSED, int *tpmfd, int *cancelfd) { --=20 2.34.1 From nobody Sat Feb 7 15:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644422707; cv=none; d=zohomail.com; s=zohoarc; b=k1UvldjY+veZQEqzM5iKrOKa20SZpKr+ggu0dEaCw+32BgVbjlS9V1+zCfSvtIh3Fk9SrST3B3Byb5pevoyfii2PW0MFjzWHBMmxo4S9jq79WObCqVijTEWrEh3PH2A+lildkUuhusI7oVA2guUNaTnhxNxWjp1M59qzA3iVWYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422707; 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=aICIrdZAeoGLsOMU45pkaYVZasvX9SZI86tQd35AhcQ=; b=Wq+VAj5Ys+Z2AQDd8puIxu3aVSQZYYEPGMtQ4Y/nNQBYoeRofcASilaV33Yoa1agm+b75OKUpkkBqicFWzO24EAWA/VNU9K8408eMjucBuk3OIgj3KSM4+uqOh8ZuTO/Szdwina+PaOGti7uyx1wdQdY1LtLWAsqS1IY1yC+uYk= 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 1644422706998304.9979684659687; Wed, 9 Feb 2022 08:05:06 -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-367-qrJ4_jppMHqk1EhWMpMc0g-1; Wed, 09 Feb 2022 11:03:51 -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 EF24E100F959; Wed, 9 Feb 2022 16:03:19 +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 C85F2798A5; Wed, 9 Feb 2022 16:03:19 +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 95F6F18218B6; Wed, 9 Feb 2022 16:03:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G329E012565 for ; Wed, 9 Feb 2022 11:03:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id D68B47DE4A; Wed, 9 Feb 2022 16:03:02 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43699838E4 for ; Wed, 9 Feb 2022 16:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422705; 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=aICIrdZAeoGLsOMU45pkaYVZasvX9SZI86tQd35AhcQ=; b=E868g2z6hEySPeWV1dTalHdAY8/06F3YptVWYJGTN9/6NGp3yWgWL31eRDTVsioEUGCUz/ vbIyvNcbW0/N0DnxTlTiG5Vo0z/I8/pKNAP8hAl9sMiQAh9V07ubt1pdFHRdhYGCY/EerJ E488zD5HKRYYeaX31SCDNr0hGf7Zlnk= X-MC-Unique: qrJ4_jppMHqk1EhWMpMc0g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 27/27] qemuBuildTPMCommandLine: Use 'qemuPassFD' infrastructure Date: Wed, 9 Feb 2022 17:02:19 +0100 Message-Id: <2f693b177050df19b82f2f0b5dd546249f241b00.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: 1644422708162100004 Content-Type: text/plain; charset="utf-8" Remove the last code path using hardcoded fdsets. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 140 +++++------------- .../tpm-passthrough-crb.x86_64-latest.args | 6 +- .../tpm-passthrough.x86_64-latest.args | 6 +- 3 files changed, 45 insertions(+), 107 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7169b8ff90..9649ba3701 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -301,56 +301,6 @@ qemuBuildMasterKeyCommandLine(virCommand *cmd, } -/** - * qemuVirCommandGetFDSet: - * @cmd: the command to modify - * @fd: fd to reassign to the child - * - * Get the parameters for the QEMU -add-fd command line option - * for the given file descriptor. The file descriptor must previously - * have been 'transferred' in a virCommandPassFD() call. - * This function for example returns "set=3D10,fd=3D20". - */ -static char * -qemuVirCommandGetFDSet(virCommand *cmd, int fd) -{ - int idx =3D virCommandPassFDGetFDIndex(cmd, fd); - - if (idx < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("file descriptor %d has not been transferred"), f= d); - return NULL; - } - - return g_strdup_printf("set=3D%d,fd=3D%d", idx, fd); -} - - -/** - * qemuVirCommandGetDevSet: - * @cmd: the command to modify - * @fd: fd to reassign to the child - * - * Get the parameters for the QEMU path=3D parameter where a file - * descriptor is accessed via a file descriptor set, for example - * /dev/fdset/10. The file descriptor must previously have been - * 'transferred' in a virCommandPassFD() call. - */ -static char * -qemuVirCommandGetDevSet(virCommand *cmd, int fd) -{ - int idx =3D virCommandPassFDGetFDIndex(cmd, fd); - - if (idx < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("file descriptor %d has not been transferred"), f= d); - return NULL; - } - - return g_strdup_printf("/dev/fdset/%d", idx); -} - - static char * qemuBuildDeviceAddressPCIGetBus(const virDomainDef *domainDef, const virDomainDeviceInfo *info) @@ -9764,40 +9714,22 @@ qemuBuildTPMOpenBackendFDs(const char *tpmdev, static char * -qemuBuildTPMBackendStr(virCommand *cmd, - virDomainTPMDef *tpm, - int *tpmfd, - int *cancelfd) +qemuBuildTPMBackendStr(virDomainTPMDef *tpm, + qemuFDPass *passtpm, + qemuFDPass *passcancel) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - g_autofree char *devset =3D NULL; - g_autofree char *cancelset =3D NULL; - - *tpmfd =3D -1; - *cancelfd =3D -1; virBufferAsprintf(&buf, "%s", virDomainTPMBackendTypeToString(tpm->typ= e)); virBufferAsprintf(&buf, ",id=3Dtpm-%s", tpm->info.alias); switch (tpm->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - if (qemuBuildTPMOpenBackendFDs(tpm->data.passthrough.source->data.= file.path, - tpmfd, cancelfd) < 0) - return NULL; - - virCommandPassFD(cmd, *tpmfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); - virCommandPassFD(cmd, *cancelfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); - - if (!(devset =3D qemuVirCommandGetDevSet(cmd, *tpmfd)) || - !(cancelset =3D qemuVirCommandGetDevSet(cmd, *cancelfd))) - return NULL; - virBufferAddLit(&buf, ",path=3D"); - virQEMUBuildBufferEscapeComma(&buf, devset); + virQEMUBuildBufferEscapeComma(&buf, qemuFDPassGetPath(passtpm)); virBufferAddLit(&buf, ",cancel-path=3D"); - virQEMUBuildBufferEscapeComma(&buf, cancelset); - + virQEMUBuildBufferEscapeComma(&buf, qemuFDPassGetPath(passcancel)); break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: virBufferAddLit(&buf, ",chardev=3Dchrtpm"); @@ -9814,42 +9746,49 @@ static int qemuBuildTPMCommandLine(virCommand *cmd, const virDomainDef *def, virDomainTPMDef *tpm, - virQEMUCaps *qemuCaps) + qemuDomainObjPrivate *priv) { g_autofree char *tpmdevstr =3D NULL; - int tpmfd =3D -1; - int cancelfd =3D -1; - char *fdset; + g_autoptr(qemuFDPass) passtpm =3D NULL; + g_autoptr(qemuFDPass) passcancel =3D NULL; - if (tpm->type =3D=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) { - if (qemuBuildChardevCommand(cmd, tpm->data.emulator.source, "chrtp= m", qemuCaps) < 0) - return -1; - } + switch ((virDomainTPMBackendType) tpm->type) { + case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: { + VIR_AUTOCLOSE fdtpm =3D -1; + VIR_AUTOCLOSE fdcancel =3D -1; - if (!(tpmdevstr =3D qemuBuildTPMBackendStr(cmd, tpm, &tpmfd, &cancelfd= ))) - return -1; + if (qemuBuildTPMOpenBackendFDs(tpm->data.passthrough.source->data.= file.path, + &fdtpm, &fdcancel) < 0) + return -1; - virCommandAddArgList(cmd, "-tpmdev", tpmdevstr, NULL); + passtpm =3D qemuFDPassNew(tpm->info.alias, priv, true); + passcancel =3D qemuFDPassNew(tpm->info.alias, priv, true); - if (tpmfd >=3D 0) { - fdset =3D qemuVirCommandGetFDSet(cmd, tpmfd); - if (!fdset) + if (qemuFDPassAddFD(passtpm, &fdtpm, "-tpm") < 0 || + qemuFDPassAddFD(passcancel, &fdcancel, "-cancel") < 0) return -1; - - virCommandAddArgList(cmd, "-add-fd", fdset, NULL); - VIR_FREE(fdset); } + break; - if (cancelfd >=3D 0) { - fdset =3D qemuVirCommandGetFDSet(cmd, cancelfd); - if (!fdset) + case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (qemuBuildChardevCommand(cmd, tpm->data.emulator.source, "chrtp= m", priv->qemuCaps) < 0) return -1; + break; - virCommandAddArgList(cmd, "-add-fd", fdset, NULL); - VIR_FREE(fdset); + case VIR_DOMAIN_TPM_TYPE_LAST: + virReportEnumRangeError(virDomainTPMBackendType, tpm->type); + return -1; } - if (qemuBuildTPMDevCmd(cmd, def, tpm, qemuCaps) < 0) + qemuFDPassTransferCommand(passtpm, cmd); + qemuFDPassTransferCommand(passcancel, cmd); + + if (!(tpmdevstr =3D qemuBuildTPMBackendStr(tpm, passtpm, passcancel))) + return -1; + + virCommandAddArgList(cmd, "-tpmdev", tpmdevstr, NULL); + + if (qemuBuildTPMDevCmd(cmd, def, tpm, priv->qemuCaps) < 0) return -1; return 0; @@ -9880,16 +9819,15 @@ qemuBuildTPMProxyCommandLine(virCommand *cmd, static int qemuBuildTPMsCommandLine(virCommand *cmd, const virDomainDef *def, - virQEMUCaps *qemuCaps) + qemuDomainObjPrivate *priv) { size_t i; for (i =3D 0; i < def->ntpms; i++) { if (def->tpms[i]->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) { - if (qemuBuildTPMProxyCommandLine(cmd, def->tpms[i], qemuCaps) = < 0) + if (qemuBuildTPMProxyCommandLine(cmd, def->tpms[i], priv->qemu= Caps) < 0) return -1; - } else if (qemuBuildTPMCommandLine(cmd, def, - def->tpms[i], qemuCaps) < 0) { + } else if (qemuBuildTPMCommandLine(cmd, def, def->tpms[i], priv) <= 0) { return -1; } } @@ -10633,7 +10571,7 @@ qemuBuildCommandLine(virQEMUDriver *driver, if (qemuBuildConsoleCommandLine(cmd, def, qemuCaps) < 0) return NULL; - if (qemuBuildTPMsCommandLine(cmd, def, qemuCaps) < 0) + if (qemuBuildTPMsCommandLine(cmd, def, priv) < 0) return NULL; if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0) diff --git a/tests/qemuxml2argvdata/tpm-passthrough-crb.x86_64-latest.args = b/tests/qemuxml2argvdata/tpm-passthrough-crb.x86_64-latest.args index e099cf0fa1..b9f22188c2 100644 --- a/tests/qemuxml2argvdata/tpm-passthrough-crb.x86_64-latest.args +++ b/tests/qemuxml2argvdata/tpm-passthrough-crb.x86_64-latest.args @@ -27,9 +27,9 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-TPM-VM/.config \ -no-shutdown \ -boot menu=3Don,strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --tpmdev passthrough,id=3Dtpm-tpm0,path=3D/dev/fdset/0,cancel-path=3D/dev/f= dset/1 \ --add-fd set=3D0,fd=3D1730 \ --add-fd set=3D1,fd=3D1731 \ +-add-fd set=3D1,fd=3D1730,opaque=3Dtpm0-tpm \ +-add-fd set=3D2,fd=3D1731,opaque=3Dtpm0-cancel \ +-tpmdev passthrough,id=3Dtpm-tpm0,path=3D/dev/fdset/1,cancel-path=3D/dev/f= dset/2 \ -device '{"driver":"tpm-crb","tpmdev":"tpm-tpm0","id":"tpm0"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ diff --git a/tests/qemuxml2argvdata/tpm-passthrough.x86_64-latest.args b/te= sts/qemuxml2argvdata/tpm-passthrough.x86_64-latest.args index beb6a307cb..da042d3b2b 100644 --- a/tests/qemuxml2argvdata/tpm-passthrough.x86_64-latest.args +++ b/tests/qemuxml2argvdata/tpm-passthrough.x86_64-latest.args @@ -27,9 +27,9 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-TPM-VM/.config \ -no-shutdown \ -boot menu=3Don,strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --tpmdev passthrough,id=3Dtpm-tpm0,path=3D/dev/fdset/0,cancel-path=3D/dev/f= dset/1 \ --add-fd set=3D0,fd=3D1730 \ --add-fd set=3D1,fd=3D1731 \ +-add-fd set=3D1,fd=3D1730,opaque=3Dtpm0-tpm \ +-add-fd set=3D2,fd=3D1731,opaque=3Dtpm0-cancel \ +-tpmdev passthrough,id=3Dtpm-tpm0,path=3D/dev/fdset/1,cancel-path=3D/dev/f= dset/2 \ -device '{"driver":"tpm-tis","tpmdev":"tpm-tpm0","id":"tpm0"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ --=20 2.34.1