Skip to contentSkip to conversation

-machine vmport=auto: Fix handling of VMWare ioport emulation for xen

PATCH Superseded Don Slutz 2 participants 7 messages Nov 20, 2014 – Nov 21, 2014

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Don Slutz

author
#0 lore raw

PATCH v5 1/1 -machine vmport=auto: Fix handling of VMWare ioport emulation for xen

c/s 9b23cfb76b3a5e9eb5cc899eaf2f46bc46d33ba4

or

c/s b154537ad07598377ebf98252fb7d2aff127983b

moved the testing of xen_enabled() from pc_init1() to pc_machine_initfn().

xen_enabled() does not return the correct value in pc_machine_initfn().

Changed vmport from a bool to an enum. Added the value "auto" to do the old way.

---

v5:
Eduardo Habkost:
What about changing pc_machine->vmport here instead of using a no_vmport variable, so the actual vmport configuration may be queried by anybody later using the QOM property? It would even make the code shorter.
Done.
Eric Blake:
I've only reviewed the qapi/common.json and qemu-options.hx files for QMP interface (and will leave the rest of the patch to others), but I'm okay with the changes to those files. I guess that means no R-b, since I didn't do a full review, so here's a weaker acked-by.

v4:
Michael S. Tsirkin, Eric Blake, Eduardo Habkost:
Rename vmport to OnOffAuto and move to qapi/common.json
Eduardo Habkost:
Simpler convert of enum to no_vmport.
Michael S. Tsirkin:
Add assert for ON_OFF_AUTO_MAX.

 hw/i386/pc.c         | 23 ++++++++++++++---------
 hw/i386/pc_piix.c    |  7 ++++++-
 hw/i386/pc_q35.c     |  7 ++++++-
 include/hw/i386/pc.h |  2 +-
 qapi/common.json     | 15 +++++++++++++++
 qemu-options.hx      |  8 +++++---
 vl.c                 |  2 +-
 7 files changed, 48 insertions(+), 16 deletions(-)
hw/i386/pc.c +14 -9
index 1205db8..15fba60 100644
@@ -1711,18 +1711,23 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
     pcms->max_ram_below_4g = value;
 }
 
-static bool pc_machine_get_vmport(Object *obj, Error **errp)
+static void pc_machine_get_vmport(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
+    int vmport = pcms->vmport;
 
-    return pcms->vmport;
+    visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp);
 }
 
-static void pc_machine_set_vmport(Object *obj, bool value, Error **errp)
+static void pc_machine_set_vmport(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
+    int vmport;
 
-    pcms->vmport = value;
+    visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp);
+    pcms->vmport = vmport;
 }
 
 static void pc_machine_initfn(Object *obj)
@@ -1737,11 +1742,11 @@ static void pc_machine_initfn(Object *obj)
                         pc_machine_get_max_ram_below_4g,
                         pc_machine_set_max_ram_below_4g,
                         NULL, NULL, NULL);
-    pcms->vmport = !xen_enabled();
-    object_property_add_bool(obj, PC_MACHINE_VMPORT,
-                             pc_machine_get_vmport,
-                             pc_machine_set_vmport,
-                             NULL);
+    pcms->vmport = ON_OFF_AUTO_AUTO;
+    object_property_add(obj, PC_MACHINE_VMPORT, "str",
+                        pc_machine_get_vmport,
+                        pc_machine_set_vmport,
+                        NULL, NULL, NULL);
 }
 
 static void pc_machine_class_init(ObjectClass *oc, void *data)
hw/i386/pc_piix.c +6 -1
index 7bb97a4..fffaab7 100644
@@ -234,9 +234,14 @@ static void pc_init1(MachineState *machine,
 
     pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
 
+    assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
+    if (pc_machine->vmport == ON_OFF_AUTO_AUTO) {
+        pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
+    }
+
     /* init basic PC hardware */
     pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy,
-                         !pc_machine->vmport, 0x4);
+                         (pc_machine->vmport != ON_OFF_AUTO_ON), 0x4);
 
     pc_nic_init(isa_bus, pci_bus);
 
hw/i386/pc_q35.c +6 -1
index 598e679..88cee93 100644
@@ -242,9 +242,14 @@ static void pc_q35_init(MachineState *machine)
 
     pc_register_ferr_irq(gsi[13]);
 
+    assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
+    if (pc_machine->vmport == ON_OFF_AUTO_AUTO) {
+        pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
+    }
+
     /* init basic PC hardware */
     pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy,
-                         !pc_machine->vmport, 0xff0104);
+                         (pc_machine->vmport != ON_OFF_AUTO_ON), 0xff0104);
 
     /* connect pm stuff to lpc */
     ich9_lpc_pm_init(lpc);
include/hw/i386/pc.h +1 -1
index 7c3731f..7f7d2d4 100644
@@ -37,7 +37,7 @@ struct PCMachineState {
     ISADevice *rtc;
 
     uint64_t max_ram_below_4g;
-    bool vmport;
+    OnOffAuto vmport;
 };
 
 #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
qapi/common.json +15 -0
index 4e9a21f..63ef3b4 100644
@@ -87,3 +87,18 @@
 ##
 { 'command': 'query-commands', 'returns': ['CommandInfo'] }
 
+##
+# @OnOffAuto
+#
+# An enumeration of three options: on, off, and auto
+#
+# @auto: QEMU selects the value between on and off
+#
+# @on: Enabled
+#
+# @off: Disabled
+#
+# Since: 2.2
+##
+{ 'enum': 'OnOffAuto',
+  'data': [ 'auto', 'on', 'off' ] }
qemu-options.hx +5 -3
index da9851d..64af16d 100644
@@ -33,7 +33,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
     "                property accel=accel1[:accel2[:...]] selects accelerator\n"
     "                supported accelerators are kvm, xen, tcg (default: tcg)\n"
     "                kernel_irqchip=on|off controls accelerated irqchip support\n"
-    "                vmport=on|off controls emulation of vmport (default: on)\n"
+    "                vmport=on|off|auto controls emulation of vmport (default: auto)\n"
     "                kvm_shadow_mem=size of KVM shadow MMU\n"
     "                dump-guest-core=on|off include guest memory in a core dump (default=on)\n"
     "                mem-merge=on|off controls memory merge support (default: on)\n"
@@ -52,8 +52,10 @@ than one accelerator specified, the next one is used if the previous one fails
 to initialize.
 @item kernel_irqchip=on|off
 Enables in-kernel irqchip support for the chosen accelerator when available.
-@item vmport=on|off
-Enables emulation of VMWare IO port, for vmmouse etc. (enabled by default)
+@item vmport=on|off|auto
+Enables emulation of VMWare IO port, for vmmouse etc. auto says to select the
+value based on accel. For accel=xen the default is off otherwise the default
+is on.
 @item kvm_shadow_mem=size
 Defines the size of the KVM shadow MMU.
 @item dump-guest-core=on|off
vl.c +1 -1
index f4a6e5e..eb89d62 100644
@@ -381,7 +381,7 @@ static QemuOptsList qemu_machine_opts = {
             .help = "maximum ram below the 4G boundary (32bit boundary)",
         }, {
             .name = PC_MACHINE_VMPORT,
-            .type = QEMU_OPT_BOOL,
+            .type = QEMU_OPT_STRING,
             .help = "Enable vmport (pc & q35)",
         },{
             .name = "iommu",
Signature · 1 line
1.8.4
#1 lore raw

On Thu, Nov 20, 2014 at 05:32:56PM -0500, Don Slutz wrote:
[...]

hw/i386/pc.c static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, · line 1720

Quoted 13 lines
hw/i386/pc.c +4 -2
@@ -1711,18 +1711,23 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
     pcms->max_ram_below_4g = value;
 }
 
-static bool pc_machine_get_vmport(Object *obj, Error **errp)
+static void pc_machine_get_vmport(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
+    int vmport = pcms->vmport;
 
-    return pcms->vmport;
+    visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp);

A visit_type_OnOffAuto() function is automatically generated by the QAPI schema, so you don't need to deal with the low level visit_type_enum() function.

hw/i386/pc.c static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, · line 1730

Quoted 12 lines
hw/i386/pc.c +5 -2
 }
 
-static void pc_machine_set_vmport(Object *obj, bool value, Error **errp)
+static void pc_machine_set_vmport(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
+    int vmport;
 
-    pcms->vmport = value;
+    visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp);
+    pcms->vmport = vmport;

