Skip to contentSkip to conversation

user-mode: Prune build dependencies (part 3)

PATCH Superseded Philippe Mathieu-Daudé 5 participants 24 messages Sep 30, 2020 – Oct 1, 2020

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover user-mode: Prune build dependencies (part 3)

This is the third part of a series reducing user-mode dependencies. By stripping out unused code, the build and testing time is reduced (as is space used by objects).

Part 3:
- Extract code not related to user-mode from hw/core/qdev-properties.c
- Reduce user-mode QAPI generated files

Since v2:
- Fixed UuidInfo placed in incorrect json
- Rebased on Meson
- Include X86CPUFeatureWord unmerged from part 2

Since v1:
- Addressed Richard and Paolo review comments

Patches missing review: QAPI ones :)
- #1 'qapi: Restrict query-uuid command to block code'
- #11 'qapi: Restrict code generated for user-mode'

Green CI: https://gitlab.com/philmd/qemu/-/pipelines/196505787

v2: https://www.mail-archive.com/[email protected]/msg688879.html
v1: https://www.mail-archive.com/[email protected]/msg688486.html

Philippe Mathieu-Daudé (11):
qapi: Restrict query-uuid command to block code hw/core/qdev-properties: Use qemu_strtol() in set_mac() handler hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr() hw/core/qdev-properties: Fix code style hw/core/qdev-properties: Export enum-related functions hw/core/qdev-properties: Export qdev_prop_enum hw/core/qdev-properties: Export some integer-related functions hw/core/qdev-properties: Extract system-mode specific properties hw/core: Add qdev stub for user-mode
target/i386: Restrict X86CPUFeatureWord to X86 targets
qapi: Restrict code generated for user-mode

 qapi/block.json                  |  30 ++
 qapi/machine-target.json         |  45 ++
 qapi/machine.json                |  72 ---
 hw/core/qdev-prop-internal.h     |  30 ++
 include/hw/qdev-properties.h     |   1 +
 block/iscsi.c                    |   2 +-
 hw/core/qdev-properties-system.c | 687 ++++++++++++++++++++++++++++-
 hw/core/qdev-properties.c        | 735 ++-----------------------------
 stubs/qdev-system.c              |  24 +
 stubs/uuid.c                     |   2 +-
 target/i386/cpu.c                |   2 +-
 target/i386/feature-stub.c       |  23 +
 qapi/meson.build                 |  51 ++-
 stubs/meson.build                |   5 +-
 target/i386/meson.build          |   1 +
 15 files changed, 915 insertions(+), 795 deletions(-)
 create mode 100644 hw/core/qdev-prop-internal.h
 create mode 100644 stubs/qdev-system.c
 create mode 100644 target/i386/feature-stub.c
Signature · 1 line
2.26.2
#1 lore raw

PATCH v3 1/11 qapi: Restrict query-uuid command to block code

In commit f68c01470b we restricted the query-uuid command to machine code, but it is incorrect, as it is also used by the tools. Therefore move this command again, but to block.json, which is shared by machine code and tools.

Fixes f68c01470b ("qapi: Restrict query-uuid command to machine code")
---
 qapi/block.json   | 30 ++++++++++++++++++++++++++++++
 qapi/machine.json | 30 ------------------------------
 block/iscsi.c     |  2 +-
 stubs/uuid.c      |  2 +-
 stubs/meson.build |  4 +++-
 5 files changed, 35 insertions(+), 33 deletions(-)
qapi/block.json +30 -0
index a009f7d3a2..4ae1716b56 100644
@@ -11,6 +11,36 @@
 # == Additional block stuff (VM related)
 ##
 
+##
+# @UuidInfo:
+#
+# Guest UUID information (Universally Unique Identifier).
+#
+# @UUID: the UUID of the guest
+#
+# Since: 0.14.0
+#
+# Notes: If no UUID was specified for the guest, a null UUID is returned.
+##
+{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} }
+
+##
+# @query-uuid:
+#
+# Query the guest UUID information.
+#
+# Returns: The @UuidInfo for the guest
+#
+# Since: 0.14.0
+#
+# Example:
+#
+# -> { "execute": "query-uuid" }
+# <- { "return": { "UUID": "550e8400-e29b-41d4-a716-446655440000" } }
+#
+##
+{ 'command': 'query-uuid', 'returns': 'UuidInfo', 'allow-preconfig': true }
+
 ##
 # @BiosAtaTranslation:
 #
qapi/machine.json +0 -30
index 756dacb06f..72f014bb5b 100644
@@ -402,36 +402,6 @@
 ##
 { 'command': 'query-target', 'returns': 'TargetInfo' }
 
-##
-# @UuidInfo:
-#
-# Guest UUID information (Universally Unique Identifier).
-#
-# @UUID: the UUID of the guest
-#
-# Since: 0.14.0
-#
-# Notes: If no UUID was specified for the guest, a null UUID is returned.
-##
-{ 'struct': 'UuidInfo', 'data': {'UUID': 'str'} }
-
-##
-# @query-uuid:
-#
-# Query the guest UUID information.
-#
-# Returns: The @UuidInfo for the guest
-#
-# Since: 0.14.0
-#
-# Example:
-#
-# -> { "execute": "query-uuid" }
-# <- { "return": { "UUID": "550e8400-e29b-41d4-a716-446655440000" } }
-#
-##
-{ 'command': 'query-uuid', 'returns': 'UuidInfo', 'allow-preconfig': true }
-
 ##
 # @GuidInfo:
 #
block/iscsi.c +1 -1
index e30a7e3606..1effea25ed 100644
@@ -42,7 +42,7 @@
 #include "qemu/uuid.h"
 #include "sysemu/replay.h"
 #include "qapi/error.h"
-#include "qapi/qapi-commands-machine.h"
+#include "qapi/qapi-commands-block.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
 #include "crypto/secret.h"
stubs/uuid.c +1 -1
index e5112eb3f6..d6bfb442e0 100644
@@ -1,5 +1,5 @@
 #include "qemu/osdep.h"
-#include "qapi/qapi-commands-machine.h"
+#include "qapi/qapi-commands-block.h"
 #include "qemu/uuid.h"
 
 UuidInfo *qmp_query_uuid(Error **errp)
stubs/meson.build +3 -1
index e0b322bc28..2e231590e1 100644
@@ -39,7 +39,9 @@ stub_ss.add(files('target-get-monitor-def.c'))
 stub_ss.add(files('target-monitor-defs.c'))
 stub_ss.add(files('tpm.c'))
 stub_ss.add(files('trace-control.c'))
-stub_ss.add(files('uuid.c'))
+if have_block
+  stub_ss.add(files('uuid.c'))
+endif
 stub_ss.add(files('vmgenid.c'))
 stub_ss.add(files('vmstate.c'))
 stub_ss.add(files('vm-stop.c'))
Signature · 1 line
2.26.2
#2 lore raw

Re: [PATCH v3 01/11] qapi: Restrict query-uuid command to block code

Quoted 8 lines · Philippe Mathieu-Daudé

In commit f68c01470b we restricted the query-uuid command to machine code, but it is incorrect, as it is also used by the tools. Therefore move this command again, but to block.json, which is shared by machine code and tools.

Fixes f68c01470b ("qapi: Restrict query-uuid command to machine code")

UUIDs are not really a block-specific thing.

QMP query-uuid and HMP info uuid are about the VM, like query-name. That's why they used to be next to query-name in misc.json.

There's one additional use in block/iscsi.c's get_initiator_name(). I figure that's what pulls it into tools via qemu-img.

Which other QAPI modules are shared by all the executables that use it?

What about reverting the commit? How bad would that be for user mode?

#3 lore raw

Re: [PATCH v3 01/11] qapi: Restrict query-uuid command to block code

+Igor

Quoted 7 lines · Markus Armbruster
Quoted 5 lines · Philippe Mathieu-Daudé

In commit f68c01470b we restricted the query-uuid command to machine code, but it is incorrect, as it is also used by the tools. Therefore move this command again, but to block.json, which is shared by machine code and tools.

Quoted 5 lines
Quoted 3 lines
Fixes f68c01470b ("qapi: Restrict query-uuid command to machine code")

UUIDs are not really a block-specific thing.

This is the discussion we had in v1 with Igor...

UuidInfo is a iSCSI-specific "thing", the original commit is f9dadc9855 ("iSCSI: add configuration variables for iSCSI") then Paolo introduced 'UuidInfo' in commit 5accc8408f ("scsi: prefer UUID to VM name for the initiator name") but is misnamed?

Quoted 3 lines

QMP query-uuid and HMP info uuid are about the VM, like query-name. That's why they used to be next to query-name in misc.json.

This is GuidInfo, not UuidInfo...

GuidInfo is correctly in machine.json.

Quoted 3 lines

There's one additional use in block/iscsi.c's get_initiator_name(). I figure that's what pulls it into tools via qemu-img.

Yes.

Quoted 2 lines

Which other QAPI modules are shared by all the executables that use it?

None?

Quoted 3 lines

What about reverting the commit? How bad would that be for user mode?

The problem is not user-mode, is linking tools.

#4 lore raw

Re: [PATCH v3 01/11] qapi: Restrict query-uuid command to block code

Quoted 16 lines · Philippe Mathieu-Daudé

+Igor

Quoted 7 lines · Markus Armbruster
Quoted 5 lines · Philippe Mathieu-Daudé

In commit f68c01470b we restricted the query-uuid command to machine code, but it is incorrect, as it is also used by the tools. Therefore move this command again, but to block.json, which is shared by machine code and tools.

Quoted 5 lines
Quoted 3 lines
Fixes f68c01470b ("qapi: Restrict query-uuid command to machine code")

UUIDs are not really a block-specific thing.

Quoted 7 lines

This is the discussion we had in v1 with Igor...

UuidInfo is a iSCSI-specific "thing", the original commit is f9dadc9855 ("iSCSI: add configuration variables for iSCSI") then Paolo introduced 'UuidInfo' in commit 5accc8408f ("scsi: prefer UUID to VM name for the initiator name") but is misnamed?

UuidInfo is also used by query-uuid and info uuid. query-uuid returns whatever was set with option -uuid. Option's help text calls it "machine UUID".

Quoted 6 lines
Quoted 2 lines

QMP query-uuid and HMP info uuid are about the VM, like query-name. That's why they used to be next to query-name in misc.json.

This is GuidInfo, not UuidInfo...

GuidInfo is correctly in machine.json.

GuidInfo is used by query-vm-generation-id and info vm-generation-id. query-vm-generation-id returns the value of property "guid" of the vmgenid device.

I don't know why we have both.

Quoted 9 lines
Quoted 2 lines

There's one additional use in block/iscsi.c's get_initiator_name(). I figure that's what pulls it into tools via qemu-img.

Yes.

Quoted 2 lines

Which other QAPI modules are shared by all the executables that use it?

None?

I'd expect at least all the modules block.json includes:
block-core.json, common.json, crypto.json, job.json, sockets.json.

Quoted 4 lines
Quoted 2 lines

What about reverting the commit? How bad would that be for user mode?

The problem is not user-mode, is linking tools.

Which modules are linked now?

#5 lore raw

PATCH v3 2/11 hw/core/qdev-properties: Use qemu_strtol() in set_mac() handler

In reply to Philippe Mathieu-Daudé

The MACAddr structure contains an array of uint8_t. Previously if a value was out of the [0..255] range, it was silently casted and no input validation was done.
Replace strtol() by qemu_strtol() -- so checkpatch.pl won't complain if we move this code later -- and return EINVAL if the input is invalid.

---
 hw/core/qdev-properties.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
hw/core/qdev-properties.c +9 -2
index 343c824da0..080ba319a1 100644
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "net/net.h"
 #include "hw/qdev-properties.h"
 #include "qapi/error.h"
@@ -524,7 +525,8 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
     Property *prop = opaque;
     MACAddr *mac = qdev_get_prop_ptr(dev, prop);
     int i, pos;
-    char *str, *p;
+    char *str;
+    const char *p;
 
     if (dev->realized) {
         qdev_prop_set_after_realize(dev, name, errp);
@@ -536,6 +538,8 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
     }
 
     for (i = 0, pos = 0; i < 6; i++, pos += 3) {
+        long val;
+
         if (!qemu_isxdigit(str[pos])) {
             goto inval;
         }
@@ -551,7 +555,10 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
                 goto inval;
             }
         }
-        mac->a[i] = strtol(str+pos, &p, 16);
+        if (qemu_strtol(str + pos, &p, 16, &val) < 0 || val > 0xff) {
+            goto inval;
+        }
+        mac->a[i] = val;
     }
     g_free(str);
     return;
Signature · 1 line
2.26.2
#6 lore raw

PATCH v3 3/11 hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr()

In reply to Philippe Mathieu-Daudé

Replace strtoul() by qemu_strtoul() so checkpatch.pl won't complain if we move this code later.

---
 hw/core/qdev-properties.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
hw/core/qdev-properties.c +12 -13
index 080ba319a1..a1190a5db9 100644
@@ -951,7 +951,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
     Property *prop = opaque;
     PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
     char *str, *p;
-    char *e;
+    const char *e;
     unsigned long val;
     unsigned long dom = 0, bus = 0;
     unsigned int slot = 0, func = 0;
@@ -966,23 +966,23 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
     }
 
     p = str;
-    val = strtoul(p, &e, 16);
-    if (e == p || *e != ':') {
+    if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0xffff || e == p) {
+        goto inval;
+    }
+    if (*e != ':') {
         goto inval;
     }
     bus = val;
 
-    p = e + 1;
-    val = strtoul(p, &e, 16);
-    if (e == p) {
+    p = (char *)e + 1;
+    if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0x1f || e == p) {
         goto inval;
     }
     if (*e == ':') {
         dom = bus;
         bus = val;
-        p = e + 1;
-        val = strtoul(p, &e, 16);
-        if (e == p) {
+        p = (char *)e + 1;
+        if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0x1f || e == p) {
             goto inval;
         }
     }
@@ -991,14 +991,13 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
     if (*e != '.') {
         goto inval;
     }
-    p = e + 1;
-    val = strtoul(p, &e, 10);
-    if (e == p) {
+    p = (char *)e + 1;
+    if (qemu_strtoul(p, &e, 10, &val) < 0 || val > 7 || e == p) {
         goto inval;
     }
     func = val;
 
-    if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7) {
+    if (bus > 0xff) {
         goto inval;
     }
 
Signature · 1 line
2.26.2
#7 lore raw

PATCH v3 4/11 hw/core/qdev-properties: Fix code style

In reply to Philippe Mathieu-Daudé

We will soon move this code, fix its style to avoid checkpatch.pl to complain.

---
 hw/core/qdev-properties.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
hw/core/qdev-properties.c +5 -5
index a1190a5db9..071fd5864a 100644
@@ -543,15 +543,15 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
         if (!qemu_isxdigit(str[pos])) {
             goto inval;
         }
-        if (!qemu_isxdigit(str[pos+1])) {
+        if (!qemu_isxdigit(str[pos + 1])) {
             goto inval;
         }
         if (i == 5) {
-            if (str[pos+2] != '\0') {
+            if (str[pos + 2] != '\0') {
                 goto inval;
             }
         } else {
-            if (str[pos+2] != ':' && str[pos+2] != '-') {
+            if (str[pos + 2] != ':' && str[pos + 2] != '-') {
                 goto inval;
             }
         }
@@ -898,8 +898,8 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,
     /* We rely on power-of-2 blocksizes for bitmasks */
     if ((value & (value - 1)) != 0) {
         error_setg(errp,
-                  "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2",
-                  dev->id ?: "", name, (int64_t)value);
+                  "Property %s.%s doesn't take value '%" PRId64 "', "
+                  "it's not a power of 2", dev->id ?: "", name, (int64_t)value);
         return;
     }
 
Signature · 1 line
2.26.2
#8 lore raw

PATCH v3 5/11 hw/core/qdev-properties: Export enum-related functions

In reply to Philippe Mathieu-Daudé

We are going to split this file and reuse these static functions. Add the local "qdev-prop-internal.h" header declaring them.

---
 hw/core/qdev-prop-internal.h | 19 ++++++++++++
 hw/core/qdev-properties.c    | 58 +++++++++++++++++++-----------------
 2 files changed, 49 insertions(+), 28 deletions(-)
 create mode 100644 hw/core/qdev-prop-internal.h
hw/core/qdev-prop-internal.h new file +19 -0
new file mode 100644
index 0000000000..2a8c9a306a
@@ -0,0 +1,19 @@
+/*
+ * qdev property parsing
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef HW_CORE_QDEV_PROP_INTERNAL_H
+#define HW_CORE_QDEV_PROP_INTERNAL_H
+
+void qdev_propinfo_get_enum(Object *obj, Visitor *v, const char *name,
+                            void *opaque, Error **errp);
+void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name,
+                            void *opaque, Error **errp);
+
+void qdev_propinfo_set_default_value_enum(ObjectProperty *op,
+                                          const Property *prop);
+
+#endif
hw/core/qdev-properties.c +30 -28

134 lines not on this page · raw message

Signature · 1 line
2.26.2
#9 lore raw

PATCH v3 6/11 hw/core/qdev-properties: Export qdev_prop_enum

In reply to Philippe Mathieu-Daudé
---
 include/hw/qdev-properties.h | 1 +
 hw/core/qdev-properties.c    | 7 +++++++
 2 files changed, 8 insertions(+)
include/hw/qdev-properties.h +1 -0
index 528310bb22..4437450065 100644
@@ -8,6 +8,7 @@
 extern const PropertyInfo qdev_prop_bit;
 extern const PropertyInfo qdev_prop_bit64;
 extern const PropertyInfo qdev_prop_bool;
+extern const PropertyInfo qdev_prop_enum;
 extern const PropertyInfo qdev_prop_uint8;
 extern const PropertyInfo qdev_prop_uint16;
 extern const PropertyInfo qdev_prop_uint32;
hw/core/qdev-properties.c +7 -0
index 76417d0936..31dfe441e2 100644
@@ -86,6 +86,13 @@ void qdev_propinfo_set_default_value_enum(ObjectProperty *op,
         qapi_enum_lookup(prop->info->enum_table, prop->defval.i));
 }
 
+const PropertyInfo qdev_prop_enum = {
+    .name  = "enum",
+    .get   = qdev_propinfo_get_enum,
+    .set   = qdev_propinfo_set_enum,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
+
 /* Bit */
 
 static uint32_t qdev_get_prop_mask(Property *prop)
Signature · 1 line
2.26.2
#10 lore raw

PATCH v3 7/11 hw/core/qdev-properties: Export some integer-related functions

In reply to Philippe Mathieu-Daudé

We are going to split this file and reuse these static functions. Declare them in the local "qdev-prop-internal.h" header.

---
v3:
Also export qdev_propinfo_get_size32 introduced in commits 914e74cda9 ("qdev-properties: add size32 property type") and 031ffd9a61 ("qdev-properties: add getter for size32 and blocksize").

---
 hw/core/qdev-prop-internal.h | 11 +++++++++
 hw/core/qdev-properties.c    | 46 +++++++++++++++++++-----------------
 2 files changed, 35 insertions(+), 22 deletions(-)
hw/core/qdev-prop-internal.h +11 -0
index 2a8c9a306a..9cf5cc1d51 100644
@@ -15,5 +15,16 @@ void qdev_propinfo_set_enum(Object *obj, Visitor *v, const char *name,
 
 void qdev_propinfo_set_default_value_enum(ObjectProperty *op,
                                           const Property *prop);
+void qdev_propinfo_set_default_value_int(ObjectProperty *op,
+                                         const Property *prop);
+void qdev_propinfo_set_default_value_uint(ObjectProperty *op,
+                                          const Property *prop);
+
+void qdev_propinfo_get_uint16(Object *obj, Visitor *v, const char *name,
+                              void *opaque, Error **errp);
+void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name,
+                             void *opaque, Error **errp);
+void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name,
+                              void *opaque, Error **errp);
 
 #endif
hw/core/qdev-properties.c +24 -22

134 lines not on this page · raw message

Signature · 1 line
2.26.2
#11 lore raw

PATCH v3 8/11 hw/core/qdev-properties: Extract system-mode specific properties

In reply to Philippe Mathieu-Daudé

Move properties specific to machines into a separate file.

---
v3: Also move Reserved Region introduced in commit f78069253c
("qdev: Introduce DEFINE_PROP_RESERVED_REGION").

---
 hw/core/qdev-properties-system.c | 687 ++++++++++++++++++++++++++++++-
 hw/core/qdev-properties.c        | 674 ------------------------------
 2 files changed, 679 insertions(+), 682 deletions(-)
hw/core/qdev-properties-system.c +679 -8
index b29daf4fb5..49bdd12581 100644
@@ -11,19 +11,25 @@
  */
 
 #include "qemu/osdep.h"
-#include "audio/audio.h"
-#include "net/net.h"
 #include "hw/qdev-properties.h"
 #include "qapi/error.h"
+#include "qapi/visitor.h"
+#include "qapi/qapi-types-block.h"
+#include "qapi/qapi-types-machine.h"
+#include "qapi/qapi-types-migration.h"
 #include "qapi/qmp/qerror.h"
+#include "qemu/ctype.h"
+#include "qemu/cutils.h"
+#include "qemu/units.h"
+#include "qemu/error-report.h"
+#include "qdev-prop-internal.h"
+
+#include "audio/audio.h"
+#include "chardev/char-fe.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/block/block.h"
-#include "net/hub.h"
-#include "qapi/visitor.h"
-#include "chardev/char-fe.h"
-#include "sysemu/iothread.h"
-#include "sysemu/tpm_backend.h"
+#include "net/net.h"
+#include "hw/pci/pci.h"
 
 static bool check_prop_still_unset(DeviceState *dev, const char *name,
                                    const void *old_val, const char *new_val,
@@ -280,6 +286,96 @@ const PropertyInfo qdev_prop_chr = {
     .release = release_chr,
 };
 
+/* --- mac address --- */
+
+/*
+ * accepted syntax versions:
+ *   01:02:03:04:05:06
+ *   01-02-03-04-05-06
+ */
+static void get_mac(Object *obj, Visitor *v, const char *name, void *opaque,
+                    Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    MACAddr *mac = qdev_get_prop_ptr(dev, prop);
+    char buffer[2 * 6 + 5 + 1];
+    char *p = buffer;
+
+    snprintf(buffer, sizeof(buffer), "%02x:%02x:%02x:%02x:%02x:%02x",
+             mac->a[0], mac->a[1], mac->a[2],
+             mac->a[3], mac->a[4], mac->a[5]);
+
+    visit_type_str(v, name, &p, errp);
+}
+
+static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
+                    Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    MACAddr *mac = qdev_get_prop_ptr(dev, prop);
+    int i, pos;
+    char *str;
+    const char *p;
+
+    if (dev->realized) {
+        qdev_prop_set_after_realize(dev, name, errp);
+        return;
+    }
+
+    if (!visit_type_str(v, name, &str, errp)) {
+        return;
+    }
+
+    for (i = 0, pos = 0; i < 6; i++, pos += 3) {
+        long val;
+
+        if (!qemu_isxdigit(str[pos])) {
+            goto inval;
+        }
+        if (!qemu_isxdigit(str[pos + 1])) {
+            goto inval;
+        }
+        if (i == 5) {
+            if (str[pos + 2] != '\0') {
+                goto inval;
+            }
+        } else {
+            if (str[pos + 2] != ':' && str[pos + 2] != '-') {
+                goto inval;
+            }
+        }
+        if (qemu_strtol(str + pos, &p, 16, &val) < 0 || val > 0xff) {
+            goto inval;
+        }
+        mac->a[i] = val;
+    }
+    g_free(str);
+    return;
+
+inval:
+    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+    g_free(str);
+}
+
+const PropertyInfo qdev_prop_macaddr = {
+    .name  = "str",
+    .description = "Ethernet 6-byte MAC Address, example: 52:54:00:12:34:56",
+    .get   = get_mac,
+    .set   = set_mac,
+};
+
+void qdev_prop_set_macaddr(DeviceState *dev, const char *name,
+                           const uint8_t *value)
+{
+    char str[2 * 6 + 5 + 1];
+    snprintf(str, sizeof(str), "%02x:%02x:%02x:%02x:%02x:%02x",
+             value[0], value[1], value[2], value[3], value[4], value[5]);
+
+    object_property_set_str(OBJECT(dev), name, str, &error_abort);
+}
+
 /* --- netdev device --- */
 static void get_netdev(Object *obj, Visitor *v, const char *name,
                        void *opaque, Error **errp)
@@ -465,3 +561,578 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
     }
     nd->instantiated = 1;
 }
