All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Beraldo Leal <bleal@redhat.com>,
	Qemu-block <qemu-block@nongnu.org>,
	Vladimir Sementsov-Ogievskiy
	<vladimir.sementsov-ogievskiy@openvz.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	Hanna Reitz <hreitz@redhat.com>,
	vsementsov@openvz.org, Cleber Rosa <crosa@redhat.com>
Subject: Re: [PATCH 1/2] python/machine.py: upgrade vm.command() method
Date: Wed, 20 Apr 2022 09:20:02 +0100	[thread overview]
Message-ID: <Yl/CMgN4ITRYVbAy@redhat.com> (raw)
In-Reply-To: <CAFn=p-Ym3_irrG_p8Wb5bmw9SQ3AOy+fAXMP3Qwm-uMLZVJwOA@mail.gmail.com>

On Tue, Apr 19, 2022 at 01:08:06PM -0400, John Snow wrote:
> On Tue, Apr 19, 2022, 12:42 PM Daniel P. Berrangé <berrange@redhat.com>
> wrote:
> 
> > On Fri, Apr 08, 2022 at 08:02:13PM +0300, Vladimir Sementsov-Ogievskiy
> > wrote:
> > > The method is not popular, we prefer use vm.qmp() and then check
> > > success by hand.. But that's not optimal. To simplify movement to
> > > vm.command() support same interface improvements like in vm.qmp() and
> > > rename to shorter vm.cmd().
> > >
> > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
> > > ---
> > >  python/qemu/machine/machine.py | 16 ++++++++++++---
> > >  tests/qemu-iotests/256         | 34 ++++++++++++++++----------------
> > >  tests/qemu-iotests/257         | 36 +++++++++++++++++-----------------
> > >  3 files changed, 48 insertions(+), 38 deletions(-)
> > >
> > > diff --git a/python/qemu/machine/machine.py
> > b/python/qemu/machine/machine.py
> > > index 07ac5a710b..a3fb840b93 100644
> > > --- a/python/qemu/machine/machine.py
> > > +++ b/python/qemu/machine/machine.py
> > > @@ -648,14 +648,24 @@ def qmp(self, cmd: str,
> > >              self._quit_issued = True
> > >          return ret
> > >
> > > -    def command(self, cmd: str,
> > > -                conv_keys: bool = True,
> > > -                **args: Any) -> QMPReturnValue:
> > > +    def cmd(self, cmd: str,
> >
> > FYI, the original 'command' name matches semantics of 'command'
> > in the QEMUMonitorProtocol class.  The QEMUMonitorProtocol
> > class has a 'cmd' method that matches semantics of 'qmp' in
> > QEMUMachine.
> >
> > I think it is desirable to have consistency between naming in
> > the two classes.
> >
> 
> Broadly agree.
> 
> 
> > The current use of both 'cmd' and 'command' in QEMUMonitorProtocol
> > is horrible naming though. How is anyone supposed to remember which
> > name raises the exception and which doesn't ? Urgh.
> >
> 
> Also agree.
> 
> 
> > I agree with your desire to simplify things, but if anything I would
> > suggest we change both QEMUMonitorProtocol and QEMUMachine to have a
> > convention more like python's subprocess module:
> >
> >  - 'cmd' runs without error checking, just returning the
> >    reply data as is
> >
> >  - 'check_cmd' calls 'cmd' but raises an exception on error.
> >
> 
> Not sure I'm on board here, though.
> 
> For what it's worth, in async qmp I added a single method "execute()",
> mimicking the name of the field used over the wire. It uses semantics like
> command() here, in that it raises an exception on error and returns only
> the response data and not the entire QMP response.
> 
> I'm in favor of, broadly, an approach wherein the default behavior raises
> an exception and the caller must opt-in to squelch it; either via
> try-except or a check=False argument. It should be a conscious decision.

I'd be happy with a single 'cmd' method with 'check=False' to turn
off exceptions on demand.

With 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 :|



  reply	other threads:[~2022-04-20  8:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08 17:02 [RFC 0/2] introduce QEMUMachind.cmd() Vladimir Sementsov-Ogievskiy
2022-04-08 17:02 ` [PATCH 1/2] python/machine.py: upgrade vm.command() method Vladimir Sementsov-Ogievskiy
2022-04-19 16:42   ` Daniel P. Berrangé
2022-04-19 17:08     ` John Snow
2022-04-20  8:20       ` Daniel P. Berrangé [this message]
2022-05-26 14:30   ` Vladimir Sementsov-Ogievskiy
2022-05-26 14:55     ` John Snow
2022-04-08 17:02 ` [PATCH 2/2] iotests: use vm.cmd() instead of vm.qmp() where appropriate Vladimir Sementsov-Ogievskiy
2022-05-18 12:46   ` Eric Blake
2022-04-27 19:29 ` [RFC 0/2] introduce QEMUMachind.cmd() John Snow
2022-05-17 11:22   ` Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yl/CMgN4ITRYVbAy@redhat.com \
    --to=berrange@redhat.com \
    --cc=bleal@redhat.com \
    --cc=crosa@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vladimir.sementsov-ogievskiy@openvz.org \
    --cc=vsementsov@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.