summaryrefslogtreecommitdiffstats
path: root/qom
diff options
context:
space:
mode:
authorPeter Maydell2014-03-13 16:33:04 +0100
committerPeter Maydell2014-03-13 16:33:04 +0100
commit57fac92c2d4487d5c45e1ca96df6790f96c9e64c (patch)
treebd6d23260932db3f7663102a5222bc0b6d5bffe2 /qom
parentoslib-posix: Fix build on FreeBSD (diff)
parentblock/raw-win32: bdrv_parse_filename() for hdev (diff)
downloadqemu-57fac92c2d4487d5c45e1ca96df6790f96c9e64c.tar.gz
qemu-57fac92c2d4487d5c45e1ca96df6790f96c9e64c.tar.xz
qemu-57fac92c2d4487d5c45e1ca96df6790f96c9e64c.zip
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request # gpg: Signature made Thu 13 Mar 2014 13:50:49 GMT using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/block-pull-request: (24 commits) block/raw-win32: bdrv_parse_filename() for hdev block/raw-posix: Strip protocol prefix on creation block/raw-posix: bdrv_parse_filename() for cdrom block/raw-posix: bdrv_parse_filename() for floppy block/raw-posix: bdrv_parse_filename() for hdev qemu-io: Fix warnings from static code analysis block: Unlink temporary file qcow2: Don't write with BDRV_O_INCOMING qcow2: Keep option in qcow2_invalidate_cache() qmp: add query-iothreads command iothread: stash thread ID away dataplane: replace internal thread with IOThread iothread: add "iothread" qdev property type qdev: make get_pointer() handle temporary strings iothread: add I/O thread object aio: add aio_context_acquire() and aio_context_release() rfifolock: add recursive FIFO lock object: add object_get_canonical_path_component() block: Rewrite the snapshot authorization mechanism for block filters. iotests: Test corruption during COW request ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/qom/object.c b/qom/object.c
index c88909c6b6..a2a1ffa1b3 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1102,39 +1102,49 @@ void object_property_add_link(Object *obj, const char *name,
g_free(full_type);
}
+gchar *object_get_canonical_path_component(Object *obj)
+{
+ ObjectProperty *prop = NULL;
+
+ g_assert(obj);
+ g_assert(obj->parent != NULL);
+
+ QTAILQ_FOREACH(prop, &obj->parent->properties, node) {
+ if (!object_property_is_child(prop)) {
+ continue;
+ }
+
+ if (prop->opaque == obj) {
+ return g_strdup(prop->name);
+ }
+ }
+
+ /* obj had a parent but was not a child, should never happen */
+ g_assert_not_reached();
+ return NULL;
+}
+
gchar *object_get_canonical_path(Object *obj)
{
Object *root = object_get_root();
- char *newpath = NULL, *path = NULL;
+ char *newpath, *path = NULL;
while (obj != root) {
- ObjectProperty *prop = NULL;
-
- g_assert(obj->parent != NULL);
-
- QTAILQ_FOREACH(prop, &obj->parent->properties, node) {
- if (!object_property_is_child(prop)) {
- continue;
- }
+ char *component = object_get_canonical_path_component(obj);
- if (prop->opaque == obj) {
- if (path) {
- newpath = g_strdup_printf("%s/%s", prop->name, path);
- g_free(path);
- path = newpath;
- } else {
- path = g_strdup(prop->name);
- }
- break;
- }
+ if (path) {
+ newpath = g_strdup_printf("%s/%s", component, path);
+ g_free(component);
+ g_free(path);
+ path = newpath;
+ } else {
+ path = component;
}
- g_assert(prop != NULL);
-
obj = obj->parent;
}
- newpath = g_strdup_printf("/%s", path);
+ newpath = g_strdup_printf("/%s", path ? path : "");
g_free(path);
return newpath;