mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
char: replace qemu_chr_claim/release with qemu_chr_fe_init/deinit
Now that all front end use qemu_chr_fe_init(), we can move chardev claiming in init(), and add a function deinit() to release the chardev and cleanup handlers. The qemu_chr_fe_claim_no_fail() for property are gone, since the property will raise an error instead. In other cases, where there is already an error path, an error is raised instead. Finally, other cases are handled by &error_abort in qemu_chr_fe_init(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20161022095318.17775-19-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
5d300164d0
commit
c39860e6dc
19 changed files with 44 additions and 137 deletions
|
@ -206,13 +206,12 @@ static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque,
|
|||
object_get_typename(obj), prop->name, str);
|
||||
return;
|
||||
}
|
||||
if (qemu_chr_fe_claim(s) != 0) {
|
||||
error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use",
|
||||
object_get_typename(obj), prop->name, str);
|
||||
|
||||
if (!qemu_chr_fe_init(be, s, errp)) {
|
||||
error_prepend(errp, "Property '%s.%s' can't take value '%s': ",
|
||||
object_get_typename(obj), prop->name, str);
|
||||
return;
|
||||
}
|
||||
|
||||
qemu_chr_fe_init(be, s, errp);
|
||||
}
|
||||
|
||||
static void release_chr(Object *obj, const char *name, void *opaque)
|
||||
|
@ -221,10 +220,7 @@ static void release_chr(Object *obj, const char *name, void *opaque)
|
|||
Property *prop = opaque;
|
||||
CharBackend *be = qdev_get_prop_ptr(dev, prop);
|
||||
|
||||
if (be->chr) {
|
||||
qemu_chr_fe_set_handlers(be, NULL, NULL, NULL, NULL, NULL);
|
||||
qemu_chr_fe_release(be->chr);
|
||||
}
|
||||
qemu_chr_fe_deinit(be);
|
||||
}
|
||||
|
||||
PropertyInfo qdev_prop_chr = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue