On Tue, Mar 13, 2018 at 05:49:44PM +0000, Anthony PERARD wrote:
> 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.per...@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.

OK that's fine.

Wei.

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

Reply via email to