Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-27 Thread Markus Armbruster
Daniel P. Berrange berra...@redhat.com writes:

 On Wed, Jul 25, 2012 at 02:47:57PM -0500, Anthony Liguori wrote:
 The help output is going to change dramatically for 0.13.  We've
 spent too long
 waiting for a perfect solution to capabilities handling and the end loser is
 the direct consumer of QEMU because the help output is awful.
 
 I will not apply any patches that change help output until 0.13 development
 opens up.  This should give libvirt adequate time to implement support for
 dealing with this new option.

 I completely agree with this. We have spent far too long making do with
 help output and its about time we finish with this once  for all.
 I'm assuming you mean the 1.3 release here. If so I'll agree that it
 is an acceptable plan to change help output at the start of the 1.3
 release.

 This gives us enough time to agree on what todo to support apps needing
 to query QEMU.

 This capabilities set comes directly from libvirt's source code so
 it's entirely
 adequate for libvirt's purposes.  We can still explore more sophisticated
 approaches that are more general purpose but the help output will be 
 changing.

 While I appreciate what you're trying todo here, I think this would be a
 serious mistake on many counts, and even be incorrect in some ways.

  - It ignores the needs of other apps using QEMU. In particular Richard
Jones has frequently requested a way to detect QEMU capabilities
to satisfy libguestfs. I think it is unreasonable to expect libguestfs
to use the libvirt capabilities described here. Likewise other apps

  - This is just a point in time snapshot of what libvirt currently uses
from QEMU. If, for example, someone provided a patch to libvirt to
support the bluetooth devices we'd be stuck, because although QEMU
already supports bluetooth, this is not expressed in any of the
caps libvirt already has.

  - Not all of this information actually comes from the help output.
A bunch of it is stuff we detect from '-device ?' and
'-device name,?'. Although, (AFAIR) no one has objections to use
parsing the -device output because it is much better defined 
stable than -help, I think we could use some improvement to make
the parsing 100% long term maintainable by QEMU/apps. Similarly
we do  '-cpu ?' and '-machine ?'.  Some of the caps are set based
on the machine architecture, or QEMU version.

  - Some of the caps are set based on what libvirt is actually
able to handle from a command line generation POV, so having
QEMU report these unconditionally is misleading/wrong. It is
not about what QEMU supports, it is about what libvirt is able
to cope with.

  - In the future some of the caps may be describing supported
monitor commands, detected via 'query-commands' QMP cmd.

  - Users of libvirt are asking us to expose information about
what QEMU supports, in particular wrt to devices, but also
other aspects of configuration.



 A long time back I proposed a '-capabilities' command line argument
 for querying QEMU.

   https://lists.gnu.org/archive/html/qemu-devel/2010-06/msg00921.html

 There was a long discussion about this  many aspects of it were
 disliked. In retrospect I agree with many of the comments, and
 am glad we didn't adopt this. I think, however, there is a merit
 in trying something vaguely related again, but with some key
 differences. Basically I'd sum up my new idea as just use QMP.


  * No new command line arguments like -capabilities

  * libvirt invokes something like

  $QEMUBINARY -qmp CHARDEV -nodefault -nodefconfig -nographics

  * libvirt then runs a number of  QMP commands to find out
what it needs to know. I'd expect the following existing
commands would be used

  - query-version - already supported
  - query-commands- already supported
  - query-events  - already supported
  - query-kvm - already supported
  - qom-{list,list-types,get} - already supported
  - query-spice/vnc   - already supported

