From nobody Tue Feb 10 03:45:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506467505621807.1702178644737; Tue, 26 Sep 2017 16:11:45 -0700 (PDT) Received: from localhost ([::1]:51420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwz0w-0002tD-TS for importer@patchew.org; Tue, 26 Sep 2017 19:11:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwywn-0007nm-3I for qemu-devel@nongnu.org; Tue, 26 Sep 2017 19:07:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwywj-0005OB-SE for qemu-devel@nongnu.org; Tue, 26 Sep 2017 19:07:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34256) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwywj-0005NP-Jy for qemu-devel@nongnu.org; Tue, 26 Sep 2017 19:07:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B81C981DFC for ; Tue, 26 Sep 2017 23:07:20 +0000 (UTC) Received: from localhost (ovpn-116-64.gru2.redhat.com [10.97.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03D4F6B6CD; Tue, 26 Sep 2017 23:07:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B81C981DFC Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 26 Sep 2017 20:07:08 -0300 Message-Id: <20170926230709.22958-6-ehabkost@redhat.com> In-Reply-To: <20170926230709.22958-1-ehabkost@redhat.com> References: <20170926230709.22958-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 26 Sep 2017 23:07:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 5/6] device-crash-test: Basic device_add support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , "Dr. David Alan Gilbert" , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a 'method' testcase argument that will test the device using device_add instead of -device. A new device_add_error whitelist key is now supported, to catch device_add errors. Signed-off-by: Eduardo Habkost --- scripts/device-crash-test | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/scripts/device-crash-test b/scripts/device-crash-test index 4c23ffa449..1245e214a0 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -35,7 +35,7 @@ import argparse from itertools import chain =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'scripts')) -from qemu import QEMUMachine +from qemu import QEMUMachine, MonitorResponseError =20 logger =3D logging.getLogger('device-crash-test') dbg =3D logger.debug @@ -203,6 +203,11 @@ ERROR_WHITELIST =3D [ {'log':r"core 0 already populated"}, {'log':r"could not find stage1 bootloader"}, =20 + {'exitcode':None, 'device_add_error':r"^Bus '[\w.-]+' does not support= hotplugging$"}, + {'exitcode':None, 'device_add_error':r"^No '[\w-]+' bus found for devi= ce '[\w-]+'$"}, + # There are too many ways device_add can fail, ignore all of them as l= ong as QEMU doesn't crash: + {'exitcode':None, 'device_add_error':r".+"}, + # other exitcode=3D1 failures not listed above will just generate INFO= messages: {'exitcode':1, 'loglevel':logging.INFO}, =20 @@ -290,7 +295,10 @@ def whitelistResultMatch(wl, r): r.get('exitcode') =3D=3D wl.get('exitcode', 1)) and ('log' not in wl or ('log' in r and - re.search(wl['log'], r['log'], re.MULTILINE)))) + re.search(wl['log'], r['log'], re.MULTILINE))) and + ('device_add_error' not in wl or + ('device_add_error' in r and + re.search(wl['device_add_error'], r['device_add_error'])))) =20 =20 def checkResultWhitelist(r): @@ -339,6 +347,7 @@ class QemuBinaryInfo(object): self.alldevs =3D set(qomListTypeNames(vm, implements=3Ddevtype= , abstract=3DFalse)) self.dev_info =3D dict((t, vm.command('query-device-type', typ= ename=3Dt)) for t in self.alldevs) self.user_devs =3D set(d for d in self.alldevs if self.dev_inf= o[d]['user-creatable']) + self.hotpluggable_devs =3D set(d for d in self.alldevs if self= .dev_info[d]['hotpluggable']) self.machines =3D list(m['name'] for m in vm.command('query-ma= chines')) self.kvm_available =3D vm.command('query-kvm')['enabled'] finally: @@ -391,11 +400,14 @@ def checkOneCase(args, testcase): accel =3D testcase['accel'] machine =3D testcase['machine'] device =3D testcase['device'] + method =3D testcase['method'] + assert method in ['-device', 'device_add'] =20 dbg("will test: %r", testcase) =20 - args =3D ['-S', '-machine', '%s,accel=3D%s' % (machine, accel), - '-device', qemuOptsEscape(device)] + args =3D ['-S', '-machine', '%s,accel=3D%s' % (machine, accel)] + if method =3D=3D '-device': + args.extend(['-device', qemuOptsEscape(device)]) cmdline =3D ' '.join([binary] + args) dbg("will launch QEMU: %s", cmdline) vm =3D QEMUMachine(binary=3Dbinary, args=3Dargs) @@ -405,6 +417,12 @@ def checkOneCase(args, testcase): =20 try: vm.launch() + if method =3D=3D 'device_add': + dbg('running device_add %s', device) + try: + vm.command('device_add', driver=3Ddevice) + except MonitorResponseError, e: + r['device_add_error'] =3D e.reply['error']['desc'] except KeyboardInterrupt: raise except: @@ -434,14 +452,22 @@ def machinesToTest(args, testcase): return getBinaryInfo(args, testcase['binary']).machines =20 =20 +def plugMethods(args, testcase): + return ['-device', 'device_add'] + + def devicesToTest(args, testcase): - return getBinaryInfo(args, testcase['binary']).user_devs + if testcase['method'] =3D=3D 'device_add': + return getBinaryInfo(args, testcase['binary']).hotpluggable_devs + else: + return getBinaryInfo(args, testcase['binary']).user_devs =20 =20 TESTCASE_VARIABLES =3D [ ('binary', binariesToTest), ('accel', accelsToTest), ('machine', machinesToTest), + ('method', plugMethods), ('device', devicesToTest), ] =20 @@ -494,6 +520,8 @@ def logResult(f, level): logger.log(level, "cmdline: %s", f['cmdline']) for l in f.get('log', '').strip().split('\n'): logger.log(level, "log: %s", l) + if 'device_add_error' in f: + logger.log(level, "device_add error: %s", f['device_add_error']) logger.log(level, "exit code: %r", f.get('exitcode')) if 'exc_traceback' in f: logger.log(level, "exception:") --=20 2.13.5