From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 631C5C433E0 for ; Thu, 14 Jan 2021 15:27:40 +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 0B11923A5F for ; Thu, 14 Jan 2021 15:27:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B11923A5F 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]:56924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l04XC-0007YF-UX for qemu-devel@archiver.kernel.org; Thu, 14 Jan 2021 10:27:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l04Su-0003Hh-2x for qemu-devel@nongnu.org; Thu, 14 Jan 2021 10:23:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l04Sq-0001HC-FO for qemu-devel@nongnu.org; Thu, 14 Jan 2021 10:23:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610637786; h=from:from:reply-to: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=ckzGadjxvM/6T4r6bglv8AE5jA4P2i1e9YeE8xB6gUg=; b=OkISEYMsWaQhred+0KL7gTTfNPuS1ibzvkbfBzxGXFtFKm39O8M8XzSwtmrcj8/ywzD1U3 Adcj82l6KuU6yJU6ISzlwY4exQvABMJ8WpVe9yAr2qJbVHjnj+HVTa9fq3B/ftZdBJDwAB CWjCyY2lLQ7iqS95YoEPiCUlkzZBSls= 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-48-pnpP4bWtMUqvwfu7OeUvsg-1; Thu, 14 Jan 2021 10:22:55 -0500 X-MC-Unique: pnpP4bWtMUqvwfu7OeUvsg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE9EE107ACF8; Thu, 14 Jan 2021 15:22:54 +0000 (UTC) Received: from redhat.com (ovpn-115-77.ams2.redhat.com [10.36.115.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29D0F5D9E2; Thu, 14 Jan 2021 15:22:44 +0000 (UTC) Date: Thu, 14 Jan 2021 15:22:41 +0000 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= To: Kevin Wolf Subject: Re: qmp-shell TUI (was: Re: Call for Google Summer of Code 2021 project ideas) Message-ID: <20210114152241.GK1643043@redhat.com> References: <92903d8d-24c4-5177-67c9-1690ea794739@redhat.com> <20210114135234.GC292902@stefanha-x1.localdomain> <20210114135942.GI1643043@redhat.com> <20210114150256.GE6058@merkur.fritz.box> MIME-Version: 1.0 In-Reply-To: <20210114150256.GE6058@merkur.fritz.box> User-Agent: Mutt/1.14.6 (2020-07-11) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@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.248, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= Cc: Eduardo Habkost , libvir-list@redhat.com, Stefan Hajnoczi , QEMU Developers , Stefan Hajnoczi , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Thu, Jan 14, 2021 at 04:02:56PM +0100, Kevin Wolf wrote: > Am 14.01.2021 um 14:59 hat Daniel P. Berrangé geschrieben: > > On Thu, Jan 14, 2021 at 01:52:34PM +0000, Stefan Hajnoczi wrote: > > > On Wed, Jan 13, 2021 at 01:59:43PM -0500, John Snow wrote: > > > > On 1/13/21 3:53 AM, Stefan Hajnoczi wrote: > > > > > On Tue, Jan 12, 2021 at 9:10 PM John Snow wrote: > > > > > 2. Ability to watch QMP activity on a running QEMU process, e.g. even > > > > > when libvirt is directly connected to the monitor. > > > > > > > > > > > > > That *WOULD* be extremely cool, and moves a lot closer to how mitmproxy > > > > works. > > > > > > > > (Actually, mitmproxy could theoretically be taught how to read and > > > > understand QMP traffic, but that's not something I know how to do or would > > > > be prepared to mentor.) > > > > > > > > Is this possible to do in a post-hoc fashion? Let's say you are using > > > > production environment QEMU, how do we attach the QMP listener to it? Or > > > > does this idea require that we start QEMU in a specific fashion with a > > > > second debug socket that qmp-shell can connect to in order to listen? > > > > > > > > ... Or do we engineer qmp-shell to open its own socket that libvirt connects > > > > to ...? > > > > > > Here is the QEMU command-line that libvirt uses on my F33 system: > > > > > > -chardev socket,id=charmonitor,fd=36,server,nowait > > > -mon chardev=charmonitor,id=monitor,mode=control > > > > > > Goals for this feature: > > > > > > 1. No manual steps required for setup. > > > 2. Ability to start/stop monitoring traffic at runtime without > > > restarting QEMU. > > > 3. Available to unprivileged users. > > > > > > I think the easiest way to achieve this is through a new QEMU monitor > > > command. Approaches that come to mind: > > > > > > 1. Add a -mon debug-chardev property and a QMP command to set it at > > > runtime. The debug-chardev receives both monitor input (commands) and > > > output (responses and events). This does not allow MITM, rather it > > > mirrors traffic. > > > > > > 2. Add a chardev-get-fd command that fetches the fd from a chardev and > > > then use the existing chardev-change command to replace the monitor > > > chardev with a chardev connected to qmp-shell. This inserts qmp-shell > > > as a proxy between the QMP client and server. qmp-shell can remove > > > itself again with another chardev-change command. This approach > > > allows MITM. The downside is it assumes the QMP chardev is a file > > > descriptor, so it won't work with all types of chardev. > > > > > > 3. Add a new chardev-proxy type that aggregates 3 chardevs: 1. an origin > > > source chardev, 2. a monitoring sink chardev, and 3. a monitoring > > > source chardev. The data flow is origin <-> monitoring sink <-> > > > monitoring source <-> QMP monitor. qmp-shell creates the monitoring > > > sink (for receiving incoming QMP commands) and monitoring source > > > chardev (for forwarding QMP commands or MITM commands), and then it > > > uses change-chardev to instantiate a chardev-proxy that directs the > > > original libvirt chardev through the monitoring sink and source. > > > > > > This is the most complex but also completely contained within the > > > QEMU chardev layer. > > I have an idea for the QMP command name: chardev-snapshot-sync! > > Finally we get backing file chains for chardevs! :-) > > > > In all these approaches qmp-shell uses virsh qemu-monitor-command or an > > > equivalent API to start/stop monitoring a running VM without manual > > > setup steps. > > > > Why go to the trouble of adding more chardevs to a running QEMU that > > libvirt has. qmp-shell can just directly use the libvirt Python API > > to invoke virDomainQemuMonitorCommand to invoke QMP commands, and > > the othe API for receiving QMP events. > > > > Essentially it just needs to be split into two layers. The upper > > layer works in terms of individual QMP command/replies, and QMP > > events. The lower layer provides a transport that is either a > > UNIX socket, or is the libvirt QMP passthrough API. > > > > Or alternatively, provide a virt-qmp-shim command that listens on > > a UNIX socket, accepts QMP commands and turns them into calls to > > virDomainQemuMonitorCommand, and funnells back the response. > > I think the idea was to show the QMP traffic that libvirt produces for > other management applications, not for the QMP shell. These APIs > probably don't allow this? FWIW if you want to monitor what libvirt is sending/receiving we have a script for that that uses our systemtap probe points: https://gitlab.com/libvirt/libvirt/-/blob/master/examples/systemtap/qemu-monitor.stp Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|