And add the following new commands

  - query-devices - new, -device ?, and/or -device NAME,? data 
 in QMP
  - query-machines- new, -M ? in QMP
  - query-cpu-types   - new, -cpu ? in QMP

 The above would take care of probably 50% of the current libvirt
 capabilities probing, including a portion of the -help stuff. Then
 there is all the rest of the crap we detect from the -help. We could
 just take the view, that as of 1.2, we assume everything we previously
 detected is just available by default, and thus don't need to probe
 it.  For stuff that is QOM based, I expect we'll be able to detect new
 features in the future using the qom-XXX monitor commands. For stuff
 that is non-qdev, and non-qom, libvirt can just do a plain version
 number check, unless we decide there is specific info worth exposing
 via other new 'query-XXX' monitor 

Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-27 Thread Daniel P. Berrange
On Fri, Jul 27, 2012 at 01:23:03PM +0200, Markus Armbruster wrote:
 
 Assuming version X (according to query-version) supports no less than
 upstream version X sounds fair.
 
 If a command line option has a corresponding QMP command, probing QMP
 for the feature suffices.  For instance, query-devices gives you devices
 for -device.
 
 I'm afraid there could still be an occasional need for probing the
 command line.  A simple, machine-readable command line self-description
 could satisfy it.  Something like:
 
 - query-cmdline-options: JSON representation of qemu_options[], with
   unnecessary detail elided.  Basically option name and whether it takes
   an argument.
 
 For options with a QemuOpts argument, we may want to add argument
 self-description.  Basically its QemuOptsList, with unnecessary detail
 elided.  Non-QemuOpts arguments don't get that.  New structured option
 arguments should use QemuOpts anyway.
 
 Some users might prefer to get this via a command line option rather
 than a QMP command.  They should ask for it.

In my original proposal from 2 years back, I actually exposed a number
of QMP query-XXX commands via a -capabilities  command line args.
On revisiting it though, I think that since we'll want to ask for
info on many different aspects, it is easier just to use QMP directly
rather than string together various command line args upfront, or
invoke QEMU multiple times.

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-27 Thread Markus Armbruster
Daniel P. Berrange berra...@redhat.com writes:

 On Fri, Jul 27, 2012 at 01:23:03PM +0200, Markus Armbruster wrote:
 
 Assuming version X (according to query-version) supports no less than
 upstream version X sounds fair.
 
 If a command line option has a corresponding QMP command, probing QMP
 for the feature suffices.  For instance, query-devices gives you devices
 for -device.
 
 I'm afraid there could still be an occasional need for probing the
 command line.  A simple, machine-readable command line self-description
 could satisfy it.  Something like:
 
 - query-cmdline-options: JSON representation of qemu_options[], with
   unnecessary detail elided.  Basically option name and whether it takes
   an argument.
 
 For options with a QemuOpts argument, we may want to add argument
 self-description.  Basically its QemuOptsList, with unnecessary detail
 elided.  Non-QemuOpts arguments don't get that.  New structured option
 arguments should use QemuOpts anyway.
 
 Some users might prefer to get this via a command line option rather
 than a QMP command.  They should ask for it.

 In my original proposal from 2 years back, I actually exposed a number
 of QMP query-XXX commands via a -capabilities  command line args.
 On revisiting it though, I think that since we'll want to ask for
 info on many different aspects, it is easier just to use QMP directly
 rather than string together various command line args upfront, or
 invoke QEMU multiple times.

I read that as libvirt isn't asking for it.  That's fine.  Whoever
wants it needs to ask.



Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-27 Thread Anthony Liguori
Paolo Bonzini pbonz...@redhat.com writes:

 Il 26/07/2012 16:10, Anthony Liguori ha scritto:
 Yup.
 
 You could do:
 
 qom-list-types implements=TYPE_DEVICE
 
 And that will give you the various types.  We'll need to add a:
 
 device-list-properties typename=FOO
 
 I've got a patch locally for that that I'm testing right now.  Paolo and
 I never came to an agreement on how to do this generically for Objects
 but I'm happy with a device-specific interface for the short term.

 I don't like the idea of using object_new, but it obviously works at
 least for now, so go ahead and call it qom-type-list-properties.

My patch doesn't use object_new() to do it.  It uses static properties.
I'm going to try to push static properties to object.  If I can do that
before 1.2, I'll rename this function to qom-type-list-properties.

Regards,

Anthony Liguori


 Paolo




Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-27 Thread Paolo Bonzini
Il 26/07/2012 16:10, Anthony Liguori ha scritto:
 Yup.
 
 You could do:
 
 qom-list-types implements=TYPE_DEVICE
 
 And that will give you the various types.  We'll need to add a:
 
 device-list-properties typename=FOO
 
 I've got a patch locally for that that I'm testing right now.  Paolo and
 I never came to an agreement on how to do this generically for Objects
 but I'm happy with a device-specific interface for the short term.

I don't like the idea of using object_new, but it obviously works at
least for now, so go ahead and call it qom-type-list-properties.

