From: Utkarsh Verma <[email protected]>

In VOF mode, add a single generic "disk" child node under the vSCSI
FDT node instead of one node per attached LUN, matching the Open
Firmware behaviour.

The node carries device_type = "block" and a name property. The
path_offset() wildcard fallback introduced alongside this change
resolves any "disk@<srp-lun>" open request to this shared node,
from which vof_do_open() extracts the LUN from the path string
at runtime.

AI-used-for: code
Signed-off-by: Utkarsh Verma <[email protected]>
---
Changelog:
v2:
- Replaced one FDT child node per attached LUN ("disk@<srp-lun>" with
  reg + device_type) with a single generic "disk" wildcard node shared
  by all LUNs, matching the Open Firmware behaviour.
---
 hw/scsi/spapr_vscsi.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index b4c8f94d22..a799181d0f 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -1255,6 +1255,29 @@ static int spapr_vscsi_devnode(SpaprVioDevice *dev, void 
*fdt, int node_off)
         return ret;
     }
 
+    /*
+     * In VOF mode add a generic "disk" wildcard child node without appending
+     * srp-lun to it's path name, matching the actual Open Firmware behaviour.
+     * Its phandle and device_type covers any disk@<srp-lun> path.
+     */
+    SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
+    if (spapr->vof) {
+        int disk_off = fdt_add_subnode(fdt, node_off, "disk");
+        if (disk_off < 0) {
+            return disk_off;
+        }
+
+        ret = fdt_setprop_string(fdt, disk_off, "name", "disk");
+        if (ret < 0) {
+            return ret;
+        }
+
+        ret = fdt_setprop_string(fdt, disk_off, "device_type", "block");
+        if (ret < 0) {
+            return ret;
+        }
+    }
+
     return 0;
 }
 
-- 
2.55.0


Reply via email to