]> git.proxmox.com Git - mirror_qemu.git/commit
test-char: Destroy chardev correctly at char_file_test_internal()
authorEduardo Habkost <ehabkost@redhat.com>
Tue, 15 Dec 2020 22:41:32 +0000 (17:41 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 2 Jan 2021 20:03:09 +0000 (21:03 +0100)
commit08bdf5d44f999c92399ff73df00f2ea2c7ee04bd
treeb50c8b6201c80fe66212de729e7c4a6ad027f2a9
parentfacf7c60ee60aab7d73b204ee8c86b90fbc6b3db
test-char: Destroy chardev correctly at char_file_test_internal()

commit 1e419ee68fa5 ("chardev: generate an internal id when none
given") changed the reference ownership semantics of
qemu_chardev_new(NULL, ...): now all chardevs created using
qemu_chardev_new() are added to the /chardevs QOM container, and
the caller does not own a reference to the newly created object.

However, the code at char_file_test_internal() had not been
updated and was calling object_unref() on a chardev object it
didn't own.  This makes the chardev be destroyed, but leaves a
dangling pointer in the /chardev container children list, and
seems to be the cause of the following char_serial_test() crash:

  Unexpected error in object_property_try_add() at ../qom/object.c:1220: \
      attempt to add duplicate property 'serial-id' to object (type 'container')
  ERROR test-char - too few tests run (expected 38, got 9)

Update the code to use object_unparent() at the end of
char_file_test_internal(), to make sure the chardev will be
correctly removed from the QOM tree.

Fixes: 1e419ee68fa5 ("chardev: generate an internal id when none given")
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20201215224133.3545901-2-ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tests/test-char.c