Paolo




Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-27 Thread Daniel P. Berrange
On Fri, Jul 27, 2012 at 01:23:03PM +0200, Markus Armbruster wrote:
 Daniel P. Berrange berra...@redhat.com writes:
  The above would take care of probably 50% of the current libvirt
  capabilities probing, including a portion of the -help stuff. Then
  there is all the rest of the crap we detect from the -help. We could
  just take the view, that as of 1.2, we assume everything we previously
  detected is just available by default, and thus don't need to probe
  it.  For stuff that is QOM based, I expect we'll be able to detect new
  features in the future using the qom-XXX monitor commands. For stuff
  that is non-qdev, and non-qom, libvirt can just do a plain version
  number check, unless we decide there is specific info worth exposing
  via other new 'query-XXX' monitor commands.
 
 Assuming version X (according to query-version) supports no less than
 upstream version X sounds fair.
 
 If a command line option has a corresponding QMP command, probing QMP
 for the feature suffices.  For instance, query-devices gives you devices
 for -device.
 
 I'm afraid there could still be an occasional need for probing the
 command line.  A simple, machine-readable command line self-description
 could satisfy it.  Something like:
 
 - query-cmdline-options: JSON representation of qemu_options[], with
   unnecessary detail elided.  Basically option name and whether it takes
   an argument.
 
 For options with a QemuOpts argument, we may want to add argument
 self-description.  Basically its QemuOptsList, with unnecessary detail
 elided.  Non-QemuOpts arguments don't get that.  New structured option
 arguments should use QemuOpts anyway.

I think you are quite possibly correct, but for the sake of enabling
us to move forward without more arguments, my inclination is to ignore
this just now :-) Lets get the new commands Anthony posted merged, and
port libvirt to use this new approach. Once that's all done, we can
evaluate whether there is a any more information we ought to provide
which might require a query-cmdline-options, or something else more
targetted (eg query-chardev-options or something)


Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-27 Thread Markus Armbruster
Daniel P. Berrange berra...@redhat.com writes:

 On Fri, Jul 27, 2012 at 01:23:03PM +0200, Markus Armbruster wrote:
 Daniel P. Berrange berra...@redhat.com writes:
  The above would take care of probably 50% of the current libvirt
  capabilities probing, including a portion of the -help stuff. Then
  there is all the rest of the crap we detect from the -help. We could
  just take the view, that as of 1.2, we assume everything we previously
  detected is just available by default, and thus don't need to probe
  it.  For stuff that is QOM based, I expect we'll be able to detect new
  features in the future using the qom-XXX monitor commands. For stuff
  that is non-qdev, and non-qom, libvirt can just do a plain version
  number check, unless we decide there is specific info worth exposing
  via other new 'query-XXX' monitor commands.
 
 Assuming version X (according to query-version) supports no less than
 upstream version X sounds fair.
 
 If a command line option has a corresponding QMP command, probing QMP
 for the feature suffices.  For instance, query-devices gives you devices
 for -device.
 
 I'm afraid there could still be an occasional need for probing the
 command line.  A simple, machine-readable command line self-description
 could satisfy it.  Something like:
 
 - query-cmdline-options: JSON representation of qemu_options[], with
   unnecessary detail elided.  Basically option name and whether it takes
   an argument.
 
 For options with a QemuOpts argument, we may want to add argument
 self-description.  Basically its QemuOptsList, with unnecessary detail
 elided.  Non-QemuOpts arguments don't get that.  New structured option
 arguments should use QemuOpts anyway.

 I think you are quite possibly correct, but for the sake of enabling
 us to move forward without more arguments, my inclination is to ignore
 this just now :-) Lets get the new commands Anthony posted merged, and
 port libvirt to use this new approach. Once that's all done, we can
 evaluate whether there is a any more information we ought to provide
 which might require a query-cmdline-options, or something else more
 targetted (eg query-chardev-options or something)

I certainly don't mean to slow down the move forward.  And requiring a
real use case before accepting a feature makes sense anyway.



Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-26 Thread Daniel P. Berrange
On Wed, Jul 25, 2012 at 02:47:57PM -0500, Anthony Liguori wrote:
 The help output is going to change dramatically for 0.13.  We've spent too 
 long
 waiting for a perfect solution to capabilities handling and the end loser is
 the direct consumer of QEMU because the help output is awful.
 
 I will not apply any patches that change help output until 0.13 development
 opens up.  This should give libvirt adequate time to implement support for
 dealing with this new option.

