From nobody Thu May 16 01:39:37 2024 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=1594765515; cv=none; d=zohomail.com; s=zohoarc; b=Tyf5aNUshSQU0Zb05UA3hWii1wCDSgxKBu3vKILqBnsj7hl7iref8kIKEjgX4Yg4JHBRr2dxXPn1QJ3R6gS4mDLaNqOP0xQfHhSYEElaDjyLqFv0WExtfklplQAwLLgDP43LkKqH8/dzAL6NNrm2OxnY7AfULo1ZVsuK7r41+Uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765515; 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=lFvJAvABHJhn9aUbqkhpwxA2JbVZYnPkXyaT9KSO/8A=; b=Nz3TTE1dJwUW7c0OuyPwEirkmjSkYc7hsGEzhbEpQvGvCLjjlGqjBawjUtJAmWSBzIK//uaNiqE0H+5JMGhKOcz+fzEQpUjHMIKFHJTRYtHBAw7tCyGuc4pL/vWW8dfly+ep/Jegzb6iesig1xaPVmavxGB3AeC2yoLvKFxqBRg= 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 1594765515161520.3247451139946; Tue, 14 Jul 2020 15:25:15 -0700 (PDT) Received: from localhost ([::1]:34080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTMP-0005Cv-PQ for importer@patchew.org; Tue, 14 Jul 2020 18:25:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJ5-0000Bk-5p for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:21:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27838 helo=us-smtp-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 1jvTJ3-0004VG-41 for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:21:46 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-q_MIO3efN6mOND-FbL76Mw-1; Tue, 14 Jul 2020 18:21:41 -0400 Received: by mail-wm1-f70.google.com with SMTP id l5so90068wml.7 for ; Tue, 14 Jul 2020 15:21:40 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id z6sm277928wmf.33.2020.07.14.15.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765304; 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=lFvJAvABHJhn9aUbqkhpwxA2JbVZYnPkXyaT9KSO/8A=; b=OUsSq+Id9uj1AfGr+Cz2wqjD3DhH/91gRDpLm4AxMndgGMVwmdZq085QZ0v9BJ31Eu1TNe kUHa1RVNSXeqbaT2cIgqjG4p97TMJgivcT5F/zJMw8QYpdPteAofpnCEOkOk21PcdHJsAh Zb2J190AyZ2vXDllW7sNsbrvuXla9lw= X-MC-Unique: q_MIO3efN6mOND-FbL76Mw-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=lFvJAvABHJhn9aUbqkhpwxA2JbVZYnPkXyaT9KSO/8A=; b=aEfrwfyfMaMQUPauGZ5h8ZxtS5xifMXwkSyRC/VZNLSxgARDVa073C1juLImmKTJDo fbFHey9i5q36/pQufQz2g+1O+JR4QbFGtgq9QsyQOc3u98q2QgLvJKZcUtmaEoT3ZVFg OaTmrnTEluw5Lg/P5nrljOh0Bu31ybV1JMLe7777U849EjN1b1FnfhXOZMtLdrcwScu4 pwiKxxYDelJwoBulNkB7cRaVzIVzMoz8gepbfEw5L3kcccAsm5oXGevv/ZujjdIgevcE a6vAght/cxIHjFfUw+Y2Rumo07NCBqzUL7QFmu5hQpkpI5xo1o5IMFpHj/hTfjS6a/J5 F7nA== X-Gm-Message-State: AOAM5312L/96iZtiiO6bRT1yk1R3V4aCD5Hd5ATABILNlEoUY9cEc/GT YOvdh1C1jfVC37i/Qlmr4aIJY137bcL/E0Ul2Z7MijgcY2SAAWNyM45Ot20XZxo9uXML/L6wo4V pfm12VRHH5BEBbTQ= X-Received: by 2002:a5d:43d2:: with SMTP id v18mr8036550wrr.196.1594765299326; Tue, 14 Jul 2020 15:21:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf5GQIef7IlQoICvopUEpJloqBEI51Q+7z/cOPUBnJBo96Jsm9gt1x42ZLYOv1EnHqyav7bg== X-Received: by 2002:a5d:43d2:: with SMTP id v18mr8036527wrr.196.1594765298999; Tue, 14 Jul 2020 15:21:38 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 01/19] scripts/performance: Add dissect.py script Date: Wed, 15 Jul 2020 00:21:14 +0200 Message-Id: <20200714222132.10815-2-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com 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.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 01:42:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Eduardo Habkost , John Snow , Ahmed Karaman , Aleksandar Markovic , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Ahmed Karaman Python script that dissects QEMU execution into three main phases: code generation, JIT execution and helpers execution. Syntax: dissect.py [-h] -- [] \ [] [-h] - Print the script arguments help message. Example of usage: dissect.py -- qemu-arm coulomb_double-arm Example output: Total Instructions: 4,702,865,362 Code Generation: 115,819,309 2.463% JIT Execution: 1,081,980,528 23.007% Helpers: 3,505,065,525 74.530% Signed-off-by: Ahmed Karaman Reviewed-by: Aleksandar Markovic Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200709052055.2650-2-ahmedkhaledkaraman@gmail.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- scripts/performance/dissect.py | 166 +++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100755 scripts/performance/dissect.py diff --git a/scripts/performance/dissect.py b/scripts/performance/dissect.py new file mode 100755 index 0000000000..bf24f50922 --- /dev/null +++ b/scripts/performance/dissect.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python3 + +# Print the percentage of instructions spent in each phase of QEMU +# execution. +# +# Syntax: +# dissect.py [-h] -- [] \ +# [] +# +# [-h] - Print the script arguments help message. +# +# Example of usage: +# dissect.py -- qemu-arm coulomb_double-arm +# +# This file is a part of the project "TCG Continuous Benchmarking". +# +# Copyright (C) 2020 Ahmed Karaman +# Copyright (C) 2020 Aleksandar Markovic +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import argparse +import os +import subprocess +import sys +import tempfile + + +def get_JIT_line(callgrind_data): + """ + Search for the first instance of the JIT call in + the callgrind_annotate output when ran using --tree=3Dcaller + This is equivalent to the self number of instructions of JIT. + + Parameters: + callgrind_data (list): callgrind_annotate output + + Returns: + (int): Line number + """ + line =3D -1 + for i in range(len(callgrind_data)): + if callgrind_data[i].strip('\n') and \ + callgrind_data[i].split()[-1] =3D=3D "[???]": + line =3D i + break + if line =3D=3D -1: + sys.exit("Couldn't locate the JIT call ... Exiting.") + return line + + +def main(): + # Parse the command line arguments + parser =3D argparse.ArgumentParser( + usage=3D'dissect.py [-h] -- ' + ' [] ' + ' []') + + parser.add_argument('command', type=3Dstr, nargs=3D'+', help=3Dargpars= e.SUPPRESS) + + args =3D parser.parse_args() + + # Extract the needed variables from the args + command =3D args.command + + # Insure that valgrind is installed + check_valgrind =3D subprocess.run( + ["which", "valgrind"], stdout=3Dsubprocess.DEVNULL) + if check_valgrind.returncode: + sys.exit("Please install valgrind before running the script.") + + # Save all intermediate files in a temporary directory + with tempfile.TemporaryDirectory() as tmpdirname: + # callgrind output file path + data_path =3D os.path.join(tmpdirname, "callgrind.data") + # callgrind_annotate output file path + annotate_out_path =3D os.path.join(tmpdirname, "callgrind_annotate= .out") + + # Run callgrind + callgrind =3D subprocess.run((["valgrind", + "--tool=3Dcallgrind", + "--callgrind-out-file=3D" + data_path] + + command), + stdout=3Dsubprocess.DEVNULL, + stderr=3Dsubprocess.PIPE) + if callgrind.returncode: + sys.exit(callgrind.stderr.decode("utf-8")) + + # Save callgrind_annotate output + with open(annotate_out_path, "w") as output: + callgrind_annotate =3D subprocess.run( + ["callgrind_annotate", data_path, "--tree=3Dcaller"], + stdout=3Doutput, + stderr=3Dsubprocess.PIPE) + if callgrind_annotate.returncode: + sys.exit(callgrind_annotate.stderr.decode("utf-8")) + + # Read the callgrind_annotate output to callgrind_data[] + callgrind_data =3D [] + with open(annotate_out_path, 'r') as data: + callgrind_data =3D data.readlines() + + # Line number with the total number of instructions + total_instructions_line_number =3D 20 + # Get the total number of instructions + total_instructions_line_data =3D \ + callgrind_data[total_instructions_line_number] + total_instructions =3D total_instructions_line_data.split()[0] + total_instructions =3D int(total_instructions.replace(',', '')) + + # Line number with the JIT self number of instructions + JIT_self_instructions_line_number =3D get_JIT_line(callgrind_data) + # Get the JIT self number of instructions + JIT_self_instructions_line_data =3D \ + callgrind_data[JIT_self_instructions_line_number] + JIT_self_instructions =3D JIT_self_instructions_line_data.split()[= 0] + JIT_self_instructions =3D int(JIT_self_instructions.replace(',', '= ')) + + # Line number with the JIT self + inclusive number of instructions + # It's the line above the first JIT call when running with --tree= =3Dcaller + JIT_total_instructions_line_number =3D JIT_self_instructions_line_= number-1 + # Get the JIT self + inclusive number of instructions + JIT_total_instructions_line_data =3D \ + callgrind_data[JIT_total_instructions_line_number] + JIT_total_instructions =3D JIT_total_instructions_line_data.split(= )[0] + JIT_total_instructions =3D int(JIT_total_instructions.replace(',',= '')) + + # Calculate number of instructions in helpers and code generation + helpers_instructions =3D JIT_total_instructions-JIT_self_instructi= ons + code_generation_instructions =3D total_instructions-JIT_total_inst= ructions + + # Print results (Insert commas in large numbers) + # Print total number of instructions + print('{:<20}{:>20}\n'. + format("Total Instructions:", + format(total_instructions, ','))) + # Print code generation instructions and percentage + print('{:<20}{:>20}\t{:>6.3f}%'. + format("Code Generation:", + format(code_generation_instructions, ","), + (code_generation_instructions / total_instructions) *= 100)) + # Print JIT instructions and percentage + print('{:<20}{:>20}\t{:>6.3f}%'. + format("JIT Execution:", + format(JIT_self_instructions, ","), + (JIT_self_instructions / total_instructions) * 100)) + # Print helpers instructions and percentage + print('{:<20}{:>20}\t{:>6.3f}%'. + format("Helpers:", + format(helpers_instructions, ","), + (helpers_instructions/total_instructions)*100)) + + +if __name__ =3D=3D "__main__": + main() --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765624; cv=none; d=zohomail.com; s=zohoarc; b=IF5GczxIY+EDjLLR1G1+sf2FODg10ew3cuxVNil0vpK0R1+Va/UUDwVmGKQxT1BetqyBZ1+GMsbOcmJ1sNZ9Dt1APV+LuymIoSTeuTXMAbvWjSBl0FNXeIS3gEn8ShKt3OtczKSV6/rsLFbC3GpECjGImk3pooIVokUVUCrvdZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765624; 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=8FhXd9jo3ZykzUIegSI6TSb8wRrSAAOgjzX+n7PAM3E=; b=H4xEnxFiD1igZPu6DgM+Oinn8NqrEiFasdTer1Vix8Ep46jR2FcTmPKIE29wLlcKjwiWwytCY4P9TMjFpBY/hYRD0jZQulGH0FHik66EVt/IKcFzMCgc5oRrlWTHIvABuiBXpJjzVowS+NY+8WL3O/LDFEjFas2BH7u9nFYOdAg= 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 1594765624699451.0836273634445; Tue, 14 Jul 2020 15:27:04 -0700 (PDT) Received: from localhost ([::1]:42568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTOB-0000Jk-D4 for importer@patchew.org; Tue, 14 Jul 2020 18:27:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJA-0000EQ-Ka for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:21:56 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:55051 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 1jvTJ7-0004VZ-5a for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:21:52 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-213-RryxhGZ0PHyIl952Tn3-gQ-1; Tue, 14 Jul 2020 18:21:45 -0400 Received: by mail-wr1-f71.google.com with SMTP id v3so19812wrq.10 for ; Tue, 14 Jul 2020 15:21:45 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id j145sm351404wmj.7.2020.07.14.15.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765307; 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=8FhXd9jo3ZykzUIegSI6TSb8wRrSAAOgjzX+n7PAM3E=; b=YXKTSTLdNTip89ad/saQckhVTe7tUqq6Xt0YNSYR3QeUkLH+KTsOxQwb5I0Kyo71fFQypn okxGdwsBgcK1PJMUI/vevpaPzmyXIc4eEvT47I1E95pN8YZ+QcYznOeg/PrO+Yo9WnS51y KAkDpX8wyVIqaqG2kJrUoDB0AVNvaqE= X-MC-Unique: RryxhGZ0PHyIl952Tn3-gQ-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=8FhXd9jo3ZykzUIegSI6TSb8wRrSAAOgjzX+n7PAM3E=; b=IPHoVHYi+E6SWhYkYpDQampYrawK+APcck3/Frg+DVvTW2Z7EOw425oyWbKgvppW0o 3PguIkXMhMIN7Y1ePY1SBu5V76z9NgZlfMpTeQX8aTCshS/R1wsquE9ApEJl/ehrmIZB u4k80aUQeM69RL81tl3eyswcEKfBS048dZmiC1EftljnafdrwRDBDQc5PsGiGEDyxOIU 42T7SCijjINCeEEmnmy5P2FUquAEU2MP5WjOLejqBCwG4tKWF9eN6Ze+tKJ8X0K1r7A+ ntLOXL8XKvO7S+vwL90UvCGGGc9Ne+N+xEcwxnXtOLsm12sX857m4ziJpDTVz4FFrrHM ryuw== X-Gm-Message-State: AOAM5315lHBst/6txZFzgqxUfUEL7pW/QRhnzFQOlrljjX2G561BHxCg qbv1K9drVjRpLDJMlY3l9hDeGXyyX4YSoktKxWPeR0z7ntM+cqV+ZTTy2eb2eJzHt4oJH+TWdPD PqhFWQ0acdcjHwD0= X-Received: by 2002:a5d:628b:: with SMTP id k11mr8159969wru.107.1594765304163; Tue, 14 Jul 2020 15:21:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzzUFgb07Cm3+x5Qosv7eEcZqNJKwtfLwh3QJmI2BohpotIatfLAm2GmCtHEnR79ejMueHeQ== X-Received: by 2002:a5d:628b:: with SMTP id k11mr8159951wru.107.1594765303957; Tue, 14 Jul 2020 15:21:43 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 02/19] python/machine.py: consolidate _post_shutdown() Date: Wed, 15 Jul 2020 00:21:15 +0200 Message-Id: <20200714222132.10815-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 12:02:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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 Move more cleanup actions into _post_shutdown. As a change, if QEMU should so happen to be terminated during a call to wait(), that event will now be logged. This is not likely to occur during normative use. Signed-off-by: John Snow Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200710050649.32434-2-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index c25f0b42cf..ca1f2114e6 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -294,6 +294,8 @@ def _post_launch(self): self._qmp.accept() =20 def _post_shutdown(self): + self._load_io_log() + if self._qemu_log_file is not None: self._qemu_log_file.close() self._qemu_log_file =3D None @@ -307,6 +309,17 @@ def _post_shutdown(self): while len(self._remove_files) > 0: self._remove_if_exists(self._remove_files.pop()) =20 + exitcode =3D self.exitcode() + if exitcode is not None and exitcode < 0: + msg =3D 'qemu received signal %i; command: "%s"' + if self._qemu_full_args: + command =3D ' '.join(self._qemu_full_args) + else: + command =3D '' + LOG.warning(msg, -int(exitcode), command) + + self._launched =3D False + def launch(self): """ Launch the VM and make sure we cleanup and expose the @@ -355,7 +368,6 @@ def wait(self): self._popen.wait() if self._qmp: self._qmp.close() - self._load_io_log() self._post_shutdown() =20 def shutdown(self, has_quit=3DFalse, hard=3DFalse): @@ -382,21 +394,8 @@ def shutdown(self, has_quit=3DFalse, hard=3DFalse): self._popen.kill() self._popen.wait() =20 - self._load_io_log() self._post_shutdown() =20 - exitcode =3D self.exitcode() - if exitcode is not None and exitcode < 0 and \ - not (exitcode =3D=3D -9 and hard): - msg =3D 'qemu received signal %i: %s' - if self._qemu_full_args: - command =3D ' '.join(self._qemu_full_args) - else: - command =3D '' - LOG.warning(msg, -int(exitcode), command) - - self._launched =3D False - def kill(self): self.shutdown(hard=3DTrue) =20 --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765735; cv=none; d=zohomail.com; s=zohoarc; b=fucfgAMnyHK5Hz4QND0PvSlyKMpDaKSkZavrNZfVLz1WqbwQRc1OxupEtqSBWWO4Y1XdmA7zgqiqqV2ZOdQU+nAEcW6kALxNg0ERYCaVAxrFMuBkcUYAeSAwsArXk054MFCOTfB+qLlPUYkEDc/1p5wKwm7Ivrqfb5pqLn9Edwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765735; 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=f4PIu0HMQQfwQmcqNhOsRKcF3CqOiR6vgF4LSRdEoL8=; b=MUhYEP3szdxqRbg7ZZiY4Vp9xLXJb0JKjSDi0YuUVogkGK2o2MC4oLDYeg7FRZ3Z/4XWXqepQ7koP5IoRmuUgADTc6K+AXHEnqUqysrQrINo/OmPWCQwH5dOXBM/ObdTA+JryKT/orCTb/bDL4iyZz+m6c70tv0l60qsPp3AALI= 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 1594765735895461.1146631370582; Tue, 14 Jul 2020 15:28:55 -0700 (PDT) Received: from localhost ([::1]:50996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTPx-0003kP-QE for importer@patchew.org; Tue, 14 Jul 2020 18:28:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJE-0000F1-J4 for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:21:56 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:47098 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 1jvTJA-0004W1-NJ for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:21:56 -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-226-qxrP7g1zO42P-jKnvr-Rvw-1; Tue, 14 Jul 2020 18:21:50 -0400 Received: by mail-wr1-f72.google.com with SMTP id o25so17927wro.16 for ; Tue, 14 Jul 2020 15:21:50 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id j6sm181798wro.25.2020.07.14.15.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765311; 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=f4PIu0HMQQfwQmcqNhOsRKcF3CqOiR6vgF4LSRdEoL8=; b=I4oPX68cWplyaskyWsF8q1BOyKyOatqEFQuarlHi1KuBQ+rVS9T+2qOMXwBl2+WlZX2DbW FWd6gkxC/a9W5bbTsuoxSAwzkviRsEUSk2UFGZYQl9R2GlyzdhZFrIhAoUUMMvVnA4biVS z+aeYFWLe4LKcFV13uvYl+/U1/frJ3k= X-MC-Unique: qxrP7g1zO42P-jKnvr-Rvw-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=f4PIu0HMQQfwQmcqNhOsRKcF3CqOiR6vgF4LSRdEoL8=; b=jASlVRxaHYrxxZHForxYuacahVLR2hQa2RcZdTkJpKrImfb8IhZgNAqa3WetnDNaSo sfTWCcyHGuh4F1Ox1OOYkBlL9K4ksF+S5SVjxjVWtUhqrS8fAwRSU9x5vR0LqQZd5ify g/mcTeXobd/U8yMJzwTD3FXzZGnYJhnHa9ii+bX/UMYDKiu0HJ5itkB3NZz/MPFC/2Q4 QqcXDIbtZ3hm4XGJSBSwRqfzLTZk9btr468OcModEbaLKg9FmDHPm22s3ntb37Vauw3A NdXkEsgYzuZKzf0kzzgnLVZB5oC2ChDV0COJAiOAJWNB8nrzPmrG7zjLAQ0kD3P80eCC bcew== X-Gm-Message-State: AOAM531UAY87lNIP+8ovZasRU97PJdNgGuUnuXfK9bMU1DgPJyWG64mJ rjx7tUBplYJjlXwUjP8xRcO3Mk+KqWo6vWu+aNrwQeLJ+sZ/rzHdbNM43ZUgaNYsoEUw6Ow+9oi VSnbRpuItjDnXbQM= X-Received: by 2002:a1c:3bc1:: with SMTP id i184mr5729269wma.119.1594765308880; Tue, 14 Jul 2020 15:21:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKDnGybAjeG5dJqWW0wSiVBJBdnKyUwvcrZOYtDNIFnAYbHL6Th6v+//SXR1HN3sCe/buyCQ== X-Received: by 2002:a1c:3bc1:: with SMTP id i184mr5729252wma.119.1594765308665; Tue, 14 Jul 2020 15:21:48 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 03/19] python/machine.py: Close QMP socket in cleanup Date: Wed, 15 Jul 2020 00:21:16 +0200 Message-Id: <20200714222132.10815-4-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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/07/14 03:57:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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's not important to do this before waiting for the process to exit, so it can be done during generic post-shutdown cleanup. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Message-Id: <20200710050649.32434-3-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index ca1f2114e6..d3faa9a84c 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -294,6 +294,10 @@ def _post_launch(self): self._qmp.accept() =20 def _post_shutdown(self): + if self._qmp: + self._qmp.close() + self._qmp =3D None + self._load_io_log() =20 if self._qemu_log_file is not None: @@ -366,8 +370,6 @@ def wait(self): Wait for the VM to power off """ self._popen.wait() - if self._qmp: - self._qmp.close() self._post_shutdown() =20 def shutdown(self, has_quit=3DFalse, hard=3DFalse): @@ -388,7 +390,6 @@ def shutdown(self, has_quit=3DFalse, hard=3DFalse): try: if not has_quit: self._qmp.cmd('quit') - self._qmp.close() self._popen.wait(timeout=3D3) except: self._popen.kill() --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765420; cv=none; d=zohomail.com; s=zohoarc; b=WE65AkOBx0qozRS3rXGw9CqkCLuY5M7jKaucw/E+8LyoSTe2NQZNHGiVinRS5l37QcJkTbNf4SZFhzqs7wAG3pBxSF60zcxkbsuPSTwHWShVULKsDprCSzi3GZg72DO7KGuKVmEejzhlx7zQkFCCDknEAJ04n/Cu/rkNSJJ//N4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765420; 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=Ieea/9qJdXQlkW1JakEFibi3dTSnv+m6I0AuJj8UjYg=; b=Qh5kUQMzcIIXAwtNbBlLpe8DAtp9G9BPoVM2gmcCBp1MUxeJJrnMZhv4KDRvx1VJfYzVIjF/gpdJYsGYV5WoqunrXeDDPdJZ+1ZD65mOwCr/D2CtOV+CNZilzE9SYFIj2mQsDLs2vAz2/GUO5nuvMuIuMAaU/XXk6XK+nh+K3kw= 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 1594765420229125.16226101168672; Tue, 14 Jul 2020 15:23:40 -0700 (PDT) Received: from localhost ([::1]:54534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTKt-0001wO-0J for importer@patchew.org; Tue, 14 Jul 2020 18:23:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJI-0000Ic-Mg for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:00 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37396 helo=us-smtp-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 1jvTJH-0004Wn-7G for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:00 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-1Eq9Bf-vM86VZ1garop8iQ-1; Tue, 14 Jul 2020 18:21:54 -0400 Received: by mail-wr1-f69.google.com with SMTP id c6so21754wru.7 for ; Tue, 14 Jul 2020 15:21:54 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id d13sm134916wrq.89.2020.07.14.15.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765318; 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=Ieea/9qJdXQlkW1JakEFibi3dTSnv+m6I0AuJj8UjYg=; b=SsRDyt9tGqJ86hTatVRIlYRbUPiJFeSjKcLXpqnh/8NRFW6V6/pcrjAyvpfpum2jitCoLg LTNZegyzDBlogrEX4qTGIvqysF1j8GCOQ9A0DX0d8T/rQlqODsaFP85E7crzGiV8E6PY9k aI7hNfE26atJSMBUnbizeNbBvcCi+4Q= X-MC-Unique: 1Eq9Bf-vM86VZ1garop8iQ-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=Ieea/9qJdXQlkW1JakEFibi3dTSnv+m6I0AuJj8UjYg=; b=fj47+WhnQ2/5oLoWFgvyggIw3VKI6uQyDu2z+nZtZh7bwj+J553JyBIE6aZab6rNrM Uf71T7xT3JI1ICrBoshcyfgn8zQDYG6TpUb30G3ua7VTorAKk7Vxe/SWKP4+yXa82qSk 5fBChwbXh0ZO5rugTDNPJ0pl0y/mCWV0ZRL6dTqfXLgYxvhjxH3hgxO8QlxnvNH1WBXk EoGkxV+Q51ZNZfHaqWbWtVOo7542gy/PUTF4aIUsItp3Zxxj3HVEBAOgsLM5VRUn6bN0 spwoGN3XNsFRksgSInGIKeSl/bGPi6SEFhJRLuyvLXT4Kbizbms+xJ8QvBQltwWXSijS m1LA== X-Gm-Message-State: AOAM533r0ka1bopatUODwyODV1irLKSSZG8Ca/WV84eWUM2up5S221C1 VpI6rfH/SeZO4rfXl6YlJeDMxa+M7pRKBO6iohYBQuABHOgVN8JsxcFpe2Dc/IItThI0ycPyrvv IJgymXvP6meLJSR0= X-Received: by 2002:adf:ed02:: with SMTP id a2mr8044793wro.110.1594765313494; Tue, 14 Jul 2020 15:21:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvCAgT5kcc/CujbqK+Zpvl+tmQT6xu1hLeTJx9kHTc/umP+5RKIB6eSZUJIChYoiEzyDWxEQ== X-Received: by 2002:adf:ed02:: with SMTP id a2mr8044778wro.110.1594765313300; Tue, 14 Jul 2020 15:21:53 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 04/19] python/machine.py: Add _early_cleanup hook Date: Wed, 15 Jul 2020 00:21:17 +0200 Message-Id: <20200714222132.10815-5-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 18:21:58 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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 Some parts of cleanup need to occur prior to shutdown, otherwise shutdown might break. Move this into a suitably named method/callback. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Message-Id: <20200710050649.32434-4-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index d3faa9a84c..127926b276 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -365,6 +365,17 @@ def _launch(self): close_fds=3DFalse) self._post_launch() =20 + def _early_cleanup(self) -> None: + """ + Perform any cleanup that needs to happen before the VM exits. + """ + # If we keep the console socket open, we may deadlock waiting + # for QEMU to exit, while QEMU is waiting for the socket to + # become writeable. + if self._console_socket is not None: + self._console_socket.close() + self._console_socket =3D None + def wait(self): """ Wait for the VM to power off @@ -376,12 +387,7 @@ def shutdown(self, has_quit=3DFalse, hard=3DFalse): """ Terminate the VM and clean up """ - # If we keep the console socket open, we may deadlock waiting - # for QEMU to exit, while QEMU is waiting for the socket to - # become writeable. - if self._console_socket is not None: - self._console_socket.close() - self._console_socket =3D None + self._early_cleanup() =20 if self.is_running(): if hard: --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765424; cv=none; d=zohomail.com; s=zohoarc; b=PVkZT6GkfPxHIqeCaPKWSjCwaC3kNwj8d0mHnFL6OVgrv/EhRJpCyf9gKO3Ny2grXh1zI0R+M9XlxY7Fu5PdEf/PBE1f7+WZUdJOu6eL65i90YP1jIXpj5OuASzc+R+QOd+CBvXrasoRZ5tCJHjTaOO443UgZRMR9fPy+pIhzDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765424; 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=5KOJiRNNgCKXxXF3PAojUBMhMfHmXxvQ94Tix5b7+Js=; b=RSlhx1cEcHxrBMv4imYoGxfBbrypH+MjRXgDBshL4SWw25IwoivJ6fbRq0ja3o2BaNgzumid69NRh6H/irMzqp5WlB8/XzHpJ6D1Yi+uXzaVKIE1NTpuWS9CAr6n3tmiucvDMlIN3fsGma1Ym4yexYf/kuxo+HQ978KrY1J+J74= 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 1594765424145493.4994726370743; Tue, 14 Jul 2020 15:23:44 -0700 (PDT) Received: from localhost ([::1]:54906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTKw-00025s-OS for importer@patchew.org; Tue, 14 Jul 2020 18:23:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJQ-0000QC-VQ for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:08 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36500 helo=us-smtp-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 1jvTJL-0004YW-Uo for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:08 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-REd_f3inPm6Lk3IcPssU6A-1; Tue, 14 Jul 2020 18:21:59 -0400 Received: by mail-wm1-f70.google.com with SMTP id c124so105702wme.0 for ; Tue, 14 Jul 2020 15:21:59 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id f12sm177045wrw.53.2020.07.14.15.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765323; 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=5KOJiRNNgCKXxXF3PAojUBMhMfHmXxvQ94Tix5b7+Js=; b=R/A3ea93+FwISTxZVqFOq65GnTZ4Kl5jo0Y0wAmvVLTcXkoRjcKRRFo1d6aVWvokrb5UYU gE8BnCiax6+gwh4NdMCDp6LN2H4TpZbnUnOH1vgvAy9VHBRbWTxg3eCRppZNRvKGb2ZyDh cQTGIran13IqKF3JRz31NCh1wqduwWw= X-MC-Unique: REd_f3inPm6Lk3IcPssU6A-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=5KOJiRNNgCKXxXF3PAojUBMhMfHmXxvQ94Tix5b7+Js=; b=UCZvluu8BM/ha9Vh1JwEbsBHjez1AeuloBWnQ4eJvMECWpcSz6LqVie+eiliG4lrYQ VspNmtnDiKK4XmrAOTXFxYwqUWh3LB/5GptAV7ZpCWqDpNvpffg0pJ7ikNJl4AHPHnEB IAhYDxNl9NMlYDrRgR7sgrcxDXvOVJRS8zRcPIi/AQyfZ+l+lxaDGbHBZRgcupoIrsRA uVIXpO5NoT5WeVYfllw01txYHmnZuU4RM3/Yjwny5mrS/PpEy5cgagH7elnc8BVq5Qkl Y0mLKBrUzNhbXgiSA+9S+wUqwYhGDgYZCGEgothorE0xF9ggU6IHQCg9YEN7VUWEnhRX yZ5Q== X-Gm-Message-State: AOAM5301O3xzJJHTEENZbF/aqQ+f3/v7LkyiTNdMpnB8MkGjMAHBNVhP CKj2OFIJ4PF9P+mi0SbHotdizbb3Y5ZErn0rHzF22g2vaPGmXh+07JJKmhGyVFCOF2ARquiJiGW Q6SsoZh1N3KJJe4w= X-Received: by 2002:a5d:554d:: with SMTP id g13mr7730002wrw.98.1594765318138; Tue, 14 Jul 2020 15:21:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIl8VT+T+TJSXcjMJX3LIWDdwurgfpY6HH5UdPHk5kiuwk0HdcZ1OVeT6zU3JEJIr4Aa5Vnw== X-Received: by 2002:a5d:554d:: with SMTP id g13mr7729983wrw.98.1594765317930; Tue, 14 Jul 2020 15:21:57 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 05/19] python/machine.py: Perform early cleanup for wait() calls, too Date: Wed, 15 Jul 2020 00:21:18 +0200 Message-Id: <20200714222132.10815-6-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 01:42:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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 This is primarily for consistency, and is a step towards wait() and shutdown() sharing the same implementation so that the two cleanup paths cannot diverge. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Message-Id: <20200710050649.32434-5-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 127926b276..63e40879e2 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -380,6 +380,7 @@ def wait(self): """ Wait for the VM to power off """ + self._early_cleanup() self._popen.wait() self._post_shutdown() =20 --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765578; cv=none; d=zohomail.com; s=zohoarc; b=VUf5SrZR0xHeT+pMW9iOBrOKyw/dXnJHhPt67ejXm6lOVK0Kl/RigNDJOL+bJ5Y0flCzoBwc06Cxt53HvzMFmA+fEZzOwlFN5ZozGSxM5Uyhh3YXMPJM/YdU5SmxkPqjJjv+AT5RY+HV3oP+ad9gTmcn1rveh0GOa/VmRj8ZQUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765578; 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=BU6nod1vM4pdn4SPezq8/eYZ42x6gm5zwkT0DnjVtk8=; b=F767kF4yXZpSE7Mt6bnfpl8yJFlny4KtRTU81lUD/XYOEiR0fPNdkjLABbBiXAuIumue/bX0/1G/T8poIUmFTySLsz5IL9ZVf5hAkLbWciUsToGHeH0ga5CWoqdt/jm5sS0PULd1F9UqGBHbelUBTeqZmWeoOU5NFs4zMfxDHZo= 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 1594765578166906.1855580817063; Tue, 14 Jul 2020 15:26:18 -0700 (PDT) Received: from localhost ([::1]:38410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTNQ-00073y-Th for importer@patchew.org; Tue, 14 Jul 2020 18:26:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJS-0000S9-Ds for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35561 helo=us-smtp-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 1jvTJQ-0004ZP-EA for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:10 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-OoMyNabxON60kxlWWYieQA-1; Tue, 14 Jul 2020 18:22:04 -0400 Received: by mail-wm1-f72.google.com with SMTP id z11so93311wmg.5 for ; Tue, 14 Jul 2020 15:22:04 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id v11sm8783316wmb.3.2020.07.14.15.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765326; 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=BU6nod1vM4pdn4SPezq8/eYZ42x6gm5zwkT0DnjVtk8=; b=JxpO4jtioAOcSprGNqN9dBRVFdvpDWx9durKxeXBZAICWfld9qMJgoSDp17v4ElAEXhFx2 U+onLolH8bVIRrGcBGlAULCGHIKxQYKXZXZstrTgMXIJrhPb5kWvjlsuGqaTIjN0kCphft Nfrgk1v4cF7I1lUkNEw/U9spaWOfnu4= X-MC-Unique: OoMyNabxON60kxlWWYieQA-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=BU6nod1vM4pdn4SPezq8/eYZ42x6gm5zwkT0DnjVtk8=; b=BvSLivyuS2D9SdeazwTnbt9FEMMWK19n/u0sZ3mzpH/+IVbECDR+oX4PJ8M2R4s/7l I1weB52WEsZxlo8rqLdievgQKikCp5jmm8NN4GxNsOWcM7nrKhyC7g3Vl4Ln2ZdKU9z4 xksANsoZFqceM/o2qUa+cJx8Ge8wv+gMeiSGTAJniu7KB0If4s9rhyET01vRntuYSl8M yTYHd4gIAyYMG+iNCZ9BiXR++MH4u8x6v99mWa2PMi3SizJFbPtaC3hRAXXA08nTLGyf U1SAwTzbmV6CO6rLJtStcq5ETPcG6PamZeU8wFyna7Nz3LqIfICPGN29hAjo6/oCQQhv 4jSA== X-Gm-Message-State: AOAM53362Oe3RujRks64mXw39PrDEit2p50t7xaC6vSjDBm+DsYaUYiK ryEh5Ekl9lTe3ccFEt02vki9itpNhiuKYkq7Eo4bN91JDFtafxc1XTXevME0XdnYG8YFhg3xZ8B KY5BA6SfQin7uzQw= X-Received: by 2002:a1c:2805:: with SMTP id o5mr5869292wmo.25.1594765322791; Tue, 14 Jul 2020 15:22:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO+o9WWeKqimo9LUqmtJnuajZ1bjM96ascLKDdWwmNVtnXDAetXuaTx2RX6+lxxOrv9TG7LA== X-Received: by 2002:a1c:2805:: with SMTP id o5mr5869275wmo.25.1594765322529; Tue, 14 Jul 2020 15:22:02 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 06/19] python/machine.py: Prohibit multiple shutdown() calls Date: Wed, 15 Jul 2020 00:21:19 +0200 Message-Id: <20200714222132.10815-7-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 01:42:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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 If the VM is not launched, don't try to shut it down. As a change, _post_shutdown now unconditionally also calls _early_cleanup in order to offer comprehensive object cleanup in failure cases. As a courtesy, treat it as a NOP instead of rejecting it as an error. This is slightly nicer for acceptance tests where vm.shutdown() is issued unconditionally in tearDown callbacks. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200710050649.32434-6-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 63e40879e2..c28957ee82 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -294,6 +294,13 @@ def _post_launch(self): self._qmp.accept() =20 def _post_shutdown(self): + """ + Called to cleanup the VM instance after the process has exited. + May also be called after a failed launch. + """ + # Comprehensive reset for the failed launch case: + self._early_cleanup() + if self._qmp: self._qmp.close() self._qmp =3D None @@ -339,7 +346,7 @@ def launch(self): self._launch() self._launched =3D True except: - self.shutdown() + self._post_shutdown() =20 LOG.debug('Error launching VM') if self._qemu_full_args: @@ -368,6 +375,8 @@ def _launch(self): def _early_cleanup(self) -> None: """ Perform any cleanup that needs to happen before the VM exits. + + Called additionally by _post_shutdown for comprehensive cleanup. """ # If we keep the console socket open, we may deadlock waiting # for QEMU to exit, while QEMU is waiting for the socket to @@ -388,6 +397,9 @@ def shutdown(self, has_quit=3DFalse, hard=3DFalse): """ Terminate the VM and clean up """ + if not self._launched: + return + self._early_cleanup() =20 if self.is_running(): --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765523; cv=none; d=zohomail.com; s=zohoarc; b=BXlomzuxbrN3uzqHLqOny0hDF+kLDcrCY2JsNPyiAbDK/DqedIGLYGaPIyJGd9tb8IraVF9RFBg/5r7euZrXT+6hnWf9WW4Su8HpJw9qSoQ7+YRGbOafyjm8Si/mRZNv1se6qUCFzHdAtQJ6uPYx53y+j9p/J/BpbQ4UTDgNTzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765523; 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=68z3SIjA0BJxIasZ4nmbsDP+rWPK+60CWkUJsZTRUF4=; b=e8MoiVPXN5xTLvBO/I+0jh0nfch5Jtz709plkUsGh8BlbcfoPEwrsaPN2kJkeJO4HkyVGnOp5IhtpTBSaSfZXnJCbFaqNj1u1FFR4eSqFkjHhikPBjXOdi/5U1YUomF0WvIHIeQ0nyasBlMXB2e+cXAjNxs1nP4b3zAUAtkvf2Y= 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 1594765523726117.81140783061232; Tue, 14 Jul 2020 15:25:23 -0700 (PDT) Received: from localhost ([::1]:34912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTMY-0005Xw-Ek for importer@patchew.org; Tue, 14 Jul 2020 18:25:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJU-0000Wp-PB for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:12 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40974 helo=us-smtp-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 1jvTJT-0004bC-62 for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:12 -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-249-tHJohPzqNR2-Go2YqC_DBw-1; Tue, 14 Jul 2020 18:22:08 -0400 Received: by mail-wr1-f72.google.com with SMTP id i12so20456wrx.11 for ; Tue, 14 Jul 2020 15:22:08 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id d28sm205619wrc.50.2020.07.14.15.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765330; 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=68z3SIjA0BJxIasZ4nmbsDP+rWPK+60CWkUJsZTRUF4=; b=RxLPBA93YB7sbadf/c0UDIDTYuJLqhdt2Vna3cJDdxJEE8V78cbGM+k6mA5uEVivQctAAD vrcOiKtsd4IzCOPeDMrClK4lm/pj02YhM6ZfcC9FvYvsOrfQxanZQ/bkcdMxHSXtxOKehS GqIlycgu393Bjgn0OuPOLpTwurQfNxM= X-MC-Unique: tHJohPzqNR2-Go2YqC_DBw-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=68z3SIjA0BJxIasZ4nmbsDP+rWPK+60CWkUJsZTRUF4=; b=KgK3WZRaDPy4OYK0Zn+F3DRIvqc5Pz/A+lHhAoqQLxDkp7c5s9L4sKUknw4t74/na+ Ir++IqUVvBXFMiom9MP4q6U/+djo6sPOixb5ac/K/rk+ndXsTFQEYoGQR6Dsqyq6poT8 o8p87kagSKV/5S8l1SrPhMzXVUE8KudL452po/C9qF9XEH9ybwnqir3HE9W8Ay6bJKPk n40bPYMnSz/VubVBHOWYBG+Vu2u3AV9MiJJ2olwFrdt1dUjU+TXi9vJKsk0GQieZgy+u 9YK1uH7+NRjtsaeWXC4B3ce1r9Vo7HJzZMGMXxPQ4lKdFUrkEv1M2ekbVI/HCbKxcL6r A25A== X-Gm-Message-State: AOAM533v8rDWjBs7PNLVzET8SarUvIT/j2E1+j1UKAdVc/PZ6XicuJeT mXE0+16hhH4Ab+1Fe+Nc2t65M0Hbh8WtB34Zyx20OqjrbPAjSdt+MtI63YH38om6rf4a+qk+DgB tUn8GiDmBAhVTA4M= X-Received: by 2002:adf:a34a:: with SMTP id d10mr8146581wrb.59.1594765327499; Tue, 14 Jul 2020 15:22:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4aq8z2uTcKBNxUqaFI5a3I30Ipkmo21q/+89pXZBlZJA/2QaQOTakehim7Guk7EHZfyfkVw== X-Received: by 2002:adf:a34a:: with SMTP id d10mr8146563wrb.59.1594765327304; Tue, 14 Jul 2020 15:22:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 07/19] python/machine.py: Add a configurable timeout to shutdown() Date: Wed, 15 Jul 2020 00:21:20 +0200 Message-Id: <20200714222132.10815-8-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 18:21:58 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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 Three seconds is hardcoded. Use it as a default parameter instead, and use = that value for both waits that may occur in the function. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Message-Id: <20200710050649.32434-7-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index c28957ee82..e825f0bdc6 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -393,7 +393,9 @@ def wait(self): self._popen.wait() self._post_shutdown() =20 - def shutdown(self, has_quit=3DFalse, hard=3DFalse): + def shutdown(self, has_quit: bool =3D False, + hard: bool =3D False, + timeout: Optional[int] =3D 3) -> None: """ Terminate the VM and clean up """ @@ -409,10 +411,10 @@ def shutdown(self, has_quit=3DFalse, hard=3DFalse): try: if not has_quit: self._qmp.cmd('quit') - self._popen.wait(timeout=3D3) + self._popen.wait(timeout=3Dtimeout) except: self._popen.kill() - self._popen.wait() + self._popen.wait(timeout=3Dtimeout) =20 self._post_shutdown() =20 --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765434; cv=none; d=zohomail.com; s=zohoarc; b=YlzJi6Ov0dZB27JASI767lVxcnnktRn4PuQAtgAJWOIwRebyVFZLizwGLJMu2y0Qax6VLV7YKQDD/qQirm/2IdIjGWU9NJNLqCevzJCXqllBBAivkFL0kWjRQhZbSsC2LRNh8BTL4fLSJWjdbNcNL2V9GtdTnyg3xE3o2+AUp3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765434; 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=mKUySCAcl1J3a1/0hxVxVX3VFabMkB3Xo8GnjHPY21Y=; b=ZjmxTLFv3Tv/b8EjTW0Hj4Hht2RWc74DGwIQ2gke0ZAFfTcI4MiXSsE/FG7ZnWUWVKVo94GWk7onFJJxyr9f/oPGT1F5h+hKw0cwQDSMbsA8innYstLJKGoDUlle6ccs4McO37r7bIUa9ylq/HWWrMk4AmhACTzQsg9Bi/HRB68= 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 1594765434622341.17243842093035; Tue, 14 Jul 2020 15:23:54 -0700 (PDT) Received: from localhost ([::1]:55978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTL7-0002Y7-AS for importer@patchew.org; Tue, 14 Jul 2020 18:23:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJa-0000jh-RT for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:18 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33163 helo=us-smtp-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 1jvTJX-0004dP-QU for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:18 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-340-sAQGjZmUORCucyulk8DwHA-1; Tue, 14 Jul 2020 18:22:13 -0400 Received: by mail-wm1-f70.google.com with SMTP id l5so90519wml.7 for ; Tue, 14 Jul 2020 15:22:13 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id z1sm195816wru.30.2020.07.14.15.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765335; 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=mKUySCAcl1J3a1/0hxVxVX3VFabMkB3Xo8GnjHPY21Y=; b=EACixxg1dXb7lBqpxHFPhxt9Ddwy3I9OXGiHKvBGiqB+y4SNYhUNn1NaVwT+VhPxfYeepz gRZOhWiPzRduAYuSQkQBrQ/VewaWORFkimE+jEs2SYMZXDs9avH4fk4l5DDw6AvFjOR/tD lxktpk/5Gt1m0OjFaiYVJ08MG/FaYdI= X-MC-Unique: sAQGjZmUORCucyulk8DwHA-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=mKUySCAcl1J3a1/0hxVxVX3VFabMkB3Xo8GnjHPY21Y=; b=T/xOPObsdI26r3yWXxzuxBDQl8byiWvN0kG32d06t0hucoC0PXBc+N6V9ywcZjhEfS 4gLKBtZ3Ih9ThZyO1K+JNNBxrKxhTNNCDX8M9n3aM1BlzQVfi7KOYBb7G5b9/LHoShEk dhmtC/9uyhSEL6d5oGDZrL16w8Gr38VRuy56KimlDZJscm5SlNcHNe49634h1saR9FU5 QoVw4TpxgMw8AFSDAyY+SrSzTMCSie0vYJcdVTxp/HpLQAlmL1p2gXoXOvnhBnURNBWL 2EbM2WJlrMn2J7erZqdTg55ElhPKwNHzMSjdwZbQDtgHng5K4pcvqUXvhBJ5NhBnbHgO /P1w== X-Gm-Message-State: AOAM5306Odag63nOHFvNtEu3U97yZvHgz65feZ0Sp5JJT8ZlRmPykxfG QCValDRh8taggdS+NvokNvHqK7TKE+kveV/cCFSB2tC45cdNht0Dm/rUkNPah4aQf8Eyf/v4Qte t0C01ql84QUYOtDo= X-Received: by 2002:a5d:408c:: with SMTP id o12mr8088770wrp.412.1594765332170; Tue, 14 Jul 2020 15:22:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXwwxysFJ5iRQmTLqaL20VRf1rWyYdiTmWhT9ROP3DgVZ3r+9Zewj8UNG56cgKfC15v/KHog== X-Received: by 2002:a5d:408c:: with SMTP id o12mr8088756wrp.412.1594765331998; Tue, 14 Jul 2020 15:22:11 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 08/19] python/machine.py: Make wait() call shutdown() Date: Wed, 15 Jul 2020 00:21:21 +0200 Message-Id: <20200714222132.10815-9-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 01:42:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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 At this point, shutdown(has_quit=3DTrue) and wait() do essentially the same thing; they perform cleanup without actually instructing QEMU to quit. Define one in terms of the other. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Message-Id: <20200710050649.32434-8-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index e825f0bdc6..3f0b873f58 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -385,14 +385,6 @@ def _early_cleanup(self) -> None: self._console_socket.close() self._console_socket =3D None =20 - def wait(self): - """ - Wait for the VM to power off - """ - self._early_cleanup() - self._popen.wait() - self._post_shutdown() - def shutdown(self, has_quit: bool =3D False, hard: bool =3D False, timeout: Optional[int] =3D 3) -> None: @@ -421,6 +413,15 @@ def shutdown(self, has_quit: bool =3D False, def kill(self): self.shutdown(hard=3DTrue) =20 + def wait(self, timeout: Optional[int] =3D None) -> None: + """ + Wait for the VM to power off and perform post-shutdown cleanup. + + :param timeout: Optional timeout in seconds. + Default None, an infinite wait. + """ + self.shutdown(has_quit=3DTrue, timeout=3Dtimeout) + def set_qmp_monitor(self, enabled=3DTrue): """ Set the QMP monitor. --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765685; cv=none; d=zohomail.com; s=zohoarc; b=NyjdKFtFW8jlG5ww6lIFW8Zk7mQ9YM/u7wtGzeU7ZaPthuT0R1dwPkPHweOP0Ly1WhUBq56LOI3hvXv8WhJKoH/qzDSixtCKB+kIeuU0jjYzfycZDLf+74VZPIN178VAPfCEoEOiI38sPEgpC4+Nqe93ASSy55Tc9nG7UegkmSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765685; 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=VtAHwUMbT3DZQFjgf7HP2io0KT4bOSabkBp+DZ3uFOE=; b=ZBKrR8ytviYFL5DDLpuaBl9m8KKBL10GmAzSzfF7XkZaZrUKeN+qspbE5eMtrg0tKPpMSZxYq1D80rW4qG64aWjtcRqmIc5dWCJNShRl1fVtbhoOablvYw445ZBSVAnuLVU4BFhCSFWpQkN/lwwa0g0E0rBQ7xbSe1JpQXUcXoI= 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 1594765685008758.129551080982; Tue, 14 Jul 2020 15:28:05 -0700 (PDT) Received: from localhost ([::1]:46920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTP9-00024m-Mg for importer@patchew.org; Tue, 14 Jul 2020 18:28:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJn-0000yr-4H for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:31 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:21519 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 1jvTJd-0004gn-Hn for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:30 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-MkhiJw3RPMmAZEFeurOK5g-1; Tue, 14 Jul 2020 18:22:19 -0400 Received: by mail-wr1-f70.google.com with SMTP id s16so25255wrv.1 for ; Tue, 14 Jul 2020 15:22:19 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id l18sm176389wrm.52.2020.07.14.15.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765340; 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=VtAHwUMbT3DZQFjgf7HP2io0KT4bOSabkBp+DZ3uFOE=; b=HDQYy7reADmK0ef34/J+g41oSU1TB+PBxD36/TRzPHu2gnQKfVIyrRU9VwbXyXkHdveyUc 0MQhFcsUGaYAIFDZovjaRRlTc0GYkB9jO5juXd7EtXP0z61hHsj5Bg35lgJm9C+w1H50mS W6nQlIcuwptCQA2bbNlJdFbM2wSlQuw= X-MC-Unique: MkhiJw3RPMmAZEFeurOK5g-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=VtAHwUMbT3DZQFjgf7HP2io0KT4bOSabkBp+DZ3uFOE=; b=UqdPpGzBtpVhtAmN+mrka1vriXWSesUAqDaENT/sAaSDKssSWdbzNyeMD0KQqGM+hZ WLRaFxkQnv6Ql2BidTIQmnZXWRLQZHJ+YBrO5v4oCVt8xKO7lFqanudN3yIm+sYZ7oF9 ovVLbzGq5pjZa6WLhfdMd0UIXeqYcmvlbGzQpy3QBwQdqVU+/0/WtQ3AWgJ32BeEp1jS Q6kAJl9jo3/GxHVCn46fQAEqjUAffZqd0kSlHm9g5xhovU+++wsYyAMJnJdLJA0YUWPl SG41qQdT6WTdIW9ZFL3XNcY2k0hh+/o8mM93mZqz8s0Ryb4qgCxsq22LwL4mbGETx1NP 4qOA== X-Gm-Message-State: AOAM531EDz6gh+TW6g5vO+QteOQGLMpmXMsr7Y9OnSqzBf1hkAoW9UOy 2fPJ1eL3pRdMWL5E/xO5TnEgWWbm9gTzB71lVlUGELpAuPQ8DIhkD5Cs7iN2aH8dFu4PiIQzt/c Pi5WjnPKcqhCWD18= X-Received: by 2002:adf:db42:: with SMTP id f2mr8018684wrj.298.1594765337201; Tue, 14 Jul 2020 15:22:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYlZoqndMmXVvUNG7YjLVhDx9CeTYBym6U33tY9gsnqfWWKCkgtUnfCoQdUpcE8uh4ePWUAA== X-Received: by 2002:adf:db42:: with SMTP id f2mr8018663wrj.298.1594765337015; Tue, 14 Jul 2020 15:22:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 09/19] tests/acceptance: wait() instead of shutdown() where appropriate Date: Wed, 15 Jul 2020 00:21:22 +0200 Message-Id: <20200714222132.10815-10-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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/07/14 03:57:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Aleksandar Rikalo , Eduardo Habkost , John Snow , Wainer dos Santos Moschetta , Ahmed Karaman , Aleksandar Markovic , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno 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 When issuing 'reboot' to a VM with the no-reboot option, that VM will exit. When then issuing a shutdown command, the cleanup may race. Add calls to vm.wait() which will gracefully mark the VM as having exited. Subsequent vm.shutdown() calls in generic tearDown code will not race when called after completion of the call. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Message-Id: <20200710050649.32434-9-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/acceptance/boot_linux_console.py | 10 ++++++++++ tests/acceptance/linux_ssh_mips_malta.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot= _linux_console.py index 3d02519660..5867ef760c 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -191,6 +191,8 @@ def test_mips_malta_cpio(self): 'Debian') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system= ') + # Wait for VM to shut down gracefully + self.vm.wait() =20 @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code= ') def test_mips64el_malta_5KEc_cpio(self): @@ -231,6 +233,8 @@ def test_mips64el_malta_5KEc_cpio(self): '3.19.3.mtoman.20150408') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system= ') + # Wait for VM to shut down gracefully + self.vm.wait() =20 def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash): kernel_path_xz =3D self.fetch_asset(kernel_url, asset_hash=3Dkerne= l_hash) @@ -506,6 +510,7 @@ def test_arm_cubieboard_initrd(self): 'system-control@1c00000') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system= ') + # NB: Do not issue vm.wait() here, cubieboard's reboot does not ex= it! =20 def test_arm_cubieboard_sata(self): """ @@ -550,6 +555,7 @@ def test_arm_cubieboard_sata(self): 'sda') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system= ') + # NB: Do not issue vm.wait() here, cubieboard's reboot does not ex= it! =20 def test_arm_orangepi(self): """ @@ -615,6 +621,8 @@ def test_arm_orangepi_initrd(self): 'system-control@1c00000') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system= ') + # Wait for VM to shut down gracefully + self.vm.wait() =20 def test_arm_orangepi_sd(self): """ @@ -662,6 +670,8 @@ def test_arm_orangepi_sd(self): '3 packets transmitted, 3 packets received, 0% packet loss') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system= ') + # Wait for VM to shut down gracefully + self.vm.wait() =20 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited= ') @skipUnless(P7ZIP_AVAILABLE, '7z not installed') diff --git a/tests/acceptance/linux_ssh_mips_malta.py b/tests/acceptance/li= nux_ssh_mips_malta.py index 90d7f2f167..25c5c5f741 100644 --- a/tests/acceptance/linux_ssh_mips_malta.py +++ b/tests/acceptance/linux_ssh_mips_malta.py @@ -212,6 +212,8 @@ def check_mips_malta(self, uname_m, endianess): =20 self.run_common_commands(wordsize) self.shutdown_via_ssh() + # Wait for VM to shut down gracefully + self.vm.wait() =20 def test_mips_malta32eb_kernel3_2_0(self): """ --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765633; cv=none; d=zohomail.com; s=zohoarc; b=YA+jVjEqmKYExFLS+ql2GqFkP0XYiVqT8MMNFGwh9D0x/Q6wD9xgzzjSuT5fcMaMjs1/fYtknLpR6Z6Q+Xtr+brGPU4si5TlfaQ6xbmYPwJekhVJpjB/az7M/Yt5qW9DGBTDYV9/vXoJW3kUZ4axoTAb4h33oC8sNKo/Gwj7vJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765633; 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=yI/gwTOC/ILtlhkZf0FnguyCxPWQjiV56qaIviljiXg=; b=BSMXqqWpbEDlardJFSSG/QKU6nb8WccaO3iNQ8r78rst6TsPG1bm/67N+QMT2fMf+YLXnUsu0IKkczgvS0cNfpBt+bORp15D5N0KAxrsCPkSkHX6PQYODMKwbpCtHA4jOn+7PPAZLOz0V7pBYj76GC6C4Dk5kkCtB5g7b9e/X3M= 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 1594765633104690.1600104128999; Tue, 14 Jul 2020 15:27:13 -0700 (PDT) Received: from localhost ([::1]:43372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTOJ-0000ed-TG for importer@patchew.org; Tue, 14 Jul 2020 18:27:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJs-0001Ae-MO for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:36 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:48214 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 1jvTJh-0004j9-Ro for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:36 -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-378-5miYbdudO9CRUfyIytE0fA-1; Tue, 14 Jul 2020 18:22:23 -0400 Received: by mail-wr1-f72.google.com with SMTP id i12so20685wrx.11 for ; Tue, 14 Jul 2020 15:22:23 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id k18sm186277wrx.34.2020.07.14.15.22.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765344; 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=yI/gwTOC/ILtlhkZf0FnguyCxPWQjiV56qaIviljiXg=; b=cJ5sk1ls3gkj15Zy30hgCk6IQc2XfL1howXf40k0hXnE/hNUZkGXnMOOuQdM6RejPHiqlU Z7brF453PuoUdOj3SSQC2hjfxmGO0ZqrojnwacJeDRyQovQYqpKjd/c6l1I3hprqbx4gKK hM8SjbxW0GAtYju9HAEFZS5+mdjyL2I= X-MC-Unique: 5miYbdudO9CRUfyIytE0fA-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=yI/gwTOC/ILtlhkZf0FnguyCxPWQjiV56qaIviljiXg=; b=L70WkW7lD7rR8Y8Q+WtWfuc9nDVIbry/XWwXD36lK1iv2z88tRz16qyjH7vduWswoL R0+5p4ZJtYnnAJll8GHaXJNZ9MpmmAjbl4SI7idb4NCcGSgCj2iP1gQZGLOxAW2lRLhu 07ff9kP/Ez9OKQJVY8PgCDH5sgW9hoGoSE1KlbfZ1wtihWM7Gt+Wn3x+Vqm4t/bgxYPK BxDxBCGB/eLjP8l4h6L/lws23o7JbDJDQ3Vm4pgg96GlWLRqyWt/41KqFw4KsFPQWnHm iE03gR5PkaKceW2QJM+cqFJYrAY/0woOuVmbSsNB8b12+mfQuvDwlTW805dU1U5ZKDh/ cc9g== X-Gm-Message-State: AOAM5322zeoiH3eF8kYxEnh75c15Z45zuNVgzVB21MiLPCT+nT97itlp 8swucyYwHvw4mie4G1WFftTnm6RfsxZTA3sAgqV5ZpnyDSssYyZB/o4kxFNSmZnXHvKsr49urNd xc+JxaFbWaVCeCDo= X-Received: by 2002:a1c:e209:: with SMTP id z9mr5861731wmg.153.1594765341877; Tue, 14 Jul 2020 15:22:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjmKxmbIJW0/cPl2BPl6yPDtNyf1lHyHgquft37qp4ZS8FqBv/eUDsxQxvcesIaxdOKwQPrA== X-Received: by 2002:a1c:e209:: with SMTP id z9mr5861718wmg.153.1594765341691; Tue, 14 Jul 2020 15:22:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 10/19] tests/acceptance: Don't test reboot on cubieboard Date: Wed, 15 Jul 2020 00:21:23 +0200 Message-Id: <20200714222132.10815-11-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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/07/14 03:57:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Eduardo Habkost , John Snow , Wainer dos Santos Moschetta , Ahmed Karaman , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 cubieboard does not have a functioning reboot, it halts and QEMU does not exit. vm.shutdown() is modified in a forthcoming patch that makes it less tolerant of race conditions on shutdown; tests should consciously decide to WAIT or to SHUTDOWN qemu. So long as this test is attempting to reboot, the correct choice would be to WAIT for the VM to exit. However, since that's broken, we should SHUTDOWN instead. SHUTDOWN is indeed what already happens when the test performs teardown, however, if anyone fixes cubieboard reboot in the future, this test will develop a new race condition that might be hard to debug. Therefore: remove the reboot test and make it obvious that the VM is still running when the test concludes, where the test teardown will do the right thing. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Message-Id: <20200710050649.32434-10-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/acceptance/boot_linux_console.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot= _linux_console.py index 5867ef760c..8b8b828bc5 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -508,9 +508,7 @@ def test_arm_cubieboard_initrd(self): 'Allwinner sun4i/sun5i') exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', 'system-control@1c00000') - exec_command_and_wait_for_pattern(self, 'reboot', - 'reboot: Restarting system= ') - # NB: Do not issue vm.wait() here, cubieboard's reboot does not ex= it! + # cubieboard's reboot is not functioning; omit reboot test. =20 def test_arm_cubieboard_sata(self): """ @@ -553,9 +551,7 @@ def test_arm_cubieboard_sata(self): 'Allwinner sun4i/sun5i') exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', 'sda') - exec_command_and_wait_for_pattern(self, 'reboot', - 'reboot: Restarting system= ') - # NB: Do not issue vm.wait() here, cubieboard's reboot does not ex= it! + # cubieboard's reboot is not functioning; omit reboot test. =20 def test_arm_orangepi(self): """ --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765539; cv=none; d=zohomail.com; s=zohoarc; b=Xm986bzxSPmuOrUTb2dzBlAeu7POqLWCwajMBoFTRY4SE4SEM6KV8yL6cfVlOXXNtgfnLnr6CO9CPOnnlmbfUVTG6+ZgGheIvzWdUa/ycFeHMcCKNNIhziVTHxMWACt1w3LsrHBtEImA+Os4E0yJPJs+gKDfSa79YHXGazeI/1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765539; 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=fxpPD25l94H6jH9waRJgbDvpErEb7UHCQOGbx0fD5YA=; b=ZhlcECQgXh/u+IdU2ycbupzTW3L/ACpgYM/2o7sF1fMV0NCusdSzVV1OsSp0rFQEf2uHbPJvfFr8qzFsYVqBvy3LraAED7d3mdZg0iWiD5aSEZrrPmokQp5AuL8MI6iIRrput/q3m4kBUlOqAMUOt/kxaR1MbYwGP8KuObrucyM= 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 1594765539411416.7411097985216; Tue, 14 Jul 2020 15:25:39 -0700 (PDT) Received: from localhost ([::1]:36318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTMo-0006Ah-50 for importer@patchew.org; Tue, 14 Jul 2020 18:25:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJr-00018N-IM for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:35 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49781 helo=us-smtp-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 1jvTJm-0004kS-Vb for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:35 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-KkgddlGiPQC-_tDG0pLbDw-1; Tue, 14 Jul 2020 18:22:28 -0400 Received: by mail-wr1-f69.google.com with SMTP id o25so18488wro.16 for ; Tue, 14 Jul 2020 15:22:28 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id u10sm289156wml.29.2020.07.14.15.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765349; 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=fxpPD25l94H6jH9waRJgbDvpErEb7UHCQOGbx0fD5YA=; b=NzH+JV/OeyOmDwfCMRFP6in31PtVI7IkeWspg1rMY5Htsujd/xDhixjIvWAoBLLFKRBldM 5LJrQi/TE3KG7ve6ad9R9FZomwk/Qbg5GTIZwyj0GpArs/wmYMlRnAmeTBcgeXY8lp1wv+ h4Q+FsrKHvEYhrwb5hQaqmPjWy1OtkM= X-MC-Unique: KkgddlGiPQC-_tDG0pLbDw-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=fxpPD25l94H6jH9waRJgbDvpErEb7UHCQOGbx0fD5YA=; b=f1nu1Cz/NMljK7PDhGXAUOQclcthHm4aLlUezAW6U8RncBWBbJNxhiKTH9IusqMJFT M/+KVPhbhQeP+TszYEALExbU/VEddkpRFX5znkmyo+ImuJQY7PAnA9Gq4XQrezWuwJgD qhd9WNmsedkf2A5+KGMo9bVZCBEhJqhCmwFWON6XTGyDjAi1SAGOsSB/BWD2wWkCWSa5 Vdz9Z5xmcxo4Y+xKTMpJjlyNNHbwRmpZKENyXHbSoXymqFKlrCyoFRyvqrCvqGAK/wq0 6DUjk5bIQQovoVyDuzOuANWhWhfiSPCnFqQIAkyXqT7nvDI8cKcU7oUgxd2VF1E1wqWU g+Ng== X-Gm-Message-State: AOAM530sd8ooIsb1NM5iZtHUNFE/84bLs4byfs/A5bsHJP6L3JSUGo84 S8ezS+i+q30oF/dwtJ1vcALESRMgyVlontl+wBws3pK/TBX2zdwZ5dcvq5GAWQms2iZecaoaU50 m8rjOjvZNwsFj8kY= X-Received: by 2002:a5d:40cb:: with SMTP id b11mr8264546wrq.263.1594765346765; Tue, 14 Jul 2020 15:22:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwanRA/LIdrlHXnRYIrv61pWu7j68fnofevncVhh1VvW3D1TOPE3ae+3SWppY5GjxrIbmNkQ== X-Received: by 2002:a5d:40cb:: with SMTP id b11mr8264521wrq.263.1594765346477; Tue, 14 Jul 2020 15:22:26 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 11/19] python/machine.py: split shutdown into hard and soft flavors Date: Wed, 15 Jul 2020 00:21:24 +0200 Message-Id: <20200714222132.10815-12-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 18:21:58 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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 This is done primarily to avoid the 'bare except' pattern, which suppresses all exceptions during shutdown and can obscure errors. Replace this with a pattern that isolates the different kind of shutdown paradigms (_hard_shutdown and _soft_shutdown), and a new fallback shutdown handler (_do_shutdown) that gracefully attempts one before the other. This split now also ensures that no matter what happens, _post_shutdown() is always invoked. shutdown() changes in behavior such that if it attempts to do a graceful shutdown and is unable to, it will now always raise an exception to indicate this. This can be avoided by the test writer in three ways: 1. If the VM is expected to have already exited or is in the process of exiting, wait() can be used instead of shutdown() to clean up resources instead. This helps avoid race conditions in shutdown. 2. If a test writer is expecting graceful shutdown to fail, shutdown should be called in a try...except block. 3. If the test writer has no interest in performing a graceful shutdown at all, kill() can be used instead. Handling shutdown in this way makes it much more explicit which type of shutdown we want and allows the library to report problems with this process. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Message-Id: <20200710050649.32434-11-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 98 +++++++++++++++++++++++++++++++++++------- 1 file changed, 83 insertions(+), 15 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 3f0b873f58..a955e3f221 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -49,6 +49,12 @@ class QEMUMachineAddDeviceError(QEMUMachineError): """ =20 =20 +class AbnormalShutdown(QEMUMachineError): + """ + Exception raised when a graceful shutdown was requested, but not perfo= rmed. + """ + + class MonitorResponseError(qmp.QMPError): """ Represents erroneous QMP monitor reply @@ -376,6 +382,7 @@ def _early_cleanup(self) -> None: """ Perform any cleanup that needs to happen before the VM exits. =20 + May be invoked by both soft and hard shutdown in failover scenario= s. Called additionally by _post_shutdown for comprehensive cleanup. """ # If we keep the console socket open, we may deadlock waiting @@ -385,32 +392,93 @@ def _early_cleanup(self) -> None: self._console_socket.close() self._console_socket =3D None =20 + def _hard_shutdown(self) -> None: + """ + Perform early cleanup, kill the VM, and wait for it to terminate. + + :raise subprocess.Timeout: When timeout is exceeds 60 seconds + waiting for the QEMU process to terminate. + """ + self._early_cleanup() + self._popen.kill() + self._popen.wait(timeout=3D60) + + def _soft_shutdown(self, has_quit: bool =3D False, + timeout: Optional[int] =3D 3) -> None: + """ + Perform early cleanup, attempt to gracefully shut down the VM, and= wait + for it to terminate. + + :param has_quit: When True, don't attempt to issue 'quit' QMP comm= and + :param timeout: Optional timeout in seconds for graceful shutdown. + Default 3 seconds, A value of None is an infinite = wait. + + :raise ConnectionReset: On QMP communication errors + :raise subprocess.TimeoutExpired: When timeout is exceeded waiting= for + the QEMU process to terminate. + """ + self._early_cleanup() + + if self._qmp is not None: + if not has_quit: + # Might raise ConnectionReset + self._qmp.cmd('quit') + + # May raise subprocess.TimeoutExpired + self._popen.wait(timeout=3Dtimeout) + + def _do_shutdown(self, has_quit: bool =3D False, + timeout: Optional[int] =3D 3) -> None: + """ + Attempt to shutdown the VM gracefully; fallback to a hard shutdown. + + :param has_quit: When True, don't attempt to issue 'quit' QMP comm= and + :param timeout: Optional timeout in seconds for graceful shutdown. + Default 3 seconds, A value of None is an infinite = wait. + + :raise AbnormalShutdown: When the VM could not be shut down gracef= ully. + The inner exception will likely be ConnectionReset or + subprocess.TimeoutExpired. In rare cases, non-graceful termina= tion + may result in its own exceptions, likely subprocess.TimeoutExp= ired. + """ + try: + self._soft_shutdown(has_quit, timeout) + except Exception as exc: + self._hard_shutdown() + raise AbnormalShutdown("Could not perform graceful shutdown") \ + from exc + def shutdown(self, has_quit: bool =3D False, hard: bool =3D False, timeout: Optional[int] =3D 3) -> None: """ - Terminate the VM and clean up + Terminate the VM (gracefully if possible) and perform cleanup. + Cleanup will always be performed. + + If the VM has not yet been launched, or shutdown(), wait(), or kil= l() + have already been called, this method does nothing. + + :param has_quit: When true, do not attempt to issue 'quit' QMP com= mand. + :param hard: When true, do not attempt graceful shutdown, and + suppress the SIGKILL warning log message. + :param timeout: Optional timeout in seconds for graceful shutdown. + Default 3 seconds, A value of None is an infinite = wait. """ if not self._launched: return =20 - self._early_cleanup() - - if self.is_running(): + try: if hard: - self._popen.kill() - elif self._qmp: - try: - if not has_quit: - self._qmp.cmd('quit') - self._popen.wait(timeout=3Dtimeout) - except: - self._popen.kill() - self._popen.wait(timeout=3Dtimeout) - - self._post_shutdown() + self._hard_shutdown() + else: + self._do_shutdown(has_quit, timeout=3Dtimeout) + finally: + self._post_shutdown() =20 def kill(self): + """ + Terminate the VM forcefully, wait for it to exit, and perform clea= nup. + """ self.shutdown(hard=3DTrue) =20 def wait(self, timeout: Optional[int] =3D None) -> None: --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765837; cv=none; d=zohomail.com; s=zohoarc; b=Pvs2hL9QVttMivaIm1pqUoE60nN0USavXGlHIyUPUw6SXix3oUd7OyGU3OQWOCRePiwoLvROPYHys7DP0C84ND5B/B01cVhHgKVzNihGTaJCaPfI/ouy7eKwelRp4S8s5xbqJsPMJ77C9z0pBDl93pAOr1PpM4r0oOPUQxvfb6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765837; 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=8hzthc4qYvhQKW4qzzIgQcGvyaWLPgPNTx6+69cJTCU=; b=liSC3TQQAaIh1o960NIjH8t8mLXrUE2sbDTTbw1YWLukCCR1rfmRbc3/19p8V0InzklmgkP4P7zOsHrmvXisSkBRWUmbsY+WEotUu/qi+wGmiR+ncXM136Fh51qFd1n4+jywgBTwcXp6ZECbrUFaYGGcl9bhU5duOa1uJUMivkY= 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 1594765837315449.0533361838709; Tue, 14 Jul 2020 15:30:37 -0700 (PDT) Received: from localhost ([::1]:57520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTRb-0006Qd-QW for importer@patchew.org; Tue, 14 Jul 2020 18:30:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJw-0001Iy-3o for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:40 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:49130 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 1jvTJr-0004mW-NR for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:39 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-vmVq7gf8NDOjhmpU18Zz4g-1; Tue, 14 Jul 2020 18:22:32 -0400 Received: by mail-wr1-f70.google.com with SMTP id j16so24307wrw.3 for ; Tue, 14 Jul 2020 15:22:32 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id c25sm299889wml.18.2020.07.14.15.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765354; 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=8hzthc4qYvhQKW4qzzIgQcGvyaWLPgPNTx6+69cJTCU=; b=fsmy7iX3dmfRVchp5g2FdxstGo+V/X6Ey4wFat02jc0epxC1lYmRnXr00ztzLGQJDQmSdJ dlXqsU2nAtEtDz2Jnxhmm1PLQOM68n/9KOSy3t1jQifOLeRubEFio5frKVZoBKSVKvSnW4 VBmgcknlNAjDE52IPavrJ7GWr+AfRE8= X-MC-Unique: vmVq7gf8NDOjhmpU18Zz4g-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=8hzthc4qYvhQKW4qzzIgQcGvyaWLPgPNTx6+69cJTCU=; b=QmrJCsuEWQdHEaYnYrw//XSBGOU0Q7ZE0V/RP9at1ZL3zY/fR/RYu+iERtYv9kXtJr Kj+opY/VKUFWB8JpVcYHp1u4h5sU5+1NasSM0Q+ZONfzbIw/b0uG44Zqn4swZtHzHlmI 5NtoPVcpeJ1wMbBpuNGBrn75Twkqao8FUHlkbcSrRYtOuJIgh3zEPbF+iJNgvuL29XJJ AlU71DWGh96CnbYf14msPCWgNUCl7GQV0cwnv7UvoNc2XEYLpnvJ3PVeOWraGFAThbOz SyUOyicJY8IEDHx2w/zQ6aPLCketG+3u4OCpi+5mwMT97yT6Geg9YRShZiFzTSe57Nbx F7iQ== X-Gm-Message-State: AOAM530duhG/XiVWzOwfwRfxXb1XUf0bO/6M+/j9KjCjimFwoOXyMEg2 zqQH+TrxOolyNL2nzHI9d4lNafNTK5QfsOK8s35e5iDN38xnAmwUZmUUdcHylVPUPprzjeROSWF 0SZBABoB55EscdtE= X-Received: by 2002:a1c:4143:: with SMTP id o64mr5968361wma.28.1594765351521; Tue, 14 Jul 2020 15:22:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUaBM960e1W2k0JPK2oz/7iOCe0w8tZXN2hSZVzOC+HuJsoZl+NLiRrqi5sJLjA9e40K7m6w== X-Received: by 2002:a1c:4143:: with SMTP id o64mr5968348wma.28.1594765351309; Tue, 14 Jul 2020 15:22:31 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 12/19] python/machine.py: re-add sigkill warning suppression Date: Wed, 15 Jul 2020 00:21:25 +0200 Message-Id: <20200714222132.10815-13-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 12:02:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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 If the user kills QEMU on purpose, we don't need to warn them about that having happened: they know already. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Message-Id: <20200710050649.32434-12-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index a955e3f221..736a3c906f 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -22,6 +22,7 @@ import os import subprocess import shutil +import signal import socket import tempfile from typing import Optional, Type @@ -133,6 +134,7 @@ def __init__(self, binary, args=3DNone, wrapper=3DNone,= name=3DNone, self._console_address =3D None self._console_socket =3D None self._remove_files =3D [] + self._user_killed =3D False self._console_log_path =3D console_log if self._console_log_path: # In order to log the console, buffering needs to be enabled. @@ -327,7 +329,8 @@ def _post_shutdown(self): self._remove_if_exists(self._remove_files.pop()) =20 exitcode =3D self.exitcode() - if exitcode is not None and exitcode < 0: + if (exitcode is not None and exitcode < 0 + and not (self._user_killed and exitcode =3D=3D -signal.SIG= KILL)): msg =3D 'qemu received signal %i; command: "%s"' if self._qemu_full_args: command =3D ' '.join(self._qemu_full_args) @@ -335,6 +338,7 @@ def _post_shutdown(self): command =3D '' LOG.warning(msg, -int(exitcode), command) =20 + self._user_killed =3D False self._launched =3D False =20 def launch(self): @@ -469,6 +473,7 @@ def shutdown(self, has_quit: bool =3D False, =20 try: if hard: + self._user_killed =3D True self._hard_shutdown() else: self._do_shutdown(has_quit, timeout=3Dtimeout) --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765742; cv=none; d=zohomail.com; s=zohoarc; b=b0Hj05obGX3BMte4jXlP/9n315ubHuBvq3JwleSCUCb4eMDs6Zo0Pxg++/ZWIvOi9VbSc9qF4XbNUXK2ZRrqMogOz27pVL1L+aFjBqrhfDY9ITJ/LsIm0yI4ZeGmkWz6nhplFpjoq0yafqRlEJpHlpCxwQGrVBRK4fty1USEUsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765742; 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=j02F5ic5GFszUU2+6LTrgWj0JvABR23KJP15O63NAeA=; b=kZvlhtpNhmnNAFUbjQ7dbi4FW0UDAj0NKtnB4pIrn1bNrCAvsQ/hl/rTyKqG3ppza+uCbU4RWhjOdHwGo/OP/V2nNa1kttPNuKOwmOwGuXUs5UB4dLtyzP6E+DV7Mv+5uWZ8nnHTkdhTPq3SQFWL+DAjeBFVUhLykEs3w/WJ11w= 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 1594765742317390.22882552479155; Tue, 14 Jul 2020 15:29:02 -0700 (PDT) Received: from localhost ([::1]:51666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTQ4-00042t-Vo for importer@patchew.org; Tue, 14 Jul 2020 18:29:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTJy-0001Nm-Bg for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:42 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:56859 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 1jvTJw-0004qh-IA for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:41 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-qKW3wQuIMQ6w2foK1v45mg-1; Tue, 14 Jul 2020 18:22:37 -0400 Received: by mail-wr1-f69.google.com with SMTP id i14so18551wru.17 for ; Tue, 14 Jul 2020 15:22:37 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id y16sm164008wro.71.2020.07.14.15.22.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765359; 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=j02F5ic5GFszUU2+6LTrgWj0JvABR23KJP15O63NAeA=; b=f5BivysUbIOP4tayQCTcroxZmBjTwINYdpCkH3yAla2FgYBjj1xJbtmGWhrEVd4zQ+8TtI xfDcS2xjqzA9ciDOcek91h3ZRXMU6YA1ZyhrStmEP7U8tugGBvMo4w7Z+/7pK4HrtVwAZh +47c9H90Cfw/2Jg76lsvtmUN3CVexrw= X-MC-Unique: qKW3wQuIMQ6w2foK1v45mg-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=j02F5ic5GFszUU2+6LTrgWj0JvABR23KJP15O63NAeA=; b=s8vBT42gVYQ+7gopXCPXfXBZV4owFE2mogvdxMxv2Mr/yld0CtfhhNGphFyUsZrul7 c6Ab8AcN8zl+lLkOJ7LDoVvFrKNIteqvqKpkLDTTsZpMYIrhkOgkXgzP8M//IzaAgSdC A8wUIQ6HZsPsO2vd5/sUYGvNTXHTseuim6GPr6KPQnDVvxRTZbVaUwksOYoql2a7vSPs WxCADXmtvEUhybJiHmbIIKZYUjSLFLUH0waY0jJoHsONmuWnnx5VXU1rlAWgXgdKlLpA pRqsifsAPdXZbsAXVMkpcz2mD2G9aIJVuXWf793rIpYDVCoZEV/BTgvcen2Acgiv2I+X h28A== X-Gm-Message-State: AOAM533w48axILcqMPWCsvGUvGFILhMnQITLiwMeaX7AEhojFHPlWPcM U0RWKXZXasz56DGAEeWcizJDPnCTVrPZOe6x92Fzg2mt+bqZ5mh/XSy/UsaYQJtDZkjPmteeB9C 8LU+u+b7D+DD+b4c= X-Received: by 2002:a1c:7f82:: with SMTP id a124mr5465654wmd.132.1594765356326; Tue, 14 Jul 2020 15:22:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvC7OqoVsBQA0sERYprgjXmkhrNV6Tou5Y09ZSqk6LiCFWVwLqhTg6huEvyc6bFAdtz29q1w== X-Received: by 2002:a1c:7f82:: with SMTP id a124mr5465640wmd.132.1594765356084; Tue, 14 Jul 2020 15:22:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 13/19] python/machine.py: change default wait timeout to 3 seconds Date: Wed, 15 Jul 2020 00:21:26 +0200 Message-Id: <20200714222132.10815-14-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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/07/14 03:57:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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: Ahmed Karaman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Eduardo Habkost , Cleber Rosa 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 Machine.wait() does not appear to be used except in the acceptance tests, and an infinite timeout by default in a test suite is not the most helpful. Change it to 3 seconds, like the default shutdown timeout. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Message-Id: <20200710050649.32434-13-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 736a3c906f..69055189bd 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -486,12 +486,12 @@ def kill(self): """ self.shutdown(hard=3DTrue) =20 - def wait(self, timeout: Optional[int] =3D None) -> None: + def wait(self, timeout: Optional[int] =3D 3) -> None: """ Wait for the VM to power off and perform post-shutdown cleanup. =20 :param timeout: Optional timeout in seconds. - Default None, an infinite wait. + Default 3 seconds, A value of None is an infinite = wait. """ self.shutdown(has_quit=3DTrue, timeout=3Dtimeout) =20 --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765645; cv=none; d=zohomail.com; s=zohoarc; b=hX9kdMIUM995/is9dhE748Ar5i93L3paOAYTFCuU4D5i/MNzfYUeq1FlID0ttfzo/bn9pdszYfqALmj3Fe2yHkOYGrkAR2l6N1+CtgHtboPUKUBhNwRpJXNbUOm1kZ4GeUula51gyFfcHOtsYG4b34BgR653Kg0UdrotmD59ses= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765645; 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=uqbjq2eSEV+Z/U6UkFGjrSQIABqGIU5R3iUFws37JAY=; b=KlnndF3H737iJ560/Aj+a5gLeGmAqMLiwnZtoVCMdyOacrjoQ/3bm2pzcQoskDnKnb3iK+ZdbiEdeOyewmfelTPSCPrEXwy0VVQ3km8VuX46tnCEEs1A8dXzSweGb22zkAUtmrV1FDaRkOwvTeDnlgM+mlHC2uSLzMNRxLLi3GE= 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 1594765645643171.03757374266866; Tue, 14 Jul 2020 15:27:25 -0700 (PDT) Received: from localhost ([::1]:44632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTOW-0001A1-FO for importer@patchew.org; Tue, 14 Jul 2020 18:27:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTK2-0001XV-LI for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:46 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35904 helo=us-smtp-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 1jvTK0-0004sh-Qv for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:46 -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-208-1yOtK8oUOZKQ54ZyAxLYWQ-1; Tue, 14 Jul 2020 18:22:42 -0400 Received: by mail-wr1-f72.google.com with SMTP id b8so18304wro.19 for ; Tue, 14 Jul 2020 15:22:42 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id q5sm173563wrp.60.2020.07.14.15.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765364; 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=uqbjq2eSEV+Z/U6UkFGjrSQIABqGIU5R3iUFws37JAY=; b=QmJ20a2/sD161kWgLArsrYXvWGkZ80krPlIXHMy/aeTA++8tyQFDdFU1T5nVn/OTUMaVDq o5yIQYKGQ8xrgO40XQK4+Xvn4048U+nqk0+qgTZ3k2wWycdOL/A3+Lumcy1VMVsI603DtE YZ9EkFLSU/TMGjWZ9Rqexpm9IBb8ZQA= X-MC-Unique: 1yOtK8oUOZKQ54ZyAxLYWQ-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=uqbjq2eSEV+Z/U6UkFGjrSQIABqGIU5R3iUFws37JAY=; b=GOzypodTAha2SGUxjA++hXKpww4EUSDtQ734q+Y7OxocXsyUdk/jHJxf3YWXaOwxQs 87S4V26IhDE0fuoRWpIsIhBKJdqK5QcMBFWSpLIjQK/A/3V+Q2skLj2BlzqLE6UN7kAs 5s7SPUj2Lve11WefBvEi+O+4KaPdCMPnILm514W7sMCyQFZDIP0xeFb+8eUCCeFbZkff nkHQZ4U2hqGgVNQ08C7tn0GNYIsZXLOc4AVR5ImN2/UVlfGVHHgjs9nx6EJ4M4mVelpO /sGM3a3r9w4kM9coAxOpmBlXFl/BCzHCBTrccWNs8RdFv0qNAi8kCdzkuNBMpDR/79h8 L7XA== X-Gm-Message-State: AOAM531gFCdT76C8ukWNcbGqc/fzr0HwjvBhtBYqDdM94PyyBXlLZTUZ o9G6m3W/MMi59jYfEQvCqzPkhD1FCmvqRYGTo+UkeWe3R2egGfKxOJcKzDp0MWzffXGNjIhmvos wldt2YK4gvognx4o= X-Received: by 2002:adf:fa8f:: with SMTP id h15mr8046335wrr.211.1594765361131; Tue, 14 Jul 2020 15:22:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgw8+a9oaIkhkITRQEjINbjIs+0+n0DnAHgVxNPI4gCYRDO4i3daoVIKpHcyUjPf0DaYki/w== X-Received: by 2002:adf:fa8f:: with SMTP id h15mr8046313wrr.211.1594765360916; Tue, 14 Jul 2020 15:22:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 14/19] python/qmp.py: Define common types Date: Wed, 15 Jul 2020 00:21:27 +0200 Message-Id: <20200714222132.10815-15-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 01:42:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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 , Eduardo Habkost , John Snow , Ahmed Karaman , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Define some common types that we'll need to annotate a lot of other functions going forward. Signed-off-by: John Snow Reviewed-by: Kevin Wolf Message-Id: <20200710052220.3306-2-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/qmp.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py index e64b6b5faa..8388c7b603 100644 --- a/python/qemu/qmp.py +++ b/python/qemu/qmp.py @@ -12,13 +12,31 @@ import socket import logging from typing import ( + Any, + Dict, Optional, TextIO, Type, + Tuple, + Union, ) from types import TracebackType =20 =20 +# QMPMessage is a QMP Message of any kind. +# e.g. {'yee': 'haw'} +# +# QMPReturnValue is the inner value of return values only. +# {'return': {}} is the QMPMessage, +# {} is the QMPReturnValue. +QMPMessage =3D Dict[str, Any] +QMPReturnValue =3D Dict[str, Any] + +InternetAddrT =3D Tuple[str, str] +UnixAddrT =3D str +SocketAddrT =3D Union[InternetAddrT, UnixAddrT] + + class QMPError(Exception): """ QMP base exception --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765978; cv=none; d=zohomail.com; s=zohoarc; b=QCBIpVUZgH06BUxd7TQMC/y2k+e6gQ4F/5cHGkAf9j+VvmkYil0lW9U5sYwGKXqT5Yc0j9YrgtGla5+F3jBSqIgXaqP0FBM36lt4u6OUzimV9tveFiuQIz6AFiDRbnIeehmnUsWUGwoWJBwm8hEtg+E/30quKKH+M3XU+oCxf8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765978; 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=rq8+AkQ2f65ZI8kNrmi3lYHC8ESMu5ga2yLy+oSnBcw=; b=iPxhcxqmfgV+ETYpofgIk0MzgltaaxPJhTcT9uvi+3+sbvgIgUMYSUEbHtcL/NfJ7nPmbEzMotXASo6NgI08/kq1+OLPa6Z4ck5B/o5BHUDhItszUitf2Koqkc3cTv0lLhOZDPy1WnTqsbHOcZ+/iV/gI9rXCIumZp5m31IXTzY= 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 1594765978188312.99795782554395; Tue, 14 Jul 2020 15:32:58 -0700 (PDT) Received: from localhost ([::1]:35494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTTt-0000ii-0O for importer@patchew.org; Tue, 14 Jul 2020 18:32:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTKD-0001oR-E6 for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49304 helo=us-smtp-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 1jvTK7-0004w7-N5 for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:57 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-LVXPlCMdNomaVdBRg7awvg-1; Tue, 14 Jul 2020 18:22:47 -0400 Received: by mail-wm1-f72.google.com with SMTP id b13so88718wme.9 for ; Tue, 14 Jul 2020 15:22:47 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id 68sm285232wmz.40.2020.07.14.15.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765371; 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=rq8+AkQ2f65ZI8kNrmi3lYHC8ESMu5ga2yLy+oSnBcw=; b=QxDOnFwMUuzrxwRLSGizeAxDPFnDgbpMM95M6Tj2uR/viYQG25+KlQv62E9nUPmpi8JOP6 s20w44LSrxjky0cKYrHUYPPYSAGGLU+yhuc/7S3DXoUpeVlMZQtfRD/Uvwa+g/4ZtA9Nex ENOiD/h9IU7e0R1ydX3eHe+8h8JBP0Q= X-MC-Unique: LVXPlCMdNomaVdBRg7awvg-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=rq8+AkQ2f65ZI8kNrmi3lYHC8ESMu5ga2yLy+oSnBcw=; b=JEEcp0gkLO5+RxgDZpU2hJ229gGULvHJX0HE7QlHL0Xf/Pn7U8dpJq7UyCO6mwpj8R LwnGaw6PHvngkOlb5pKqAiZLSLRqcpj1fWYE0GAOYPuAm+wxOrzNPR1lC2svEL9RZaNy fyxxeJviU/M+QzloNW6jcs+A7trLJQxgkAD8qzrpSoJvyCRBdnjqM6LbHwZac1y3zchz 4G05zdcu9rgzMgZ6zrZ8XLYCnIWSHNYveIO4jmeQOCX+mhp7tfMznSsOeV4x/nVGA3yS ypL7gYiszZNAO4TlGUPL09SwxPNckMVfr4diQ53KJu5LtI8YALV1iFKN54qApCbV5wqd +bTg== X-Gm-Message-State: AOAM5332j2qComIeLxAA/YKioxvI2SgvtLGRgQn/vwpTtBnlC/pV/FI4 taPxhXyYTnH8y3xjO0wNYotL8X5DG6ylemYxuGYpmDYviJGmmQ8qVpMzNYT7XDAYJo3dLZKFiol X+yQ/Xjw4c7oIcY4= X-Received: by 2002:a1c:dcd5:: with SMTP id t204mr5630259wmg.17.1594765366150; Tue, 14 Jul 2020 15:22:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ0W1+mYV+xIoQKOnPVpPvIcjDUeg6KBenJbmH5A4pOKNAkP29TAvjcxBiE/kLmrFQ3GPijQ== X-Received: by 2002:a1c:dcd5:: with SMTP id t204mr5630246wmg.17.1594765365977; Tue, 14 Jul 2020 15:22:45 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 15/19] iotests.py: use qemu.qmp type aliases Date: Wed, 15 Jul 2020 00:21:28 +0200 Message-Id: <20200714222132.10815-16-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 18:21:58 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=unavailable autolearn_force=no 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 , Eduardo Habkost , "open list:Block layer core" , John Snow , Max Reitz , Ahmed Karaman , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 iotests.py should use the type definitions from qmp.py instead of its own. Signed-off-by: John Snow Reviewed-by: Kevin Wolf Message-Id: <20200710052220.3306-3-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/qemu-iotests/iotests.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 8b760405ee..3590ed78a0 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -35,13 +35,10 @@ # pylint: disable=3Dimport-error, wrong-import-position sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) from qemu import qtest +from qemu.qmp import QMPMessage =20 assert sys.version_info >=3D (3, 6) =20 -# Type Aliases -QMPResponse =3D Dict[str, Any] - - # Use this logger for logging messages directly from the iotests module logger =3D logging.getLogger('qemu.iotests') logger.addHandler(logging.NullHandler()) @@ -561,7 +558,7 @@ def add_incoming(self, addr): self._args.append(addr) return self =20 - def hmp(self, command_line: str, use_log: bool =3D False) -> QMPRespon= se: + def hmp(self, command_line: str, use_log: bool =3D False) -> QMPMessag= e: cmd =3D 'human-monitor-command' kwargs =3D {'command-line': command_line} if use_log: @@ -582,7 +579,7 @@ def resume_drive(self, drive: str) -> None: self.hmp(f'qemu-io {drive} "remove_break bp_{drive}"') =20 def hmp_qemu_io(self, drive: str, cmd: str, - use_log: bool =3D False) -> QMPResponse: + use_log: bool =3D False) -> QMPMessage: """Write to a given drive using an HMP command""" return self.hmp(f'qemu-io {drive} "{cmd}"', use_log=3Duse_log) =20 --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765854; cv=none; d=zohomail.com; s=zohoarc; b=I9CmXMoMvrfWog2um/Odq3uROiiYAAnjMqnXJNIhsNsv6es4j57+CoUWCDFJ4CnMfoAdc34g6vNr/SodJmx/e5HPGbwgtQjZ9SIy6wL0QCFCGuTLNta5AbOcAZUMTGcNkhvg8embaWnn/4wGDAs1UoAIQUu76TJVykJ9Bjb+m8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765854; 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=re7gKjIDIxjZ168y2pnh2vU3k4lXjSx5/GbYDUTFUY0=; b=ZrRiafpzRMndWT5Rp9Dwj6w5qdbj+H9KDfbwO+Fby51pVIWB8mw57oKpQn/CSsg548gWwbk3xJCXOnYdbARqRA4yTFMluD2EW3fhklaO0gqtQaLG7PUZCGTW7iz9ODstQ1t9ewUEHd7NuJ5AQ4qIIdmLWYoxlhtLJf6qFLYLjW4= 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 1594765854746910.1479296056291; Tue, 14 Jul 2020 15:30:54 -0700 (PDT) Received: from localhost ([::1]:58008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTRt-0006cx-I5 for importer@patchew.org; Tue, 14 Jul 2020 18:30:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTKD-0001pr-Us for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:57 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:33186 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 1jvTKC-0004wP-2Z for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:22:57 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-lJDu1lPVMyyinQWGs2yLDw-1; Tue, 14 Jul 2020 18:22:52 -0400 Received: by mail-wr1-f71.google.com with SMTP id b8so18420wro.19 for ; Tue, 14 Jul 2020 15:22:52 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id y189sm386094wmd.27.2020.07.14.15.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765373; 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=re7gKjIDIxjZ168y2pnh2vU3k4lXjSx5/GbYDUTFUY0=; b=EiElOsVK0YFoZXcpx7rZiFAfqMnKbuirxMOnHe10CFf4OlYadJlaeOqLUmPGpoLiC81FrG WAY/Z1UTcmHZH6m0IIxfFMuzXulJ3l3qIP4VsMkS0d9UB3ojHV+9hHvwqJU0WNRP4Azh+z ETWFpufeLKcAJOJ8gfbBgE4r+n7ed00= X-MC-Unique: lJDu1lPVMyyinQWGs2yLDw-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=re7gKjIDIxjZ168y2pnh2vU3k4lXjSx5/GbYDUTFUY0=; b=idLcoaqJoohO3r4AxODE7CP8+exwyt030AfDunqcr7Lh7w/5JhDbj4+khFV4OOeVL3 P6fuOuurExlvbJ/YxwGz/1xR7T1vCoYN4eDJARAj+2ajV+hO7h83JRswSa5zT41f+dUZ S6KcxXVqS8j/AhRJ4ufVTWQGcMsIKPR9HaU5XQ7lTryAY8wMZrex/EUOTNZEPomSTvvI 4+QxT+0Gh5nW0C6W/04K8XaPsC86MEc5By+Q1vpeOv0PzYJXoGneQroUF+0yzS0lLgvV L61NBRJ77jhVAf5dmjntdmfpGNGvn/iFFUOmxaQnLygTZ4ak0AH0Hv2FcCAnwZ5Lxfii Hcmg== X-Gm-Message-State: AOAM532MU7uE5hR+ekawdFkophDJldBqyC1wrknoaztt1Q7d3Y/cJse3 y7ud8rZljPjIyc01/9qcO0ymJyy/q0ruAEZTvRoclNgdTcwlsopsonZmewt2kXKzx0jbGQGBsDO zCDGBj8063AV+6UI= X-Received: by 2002:adf:f350:: with SMTP id e16mr7854963wrp.43.1594765370841; Tue, 14 Jul 2020 15:22:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXiNIgqK8oqPlJZrnbHoy0394nTkrzba7SHXIDy15Y4LpispKvRSNUA1ToUonH0lG38oBdSA== X-Received: by 2002:adf:f350:: with SMTP id e16mr7854944wrp.43.1594765370596; Tue, 14 Jul 2020 15:22:50 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 16/19] python/qmp.py: re-absorb MonitorResponseError Date: Wed, 15 Jul 2020 00:21:29 +0200 Message-Id: <20200714222132.10815-17-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 12:02:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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 , Eduardo Habkost , John Snow , Ahmed Karaman , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 When I initially split this out, I considered this more of a machine error than a QMP protocol error, but I think that's misguided. Move this back to qmp.py and name it QMPResponseError. Convert qmp.command() to use this exception type. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Kevin Wolf Message-Id: <20200710052220.3306-4-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/machine.py | 15 +-------------- python/qemu/qmp.py | 17 +++++++++++++++-- scripts/render_block_graph.py | 7 +++++-- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 69055189bd..80c4d4a8b6 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -56,19 +56,6 @@ class AbnormalShutdown(QEMUMachineError): """ =20 =20 -class MonitorResponseError(qmp.QMPError): - """ - Represents erroneous QMP monitor reply - """ - def __init__(self, reply): - try: - desc =3D reply["error"]["desc"] - except KeyError: - desc =3D reply - super().__init__(desc) - self.reply =3D reply - - class QEMUMachine: """ A QEMU VM @@ -533,7 +520,7 @@ def command(self, cmd, conv_keys=3DTrue, **args): if reply is None: raise qmp.QMPError("Monitor is closed") if "error" in reply: - raise MonitorResponseError(reply) + raise qmp.QMPResponseError(reply) return reply["return"] =20 def get_qmp_event(self, wait=3DFalse): diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py index 8388c7b603..aa8a666b8a 100644 --- a/python/qemu/qmp.py +++ b/python/qemu/qmp.py @@ -61,6 +61,19 @@ class QMPTimeoutError(QMPError): """ =20 =20 +class QMPResponseError(QMPError): + """ + Represents erroneous QMP monitor reply + """ + def __init__(self, reply: QMPMessage): + try: + desc =3D reply['error']['desc'] + except KeyError: + desc =3D reply + super().__init__(desc) + self.reply =3D reply + + class QEMUMonitorProtocol: """ Provide an API to connect to QEMU via QEMU Monitor Protocol (QMP) and = then @@ -251,8 +264,8 @@ def command(self, cmd, **kwds): Build and send a QMP command to the monitor, report errors if any """ ret =3D self.cmd(cmd, kwds) - if "error" in ret: - raise Exception(ret['error']['desc']) + if 'error' in ret: + raise QMPResponseError(ret) return ret['return'] =20 def pull_event(self, wait=3DFalse): diff --git a/scripts/render_block_graph.py b/scripts/render_block_graph.py index 409b4321f2..da6acf050d 100755 --- a/scripts/render_block_graph.py +++ b/scripts/render_block_graph.py @@ -25,7 +25,10 @@ from graphviz import Digraph =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python')) -from qemu.machine import MonitorResponseError +from qemu.qmp import ( + QEMUMonitorProtocol, + QMPResponseError, +) =20 =20 def perm(arr): @@ -102,7 +105,7 @@ def command(self, cmd): reply =3D json.loads(subprocess.check_output(ar)) =20 if 'error' in reply: - raise MonitorResponseError(reply) + raise QMPResponseError(reply) =20 return reply['return'] =20 --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765753; cv=none; d=zohomail.com; s=zohoarc; b=JDT+WPoJ8iT788GCOPlGdJGJVglsG47j1OhFy8PpRK9UBNCBtsMGzHEmvrjvlJJEjAMuOuoxVQyAaldBRuvxJJz04LmsoW6YxWyft5MWJI3HP7Awdk+YKhX9N3Cczg1lP/IZKmvtK3DeIovfhLXHwipp74XGRWTOon1cIITGDUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765753; 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=34BOciJNToD087b3DmEPBjP+atCQ4f8lF8uOK0B/VQo=; b=eoF9UGKsSG4HXoiiDiTy7jdZVZr2KnNVz4ghHASb7sZ5vZ2y13/KaSrPArHTpsFBvWn/SqPOlYHcr9rdmhnRlNMRJX12VwPB0H/HZiyaUlYVgiokbVH40Qa/YZufuG67NlEAAvL9eJVcASlssRz/e9mubkWoL1vMjP7N61qlFNs= 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 1594765753759975.9261203995636; Tue, 14 Jul 2020 15:29:13 -0700 (PDT) Received: from localhost ([::1]:52592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTQG-0004Pq-Fx for importer@patchew.org; Tue, 14 Jul 2020 18:29:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTKJ-00023P-9n for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:23:03 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:55618 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 1jvTKH-0004wy-Eb for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:23:02 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-79--Crii8NfNNOcjMzSqN41iQ-1; Tue, 14 Jul 2020 18:22:57 -0400 Received: by mail-wm1-f71.google.com with SMTP id w25so3502521wmc.0 for ; Tue, 14 Jul 2020 15:22:57 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id a2sm160275wrn.68.2020.07.14.15.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765380; 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=34BOciJNToD087b3DmEPBjP+atCQ4f8lF8uOK0B/VQo=; b=DuTNakhX71xD8GeB9sLqIaANETRwQUsTiY18bZKFdSbqhCnh5EiamS1VYSAmzg6GcpA53r tKE04hvDDM1xAXENrJ1TNN6uQgAXjD9BznRdviLd9wflB5acGxyPI8B1OJM5N/a3V4Gssh 9LBhH2UW3rIE6gMi7OI6Qs7A21DsJWQ= X-MC-Unique: -Crii8NfNNOcjMzSqN41iQ-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=34BOciJNToD087b3DmEPBjP+atCQ4f8lF8uOK0B/VQo=; b=GiJamUMrS+XyxFcomsCHKM2z1o1Wb/j68Wws1HE5VGzcAqXk2n1OeGuNuRxMGfqEWx 76AQkRlbcfSnl+t6o+Y+qdsU6V72gFi6up+YM3afKh46iEIqGvu2n0wlu4vKEIi/sP+8 i0B6RU6G1yKBoVxrp49RU7M0ALG4oZ81eyrHfOF64BQ52EtRButtdneLAmSkJ7fZG5iK hfq44PFqj9hlfKc3fPJS+vqHN5zGMGLYzBpgyTClFqnRBbRt0nXr7cRCkJrlSkr7aqVX YX+sprsp5AomVban5MJMR3syuaTRG9dwBAA1XMTog2g0Tv5NqevZZ1BoIpdEu64kL2EV 1tOA== X-Gm-Message-State: AOAM532ejtBAioPntoL4tMobxCvgupUflit4Vz/xNkuzWVRiHOX7dBL6 EylC03wkefh/BkUOwzbR38eHJD32JK8HRl5B6SQ+zW7VAFlJklgNEwBOY+yDPlBYcl/xcVQVHjl /imLL8FEeYS+CJVg= X-Received: by 2002:adf:e80d:: with SMTP id o13mr7963494wrm.112.1594765375651; Tue, 14 Jul 2020 15:22:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwNHB5UaUZCpE+Fa7BIw0lDObJzVZX+kL0W1LO6KAsXyqyguMPGZdBEvEHX7rhy4WGiyA3dg== X-Received: by 2002:adf:e80d:: with SMTP id o13mr7963479wrm.112.1594765375473; Tue, 14 Jul 2020 15:22:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 17/19] python/qmp.py: Do not return None from cmd_obj Date: Wed, 15 Jul 2020 00:21:30 +0200 Message-Id: <20200714222132.10815-18-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com 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=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 12:02:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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 , Eduardo Habkost , John Snow , Ahmed Karaman , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 This makes typing the qmp library difficult, as it necessitates wrapping Optional[] around the type for every return type up the stack. At some point, it becomes difficult to discern or remember why it's None instead of the expected object. Use the python exception system to tell us exactly why we didn't get an object. Remove this special-cased return. Signed-off-by: John Snow Reviewed-by: Kevin Wolf Message-Id: <20200710052220.3306-5-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/qmp.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py index aa8a666b8a..ef3c919b76 100644 --- a/python/qemu/qmp.py +++ b/python/qemu/qmp.py @@ -225,22 +225,18 @@ def accept(self, timeout=3D15.0): self.__sockfile =3D self.__sock.makefile(mode=3D'r') return self.__negotiate_capabilities() =20 - def cmd_obj(self, qmp_cmd): + def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage: """ Send a QMP command to the QMP Monitor. =20 @param qmp_cmd: QMP command to be sent as a Python dict - @return QMP response as a Python dict or None if the connection has - been closed + @return QMP response as a Python dict """ self.logger.debug(">>> %s", qmp_cmd) - try: - self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8')) - except OSError as err: - if err.errno =3D=3D errno.EPIPE: - return None - raise err + self.__sock.sendall(json.dumps(qmp_cmd).encode('utf-8')) resp =3D self.__json_read() + if resp is None: + raise QMPConnectError("Unexpected empty reply from server") self.logger.debug("<<< %s", resp) return resp =20 --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594766039; cv=none; d=zohomail.com; s=zohoarc; b=CwURoWRWsrkhjKgn/QHc4o5Ar/yhPlaT8dspf6KzTBO9LHOSmsrrovyK0T0EDzlHma5eYNmtI+qnFx1kQ8xj7GnP8G3cjFT/QroMtcK4j8L+sj8dCGKM8yAJzrn2t+ASC8myaGPaogLrg2WqVmp7Ok+KB7I23BGqnjcYoxDoVkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594766039; 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=tLWK+z3sBfoVdzNValfBnDhtm+6ZIPj+zWa7w6Apw00=; b=BYehxmzLvULN5TxKooaVeoifR1J6pnOertP3RYhXjXTsnRcpn2nlKn5tqy+qETkPm+ke7bIupbMHxrwoKZAHsPU4hj4qqKLkWBpTSTatz0tQVWKVwkzOsaePGKTlL6TI934qnpQMtb2tijGCw21p6W9vML1IPpx4T+KrXHHVans= 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 1594766039867142.35762683508676; Tue, 14 Jul 2020 15:33:59 -0700 (PDT) Received: from localhost ([::1]:39138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTUs-0002JR-MH for importer@patchew.org; Tue, 14 Jul 2020 18:33:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTKO-0002Fv-4K for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:23:08 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:30883 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 1jvTKM-0004xL-9c for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:23:07 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-173-TTmAkOahO2Wqn05wJq-rNg-1; Tue, 14 Jul 2020 18:23:01 -0400 Received: by mail-wm1-f71.google.com with SMTP id b13so88907wme.9 for ; Tue, 14 Jul 2020 15:23:01 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id a15sm192887wrh.54.2020.07.14.15.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765385; 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=tLWK+z3sBfoVdzNValfBnDhtm+6ZIPj+zWa7w6Apw00=; b=ZpSXrWerRXKgq0Dpk4sEsfzQtsFGZX8NXycIBYPac5/uBVwjcKo4lF3//zVbm4zTqoZtkU pbRjcdebIocmKQ++cWNlMqio2ANbxNfyi+7cDMqWXRHtvAVJ+/x5mr8CpFH0RtF5RA425Z wTBM0lxRzKPJlBSNNjVz3zTaj03/Dlg= X-MC-Unique: TTmAkOahO2Wqn05wJq-rNg-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=tLWK+z3sBfoVdzNValfBnDhtm+6ZIPj+zWa7w6Apw00=; b=sc2QmlExdJesGGH4OVEwfa+RGHVddLvrI1zwIeopH/McOuYYtudygzef+P009eryqm jzjqQQkmWA2T7daJYkB/FPCdvXEIs1KtNAqhe1NItgTN0fVngRLb2PuhCkA2TUubec9Q 9CZDEbp4zqnkjP9FXjNHQJ22aZZD3YtJ3pjr2ObZ4qLhF2sgX0cMpKGcgkwTVZ59KQfK Nd/En3DGwv8JGB/mGLnicoaA8cp/+Y1y4gRrHZlC3hv+AHP3DX6QUuhLOU471nf6Fdx0 1YpmrOE6Fmem1h+nFhBgV88asJ1Bc0HOmzHwSd6nK1TAntFbbZvvbxFhzOubyx3oxkp6 xwqg== X-Gm-Message-State: AOAM5314zO2y7WIXIyKudPIiemqYXvc9Y0eDieXLjKkkIjG4Ey/iTCoG xy/b5Ea+ooJDuPEdmvAaXycwmGUrn/pZS9yTZXFPP9VZzITxjWnqytt2F5iOTzo438BqXb4q1wu YBm03OOgBDiakNTs= X-Received: by 2002:a5d:68cc:: with SMTP id p12mr7956197wrw.111.1594765380392; Tue, 14 Jul 2020 15:23:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXwdQYJTrYyPvnX9mGohdnRt46wLiYrJEF/n445vpnAkkfl891rxpU1uqXlUGjqUTxpTvFQg== X-Received: by 2002:a5d:68cc:: with SMTP id p12mr7956185wrw.111.1594765380185; Tue, 14 Jul 2020 15:23:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 18/19] python/qmp.py: add casts to JSON deserialization Date: Wed, 15 Jul 2020 00:21:31 +0200 Message-Id: <20200714222132.10815-19-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 12:02:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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 , Eduardo Habkost , John Snow , Ahmed Karaman , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 mypy and python type hints are not powerful enough to properly describe JSON messages in Python 3.6. The best we can do, generally, is describe them as Dict[str, Any]. Add casts to coerce this type for static analysis; but do NOT enforce this type at runtime in any way. Note: Python 3.8 adds a TypedDict construct which allows for the description of more arbitrary Dictionary shapes. There is a third-party module, "Pydantic", which is compatible with 3.6 that can be used instead of the JSON library that parses JSON messages to fully-typed Python objects, and may be preferable in some cases. (That is well beyond the scope of this commit or series.) Signed-off-by: John Snow Reviewed-by: Kevin Wolf Message-Id: <20200710052220.3306-6-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/qmp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py index ef3c919b76..1ae36050a4 100644 --- a/python/qemu/qmp.py +++ b/python/qemu/qmp.py @@ -13,6 +13,7 @@ import logging from typing import ( Any, + cast, Dict, Optional, TextIO, @@ -130,7 +131,10 @@ def __json_read(self, only_event=3DFalse): data =3D self.__sockfile.readline() if not data: return None - resp =3D json.loads(data) + # By definition, any JSON received from QMP is a QMPMessage, + # and we are asserting only at static analysis time that it + # has a particular shape. + resp: QMPMessage =3D json.loads(data) if 'event' in resp: self.logger.debug("<<< %s", resp) self.__events.append(resp) @@ -262,7 +266,7 @@ def command(self, cmd, **kwds): ret =3D self.cmd(cmd, kwds) if 'error' in ret: raise QMPResponseError(ret) - return ret['return'] + return cast(QMPReturnValue, ret['return']) =20 def pull_event(self, wait=3DFalse): """ --=20 2.21.3 From nobody Thu May 16 01:39:37 2024 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=1594765975; cv=none; d=zohomail.com; s=zohoarc; b=Sky/mm4RJP3lWWwA6LNq8xNJtoYoGewbCu8e+R734tLbKwekMMfZhkFjFJFtWCCKzYwTskkuwaoexp9nxTCJDgO+LzfZDM2YbR4NDGGV8gMntAqnMCX4eLwmAEfwQV4Gb27Qs3hfZbK6UVKLYewIk7+6Nmd9AUxn2ZCeHpwFbBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594765975; 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=Akupi2/psErTNl648GD773WL1cQbHEfDPZG4YPkFXLs=; b=XMTjyo9kzQCkJoNIcmkqMFkv/l4JVKWPLs8Mf2ivHyqs5s4g+yQhgDYsRT/Xf1cNmORirsrriIrZ11xxIDTiMaW1NWXTlb7sNL95HMKobdlWx+L4kgfBLQ00LNgxYuJsbL9ifpuXDdBGrR+1eEkoVJyGWZnb2DkVbeEtioVw1/Y= 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 1594765975764995.4456995833317; Tue, 14 Jul 2020 15:32:55 -0700 (PDT) Received: from localhost ([::1]:35328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvTTq-0000dF-Id for importer@patchew.org; Tue, 14 Jul 2020 18:32:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvTKV-0002OW-AG for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:23:15 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50702 helo=us-smtp-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 1jvTKQ-0004xx-Cm for qemu-devel@nongnu.org; Tue, 14 Jul 2020 18:23:15 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-462-yyqF41_9PEWTeYW7Tzf-kQ-1; Tue, 14 Jul 2020 18:23:08 -0400 Received: by mail-wm1-f71.google.com with SMTP id s134so94655wme.6 for ; Tue, 14 Jul 2020 15:23:08 -0700 (PDT) Received: from localhost.localdomain (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id w17sm200963wra.42.2020.07.14.15.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 15:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594765389; 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=Akupi2/psErTNl648GD773WL1cQbHEfDPZG4YPkFXLs=; b=bppqArzsDqcBwpInWR6vq2doUZNlZagkRfUaIi45Qko7XQn0566YvKoL++iFhtM7mUKkhp QRWRZexkZeyvT2NaXex9XUSjo3yToK66xuB59ClXopQvHFEqR24lGIRFZVFXrbSP5bxdNG eAQ88EER4ZbBEOEKmUmYo73Z0tMs8zs= X-MC-Unique: yyqF41_9PEWTeYW7Tzf-kQ-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=Akupi2/psErTNl648GD773WL1cQbHEfDPZG4YPkFXLs=; b=F9F9OuyOThagS1Ga6X/yOwNDqX6XOOQi9J0gSORy1Xys4wDdMNE9INd5eWl992AZUL GrPfEFYvHltZG24T7bRRiILEJNhRbmMYl9gBkIJ1fjb2yKpLOSUjRZSferNvnOuh3R4D GtGxM7UmTmOSgFBMfAC6iCY5NWSw+fHkSCvLYNj4bWsmzwm58re6Xew4xFg452gNHkVR 7+qUr7T1MXa36pRRVxmGVW7wUQRIl0B94b3gLtDWaneASr+EeL9FrpiGIdujD2VGvgbb ad8wZ6xfT0KfyUt89N17KJ65Trj2Uy99glg5a4NHiiP+HZS02HrsPJFnJq7dOqOG3lwO wYSA== X-Gm-Message-State: AOAM531n1v94I6kCvcYlm05Cmc+sHC+Jq3516ng+ZKqSJtPubO/Jtqrp by5XbTvAfYymiWmrXgbQsBuFut9SMHcT/cZlUeD7CTg6DLr+8OswYu3dOIl+dB7BcplXsLMgn8m p0TFF88r0xgVTo7U= X-Received: by 2002:a05:600c:313:: with SMTP id q19mr5112983wmd.9.1594765385249; Tue, 14 Jul 2020 15:23:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl1qd4y1/guXy5rG6B2MQmlkEIjFWiigjiGR1tZNete2GxbwUixFCefgmCOIC3Bxi6hpAqSA== X-Received: by 2002:a05:600c:313:: with SMTP id q19mr5112971wmd.9.1594765385077; Tue, 14 Jul 2020 15:23:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 19/19] python/qmp.py: add QMPProtocolError Date: Wed, 15 Jul 2020 00:21:32 +0200 Message-Id: <20200714222132.10815-20-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200714222132.10815-1-philmd@redhat.com> References: <20200714222132.10815-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.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/14 01:42:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no 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 , Eduardo Habkost , John Snow , Ahmed Karaman , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 In the case that we receive a reply but are unable to understand it, use this exception name to indicate that case. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Kevin Wolf Message-Id: <20200710052220.3306-7-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- python/qemu/qmp.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/qemu/qmp.py b/python/qemu/qmp.py index 1ae36050a4..7935dababb 100644 --- a/python/qemu/qmp.py +++ b/python/qemu/qmp.py @@ -62,6 +62,12 @@ class QMPTimeoutError(QMPError): """ =20 =20 +class QMPProtocolError(QMPError): + """ + QMP protocol error; unexpected response + """ + + class QMPResponseError(QMPError): """ Represents erroneous QMP monitor reply @@ -266,6 +272,10 @@ def command(self, cmd, **kwds): ret =3D self.cmd(cmd, kwds) if 'error' in ret: raise QMPResponseError(ret) + if 'return' not in ret: + raise QMPProtocolError( + "'return' key not found in QMP response '{}'".format(str(r= et)) + ) return cast(QMPReturnValue, ret['return']) =20 def pull_event(self, wait=3DFalse): --=20 2.21.3