From patchwork Wed Mar 10 15:59:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 12128343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7797C433E9 for ; Wed, 10 Mar 2021 16:13:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 33B7364FB9 for ; Wed, 10 Mar 2021 16:13:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33B7364FB9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lK1SQ-00088P-8b for qemu-devel@archiver.kernel.org; Wed, 10 Mar 2021 11:13:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lK1F7-0003Q0-74 for qemu-devel@nongnu.org; Wed, 10 Mar 2021 10:59:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59036) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lK1F3-00026b-9n for qemu-devel@nongnu.org; Wed, 10 Mar 2021 10:59:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615391960; 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=WE4WcvIFHhkJweCB6XjXXqbnzA+3tvmVRvG0rsUu4uc=; b=LLSx+4VVHqpGSfj8r9KbS3J1CXItZ2GEXiUGeku79MWoTlNqMIhXt4bDNJKths8qgUQL4f f4PLWmvx0rvqjzXxUzwqP6uwlqG7nSme8fcN2FL3sIN5RViaSglfzgvDiC02A5kf9rR3cH qbcj7VIjf7HbxF7HYi4qrmUvp/5oeyo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-577-p3WAt37dMGe0Y-_lw0w-Kw-1; Wed, 10 Mar 2021 10:59:16 -0500 X-MC-Unique: p3WAt37dMGe0Y-_lw0w-Kw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C019E80433A; Wed, 10 Mar 2021 15:59:15 +0000 (UTC) Received: from localhost (ovpn-115-159.ams2.redhat.com [10.36.115.159]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 61CD76A047; Wed, 10 Mar 2021 15:59:15 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 3/4] iotests/common.qemu: Allow using the QSD Date: Wed, 10 Mar 2021 16:59:05 +0100 Message-Id: <20210310155906.147478-4-mreitz@redhat.com> In-Reply-To: <20210310155906.147478-1-mreitz@redhat.com> References: <20210310155906.147478-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.243, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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 , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For block things, we often do not need to run all of qemu, so allow using the qemu-storage-daemon instead. Signed-off-by: Max Reitz --- tests/qemu-iotests/common.qemu | 53 +++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/common.qemu b/tests/qemu-iotests/common.qemu index 56c1ea1bac..8003ed3586 100644 --- a/tests/qemu-iotests/common.qemu +++ b/tests/qemu-iotests/common.qemu @@ -291,6 +291,8 @@ _wait_event() # $qmp_pretty: Set this variable to 'y' to enable QMP pretty printing. # $keep_stderr: Set this variable to 'y' to keep QEMU's stderr output on stderr. # If this variable is empty, stderr will be redirected to stdout. +# $qsd: Set this variable to 'y' to use the QSD instead of QEMU. +# stdout and stderr are never redirected when using the QSD. # Returns: # $QEMU_HANDLE: set to a handle value to communicate with this QEMU instance. # @@ -300,18 +302,31 @@ _launch_qemu() local fifo_out= local fifo_in= + if [[ $qsd = 'y' ]]; then + mon_arg='--monitor' + else + mon_arg='-mon' + fi + if (shopt -s nocasematch; [[ "${qemu_comm_method}" == "monitor" ]]) then - comm="-monitor stdio" + comm=(--chardev stdio,id=pipe + $mon_arg pipe,mode=readline) else local qemu_comm_method="qmp" if [ "$qmp_pretty" = "y" ]; then - comm="-monitor none -qmp-pretty stdio" + comm=(--chardev stdio,id=pipe + $mon_arg pipe,mode=control,pretty=on) else - comm="-monitor none -qmp stdio" + comm=(--chardev stdio,id=pipe + $mon_arg pipe,mode=control,pretty=off) fi fi + if [[ $qsd != 'y' ]]; then + comm=(-monitor none "${comm[@]}") + fi + fifo_out=${QEMU_FIFO_OUT}_${_QEMU_HANDLE} fifo_in=${QEMU_FIFO_IN}_${_QEMU_HANDLE} mkfifo "${fifo_out}" @@ -322,15 +337,23 @@ _launch_qemu() object_options="--object secret,id=keysec0,data=$IMGKEYSECRET" fi + if [[ $qsd = 'y' ]]; then + cmd=$QSD + args=() + else + cmd=$QEMU + args=(-nographic -serial none) + fi + args+=(${object_options} "${comm[@]}") + args+=("$@") + + # Just set both QEMU_NEED_PID and QSD_NEED_PID, it can't hurt. if [ -z "$keep_stderr" ]; then - QEMU_NEED_PID='y'\ - ${QEMU} ${object_options} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ - 2>&1 \ - <"${fifo_in}" & + QEMU_NEED_PID='y' QSD_NEED_PID='y' $cmd "${args[@]}" \ + >"$fifo_out" 2>&1 <"$fifo_in" & elif [ "$keep_stderr" = "y" ]; then - QEMU_NEED_PID='y'\ - ${QEMU} ${object_options} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ - <"${fifo_in}" & + QEMU_NEED_PID='y' QSD_NEED_PID='y' $cmd "${args[@]}" \ + >"$fifo_out" <"$fifo_in" & else exit 1 fi @@ -360,6 +383,16 @@ _launch_qemu() silent=yes _timed_wait_for ${_QEMU_HANDLE} "^}" fi fi + + if [[ $qsd = 'y' ]]; then + # Wait for PID file, then move it to where qemu would put it + pidfile="$QEMU_TEST_DIR/qemu-storage-daemon.pid" + while [[ ! -f $pidfile ]]; do + sleep 0.5 + done + mv "$pidfile" "$QEMU_TEST_DIR/qemu-${_QEMU_HANDLE}.pid" + fi + QEMU_HANDLE=${_QEMU_HANDLE} let _QEMU_HANDLE++ }