Skip to contentSkip to conversation

Multiple ports for virtio-console

Qemu-devel In review Amit Shah 2 participants 15 messages Sep 11, 2009 – Sep 14, 2009

lore
Share & tools
lore

Amit Shah

author
#0 lore raw

Hello,

This is the patchset spun against current qemu-master.

There are a few fixes since the last send:
- Use a bitmap for the guest_connected bit during save/restore (instead of sending a separate byte for each bit)
- Cleanups in the in-qemu api patch
- vnc patch now works for all the vnc displays (didn't earlier)

However the vnc patch is just meant to show how the api can be used; I don't really intend it to be applied without any userspace tools to get the clipboards in sync.

This has been working well in my testing for a while now. I've tested migration, combinations of old kernel/new qemu, old qemu/new kernel and new kernel/new qemu and it all works well.

Please apply.
Amit

author
#1 lore raw

PATCH 1/5 char: Emit 'OPENED' events on char device open

Notify users of the char interface whenever the file / connection is opened.

The existing RESET event is triggered when the qemu char state is reset as well; which may not be as interesting as char device open events.

---
 qemu-char.c |   14 +++++++++++++-
 qemu-char.h |    1 +
 2 files changed, 14 insertions(+), 1 deletions(-)
qemu-char.c +13 -1
index c25ed1c..5fe882a 100644
@@ -474,6 +474,8 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv)
     chr->chr_write = mux_chr_write;
     chr->chr_update_read_handler = mux_chr_update_read_handler;
     chr->chr_accept_input = mux_chr_accept_input;
+
+    qemu_chr_event(chr, CHR_EVENT_OPENED);
     return chr;
 }
 
@@ -622,6 +624,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
     chr->chr_close = fd_chr_close;
 
     qemu_chr_reset(chr);
+    qemu_chr_event(chr, CHR_EVENT_OPENED);
 
     return chr;
 }
@@ -913,8 +916,10 @@ static void pty_chr_state(CharDriverState *chr, int connected)
          * the virtual device linked to our pty. */
         qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 1000);
     } else {
-        if (!s->connected)
+        if (!s->connected) {
             qemu_chr_reset(chr);
+            qemu_chr_event(chr, CHR_EVENT_OPENED);
+        }
         s->connected = 1;
     }
 }
@@ -1152,6 +1157,7 @@ static CharDriverState *qemu_chr_open_tty(const char *filename)
     }
     chr->chr_ioctl = tty_serial_ioctl;
     qemu_chr_reset(chr);
+    qemu_chr_event(chr, CHR_EVENT_OPENED);
     return chr;
 }
 #else  /* ! __linux__ && ! __sun__ */
@@ -1297,6 +1303,7 @@ static CharDriverState *qemu_chr_open_pp(const char *filename)
     chr->opaque = drv;
 
     qemu_chr_reset(chr);
+    qemu_chr_event(chr, CHR_EVENT_OPENED);
 
     return chr;
 }
@@ -1576,6 +1583,7 @@ static CharDriverState *qemu_chr_open_win(const char *filename)
         return NULL;
     }
     qemu_chr_reset(chr);
+    qemu_chr_event(chr, CHR_EVENT_OPENED);
     return chr;
 }
 
@@ -1675,6 +1683,7 @@ static CharDriverState *qemu_chr_open_win_pipe(const char *filename)
         return NULL;
     }
     qemu_chr_reset(chr);
+    qemu_chr_event(chr, CHR_EVENT_OPENED);
     return chr;
 }
 
@@ -1689,6 +1698,7 @@ static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
     chr->opaque = s;
     chr->chr_write = win_chr_write;
     qemu_chr_reset(chr);
+    qemu_chr_event(chr, CHR_EVENT_OPENED);
     return chr;
 }
 
@@ -1823,6 +1833,7 @@ static CharDriverState *qemu_chr_open_udp(const char *def)
     chr->chr_write = udp_chr_write;
     chr->chr_update_read_handler = udp_chr_update_read_handler;
     chr->chr_close = udp_chr_close;
+    qemu_chr_event(chr, CHR_EVENT_OPENED);
     return chr;
 
 return_err:
@@ -2029,6 +2040,7 @@ static void tcp_chr_connect(void *opaque)
     qemu_set_fd_handler2(s->fd, tcp_chr_read_poll,
                          tcp_chr_read, NULL, chr);
     qemu_chr_reset(chr);
+    qemu_chr_event(chr, CHR_EVENT_OPENED);
 }
 
 #define IACSET(x,a,b,c) x[0] = a; x[1] = b; x[2] = c;
qemu-char.h +1 -0
index df620bc..d725d48 100644
@@ -12,6 +12,7 @@
 #define CHR_EVENT_MUX_IN  3 /* mux-focus was set to this terminal */
 #define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */
 #define CHR_EVENT_CLOSED  5 /* connection closed */
+#define CHR_EVENT_OPENED  6 /* connection opened */
 
 
 #define CHR_IOCTL_SERIAL_SET_PARAMS   1
Signature · 1 line
1.6.2.5
author
#2 lore raw

PATCH 2/5 virtio-console: Add support for multiple ports for generic guest-host communication

This interface extends the virtio-console device to handle multiple ports that present a char device from which bits can be sent and read.

Sample uses for such a device can be obtaining info from the guest like the file systems used, apps installed, etc. for offline usage and logged-in users, clipboard copy-paste, etc. for online usage.

Each port is to be assigned a unique function, for example, the first 4 ports may be reserved for libvirt usage, the next 4 for generic streaming data and so on. This port-function mapping isn't finalised yet.

For requirements, use-cases and some history see

http://www.linux-kvm.org/page/VMchannel_Requirements

---
 hw/pc.c             |   16 +-
 hw/virtio-console.c |  691 +++++++++++++++++++++++++++++++++++++++++++++++----
 hw/virtio-console.h |   55 ++++
 monitor.c           |    7 +
 qemu-monitor.hx     |   10 +
 qemu-options.hx     |    2 +-
 sysemu.h            |   10 +-
 vl.c                |   41 ++--
 8 files changed, 754 insertions(+), 78 deletions(-)
hw/pc.c +11 -5
index d96d756..d5d2542 100644
@@ -1422,11 +1422,17 @@ static void pc_init1(ram_addr_t ram_size,
     }
 
     /* Add virtio console devices */
-    if (pci_enabled) {
-        for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
-            if (virtcon_hds[i]) {
-                pci_create_simple(pci_bus, -1, "virtio-console-pci");
-            }
+    if (pci_enabled && virtcon_nr_ports) {
+        void *dev;
+
+        dev = pci_create_simple(pci_bus, -1, "virtio-console-pci");
+        if (!dev) {
+            fprintf(stderr, "qemu: could not create virtio console pci device\n");
+            exit(1);
+        }
+
+        for (i = 0; i < virtcon_nr_ports; i++) {
+                virtio_console_new_port(dev, virtcon_idx[i]);
         }
     }
 }
hw/virtio-console.c +642 -49

781 lines not on this page · raw message

hw/virtio-console.h +55 -0

71 lines not on this page · raw message

monitor.c +7 -0
index f5f4d0e..1b9e2a3 100644
@@ -47,6 +47,7 @@
 #include "qint.h"
 #include "qdict.h"
 #include "qstring.h"
+#include "hw/virtio-console.h"
 
 //#define DEBUG
 //#define DEBUG_COMPLETION
@@ -1800,6 +1801,12 @@ int monitor_get_fd(Monitor *mon, const char *fdname)
     return -1;
 }
 
+static void do_virtio_console_action(Monitor *mon,
+                                     const char *command, const char *param)
+{
+    virtio_console_monitor_command(mon, command, param);
+}
+
 static const mon_cmd_t mon_cmds[] = {
 #include "qemu-monitor.h"
     { NULL, NULL, },
qemu-monitor.hx +10 -0
index 9f91873..9d75f02 100644
@@ -573,6 +573,16 @@ STEXI
 Change watchdog action.
 ETEXI
 
+    { "virtio-console", "ss?", do_virtio_console_action,
+      "<command> [<parameters>]\n",
+      "virtio-serial write port=3,key=get,value=clipboard\n"
+      "virtio-serial add_port\n"
+      "virtio-serial add_port port=6,name=foo,protocol=keyvalue\n" },
+STEXI
+@item virtio-console
+Hot-add ports or send data to virtio-console port
+ETEXI
+
     { "acl_show", "aclname:s", do_acl_show, "aclname",
       "list rules in the access control list" },
 STEXI
qemu-options.hx +1 -1
index ce38a3b..7608577 100644
@@ -1603,7 +1603,7 @@ ETEXI
 
 DEF("virtioconsole", HAS_ARG, QEMU_OPTION_virtiocon, \
     "-virtioconsole c\n" \
-    "                set virtio console\n")
+    "                define virtio console\n")
 STEXI
 @item -virtioconsole @var{c}
 Set virtio console.
sysemu.h +8 -2
index ac16c21..8eea3ab 100644
@@ -2,6 +2,7 @@
 #define SYSEMU_H
 /* Misc. things related to the system emulator.  */
 
+#include <stdbool.h>
 #include "qemu-common.h"
 #include "qemu-option.h"
 #include "sys-queue.h"
@@ -230,9 +231,14 @@ extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 
 /* virtio consoles */
 
-#define MAX_VIRTIO_CONSOLES 1
+#define MAX_VIRTIO_CONSOLE_PORTS 64 /* Should be a multiple of 32 */
+#define VIRTIO_CONSOLE_PROTO_MAX_LEN 30
 
-extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
+extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLE_PORTS];
+extern uint32_t virtcon_idx[MAX_VIRTIO_CONSOLE_PORTS];
+extern int virtcon_nr_ports;
+extern int init_virtio_console_port(int port, const char *opts);
+extern void *virtio_console_new_port(PCIDevice *dev, uint32_t idx);
 
 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
 
vl.c +20 -21

84 lines not on this page · raw message

Signature · 1 line
1.6.2.5
author
#3 lore raw

PATCH 3/5 virtio-console: Add a in-qemu api for open/read/write/close ports

This is a simple-to-use api for opening a port, registering a callback for read, writing to a port and closing it.

---
 hw/virtio-console.c |   65 ++++++++++++++++++++++++++++++++++++++++++++++++--
 hw/virtio-console.h |    5 ++++
 2 files changed, 67 insertions(+), 3 deletions(-)
hw/virtio-console.c +62 -3
index 9fa35ec..dce7191 100644
@@ -52,6 +52,11 @@ struct VirtIOConsolePort {
 
     TAILQ_HEAD(, VirtIOConsolePortBuffer) unflushed_buffer_head;
 
+    /* Callback that's invoked when we have a buffer that can be consumed
+     * by an in-qemu user of this port
+     */
+    size_t (*read_callback)(const uint8_t *buf, const size_t len);
+
     bool guest_connected;
     bool host_connected;
 };
@@ -150,10 +155,15 @@ static bool has_complete_data(VirtIOConsolePort *port)
 
 static size_t flush_buf(VirtIOConsolePort *port, const uint8_t *buf, size_t len)
 {
-    if (!port->hd) {
-        return 0;
+    int ret;
+
+    ret = 0;
+    if (port->read_callback) {
+        ret = port->read_callback(buf, len);
+    } else if (port->hd) {
+        ret = qemu_chr_write(port->hd, buf, len);
     }
-    return qemu_chr_write(port->hd, buf, len);
+    return ret;
 }
 
 static void flush_queue(VirtIOConsolePort *port)
@@ -431,6 +441,55 @@ static void vcon_event(void *opaque, int event)
     send_control_event(port, &cpkt);
 }
 
+/* Functions for use inside qemu to open and read from/write to ports */
+VirtIOConsolePort *virtio_console_open(uint32_t id,
+                                       size_t(*read_callback)(const uint8_t*buf,
+                                                              const size_t len))
+{
+    VirtIOConsolePort *port;
+    struct virtio_console_control cpkt;
+
+    port = get_port_from_id(id);
+    if (!port) {
+        return NULL;
+    }
+    /* Don't allow opening an already-open port */
+    if (port->host_connected) {
+        return NULL;
+    }
+    port->read_callback = read_callback;
+
+    /* Send port open notification to the guest */
+    port->host_connected = true;
+    cpkt.event = VIRTIO_CONSOLE_PORT_OPEN;
+    cpkt.value = 1;
+    send_control_event(port, &cpkt);
+
+    return port;
+}
+
+void virtio_console_close(VirtIOConsolePort *port)
+{
+    struct virtio_console_control cpkt;
+
+    if (!port)
+        return;
+
+    port->read_callback = NULL;
+
+    cpkt.event = VIRTIO_CONSOLE_PORT_OPEN;
+    cpkt.value = 0;
+    send_control_event(port, &cpkt);
+}
+
+size_t virtio_console_write(VirtIOConsolePort *port, uint8_t *buf, size_t size)
+{
+    if (!port || !port->host_connected) {
+        return 0;
+    }
+    return write_to_port(port, buf, size, false);
+}
+
 static void set_port_active(uint32_t *map, uint32_t idx)
 {
     int i;
hw/virtio-console.h +5 -0
index 9bf6aaf..b06297e 100644
@@ -70,5 +70,10 @@ struct virtio_console_header {
 typedef struct VirtIOConsolePort VirtIOConsolePort;
 void virtio_console_monitor_command(Monitor *mon,
                                     const char *command, const char *param);
+VirtIOConsolePort *virtio_console_open(uint32_t id,
+                                       size_t(*read_callback)(const uint8_t*buf,
+                                                              const size_t len));
+void virtio_console_close(VirtIOConsolePort *port);
+size_t virtio_console_write(VirtIOConsolePort *port, uint8_t *buf, size_t size);
 
 #endif
Signature · 1 line
1.6.2.5
author
#4 lore raw

PATCH 4/5 vnc: add a is_vnc_active() helper

This helper is introduced to query the status of vnc.

---
 vnc.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
vnc.c +9 -1
index 5eaef6a..ff2d4a8 100644
@@ -178,9 +178,17 @@ static void do_info_vnc_client(Monitor *mon, VncState *client)
 #endif
 }
 
-void do_info_vnc(Monitor *mon)
+static int is_vnc_active(void)
 {
     if (vnc_display == NULL || vnc_display->display == NULL) {
+        return 0;
+    }
+    return 1;
+}
+
+void do_info_vnc(Monitor *mon)
+{
+    if (!is_vnc_active()) {
         monitor_printf(mon, "Server: disabled\n");
     } else {
         char *serverAddr = vnc_socket_local_addr("     address: %s:%s\n",
Signature · 1 line
1.6.2.5
author
#5 lore raw

PATCH 5/5 vnc: Send / receive guest clipboard if virtio-console connected to clipboard port

If a connection to the guest clipboard is open, send the host clipboard to the guest and guest clipboard to the host on any change

---
 hw/virtio-console.h |    1 +
 vnc.c               |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)
hw/virtio-console.h +1 -0
index b06297e..caefb2c 100644
@@ -28,6 +28,7 @@
 /* Port number to function mapping */
 #define VIRTIO_CONSOLE_CONSOLE_PORT	0
 #define VIRTIO_CONSOLE_CONSOLE2_PORT	1
+#define VIRTIO_CONSOLE_CLIPBOARD_PORT	3
 
 /* Features supported */
 #define VIRTIO_CONSOLE_F_MULTIPORT	1
vnc.c +38 -0
index ff2d4a8..74602dd 100644
@@ -29,6 +29,7 @@
 #include "qemu_socket.h"
 #include "qemu-timer.h"
 #include "acl.h"
+#include "hw/virtio-console.h"
 
 #define VNC_REFRESH_INTERVAL_BASE 30
 #define VNC_REFRESH_INTERVAL_INC  50
@@ -47,6 +48,7 @@
 
 static VncDisplay *vnc_display; /* needed for info vnc */
 static DisplayChangeListener *dcl;
+static VirtIOConsolePort *virtcon_port;
 
 static char *addr_to_string(const char *format,
                             struct sockaddr_storage *sa,
@@ -671,6 +673,37 @@ static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, i
     vnc_flush(vs);
 }
 
+static size_t vnc_clipboard_data_from_guest(const uint8_t *buf, size_t len)
+{
+    VncState *vs;
+    VncDisplay *vd;
+    DisplayState *ds;
+    size_t orig_len;
+
+    orig_len = len;
+    if (!is_vnc_active()) {
+        /* If there's no display we don't want the caller to buffer any data */
+        return orig_len;
+    }
+
+    ds = vnc_display->ds;
+    vd = ds->opaque;
+
+    for (vs = vd->clients; vs; vs = vs->next) {
+        len = orig_len;
+        vnc_write_u8(vs, 3);  /* ServerCutText */
+        vnc_write_u8(vs, 0);  /* Padding */
+        vnc_write_u8(vs, 0);  /* Padding */
+        vnc_write_u8(vs, 0);  /* Padding */
+        vnc_write_u32(vs, len);
+        while (len--) {
+            vnc_write_u8(vs, *(buf++));
+        }
+        vnc_flush(vs);
+    }
+    return orig_len;
+}
+
 static void vnc_dpy_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
 {
     VncDisplay *vd = ds->opaque;
@@ -1240,6 +1273,7 @@ uint32_t read_u32(uint8_t *data, size_t offset)
 
 static void client_cut_text(VncState *vs, size_t len, uint8_t *text)
 {
+    virtio_console_write(virtcon_port, text, len);
 }
 
 static void check_pointer_type_change(VncState *vs, int absolute)
@@ -2265,6 +2299,7 @@ void vnc_display_close(DisplayState *ds)
     vs->subauth = VNC_AUTH_INVALID;
     vs->tls.x509verify = 0;
 #endif
+    virtio_console_close(virtcon_port);
 }
 
 int vnc_display_password(DisplayState *ds, const char *password)
@@ -2514,5 +2549,8 @@ int vnc_display_open(DisplayState *ds, const char *display)
             vs->display = dpy;
         }
     }
+
+    virtcon_port = virtio_console_open(VIRTIO_CONSOLE_CLIPBOARD_PORT,
+                                       vnc_clipboard_data_from_guest);
     return qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_read, NULL, vs);
 }
Signature · 1 line
1.6.2.5
#6 lore raw

[Qemu-devel] Re: [PATCH 2/5] virtio-console: Add support for multiple ports for generic guest-host communication

In reply to Amit Shah
Quoted 9 lines · Amit Shah

This interface extends the virtio-console device to handle multiple ports that present a char device from which bits can be sent and read.

Sample uses for such a device can be obtaining info from the guest like the file systems used, apps installed, etc. for offline usage and logged-in users, clipboard copy-paste, etc. for online usage.

Quoted 6 lines

Each port is to be assigned a unique function, for example, the first 4 ports may be reserved for libvirt usage, the next 4 for generic streaming data and so on. This port-function mapping isn't finalised yet.

I thought the consensus was that we wanted strings to identify ports such that a scheme like reverse fqdn could be used?

Quoted 18 lines
hw/pc.c +4 -5
index d96d756..d5d2542 100644
@@ -1422,11 +1422,17 @@ static void pc_init1(ram_addr_t ram_size,
     }
 
     /* Add virtio console devices */
-    if (pci_enabled) {
-        for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
-            if (virtcon_hds[i]) {
-                pci_create_simple(pci_bus, -1, "virtio-console-pci");
-            }
+    if (pci_enabled && virtcon_nr_ports) {
+        void *dev;
+
+        dev = pci_create_simple(pci_bus, -1, "virtio-console-pci");

hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 1438

Quoted 10 lines
hw/pc.c +7 -0
+        if (!dev) {
+            fprintf(stderr, "qemu: could not create virtio console pci device\n");
+            exit(1);
+        }
+
+        for (i = 0; i < virtcon_nr_ports; i++) {
+                virtio_console_new_port(dev, virtcon_idx[i]);
         }
     }
 }

If a user does:

qemu -M pc-0.11.0 -virtiocon vc -virtiocon vc

This patch will break that guest. I think the best solution to this is to properly integrate with qdev and the new chardev infrastructure. virtio-console-pci-0.11 should have the old semantics, virtio-console-pci-0.12 should be a bus.

hw/pc.c

Quoted 4 lines

#include "hw.h"

hw/pc.c +2 -0
+#include "monitor.h"
+#include "pci.h"

We don't want to add PCI dependency to virtio console. It isn't always used on platforms with PCI.

hw/pc.c

Quoted 4 lines
hw/pc.c +3 -0
+static VirtIOConsole *virtio_console;
+static struct virtio_console_config virtcon_config;
+static VirtIOConsolePort virtcon_ports[MAX_VIRTIO_CONSOLE_PORTS]

Introducing statics like this indicates something isn't right. Again, I think a proper qdev bus conversion would take care of that.

Quoted 7 lines
hw/pc.c +6 -0
+/* This function gets called from vl.c during initial options
+ * parsing as well as from the monitor to parse the options.
+ * So it's a good idea to not print out anything and just
+ * return values which can become meaningful.
+ */
+int init_virtio_console_port(int port, const char *opts)

hw/pc.c

