Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id ED8F6C433EF for ; Fri, 27 May 2022 10:34:51 +0000 (UTC) Received: from localhost ([::1]:45482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuXIw-0005RI-Dj for qemu-devel@archiver.kernel.org; Fri, 27 May 2022 06:34:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuX6e-0005ve-DE for qemu-devel@nongnu.org; Fri, 27 May 2022 06:22:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuX6Y-0004dA-EM for qemu-devel@nongnu.org; Fri, 27 May 2022 06:22:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653646921; 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=QIxm+cF+GHIGPaStoS+t5g+oKyUQgOtqzjH9oUuXyro=; b=ZD6u/6n78mAZiiSrvkDnUkw4zvYXivSvMQgJcyfLU1BgVAsbNDPyN/xgV1+DxxiTQttK1P OX5jvUjXPfV1oKRJH+FV4Lu//aZCQWNEKmR4rskOTmmGEYuLCTqxklkTp6h/nre0HDJ1rP OLBgdveQQUbHpbNJ+lY2hniLHxI6BoM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-124-ZdmPYtZUOj6L5Q-Da5Wrdg-1; Fri, 27 May 2022 06:20:44 -0400 X-MC-Unique: ZdmPYtZUOj6L5Q-Da5Wrdg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4729985A5BC for ; Fri, 27 May 2022 10:20:44 +0000 (UTC) Received: from angien.pipo.sk (unknown [10.40.208.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4909C27E98; Fri, 27 May 2022 10:20:42 +0000 (UTC) Date: Fri, 27 May 2022 12:20:39 +0200 From: Peter Krempa To: Daniel =?iso-8859-1?Q?P=2E_Berrang=E9?= Cc: libvir-list@redhat.com, Markus Armbruster , John Snow , "Dr . David Alan Gilbert" , qemu-devel@nongnu.org Subject: Re: [libvirt PATCH] tools: add virt-qmp-proxy for proxying QMP clients to libvirt QEMU guests Message-ID: References: <20220527094758.604621-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220527094758.604621-1-berrange@redhat.com> User-Agent: Mutt/2.1.5 (2021-12-30) X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pkrempa@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Fri, May 27, 2022 at 10:47:58 +0100, Daniel P. Berrangé wrote: > Libvirt provides QMP passthrough APIs for the QEMU driver and these are > exposed in virsh. It is not especially pleasant, however, using the raw > QMP JSON syntax. QEMU has a tool 'qmp-shell' which can speak QMP and > exposes a human friendly interactive shell. It is not possible to use > this with libvirt managed guest, however, since only one client can > attach to he QMP socket at any point in time. > > The virt-qmp-proxy tool aims to solve this problem. It opens a UNIX > socket and listens for incoming client connections, speaking QMP on > the connected socket. It will forward any QMP commands received onto > the running libvirt QEMU guest, and forward any replies back to the > QMP client. > > $ virsh start demo > $ virt-qmp-proxy demo demo.qmp & > $ qmp-shell demo.qmp > Welcome to the QMP low-level shell! > Connected to QEMU 6.2.0 > > (QEMU) query-kvm > { > "return": { > "enabled": true, > "present": true > } > } > > Note this tool of course has the same risks as the raw libvirt > QMP passthrough. It is safe to run query commands to fetch information > but commands which change the QEMU state risk disrupting libvirt's > management of QEMU, potentially resulting in data loss/corruption in > the worst case. > > Signed-off-by: Daniel P. Berrangé > --- > > CC'ing QEMU since this is likely of interest to maintainers and users > who work with QEMU and libvirt > > Note this impl is fairly crude in that it assumes it is receiving > the QMP commands linewise one at a time. None the less it is good > enough to work with qmp-shell already, so I figured it was worth > exposing to the world. It also lacks support for forwarding events > back to the QMP client. I originally wanted to teach the qemu tools to work with libvirt directly similarly how 'scripts/render_block_graph.py' from the qemu tree already does but I guess this is also an option. This is an option too albeit a bit more complex to set up, but on the other hand a bit more universal. I'll have a look at the code a bit later.