'vmport' may be undefined in case the visitor return an error, and in this case you shouldn't change pcms->vmport. This won't be a problem if you just call:

    visit_type_OnOffAuto(v, &pcms->vmport, name, errp);
Quoted 4 lines
hw/i386/pc.c +0 -0
 }
 
 static void pc_machine_initfn(Object *obj)

hw/i386/pc.c static void pc_machine_initfn(Object *obj) · line 1746

Quoted 10 lines
hw/i386/pc.c +2 -5
@@ -1737,11 +1742,11 @@ static void pc_machine_initfn(Object *obj)
                         pc_machine_get_max_ram_below_4g,
                         pc_machine_set_max_ram_below_4g,
                         NULL, NULL, NULL);
-    pcms->vmport = !xen_enabled();
-    object_property_add_bool(obj, PC_MACHINE_VMPORT,
-                             pc_machine_get_vmport,
-                             pc_machine_set_vmport,
-                             NULL);
+    pcms->vmport = ON_OFF_AUTO_AUTO;
+    object_property_add(obj, PC_MACHINE_VMPORT, "str",

I believe "OnOffAuto" is a valid type name, if it is defined in the QAPI schema.

Quoted 5 lines
hw/i386/pc.c +3 -0
+                        pc_machine_get_vmport,
+                        pc_machine_set_vmport,
+                        NULL, NULL, NULL);
 }
 

[...]

Signature · 1 line
Eduardo
author
#2 lore raw
Quoted 13 lines · Eduardo Habkost

On Thu, Nov 20, 2014 at 05:32:56PM -0500, Don Slutz wrote:
[...]

Quoted 11 lines
hw/i386/pc.c +3 -1
@@ -1711,18 +1711,23 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
      pcms->max_ram_below_4g = value;
  }
 
-static bool pc_machine_get_vmport(Object *obj, Error **errp)
+static void pc_machine_get_vmport(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
  {
      PCMachineState *pcms = PC_MACHINE(obj);
+    int vmport = pcms->vmport;
 
Quoted 5 lines

Review static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, · line 1720

Quoted 2 lines
(quoted diff) +1 -1
-    return pcms->vmport;
+    visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp);

A visit_type_OnOffAuto() function is automatically generated by the QAPI schema, so you don't need to deal with the low level visit_type_enum() function.

Ok. Will switch.

Quoted 9 lines
Quoted 9 lines
hw/i386/pc.c +3 -1
  }
 
-static void pc_machine_set_vmport(Object *obj, bool value, Error **errp)
+static void pc_machine_set_vmport(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
  {
      PCMachineState *pcms = PC_MACHINE(obj);
+    int vmport;
 
Quoted 8 lines

hw/i386/pc.c static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, · line 1730

Quoted 3 lines
hw/i386/pc.c +2 -1
-    pcms->vmport = value;
+    visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp);
+    pcms->vmport = vmport;

'vmport' may be undefined in case the visitor return an error, and in this case you shouldn't change pcms->vmport. This won't be a problem if you just call:

     visit_type_OnOffAuto(v, &pcms->vmport, name, errp);

Will do.

Quoted 16 lines
Quoted 4 lines
hw/i386/pc.c +0 -0
  }
 
  static void pc_machine_initfn(Object *obj)

hw/i386/pc.c static void pc_machine_initfn(Object *obj) · line 1746

Quoted 10 lines
hw/i386/pc.c +2 -5
@@ -1737,11 +1742,11 @@ static void pc_machine_initfn(Object *obj)
                          pc_machine_get_max_ram_below_4g,
                          pc_machine_set_max_ram_below_4g,
                          NULL, NULL, NULL);
-    pcms->vmport = !xen_enabled();
-    object_property_add_bool(obj, PC_MACHINE_VMPORT,
-                             pc_machine_get_vmport,
-                             pc_machine_set_vmport,
-                             NULL);
+    pcms->vmport = ON_OFF_AUTO_AUTO;
+    object_property_add(obj, PC_MACHINE_VMPORT, "str",

I believe "OnOffAuto" is a valid type name, if it is defined in the QAPI schema.

I can only find:

qapi-types.h:typedef enum OnOffAuto
qapi-types.h:} OnOffAuto;

