[PATCH v3 7/7] hw/boards: Ensure machine setting auto_create_sdcard expose a SD Bus

Philippe Mathieu-Daudé posted 7 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH v3 7/7] hw/boards: Ensure machine setting auto_create_sdcard expose a SD Bus
Posted by Philippe Mathieu-Daudé 1 month, 1 week ago
Using the auto_create_sdcard feature without SD Bus is irrelevant.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 system/vl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/system/vl.c b/system/vl.c
index 5ff461ea4ca..dd8053e1e79 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -53,6 +53,7 @@
 #include "hw/usb.h"
 #include "hw/isa/isa.h"
 #include "hw/scsi/scsi.h"
+#include "hw/sd/sd.h"
 #include "hw/display/vga.h"
 #include "hw/firmware/smbios.h"
 #include "hw/acpi/acpi.h"
@@ -2661,12 +2662,19 @@ static void qemu_init_displays(void)
 
 static void qemu_init_board(void)
 {
+    MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
+
     /* process plugin before CPUs are created, but once -smp has been parsed */
     qemu_plugin_load_list(&plugin_list, &error_fatal);
 
     /* From here on we enter MACHINE_PHASE_INITIALIZED.  */
     machine_run_board_init(current_machine, mem_path, &error_fatal);
 
+    if (machine_class->auto_create_sdcard) {
+        /* Ensure there is a SD bus available to create SD card on */
+        assert(object_resolve_path_type("", TYPE_SD_BUS, NULL));
+    }
+
     drive_check_orphaned();
 
     realtime_init();
-- 
2.47.1


Re: [PATCH v3 7/7] hw/boards: Ensure machine setting auto_create_sdcard expose a SD Bus
Posted by Thomas Huth 1 month, 1 week ago
On 04/02/2025 19.29, Philippe Mathieu-Daudé wrote:
> Using the auto_create_sdcard feature without SD Bus is irrelevant.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   system/vl.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/system/vl.c b/system/vl.c
> index 5ff461ea4ca..dd8053e1e79 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -53,6 +53,7 @@
>   #include "hw/usb.h"
>   #include "hw/isa/isa.h"
>   #include "hw/scsi/scsi.h"
> +#include "hw/sd/sd.h"
>   #include "hw/display/vga.h"
>   #include "hw/firmware/smbios.h"
>   #include "hw/acpi/acpi.h"
> @@ -2661,12 +2662,19 @@ static void qemu_init_displays(void)
>   
>   static void qemu_init_board(void)
>   {
> +    MachineClass *machine_class = MACHINE_GET_CLASS(current_machine);
> +
>       /* process plugin before CPUs are created, but once -smp has been parsed */
>       qemu_plugin_load_list(&plugin_list, &error_fatal);
>   
>       /* From here on we enter MACHINE_PHASE_INITIALIZED.  */
>       machine_run_board_init(current_machine, mem_path, &error_fatal);
>   
> +    if (machine_class->auto_create_sdcard) {
> +        /* Ensure there is a SD bus available to create SD card on */
> +        assert(object_resolve_path_type("", TYPE_SD_BUS, NULL));
> +    }
> +
>       drive_check_orphaned();
>   
>       realtime_init();

Reviewed-by: Thomas Huth <thuth@redhat.com>