+
+/* --- lost tick policy --- */
+
+QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int));
+
+const PropertyInfo qdev_prop_losttickpolicy = {
+    .name  = "LostTickPolicy",
+    .enum_table  = &LostTickPolicy_lookup,
+    .get   = qdev_propinfo_get_enum,
+    .set   = qdev_propinfo_set_enum,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
+
+/* --- blocksize --- */
+
+/* lower limit is sector size */
+#define MIN_BLOCK_SIZE          512
+#define MIN_BLOCK_SIZE_STR      "512 B"
+/*
+ * upper limit is arbitrary, 2 MiB looks sufficient for all sensible uses, and
+ * matches qcow2 cluster size limit
+ */
+#define MAX_BLOCK_SIZE          (2 * MiB)
+#define MAX_BLOCK_SIZE_STR      "2 MiB"
+
+static void set_blocksize(Object *obj, Visitor *v, const char *name,
+                          void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+    uint64_t value;
+
+    if (dev->realized) {
+        qdev_prop_set_after_realize(dev, name, errp);
+        return;
+    }
+
+    if (!visit_type_size(v, name, &value, errp)) {
+        return;
+    }
+    /* value of 0 means "unset" */
+    if (value && (value < MIN_BLOCK_SIZE || value > MAX_BLOCK_SIZE)) {
+        error_setg(errp,
+                   "Property %s.%s doesn't take value %" PRIu64
+                   " (minimum: " MIN_BLOCK_SIZE_STR
+                   ", maximum: " MAX_BLOCK_SIZE_STR ")",
+                   dev->id ? : "", name, value);
+        return;
+    }
+
+    /* We rely on power-of-2 blocksizes for bitmasks */
+    if ((value & (value - 1)) != 0) {
+        error_setg(errp,
+                  "Property %s.%s doesn't take value '%" PRId64 "', "
+                  "it's not a power of 2", dev->id ?: "", name, (int64_t)value);
+        return;
+    }
+
+    *ptr = value;
+}
+
+const PropertyInfo qdev_prop_blocksize = {
+    .name  = "size",
+    .description = "A power of two between " MIN_BLOCK_SIZE_STR
+                   " and " MAX_BLOCK_SIZE_STR,
+    .get   = qdev_propinfo_get_size32,
+    .set   = set_blocksize,
+    .set_default_value = qdev_propinfo_set_default_value_uint,
+};
+
+/* --- Block device error handling policy --- */
+
+QEMU_BUILD_BUG_ON(sizeof(BlockdevOnError) != sizeof(int));
+
+const PropertyInfo qdev_prop_blockdev_on_error = {
+    .name = "BlockdevOnError",
+    .description = "Error handling policy, "
+                   "report/ignore/enospc/stop/auto",
+    .enum_table = &BlockdevOnError_lookup,
+    .get = qdev_propinfo_get_enum,
+    .set = qdev_propinfo_set_enum,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
+
+/* --- BIOS CHS translation */
+
+QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int));
+
+const PropertyInfo qdev_prop_bios_chs_trans = {
+    .name = "BiosAtaTranslation",
+    .description = "Logical CHS translation algorithm, "
+                   "auto/none/lba/large/rechs",
+    .enum_table = &BiosAtaTranslation_lookup,
+    .get = qdev_propinfo_get_enum,
+    .set = qdev_propinfo_set_enum,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
+
+/* --- FDC default drive types */
+
+const PropertyInfo qdev_prop_fdc_drive_type = {
+    .name = "FdcDriveType",
+    .description = "FDC drive type, "
+                   "144/288/120/none/auto",
+    .enum_table = &FloppyDriveType_lookup,
+    .get = qdev_propinfo_get_enum,
+    .set = qdev_propinfo_set_enum,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
+
+/* --- MultiFDCompression --- */
+
+const PropertyInfo qdev_prop_multifd_compression = {
+    .name = "MultiFDCompression",
+    .description = "multifd_compression values, "
+                   "none/zlib/zstd",
+    .enum_table = &MultiFDCompression_lookup,
+    .get = qdev_propinfo_get_enum,
+    .set = qdev_propinfo_set_enum,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
+
+/* --- Reserved Region --- */
+
+/*
+ * Accepted syntax:
+ *   <low address>:<high address>:<type>
+ *   where low/high addresses are uint64_t in hexadecimal
+ *   and type is a non-negative decimal integer
+ */
+static void get_reserved_region(Object *obj, Visitor *v, const char *name,
+                                void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    ReservedRegion *rr = qdev_get_prop_ptr(dev, prop);
+    char buffer[64];
+    char *p = buffer;
+    int rc;
+
+    rc = snprintf(buffer, sizeof(buffer), "0x%"PRIx64":0x%"PRIx64":%u",
+                  rr->low, rr->high, rr->type);
+    assert(rc < sizeof(buffer));
+
+    visit_type_str(v, name, &p, errp);
+}
+
+static void set_reserved_region(Object *obj, Visitor *v, const char *name,
+                                void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    ReservedRegion *rr = qdev_get_prop_ptr(dev, prop);
+    Error *local_err = NULL;
+    const char *endptr;
+    char *str;
+    int ret;
+
+    if (dev->realized) {
+        qdev_prop_set_after_realize(dev, name, errp);
+        return;
+    }
+
+    visit_type_str(v, name, &str, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    ret = qemu_strtou64(str, &endptr, 16, &rr->low);
+    if (ret) {
+        error_setg(errp, "start address of '%s'"
+                   " must be a hexadecimal integer", name);
+        goto out;
+    }
+    if (*endptr != ':') {
+        goto separator_error;
+    }
+
+    ret = qemu_strtou64(endptr + 1, &endptr, 16, &rr->high);
+    if (ret) {
+        error_setg(errp, "end address of '%s'"
+                   " must be a hexadecimal integer", name);
+        goto out;
+    }
+    if (*endptr != ':') {
+        goto separator_error;
+    }
+
+    ret = qemu_strtoui(endptr + 1, &endptr, 10, &rr->type);
+    if (ret) {
+        error_setg(errp, "type of '%s'"
+                   " must be a non-negative decimal integer", name);
+    }
+    goto out;
+
+separator_error:
+    error_setg(errp, "reserved region fields must be separated with ':'");
+out:
+    g_free(str);
+    return;
+}
+
+const PropertyInfo qdev_prop_reserved_region = {
+    .name  = "reserved_region",
+    .description = "Reserved Region, example: 0xFEE00000:0xFEEFFFFF:0",
+    .get   = get_reserved_region,
+    .set   = set_reserved_region,
+};
+
+/* --- pci address --- */
+
+/*
+ * bus-local address, i.e. "$slot" or "$slot.$fn"
+ */
+static void set_pci_devfn(Object *obj, Visitor *v, const char *name,
+                          void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    int32_t value, *ptr = qdev_get_prop_ptr(dev, prop);
+    unsigned int slot, fn, n;
+    char *str;
+
+    if (dev->realized) {
+        qdev_prop_set_after_realize(dev, name, errp);
+        return;
+    }
+
+    if (!visit_type_str(v, name, &str, NULL)) {
+        if (!visit_type_int32(v, name, &value, errp)) {
+            return;
+        }
+        if (value < -1 || value > 255) {
+            error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                       name ? name : "null", "pci_devfn");
+            return;
+        }
+        *ptr = value;
+        return;
+    }
+
+    if (sscanf(str, "%x.%x%n", &slot, &fn, &n) != 2) {
+        fn = 0;
+        if (sscanf(str, "%x%n", &slot, &n) != 1) {
+            goto invalid;
+        }
+    }
+    if (str[n] != '\0' || fn > 7 || slot > 31) {
+        goto invalid;
+    }
+    *ptr = slot << 3 | fn;
+    g_free(str);
+    return;
+
+invalid:
+    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+    g_free(str);
+}
+
+static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest,
+                           size_t len)
+{
+    int32_t *ptr = qdev_get_prop_ptr(dev, prop);
+
+    if (*ptr == -1) {
+        return snprintf(dest, len, "<unset>");
+    } else {
+        return snprintf(dest, len, "%02x.%x", *ptr >> 3, *ptr & 7);
+    }
+}
+
+const PropertyInfo qdev_prop_pci_devfn = {
+    .name  = "int32",
+    .description = "Slot and optional function number, example: 06.0 or 06",
+    .print = print_pci_devfn,
+    .get   = qdev_propinfo_get_int32,
+    .set   = set_pci_devfn,
+    .set_default_value = qdev_propinfo_set_default_value_int,
+};
+
+/* --- pci host address --- */
+
+static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
+                                 void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    char buffer[] = "ffff:ff:ff.f";
+    char *p = buffer;
+    int rc = 0;
+
+    /*
+     * Catch "invalid" device reference from vfio-pci and allow the
+     * default buffer representing the non-existent device to be used.
+     */
+    if (~addr->domain || ~addr->bus || ~addr->slot || ~addr->function) {
+        rc = snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%0d",
+                      addr->domain, addr->bus, addr->slot, addr->function);
+        assert(rc == sizeof(buffer) - 1);
+    }
+
+    visit_type_str(v, name, &p, errp);
+}
+
+/*
+ * Parse [<domain>:]<bus>:<slot>.<func>
+ *   if <domain> is not supplied, it's assumed to be 0.
+ */
+static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
+                                 void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
+    char *str, *p;
+    const char *e;
+    unsigned long val;
+    unsigned long dom = 0, bus = 0;
+    unsigned int slot = 0, func = 0;
+
+    if (dev->realized) {
+        qdev_prop_set_after_realize(dev, name, errp);
+        return;
+    }
+
+    if (!visit_type_str(v, name, &str, errp)) {
+        return;
+    }
+
+    p = str;
+    if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0xffff || e == p) {
+        goto inval;
+    }
+    if (*e != ':') {
+        goto inval;
+    }
+    bus = val;
+
+    p = (char *)e + 1;
+    if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0x1f || e == p) {
+        goto inval;
+    }
+    if (*e == ':') {
+        dom = bus;
+        bus = val;
+        p = (char *)e + 1;
+        if (qemu_strtoul(p, &e, 16, &val) < 0 || val > 0x1f || e == p) {
+            goto inval;
+        }
+    }
+    slot = val;
+
+    if (*e != '.') {
+        goto inval;
+    }
+    p = (char *)e + 1;
+    if (qemu_strtoul(p, &e, 10, &val) < 0 || val > 7 || e == p) {
+        goto inval;
+    }
+    func = val;
+
+    if (bus > 0xff) {
+        goto inval;
+    }
+
+    if (*e) {
+        goto inval;
+    }
+
+    addr->domain = dom;
+    addr->bus = bus;
+    addr->slot = slot;
+    addr->function = func;
+
+    g_free(str);
+    return;
+
+inval:
+    error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str);
+    g_free(str);
+}
+
+const PropertyInfo qdev_prop_pci_host_devaddr = {
+    .name = "str",
+    .description = "Address (bus/device/function) of "
+                   "the host device, example: 04:10.0",
+    .get = get_pci_host_devaddr,
+    .set = set_pci_host_devaddr,
+};
+
+/* --- OffAutoPCIBAR off/auto/bar0/bar1/bar2/bar3/bar4/bar5 --- */
+
+const PropertyInfo qdev_prop_off_auto_pcibar = {
+    .name = "OffAutoPCIBAR",
+    .description = "off/auto/bar0/bar1/bar2/bar3/bar4/bar5",
+    .enum_table = &OffAutoPCIBAR_lookup,
+    .get = qdev_propinfo_get_enum,
+    .set = qdev_propinfo_set_enum,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
+
+/* --- PCIELinkSpeed 2_5/5/8/16 -- */
+
+static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
+                                   void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIExpLinkSpeed *p = qdev_get_prop_ptr(dev, prop);
+    int speed;
+
+    switch (*p) {
+    case QEMU_PCI_EXP_LNK_2_5GT:
+        speed = PCIE_LINK_SPEED_2_5;
+        break;
+    case QEMU_PCI_EXP_LNK_5GT:
+        speed = PCIE_LINK_SPEED_5;
+        break;
+    case QEMU_PCI_EXP_LNK_8GT:
+        speed = PCIE_LINK_SPEED_8;
+        break;
+    case QEMU_PCI_EXP_LNK_16GT:
+        speed = PCIE_LINK_SPEED_16;
+        break;
+    default:
+        /* Unreachable */
+        abort();
+    }
+
+    visit_type_enum(v, prop->name, &speed, prop->info->enum_table, errp);
+}
+
+static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name,
+                                   void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIExpLinkSpeed *p = qdev_get_prop_ptr(dev, prop);
+    int speed;
+
+    if (dev->realized) {
+        qdev_prop_set_after_realize(dev, name, errp);
+        return;
+    }
+
+    if (!visit_type_enum(v, prop->name, &speed, prop->info->enum_table,
+                         errp)) {
+        return;
+    }
+
+    switch (speed) {
+    case PCIE_LINK_SPEED_2_5:
+        *p = QEMU_PCI_EXP_LNK_2_5GT;
+        break;
+    case PCIE_LINK_SPEED_5:
+        *p = QEMU_PCI_EXP_LNK_5GT;
+        break;
+    case PCIE_LINK_SPEED_8:
+        *p = QEMU_PCI_EXP_LNK_8GT;
+        break;
+    case PCIE_LINK_SPEED_16:
+        *p = QEMU_PCI_EXP_LNK_16GT;
+        break;
+    default:
+        /* Unreachable */
+        abort();
+    }
+}
+
+const PropertyInfo qdev_prop_pcie_link_speed = {
+    .name = "PCIELinkSpeed",
+    .description = "2_5/5/8/16",
+    .enum_table = &PCIELinkSpeed_lookup,
+    .get = get_prop_pcielinkspeed,
+    .set = set_prop_pcielinkspeed,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
+
+/* --- PCIELinkWidth 1/2/4/8/12/16/32 -- */
+
+static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
+                                   void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIExpLinkWidth *p = qdev_get_prop_ptr(dev, prop);
+    int width;
+
+    switch (*p) {
+    case QEMU_PCI_EXP_LNK_X1:
+        width = PCIE_LINK_WIDTH_1;
+        break;
+    case QEMU_PCI_EXP_LNK_X2:
+        width = PCIE_LINK_WIDTH_2;
+        break;
+    case QEMU_PCI_EXP_LNK_X4:
+        width = PCIE_LINK_WIDTH_4;
+        break;
+    case QEMU_PCI_EXP_LNK_X8:
+        width = PCIE_LINK_WIDTH_8;
+        break;
+    case QEMU_PCI_EXP_LNK_X12:
+        width = PCIE_LINK_WIDTH_12;
+        break;
+    case QEMU_PCI_EXP_LNK_X16:
+        width = PCIE_LINK_WIDTH_16;
+        break;
+    case QEMU_PCI_EXP_LNK_X32:
+        width = PCIE_LINK_WIDTH_32;
+        break;
+    default:
+        /* Unreachable */
+        abort();
+    }
+
+    visit_type_enum(v, prop->name, &width, prop->info->enum_table, errp);
+}
+
+static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name,
+                                   void *opaque, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    Property *prop = opaque;
+    PCIExpLinkWidth *p = qdev_get_prop_ptr(dev, prop);
+    int width;
+
+    if (dev->realized) {
+        qdev_prop_set_after_realize(dev, name, errp);
+        return;
+    }
+
+    if (!visit_type_enum(v, prop->name, &width, prop->info->enum_table,
+                         errp)) {
+        return;
+    }
+
+    switch (width) {
+    case PCIE_LINK_WIDTH_1:
+        *p = QEMU_PCI_EXP_LNK_X1;
+        break;
+    case PCIE_LINK_WIDTH_2:
+        *p = QEMU_PCI_EXP_LNK_X2;
+        break;
+    case PCIE_LINK_WIDTH_4:
+        *p = QEMU_PCI_EXP_LNK_X4;
+        break;
+    case PCIE_LINK_WIDTH_8:
+        *p = QEMU_PCI_EXP_LNK_X8;
+        break;
+    case PCIE_LINK_WIDTH_12:
+        *p = QEMU_PCI_EXP_LNK_X12;
+        break;
+    case PCIE_LINK_WIDTH_16:
+        *p = QEMU_PCI_EXP_LNK_X16;
+        break;
+    case PCIE_LINK_WIDTH_32:
+        *p = QEMU_PCI_EXP_LNK_X32;
+        break;
+    default:
+        /* Unreachable */
+        abort();
+    }
+}
+
+const PropertyInfo qdev_prop_pcie_link_width = {
+    .name = "PCIELinkWidth",
+    .description = "1/2/4/8/12/16/32",
+    .enum_table = &PCIELinkWidth_lookup,
+    .get = get_prop_pcielinkwidth,
+    .set = set_prop_pcielinkwidth,
+    .set_default_value = qdev_propinfo_set_default_value_enum,
+};
hw/core/qdev-properties.c +0 -674

