All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org,
	"Markus Armbruster" <armbru@redhat.com>,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>
Subject: [PATCH v4 7/7] hw/boards: Ensure machine setting auto_create_sdcard expose a SD Bus
Date: Tue,  4 Feb 2025 21:09:34 +0100	[thread overview]
Message-ID: <20250204200934.65279-8-philmd@linaro.org> (raw)
In-Reply-To: <20250204200934.65279-1-philmd@linaro.org>

Using the auto_create_sdcard feature without SD Bus is irrelevant.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 system/vl.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/system/vl.c b/system/vl.c
index 5ff461ea4ca..a904687b57c 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,27 @@ 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) {
+        bool ambigous;
+
+        /* Ensure there is a SD bus available to create SD card on */
+        Object *obj = object_resolve_path_type("", TYPE_SD_BUS, &ambigous);
+        if (!obj && !ambigous) {
+            fprintf(stderr, "Can not create sd-card on '%s' machine"
+                            " because it lacks a sd-bus\n",
+                            machine_class->name);
+            abort();
+        }
+    }
+
     drive_check_orphaned();
 
     realtime_init();
-- 
2.47.1



  parent reply	other threads:[~2025-02-04 20:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 20:09 [PATCH v4 0/7] hw/boards: Try to make sense of MachineClass::no_sdcard flag Philippe Mathieu-Daudé
2025-02-04 20:09 ` [PATCH v4 1/7] hw/boards: Convert no_sdcard flag to OnOffAuto tri-state Philippe Mathieu-Daudé
2025-02-04 20:09 ` [PATCH v4 2/7] hw/boards: Explicit no_sdcard=false as ON_OFF_AUTO_OFF Philippe Mathieu-Daudé
2025-02-04 20:09 ` [PATCH v4 3/7] hw/boards: Rename no_sdcard -> auto_create_sdcard Philippe Mathieu-Daudé
2025-02-05  7:04   ` Thomas Huth
2025-02-04 20:09 ` [PATCH v4 4/7] hw/boards: Remove all invalid uses of auto_create_sdcard=true Philippe Mathieu-Daudé
2025-02-04 20:09 ` [PATCH v4 5/7] hw/arm: " Philippe Mathieu-Daudé
2025-02-05  7:14   ` Thomas Huth
2025-02-04 20:09 ` [PATCH v4 6/7] hw/riscv: " Philippe Mathieu-Daudé
2025-02-04 20:09 ` Philippe Mathieu-Daudé [this message]
2025-02-10 20:37 ` [PATCH v4 0/7] hw/boards: Try to make sense of MachineClass::no_sdcard flag Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250204200934.65279-8-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=armbru@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.