xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: xen-devel@lists.xenproject.org, Ian Jackson <ian.jackson@eu.citrix.com>
Subject: Re: [PATCH 1/2] libxl: Add a version check of QEMU for QMP commands
Date: Tue, 13 Mar 2018 17:49:44 +0000	[thread overview]
Message-ID: <20180313174944.GS1921@perard.uk.xensource.com> (raw)
In-Reply-To: <20180313174008.2tb6xmk2i52yg4lc@citrix.com>

On Tue, Mar 13, 2018 at 05:40:08PM +0000, Wei Liu wrote:
> On Tue, Mar 13, 2018 at 11:13:17AM +0000, Anthony PERARD wrote:
> > On connection to QEMU via QMP, the version of QEMU is provided, store it
> > for later use.
> > 
> > Add a function qmp_qemu_check_version that can be used to check if QEMU
> > is new enough for certain fonctionnality. This will be used in a moment.
> > 
> > As it's a static function, it is commented out until first use, which is
> > in the next patch.
> > 
> > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> > ---
> >  tools/libxl/libxl_qmp.c | 31 ++++++++++++++++++++++++++++++-
> >  1 file changed, 30 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
> > index eab993aca9..b1c6598cf7 100644
> > --- a/tools/libxl/libxl_qmp.c
> > +++ b/tools/libxl/libxl_qmp.c
> > @@ -75,6 +75,11 @@ struct libxl__qmp_handler {
> >  
> >      int last_id_used;
> >      LIBXL_STAILQ_HEAD(callback_list, callback_id_pair) callback_list;
> > +    struct {
> > +        int major;
> > +        int minor;
> > +        int micro;
> > +    } version;
> >  };
> >  
> >  static int qmp_send(libxl__qmp_handler *qmp,
> > @@ -296,9 +301,22 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp,
> >      LOGD(DEBUG, qmp->domid, "message type: %s", libxl__qmp_message_type_to_string(type));
> >  
> >      switch (type) {
> > -    case LIBXL__QMP_MESSAGE_TYPE_QMP:
> > +    case LIBXL__QMP_MESSAGE_TYPE_QMP: {
> > +        const libxl__json_object *o;
> > +        o = libxl__json_map_get("QMP", resp, JSON_MAP);
> > +        o = libxl__json_map_get("version", o, JSON_MAP);
> > +        o = libxl__json_map_get("qemu", o, JSON_MAP);
> > +        qmp->version.major = libxl__json_object_get_integer(
> > +            libxl__json_map_get("major", o, JSON_INTEGER));
> > +        qmp->version.minor = libxl__json_object_get_integer(
> > +            libxl__json_map_get("minor", o, JSON_INTEGER));
> > +        qmp->version.micro = libxl__json_object_get_integer(
> > +            libxl__json_map_get("micro", o, JSON_INTEGER));
> > +        LOGD(DEBUG, qmp->domid, "QEMU version: %d.%d.%d",
> > +             qmp->version.major, qmp->version.minor, qmp->version.micro);
> >          /* On the greeting message from the server, enable QMP capabilities */
> >          return enable_qmp_capabilities(qmp);
> > +    }
> 
> Are those fields available in QMP in all the versions we care about?

I don't care if the field is available or not, the result would be a
QEMU version -1.-1.-1 This is why I did not do any check here to find
out if a particular value exist.  But the version field is part of the
QMP protocol, so it should be there.

Also yes, the field is available in all QEMU version we care about, e.i.
QEMU 2.11 and later. That information is not usefull for older version
of QEMU.

> If so, 
> 
> Acked-by: Wei Liu <wei.liu2@citrix.com>

Thanks,

-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-03-13 17:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-13 11:13 [PATCH 0/2] libxl: Update of QMP xen-save-devices-state Anthony PERARD
2018-03-13 11:13 ` [PATCH 1/2] libxl: Add a version check of QEMU for QMP commands Anthony PERARD
2018-03-13 17:40   ` Wei Liu
2018-03-13 17:49     ` Anthony PERARD [this message]
2018-03-13 17:56       ` Wei Liu
2018-03-13 11:13 ` [PATCH 2/2] libxl_qmp: Tell QEMU about live migration or snapshot Anthony PERARD
2018-03-13 17:42   ` Wei Liu

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=20180313174944.GS1921@perard.uk.xensource.com \
    --to=anthony.perard@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).