712 lines not on this page · raw message

Signature · 1 line
2.26.2
#12 lore raw

PATCH v3 9/11 hw/core: Add qdev stub for user-mode

In reply to Philippe Mathieu-Daudé

While user-mode does not use peripherals (devices), it uses a CPU which is a device.
In the next commit we will reduce the QAPI generated code for user-mode. Since qdev.c calls qapi_event_send_device_deleted() in device_finalize, let's add a stub for it.

---
v3: Meson rebase

---
 stubs/qdev-system.c | 24 ++++++++++++++++++++++++
 stubs/meson.build   |  1 +
 2 files changed, 25 insertions(+)
 create mode 100644 stubs/qdev-system.c
stubs/qdev-system.c new file +24 -0
new file mode 100644
index 0000000000..2b4b54f621
@@ -0,0 +1,24 @@
+/*
+ * QAPI qdev stubs
+ *
+ * Copyright (c) 2020 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/qapi-events-qdev.h"
+
+void qapi_event_send_device_deleted(bool has_device,
+                                    const char *device, const char *path)
+{
+    /*
+     * Called in user-mode in fork() when a CPUState is qdev::finalize()'d.
+     * Simply ignore the QAPI event there.
+     */
+}
stubs/meson.build +1 -0
index 2e231590e1..71d42c34d6 100644
@@ -25,6 +25,7 @@ stub_ss.add(files('monitor.c'))
 stub_ss.add(files('monitor-core.c'))
 stub_ss.add(files('pci-bus.c'))
 stub_ss.add(files('pci-host-piix.c'))
