From nobody Fri Dec 19 21:47:40 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1646416519; cv=none; d=zohomail.com; s=zohoarc; b=fWnnlwhDNYmxWO3xyedDgU3pHWaIfpc/IrRd4M4/lH2CNSezZrJ2OXEr4eR/GHeH7L8SNGFzJDGCTmEWjVAuLFjOomeuIJ2mtuJf2EaDTxMlhO/zEEQttR7y8aIaWP6mfbg5Q4dBHFgkcLYKK3Uw/WF9ILYx8RJCT1VlIkW90vM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646416519; h=Content-Type:Content-Transfer-Encoding:Cc: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=jjYOx8PF5XhaZNI6XlydFCe206hP78FYRIgWjsb9uQs=; b=MUUnEuGDqlykl8Hj6UDJdSlrqt8OUpYyBdQANIAzycksqC2cNIDidVKAgOPZx9VdGiPUssNPMQW+Kym3zkJ9gmQgfZPf1Zix6LZA6lF/WMr79+eKVrf5jyCxjj1u9UPuhXIbxgGTvXLYzshbWP4lQeUaUGaCm1vGDbI+IV7RoD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646416519909912.3624743152653; Fri, 4 Mar 2022 09:55:19 -0800 (PST) Received: from localhost ([::1]:45450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQC98-00085o-JP for importer@patchew.org; Fri, 04 Mar 2022 12:55:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQB6l-0006ml-Fc for qemu-devel@nongnu.org; Fri, 04 Mar 2022 11:48:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40754) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQB6j-00081M-J1 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 11:48:46 -0500 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-440-v0jQjU0lOM-fH0GuDPtBKg-1; Fri, 04 Mar 2022 11:48:43 -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 F1027814600; Fri, 4 Mar 2022 16:48:42 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01D6E8658F; Fri, 4 Mar 2022 16:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646412525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jjYOx8PF5XhaZNI6XlydFCe206hP78FYRIgWjsb9uQs=; b=LiKPyR597Z+XUSXKWHfh9FlOHNJW04QZ48iVsbc/s7iZL+SRqny5yyMLxgGyIFxAFciWSv kS0ek/glMXEwIeIGxZGMwMNj1ahPQ9uihonT1J8IT8k62Uov7ruSFMtg5RJWuUeNTzLkbJ B0YJaewsfamrUn6hTglaF+0T3gyxDg4= X-MC-Unique: v0jQjU0lOM-fH0GuDPtBKg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 46/50] iotests: Allow using QMP with the QSD Date: Fri, 4 Mar 2022 17:47:07 +0100 Message-Id: <20220304164711.474713-47-kwolf@redhat.com> In-Reply-To: <20220304164711.474713-1-kwolf@redhat.com> References: <20220304164711.474713-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646416521610100001 Content-Type: text/plain; charset="utf-8" From: Hanna Reitz Add a parameter to optionally open a QMP connection when creating a QemuStorageDaemon instance. Signed-off-by: Hanna Reitz Message-Id: <20220216105355.30729-3-hreitz@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 6ba65eb1ff..6027780180 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -39,6 +39,7 @@ =20 from qemu.machine import qtest from qemu.qmp import QMPMessage +from qemu.aqmp.legacy import QEMUMonitorProtocol =20 # Use this logger for logging messages directly from the iotests module logger =3D logging.getLogger('qemu.iotests') @@ -348,14 +349,30 @@ def cmd(self, cmd): =20 =20 class QemuStorageDaemon: - def __init__(self, *args: str, instance_id: str =3D 'a'): + _qmp: Optional[QEMUMonitorProtocol] =3D None + _qmpsock: Optional[str] =3D None + # Python < 3.8 would complain if this type were not a string literal + # (importing `annotations` from `__future__` would work; but not on <= =3D 3.6) + _p: 'Optional[subprocess.Popen[bytes]]' =3D None + + def __init__(self, *args: str, instance_id: str =3D 'a', qmp: bool =3D= False): assert '--pidfile' not in args self.pidfile =3D os.path.join(test_dir, f'qsd-{instance_id}-pid') all_args =3D [qsd_prog] + list(args) + ['--pidfile', self.pidfile] =20 + if qmp: + self._qmpsock =3D os.path.join(sock_dir, f'qsd-{instance_id}.s= ock') + all_args +=3D ['--chardev', + f'socket,id=3Dqmp-sock,path=3D{self._qmpsock}', + '--monitor', 'qmp-sock'] + + self._qmp =3D QEMUMonitorProtocol(self._qmpsock, server=3DTrue) + # Cannot use with here, we want the subprocess to stay around # pylint: disable=3Dconsider-using-with self._p =3D subprocess.Popen(all_args) + if self._qmp is not None: + self._qmp.accept() while not os.path.exists(self.pidfile): if self._p.poll() is not None: cmd =3D ' '.join(all_args) @@ -370,11 +387,24 @@ def __init__(self, *args: str, instance_id: str =3D '= a'): =20 assert self._pid =3D=3D self._p.pid =20 + def qmp(self, cmd: str, args: Optional[Dict[str, object]] =3D None) \ + -> QMPMessage: + assert self._qmp is not None + return self._qmp.cmd(cmd, args) + def stop(self, kill_signal=3D15): self._p.send_signal(kill_signal) self._p.wait() self._p =3D None =20 + if self._qmp: + self._qmp.close() + + if self._qmpsock is not None: + try: + os.remove(self._qmpsock) + except OSError: + pass try: os.remove(self.pidfile) except OSError: --=20 2.35.1