mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03: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
23
qemu-char.c
23
qemu-char.c
|
@ -3452,6 +3452,29 @@ int qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond,
|
|||
return tag;
|
||||
}
|
||||
|
||||
int qemu_chr_fe_claim(CharDriverState *s)
|
||||
{
|
||||
if (s->avail_connections < 1) {
|
||||
return -1;
|
||||
}
|
||||
s->avail_connections--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void qemu_chr_fe_claim_no_fail(CharDriverState *s)
|
||||
{
|
||||
if (qemu_chr_fe_claim(s) != 0) {
|
||||
fprintf(stderr, "%s: error chardev \"%s\" already used\n",
|
||||
__func__, s->label);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void qemu_chr_fe_release(CharDriverState *s)
|
||||
{
|
||||
s->avail_connections++;
|
||||
}
|
||||
|
||||
void qemu_chr_delete(CharDriverState *chr)
|
||||
{
|
||||
QTAILQ_REMOVE(&chardevs, chr, next);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue