From nobody Mon Feb 9 01:19:51 2026 Delivered-To: importer@patchew.org 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; 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=1582555447; cv=none; d=zohomail.com; s=zohoarc; b=UKElkQlnmiEuPF5WO8RFpNDTT1AoqLIP9XJ024Kbx9w4VrApIGtuUR3bQPaYBrpJPZ98xOylyCUGZjWQIvlKiAbzrQJDSpxMlyTj64Y1GZaNkkmPZMPkn2+1Ya4ivUcHV+6lx/UknjvJlbyzl3pRfhs5qFi1FDzAV+lBqxv+Znw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582555447; 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=kBa7U5Scjuxiou/Q3JgDAKz4JwgKecQXFncadPgqf34=; b=NigSMbfRbFRk7tXrCkLgrJMG7eUJXxBgIi83LR7qY6TlXJsk97rN/3NJjkyI+jO8PAaGc2eCKcvM1HB+VZYvj8UdVEk9BgIZyR1xQCeHuzDGs4rDsXR70d2e7Fyo1J1wS6PNk3g2SiWQw3sXoUNwkqZZScm1FpOlYXsee+rChbA= 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 1582555447526766.9156949309416; Mon, 24 Feb 2020 06:44:07 -0800 (PST) Received: from localhost ([::1]:37588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6Exp-0000fz-F8 for importer@patchew.org; Mon, 24 Feb 2020 09:44:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51024) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6ElX-0002Tl-Lj for qemu-devel@nongnu.org; Mon, 24 Feb 2020 09:31:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6ElW-0002xc-Km for qemu-devel@nongnu.org; Mon, 24 Feb 2020 09:31:23 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23557 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6ElW-0002wJ-Go for qemu-devel@nongnu.org; Mon, 24 Feb 2020 09:31:22 -0500 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-158-LI1KSHlMO5203_ARIcwvhg-1; Mon, 24 Feb 2020 09:31:20 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 605191005510; Mon, 24 Feb 2020 14:31:19 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-134.ams2.redhat.com [10.36.117.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13D7C91835; Mon, 24 Feb 2020 14:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582554682; 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=kBa7U5Scjuxiou/Q3JgDAKz4JwgKecQXFncadPgqf34=; b=LEYKl1C1ZRLRU4baDuF6ywvhqY15jmaCyYXywYYSSMOrOP68ScR9aFACk5iUIxNiqzPWZp jzJuHuE+wMkcrED2hY5jtVvHkc4ea1q4j+mC5znF+mtFWPPT0XBfjIVW2smEqZ+gBSiD/7 kTzHIPLlMip2+M+NmR7Bfhi0V+NnVUo= X-MC-Unique: LI1KSHlMO5203_ARIcwvhg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v2 19/20] monitor: Add allow_hmp parameter to monitor_init() Date: Mon, 24 Feb 2020 15:30:07 +0100 Message-Id: <20200224143008.13362-20-kwolf@redhat.com> In-Reply-To: <20200224143008.13362-1-kwolf@redhat.com> References: <20200224143008.13362-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, coiby.xu@gmail.com, mreitz@redhat.com, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add a new parameter allow_hmp to monitor_init() so that the storage daemon can disable HMP. Signed-off-by: Kevin Wolf --- qapi/control.json | 3 ++- include/monitor/monitor.h | 2 +- monitor/monitor.c | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/qapi/control.json b/qapi/control.json index 3ee086aec7..85b12fe0fb 100644 --- a/qapi/control.json +++ b/qapi/control.json @@ -237,7 +237,8 @@ # # @id: Name of the monitor # -# @mode: Selects the monitor mode (default: readline) +# @mode: Selects the monitor mode (default: readline in the system +# emulator, control in qemu-storage-daemon) # # @pretty: Enables pretty printing (QMP only) # diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index ad823b9edb..1018d754a6 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -19,7 +19,7 @@ void monitor_init_globals(void); void monitor_init_globals_core(void); void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp); void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp); -int monitor_init(MonitorOptions *opts, Error **errp); +int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp); int monitor_init_opts(QemuOpts *opts, Error **errp); void monitor_cleanup(void); =20 diff --git a/monitor/monitor.c b/monitor/monitor.c index 4a36107afb..7e49914626 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -611,7 +611,7 @@ void monitor_init_globals_core(void) NULL); } =20 -int monitor_init(MonitorOptions *opts, Error **errp) +int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp) { Chardev *chr; Error *local_err =3D NULL; @@ -622,11 +622,19 @@ int monitor_init(MonitorOptions *opts, Error **errp) return -1; } =20 + if (!opts->has_mode) { + opts->mode =3D allow_hmp ? MONITOR_MODE_READLINE : MONITOR_MODE_CO= NTROL; + } + switch(opts->mode) { case MONITOR_MODE_CONTROL: monitor_init_qmp(chr, opts->pretty, &local_err); break; case MONITOR_MODE_READLINE: + if (!allow_hmp) { + error_setg(errp, "Only QMP is supported"); + return -1; + } if (opts->pretty) { warn_report("'pretty' is deprecated for HMP monitors, it has n= o " "effect and will be removed in future versions"); @@ -658,7 +666,7 @@ int monitor_init_opts(QemuOpts *opts, Error **errp) goto out; } =20 - monitor_init(options, &local_err); + monitor_init(options, true, &local_err); qapi_free_MonitorOptions(options); =20 out: --=20 2.20.1