From ec64213c4d482ee4d15b34511441eaecdd002adf Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Fri, 19 Mar 2010 17:36:43 +0530 Subject: virtio: console: Generate a kobject CHANGE event on adding 'name' attribute When the host lets us know what 'name' a port is assigned, we create the sysfs 'name' attribute. Generate a 'change' event after this so that udev wakes up and acts on the rules for virtio-ports (currently there's only one rule that creates a symlink from the 'name' to the actual char device). Signed-off-by: Amit Shah Signed-off-by: Michael S. Tsirkin --- drivers/char/virtio_console.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index f404ccfc9c2..67b474b4167 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -947,11 +947,18 @@ static void handle_control_message(struct ports_device *portdev, */ err = sysfs_create_group(&port->dev->kobj, &port_attribute_group); - if (err) + if (err) { dev_err(port->dev, "Error %d creating sysfs device attributes\n", err); - + } else { + /* + * Generate a udev event so that appropriate + * symlinks can be created based on udev + * rules. + */ + kobject_uevent(&port->dev->kobj, KOBJ_CHANGE); + } break; case VIRTIO_CONSOLE_PORT_REMOVE: /* -- cgit v1.2.3-70-g09d2 From 2de16a493cc6153f7fa0b9da12a3862d063e3425 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Fri, 19 Mar 2010 17:36:44 +0530 Subject: virtio: console: Check if port is valid in resize_console The console port could have been hot-unplugged. Check if it is valid before working on it. Signed-off-by: Amit Shah Signed-off-by: Michael S. Tsirkin --- drivers/char/virtio_console.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 67b474b4167..44288ce0cb4 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -681,6 +681,10 @@ static void resize_console(struct port *port) struct virtio_device *vdev; struct winsize ws; + /* The port could have been hot-unplugged */ + if (!port) + return; + vdev = port->portdev->vdev; if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) { vdev->config->get(vdev, -- cgit v1.2.3-70-g09d2