qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kusanagi Kouichi <slash@ac.auone-net.jp>
To: Amit Shah <amit.shah@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v3 2/2] virtio-console: Notify resize to the guest.
Date: Mon, 3 May 2010 13:58:13 +0900	[thread overview]
Message-ID: <20100503045814.0AE306AC03C@msa102.auone-net.jp> (raw)
In-Reply-To: <20100430104338.GA27314@amit-x200.redhat.com>

I tested this patch as follows:
I put printf()s into involved functions. Then ran qemu on a terminal
emulator, and resized it.
The guest kernel gets initial size, and follows host resize. Both
singleport and multiport work.

v3:
 If multiport is enabled, send the control message. If not, send a config space update.

v2:
 Rename virtio_serial_resize to virtio_serial_resize_console.

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
---
 hw/virtio-console.c    |    3 +++
 hw/virtio-serial-bus.c |   15 +++++++++++++++
 hw/virtio-serial.h     |   11 +++++++++--
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index caea11f..58246d1 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -55,6 +55,9 @@ static void chr_event(void *opaque, int event)
     case CHR_EVENT_CLOSED:
         virtio_serial_close(&vcon->port);
         break;
+    case CHR_EVENT_RESIZE:
+        virtio_serial_resize_console(&vcon->port, vcon->chr->rows, vcon->chr->cols);
+        break;
     }
 }
 
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 97694d5..8766f1d 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -205,6 +205,20 @@ int virtio_serial_close(VirtIOSerialPort *port)
     return 0;
 }
 
+void virtio_serial_resize_console(VirtIOSerialPort *port, int rows, int cols)
+{
+    VirtIOSerial *vser = port->vser;
+
+    vser->config.rows = rows;
+    vser->config.cols = cols;
+
+    if (use_multiport(vser)) {
+        send_control_event(port, VIRTIO_CONSOLE_RESIZE, 0);
+    } else {
+        virtio_notify_config(&vser->vdev);
+    }
+}
+
 /* Individual ports/apps call this function to write to the guest. */
 ssize_t virtio_serial_write(VirtIOSerialPort *port, const uint8_t *buf,
                             size_t size)
@@ -425,6 +439,7 @@ static uint32_t get_features(VirtIODevice *vdev, uint32_t features)
 
     vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
 
+    features |= (1 << VIRTIO_CONSOLE_F_SIZE);
     if (vser->bus->max_nr_ports > 1) {
         features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
     }
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index a93b545..b51a040 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -25,14 +25,16 @@
 #define VIRTIO_ID_CONSOLE		3
 
 /* Features supported */
+#define VIRTIO_CONSOLE_F_SIZE		0
 #define VIRTIO_CONSOLE_F_MULTIPORT	1
 
 #define VIRTIO_CONSOLE_BAD_ID           (~(uint32_t)0)
 
 struct virtio_console_config {
     /*
-     * These two fields are used by VIRTIO_CONSOLE_F_SIZE which
-     * isn't implemented here yet
+     * These two fields hold the size of the underlying chardev.
+     * When it resized, the guest is notified by the control message
+     * if multiport is enabled, or by a config space update if not.
      */
     uint16_t cols;
     uint16_t rows;
@@ -165,6 +167,11 @@ int virtio_serial_open(VirtIOSerialPort *port);
 int virtio_serial_close(VirtIOSerialPort *port);
 
 /*
+ * Notify resize to the guest
+ */
+void virtio_serial_resize_console(VirtIOSerialPort *port, int rows, int cols);
+
+/*
  * Send data to Guest
  */
 ssize_t virtio_serial_write(VirtIOSerialPort *port, const uint8_t *buf,
-- 
1.7.1

  reply	other threads:[~2010-05-03  4:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16 11:42 [Qemu-devel] [PATCH 2/2] virtio-console: Notify resize to the guest Kusanagi Kouichi
2010-04-16 13:02 ` Amit Shah
2010-04-29  7:12   ` Kusanagi Kouichi
2010-04-29 10:47     ` Amit Shah
2010-04-29 12:36       ` Kusanagi Kouichi
2010-04-29 12:49         ` Amit Shah
2010-04-30  8:12           ` [Qemu-devel] [PATCH v2 " Kusanagi Kouichi
2010-04-30 10:43             ` [Qemu-devel] " Amit Shah
2010-05-03  4:58               ` Kusanagi Kouichi [this message]
2010-05-03  6:37                 ` [Qemu-devel] Re: [PATCH v3 " Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100503045814.0AE306AC03C@msa102.auone-net.jp \
    --to=slash@ac.auone-net.jp \
    --cc=amit.shah@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).