+stub_ss.add(files('qdev-system.c'))
 stub_ss.add(files('qemu-timer-notify-cb.c'))
 stub_ss.add(files('qmp_memory_device.c'))
 stub_ss.add(files('qtest.c'))
Signature · 1 line
2.26.2
#13 lore raw

PATCH v3 10/11 target/i386: Restrict X86CPUFeatureWord to X86 targets

In reply to Philippe Mathieu-Daudé

Only qemu-system-FOO and qemu-storage-daemon provide QMP monitors, therefore such declarations and definitions are irrelevant for user-mode emulation.

Restricting the x86-specific commands to machine-target.json pulls less QAPI-generated code into user-mode.

Add a stub to satisfy linking in user-mode:

/usr/bin/ld: libqemu-i386-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_get_feature_words':
target/i386/cpu.c:4643: undefined reference to `visit_type_X86CPUFeatureWordInfoList'
collect2: error: ld returned 1 exit status
make: *** [Makefile.ninja:1125: qemu-i386] Error 1

---
v3: Reworded + Meson rebase

---
 qapi/machine-target.json   | 45 ++++++++++++++++++++++++++++++++++++++
 qapi/machine.json          | 42 -----------------------------------
 target/i386/cpu.c          |  2 +-
 target/i386/feature-stub.c | 23 +++++++++++++++++++
 target/i386/meson.build    |  1 +
 5 files changed, 70 insertions(+), 43 deletions(-)
 create mode 100644 target/i386/feature-stub.c
qapi/machine-target.json +45 -0
index 698850cc78..b4d769a53b 100644
@@ -4,6 +4,51 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+##
+# @X86CPURegister32:
+#
+# A X86 32-bit register
+#
+# Since: 1.5
+##
+{ 'enum': 'X86CPURegister32',
+  'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ],
+  'if': 'defined(TARGET_I386)' }
+
+##
+# @X86CPUFeatureWordInfo:
+#
+# Information about a X86 CPU feature word
+#
+# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
+#
+# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
+#                   feature word
+#
+# @cpuid-register: Output register containing the feature bits
+#
+# @features: value of output register, containing the feature bits
+#
+# Since: 1.5
+##
+{ 'struct': 'X86CPUFeatureWordInfo',
+  'data': { 'cpuid-input-eax': 'int',
+            '*cpuid-input-ecx': 'int',
+            'cpuid-register': 'X86CPURegister32',
+            'features': 'int' },
+  'if': 'defined(TARGET_I386)' }
+
+##
+# @DummyForceArrays:
+#
+# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally
+#
+# Since: 2.5
+##
+{ 'struct': 'DummyForceArrays',
+  'data': { 'unused': ['X86CPUFeatureWordInfo'] },
+  'if': 'defined(TARGET_I386)' }
+
 ##
 # @CpuModelInfo:
 #
qapi/machine.json +0 -42

48 lines not on this page · raw message

target/i386/cpu.c +1 -1
index 3ffd877dd5..d45fa217cc 100644
@@ -38,7 +38,7 @@
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "qapi/error.h"
-#include "qapi/qapi-visit-machine.h"
+#include "qapi/qapi-visit-machine-target.h"
 #include "qapi/qapi-visit-run-state.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qerror.h"
target/i386/feature-stub.c new file +23 -0
new file mode 100644
index 0000000000..787c3c7fa1
@@ -0,0 +1,23 @@
+/*
+ * QAPI x86 CPU features stub
+ *
+ * Copyright (c) 2020 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qapi/qapi-visit-machine-target.h"
+
+bool visit_type_X86CPUFeatureWordInfoList(Visitor *v, const char *name,
+                                          X86CPUFeatureWordInfoList **obj,
+                                          Error **errp)
+{
+    g_assert_not_reached();
+}
target/i386/meson.build +1 -0
index e0b71ade56..0c5d9e6caf 100644
@@ -5,6 +5,7 @@ i386_ss.add(files(
   'helper.c',
   'xsave_helper.c',
 ))
+i386_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('feature-stub.c'))
 i386_ss.add(when: 'CONFIG_TCG', if_true: files(
   'bpt_helper.c',
   'cc_helper.c',
Signature · 1 line
2.26.2
#14 lore raw

Re: [PATCH v3 10/11] target/i386: Restrict X86CPUFeatureWord to X86 targets

Quoted 7 lines · Philippe Mathieu-Daudé

Only qemu-system-FOO and qemu-storage-daemon provide QMP monitors, therefore such declarations and definitions are irrelevant for user-mode emulation.

Restricting the x86-specific commands to machine-target.json pulls less QAPI-generated code into user-mode.

Quoted 7 lines

Add a stub to satisfy linking in user-mode:

/usr/bin/ld: libqemu-i386-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_get_feature_words':
target/i386/cpu.c:4643: undefined reference to `visit_type_X86CPUFeatureWordInfoList'
collect2: error: ld returned 1 exit status
make: *** [Makefile.ninja:1125: qemu-i386] Error 1

If you don't want the QAPI definitions in user mode, there's no reason to register the properties in user mode. Wrapping #ifdef around "feature-words" and "filtered-features" registration would be simpler than adding a stub.

Quoted 180 lines

---
v3: Reworded + Meson rebase

---
 qapi/machine-target.json   | 45 ++++++++++++++++++++++++++++++++++++++
 qapi/machine.json          | 42 -----------------------------------
 target/i386/cpu.c          |  2 +-
 target/i386/feature-stub.c | 23 +++++++++++++++++++
 target/i386/meson.build    |  1 +
 5 files changed, 70 insertions(+), 43 deletions(-)
 create mode 100644 target/i386/feature-stub.c
qapi/machine-target.json +45 -0
index 698850cc78..b4d769a53b 100644
@@ -4,6 +4,51 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+##
+# @X86CPURegister32:
+#
+# A X86 32-bit register
+#
+# Since: 1.5
+##
+{ 'enum': 'X86CPURegister32',
+  'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ],
+  'if': 'defined(TARGET_I386)' }
+
+##
+# @X86CPUFeatureWordInfo:
+#
+# Information about a X86 CPU feature word
+#
+# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
+#
+# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
+#                   feature word
+#
+# @cpuid-register: Output register containing the feature bits
+#
+# @features: value of output register, containing the feature bits
+#
+# Since: 1.5
+##
+{ 'struct': 'X86CPUFeatureWordInfo',
+  'data': { 'cpuid-input-eax': 'int',
+            '*cpuid-input-ecx': 'int',
+            'cpuid-register': 'X86CPURegister32',
+            'features': 'int' },
+  'if': 'defined(TARGET_I386)' }
+
+##
+# @DummyForceArrays:
+#
+# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally
+#
+# Since: 2.5
+##
+{ 'struct': 'DummyForceArrays',
+  'data': { 'unused': ['X86CPUFeatureWordInfo'] },
+  'if': 'defined(TARGET_I386)' }
+
 ##
 # @CpuModelInfo:
 #
