Skip to contentSkip to conversation

chardev: don't abort on attempt to add duplicated chardev

PATCH In review Marc-André Lureau 3 participants 4 messages Jul 6, 2020 – Jul 9, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 chardev: don't abort on attempt to add duplicated chardev

This is a regression from commit d2623129a7dec1d3041ad1221dda1ca49c667532 ("qom: Drop parameter @errp of object_property_add() & friends").

(qemu) chardev-add id=null,backend=null
(qemu) chardev-add id=null,backend=null
Unexpected error in object_property_try_add() at /home/elmarco/src/qemu/qom/object.c:1166:
attempt to add duplicate property 'null' to object (type 'container')

That case is currently not covered in the test suite, but will be with the queued patch "char: fix use-after-free with dup chardev & reconnect".

---
 chardev/char.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
chardev/char.c +4 -1
index e3051295ac3..876e41bb592 100644
@@ -998,7 +998,10 @@ static Chardev *chardev_new(const char *id, const char *typename,
     }
 
     if (id) {
-        object_property_add_child(get_chardevs_root(), id, obj);
+        object_property_try_add_child(get_chardevs_root(), id, obj, &local_err);
+        if (local_err) {
+            goto end;
+        }
         object_unref(obj);
     }
 
Signature · 1 line
2.27.0.90.geebb51ba8c
#1 lore raw
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

CC tpm.o
CC device_tree.o
/tmp/qemu-test/src/chardev/char.c: In function 'chardev_new':
/tmp/qemu-test/src/chardev/char.c:1001:9: error: implicit declaration of function 'object_property_try_add_child' [-Werror=implicit-function-declaration]

         object_property_try_add_child(get_chardevs_root(), id, obj, &local_err);
         ^

/tmp/qemu-test/src/chardev/char.c:1001:9: error: nested extern declaration of 'object_property_try_add_child' [-Werror=nested-externs]
cc1: all warnings being treated as errors
make: *** [chardev/char.o] Error 1
make: *** Waiting for unfinished jobs....
CC cpus-common.o
CC accel/accel.o
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=9c2bd824c6b0443b9d75ae3ed63f68ae', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-iez5j30m/src/docker-src.2020-07-06-14.28.46.1356:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=9c2bd824c6b0443b9d75ae3ed63f68ae
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-iez5j30m/src'
make: *** [docker-run-test-quick@centos7] Error 2

real 2m14.145s
user 0m8.128s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#2 lore raw
In reply to Marc-André Lureau
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

CC hw/acpi/ipmi.o
CC hw/acpi/acpi-stub.o
/tmp/qemu-test/src/chardev/char.c: In function 'chardev_new':
/tmp/qemu-test/src/chardev/char.c:1001:9: error: implicit declaration of function 'object_property_try_add_child'; did you mean 'object_property_add_child'? [-Werror=implicit-function-declaration]

 1001 |         object_property_try_add_child(get_chardevs_root(), id, obj, &local_err);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         object_property_add_child

/tmp/qemu-test/src/chardev/char.c:1001:9: error: nested extern declaration of 'object_property_try_add_child' [-Werror=nested-externs]
cc1: all warnings being treated as errors
make: *** [/tmp/qemu-test/src/rules.mak:69: chardev/char.o] Error 1
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
File "./tests/docker/docker.py", line 669, in <module>
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=5a5c146077564649a10f33f7cd376a96', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-w3u96ywu/src/docker-src.2020-07-06-14.28.31.32389:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=5a5c146077564649a10f33f7cd376a96
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-w3u96ywu/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real 3m3.035s
user 0m8.386s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

Reviewed-by on v1 1/1
#3 lore raw
In reply to Marc-André Lureau
Quoted 4 lines · Marc-André Lureau

This is a regression from commit d2623129a7dec1d3041ad1221dda1ca49c667532 ("qom: Drop parameter @errp of object_property_add() & friends").

Quoted 9 lines

(qemu) chardev-add id=null,backend=null
(qemu) chardev-add id=null,backend=null
Unexpected error in object_property_try_add() at /home/elmarco/src/qemu/qom/object.c:1166:
attempt to add duplicate property 'null' to object (type 'container')

That case is currently not covered in the test suite, but will be with the queued patch "char: fix use-after-free with dup chardev & reconnect".

Please add

Fixes d2623129a7dec1d3041ad1221dda1ca49c667532

Bonus: you can then shorten the hash above for readability.

Quoted 10 lines
---
 chardev/char.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
chardev/char.c +0 -0
index e3051295ac3..876e41bb592 100644

chardev/char.c static Chardev *chardev_new(const char *id, const char *typename, · line 1001

Quoted 5 lines
chardev/char.c +1 -1
@@ -998,7 +998,10 @@ static Chardev *chardev_new(const char *id, const char *typename,
     }
 
     if (id) {
-        object_property_add_child(get_chardevs_root(), id, obj);
+        object_property_try_add_child(get_chardevs_root(), id, obj, &local_err);

Suggest to break this line before &local_err.

chardev/char.c static Chardev *chardev_new(const char *id, const char *typename, · line 1006

Quoted 5 lines
chardev/char.c +3 -0
+        if (local_err) {
+            goto end;
+        }
         object_unref(obj);
     }

Sorry for breaking this.