I completely agree with this. We have spent far too long making do with
help output and its about time we finish with this once  for all.
I'm assuming you mean the 1.3 release here. If so I'll agree that it
is an acceptable plan to change help output at the start of the 1.3
release.

This gives us enough time to agree on what todo to support apps needing
to query QEMU.

 This capabilities set comes directly from libvirt's source code so it's 
 entirely
 adequate for libvirt's purposes.  We can still explore more sophisticated
 approaches that are more general purpose but the help output will be changing.

While I appreciate what you're trying todo here, I think this would be a
serious mistake on many counts, and even be incorrect in some ways.

 - It ignores the needs of other apps using QEMU. In particular Richard
   Jones has frequently requested a way to detect QEMU capabilities
   to satisfy libguestfs. I think it is unreasonable to expect libguestfs
   to use the libvirt capabilities described here. Likewise other apps

 - This is just a point in time snapshot of what libvirt currently uses
   from QEMU. If, for example, someone provided a patch to libvirt to
   support the bluetooth devices we'd be stuck, because although QEMU
   already supports bluetooth, this is not expressed in any of the
   caps libvirt already has.

 - Not all of this information actually comes from the help output.
   A bunch of it is stuff we detect from '-device ?' and
   '-device name,?'. Although, (AFAIR) no one has objections to use
   parsing the -device output because it is much better defined 
   stable than -help, I think we could use some improvement to make
   the parsing 100% long term maintainable by QEMU/apps. Similarly
   we do  '-cpu ?' and '-machine ?'.  Some of the caps are set based
   on the machine architecture, or QEMU version.

 - Some of the caps are set based on what libvirt is actually
   able to handle from a command line generation POV, so having
   QEMU report these unconditionally is misleading/wrong. It is
   not about what QEMU supports, it is about what libvirt is able
   to cope with.

 - In the future some of the caps may be describing supported
   monitor commands, detected via 'query-commands' QMP cmd.

 - Users of libvirt are asking us to expose information about
   what QEMU supports, in particular wrt to devices, but also
   other aspects of configuration.



A long time back I proposed a '-capabilities' command line argument
for querying QEMU.

  https://lists.gnu.org/archive/html/qemu-devel/2010-06/msg00921.html

There was a long discussion about this  many aspects of it were
disliked. In retrospect I agree with many of the comments, and
am glad we didn't adopt this. I think, however, there is a merit
in trying something vaguely related again, but with some key
differences. Basically I'd sum up my new idea as just use QMP.


 * No new command line arguments like -capabilities

 * libvirt invokes something like

 $QEMUBINARY -qmp CHARDEV -nodefault -nodefconfig -nographics

 * libvirt then runs a number of  QMP commands to find out
   what it needs to know. I'd expect the following existing
   commands would be used

 - query-version - already supported
 - query-commands- already supported
 - query-events  - already supported
 - query-kvm - already supported
 - qom-{list,list-types,get} - already supported
 - query-spice/vnc   - already supported

   And add the following new commands

 - query-devices - new, -device ?, and/or -device NAME,? data 
in QMP
 - query-machines- new, -M ? in QMP
 - query-cpu-types   - new, -cpu ? in QMP

The above would take care of probably 50% of the current libvirt
capabilities probing, including a portion of the -help stuff. Then
there is all the rest of the crap we detect from the -help. We could
just take the view, that as of 1.2, we assume everything we previously
detected is just available by default, and thus don't need to probe
it.  For stuff that is QOM based, I expect we'll be able to detect new
features in the future using the qom-XXX monitor commands. For stuff
that is non-qdev, and non-qom, libvirt can just do a plain version
number check, unless we decide there is specific info worth exposing
via other new 'query-XXX' monitor commands.

So in summary, as of 1.2 QEMU, libvirt would

  - Remove all use of -help, and other - command line args
   

Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-26 Thread Daniel P. Berrange
On Thu, Jul 26, 2012 at 01:47:23PM +0100, Daniel P. Berrange wrote:
 On Wed, Jul 25, 2012 at 02:47:57PM -0500, Anthony Liguori wrote:
  The help output is going to change dramatically for 0.13.  We've spent too 
  long
  waiting for a perfect solution to capabilities handling and the end loser is
  the direct consumer of QEMU because the help output is awful.
  
  I will not apply any patches that change help output until 0.13 development
  opens up.  This should give libvirt adequate time to implement support for
  dealing with this new option.
 
 I completely agree with this. We have spent far too long making do with
 help output and its about time we finish with this once  for all.
 I'm assuming you mean the 1.3 release here. If so I'll agree that it
 is an acceptable plan to change help output at the start of the 1.3
 release.
 
 This gives us enough time to agree on what todo to support apps needing
 to query QEMU.
 
  This capabilities set comes directly from libvirt's source code so it's 
  entirely
  adequate for libvirt's purposes.  We can still explore more sophisticated
  approaches that are more general purpose but the help output will be 
  changing.
 
 While I appreciate what you're trying todo here, I think this would be a
 serious mistake on many counts, and even be incorrect in some ways.
 
  - It ignores the needs of other apps using QEMU. In particular Richard
