aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2021-10-15 12:08:54 -0700
committerRichard Henderson <richard.henderson@linaro.org>2021-10-15 12:08:54 -0700
commit253e399bab7c83b3411f8eac01840283a9304cb3 (patch)
tree9fd0a3fcf71a9e6b0d6ecc81222688539f572ce2 /include
parent82d88f834c8f7d33ad9529fca80924bc496fcb70 (diff)
parent5dacda5167560b3af8eadbce5814f60ba44b467e (diff)
downloadqemu-253e399bab7c83b3411f8eac01840283a9304cb3.zip
qemu-253e399bab7c83b3411f8eac01840283a9304cb3.tar.gz
qemu-253e399bab7c83b3411f8eac01840283a9304cb3.tar.bz2
Merge remote-tracking branch 'remotes/kwolf/tags/for-upstream' into staging
qdev: Add JSON -device - Add a JSON mode to the -device command line option - net/vhost-{user,vdpa}: Fix device compatibility check - Minor iotests fixes # gpg: Signature made Fri 15 Oct 2021 07:41:22 AM PDT # gpg: using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6 # gpg: issuer "kwolf@redhat.com" # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full] * remotes/kwolf/tags/for-upstream: vl: Enable JSON syntax for -device qdev: Base object creation on QDict rather than QemuOpts virtio-net: Avoid QemuOpts in failover_find_primary_device() virtio-net: Store failover primary opts pointer locally qdev: Add Error parameter to hide_device() callbacks qemu-option: Allow deleting opts during qemu_opts_foreach() softmmu/qdev-monitor: add error handling in qdev_set_id qdev: Make DeviceState.id independent of QemuOpts qdev: Avoid using string visitor for properties iotests/051: Fix typo iotests/245: Fix type for iothread property qom: Reduce use of error_propagate() net/vhost-vdpa: Fix device compatibility check net/vhost-user: Fix device compatibility check net: Introduce NetClientInfo.check_peer_type() Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'include')
-rw-r--r--include/hw/qdev-core.h16
-rw-r--r--include/hw/virtio/virtio-net.h2
-rw-r--r--include/monitor/qdev.h27
-rw-r--r--include/net/net.h2
4 files changed, 41 insertions, 6 deletions
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 4ff19c7..1bad070 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -176,11 +176,11 @@ struct DeviceState {
Object parent_obj;
/*< public >*/
- const char *id;
+ char *id;
char *canonical_path;
bool realized;
bool pending_deleted_event;
- QemuOpts *opts;
+ QDict *opts;
int hotplugged;
bool allow_unplug_during_migration;
BusState *parent_bus;
@@ -201,8 +201,12 @@ struct DeviceListener {
* informs qdev if a device should be visible or hidden. We can
* hide a failover device depending for example on the device
* opts.
+ *
+ * On errors, it returns false and errp is set. Device creation
+ * should fail in this case.
*/
- bool (*hide_device)(DeviceListener *listener, QemuOpts *device_opts);
+ bool (*hide_device)(DeviceListener *listener, const QDict *device_opts,
+ bool from_json, Error **errp);
QTAILQ_ENTRY(DeviceListener) link;
};
@@ -831,13 +835,15 @@ void device_listener_unregister(DeviceListener *listener);
/**
* @qdev_should_hide_device:
- * @opts: QemuOpts as passed on cmdline.
+ * @opts: options QDict
+ * @from_json: true if @opts entries are typed, false for all strings
+ * @errp: pointer to error object
*
* Check if a device should be added.
* When a device is added via qdev_device_add() this will be called,
* and return if the device should be added now or not.
*/
-bool qdev_should_hide_device(QemuOpts *opts);
+bool qdev_should_hide_device(const QDict *opts, bool from_json, Error **errp);
typedef enum MachineInitPhase {
/* current_machine is NULL. */
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index 824a69c..74a10eb 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -209,6 +209,8 @@ struct VirtIONet {
bool failover_primary_hidden;
bool failover;
DeviceListener primary_listener;
+ QDict *primary_opts;
+ bool primary_opts_from_json;
Notifier migration_state;
VirtioNetRssData rss_data;
struct NetRxPkt *rx_pkt;
diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h
index eaa947d..1d57bf6 100644
--- a/include/monitor/qdev.h
+++ b/include/monitor/qdev.h
@@ -9,6 +9,31 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp);
int qdev_device_help(QemuOpts *opts);
DeviceState *qdev_device_add(QemuOpts *opts, Error **errp);
-void qdev_set_id(DeviceState *dev, const char *id);
+DeviceState *qdev_device_add_from_qdict(const QDict *opts,
+ bool from_json, Error **errp);
+
+/**
+ * qdev_set_id: parent the device and set its id if provided.
+ * @dev: device to handle
+ * @id: id to be given to the device, or NULL.
+ *
+ * Returns: the id of the device in case of success; otherwise NULL.
+ *
+ * @dev must be unrealized, unparented and must not have an id.
+ *
+ * If @id is non-NULL, this function tries to setup @dev qom path as
+ * "/peripheral/id". If @id is already taken, it fails. If it succeeds,
+ * the id field of @dev is set to @id (@dev now owns the given @id
+ * parameter).
+ *
+ * If @id is NULL, this function generates a unique name and setups @dev
+ * qom path as "/peripheral-anon/name". This name is not set as the id
+ * of @dev.
+ *
+ * Upon success, it returns the id/name (generated or provided). The
+ * returned string is owned by the corresponding child property and must
+ * not be freed by the caller.
+ */
+const char *qdev_set_id(DeviceState *dev, char *id, Error **errp);
#endif
diff --git a/include/net/net.h b/include/net/net.h
index 5d15080..986288e 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -62,6 +62,7 @@ typedef struct SocketReadState SocketReadState;
typedef void (SocketReadStateFinalize)(SocketReadState *rs);
typedef void (NetAnnounce)(NetClientState *);
typedef bool (SetSteeringEBPF)(NetClientState *, int);
+typedef bool (NetCheckPeerType)(NetClientState *, ObjectClass *, Error **);
typedef struct NetClientInfo {
NetClientDriver type;
@@ -84,6 +85,7 @@ typedef struct NetClientInfo {
SetVnetBE *set_vnet_be;
NetAnnounce *announce;
SetSteeringEBPF *set_steering_ebpf;
+ NetCheckPeerType *check_peer_type;
} NetClientInfo;
struct NetClientState {