aboutsummaryrefslogtreecommitdiff
path: root/include/qom
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2021-10-19 10:57:11 +0200
committerMarkus Armbruster <armbru@redhat.com>2021-11-10 06:14:51 +0100
commit1bf4d3294bd48b702530b131e3344860495425fd (patch)
tree96d79ed8d3bcf780ce4df4e61552b616b81437c9 /include/qom
parent0a70bcf18caf7a61d480f8448723c15209d128ef (diff)
monitor: Fix find_device_state() for IDs containing slashes
Recent commit 6952026120 "monitor: Tidy up find_device_state()" assumed the function's argument is "the device's ID or QOM path" (as documented for device_del). It's actually either an absolute QOM path, or a QOM path relative to /machine/peripheral/. Such a relative path is a device ID when it doesn't contain a slash. When it does, the function now always fails. Broke iotest 200, which uses relative path "vda/virtio-backend". It fails because object_resolve_path_component() resolves just one component, not a relative path. The obvious function to resolve relative paths is object_resolve_path(). It picks a parent automatically. Too much magic, we want to specify the parent. Create new object_resolve_path_at() for that, and use it in find_device_state(). Reported-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20211019085711.86377-1-armbru@redhat.com> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qom')
-rw-r--r--include/qom/object.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/qom/object.h b/include/qom/object.h
index faae0d841f..fae096f51c 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1544,6 +1544,18 @@ Object *object_resolve_path_type(const char *path, const char *typename,
bool *ambiguous);
/**
+ * object_resolve_path_at:
+ * @parent: the object in which to resolve the path
+ * @path: the path to resolve
+ *
+ * This is like object_resolve_path(), except paths not starting with
+ * a slash are relative to @parent.
+ *
+ * Returns: The resolved object or NULL on path lookup failure.
+ */
+Object *object_resolve_path_at(Object *parent, const char *path);
+
+/**
* object_resolve_path_component:
* @parent: the object in which to resolve the path
* @part: the component to resolve.