diff mbox

[3/3] vl.c: add HMP help to machine

Message ID 1418217570-15517-4-git-send-email-marcel.a@redhat.com
State New
Headers show

Commit Message

Marcel Apfelbaum Dec. 10, 2014, 1:19 p.m. UTC
The help is based on the actual machine properties
exposing only the relevant options.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 vl.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

Alexander Graf Dec. 15, 2014, 3:16 p.m. UTC | #1
On 10.12.14 14:19, Marcel Apfelbaum wrote:
> The help is based on the actual machine properties
> exposing only the relevant options.
> 
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>

Can libvirt make use of this or would it need QMP based exposure?


Alex
Daniel P. Berrangé Dec. 15, 2014, 3:20 p.m. UTC | #2
On Mon, Dec 15, 2014 at 04:16:02PM +0100, Alexander Graf wrote:
> 
> 
> On 10.12.14 14:19, Marcel Apfelbaum wrote:
> > The help is based on the actual machine properties
> > exposing only the relevant options.
> > 
> > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> 
> Can libvirt make use of this or would it need QMP based exposure?

Libvirt *never* looks at any -help option anymore. We exclusively use
the QMP  query-XXXX commands to discover information about QEMU. So
if its not already possible to query existance of these new machine
properties via QMP, it'll need work.

Regards,
Daniel
Marcel Apfelbaum Dec. 15, 2014, 7:24 p.m. UTC | #3
On 12/15/2014 05:20 PM, Daniel P. Berrange wrote:

> On Mon, Dec 15, 2014 at 04:16:02PM +0100, Alexander Graf wrote:
>>
>> On 10.12.14 14:19, Marcel Apfelbaum wrote:
>>> The help is based on the actual machine properties
>>> exposing only the relevant options.
>>>
>>> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
>> Can libvirt make use of this or would it need QMP based exposure?
> Libvirt *never* looks at any -help option anymore. We exclusively use
> the QMP  query-XXXX commands to discover information about QEMU. So
> if its not already possible to query existance of these new machine
> properties via QMP, it'll need work.

Hi Daniel,
I thought we already have something generic that creates temp QOM object,
query its properties and then deletes it.
Who can answer this question? (I didn't get the chance to work with qmp yet.)

Thanks,
Marcel

>
> Regards,
> Daniel
>
diff mbox

Patch

diff --git a/vl.c b/vl.c
index f9757c3..fd54b44 100644
--- a/vl.c
+++ b/vl.c
@@ -1469,6 +1469,31 @@  MachineInfoList *qmp_query_machines(Error **errp)
     return mach_list;
 }
 
+static int machine_help_func(QemuOpts *opts, MachineState *machine)
+{
+    ObjectProperty *prop;
+
+    if (!qemu_opt_has_help_opt(opts)) {
+        return 0;
+    }
+
+    QTAILQ_FOREACH(prop, &OBJECT(machine)->properties, node) {
+        if (!prop->set) {
+            continue;
+        }
+
+        error_printf("%s.%s=%s", MACHINE_GET_CLASS(machine)->name,
+                     prop->name, prop->type);
+        if (prop->description) {
+            error_printf(" (%s)\n", prop->description);
+        } else {
+            error_printf("\n");
+        }
+    }
+
+    return 1;
+}
+
 /***********************************************************/
 /* main execution loop */
 
@@ -3767,6 +3792,9 @@  int main(int argc, char **argv, char **envp)
 
     current_machine = MACHINE(object_new(object_class_get_name(
                           OBJECT_CLASS(machine_class))));
+    if (machine_help_func(qemu_get_machine_opts(), current_machine)) {
+        exit(0);
+    }
     object_property_add_child(object_get_root(), "machine",
                               OBJECT(current_machine), &error_abort);
     cpu_exec_init_all();