qapi/machine.json +0 -42
index 72f014bb5b..cb878acdac 100644
@@ -544,48 +544,6 @@
    'dst': 'uint16',
    'val': 'uint8' }}
 
-##
-# @X86CPURegister32:
-#
-# A X86 32-bit register
-#
-# Since: 1.5
-##
-{ 'enum': 'X86CPURegister32',
-  'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ] }
-
-##
-# @X86CPUFeatureWordInfo:
-#
-# Information about a X86 CPU feature word
-#
-# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
-#
-# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
-#                   feature word
-#
-# @cpuid-register: Output register containing the feature bits
-#
-# @features: value of output register, containing the feature bits
-#
-# Since: 1.5
-##
-{ 'struct': 'X86CPUFeatureWordInfo',
-  'data': { 'cpuid-input-eax': 'int',
-            '*cpuid-input-ecx': 'int',
-            'cpuid-register': 'X86CPURegister32',
-            'features': 'int' } }
-
-##
-# @DummyForceArrays:
-#
-# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally
-#
-# Since: 2.5
-##
-{ 'struct': 'DummyForceArrays',
-  'data': { 'unused': ['X86CPUFeatureWordInfo'] } }
-
 ##
 # @NumaCpuOptions:
 #
target/i386/cpu.c +1 -1
index 3ffd877dd5..d45fa217cc 100644
@@ -38,7 +38,7 @@
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "qapi/error.h"
-#include "qapi/qapi-visit-machine.h"
+#include "qapi/qapi-visit-machine-target.h"
 #include "qapi/qapi-visit-run-state.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qerror.h"
target/i386/feature-stub.c new file +23 -0
new file mode 100644
index 0000000000..787c3c7fa1
@@ -0,0 +1,23 @@
+/*
+ * QAPI x86 CPU features stub
+ *
+ * Copyright (c) 2020 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qapi/qapi-visit-machine-target.h"
+
+bool visit_type_X86CPUFeatureWordInfoList(Visitor *v, const char *name,
+                                          X86CPUFeatureWordInfoList **obj,
+                                          Error **errp)
+{
+    g_assert_not_reached();
+}
target/i386/meson.build +1 -0
index e0b71ade56..0c5d9e6caf 100644
@@ -5,6 +5,7 @@ i386_ss.add(files(
   'helper.c',
   'xsave_helper.c',
 ))
+i386_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('feature-stub.c'))
 i386_ss.add(when: 'CONFIG_TCG', if_true: files(
   'bpt_helper.c',
   'cc_helper.c',
Signature · 1 line
2.26.2
Signature · 1 line
Eduardo
#15 lore raw

PATCH v3 11/11 qapi: Restrict code generated for user-mode

In reply to Philippe Mathieu-Daudé

A lot of QAPI generated code is never used by user-mode.

Split out qapi_system_modules and qapi_system_or_tools_modules from the qapi_all_modules array. We now have 3 groups:
- always used
- use by system-mode or tools (usually by the block layer)
- only used by system-mode

---
Resetting due to Meson update:

---
 qapi/meson.build | 51 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 15 deletions(-)
qapi/meson.build +36 -15
index 7c4a89a882..ba9677ba97 100644
@@ -14,39 +14,60 @@ util_ss.add(files(
 ))
 
 qapi_all_modules = [
+  'common',
+  'introspect',
+  'misc',
+]
+
+qapi_system_modules = [
   'acpi',
   'audio',
+  'dump',
+  'machine-target',
+  'machine',
+  'migration',
+  'misc-target',
+  'net',
+  'pci',
+  'qdev',
+  'rdma',
+  'rocker',
+  'tpm',
+  'trace',
+]
+
+# system or tools
+qapi_block_modules = [
   'authz',
   'block-core',
   'block',
   'char',
-  'common',
   'control',
   'crypto',
-  'dump',
   'error',
-  'introspect',
   'job',
-  'machine',
-  'machine-target',
-  'migration',
-  'misc',
-  'misc-target',
-  'net',
   'pragma',
-  'qdev',
-  'pci',
   'qom',
-  'rdma',
-  'rocker',
   'run-state',
   'sockets',
-  'tpm',
-  'trace',
   'transaction',
   'ui',
 ]
 
+if have_system
+  qapi_all_modules += qapi_system_modules
+elif have_user
+  # Temporary kludge because X86CPUFeatureWordInfo is not
+  # restricted to system-mode. This should be removed (along
+  # with target/i386/feature-stub.c) once target/i386/cpu.c
+  # has been cleaned.
+  qapi_all_modules += ['machine-target']
+endif
+
+if have_block
+  qapi_all_modules += qapi_block_modules
+endif
+
 qapi_storage_daemon_modules = [
   'block-core',
   'char',
Signature · 1 line
2.26.2
#16 lore raw

Re: [PATCH v3 11/11] qapi: Restrict code generated for user-mode

Quoted 68 lines · Philippe Mathieu-Daudé

A lot of QAPI generated code is never used by user-mode.

Split out qapi_system_modules and qapi_system_or_tools_modules from the qapi_all_modules array. We now have 3 groups:
- always used
- use by system-mode or tools (usually by the block layer)
- only used by system-mode

---
Resetting due to Meson update:

---
 qapi/meson.build | 51 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 15 deletions(-)
qapi/meson.build +22 -11
index 7c4a89a882..ba9677ba97 100644
@@ -14,39 +14,60 @@ util_ss.add(files(
 ))
 
 qapi_all_modules = [
+  'common',
+  'introspect',
+  'misc',
+]
+
+qapi_system_modules = [
   'acpi',
   'audio',
+  'dump',
+  'machine-target',
+  'machine',
+  'migration',
+  'misc-target',
+  'net',
+  'pci',
+  'qdev',
+  'rdma',
+  'rocker',
+  'tpm',
+  'trace',
+]
+
+# system or tools
+qapi_block_modules = [
   'authz',
   'block-core',
   'block',
   'char',
-  'common',
   'control',
   'crypto',
-  'dump',
   'error',
-  'introspect',
   'job',
-  'machine',
-  'machine-target',
-  'migration',
-  'misc',
-  'misc-target',
-  'net',
   'pragma',
-  'qdev',
-  'pci',

qapi/meson.build util_ss.add(files( · line 55

Quoted 10 lines
qapi/meson.build +0 -4
   'qom',
-  'rdma',
-  'rocker',
   'run-state',
   'sockets',
-  'tpm',
-  'trace',
   'transaction',
   'ui',
 ]

Most of these aren't "block modules". Name the thing qapi_system_or_tools_modules?

qapi/meson.build util_ss.add(files( · line 67

Quoted 11 lines
qapi/meson.build +11 -0
+if have_system
+  qapi_all_modules += qapi_system_modules
+elif have_user
+  # Temporary kludge because X86CPUFeatureWordInfo is not
+  # restricted to system-mode. This should be removed (along
+  # with target/i386/feature-stub.c) once target/i386/cpu.c
+  # has been cleaned.
+  qapi_all_modules += ['machine-target']
+endif
+
+if have_block

Aha, precedence for using "block" as an abbreviation of "system or tools". I find that confusing.

Quoted 6 lines
qapi/meson.build +3 -0
+  qapi_all_modules += qapi_block_modules
+endif
+
 qapi_storage_daemon_modules = [
   'block-core',
   'char',
#17 lore raw

Re: [PATCH v3 11/11] qapi: Restrict code generated for user-mode

Quoted 75 lines · Markus Armbruster
Quoted 73 lines · Philippe Mathieu-Daudé

A lot of QAPI generated code is never used by user-mode.

Split out qapi_system_modules and qapi_system_or_tools_modules from the qapi_all_modules array. We now have 3 groups:
- always used
- use by system-mode or tools (usually by the block layer)
- only used by system-mode

---
Resetting due to Meson update:

---
 qapi/meson.build | 51 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 15 deletions(-)
qapi/meson.build +22 -13
index 7c4a89a882..ba9677ba97 100644
@@ -14,39 +14,60 @@ util_ss.add(files(
 ))
 
 qapi_all_modules = [
+  'common',
+  'introspect',
+  'misc',
+]
+
+qapi_system_modules = [
   'acpi',
   'audio',
+  'dump',
+  'machine-target',
+  'machine',
+  'migration',
+  'misc-target',
+  'net',
+  'pci',
+  'qdev',
+  'rdma',
+  'rocker',
+  'tpm',
+  'trace',
+]
+
+# system or tools
+qapi_block_modules = [
   'authz',
   'block-core',
   'block',
   'char',
-  'common',
   'control',
   'crypto',
-  'dump',
   'error',
-  'introspect',
   'job',
-  'machine',
-  'machine-target',
-  'migration',
-  'misc',
-  'misc-target',
-  'net',
   'pragma',
-  'qdev',
-  'pci',
   'qom',
-  'rdma',
-  'rocker',
   'run-state',
   'sockets',
Quoted 8 lines

qapi/meson.build util_ss.add(files( · line 55

Quoted 5 lines
qapi/meson.build +0 -2
-  'tpm',
-  'trace',
   'transaction',
   'ui',
 ]

Most of these aren't "block modules". Name the thing qapi_system_or_tools_modules?

This is why I used first, then realized this is defined as:
have_block = have_system or have_tools

Quoted 15 lines

qapi/meson.build util_ss.add(files( · line 67

Quoted 12 lines
qapi/meson.build +11 -0
+if have_system
+  qapi_all_modules += qapi_system_modules
+elif have_user
+  # Temporary kludge because X86CPUFeatureWordInfo is not
+  # restricted to system-mode. This should be removed (along
+  # with target/i386/feature-stub.c) once target/i386/cpu.c
+  # has been cleaned.
+  qapi_all_modules += ['machine-target']
+endif
+
+if have_block

Aha, precedence for using "block" as an abbreviation of "system or tools". I find that confusing.

I'll use qapi_system_or_tools_modules back, it is clearer, thanks.

Quoted 8 lines
Quoted 7 lines
qapi/meson.build +3 -0
+  qapi_all_modules += qapi_block_modules
+endif
+
 qapi_storage_daemon_modules = [
   'block-core',
   'char',
#18 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 3 lines · Philippe Mathieu-Daudé

This is the third part of a series reducing user-mode dependencies. By stripping out unused code, the build and testing time is reduced (as is space used by objects).

I'm queueing patches 2-9 on machine-next. Thanks!

Markus, Eric: I can merge the QAPI patches (1, 11) if I get an Acked-by.

I'll send separate comments on patch 10.

Quoted 58 lines

Part 3:
- Extract code not related to user-mode from hw/core/qdev-properties.c
- Reduce user-mode QAPI generated files

Since v2:
- Fixed UuidInfo placed in incorrect json
- Rebased on Meson
- Include X86CPUFeatureWord unmerged from part 2

Since v1:
- Addressed Richard and Paolo review comments

Patches missing review: QAPI ones :)
- #1 'qapi: Restrict query-uuid command to block code'
- #11 'qapi: Restrict code generated for user-mode'

Green CI: https://gitlab.com/philmd/qemu/-/pipelines/196505787

v2: https://www.mail-archive.com/[email protected]/msg688879.html
v1: https://www.mail-archive.com/[email protected]/msg688486.html

Philippe Mathieu-Daudé (11):
qapi: Restrict query-uuid command to block code hw/core/qdev-properties: Use qemu_strtol() in set_mac() handler hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr() hw/core/qdev-properties: Fix code style hw/core/qdev-properties: Export enum-related functions hw/core/qdev-properties: Export qdev_prop_enum hw/core/qdev-properties: Export some integer-related functions hw/core/qdev-properties: Extract system-mode specific properties hw/core: Add qdev stub for user-mode
target/i386: Restrict X86CPUFeatureWord to X86 targets
qapi: Restrict code generated for user-mode

 qapi/block.json                  |  30 ++
 qapi/machine-target.json         |  45 ++
 qapi/machine.json                |  72 ---
 hw/core/qdev-prop-internal.h     |  30 ++
 include/hw/qdev-properties.h     |   1 +
 block/iscsi.c                    |   2 +-
 hw/core/qdev-properties-system.c | 687 ++++++++++++++++++++++++++++-
 hw/core/qdev-properties.c        | 735 ++-----------------------------
 stubs/qdev-system.c              |  24 +
 stubs/uuid.c                     |   2 +-
 target/i386/cpu.c                |   2 +-
 target/i386/feature-stub.c       |  23 +
 qapi/meson.build                 |  51 ++-
 stubs/meson.build                |   5 +-
 target/i386/meson.build          |   1 +
 15 files changed, 915 insertions(+), 795 deletions(-)
 create mode 100644 hw/core/qdev-prop-internal.h
 create mode 100644 stubs/qdev-system.c
 create mode 100644 target/i386/feature-stub.c
Signature · 1 line
2.26.2
Signature · 1 line
Eduardo
#19 lore raw
Quoted 11 lines · Eduardo Habkost
Quoted 3 lines · Philippe Mathieu-Daudé

This is the third part of a series reducing user-mode dependencies. By stripping out unused code, the build and testing time is reduced (as is space used by objects).

I'm queueing patches 2-9 on machine-next. Thanks!

Markus, Eric: I can merge the QAPI patches (1, 11) if I get an Acked-by.

I'll send separate comments on patch 10.

1-8 is fine, but I think 9-11 is too much complication (especially not really future-proof) for the benefit.

Paolo

#20 lore raw
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Eduardo Habkost
Quoted 3 lines · Philippe Mathieu-Daudé

This is the third part of a series reducing user-mode dependencies. By stripping out unused code, the build and testing time is reduced (as is space used by objects).

I'm queueing patches 2-9 on machine-next. Thanks!

Quoted 8 lines
Quoted 5 lines

Markus, Eric: I can merge the QAPI patches (1, 11) if I get an Acked-by.

I'll send separate comments on patch 10.

1-8 is fine, but I think 9-11 is too much complication (especially not really future-proof) for the benefit.

I'll dequeue patch 9 while this is discussed.

Signature · 1 line
Eduardo
#21 lore raw
Quoted 11 lines · Eduardo Habkost
Quoted 10 lines · Paolo Bonzini
Quoted 9 lines · Eduardo Habkost
Quoted 3 lines · Philippe Mathieu-Daudé

This is the third part of a series reducing user-mode dependencies. By stripping out unused code, the build and testing time is reduced (as is space used by objects).

I'm queueing patches 2-9 on machine-next. Thanks!

Markus, Eric: I can merge the QAPI patches (1, 11) if I get an Acked-by.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I'll send separate comments on patch 10.

1-8 is fine, but I think 9-11 is too much complication (especially not really future-proof) for the benefit.

I'll dequeue patch 9 while this is discussed.

Please also dequeue 1 :(

Markus hasn't sent negative comments on 2-8 so these should be OK.

#22 lore raw
In reply to Paolo Bonzini
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Eduardo Habkost
Quoted 3 lines · Philippe Mathieu-Daudé

This is the third part of a series reducing user-mode dependencies. By stripping out unused code, the build and testing time is reduced (as is space used by objects).

I'm queueing patches 2-9 on machine-next. Thanks!

Quoted 8 lines
Quoted 5 lines

Markus, Eric: I can merge the QAPI patches (1, 11) if I get an Acked-by.

I'll send separate comments on patch 10.

1-8 is fine, but I think 9-11 is too much complication (especially not really future-proof) for the benefit.

Isn't qdev considered an internal API for our object and device lifetime handling (which should be shared) versus QAPI which only exists for system emulation and tool integration? That is of course assuming libvirt is never going to want to know about linux-user emulation?

Quoted 2 lines

Paolo

Signature · 1 line
Alex Bennée
#23 lore raw

Il mer 30 set 2020, 20:57 Alex Bennée <[email protected]> ha scritto:

Quoted 7 lines
Quoted 2 lines

1-8 is fine, but I think 9-11 is too much complication (especially not really future-proof) for the benefit.

Isn't qdev considered an internal API for our object and device lifetime handling (which should be shared) versus QAPI which only exists for system emulation and tool integration?

qdev is nothing more than a bunch of QOM classes, and QAPI is an integral part of QOM (though properties, which are used when setting up CPUs in user more emulation)

Therefore, even though most of the QAPI schema is specific to system emulation and tools, a small part is used by common code.

Paolo

Quoted 1 line