{"id":2219356,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2219356/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260402215629.745866-32-ruslichenko.r@gmail.com>","date":"2026-04-02T21:56:16","name":"[v3,31/33] hw/core/fdt_generic_util: Add blockdev binding support","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"21e5254913b46363387d54dbd7f2da429f9275aa","submitter":{"id":92275,"url":"http://patchwork.ozlabs.org/api/1.0/people/92275/?format=json","name":"Ruslan Ruslichenko","email":"ruslichenko.r@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260402215629.745866-32-ruslichenko.r@gmail.com/mbox/","series":[{"id":498555,"url":"http://patchwork.ozlabs.org/api/1.0/series/498555/?format=json","date":"2026-04-02T21:55:47","name":"hw/arm: Introduce generic FDT-driven machine","version":3,"mbox":"http://patchwork.ozlabs.org/series/498555/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219356/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=M34Fax9n;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmwm53bq0z1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 09:01:09 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w8Q3C-0001MB-Sp; Thu, 02 Apr 2026 17:58:06 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <ruslichenko.r@gmail.com>)\n id 1w8Q2o-0000Lt-3S\n for qemu-devel@nongnu.org; Thu, 02 Apr 2026 17:57:42 -0400","from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <ruslichenko.r@gmail.com>)\n id 1w8Q2l-0007Hz-Ho\n for qemu-devel@nongnu.org; Thu, 02 Apr 2026 17:57:41 -0400","by mail-ej1-x62b.google.com with SMTP id\n a640c23a62f3a-b8d7f22d405so207524266b.0\n for <qemu-devel@nongnu.org>; Thu, 02 Apr 2026 14:57:38 -0700 (PDT)","from thinkpad-t470s.. (93-143-182-244.adsl.net.t-com.hr.\n [93.143.182.244]) by smtp.googlemail.com with ESMTPSA id\n a640c23a62f3a-b9c3cac0e1asm134009166b.27.2026.04.02.14.57.35\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 02 Apr 2026 14:57:36 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1775167057; x=1775771857; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=n6mkiV7CLVebcyX6UefYuso6mVsuMOpfGW0RofMKUx8=;\n b=M34Fax9n9DAJvQgTwhFcpz6CXZ6Ij4HTI+h3dGjFCUi7zowmxjx18Wo9XpdCW0OVAG\n u4M9THcXZfFHywlQpaTBkTO2F8kyALzpFP6AhGaMWg0gh75t2TATd3oPqqNdFaTauGWA\n 2PiNC/enjI/D9/6qa9GeZvoZEB98Ezf30FGYniLJGu0+/m8f1+CcExTgNDDlquODGanh\n MfH6PcUbYnt9K8UX8+7OQdE2r6rBHtd441Ej3RIpAcHUBAKDl252DuszSooxy1neV5RY\n SeKIY3zpwT0TznN+at+NJuGv8pWzbaHbY9Ohya3zQISBiZKywp78eRzRkX2dUmskS9Nq\n sV6Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775167057; x=1775771857;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=n6mkiV7CLVebcyX6UefYuso6mVsuMOpfGW0RofMKUx8=;\n b=hZPKaCZTgt6DeQhTAjMEk0QTlLKgEWpq+lAUOpIMesdC+sR1HQ+LI/VB2cQ6lueXLI\n WX7OcOll7uA5qYhz9nrWg6PXyxjL2FL6YfXihgNHljrNiBkfeBeA+jstP/L+Ewj/3M7t\n mwceeRWeoasNOroTSdjipem20ckmkTR1NvHw9vgqg9lDlucvmtIr8o7w8Tv9a31X9RaN\n H0xKhaC63Ul3qNtRwFl31g/+g3HHC1XcEg+mqD7KghqJCWXA5DDpKC94h/ojfsBzcgNV\n 1iwCVrH7Tj6KRmS2wifMWlshOHT4OsCyXSviQSefxgKzTwMV9IjYuSxJCEFveV0nC6rc\n ICUw==","X-Gm-Message-State":"AOJu0Yyc5HDt/oLupmIOXtKAwVctrxNAKoZP/mT7tQe2LMeeWPLYcc9B\n 5xi1fyjHctuRV8jNRwNaew2NBxar4ZeLWtipIHOug76AGV3se8qDz7sb7ECxAPx5","X-Gm-Gg":"ATEYQzzv4bVWbR87eeXVzD0eKgj7FshpEc5IjxP9rri6nAj6rWjv4Qwi1cTqnsWnwbI\n HGuMoVTFfqF7IFuo69ITzSKEPjfocZ2HEUoJp4qnEqJNzcRQm5q04fE55iDrMeDBHnVVU46DLjL\n FZLPVoeuaA1uoBqPNcU1SVXpXk7F4jS/4QVYfw/bFw5iJ8B5NAnSEB0+NraLXG7Iv/Iyw6lg5CT\n /Kx/kMUO8ZyjBfxfII1QpA3x+AXedymOASo1a+CwC41c85inftRa76oZRnENsOMH+RTE7CXvKss\n pfiv2Knsfxu1i5d5B8zPyLXwwKsF727jUIp9v/TUzksIRKHgevKQOCMPdsohq2BIPN4k0xU6kOD\n 2vh2Dm0e3LUesHwCjCm6t5WO3tSz5hF47KiuPjj77p6gSb6zwWCBAGplcDmBEEEFnXTjxRkQKQ3\n ZwqCpJfS+qpKwmJMVESEknSSHAXFF0b14MPY77sKoL9Gm/Jurt6xglRHqDpJ4d9/u40KRNNA==","X-Received":"by 2002:a17:907:c988:b0:b98:32c1:249b with SMTP id\n a640c23a62f3a-b9c674465ebmr22620466b.8.1775167057079;\n Thu, 02 Apr 2026 14:57:37 -0700 (PDT)","From":"Ruslan Ruslichenko <ruslichenko.r@gmail.com>","To":"qemu-devel@nongnu.org","Cc":"qemu-arm@nongnu.org, alex.bennee@linaro.org, peter.maydell@linaro.org,\n artem_mygaiev@epam.com, volodymyr_babchuk@epam.com,\n takahiro.nakata.wr@renesas.com,\n \"Edgar E . Iglesias\" <edgar.iglesias@gmail.com>,\n Ruslan_Ruslichenko@epam.com, balaton@eik.bme.hu","Subject":"[PATCH v3 31/33] hw/core/fdt_generic_util: Add blockdev binding\n support","Date":"Thu,  2 Apr 2026 23:56:16 +0200","Message-ID":"<20260402215629.745866-32-ruslichenko.r@gmail.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260402215629.745866-1-ruslichenko.r@gmail.com>","References":"<20260402215629.745866-1-ruslichenko.r@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2a00:1450:4864:20::62b;\n envelope-from=ruslichenko.r@gmail.com; helo=mail-ej1-x62b.google.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"From: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>\n\nThe path add possibility to bind to QEMU block backends\nvia the blockdev-node-name property.\n\nThis enables support for the modern -blockdev command line option.\n\nSince the generic FDT initialization traverses the device tree\ninside  QEMU coroutines, realizing block devices immediately\ncauses conflict: QEMU's block subsystem and AIO (Asynchronous I/O)\nare not compatible with being invoked from within these setup\ncoroutines. To resolve this block device initialization are\nmoved to the latest stage outside of co-routing context.\n\nSigned-off-by: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>\n---\n hw/core/fdt_generic_util.c | 77 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 77 insertions(+)","diff":"diff --git a/hw/core/fdt_generic_util.c b/hw/core/fdt_generic_util.c\nindex ae54ada11d..7d074745b5 100644\n--- a/hw/core/fdt_generic_util.c\n+++ b/hw/core/fdt_generic_util.c\n@@ -69,6 +69,8 @@ static void fdt_get_irq_info_from_intc(FDTMachineInfo *fdti, qemu_irq *ret,\n                                        char *intc_node_path,\n                                        uint32_t *cells, uint32_t num_cells,\n                                        uint32_t max, Error **errp);\n+static bool fdt_attach_blockdev(FDTMachineInfo *fdti,\n+                                const char *node_path, Object *dev);\n \n typedef struct QEMUIRQSharedState {\n     qemu_irq sink;\n@@ -173,6 +175,19 @@ static void fdt_init_deferred(FDTMachineInfo *fdti)\n {\n     while (fdti->deferred) {\n         FDTDeferredNode *dnode = fdti->deferred;\n+        int length = 0;\n+\n+        int offset = fdt_path_offset(fdti->fdt, dnode->node_path);\n+        if (offset < 0) {\n+            error_report(\"%s Couldn't find node %s: %s\", __func__,\n+                         dnode->node_path, fdt_strerror(offset));\n+        }\n+        const char *blockdev = fdt_stringlist_get(fdti->fdt, offset,\n+                                              \"blockdev-node-name\", 0, &length);\n+\n+        if (blockdev && object_property_find(OBJECT(dnode->dev), \"drive\")) {\n+            fdt_attach_blockdev(fdti, dnode->node_path, OBJECT(dnode->dev));\n+        }\n \n         fdt_debug(\"FDT: Deferred realize node: %s\\n\",\n                  dnode->node_path);\n@@ -212,6 +227,8 @@ FDTMachineInfo *fdt_generic_create_machine(void *fdt, qemu_irq *cpu_irq)\n     current_machine->smp.cpus = fdt_generic_num_cpus;\n     current_machine->smp.max_cpus = fdt_generic_num_cpus;\n \n+    bdrv_drain_all();\n+\n     fdt_debug(\"FDT: Device tree scan complete\\n\");\n     return fdti;\n }\n@@ -707,6 +724,47 @@ static void fdt_init_qdev_array_prop(Object *obj,\n     fdt_debug_np(\"set property %s propname to <list>\\n\", propname);\n }\n \n+/*\n+ * Try to attach by matching drive created by '-blockdev node-name=LABEL'\n+ * iff the FDT node contains property 'blockdev-node-name=LABEL'.\n+ *\n+ * Return false unless the given node_path has the property.\n+ *\n+ */\n+static bool fdt_attach_blockdev(FDTMachineInfo *fdti,\n+                                const char *node_path, Object *dev)\n+{\n+    static const char propname[] = \"blockdev-node-name\";\n+    const char *label;\n+\n+    /* Inspect FDT node for blockdev-only binding */\n+    label = qemu_fdt_getprop(fdti->fdt, node_path, propname,\n+                             NULL, NULL);\n+\n+    /* Skip legacy node */\n+    if (!label) {\n+        return false;\n+    }\n+\n+    /*\n+     * Missing matching bdev is not an error: attachment is optional.\n+     *\n+     * error_setg() aborts, never returns: 'return false' is just sanity.\n+     */\n+    if (!label[0]) {\n+        error_setg(&error_abort, \"FDT-node '%s': property '%s' = <empty>\",\n+                   node_path, propname);\n+        return false;\n+    }\n+\n+    if (!bdrv_find_node(label)) {\n+        return false;\n+    }\n+\n+    object_property_set_str(OBJECT(dev), \"drive\", label, NULL);\n+    return true;\n+}\n+\n static void fdt_init_qdev_properties(char *node_path, FDTMachineInfo *fdti,\n                                      Object *dev)\n {\n@@ -1048,6 +1106,7 @@ static int fdt_init_qdev(char *node_path, FDTMachineInfo *fdti, char *compat)\n {\n     Object *dev, *parent;\n     char *parent_node_path;\n+    ObjectProperty *p;\n \n     if (!compat) {\n         return 1;\n@@ -1086,12 +1145,30 @@ static int fdt_init_qdev(char *node_path, FDTMachineInfo *fdti, char *compat)\n \n     fdt_init_qdev_properties(node_path, fdti, dev);\n \n+    /*\n+     * In case device need to be attached to block backend,\n+     * defer realize to latest stage, outside of co-routines,\n+     * which are not compatible with AIO used by block subsystem\n+     */\n+    p = object_property_find(dev, \"drive\");\n+    if (p && !strcmp(p->type, \"str\")) {\n+        FDTDeferredNode *dnode = g_new0(FDTDeferredNode, 1);\n+        *dnode = (FDTDeferredNode) {\n+                .dev = DEVICE(dev),\n+                .node_path = g_strdup(node_path),\n+                .next = fdti->deferred\n+        };\n+        fdti->deferred = dnode;\n+        goto exit;\n+    }\n+\n     fdt_init_device_realize(fdti, node_path, dev);\n \n     fdt_parse_node_reg_prop(fdti, node_path, dev);\n \n     fdt_parse_node_irq_prop(fdti, node_path, dev);\n \n+exit:\n     g_free(parent_node_path);\n \n     return 0;\n","prefixes":["v3","31/33"]}