Skip to content

Commit

Permalink
qemu-char: Cleanup: consolidate fe_open/fe_close into fe_set_open
Browse files Browse the repository at this point in the history
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Message-id: 1364292483-16564-6-git-send-email-hdegoede@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
jwrdegoede authored and Anthony Liguori committed Mar 27, 2013
1 parent 1908322 commit 8e25daa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
4 changes: 2 additions & 2 deletions hw/virtio-console.c
Expand Up @@ -74,7 +74,7 @@ static void guest_open(VirtIOSerialPort *port)
if (!vcon->chr) {
return;
}
qemu_chr_fe_open(vcon->chr);
qemu_chr_fe_set_open(vcon->chr, 1);
}

/* Callback function that's called when the guest closes the port */
Expand All @@ -85,7 +85,7 @@ static void guest_close(VirtIOSerialPort *port)
if (!vcon->chr) {
return;
}
qemu_chr_fe_close(vcon->chr);
qemu_chr_fe_set_open(vcon->chr, 0);
}

/* Readiness of the guest to accept data on a port */
Expand Down
17 changes: 4 additions & 13 deletions include/char/char.h
Expand Up @@ -129,21 +129,12 @@ void qemu_chr_delete(CharDriverState *chr);
void qemu_chr_fe_set_echo(struct CharDriverState *chr, bool echo);

/**
* @qemu_chr_fe_open:
* @qemu_chr_fe_set_open:
*
* Open a character backend. This function call is an indication that the
* front end is ready to begin doing I/O.
* Set character frontend open status. This is an indication that the
* front end is ready (or not) to begin doing I/O.
*/
void qemu_chr_fe_open(struct CharDriverState *chr);

/**
* @qemu_chr_fe_close:
*
* Close a character backend. This function call indicates that the front end
* no longer is able to process I/O. To process I/O again, the front end will
* call @qemu_chr_fe_open.
*/
void qemu_chr_fe_close(struct CharDriverState *chr);
void qemu_chr_fe_set_open(struct CharDriverState *chr, int fe_open);

/**
* @qemu_chr_fe_printf:
Expand Down
24 changes: 6 additions & 18 deletions qemu-char.c
Expand Up @@ -238,11 +238,7 @@ void qemu_chr_add_handlers(CharDriverState *s,
s->chr_update_read_handler(s);

if (!s->explicit_fe_open) {
if (fe_open) {
qemu_chr_fe_open(s);
} else {
qemu_chr_fe_close(s);
}
qemu_chr_fe_set_open(s, fe_open);
}

/* We're connecting to an already opened device, so let's make sure we
Expand Down Expand Up @@ -3423,24 +3419,16 @@ void qemu_chr_fe_set_echo(struct CharDriverState *chr, bool echo)
}
}

void qemu_chr_fe_open(struct CharDriverState *chr)
void qemu_chr_fe_set_open(struct CharDriverState *chr, int fe_open)
{
if (chr->fe_open) {
if (chr->fe_open == fe_open) {
return;
}
chr->fe_open = 1;
if (chr->chr_guest_open) {
chr->fe_open = fe_open;
if (fe_open && chr->chr_guest_open) {
chr->chr_guest_open(chr);
}
}

void qemu_chr_fe_close(struct CharDriverState *chr)
{
if (!chr->fe_open) {
return;
}
chr->fe_open = 0;
if (chr->chr_guest_close) {
if (!fe_open && chr->chr_guest_close) {
chr->chr_guest_close(chr);
}
}
Expand Down

0 comments on commit 8e25daa

Please sign in to comment.