Which I use to define pcms->vmport. The best I can translate this is that "str" is what you are looking to replace.

So I plan no change here.

-Don Slutz

Quoted 7 lines
Quoted 5 lines
hw/i386/pc.c +3 -0
+                        pc_machine_get_vmport,
+                        pc_machine_set_vmport,
+                        NULL, NULL, NULL);
  }
 

[...]

#3 lore raw
Quoted 54 lines · Don Slutz
Quoted 16 lines · Eduardo Habkost

On Thu, Nov 20, 2014 at 05:32:56PM -0500, Don Slutz wrote:
[...]

hw/i386/pc.c static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, · line 1718

Quoted 11 lines
hw/i386/pc.c +4 -2
@@ -1711,18 +1711,23 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
     pcms->max_ram_below_4g = value;
 }
-static bool pc_machine_get_vmport(Object *obj, Error **errp)
+static void pc_machine_get_vmport(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
+    int vmport = pcms->vmport;
-    return pcms->vmport;
+    visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp);

A visit_type_OnOffAuto() function is automatically generated by the QAPI schema, so you don't need to deal with the low level visit_type_enum() function.

Ok. Will switch.

Quoted 14 lines

hw/i386/pc.c static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, · line 1730

Quoted 10 lines
hw/i386/pc.c +5 -2
 }
-static void pc_machine_set_vmport(Object *obj, bool value, Error **errp)
+static void pc_machine_set_vmport(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
+    int vmport;
-    pcms->vmport = value;
+    visit_type_enum(v, &vmport, OnOffAuto_lookup, NULL, name, errp);
+    pcms->vmport = vmport;

'vmport' may be undefined in case the visitor return an error, and in this case you shouldn't change pcms->vmport. This won't be a problem if you just call:

Quoted 1 line
    visit_type_OnOffAuto(v, &pcms->vmport, name, errp);

Will do.

Quoted 7 lines
Quoted 7 lines
hw/i386/pc.c +0 -1
 }
 static void pc_machine_initfn(Object *obj)
@@ -1737,11 +1742,11 @@ static void pc_machine_initfn(Object *obj)
                         pc_machine_get_max_ram_below_4g,
                         pc_machine_set_max_ram_below_4g,
                         NULL, NULL, NULL);
-    pcms->vmport = !xen_enabled();
Quoted 8 lines

hw/i386/pc.c static void pc_machine_initfn(Object *obj) · line 1746

Quoted 6 lines
hw/i386/pc.c +2 -4
-    object_property_add_bool(obj, PC_MACHINE_VMPORT,
-                             pc_machine_get_vmport,
-                             pc_machine_set_vmport,
-                             NULL);
+    pcms->vmport = ON_OFF_AUTO_AUTO;
+    object_property_add(obj, PC_MACHINE_VMPORT, "str",

I believe "OnOffAuto" is a valid type name, if it is defined in the QAPI schema.

Quoted 4 lines

I can only find:

qapi-types.h:typedef enum OnOffAuto
qapi-types.h:} OnOffAuto;

I don't understand what you mean, where did you expect to find it? You added it to the schema, so it is now a valid type name.

Quoted 5 lines

Which I use to define pcms->vmport. The best I can translate this is that "str" is what you are looking to replace.

So I plan no change here.

You are not defining a string property, but an OnOffAuto enum property, so why use "str"?

See, for example, the type of an existing enum property:
ide-hd.bios-chs-trans:

  $ qemu-system-x86_64 -device ide-hd,?
  [...]
  ide-hd.bios-chs-trans=BiosAtaTranslation (Logical CHS translation algorithm, auto/none/lba/large/rechs)
  [...]
  $ 
Signature · 1 line
Eduardo
author
#4 lore raw
Quoted 4 lines · Eduardo Habkost
Quoted 3 lines · Don Slutz
Quoted 2 lines · Eduardo Habkost

On Thu, Nov 20, 2014 at 05:32:56PM -0500, Don Slutz wrote:
[...]

[...]

Quoted 18 lines
Quoted 8 lines
Quoted 4 lines

hw/i386/pc.c static void pc_machine_initfn(Object *obj) · line 1746