Quoted 10 lines
hw/pc.c +10 -0
+{
+    char dev[256];
+    const char *prot;
+    const char *idx;
+    uint32_t port_nr;
+    int j, k;
+
+    memset(dev, 0, sizeof(dev));
+    prot = strstr(opts, ",protocol=");
+    idx  = strstr(opts, ",port=");

Need to integrate with QemuOpts.

hw/pc.c

Quoted 3 lines
hw/pc.c +2 -0
+
+    register_savevm("virtio-console", -1, 2, virtio_console_save, virtio_console_load, s);

Should integrate with VMState.

Regards,

Anthony Liguori

author
#7 lore raw

[Qemu-devel] Re: [PATCH 2/5] virtio-console: Add support for multiple ports for generic guest-host communication

Quoted 17 lines · Anthony Liguori
Quoted 9 lines · Amit Shah

This interface extends the virtio-console device to handle multiple ports that present a char device from which bits can be sent and read.

Sample uses for such a device can be obtaining info from the guest like the file systems used, apps installed, etc. for offline usage and logged-in users, clipboard copy-paste, etc. for online usage.

Quoted 6 lines

Each port is to be assigned a unique function, for example, the first 4 ports may be reserved for libvirt usage, the next 4 for generic streaming data and so on. This port-function mapping isn't finalised yet.

Quoted 2 lines

I thought the consensus was that we wanted strings to identify ports such that a scheme like reverse fqdn could be used?

There wasn't any consensus; the discussion just ended abruptly.

That said, I'll have to revisit the discussion to see what the fqdn idea was about.

That, or some other alternative will have to be used.

Quoted 30 lines
Quoted 17 lines
hw/pc.c +5 -5
index d96d756..d5d2542 100644
@@ -1422,11 +1422,17 @@ static void pc_init1(ram_addr_t ram_size,
     }
      /* Add virtio console devices */
-    if (pci_enabled) {
-        for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
-            if (virtcon_hds[i]) {
-                pci_create_simple(pci_bus, -1, "virtio-console-pci");
-            }
+    if (pci_enabled && virtcon_nr_ports) {
+        void *dev;
+
+        dev = pci_create_simple(pci_bus, -1, "virtio-console-pci");
+        if (!dev) {

hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 1438

Quoted 10 lines
hw/pc.c +6 -0
+            fprintf(stderr, "qemu: could not create virtio console pci device\n");
+            exit(1);
+        }
+
+        for (i = 0; i < virtcon_nr_ports; i++) {
+                virtio_console_new_port(dev, virtcon_idx[i]);
         }
     }
 }
 

If a user does:

Quoted 3 lines

qemu -M pc-0.11.0 -virtiocon vc -virtiocon vc

This patch will break that guest. I think the best solution to this is

If there are multiple virtiocon devices specified, the first one will default to port #0. The second one will error out saying port 0 is taken. Isn't different from the current behaviour though.

Quoted 11 lines

to properly integrate with qdev and the new chardev infrastructure. virtio-console-pci-0.11 should have the old semantics, virtio-console-pci-0.12 should be a bus.

hw/pc.c

Quoted 4 lines

#include "hw.h"

hw/pc.c +2 -0
+#include "monitor.h"
+#include "pci.h"

We don't want to add PCI dependency to virtio console. It isn't always used on platforms with PCI.

OK; there's a place where I need the qdev pointer from the PCIDevice. Any other way of obtaining that?

Quoted 19 lines

hw/pc.c

Quoted 4 lines
hw/pc.c +3 -0
+static VirtIOConsole *virtio_console;
+static struct virtio_console_config virtcon_config;
+static VirtIOConsolePort virtcon_ports[MAX_VIRTIO_CONSOLE_PORTS]

Introducing statics like this indicates something isn't right. Again, I think a proper qdev bus conversion would take care of that.

Quoted 11 lines
hw/pc.c +11 -0
+/* This function gets called from vl.c during initial options
+ * parsing as well as from the monitor to parse the options.
+ * So it's a good idea to not print out anything and just
+ * return values which can become meaningful.
+ */
+int init_virtio_console_port(int port, const char *opts)
+{
+    char dev[256];
+    const char *prot;
+    const char *idx;
+    uint32_t port_nr;
Quoted 8 lines

hw/pc.c

Quoted 6 lines
hw/pc.c +5 -0
+    int j, k;
+
+    memset(dev, 0, sizeof(dev));
+    prot = strstr(opts, ",protocol=");
+    idx  = strstr(opts, ",port=");

Need to integrate with QemuOpts.

Wondering if it already entered master.. I'll sync up with kraxel if not.

Quoted 5 lines

hw/pc.c

Quoted 3 lines
hw/pc.c +2 -0
+
+    register_savevm("virtio-console", -1, 2, virtio_console_save, virtio_console_load, s);

Should integrate with VMState.

I don't think virtio devices have been converted yet.

Amit

#8 lore raw

[Qemu-devel] Re: [PATCH 2/5] virtio-console: Add support for multiple ports for generic guest-host communication

Quoted 2 lines · Amit Shah

There wasn't any consensus; the discussion just ended abruptly.

At least Gerd and I were in violent agreement. I don't think anyone disagreed.

Quoted 11 lines
Quoted 6 lines

If a user does:

qemu -M pc-0.11.0 -virtiocon vc -virtiocon vc

This patch will break that guest. I think the best solution to this is

If there are multiple virtiocon devices specified, the first one will default to port #0. The second one will error out saying port 0 is taken. Isn't different from the current behaviour though.

But that's a problem for -M pc-0.11.0. We need to have a way to specify a command line syntax with -M pc-0.11.0 such that the machine created matches what would have been created with qemu-0.11.0. Otherwise, we have no hope of being able to do live migration or save/restore between versions.

Quoted 6 lines
Quoted 2 lines

We don't want to add PCI dependency to virtio console. It isn't always used on platforms with PCI.

OK; there's a place where I need the qdev pointer from the PCIDevice. Any other way of obtaining that?

Why do you need the qdev pointer?

Quoted 7 lines
Quoted 2 lines

Need to integrate with QemuOpts.

Wondering if it already entered master.. I'll sync up with kraxel if not.

Yup, it's been there for a while.

Quoted 9 lines
Quoted 6 lines

hw/virtio-console.c static void virtio_console_handle_input(VirtIODevice *vdev, VirtQueue *vq) · line 730

Quoted 4 lines
hw/virtio-console.c +2 -0
+
+    register_savevm("virtio-console", -1, 2, virtio_console_save, virtio_console_load, s);

Should integrate with VMState.

I don't think virtio devices have been converted yet.

I think that's next on Juan's list.

Regards,

Anthony Liguori

author
#9 lore raw

[Qemu-devel] Re: [PATCH 2/5] virtio-console: Add support for multiple ports for generic guest-host communication

Quoted 6 lines · Anthony Liguori
Quoted 2 lines · Amit Shah

There wasn't any consensus; the discussion just ended abruptly.

At least Gerd and I were in violent agreement. I don't think anyone disagreed.

So how's suggestion about udev making symlinks based on the ports ids?

Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

If a user does:

qemu -M pc-0.11.0 -virtiocon vc -virtiocon vc

This patch will break that guest. I think the best solution to this is

If there are multiple virtiocon devices specified, the first one will default to port #0. The second one will error out saying port 0 is taken. Isn't different from the current behaviour though.

Quoted 5 lines

But that's a problem for -M pc-0.11.0. We need to have a way to specify a command line syntax with -M pc-0.11.0 such that the machine created matches what would have been created with qemu-0.11.0. Otherwise, we have no hope of being able to do live migration or save/restore between versions.

I don't actually know if I understand this completely. However, with the current behaviour, qemu just exits saying something like too many virtio consoles since the current MAX_VIRTIO_CONSOLES is defined to 1.

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

We don't want to add PCI dependency to virtio console. It isn't always used on platforms with PCI.

OK; there's a place where I need the qdev pointer from the PCIDevice. Any other way of obtaining that?

Why do you need the qdev pointer?

To init a chardev in the port hotplug case, qdev_init_chardev() needs the qdev pointer.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Need to integrate with QemuOpts.

Wondering if it already entered master.. I'll sync up with kraxel if not.

Yup, it's been there for a while.

I remembered seeing it in your queue. Anyway it's simple enough and I'll do it.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

+ register_savevm("virtio-console", -1, 2, virtio_console_save, virtio_console_load, s);

Should integrate with VMState.

I don't think virtio devices have been converted yet.

I think that's next on Juan's list.

Right; so we'll talk about that.

Amit

#10 lore raw

[Qemu-devel] Re: [PATCH 2/5] virtio-console: Add support for multiple ports for generic guest-host communication

Quoted 4 lines · Amit Shah
Quoted 2 lines · Anthony Liguori

Amit Shah wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

There wasn't any consensus; the discussion just ended abruptly.

At least Gerd and I were in violent agreement. I don't think anyone disagreed.

So how's suggestion about udev making symlinks based on the ports ids?

That doesn't solve the problem that fqdn solves. fqdn provides a means to avoid having to do centralized port number allocation.

Quoted 8 lines
Quoted 3 lines

that's a problem for -M pc-0.11.0. We need to have a way to specify
a command line syntax with -M pc-0.11.0 such that the machine created matches what would have been created with qemu-0.11.0. Otherwise, we have no hope of being able to do live migration or save/restore between versions.

I don't actually know if I understand this completely. However, with the current behaviour, qemu just exits saying something like too many virtio consoles since the current MAX_VIRTIO_CONSOLES is defined to 1.

Oh, that's goofy. Sorry, I didn't realize that.

Quoted 6 lines
Quoted 2 lines

Why do you need the qdev pointer?

To init a chardev in the port hotplug case, qdev_init_chardev() needs the qdev pointer.

If you converted to a bus, this problem would go away.

Quoted 7 lines
Quoted 2 lines

I think that's next on Juan's list.

Right; so we'll talk about that.

Amit

Regards,

Anthony Liguori

author
#11 lore raw

[Qemu-devel] Re: [PATCH 2/5] virtio-console: Add support for multiple ports for generic guest-host communication

In reply to Anthony Liguori

Hey,

Just a couple of points here:

Quoted 6 lines · Anthony Liguori
Quoted 2 lines · Amit Shah

There wasn't any consensus; the discussion just ended abruptly.

At least Gerd and I were in violent agreement. I don't think anyone disagreed.

I think Gerd was ok with the idea of a symlink and Rusty and I kept saying the port number idea isn't as bad. That does count as a disagreement :-)

Quoted 9 lines
Quoted 7 lines
Quoted 2 lines

Need to integrate with QemuOpts.

Wondering if it already entered master.. I'll sync up with kraxel if not.

Yup, it's been there for a while.

Just checked; it's in your queue but not in master.

Amit

author
#12 lore raw

Re: [Qemu-devel] Re: [PATCH 2/5] virtio-console: Add support for multiple ports for generic guest-host communication

Quoted 20 lines · Amit Shah

Hey,

Just a couple of points here:

Quoted 6 lines · Anthony Liguori
Quoted 2 lines · Amit Shah

There wasn't any consensus; the discussion just ended abruptly.

At least Gerd and I were in violent agreement. I don't think anyone disagreed.

I think Gerd was ok with the idea of a symlink and Rusty and I kept saying the port number idea isn't as bad. That does count as a disagreement :-)

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

Need to integrate with QemuOpts.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Wondering if it already entered master.. I'll sync up with kraxel if not.

Yup, it's been there for a while.

Just checked; it's in your queue but not in master.

Well it shows up in master now. Commit logs show it got pushed on Friday.

Amit

#13 lore raw

Re: [Qemu-devel] Re: [PATCH 2/5] virtio-console: Add support for multiple ports for generic guest-host communication

Quoted 4 lines · Amit Shah

Well it shows up in master now. Commit logs show it got pushed on Friday.

commit e27c88fe9eb26648e4fb282cb3761c41f06ff18a

Author: Gerd Hoffmann <[email protected]>
Date:   Wed Jul 22 16:43:03 2009 +0200

QemuOpts: framework for storing and parsing options.

Regards,

Anthony Liguori

author
#14 lore raw

Re: [Qemu-devel] Re: [PATCH 2/5] virtio-console: Add support for multiple ports for generic guest-host communication

Quoted 10 lines · Anthony Liguori
Quoted 4 lines · Amit Shah

Well it shows up in master now. Commit logs show it got pushed on Friday.

commit e27c88fe9eb26648e4fb282cb3761c41f06ff18a

Author: Gerd Hoffmann <[email protected]>
Date:   Wed Jul 22 16:43:03 2009 +0200

QemuOpts: framework for storing and parsing options.

Oh I was talking about the chardev conversion; most of this depends on that ;-)

Amit