Jones has frequently requested a way to detect QEMU capabilities
to satisfy libguestfs. I think it is unreasonable to expect libguestfs
to use the libvirt capabilities described here. Likewise other apps
 
  - This is just a point in time snapshot of what libvirt currently uses
from QEMU. If, for example, someone provided a patch to libvirt to
support the bluetooth devices we'd be stuck, because although QEMU
already supports bluetooth, this is not expressed in any of the
caps libvirt already has.
 
  - Not all of this information actually comes from the help output.
A bunch of it is stuff we detect from '-device ?' and
'-device name,?'. Although, (AFAIR) no one has objections to use
parsing the -device output because it is much better defined 
stable than -help, I think we could use some improvement to make
the parsing 100% long term maintainable by QEMU/apps. Similarly
we do  '-cpu ?' and '-machine ?'.  Some of the caps are set based
on the machine architecture, or QEMU version.
 
  - Some of the caps are set based on what libvirt is actually
able to handle from a command line generation POV, so having
QEMU report these unconditionally is misleading/wrong. It is
not about what QEMU supports, it is about what libvirt is able
to cope with.
 
  - In the future some of the caps may be describing supported
monitor commands, detected via 'query-commands' QMP cmd.
 
  - Users of libvirt are asking us to expose information about
what QEMU supports, in particular wrt to devices, but also
other aspects of configuration.
 
 
 
 A long time back I proposed a '-capabilities' command line argument
 for querying QEMU.
 
   https://lists.gnu.org/archive/html/qemu-devel/2010-06/msg00921.html
 
 There was a long discussion about this  many aspects of it were
 disliked. In retrospect I agree with many of the comments, and
 am glad we didn't adopt this. I think, however, there is a merit
 in trying something vaguely related again, but with some key
 differences. Basically I'd sum up my new idea as just use QMP.
 
 
  * No new command line arguments like -capabilities
 
  * libvirt invokes something like
 
  $QEMUBINARY -qmp CHARDEV -nodefault -nodefconfig -nographics
 
  * libvirt then runs a number of  QMP commands to find out
what it needs to know. I'd expect the following existing
commands would be used
 
  - query-version - already supported
  - query-commands- already supported
  - query-events  - already supported
  - query-kvm - already supported
  - qom-{list,list-types,get} - already supported
  - query-spice/vnc   - already supported
 
And add the following new commands
 
  - query-devices - new, -device ?, and/or -device NAME,? data 
 in QMP
  - query-machines- new, -M ? in QMP
  - query-cpu-types   - new, -cpu ? in QMP
 
 The above would take care of probably 50% of the current libvirt
 capabilities probing, including a portion of the -help stuff. Then
 there is all the rest of the crap we detect from the -help. We could
 just take the view, that as of 1.2, we assume everything we previously
 detected is just available by default, and thus don't need to probe
 it.  For stuff that is QOM based, I expect we'll be able to detect new
 features in the future using the qom-XXX monitor commands. For stuff
 that is non-qdev, and non-qom, libvirt can just do a plain version
 number check, unless we decide there is 

Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-26 Thread Anthony Liguori
Daniel P. Berrange berra...@redhat.com writes:

 On Thu, Jul 26, 2012 at 01:47:23PM +0100, Daniel P. Berrange wrote:
 On Wed, Jul 25, 2012 at 02:47:57PM -0500, Anthony Liguori wrote:
  The help output is going to change dramatically for 0.13.  We've spent too 
  long
  waiting for a perfect solution to capabilities handling and the end loser 
  is
  the direct consumer of QEMU because the help output is awful.
  
  I will not apply any patches that change help output until 0.13 development
  opens up.  This should give libvirt adequate time to implement support for
  dealing with this new option.
 
 I completely agree with this. We have spent far too long making do with
 help output and its about time we finish with this once  for all.
 I'm assuming you mean the 1.3 release here. If so I'll agree that it
 is an acceptable plan to change help output at the start of the 1.3
 release.
 
 This gives us enough time to agree on what todo to support apps needing
 to query QEMU.
 
  This capabilities set comes directly from libvirt's source code so it's 
  entirely
  adequate for libvirt's purposes.  We can still explore more sophisticated
  approaches that are more general purpose but the help output will be 
  changing.
 
 While I appreciate what you're trying todo here, I think this would be a
 serious mistake on many counts, and even be incorrect in some ways.
 
  - It ignores the needs of other apps using QEMU. In particular Richard
