Commit 3425e706 authored by Amit Shah's avatar Amit Shah Committed by Rusty Russell
Browse files

virtio: console: Add a __send_control_msg() that can send messages without a valid port



We will introduce control messages that operate on the device as a whole
rather than just ports. Make send_control_msg() a wrapper around
__send_control_msg() which does not need a valid port.

Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent b99fa815
Loading
Loading
Loading
Loading
+11 −5
Original line number Original line Diff line number Diff line
@@ -374,22 +374,22 @@ static bool port_has_data(struct port *port)
	return ret;
	return ret;
}
}


static ssize_t send_control_msg(struct port *port, unsigned int event,
static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id,
				unsigned int value)
				  unsigned int event, unsigned int value)
{
{
	struct scatterlist sg[1];
	struct scatterlist sg[1];
	struct virtio_console_control cpkt;
	struct virtio_console_control cpkt;
	struct virtqueue *vq;
	struct virtqueue *vq;
	unsigned int len;
	unsigned int len;


	if (!use_multiport(port->portdev))
	if (!use_multiport(portdev))
		return 0;
		return 0;


	cpkt.id = port->id;
	cpkt.id = port_id;
	cpkt.event = event;
	cpkt.event = event;
	cpkt.value = value;
	cpkt.value = value;


	vq = port->portdev->c_ovq;
	vq = portdev->c_ovq;


	sg_init_one(sg, &cpkt, sizeof(cpkt));
	sg_init_one(sg, &cpkt, sizeof(cpkt));
	if (virtqueue_add_buf(vq, sg, 1, 0, &cpkt) >= 0) {
	if (virtqueue_add_buf(vq, sg, 1, 0, &cpkt) >= 0) {
@@ -400,6 +400,12 @@ static ssize_t send_control_msg(struct port *port, unsigned int event,
	return 0;
	return 0;
}
}


static ssize_t send_control_msg(struct port *port, unsigned int event,
				unsigned int value)
{
	return __send_control_msg(port->portdev, port->id, event, value);
}

static ssize_t send_buf(struct port *port, void *in_buf, size_t in_count)
static ssize_t send_buf(struct port *port, void *in_buf, size_t in_count)
{
{
	struct scatterlist sg[1];
	struct scatterlist sg[1];