aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/pc.c8
-rw-r--r--hw/virtio-console.c20
-rw-r--r--hw/virtio-serial-bus.c6
3 files changed, 24 insertions, 10 deletions
diff --git a/hw/pc.c b/hw/pc.c
index 3a71992..f51afa8 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -624,9 +624,9 @@ static void *bochs_bios_init(void)
* of nodes, one word for each VCPU->node and one word for each node to
* hold the amount of memory.
*/
- numa_fw_cfg = g_malloc0((1 + smp_cpus + nb_numa_nodes) * 8);
+ numa_fw_cfg = g_malloc0((1 + max_cpus + nb_numa_nodes) * 8);
numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes);
- for (i = 0; i < smp_cpus; i++) {
+ for (i = 0; i < max_cpus; i++) {
for (j = 0; j < nb_numa_nodes; j++) {
if (node_cpumask[j] & (1 << i)) {
numa_fw_cfg[i + 1] = cpu_to_le64(j);
@@ -635,10 +635,10 @@ static void *bochs_bios_init(void)
}
}
for (i = 0; i < nb_numa_nodes; i++) {
- numa_fw_cfg[smp_cpus + 1 + i] = cpu_to_le64(node_mem[i]);
+ numa_fw_cfg[max_cpus + 1 + i] = cpu_to_le64(node_mem[i]);
}
fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, (uint8_t *)numa_fw_cfg,
- (1 + smp_cpus + nb_numa_nodes) * 8);
+ (1 + max_cpus + nb_numa_nodes) * 8);
return fw_cfg;
}
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index d3351c8..73d866a 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -27,6 +27,11 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
ssize_t ret;
+ if (!vcon->chr) {
+ /* If there's no backend, we can just say we consumed all data. */
+ return len;
+ }
+
ret = qemu_chr_fe_write(vcon->chr, buf, len);
trace_virtio_console_flush_buf(port->id, len, ret);
@@ -52,6 +57,9 @@ static void guest_open(VirtIOSerialPort *port)
{
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+ if (!vcon->chr) {
+ return;
+ }
qemu_chr_fe_open(vcon->chr);
}
@@ -60,6 +68,9 @@ static void guest_close(VirtIOSerialPort *port)
{
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+ if (!vcon->chr) {
+ return;
+ }
qemu_chr_fe_close(vcon->chr);
}
@@ -109,9 +120,6 @@ static int virtconsole_initfn(VirtIOSerialPort *port)
if (vcon->chr) {
qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
vcon);
- info->have_data = flush_buf;
- info->guest_open = guest_open;
- info->guest_close = guest_close;
}
return 0;
@@ -138,6 +146,9 @@ static VirtIOSerialPortInfo virtconsole_info = {
.is_console = true,
.init = virtconsole_initfn,
.exit = virtconsole_exitfn,
+ .have_data = flush_buf,
+ .guest_open = guest_open,
+ .guest_close = guest_close,
.qdev.props = (Property[]) {
DEFINE_PROP_CHR("chardev", VirtConsole, chr),
DEFINE_PROP_END_OF_LIST(),
@@ -155,6 +166,9 @@ static VirtIOSerialPortInfo virtserialport_info = {
.qdev.size = sizeof(VirtConsole),
.init = virtconsole_initfn,
.exit = virtconsole_exitfn,
+ .have_data = flush_buf,
+ .guest_open = guest_open,
+ .guest_close = guest_close,
.qdev.props = (Property[]) {
DEFINE_PROP_CHR("chardev", VirtConsole, chr),
DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index a4825b9..fe0233f 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -466,13 +466,11 @@ static void handle_output(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOSerial *vser;
VirtIOSerialPort *port;
- VirtIOSerialPortInfo *info;
vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
port = find_port_by_vq(vser, vq);
- info = port ? DO_UPCAST(VirtIOSerialPortInfo, qdev, port->dev.info) : NULL;
- if (!port || !port->host_connected || !info->have_data) {
+ if (!port || !port->host_connected) {
discard_vq_data(vq, vdev);
return;
}
@@ -746,6 +744,8 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
port->vser = bus->vser;
port->bh = qemu_bh_new(flush_queued_data_bh, port);
+ assert(info->have_data);
+
/*
* Is the first console port we're seeing? If so, put it up at
* location 0. This is done for backward compatibility (old