From nobody Tue Feb 10 04:13:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590943746; cv=none; d=zohomail.com; s=zohoarc; b=g5zQITZDBCiPN4EWFo0kOWPnXNudy6YqBbLjLqM/IVX03VxPSYct0IohsRClG8R66Ach0UaARiQkUvrXfLO8BQUU49PlPbCAS7ImjQ4pRYjEHPvNCj1cqvc+MW6SCIZDgF/1nN5i15ehTYMijqTz4St2lpYcTqoQEZ1L7J1Rb9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590943746; 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=hSfG89j1yh/LShH9lpHtA4pkqoFK62nXlpymRDXmlAY=; b=B+bt9F5nWNeXK7/UbuXqGEVOV9YGGX67cELT7mZNm+uq/NReWOGjW8N1zzhH06oKt2Qjze8/QuRDs9nnduJtKuP0f5ZB8AspciU4bd/2ykWKixF4w2+iGVmb28eNCpMQziao8MP9pWgvYlDlSYfne+tfhA2cLMpoMpLMI7LlvWQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590943746216158.10336504844145; Sun, 31 May 2020 09:49:06 -0700 (PDT) Received: from localhost ([::1]:54350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfR8y-0008GK-Aj for importer@patchew.org; Sun, 31 May 2020 12:49:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfR0Y-0003Iv-Qv for qemu-devel@nongnu.org; Sun, 31 May 2020 12:40:22 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:34597 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jfR0X-00070T-Oi for qemu-devel@nongnu.org; Sun, 31 May 2020 12:40:22 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-4f6vSCdRMB69ERWZvM-fxQ-1; Sun, 31 May 2020 12:40:17 -0400 Received: by mail-wr1-f72.google.com with SMTP id m14so1789919wrj.12 for ; Sun, 31 May 2020 09:40:17 -0700 (PDT) Received: from localhost.localdomain (43.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.43]) by smtp.gmail.com with ESMTPSA id b187sm8297281wmd.26.2020.05.31.09.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 May 2020 09:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590943221; 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=hSfG89j1yh/LShH9lpHtA4pkqoFK62nXlpymRDXmlAY=; b=b5N7RJjFuuWrIr+V9i7OtyNwqMBSSg319w3mPCn7pU966l4zRypHyyw9QfmgMET+ETTIS5 LZ455pFlLGPLkvzA1+KTuMy4Zv/jC2rs0qCeEW8U6MKYxPJ9Rzg1/R9EuM2OW82IRqnU99 sf/9T6OC2jJdW9XefN5fWpMu8bp/ZUw= X-MC-Unique: 4f6vSCdRMB69ERWZvM-fxQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hSfG89j1yh/LShH9lpHtA4pkqoFK62nXlpymRDXmlAY=; b=IQYYbK3GQLuPhA97Ed7qJsatq3ckj5ksIGHe1XJpQYr1WVIt51TSiXS/SDDrhAEWDi xTpaI0eO+8suLudnlwQL/plHdhDfC5j1bsIGVqGe7bKuZqBun3ViVPzRnisO2EqJhKKW SQLulQDzWMB9A8pV45SIYJpQdSE7Z3nj2v886ogaOewDVX/xKh/ohDbFGI3yklOdMhha kzNhrw5fYqke+q4MylXPwYCjowcbKwfbEXKb0Fbd08B9H5UGWVj44HhuTq343OlPkqfO 2OLvhILppxR2Gc5GzeVRLY5GkrmC3tLCWC90fqkxaKn0D8a8/70KKGNJHa7cb2SbmadD uOIQ== X-Gm-Message-State: AOAM531r4qRFnr8um8Ny0xv5SDgvErPYhxGmLYWa971nmdjZIp25jFde 1ku8lRdsFUZFJ9SQS+uAiQ+cOFGuYliuEU15yZms6nRArvfsRBF6/CKsVCqGPAUUh06edYEMFFs lzY3nlA3ApPljlsI= X-Received: by 2002:a7b:c5d7:: with SMTP id n23mr19218271wmk.185.1590943216327; Sun, 31 May 2020 09:40:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh77KlO64phqJTcDuJt0gPKNWkW2egnQKIXztLKi9l6mDsg1cRYoXGChGRkZq/Axxfqzi/sw== X-Received: by 2002:a7b:c5d7:: with SMTP id n23mr19218248wmk.185.1590943216159; Sun, 31 May 2020 09:40:16 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 17/25] python/qemu/qtest: Check before accessing _qtest Date: Sun, 31 May 2020 18:38:38 +0200 Message-Id: <20200531163846.25363-18-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200531163846.25363-1-philmd@redhat.com> References: <20200531163846.25363-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" 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=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/31 12:39:08 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , Eduardo Habkost , kvm@vger.kernel.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcelo Tosatti , Markus Armbruster , Max Reitz , John Snow , Stefan Hajnoczi , Cleber Rosa , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: John Snow It can be None; so add assertions or exceptions where appropriate to guard the access accordingly. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200514055403.18902-30-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/qtest.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/python/qemu/qtest.py b/python/qemu/qtest.py index 4c88590eb0..888c8bd2f6 100644 --- a/python/qemu/qtest.py +++ b/python/qemu/qtest.py @@ -121,7 +121,8 @@ def _pre_launch(self): super()._pre_launch() self._qtest =3D QEMUQtestProtocol(self._qtest_path, server=3DTrue) =20 - def _post_launch(self): + def _post_launch(self) -> None: + assert self._qtest is not None super()._post_launch() self._qtest.accept() =20 @@ -129,6 +130,13 @@ def _post_shutdown(self): super()._post_shutdown() self._remove_if_exists(self._qtest_path) =20 - def qtest(self, cmd): - '''Send a qtest command to guest''' + def qtest(self, cmd: str) -> str: + """ + Send a qtest command to the guest. + + :param cmd: qtest command to send + :return: qtest server response + """ + if self._qtest is None: + raise RuntimeError("qtest socket not available") return self._qtest.cmd(cmd) --=20 2.21.3