Jones has frequently requested a way to detect QEMU capabilities
to satisfy libguestfs. I think it is unreasonable to expect libguestfs
to use the libvirt capabilities described here. Likewise other apps
 
  - This is just a point in time snapshot of what libvirt currently uses
from QEMU. If, for example, someone provided a patch to libvirt to
support the bluetooth devices we'd be stuck, because although QEMU
already supports bluetooth, this is not expressed in any of the
caps libvirt already has.
 
  - Not all of this information actually comes from the help output.
A bunch of it is stuff we detect from '-device ?' and
'-device name,?'. Although, (AFAIR) no one has objections to use
parsing the -device output because it is much better defined 
stable than -help, I think we could use some improvement to make
the parsing 100% long term maintainable by QEMU/apps. Similarly
we do  '-cpu ?' and '-machine ?'.  Some of the caps are set based
on the machine architecture, or QEMU version.
 
  - Some of the caps are set based on what libvirt is actually
able to handle from a command line generation POV, so having
QEMU report these unconditionally is misleading/wrong. It is
not about what QEMU supports, it is about what libvirt is able
to cope with.
 
  - In the future some of the caps may be describing supported
monitor commands, detected via 'query-commands' QMP cmd.
 
  - Users of libvirt are asking us to expose information about
what QEMU supports, in particular wrt to devices, but also
other aspects of configuration.
 
 
 
 A long time back I proposed a '-capabilities' command line argument
 for querying QEMU.
 
   https://lists.gnu.org/archive/html/qemu-devel/2010-06/msg00921.html
 
 There was a long discussion about this  many aspects of it were
 disliked. In retrospect I agree with many of the comments, and
 am glad we didn't adopt this. I think, however, there is a merit
 in trying something vaguely related again, but with some key
 differences. Basically I'd sum up my new idea as just use QMP.
 
 
  * No new command line arguments like -capabilities
 
  * libvirt invokes something like
 
  $QEMUBINARY -qmp CHARDEV -nodefault -nodefconfig -nographics
 
  * libvirt then runs a number of  QMP commands to find out
what it needs to know. I'd expect the following existing
commands would be used
 
  - query-version - already supported
  - query-commands- already supported
  - query-events  - already supported
  - query-kvm - already supported
  - qom-{list,list-types,get} - already supported
  - query-spice/vnc   - already supported
 
And add the following new commands
 
  - query-devices - new, -device ?, and/or -device NAME,? 
 data in QMP
  - query-machines- new, -M ? in QMP
  - query-cpu-types   - new, -cpu ? in QMP
 
 The above would take care of probably 50% of the current libvirt
 capabilities probing, including a portion of the -help stuff. Then
 there is all the rest of the crap we detect from the -help. We could
 just take the view, that as of 1.2, we assume everything we previously
 detected is just available by default, and thus don't need to probe
 it.  For stuff that is QOM based, I expect we'll be able to detect new
 features in the future using the qom-XXX monitor commands. For stuff
 that is non-qdev, and non-qom, libvirt can just do a plain 

Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-25 Thread Eric Blake
[adding libvirt]

On 07/25/2012 01:47 PM, Anthony Liguori wrote:
 The help output is going to change dramatically for 0.13.  We've spent too 
 long

0.13?  How long have you been sitting on this commit? :)

 waiting for a perfect solution to capabilities handling and the end loser is
 the direct consumer of QEMU because the help output is awful.
 
 I will not apply any patches that change help output until 0.13 development
 opens up.  This should give libvirt adequate time to implement support for
 dealing with this new option.
 
 This capabilities set comes directly from libvirt's source code so it's 
 entirely
 adequate for libvirt's purposes.  We can still explore more sophisticated
 approaches that are more general purpose but the help output will be changing.