Quoted 2 lines
hw/i386/pc.c +2 -0
+    pcms->vmport = ON_OFF_AUTO_AUTO;
+    object_property_add(obj, PC_MACHINE_VMPORT, "str",

I believe "OnOffAuto" is a valid type name, if it is defined in the QAPI schema.

I can only find:

qapi-types.h:typedef enum OnOffAuto
qapi-types.h:} OnOffAuto;

I don't understand what you mean, where did you expect to find it? You added it to the schema, so it is now a valid type name.

Quoted 4 lines

Which I use to define pcms->vmport. The best I can translate this is that "str" is what you are looking to replace.

So I plan no change here.

You are not defining a string property, but an OnOffAuto enum property, so why use "str"?

Quoted 10 lines

See, for example, the type of an existing enum property:
ide-hd.bios-chs-trans:

   $ qemu-system-x86_64 -device ide-hd,?
   [...]
   ide-hd.bios-chs-trans=BiosAtaTranslation (Logical CHS translation algorithm, auto/none/lba/large/rechs)
   [...]
   $

Ok, I now understand what you are getting at. From object.h:

* @type: the type name of the property. This namespace is pretty loosely

 *   defined.  Sub namespaces are constructed by using a prefix and then
 *   to angle brackets.  For instance, the type 'virtio-net-pci' in the
 *   'link' namespace would be 'link<virtio-net-pci>'.

It turns out that BiosAtaTranslation is a .name not a .type:

hyper-0-21-52:~/qemu>git grep BiosAtaTranslation hw/core/qdev-properties.c:QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int));

hw/core/qdev-properties.c:    .name = "BiosAtaTranslation",
hw/core/qdev-properties.c:    .enum_table = BiosAtaTranslation_lookup,

qapi/block.json:# BiosAtaTranslation:
qapi/block.json:{ 'enum': 'BiosAtaTranslation',

so to me there are a few options:

1) "enum"
2) "OnOffAuto"
3) "enum<OnOffAuto>"
4) "enum OnOffAuto"
5) "enum-OnOffAuto"

I think #2 was what you were thinking of, but I am not sure. Please advise.

-Don Slutz

#5 lore raw
Quoted 34 lines · Don Slutz
Quoted 4 lines · Eduardo Habkost
Quoted 3 lines · Don Slutz
Quoted 2 lines · Eduardo Habkost

On Thu, Nov 20, 2014 at 05:32:56PM -0500, Don Slutz wrote:
[...]

[...]

Quoted 18 lines
Quoted 8 lines
Quoted 4 lines

hw/i386/pc.c static void pc_machine_initfn(Object *obj) · line 1746

Quoted 2 lines
hw/i386/pc.c +2 -0
+    pcms->vmport = ON_OFF_AUTO_AUTO;
+    object_property_add(obj, PC_MACHINE_VMPORT, "str",

I believe "OnOffAuto" is a valid type name, if it is defined in the QAPI schema.

I can only find:

qapi-types.h:typedef enum OnOffAuto
qapi-types.h:} OnOffAuto;

I don't understand what you mean, where did you expect to find it? You added it to the schema, so it is now a valid type name.

Quoted 4 lines

Which I use to define pcms->vmport. The best I can translate this is that "str" is what you are looking to replace.

So I plan no change here.

You are not defining a string property, but an OnOffAuto enum property, so why use "str"?

Quoted 10 lines

See, for example, the type of an existing enum property:
ide-hd.bios-chs-trans:

  $ qemu-system-x86_64 -device ide-hd,?
  [...]
  ide-hd.bios-chs-trans=BiosAtaTranslation (Logical CHS translation algorithm, auto/none/lba/large/rechs)
  [...]
  $
Quoted 9 lines

Ok, I now understand what you are getting at. From object.h:

* @type: the type name of the property. This namespace is pretty loosely

 *   defined.  Sub namespaces are constructed by using a prefix and then
 *   to angle brackets.  For instance, the type 'virtio-net-pci' in the
 *   'link' namespace would be 'link<virtio-net-pci>'.

It turns out that BiosAtaTranslation is a .name not a .type:

"-device ...,?" above is showing the property type. See qdev_device_help().

Quoted 7 lines

