Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 211656
b: refs/heads/master
c: 3eae0ad
h: refs/heads/master
v: v3
  • Loading branch information
Amit Shah authored and Rusty Russell committed Oct 21, 2010
1 parent 4d8c139 commit e0079b3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e062013c7d22e40ee634b818d28fd615db36998e
refs/heads/master: 3eae0adea949d8fdd8fa3e5301192901219d2c64
25 changes: 25 additions & 0 deletions trunk/drivers/char/virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ struct port {
/* The 'name' of the port that we expose via sysfs properties */
char *name;

/* We can notify apps of host connect / disconnect events via SIGIO */
struct fasync_struct *async_queue;

/* The 'id' to identify the port with the Host */
u32 id;

Expand Down Expand Up @@ -815,6 +818,14 @@ static int port_fops_open(struct inode *inode, struct file *filp)
return ret;
}

static int port_fops_fasync(int fd, struct file *filp, int mode)
{
struct port *port;

port = filp->private_data;
return fasync_helper(fd, filp, mode, &port->async_queue);
}

/*
* The file operations that we support: programs in the guest can open
* a console device, read from it, write to it, poll for data and
Expand All @@ -828,6 +839,7 @@ static const struct file_operations port_fops = {
.write = port_fops_write,
.poll = port_fops_poll,
.release = port_fops_release,
.fasync = port_fops_fasync,
};

/*
Expand Down Expand Up @@ -1086,6 +1098,12 @@ static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
return nr_added_bufs;
}

static void send_sigio_to_port(struct port *port)
{
if (port->async_queue && port->guest_connected)
kill_fasync(&port->async_queue, SIGIO, POLL_OUT);
}

static int add_port(struct ports_device *portdev, u32 id)
{
char debugfs_name[16];
Expand All @@ -1108,6 +1126,7 @@ static int add_port(struct ports_device *portdev, u32 id)
port->name = NULL;
port->inbuf = NULL;
port->cons.hvc = NULL;
port->async_queue = NULL;

port->cons.ws.ws_row = port->cons.ws.ws_col = 0;

Expand Down Expand Up @@ -1362,6 +1381,12 @@ static void handle_control_message(struct ports_device *portdev,
spin_lock_irq(&port->outvq_lock);
reclaim_consumed_buffers(port);
spin_unlock_irq(&port->outvq_lock);

/*
* If the guest is connected, it'll be interested in
* knowing the host connection state changed.
*/
send_sigio_to_port(port);
break;
case VIRTIO_CONSOLE_PORT_NAME:
/*
Expand Down

0 comments on commit e0079b3

Please sign in to comment.