Implement early printk in virtio-console

On our S390x Virtio machine we don't have anywhere to display early printks
on, because we don't know about VGA or serial ports.

So instead we just forward everything to the virtio console that we created
anyways.

Signed-off-by: Alexander Graf <agraf@suse.de>

Conflicts:

	hw/s390-virtio.c
This commit is contained in:
Alexander Graf
2009-10-19 12:21:55 +02:00
committed by Andreas Färber
parent 63d9acbe99
commit bf5b9c24c5
4 changed files with 15 additions and 1 deletions

View File

@@ -76,6 +76,9 @@ static int s390_virtio_hcall_notify(const uint64_t *args)
}
} else {
/* Early printk */
uint8_t *p = (uint8_t *)qemu_get_ram_ptr(mem);
VirtIOS390Device *dev = s390_virtio_bus_console(s390_bus);
virtio_console_print_early(dev->vdev, p);
}
return r;
}

View File

@@ -20,6 +20,14 @@ typedef struct VirtConsole {
CharDriverState *chr;
} VirtConsole;
void virtio_console_print_early(VirtIODevice *vdev, uint8_t *buf)
{
VirtIOSerial *vser = (void*)vdev;
VirtIOSerialPort *port = find_port_by_id(vser, 0);
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
qemu_chr_fe_write(vcon->chr, buf, strlen((char*)buf));
}
/* Callback function that's called when the guest sends us data */
static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)

View File

@@ -66,7 +66,7 @@ struct VirtIOSerial {
struct VirtIOSerialPostLoad *post_load;
};
static VirtIOSerialPort *find_port_by_id(VirtIOSerial *vser, uint32_t id)
VirtIOSerialPort *find_port_by_id(VirtIOSerial *vser, uint32_t id)
{
VirtIOSerialPort *port;

View File

@@ -205,4 +205,7 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port);
*/
void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle);
void virtio_console_print_early(VirtIODevice *vdev, uint8_t *buf);
VirtIOSerialPort *find_port_by_id(VirtIOSerial *vser, uint32_t id);
#endif