Commit 9ede2fde19eaf65c07c8bed3936e78dc0ed37412

Authored by aliguori
1 parent c76ee25d

add virtio-console support (Christian Ehrhardt)

This patch adds the virtio console to qemu. This console can be found after the
serial and parallel outputs as another virtual console. In the -nographic case
it is redirected to the null output by default.

Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6315 c046a42c-6fe2-441c-8c8c-71466251a162
Makefile.target
... ... @@ -554,7 +554,7 @@ ifndef CONFIG_USER_ONLY
554 554 OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o
555 555 # virtio has to be here due to weird dependency between PCI and virtio-net.
556 556 # need to fix this properly
557   -OBJS+=virtio.o virtio-blk.o virtio-balloon.o virtio-net.o
  557 +OBJS+=virtio.o virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o
558 558 OBJS+=fw_cfg.o
559 559 ifdef CONFIG_KVM
560 560 OBJS+=kvm.o kvm-all.o
... ...
sysemu.h
... ... @@ -158,6 +158,12 @@ extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
158 158  
159 159 extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
160 160  
  161 +/* virtio consoles */
  162 +
  163 +#define MAX_VIRTIO_CONSOLES 1
  164 +
  165 +extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
  166 +
161 167 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
162 168  
163 169 #ifdef NEED_CPU_H
... ...
... ... @@ -209,6 +209,7 @@ static int no_frame = 0;
209 209 int no_quit = 0;
210 210 CharDriverState *serial_hds[MAX_SERIAL_PORTS];
211 211 CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
  212 +CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
212 213 #ifdef TARGET_I386
213 214 int win2k_install_hack = 0;
214 215 #endif
... ... @@ -4502,6 +4503,8 @@ int main(int argc, char **argv, char **envp)
4502 4503 int serial_device_index;
4503 4504 const char *parallel_devices[MAX_PARALLEL_PORTS];
4504 4505 int parallel_device_index;
  4506 + const char *virtio_consoles[MAX_VIRTIO_CONSOLES];
  4507 + int virtio_console_index;
4505 4508 const char *loadvm = NULL;
4506 4509 QEMUMachine *machine;
4507 4510 const char *cpu_model;
... ... @@ -4575,6 +4578,11 @@ int main(int argc, char **argv, char **envp)
4575 4578 parallel_devices[i] = NULL;
4576 4579 parallel_device_index = 0;
4577 4580  
  4581 + virtio_consoles[0] = "vc:80Cx24C";
  4582 + for(i = 1; i < MAX_VIRTIO_CONSOLES; i++)
  4583 + virtio_consoles[i] = NULL;
  4584 + virtio_console_index = 0;
  4585 +
4578 4586 usb_devices_index = 0;
4579 4587  
4580 4588 nb_net_clients = 0;
... ... @@ -5170,6 +5178,8 @@ int main(int argc, char **argv, char **envp)
5170 5178 parallel_devices[0] = "null";
5171 5179 if (strncmp(monitor_device, "vc", 2) == 0)
5172 5180 monitor_device = "stdio";
  5181 + if (virtio_console_index == 0)
  5182 + virtio_consoles[0] = "null";
5173 5183 }
5174 5184  
5175 5185 #ifndef _WIN32
... ... @@ -5464,6 +5474,22 @@ int main(int argc, char **argv, char **envp)
5464 5474 }
5465 5475 }
5466 5476  
  5477 + for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
  5478 + const char *devname = virtio_consoles[i];
  5479 + if (devname && strcmp(devname, "none")) {
  5480 + char label[32];
  5481 + snprintf(label, sizeof(label), "virtcon%d", i);
  5482 + virtcon_hds[i] = qemu_chr_open(label, devname);
  5483 + if (!virtcon_hds[i]) {
  5484 + fprintf(stderr, "qemu: could not open virtio console '%s'\n",
  5485 + devname);
  5486 + exit(1);
  5487 + }
  5488 + if (strstart(devname, "vc", 0))
  5489 + qemu_chr_printf(virtcon_hds[i], "virtio console%d\r\n", i);
  5490 + }
  5491 + }
  5492 +
5467 5493 if (kvm_enabled()) {
5468 5494 int ret;
5469 5495  
... ...