microvm: make number of virtio transports runtime changeable

This will allow to increase the number of transports in
case we have enough irq lines available for them all.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Sergio Lopez <slp@redhat.com>
Message-id: 20201203105423.10431-5-kraxel@redhat.com
This commit is contained in:
Gerd Hoffmann 2020-12-03 11:54:15 +01:00
parent 94c5a60637
commit c214a7bcb6
2 changed files with 8 additions and 3 deletions

View File

@ -178,8 +178,13 @@ static void microvm_devices_init(MicrovmMachineState *mms)
kvmclock_create(true); kvmclock_create(true);
mms->virtio_irq_base = x86_machine_is_acpi_enabled(x86ms) ? 16 : 5; mms->virtio_irq_base = 5;
for (i = 0; i < VIRTIO_NUM_TRANSPORTS; i++) { mms->virtio_num_transports = 8;
if (x86_machine_is_acpi_enabled(x86ms)) {
mms->virtio_irq_base = 16;
}
for (i = 0; i < mms->virtio_num_transports; i++) {
sysbus_create_simple("virtio-mmio", sysbus_create_simple("virtio-mmio",
VIRTIO_MMIO_BASE + i * 512, VIRTIO_MMIO_BASE + i * 512,
x86ms->gsi[mms->virtio_irq_base + i]); x86ms->gsi[mms->virtio_irq_base + i]);

View File

@ -52,7 +52,6 @@
/* Platform virtio definitions */ /* Platform virtio definitions */
#define VIRTIO_MMIO_BASE 0xfeb00000 #define VIRTIO_MMIO_BASE 0xfeb00000
#define VIRTIO_NUM_TRANSPORTS 8
#define VIRTIO_CMDLINE_MAXLEN 64 #define VIRTIO_CMDLINE_MAXLEN 64
#define GED_MMIO_BASE 0xfea00000 #define GED_MMIO_BASE 0xfea00000
@ -98,6 +97,7 @@ struct MicrovmMachineState {
/* Machine state */ /* Machine state */
uint32_t virtio_irq_base; uint32_t virtio_irq_base;
uint32_t virtio_num_transports;
bool kernel_cmdline_fixed; bool kernel_cmdline_fixed;
Notifier machine_done; Notifier machine_done;
Notifier powerdown_req; Notifier powerdown_req;