Skip to contentSkip to conversation

hw/riscv/virt.c: Make block devices default to virtio

PATCH Applied Sunil V L 3 participants 4 messages Jun 20, 2024 – Jun 21, 2024 RISC-V

lore
Share & tools
lore

Sunil V L

author
#0 lore raw

PATCH 1/1 hw/riscv/virt.c: Make block devices default to virtio

RISC-V virt is currently missing default type for block devices. Without this being set, proper backend is not created when option like -cdrom is used. So, make the virt board's default block device type be IF_VIRTIO similar to other architectures.

We also need to set no_cdrom to avoid getting a default cdrom device.

---
 hw/riscv/virt.c | 2 ++
 1 file changed, 2 insertions(+)
hw/riscv/virt.c +2 -0
index 8675c3a7d1..b0871b7f81 100644
@@ -1764,6 +1764,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
     mc->init = virt_machine_init;
     mc->max_cpus = VIRT_CPUS_MAX;
     mc->default_cpu_type = TYPE_RISCV_CPU_BASE;
+    mc->block_default_type = IF_VIRTIO;
+    mc->no_cdrom = 1;
     mc->pci_allow_0_address = true;
     mc->possible_cpu_arch_ids = riscv_numa_possible_cpu_arch_ids;
     mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Sunil V L

RISC-V virt is currently missing default type for block devices. Without this being set, proper backend is not created when option like -cdrom is used. So, make the virt board's default block device type be IF_VIRTIO similar to other architectures.

We also need to set no_cdrom to avoid getting a default cdrom device.

---

Quoted 16 lines
  hw/riscv/virt.c | 2 ++
  1 file changed, 2 insertions(+)
hw/riscv/virt.c +2 -0
index 8675c3a7d1..b0871b7f81 100644
@@ -1764,6 +1764,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
      mc->init = virt_machine_init;
      mc->max_cpus = VIRT_CPUS_MAX;
      mc->default_cpu_type = TYPE_RISCV_CPU_BASE;
+    mc->block_default_type = IF_VIRTIO;
+    mc->no_cdrom = 1;
      mc->pci_allow_0_address = true;
      mc->possible_cpu_arch_ids = riscv_numa_possible_cpu_arch_ids;
      mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Sunil V L
Quoted 9 lines · Sunil V L

RISC-V virt is currently missing default type for block devices. Without this being set, proper backend is not created when option like -cdrom is used. So, make the virt board's default block device type be IF_VIRTIO similar to other architectures.

We also need to set no_cdrom to avoid getting a default cdrom device.

Alistair

Quoted 21 lines
---
 hw/riscv/virt.c | 2 ++
 1 file changed, 2 insertions(+)
hw/riscv/virt.c +2 -1
index 8675c3a7d1..b0871b7f81 100644
@@ -1764,6 +1764,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
     mc->init = virt_machine_init;
     mc->max_cpus = VIRT_CPUS_MAX;
     mc->default_cpu_type = TYPE_RISCV_CPU_BASE;
+    mc->block_default_type = IF_VIRTIO;
+    mc->no_cdrom = 1;
     mc->pci_allow_0_address = true;
     mc->possible_cpu_arch_ids = riscv_numa_possible_cpu_arch_ids;
     mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props;
--

2.34.1

#3 lore raw
In reply to Sunil V L
Quoted 9 lines · Sunil V L

RISC-V virt is currently missing default type for block devices. Without this being set, proper backend is not created when option like -cdrom is used. So, make the virt board's default block device type be IF_VIRTIO similar to other architectures.

We also need to set no_cdrom to avoid getting a default cdrom device.

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 21 lines
---
 hw/riscv/virt.c | 2 ++
 1 file changed, 2 insertions(+)
hw/riscv/virt.c +2 -1
index 8675c3a7d1..b0871b7f81 100644
@@ -1764,6 +1764,8 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
     mc->init = virt_machine_init;
     mc->max_cpus = VIRT_CPUS_MAX;
     mc->default_cpu_type = TYPE_RISCV_CPU_BASE;
+    mc->block_default_type = IF_VIRTIO;
+    mc->no_cdrom = 1;
     mc->pci_allow_0_address = true;
     mc->possible_cpu_arch_ids = riscv_numa_possible_cpu_arch_ids;
     mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props;
--

2.34.1