mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
qemu-char: Add qemu_chr_fe_claim / _release helper functions
Add qemu_chr_fe_claim / _release helper functions for properly dealing with avail_connections. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Message-id: 1364412581-3672-2-git-send-email-hdegoede@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
4dbb9ed326
commit
44c473decd
3 changed files with 54 additions and 3 deletions
|
@ -123,11 +123,10 @@ static int parse_chr(DeviceState *dev, const char *str, void **ptr)
|
|||
if (chr == NULL) {
|
||||
return -ENOENT;
|
||||
}
|
||||
if (chr->avail_connections < 1) {
|
||||
if (qemu_chr_fe_claim(chr) != 0) {
|
||||
return -EEXIST;
|
||||
}
|
||||
*ptr = chr;
|
||||
--chr->avail_connections;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -140,7 +139,7 @@ static void release_chr(Object *obj, const char *name, void *opaque)
|
|||
|
||||
if (chr) {
|
||||
qemu_chr_add_handlers(chr, NULL, NULL, NULL, NULL);
|
||||
++chr->avail_connections;
|
||||
qemu_chr_fe_release(chr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue