s390x: Add support for virtio-scsi-pci boot device
v3 cover s390x: Add support for virtio-scsi-pci boot device
From: Jared Rossi <[email protected]>
Add support for booting from SCSI devices with a virtio-scsi-pci controller.
Some minor clean-up is done with naming in order to clarify if the function or value used with CCW, PCI, or generic IPL and to check if a PCI function is already enabled.
Changes v2 -> v3:
- Rebase on recently added Secure IPL features added to BIOS
- Define PCI IPLB length using offset and sizeof rather than magic
- Check for virtio setup failures during scsi setup
- Fix commit messages
- Update the title of patch 3 to indicate multiple lengths change
Jared Rossi (8):
pc-bios/s390-ccw: Check if a PCI function is already enabled before
trying to enable it
hw/s390x/ipl: Fix incorrect PCI IPL block lengths pc-bios/s390-ccw: Use bus specific IPL_TYPE directly for scsi IPL s390x/ipl: Add PCI and bus fields to IplBlockQemuScsi pc-bios/s390-ccw: Abstract virtio_run() for generic use pc-bios/s390-ccw: Add support for virtio-scsi-pci IPL
s390x: Find scsi-pci boot device and build IPLB tests/qtest: Add s390x PCI SCSI fallback test to cdrom-test.c
hw/s390x/ipl.c | 40 ++++++++++++++++++++++++++++++++ hw/s390x/ipl.h | 2 ++ include/hw/s390x/ipl/qipl.h | 15 ++++++++---- pc-bios/s390-ccw/clp.c | 4 ++++ pc-bios/s390-ccw/main.c | 19 +++++++++++---- pc-bios/s390-ccw/virtio-blkdev.c | 1 - pc-bios/s390-ccw/virtio-ccw.c | 17 -------------- pc-bios/s390-ccw/virtio-ccw.h | 1 - pc-bios/s390-ccw/virtio-pci.c | 31 ++++++++++++++++++++++++- pc-bios/s390-ccw/virtio-scsi.c | 18 +++++++++++++- pc-bios/s390-ccw/virtio.c | 21 +++++++++-------- tests/qtest/cdrom-test.c | 8 +++++++ 12 files changed, 137 insertions(+), 40 deletions(-)
Signature · 1 line
2.54.0
PATCH v3 1/8 pc-bios/s390-ccw: Check if a PCI function is already enabled before trying to enable it
From: Jared Rossi <[email protected]>
Enabling a PCI function that is already configured will result in an error. Simply check if the device has already been enabled, and if so, return without doing anything further; otherwise, enable it as usual.
Also, because enable_pci_function() prints its own message, let's remove the duplicate message emitted during the virtio PCI setup steps.
--- pc-bios/s390-ccw/clp.c | 4 ++++ pc-bios/s390-ccw/virtio-pci.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-)
pc-bios/s390-ccw/clp.c +4 -0
@@ -82,6 +82,10 @@ int enable_pci_function(uint32_t *fhandle) {ClpReqRspSetPci rrb; +if (*fhandle &CLP_FHLIST_MASK_CONFIG ) { +return 0 ;/* already enabled */ + } + rrb.request.hdr.len =sizeof (ClpReqSetPci); rrb.request.hdr.cmd =0x05 ; rrb.request.fh = *fhandle;
pc-bios/s390-ccw/virtio-pci.c +0 -1
@@ -452,7 +452,6 @@ int virtio_pci_setup_device(void)VDev *vdev =virtio_get_device ();if (enable_pci_function (&vdev->pci_fh)) { -puts ("Failed to enable PCI function" );return -ENODEV ; }
Signature · 1 line
2.54.0
Re: [PATCH v3 1/8] pc-bios/s390-ccw: Check if a PCI function is already enabled before trying to enable it
Quoted 37 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Enabling a PCI function that is already configured will result in an error. Simply check if the device has already been enabled, and if so, return without doing anything further; otherwise, enable it as usual.
Also, because
enable_pci_function()prints its own message, let's remove the duplicate message emitted during the virtio PCI setup steps.Reviewed-by Zhuoying Cai <[email protected]>Reviewed-by Eric Farman <[email protected]>Signed-off-by Jared Rossi <[email protected]>--- pc-bios/s390-ccw/clp.c | 4 ++++ pc-bios/s390-ccw/virtio-pci.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-)pc-bios/s390-ccw/clp.c +4
-0@@ -82,6 +82,10 @@ int enable_pci_function(uint32_t *fhandle) {ClpReqRspSetPci rrb; +if (*fhandle &CLP_FHLIST_MASK_CONFIG ) { +return 0 ;/* already enabled */ + } + rrb.request.hdr.len =sizeof (ClpReqSetPci); rrb.request.hdr.cmd =0x05 ; rrb.request.fh = *fhandle;pc-bios/s390-ccw/virtio-pci.c +0
-0
pc-bios/s390-ccw/virtio-pci.c int virtio_pci_setup_device(void) · line 457
Quoted 7 lines
pc-bios/s390-ccw/virtio-pci.c +0
-1@@ -452,7 +452,6 @@ int virtio_pci_setup_device(void)VDev *vdev =virtio_get_device ();if (enable_pci_function (&vdev->pci_fh)) { -puts ("Failed to enable PCI function" );return -ENODEV ; }
PATCH v3 2/8 hw/s390x/ipl: Fix incorrect PCI IPL block lengths
In reply to [email protected]From: Jared Rossi <[email protected]>
The length of the PCI IPLB is calculated by size of the IplBlockPci struct plus the number of bytes used for common IPLB fields.
Fix the S390_IPLB_MIN_PCI_LEN to reflect this, and assign a valid blk0_len while we are at it.
--- hw/s390x/ipl.c | 2 ++ include/hw/s390x/ipl/qipl.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
hw/s390x/ipl.c +2 -0
@@ -615,6 +615,8 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb)switch (devtype) {case PCI_DEVTYPE_VIRTIO : iplb->len =cpu_to_be32 (S390_IPLB_MIN_PCI_LEN ); + iplb->blk0_len = +cpu_to_be32 (S390_IPLB_MIN_PCI_LEN -S390_IPLB_HEADER_LEN ); iplb->pbt =S390_IPL_TYPE_PCI ; iplb->pci.fid =cpu_to_be32 (pbdev->fid);break ;
include/hw/s390x/ipl/qipl.h +1 -1
@@ -39,7 +39,7 @@ typedef enum S390IplType S390IplType;#define S390_IPLB_MIN_PV_LEN 148#define S390_IPLB_MIN_CCW_LEN 200#define S390_IPLB_MIN_FCP_LEN 384 -#define S390_IPLB_MIN_PCI_LEN 376 +#define S390_IPLB_MIN_PCI_LEN (offsetof(IplParameterBlock, pci) + sizeof(IplBlockPci))#define S390_IPLB_MIN_QEMU_SCSI_LEN 200#define S390_IPLB_MAX_LEN 4096
Signature · 1 line
2.54.0
Re: [PATCH v3 2/8] hw/s390x/ipl: Fix incorrect PCI IPL block lengths
Quoted 8 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
The length of the PCI IPLB is calculated by size of the IplBlockPci struct plus the number of bytes used for common IPLB fields.
Fix the
S390_IPLB_MIN_PCI_LENto reflect this, and assign a validblk0_lenwhile we are at it.
Quoted 7 lines
Fixes 395116781df5 ("s390x: Build IPLB for virtio-pci devices")Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 2 ++ include/hw/s390x/ipl/qipl.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
Thanks. The rest of the cleanup will be nice, but for this as a -stable candidate:
Re: [PATCH v3 2/8] hw/s390x/ipl: Fix incorrect PCI IPL block lengths
In reply to [email protected]Quoted 34 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
The length of the PCI IPLB is calculated by size of the IplBlockPci struct plus the number of bytes used for common IPLB fields.
Fix the
S390_IPLB_MIN_PCI_LENto reflect this, and assign a validblk0_lenwhile we are at it.Fixes 395116781df5 ("s390x: Build IPLB for virtio-pci devices")Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 2 ++ include/hw/s390x/ipl/qipl.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)hw/s390x/ipl.c +2
-0@@ -615,6 +615,8 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb)switch (devtype) {case PCI_DEVTYPE_VIRTIO : iplb->len =cpu_to_be32 (S390_IPLB_MIN_PCI_LEN ); + iplb->blk0_len = +cpu_to_be32 (S390_IPLB_MIN_PCI_LEN -S390_IPLB_HEADER_LEN ); iplb->pbt =S390_IPL_TYPE_PCI ; iplb->pci.fid =cpu_to_be32 (pbdev->fid);break ;include/hw/s390x/ipl/qipl.h +0
-0
include/hw/s390x/ipl/qipl.h typedef enum S390IplType S390IplType; · line 45
Quoted 8 lines
include/hw/s390x/ipl/qipl.h +1
-1@@ -39,7 +39,7 @@ typedef enum S390IplType S390IplType;#define S390_IPLB_MIN_PV_LEN 148#define S390_IPLB_MIN_CCW_LEN 200#define S390_IPLB_MIN_FCP_LEN 384 -#define S390_IPLB_MIN_PCI_LEN 376 +#define S390_IPLB_MIN_PCI_LEN (offsetof(IplParameterBlock, pci) + sizeof(IplBlockPci))#define S390_IPLB_MIN_QEMU_SCSI_LEN 200#define S390_IPLB_MAX_LEN 4096
Re: [PATCH v3 2/8] hw/s390x/ipl: Fix incorrect PCI IPL block lengths
In reply to [email protected]Quoted 34 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
The length of the PCI IPLB is calculated by size of the IplBlockPci struct plus the number of bytes used for common IPLB fields.
Fix the
S390_IPLB_MIN_PCI_LENto reflect this, and assign a validblk0_lenwhile we are at it.Fixes 395116781df5 ("s390x: Build IPLB for virtio-pci devices")Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 2 ++ include/hw/s390x/ipl/qipl.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)hw/s390x/ipl.c +2
-0@@ -615,6 +615,8 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb)switch (devtype) {case PCI_DEVTYPE_VIRTIO : iplb->len =cpu_to_be32 (S390_IPLB_MIN_PCI_LEN ); + iplb->blk0_len = +cpu_to_be32 (S390_IPLB_MIN_PCI_LEN -S390_IPLB_HEADER_LEN ); iplb->pbt =S390_IPL_TYPE_PCI ; iplb->pci.fid =cpu_to_be32 (pbdev->fid);break ;include/hw/s390x/ipl/qipl.h +0
-0
include/hw/s390x/ipl/qipl.h typedef enum S390IplType S390IplType; · line 42
Quoted 5 lines
include/hw/s390x/ipl/qipl.h +1
-1@@ -39,7 +39,7 @@ typedef enum S390IplType S390IplType;#define S390_IPLB_MIN_PV_LEN 148#define S390_IPLB_MIN_CCW_LEN 200#define S390_IPLB_MIN_FCP_LEN 384 -#define S390_IPLB_MIN_PCI_LEN 376 +#define S390_IPLB_MIN_PCI_LEN (offsetof(IplParameterBlock, pci) + sizeof(IplBlockPci))
Thanks!
Quoted 3 lines
include/hw/s390x/ipl/qipl.h +0
-0#define S390_IPLB_MIN_QEMU_SCSI_LEN 200#define S390_IPLB_MAX_LEN 4096
PATCH v3 3/8 pc-bios/s390-ccw: Use bus specific IPL_TYPE directly for scsi IPL
In reply to [email protected]From: Jared Rossi <[email protected]>
All existing switch cases that handle S390_IPL_TYPE_QEMU_SCSI directly fall through to S390_IPL_TYPE_CCW. Rather than always fall through, reassign vdev->ipl_type to the appropriate bus for the scsi controller and proceed as usual, where the bus is designated by the "bus" field and set during the IPLB build.
Because S390_IPL_TYPE_QEMU_SCSI should not appear as an ipl_type once the device is found, remove that specific case from other existing switches and allow it to land in the default case, which will generally result in an immediate error.
--- pc-bios/s390-ccw/main.c | 13 ++++++++++--- pc-bios/s390-ccw/virtio-blkdev.c | 1 - pc-bios/s390-ccw/virtio.c | 5 ----- 3 files changed, 10 insertions(+), 9 deletions(-)
pc-bios/s390-ccw/main.c +10 -3
@@ -261,8 +261,16 @@ static bool find_boot_device(void) vdev->selected_scsi_device.channel = iplb->scsi.channel; vdev->selected_scsi_device.target = iplb->scsi.target; vdev->selected_scsi_device.lun = iplb->scsi.lun; - blk_schid.ssid = iplb->scsi.ssid &0x3 ; - found =find_subch (iplb->scsi.devno); + vdev->ipl_type = iplb->scsi.bus; +switch (vdev->ipl_type) { +case S390_IPL_TYPE_CCW : + blk_schid.ssid = iplb->scsi.ssid &0x3 ; + found =find_subch (iplb->scsi.devno); +break ; +default : +puts ("Unrecognized SCSI controller" ); +break ; + }break ;case S390_IPL_TYPE_PCI : found =find_fid (iplb->pci.fid);
@@ -346,7 +354,6 @@ static void ipl_pci_device(void)static void ipl_boot_device (void ) {switch (virtio_get_device ()->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :ipl_ccw_device ();break ;
pc-bios/s390-ccw/virtio-blkdev.c +0 -1
@@ -253,7 +253,6 @@ int virtio_blk_setup_device(VDev *vdev)puts ("Using virtio-blk." );switch (vdev->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return virtio_ccw_setup (vdev);case S390_IPL_TYPE_PCI :
pc-bios/s390-ccw/virtio.c +0 -5
@@ -61,7 +61,6 @@ char *virtio_get_ring_area(int ring_num)int drain_irqs (void ) {switch (vdev.ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return drain_irqs_ccw (vdev.schid);default :
@@ -109,7 +108,6 @@ void vring_init(VRing *vr, VqInfo *info)bool vring_notify (VRing *vr) {switch (vdev.ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW : vr->cookie =virtio_ccw_notify (vdev.schid, vr->id, vr->cookie);break ;
@@ -130,7 +128,6 @@ bool vring_notify(VRing *vr)bool be_ipl (void ) {switch (virtio_get_device ()->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return true;case S390_IPL_TYPE_PCI :
@@ -231,7 +228,6 @@ int vring_wait_reply(void)int virtio_reset (VDev *vdev) {switch (vdev->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return virtio_ccw_reset (vdev);case S390_IPL_TYPE_PCI :
@@ -244,7 +240,6 @@ int virtio_reset(VDev *vdev)bool virtio_is_supported (VDev *vdev) {switch (vdev->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return virtio_ccw_is_supported (vdev);case S390_IPL_TYPE_PCI :
Signature · 1 line
2.54.0
Re: [PATCH v3 3/8] pc-bios/s390-ccw: Use bus specific IPL_TYPE directly for scsi IPL
Quoted 101 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
All existing switch cases that handle
S390_IPL_TYPE_QEMU_SCSIdirectly fall through toS390_IPL_TYPE_CCW. Rather than always fall through, reassignvdev->ipl_typeto the appropriate bus for the scsi controller and proceed as usual, where the bus is designated by the "bus" field and set during the IPLB build.Because
S390_IPL_TYPE_QEMU_SCSIshould not appear as anipl_typeonce the device is found, remove that specific case from other existing switches and allow it to land in the default case, which will generally result in an immediate error.Reviewed-by Eric Farman <[email protected]>Signed-off-by Jared Rossi <[email protected]>--- pc-bios/s390-ccw/main.c | 13 ++++++++++--- pc-bios/s390-ccw/virtio-blkdev.c | 1 - pc-bios/s390-ccw/virtio.c | 5 ----- 3 files changed, 10 insertions(+), 9 deletions(-)pc-bios/s390-ccw/main.c +10
-3@@ -261,8 +261,16 @@ static bool find_boot_device(void) vdev->selected_scsi_device.channel = iplb->scsi.channel; vdev->selected_scsi_device.target = iplb->scsi.target; vdev->selected_scsi_device.lun = iplb->scsi.lun; - blk_schid.ssid = iplb->scsi.ssid &0x3 ; - found =find_subch (iplb->scsi.devno); + vdev->ipl_type = iplb->scsi.bus; +switch (vdev->ipl_type) { +case S390_IPL_TYPE_CCW : + blk_schid.ssid = iplb->scsi.ssid &0x3 ; + found =find_subch (iplb->scsi.devno); +break ; +default : +puts ("Unrecognized SCSI controller" ); +break ; + }break ;case S390_IPL_TYPE_PCI : found =find_fid (iplb->pci.fid);@@ -346,7 +354,6 @@ static void ipl_pci_device(void)static void ipl_boot_device (void ) {switch (virtio_get_device ()->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :ipl_ccw_device ();break ;pc-bios/s390-ccw/virtio-blkdev.c +0
-1@@ -253,7 +253,6 @@ int virtio_blk_setup_device(VDev *vdev)puts ("Using virtio-blk." );switch (vdev->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return virtio_ccw_setup (vdev);case S390_IPL_TYPE_PCI :pc-bios/s390-ccw/virtio.c +0
-4@@ -61,7 +61,6 @@ char *virtio_get_ring_area(int ring_num)int drain_irqs (void ) {switch (vdev.ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return drain_irqs_ccw (vdev.schid);default :@@ -109,7 +108,6 @@ void vring_init(VRing *vr, VqInfo *info)bool vring_notify (VRing *vr) {switch (vdev.ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW : vr->cookie =virtio_ccw_notify (vdev.schid, vr->id, vr->cookie);break ;@@ -130,7 +128,6 @@ bool vring_notify(VRing *vr)bool be_ipl (void ) {switch (virtio_get_device ()->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return true;case S390_IPL_TYPE_PCI :@@ -231,7 +228,6 @@ int vring_wait_reply(void)int virtio_reset (VDev *vdev) {switch (vdev->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return virtio_ccw_reset (vdev);case S390_IPL_TYPE_PCI :
pc-bios/s390-ccw/virtio.c int virtio_reset(VDev *vdev) · line 245
Quoted 7 lines
pc-bios/s390-ccw/virtio.c +0
-1@@ -244,7 +240,6 @@ int virtio_reset(VDev *vdev)bool virtio_is_supported (VDev *vdev) {switch (vdev->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI :case S390_IPL_TYPE_CCW :return virtio_ccw_is_supported (vdev);case S390_IPL_TYPE_PCI :
PATCH v3 4/8 s390x/ipl: Add PCI and bus fields to IplBlockQemuScsi
In reply to [email protected]From: Jared Rossi <[email protected]>
Rather than add a second non-architected IPLB type for scsi-pci devices, let's add the relevant fields to the existing struct so that it can handle both PCI and CCW scsi controllers.
The PCI and CCW fields of the IplBlockQemuScsi are aligned with same offsets as the corresponding fields in IplBlockPci and IplBlockCcw for potential union access.
Add comments for PCI/CCW specifics and also denote that the S390IplType enum values must fit in uint8_t.
--- hw/s390x/ipl.c | 1 + hw/s390x/ipl.h | 2 ++ include/hw/s390x/ipl/qipl.h | 13 +++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-)
hw/s390x/ipl.c +1 -0
@@ -563,6 +563,7 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb) iplb->scsi.lun =cpu_to_be32 (sd->lun); iplb->scsi.target =cpu_to_be16 (sd->id); iplb->scsi.channel =cpu_to_be16 (sd->channel); + iplb->scsi.bus =S390_IPL_TYPE_CCW ; iplb->scsi.devno =cpu_to_be16 (ccw_dev->sch->devno); iplb->scsi.ssid = ccw_dev->sch->ssid &3 ;break ;
hw/s390x/ipl.h +2 -0
@@ -86,6 +86,8 @@ struct S390IPLState {uint16_t devno; };QEMU_BUILD_BUG_MSG (offsetof(S390IPLState , iplb) &3 ,"alignment of iplb wrong" ); +QEMU_BUILD_BUG_MSG (offsetof(IplBlockQemuScsi , fid) != offsetof(IplBlockPci , fid), +"iplb fields misaligned across bus types" );static inline bool iplb_valid_len (IplParameterBlock *iplb) {
include/hw/s390x/ipl/qipl.h +9 -4
@@ -29,7 +29,7 @@ enum S390IplType {S390_IPL_TYPE_CCW =0x02 ,S390_IPL_TYPE_PCI =0x04 ,S390_IPL_TYPE_PV =0x05 , - S390_IPL_TYPE_QEMU_SCSI = 0xff + S390_IPL_TYPE_QEMU_SCSI = 0xff /* Max value, must fit in uint8_t */ };typedef enum S390IplType S390IplType ;
@@ -123,9 +123,14 @@ struct IplBlockQemuScsi {uint32_t lun;uint16_t target;uint16_t channel; -uint8_t reserved0[77 ]; -uint8_t ssid; -uint16_t devno; +uint8_t bus; +uint8_t reserved0[76 ]; +uint8_t ssid;/* CCW only */ +uint16_t devno;/* CCW only */ +uint8_t reserved1[216 ]; +uint8_t opt;/* PCI only */ +uint8_t reserved2[3 ]; +uint32_t fid;/* PCI only */ }QEMU_PACKED ;typedef struct IplBlockQemuScsi IplBlockQemuScsi ;
Signature · 1 line
2.54.0
Re: [PATCH v3 4/8] s390x/ipl: Add PCI and bus fields to IplBlockQemuScsi
Quoted 13 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Rather than add a second non-architected IPLB type for scsi-pci devices, let's add the relevant fields to the existing struct so that it can handle both PCI and CCW scsi controllers.
The PCI and CCW fields of the IplBlockQemuScsi are aligned with same offsets as the corresponding fields in IplBlockPci and IplBlockCcw for potential union access.
Add comments for PCI/CCW specifics and also denote that the S390IplType enum values must fit in
uint8_t.
Quoted 8 lines
Reviewed-by Eric Farman <[email protected]>Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 1 + hw/s390x/ipl.h | 2 ++ include/hw/s390x/ipl/qipl.h | 13 +++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-)
PATCH v3 5/8 pc-bios/s390-ccw: Abstract virtio_run() for generic use
In reply to [email protected]From: Jared Rossi <[email protected]>
The existing virtio_ccw_run() actually has no dependency on CCW. Rather than add a case for non-ccw devices, we can just put the main logic right in the virtio_run() call so that it can be used for other bus types directly.
--- pc-bios/s390-ccw/virtio-ccw.c | 17 ----------------- pc-bios/s390-ccw/virtio-ccw.h | 1 - pc-bios/s390-ccw/virtio.c | 16 +++++++++++----- 3 files changed, 11 insertions(+), 23 deletions(-)
pc-bios/s390-ccw/virtio-ccw.c +0 -17
@@ -107,23 +107,6 @@ long virtio_ccw_notify(SubChannelId schid, int vq_idx, long cookie) vq_idx, cookie); } -int virtio_ccw_run (VDev *vdev,int vqid,VirtioCmd *cmd) -{ -VRing *vr = &vdev->vrings[vqid]; -int i =0 ; - -do { -vring_send_buf (vr, cmd[i].data, cmd[i].size, - cmd[i].flags | (i ?VRING_HIDDEN_IS_CHAIN :0 )); - }while (cmd[i++].flags &VRING_DESC_F_NEXT ); - -vring_wait_reply (); -if (drain_irqs ()) { -return -1 ; - } -return 0 ; -} -int virtio_ccw_reset (VDev *vdev) {return run_ccw (vdev,CCW_CMD_VDEV_RESET ,NULL ,0 , false);
pc-bios/s390-ccw/virtio-ccw.h +0 -1
@@ -16,7 +16,6 @@ extern SubChannelId blk_schid;/* virtio-ccw.c */ int drain_irqs_ccw (SubChannelId schid);bool virtio_ccw_is_supported (VDev *vdev); -int virtio_ccw_run (VDev *vdev,int vqid,VirtioCmd *cmd);long virtio_ccw_notify (SubChannelId schid,int vq_idx,long cookie);int virtio_ccw_setup (VDev *vdev);int virtio_ccw_reset (VDev *vdev);
pc-bios/s390-ccw/virtio.c +11 -5
@@ -70,13 +70,19 @@ int drain_irqs(void)int virtio_run (VDev *vdev,int vqid,VirtioCmd *cmd) { -switch (vdev->ipl_type) { -case S390_IPL_TYPE_QEMU_SCSI : -case S390_IPL_TYPE_CCW : -return virtio_ccw_run (vdev, vqid, cmd); -default : +VRing *vr = &vdev->vrings[vqid]; +int i =0 ; + +do { +vring_send_buf (vr, cmd[i].data, cmd[i].size, + cmd[i].flags | (i ?VRING_HIDDEN_IS_CHAIN :0 )); + }while (cmd[i++].flags &VRING_DESC_F_NEXT ); + +vring_wait_reply (); +if (drain_irqs ()) {return -1 ; } +return 0 ; }void vring_init (VRing *vr,VqInfo *info)
Signature · 1 line
2.54.0
Re: [PATCH v3 5/8] pc-bios/s390-ccw: Abstract virtio_run() for generic use
Quoted 6 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
The existing
virtio_ccw_run()actually has no dependency on CCW. Rather than add a case for non-ccw devices, we can just put the main logic right in thevirtio_run()call so that it can be used for other bus types directly.
Quoted 7 lines
Reviewed-by Eric Farman <[email protected]>Signed-off-by Jared Rossi <[email protected]>--- pc-bios/s390-ccw/virtio-ccw.c | 17 ----------------- pc-bios/s390-ccw/virtio-ccw.h | 1 - pc-bios/s390-ccw/virtio.c | 16 +++++++++++----- 3 files changed, 11 insertions(+), 23 deletions(-)
PATCH v3 6/8 pc-bios/s390-ccw: Add support for virtio-scsi-pci IPL
In reply to [email protected]From: Jared Rossi <[email protected]>
Read virtio-pci configuration and configure virt-queue for scsi devices.
Also add check for virtio setup failures when doing scsi setup and return early if it fails instead of waiting for subsequent failure.
--- pc-bios/s390-ccw/main.c | 3 ++- pc-bios/s390-ccw/virtio-pci.c | 30 ++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio-scsi.c | 18 +++++++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/main.c +2 -1
@@ -273,6 +273,7 @@ static bool find_boot_device(void) }break ;case S390_IPL_TYPE_PCI : + vdev->scsi_device_selected = false; found =find_fid (iplb->pci.fid);break ;default :
@@ -333,13 +334,13 @@ static void ipl_pci_device(void) {VDev *vdev =virtio_get_device (); vdev->is_cdrom = false; - vdev->scsi_device_selected = false;if (virtio_pci_setup_device ()) {return ; }switch (vdev->dev_type) { +case VIRTIO_ID_SCSI :case VIRTIO_ID_BLOCK :if (virtio_setup () ==0 ) {zipl_load ();/* only return on error */
pc-bios/s390-ccw/virtio-pci.c +30 -0
@@ -52,6 +52,10 @@ void virtio_pci_id2type(VDev *vdev, uint16_t device_id)case 0x1001 : vdev->dev_type =VIRTIO_ID_BLOCK ;break ; +case 0x1048 : +case 0x1004 : + vdev->dev_type =VIRTIO_ID_SCSI ; +break ;default : vdev->dev_type =0 ; }
@@ -199,6 +203,26 @@ static int virtio_pci_get_blk_config(void)return rc; } +static int virtio_pci_get_scsi_config (void ) +{ +VirtioScsiConfig *cfg = &virtio_get_device ()->config.scsi; +int rc =vpci_read_flex (d_cap.off, d_cap.bar, cfg,sizeof (VirtioScsiConfig)); + +/* all fields of scsi config must be byte swapped */ + cfg->num_queues =bswap32 (cfg->num_queues); + cfg->seg_max =bswap32 (cfg->seg_max); + cfg->max_sectors =bswap32 (cfg->max_sectors); + cfg->cmd_per_lun =bswap32 (cfg->cmd_per_lun); + cfg->event_info_size =bswap32 (cfg->event_info_size); + cfg->sense_size =bswap32 (cfg->sense_size); + cfg->cdb_size =bswap32 (cfg->cdb_size); + cfg->max_channel =bswap16 (cfg->max_channel); + cfg->max_target =bswap16 (cfg->max_target); + cfg->max_lun =bswap32 (cfg->max_lun); + +return rc; +} +static int virtio_pci_negotiate (void ) {int i, rc;
@@ -330,6 +354,7 @@ bool virtio_pci_is_supported(VDev *vdev)if (vdev->vendor_id ==PCI_VENDOR_VIRTIO ) {switch (vdev->dev_type) {case VIRTIO_ID_BLOCK : +case VIRTIO_ID_SCSI :return true;default :return false;
@@ -384,6 +409,11 @@ int virtio_pci_setup(VDev *vdev) vdev->cmd_vr_idx =0 ;virtio_pci_get_blk_config ();break ; +case VIRTIO_ID_SCSI : + vdev->nr_vqs =3 ; + vdev->cmd_vr_idx =2 ; +virtio_pci_get_scsi_config (); +break ;default :puts ("Unsupported virtio device" );return -ENODEV ;
pc-bios/s390-ccw/virtio-scsi.c +17 -1
@@ -16,6 +16,7 @@#include "scsi.h" #include "virtio-scsi.h" #include "virtio-ccw.h" +#include "virtio-pci.h" #include "s390-time.h" #include "helper.h"
@@ -479,7 +480,22 @@ static int virtio_scsi_setup(VDev *vdev)int virtio_scsi_setup_device (VDev *vdev) { -virtio_ccw_setup (vdev); +switch (vdev->ipl_type) { +case S390_IPL_TYPE_CCW : +if (virtio_ccw_setup (vdev)) { +puts ("Setup failed for virtio-scsi-ccw" ); +return 1 ; + } +break ; +case S390_IPL_TYPE_PCI : +if (virtio_pci_setup (vdev)) { +puts ("Setup failed for virtio-scsi-pci" ); +return 1 ; + } +break ; +default : +return 1 ; + }if (vdev->config.scsi.sense_size !=VIRTIO_SCSI_SENSE_SIZE ) {puts ("Config: sense size mismatch" );
Signature · 1 line
2.54.0
Re: [PATCH v3 6/8] pc-bios/s390-ccw: Add support for virtio-scsi-pci IPL
Quoted 7 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Read virtio-pci configuration and configure virt-queue for scsi devices.
Also add check for virtio setup failures when doing scsi setup and return early if it fails instead of waiting for subsequent failure.
Quoted 6 lines
Signed-off-by Jared Rossi <[email protected]>--- pc-bios/s390-ccw/main.c | 3 ++- pc-bios/s390-ccw/virtio-pci.c | 30 ++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio-scsi.c | 18 +++++++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-)
Thanks for fixing up the (lack of) return code check.
Re: [PATCH v3 6/8] pc-bios/s390-ccw: Add support for virtio-scsi-pci IPL
In reply to [email protected]Quoted 46 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Read virtio-pci configuration and configure virt-queue for scsi devices.
Also add check for virtio setup failures when doing scsi setup and return early if it fails instead of waiting for subsequent failure.
Signed-off-by Jared Rossi <[email protected]>--- pc-bios/s390-ccw/main.c | 3 ++- pc-bios/s390-ccw/virtio-pci.c | 30 ++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio-scsi.c | 18 +++++++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-)pc-bios/s390-ccw/main.c +2
-1@@ -273,6 +273,7 @@ static bool find_boot_device(void) }break ;case S390_IPL_TYPE_PCI : + vdev->scsi_device_selected = false; found =find_fid (iplb->pci.fid);break ;default :@@ -333,13 +334,13 @@ static void ipl_pci_device(void) {VDev *vdev =virtio_get_device (); vdev->is_cdrom = false; - vdev->scsi_device_selected = false;if (virtio_pci_setup_device ()) {return ; }switch (vdev->dev_type) { +case VIRTIO_ID_SCSI :case VIRTIO_ID_BLOCK :if (virtio_setup () ==0 ) {zipl_load ();/* only return on error */ pc-bios/s390-ccw/virtio-pci.c +0
-0
pc-bios/s390-ccw/virtio-pci.c void virtio_pci_id2type(VDev *vdev, uint16_t device_id) · line 61
Quoted 10 lines
pc-bios/s390-ccw/virtio-pci.c +4
-0@@ -52,6 +52,10 @@ void virtio_pci_id2type(VDev *vdev, uint16_t device_id)case 0x1001 : vdev->dev_type =VIRTIO_ID_BLOCK ;break ; +case 0x1048 : +case 0x1004 : + vdev->dev_type =VIRTIO_ID_SCSI ; +break ;default : vdev->dev_type =0 ; }
I normally dislike magic numbers, but the meaning here is clear enough, and the comment above the function is a good enough pointer to the source of the magic, in my opinion:
/* virtio spec v1.3 section 4.1.2.1 */
void virtio_pci_id2type(VDev *vdev, uint16_t device_id)
So lgtm :)
PATCH v3 7/8 s390x: Find scsi-pci boot device and build IPLB
In reply to [email protected]From: Jared Rossi <[email protected]>
Add logic to identify a virtio-pci scsi controller and target lun with assigned bootindex, then build IPLB for it.
Unfence PCI case for scsi devices in BIOS.
--- hw/s390x/ipl.c | 37 +++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/main.c | 3 +++ 2 files changed, 40 insertions(+)
hw/s390x/ipl.c +37 -0
@@ -402,6 +402,7 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) }#define PCI_DEVTYPE_VIRTIO 0x05 +#define PCI_DEVTYPE_SCSI 0x06static S390PCIBusDevice *s390_get_pci_device (DeviceState *dev_st,int *devtype) {
@@ -417,6 +418,26 @@ static S390PCIBusDevice *s390_get_pci_device(DeviceState *dev_st, int *devtype)if (pbdev) { tmp_dt =PCI_DEVTYPE_VIRTIO ; } + }else { +SCSIDevice *sd = (SCSIDevice *) +object_dynamic_cast (OBJECT (dev_st),TYPE_SCSI_DEVICE ); +if (sd) { +SCSIBus *sbus =scsi_bus_from_device (sd); +VirtIODevice *vdev = (VirtIODevice *) +object_dynamic_cast (OBJECT (sbus->qbus.parent), +TYPE_VIRTIO_DEVICE ); +if (vdev) { + pci_dev = (PCIDevice *) +object_dynamic_cast (OBJECT (qdev_get_parent_bus (DEVICE (vdev))->parent), +TYPE_PCI_DEVICE ); +if (pci_dev) { + pbdev =s390_pci_find_dev_by_pci (s390_get_phb (), pci_dev); +if (pbdev) { + tmp_dt =PCI_DEVTYPE_SCSI ; + } + } + } + } } }if (devtype) {
@@ -621,6 +642,22 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb) iplb->pbt =S390_IPL_TYPE_PCI ; iplb->pci.fid =cpu_to_be32 (pbdev->fid);break ; +case PCI_DEVTYPE_SCSI : + sd =SCSI_DEVICE (dev_st); + scsi_lp =object_property_get_str (OBJECT (sd),"loadparm" ,NULL ); +if (scsi_lp &&strlen (scsi_lp) >0 ) { + lp = scsi_lp; + } + iplb->len =cpu_to_be32 (S390_IPLB_MIN_PCI_LEN ); + iplb->blk0_len = +cpu_to_be32 (S390_IPLB_MIN_PCI_LEN -S390_IPLB_HEADER_LEN ); + iplb->pbt =S390_IPL_TYPE_QEMU_SCSI ; + iplb->scsi.lun =cpu_to_be32 (sd->lun); + iplb->scsi.target =cpu_to_be16 (sd->id); + iplb->scsi.channel =cpu_to_be16 (sd->channel); + iplb->scsi.bus =S390_IPL_TYPE_PCI ; + iplb->scsi.fid =cpu_to_be32 (pbdev->fid); +break ;default :return false; }
pc-bios/s390-ccw/main.c +3 -0
@@ -267,6 +267,9 @@ static bool find_boot_device(void) blk_schid.ssid = iplb->scsi.ssid &0x3 ; found =find_subch (iplb->scsi.devno);break ; +case S390_IPL_TYPE_PCI : + found =find_fid (iplb->scsi.fid); +break ;default :puts ("Unrecognized SCSI controller" );break ;
Signature · 1 line
2.54.0
Re: [PATCH v3 7/8] s390x: Find scsi-pci boot device and build IPLB
Quoted 27 lines · On 8/31/2026 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add logic to identify a virtio-pci scsi controller and target lun with assigned bootindex, then build IPLB for it.
Unfence PCI case for scsi devices in BIOS.
Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 37 +++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/main.c | 3 +++ 2 files changed, 40 insertions(+)hw/s390x/ipl.c +1
-0@@ -402,6 +402,7 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) }#define PCI_DEVTYPE_VIRTIO 0x05 +#define PCI_DEVTYPE_SCSI 0x06static S390PCIBusDevice *s390_get_pci_device (DeviceState *dev_st,int *devtype) {@@ -417,6 +418,26 @@ static S390PCIBusDevice *s390_get_pci_device(DeviceState *dev_st, int *devtype)if (pbdev) {
hw/s390x/ipl.c static S390PCIBusDevice *s390_get_pci_device(DeviceState *dev_st, int *devtype) · line 428
Quoted 10 lines
hw/s390x/ipl.c +8
-0tmp_dt =PCI_DEVTYPE_VIRTIO ; } + }else { +SCSIDevice *sd = (SCSIDevice *) +object_dynamic_cast (OBJECT (dev_st),TYPE_SCSI_DEVICE ); +if (sd) { +SCSIBus *sbus =scsi_bus_from_device (sd); +VirtIODevice *vdev = (VirtIODevice *) +object_dynamic_cast (OBJECT (sbus->qbus.parent), +TYPE_VIRTIO_DEVICE );
Small nit: indentation is not quite right here. TYPE_VIRTIO_DEVICE should align with OBJECT in the line above.
Quoted 52 lines
hw/s390x/ipl.c +28
-0+if (vdev) { + pci_dev = (PCIDevice *) +object_dynamic_cast (OBJECT (qdev_get_parent_bus (DEVICE (vdev))->parent), +TYPE_PCI_DEVICE ); +if (pci_dev) { + pbdev =s390_pci_find_dev_by_pci (s390_get_phb (), pci_dev); +if (pbdev) { + tmp_dt =PCI_DEVTYPE_SCSI ; + } + } + } + } } }if (devtype) {@@ -621,6 +642,22 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb) iplb->pbt =S390_IPL_TYPE_PCI ; iplb->pci.fid =cpu_to_be32 (pbdev->fid);break ; +case PCI_DEVTYPE_SCSI : + sd =SCSI_DEVICE (dev_st); + scsi_lp =object_property_get_str (OBJECT (sd),"loadparm" ,NULL ); +if (scsi_lp &&strlen (scsi_lp) >0 ) { + lp = scsi_lp; + } + iplb->len =cpu_to_be32 (S390_IPLB_MIN_PCI_LEN ); + iplb->blk0_len = +cpu_to_be32 (S390_IPLB_MIN_PCI_LEN -S390_IPLB_HEADER_LEN ); + iplb->pbt =S390_IPL_TYPE_QEMU_SCSI ; + iplb->scsi.lun =cpu_to_be32 (sd->lun); + iplb->scsi.target =cpu_to_be16 (sd->id); + iplb->scsi.channel =cpu_to_be16 (sd->channel); + iplb->scsi.bus =S390_IPL_TYPE_PCI ; + iplb->scsi.fid =cpu_to_be32 (pbdev->fid); +break ;default :return false; }pc-bios/s390-ccw/main.c +3
-0@@ -267,6 +267,9 @@ static bool find_boot_device(void) blk_schid.ssid = iplb->scsi.ssid &0x3 ; found =find_subch (iplb->scsi.devno);break ; +case S390_IPL_TYPE_PCI : + found =find_fid (iplb->scsi.fid); +break ;default :puts ("Unrecognized SCSI controller" );break ;
Re: [PATCH v3 7/8] s390x: Find scsi-pci boot device and build IPLB
In reply to [email protected]Quoted 5 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add logic to identify a virtio-pci scsi controller and target lun with assigned bootindex, then build IPLB for it.
Quoted 7 lines
Unfence PCI case for scsi devices in BIOS.
Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 37 +++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/main.c | 3 +++ 2 files changed, 40 insertions(+)
Quoted 77 lines
hw/s390x/ipl.c +37
-0@@ -402,6 +402,7 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) }#define PCI_DEVTYPE_VIRTIO 0x05 +#define PCI_DEVTYPE_SCSI 0x06static S390PCIBusDevice *s390_get_pci_device (DeviceState *dev_st,int *devtype) {@@ -417,6 +418,26 @@ static S390PCIBusDevice *s390_get_pci_device(DeviceState *dev_st, int *devtype)if (pbdev) { tmp_dt =PCI_DEVTYPE_VIRTIO ; } + }else { +SCSIDevice *sd = (SCSIDevice *) +object_dynamic_cast (OBJECT (dev_st),TYPE_SCSI_DEVICE ); +if (sd) { +SCSIBus *sbus =scsi_bus_from_device (sd); +VirtIODevice *vdev = (VirtIODevice *) +object_dynamic_cast (OBJECT (sbus->qbus.parent), +TYPE_VIRTIO_DEVICE ); +if (vdev) { + pci_dev = (PCIDevice *) +object_dynamic_cast (OBJECT (qdev_get_parent_bus (DEVICE (vdev))->parent), +TYPE_PCI_DEVICE ); +if (pci_dev) { + pbdev =s390_pci_find_dev_by_pci (s390_get_phb (), pci_dev); +if (pbdev) { + tmp_dt =PCI_DEVTYPE_SCSI ; + } + } + } + } } }if (devtype) {@@ -621,6 +642,22 @@ static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb) iplb->pbt =S390_IPL_TYPE_PCI ; iplb->pci.fid =cpu_to_be32 (pbdev->fid);break ; +case PCI_DEVTYPE_SCSI : + sd =SCSI_DEVICE (dev_st); + scsi_lp =object_property_get_str (OBJECT (sd),"loadparm" ,NULL ); +if (scsi_lp &&strlen (scsi_lp) >0 ) { + lp = scsi_lp; + } + iplb->len =cpu_to_be32 (S390_IPLB_MIN_PCI_LEN ); + iplb->blk0_len = +cpu_to_be32 (S390_IPLB_MIN_PCI_LEN -S390_IPLB_HEADER_LEN ); + iplb->pbt =S390_IPL_TYPE_QEMU_SCSI ; + iplb->scsi.lun =cpu_to_be32 (sd->lun); + iplb->scsi.target =cpu_to_be16 (sd->id); + iplb->scsi.channel =cpu_to_be16 (sd->channel); + iplb->scsi.bus =S390_IPL_TYPE_PCI ; + iplb->scsi.fid =cpu_to_be32 (pbdev->fid); +break ;default :return false; }pc-bios/s390-ccw/main.c +3
-0@@ -267,6 +267,9 @@ static bool find_boot_device(void) blk_schid.ssid = iplb->scsi.ssid &0x3 ; found =find_subch (iplb->scsi.devno);break ; +case S390_IPL_TYPE_PCI : + found =find_fid (iplb->scsi.fid); +break ;default :puts ("Unrecognized SCSI controller" );break ;
Re: [PATCH v3 7/8] s390x: Find scsi-pci boot device and build IPLB
In reply to [email protected]Quoted 5 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add logic to identify a virtio-pci scsi controller and target lun with assigned bootindex, then build IPLB for it.
Quoted 7 lines
Unfence PCI case for scsi devices in BIOS.
Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 37 +++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/main.c | 3 +++ 2 files changed, 40 insertions(+)
lgtm
PATCH v3 8/8 tests/qtest: Add s390x PCI SCSI fallback test to cdrom-test.c
In reply to [email protected]From: Jared Rossi <[email protected]>
Add a test to verify that a guest can use a PCI controlled CD as a fallback boot device after a failed CCW IPL.
--- tests/qtest/cdrom-test.c | 8 ++++++++ 1 file changed, 8 insertions(+)
tests/qtest/cdrom-test.c +8 -0
@@ -253,6 +253,14 @@ static void add_s390x_tests(void)"-drive if=none,id=d1,media=cdrom,file=" , test_cdboot); } +if (qtest_has_device ("virtio-scsi-pci" )) { +qtest_add_data_func ("cdrom/boot/pci-scsi-fallback-from-blk-ccw" , +"-device virtio-scsi-pci -device virtio-serial " +"-device virtio-blk-ccw,drive=d1,bootindex=1 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d1 " +"-device scsi-cd,drive=d2,bootindex=2 " +"-drive if=none,id=d2,media=cdrom,file=" , test_cdboot); + } }int main (int argc,char **argv)
Signature · 1 line
2.54.0
Re: [PATCH v3 8/8] tests/qtest: Add s390x PCI SCSI fallback test to cdrom-test.c
Quoted 19 lines · On 8/31/2026 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a test to verify that a guest can use a PCI controlled CD as a fallback boot device after a failed CCW IPL.
Signed-off-by Jared Rossi <[email protected]>--- tests/qtest/cdrom-test.c | 8 ++++++++ 1 file changed, 8 insertions(+)tests/qtest/cdrom-test.c +1
-0@@ -253,6 +253,14 @@ static void add_s390x_tests(void)"-drive if=none,id=d1,media=cdrom,file=" , test_cdboot); } +if (qtest_has_device ("virtio-scsi-pci" )) {
tests/qtest/cdrom-test.c static void add_s390x_tests(void) · line 266
Quoted 10 lines
tests/qtest/cdrom-test.c +7
-0+qtest_add_data_func ("cdrom/boot/pci-scsi-fallback-from-blk-ccw" , +"-device virtio-scsi-pci -device virtio-serial " +"-device virtio-blk-ccw,drive=d1,bootindex=1 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d1 " +"-device scsi-cd,drive=d2,bootindex=2 " +"-drive if=none,id=d2,media=cdrom,file=" , test_cdboot); + } }int main (int argc,char **argv)
Note: need to install xorriso to run these tests. If it is not installed, they will not run, with no indication of why. In cdrom-test.c:main(), if the exec_xorrisofs check fails, we return g_test_run() early, without having added any subtests. Maybe a separate patch can add a message that is printed in that case.
meson test --suite qtest-s390x 'qtest-s390x/cdrom-test'
...
# starting QEMU: exec ./qemu-system-s390x -qtest unix:/tmp/qtest-185425.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-185425.qmp,id=char0 -object monitor-qmp,id=qmp0,chardev=char0 -display none -audio none -run-with exit-with-parent=on -accel kvm -accel tcg -no-shutdown -device virtio-scsi-pci -device virtio-serial -device virtio-blk-ccw,drive=d1,bootindex=1 -drive driver=null-co,read-zeroes=on,if=none,id=d1 -device scsi-cd,drive=d2,bootindex=2 -drive if=none,id=d2,media=cdrom,file=cdrom-boot-iso-g8yma5 -accel qtest ok 8 /s390x/cdrom/boot/pci-scsi-fallback-from-blk-ccw
Also, I was able to boot via virtio-scsi-pci manually:
qemu-system-s390x \
-nographic \
-accel kvm \
-m 1024 \
-machine s390-ccw-virtio \
-drive file=Fedora-Server-dvd-s390x-43-1.6.iso,media=cdrom,if=none,id=cdrom0 \
-device virtio-scsi-pci \
-device scsi-cd,drive=cdrom0,bootindex=1
Re: [PATCH v3 8/8] tests/qtest: Add s390x PCI SCSI fallback test to cdrom-test.c
In reply to [email protected]Quoted 9 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add a test to verify that a guest can use a PCI controlled CD as a fallback boot device after a failed CCW IPL.
Signed-off-by Jared Rossi <[email protected]>--- tests/qtest/cdrom-test.c | 8 ++++++++ 1 file changed, 8 insertions(+)
There are more permutations that we can add in the future, but this is a good start.
Quoted 20 lines
tests/qtest/cdrom-test.c +8
-0@@ -253,6 +253,14 @@ static void add_s390x_tests(void)"-drive if=none,id=d1,media=cdrom,file=" , test_cdboot); } +if (qtest_has_device ("virtio-scsi-pci" )) { +qtest_add_data_func ("cdrom/boot/pci-scsi-fallback-from-blk-ccw" , +"-device virtio-scsi-pci -device virtio-serial " +"-device virtio-blk-ccw,drive=d1,bootindex=1 " +"-drive driver=null-co,read-zeroes=on,if=none,id=d1 " +"-device scsi-cd,drive=d2,bootindex=2 " +"-drive if=none,id=d2,media=cdrom,file=" , test_cdboot); + } }int main (int argc,char **argv)
Eric Farman
AppliedQuoted 26 lines · On 8/31/26 3:49 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Add support for booting from SCSI devices with a virtio-scsi-pci controller.
Some minor clean-up is done with naming in order to clarify if the function or value used with CCW, PCI, or generic IPL and to check if a PCI function is already enabled.
Changes v2 -> v3:
- Rebase on recently added Secure IPL features added to BIOS
- Define PCI IPLB length using offset and sizeof rather than magic
- Check for virtio setup failures during scsi setup
- Fix commit messages
- Update the title of patch 3 to indicate multiple lengths changeJared Rossi (8):
pc-bios/s390-ccw: Check if a PCI function is already enabled before
trying to enable it
hw/s390x/ipl: Fix incorrect PCI IPL block lengths pc-bios/s390-ccw: Use bus specificIPL_TYPEdirectly for scsi IPL s390x/ipl: Add PCI and bus fields to IplBlockQemuScsi pc-bios/s390-ccw: Abstractvirtio_run()for generic use pc-bios/s390-ccw: Add support for virtio-scsi-pci IPL
s390x: Find scsi-pci boot device and build IPLB tests/qtest: Add s390x PCI SCSI fallback test tocdrom-test.c
Quoted 14 lines
hw/s390x/ipl.c | 40 ++++++++++++++++++++++++++++++++ hw/s390x/ipl.h | 2 ++ include/hw/s390x/ipl/qipl.h | 15 ++++++++---- pc-bios/s390-ccw/clp.c | 4 ++++ pc-bios/s390-ccw/main.c | 19 +++++++++++---- pc-bios/s390-ccw/virtio-blkdev.c | 1 - pc-bios/s390-ccw/virtio-ccw.c | 17 -------------- pc-bios/s390-ccw/virtio-ccw.h | 1 - pc-bios/s390-ccw/virtio-pci.c | 31 ++++++++++++++++++++++++- pc-bios/s390-ccw/virtio-scsi.c | 18 +++++++++++++- pc-bios/s390-ccw/virtio.c | 21 +++++++++-------- tests/qtest/cdrom-test.c | 8 +++++++ 12 files changed, 137 insertions(+), 40 deletions(-)
Thanks! Applied for 11.2