We've gone a long way with things like newer libvirt requiring QMP, and
being able to use query-commands and even 'qemu -device ?' to figure out
which devices are present, which is already more reliable than parsing
-help output.  There may still be a few things to fix (for example, I
already pointed out that libvirt 0.9.13 is bogus for refusing to even
attempt 'qemu -device,?' unless it guesses from '-help' output that it
will work; it would be better to just attempt it in the first place and
deal with the fallout), but it should be easy to fix in time for libvirt
0.10.0, and certainly coordinate things so that new enough libvirt comes
out close to the time of qemu 1.2.

 +++ b/libvirt-caps.c
 @@ -0,0 +1,166 @@
 +/*
 + * Libvirt capabilities
 + *
 + * Copyright IBM, Corp. 2012
 + *
 + * Authors:
 + *  Anthony Liguori   aligu...@us.ibm.com
 + *
 + * This work is licensed under the terms of the GNU GPL, version 2 or later.
 + * See the COPYING file in the top-level directory.
 + *
 + */
 +
 +#include libvirt-caps.h
 +#include qemu-common.h
 +
 +/* Make sure this stays in sync with libvirt/src/qemu/qemu_capabilities.c */

This is the part I'm most worried about - it says that any time libvirt
decides to flag a new capability that it cares about within qemu, then
both libvirt and qemu have to be upgraded in lockstep to coordinate the
use of that capability.  The problem is that sometimes libvirt doesn't
care about a capability until after qemu has already been released (for
example, we didn't realize the power of fd: migration until several
releases after qemu had first implemented it, at which point when we
added the capability bit, we were able to retroactively detect it for
several qemu versions by parsing -help).

 +
 +static const char *supported_caps[] = {
 +//kqemu,
 +vnc-colon,
 +no-reboot,
 +drive,
 +drive-boot,
 +
...
 +drive-iotune,
 +system_wakeup,
 +scsi-disk.channel,
 +scsi-block,
 +transaction,
 +
 +NULL

Already incomplete.  For example, libvirt has recently added
block-job-sync, block-job-async, scsi-cd, and several others.
Thankfully, these days most of the new feature bits being added in
libvirt's qemu_capabilities.h are related to things that were probed
from 'qemu -device ?' or from QMP 'query-commands', and not from
something additionally scraped from '-help' for the first time.  I had
to go back to libvirt commit 63b4243 (May 15) to find a capability that
libvirt learned by scraping -help output (namely, support for
-no-user-config).  But yet this is one of the important config bits that
libvirt really needs to know, and not one that can easily be learned
from machine-parseable '-device ?'

I'm worried that an interface like this will let libvirt know about the
existing features that libvirt is trying to use, but will hurt the
ability of adding new feature detection in to libvirt (basically, a
newer libvirt wouldn't be able to retroactively take advantage of an
older feature already present in older qemu without parsing some
back-channel, at which point what good was having this libvirt-specific
channel?).

There's also another problem if we decide to keep this file synced
across projects:

 +++ b/libvirt-caps.h
 @@ -0,0 +1,19 @@
 +/*
 + * Libvirt capabilities
 + *
 + * Copyright IBM, Corp. 2012
 + *
 + * Authors:
 + *  Anthony Liguori   aligu...@us.ibm.com
 + *
 + * This work is licensed under the terms of the GNU GPL, version 2 or later.
 + * See the COPYING file in the top-level directory.

Libvirt is LGPLv2+.  You can obviously upgrade to GPLv2+ as part of
importing the code from libvirt to qemu; but if you decide that a new
feature is worth adding a bit to this file, then libvirt can't do the
reverse sync unless you relax the license of this file.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] vl: add -libvirt-caps option for libvirt to stop parsing help output

2012-07-25 Thread Anthony Liguori
Eric Blake ebl...@redhat.com writes:

 [adding libvirt]

 On 07/25/2012 01:47 PM, Anthony Liguori wrote:
 The help output is going to change dramatically for 0.13.  We've spent too 
 long

 0.13?  How long have you been sitting on this commit? :)

Yeah, I meant 1.3 :-)  It's been a long day...

 waiting for a perfect solution to capabilities handling and the end loser is
 the direct consumer of QEMU because the help output is awful.
 
 I will not apply any patches that change help output until 0.13 development
 opens up.  This should give libvirt adequate time to implement support for
 dealing with this new option.
 
 This capabilities set comes directly from libvirt's source code so it's 
 entirely
 adequate for libvirt's purposes.  We can still explore more sophisticated
 approaches that are more general purpose but the help output will be 
 changing.

 We've gone a long way with things like newer libvirt requiring QMP, and
 being able to use query-commands and even 'qemu -device ?' to figure out
 which devices are present, which is already more reliable than parsing
 -help output.  There may still be a few things to fix (for example, I
 already pointed out that libvirt 0.9.13 is bogus for refusing to even
 attempt 'qemu -device,?' unless it guesses from '-help' output that it
 will work; it would be better to just attempt it in the first place and
 deal with the fallout), but it should be easy to fix in time for libvirt
 0.10.0, and certainly coordinate things so that new enough libvirt comes
 out close to the time of qemu 1.2.

 +++ b/libvirt-caps.c
 @@ -0,0 +1,166 @@
 +/*
 + * Libvirt capabilities
 + *
 + * Copyright IBM, Corp. 2012
 + *
 + * Authors:
 + *  Anthony Liguori   aligu...@us.ibm.com
 + *
 + * This work is licensed under the terms of the GNU GPL, version 2 or later.
 + * See the COPYING file in the top-level directory.
 + *
 + */
 +
 +#include libvirt-caps.h
 +#include qemu-common.h
 +
 +/* Make sure this stays in sync with libvirt/src/qemu/qemu_capabilities.c */

 This is the part I'm most worried about - it says that any time libvirt
 decides to flag a new capability that it cares about within qemu, then
 both libvirt and qemu have to be upgraded in lockstep to coordinate the
 use of that capability.

This is QEMU's problem--not libvirt.  We shouldn't add new flags or
command line options without adding a capability proactively.  It
shouldn't be necessary for ya'll to always keep up.

 The problem is that sometimes libvirt doesn't
 care about a capability until after qemu has already been released (for
 example, we didn't realize the power of fd: migration until several
 releases after qemu had first implemented it, at which point when we
 added the capability bit, we were able to retroactively detect it for
 several qemu versions by parsing -help).

Again, we'd add capabilities whenever new stuff got added.

Yes, it would be better if this was all automatic but since I can't even
touch option parsing today I can't begin to untangle the mess.

So I'll admit this is not a perfect solution, but it's good enough that
we can start making real progress.

 +
 +static const char *supported_caps[] = {
 +//kqemu,
 +vnc-colon,
 +no-reboot,
 +drive,
 +drive-boot,
 +
 ...
 +drive-iotune,
 +system_wakeup,
 +scsi-disk.channel,
 +scsi-block,
 +transaction,
 +
 +NULL

 Already incomplete.  For example, libvirt has recently added
 block-job-sync, block-job-async, scsi-cd, and several others.

Yeah, my libvirt tree is old.  I'll resync.

 Thankfully, these days most of the new feature bits being added in
 libvirt's qemu_capabilities.h are related to things that were probed
 from 'qemu -device ?' or from QMP 'query-commands', and not from
 something additionally scraped from '-help' for the first time.  I had
 to go back to libvirt commit 63b4243 (May 15) to find a capability that
 libvirt learned by scraping -help output (namely, support for
 -no-user-config).  But yet this is one of the important config bits that
 libvirt really needs to know, and not one that can easily be learned
 from machine-parseable '-device ?'

I'd be happy to spend a little more time and trim the list specifically
to command line options.

 I'm worried that an interface like this will let libvirt know about the
 existing features that libvirt is trying to use, but will hurt the
 ability of adding new feature detection in to libvirt (basically, a
 newer libvirt wouldn't be able to retroactively take advantage of an
 older feature already present in older qemu without parsing some
 back-channel, at which point what good was having this libvirt-specific
 channel?).

See above.

 There's also another problem if we decide to keep this file synced
 across projects:

 +++ b/libvirt-caps.h
 @@ -0,0 +1,19 @@
 +/*
 + * Libvirt capabilities
 + *
 + * Copyright IBM, Corp. 2012
 + *
 + * Authors:
 + *  Anthony Liguori   aligu...@us.ibm.com
 + *
 + * This work is licensed under the terms of the GNU