hyper-0-21-52:~/qemu>git grep BiosAtaTranslation hw/core/qdev-properties.c:QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int));

hw/core/qdev-properties.c:    .name = "BiosAtaTranslation",
hw/core/qdev-properties.c:    .enum_table = BiosAtaTranslation_lookup,

qapi/block.json:# BiosAtaTranslation:
qapi/block.json:{ 'enum': 'BiosAtaTranslation',

PropertyInfo.name is what is used as the 'type' parameter to object_property_add() when qdev adds a static property to the object. See qdev_property_add_static().

Quoted 11 lines

so to me there are a few options:

1) "enum"
2) "OnOffAuto"
3) "enum<OnOffAuto>"
4) "enum OnOffAuto"
5) "enum-OnOffAuto"

I think #2 was what you were thinking of, but I am not sure. Please advise.

The documentation is unclear about the set of valid type names. But as existing enum properties simply use the enum type name directly, I suggest "OnOffAuto" to follow existing practice.

Signature · 1 line
Eduardo
author
#6 lore raw
Quoted 67 lines · Eduardo Habkost
Quoted 34 lines · Don Slutz
Quoted 4 lines · Eduardo Habkost
Quoted 3 lines · Don Slutz
Quoted 2 lines · Eduardo Habkost

On Thu, Nov 20, 2014 at 05:32:56PM -0500, Don Slutz wrote:
[...]

[...]

Quoted 18 lines
Quoted 8 lines
Quoted 4 lines

hw/i386/pc.c static void pc_machine_initfn(Object *obj) · line 1746

Quoted 2 lines
hw/i386/pc.c +2 -0
+    pcms->vmport = ON_OFF_AUTO_AUTO;
+    object_property_add(obj, PC_MACHINE_VMPORT, "str",

I believe "OnOffAuto" is a valid type name, if it is defined in the QAPI schema.

I can only find:

qapi-types.h:typedef enum OnOffAuto
qapi-types.h:} OnOffAuto;

I don't understand what you mean, where did you expect to find it? You added it to the schema, so it is now a valid type name.

Quoted 4 lines

Which I use to define pcms->vmport. The best I can translate this is that "str" is what you are looking to replace.

So I plan no change here.

You are not defining a string property, but an OnOffAuto enum property, so why use "str"?

Quoted 10 lines

See, for example, the type of an existing enum property:
ide-hd.bios-chs-trans:

   $ qemu-system-x86_64 -device ide-hd,?
   [...]
   ide-hd.bios-chs-trans=BiosAtaTranslation (Logical CHS translation algorithm, auto/none/lba/large/rechs)
   [...]
   $
Quoted 9 lines

Ok, I now understand what you are getting at. From object.h:

* @type: the type name of the property. This namespace is pretty loosely

  *   defined.  Sub namespaces are constructed by using a prefix and then
  *   to angle brackets.  For instance, the type 'virtio-net-pci' in the
  *   'link' namespace would be 'link<virtio-net-pci>'.

It turns out that BiosAtaTranslation is a .name not a .type:

"-device ...,?" above is showing the property type. See qdev_device_help().

Quoted 7 lines

hyper-0-21-52:~/qemu>git grep BiosAtaTranslation hw/core/qdev-properties.c:QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int));

hw/core/qdev-properties.c:    .name = "BiosAtaTranslation",
hw/core/qdev-properties.c:    .enum_table = BiosAtaTranslation_lookup,

qapi/block.json:# BiosAtaTranslation:
qapi/block.json:{ 'enum': 'BiosAtaTranslation',

PropertyInfo.name is what is used as the 'type' parameter to object_property_add() when qdev adds a static property to the object. See qdev_property_add_static().

Quoted 9 lines

so to me there are a few options:

1) "enum"
2) "OnOffAuto"
3) "enum<OnOffAuto>"
4) "enum OnOffAuto"
5) "enum-OnOffAuto"

Quoted 5 lines
Quoted 1 line

I think #2 was what you were thinking of, but I am not sure. Please advise.

The documentation is unclear about the set of valid type names. But as existing enum properties simply use the enum type name directly, I suggest "OnOffAuto" to follow existing practice.

Fine. I went with this. v6 posted.

-Don Slutz