[PATCH] chardev: don't abort on attempt to add duplicated chardev

Marc-André Lureau posted 1 patch 3 years, 9 months ago
Test FreeBSD passed
Test docker-quick@centos7 failed
Test checkpatch passed
Test docker-mingw@fedora failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200706182156.334207-1-marcandre.lureau@redhat.com
chardev/char.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[PATCH] chardev: don't abort on attempt to add duplicated chardev
Posted by Marc-André Lureau 3 years, 9 months ago
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".

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 chardev/char.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/chardev/char.c b/chardev/char.c
index e3051295ac3..876e41bb592 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -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);
     }
 
-- 
2.27.0.90.geebb51ba8c


Re: [PATCH] chardev: don't abort on attempt to add duplicated chardev
Posted by no-reply@patchew.org 3 years, 9 months ago
Patchew URL: https://patchew.org/QEMU/20200706182156.334207-1-marcandre.lureau@redhat.com/



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/20200706182156.334207-1-marcandre.lureau@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [PATCH] chardev: don't abort on attempt to add duplicated chardev
Posted by no-reply@patchew.org 3 years, 9 months ago
Patchew URL: https://patchew.org/QEMU/20200706182156.334207-1-marcandre.lureau@redhat.com/



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/20200706182156.334207-1-marcandre.lureau@redhat.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [PATCH] chardev: don't abort on attempt to add duplicated chardev
Posted by Markus Armbruster 3 years, 9 months ago
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> 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".
>

Please add

  Fixes: d2623129a7dec1d3041ad1221dda1ca49c667532

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

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  chardev/char.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/chardev/char.c b/chardev/char.c
> index e3051295ac3..876e41bb592 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -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.

> +        if (local_err) {
> +            goto end;
> +        }
>          object_unref(obj);
>      }

Sorry for breaking this.

Reviewed-by: Markus Armbruster <armbru@redhat.com>