From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Farhan Ali <alifm@linux.ibm.com>,
Jared Rossi <jrossi@linux.ibm.com>
Subject: [PULL 13/25] pc-bios/s390-ccw: Store device type independent of sense data
Date: Tue, 10 Mar 2026 06:55:18 +0100 [thread overview]
Message-ID: <20260310055530.8893-14-thuth@redhat.com> (raw)
In-Reply-To: <20260310055530.8893-1-thuth@redhat.com>
From: Jared Rossi <jrossi@linux.ibm.com>
Store the device type (e.g. block) directly as an attribute of the VDev rather
than assume all devices can be identified by accessing CCW specific sense data.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
Message-ID: <20260309003601.242634-6-jrossi@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
pc-bios/s390-ccw/virtio.h | 1 +
pc-bios/s390-ccw/main.c | 2 +-
pc-bios/s390-ccw/virtio-blkdev.c | 39 +++++++++++++++++++-------------
pc-bios/s390-ccw/virtio.c | 11 ++++++---
4 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
index 391d6ff2f7f..39b507b2219 100644
--- a/pc-bios/s390-ccw/virtio.h
+++ b/pc-bios/s390-ccw/virtio.h
@@ -239,6 +239,7 @@ struct VDev {
SubChannelId schid;
SenseId senseid;
S390IplType ipl_type;
+ VirtioDevType dev_type;
union {
VirtioBlkConfig blk;
VirtioScsiConfig scsi;
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
index 2e9261904fa..64bde497103 100644
--- a/pc-bios/s390-ccw/main.c
+++ b/pc-bios/s390-ccw/main.c
@@ -251,7 +251,7 @@ static int virtio_setup(void)
vdev->is_cdrom = false;
int ret;
- switch (vdev->senseid.cu_model) {
+ switch (vdev->dev_type) {
case VIRTIO_ID_NET:
puts("Network boot device detected");
return 0;
diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
index 019c2718b18..9cc40e9108d 100644
--- a/pc-bios/s390-ccw/virtio-blkdev.c
+++ b/pc-bios/s390-ccw/virtio-blkdev.c
@@ -53,14 +53,14 @@ int virtio_read_many(unsigned long sector, void *load_addr, int sec_num)
{
VDev *vdev = virtio_get_device();
- switch (vdev->senseid.cu_model) {
+ switch (vdev->dev_type) {
case VIRTIO_ID_BLOCK:
return virtio_blk_read_many(vdev, sector, load_addr, sec_num);
case VIRTIO_ID_SCSI:
return virtio_scsi_read_many(vdev, sector, load_addr, sec_num);
+ default:
+ return -1;
}
-
- return -1;
}
unsigned long virtio_load_direct(unsigned long rec_list1, unsigned long rec_list2,
@@ -119,7 +119,7 @@ void virtio_assume_iso9660(void)
{
VDev *vdev = virtio_get_device();
- switch (vdev->senseid.cu_model) {
+ switch (vdev->dev_type) {
case VIRTIO_ID_BLOCK:
vdev->guessed_disk_nature = VIRTIO_GDN_SCSI;
vdev->config.blk.blk_size = VIRTIO_ISO_BLOCK_SIZE;
@@ -129,6 +129,8 @@ void virtio_assume_iso9660(void)
case VIRTIO_ID_SCSI:
vdev->scsi_block_size = VIRTIO_ISO_BLOCK_SIZE;
break;
+ default:
+ return;
}
}
@@ -139,13 +141,15 @@ void virtio_assume_eckd(void)
vdev->guessed_disk_nature = VIRTIO_GDN_DASD;
vdev->blk_factor = 1;
vdev->config.blk.physical_block_exp = 0;
- switch (vdev->senseid.cu_model) {
+ switch (vdev->dev_type) {
case VIRTIO_ID_BLOCK:
vdev->config.blk.blk_size = VIRTIO_DASD_DEFAULT_BLOCK_SIZE;
break;
case VIRTIO_ID_SCSI:
vdev->config.blk.blk_size = vdev->scsi_block_size;
break;
+ default:
+ break;
}
vdev->config.blk.geometry.heads = 15;
vdev->config.blk.geometry.sectors =
@@ -162,50 +166,52 @@ bool virtio_ipl_disk_is_valid(void)
return true;
}
- return (vdev->senseid.cu_model == VIRTIO_ID_BLOCK ||
- vdev->senseid.cu_model == VIRTIO_ID_SCSI) &&
- blksize >= 512 && blksize <= 4096;
+ return (vdev->dev_type == VIRTIO_ID_BLOCK || vdev->dev_type == VIRTIO_ID_SCSI)
+ && blksize >= 512 && blksize <= 4096;
}
int virtio_get_block_size(void)
{
VDev *vdev = virtio_get_device();
- switch (vdev->senseid.cu_model) {
+ switch (vdev->dev_type) {
case VIRTIO_ID_BLOCK:
return vdev->config.blk.blk_size;
case VIRTIO_ID_SCSI:
return vdev->scsi_block_size;
+ default:
+ return 0;
}
- return 0;
}
uint8_t virtio_get_heads(void)
{
VDev *vdev = virtio_get_device();
- switch (vdev->senseid.cu_model) {
+ switch (vdev->dev_type) {
case VIRTIO_ID_BLOCK:
return vdev->config.blk.geometry.heads;
case VIRTIO_ID_SCSI:
return vdev->guessed_disk_nature == VIRTIO_GDN_DASD
? vdev->config.blk.geometry.heads : 255;
+ default:
+ return 0;
}
- return 0;
}
uint8_t virtio_get_sectors(void)
{
VDev *vdev = virtio_get_device();
- switch (vdev->senseid.cu_model) {
+ switch (vdev->dev_type) {
case VIRTIO_ID_BLOCK:
return vdev->config.blk.geometry.sectors;
case VIRTIO_ID_SCSI:
return vdev->guessed_disk_nature == VIRTIO_GDN_DASD
? vdev->config.blk.geometry.sectors : 63;
+ default:
+ return 0;
}
- return 0;
}
uint64_t virtio_get_blocks(void)
@@ -213,13 +219,14 @@ uint64_t virtio_get_blocks(void)
VDev *vdev = virtio_get_device();
const uint64_t factor = virtio_get_block_size() / VIRTIO_SECTOR_SIZE;
- switch (vdev->senseid.cu_model) {
+ switch (vdev->dev_type) {
case VIRTIO_ID_BLOCK:
return vdev->config.blk.capacity / factor;
case VIRTIO_ID_SCSI:
return vdev->scsi_last_block / factor;
+ default:
+ return 0;
}
- return 0;
}
int virtio_blk_setup_device(SubChannelId schid)
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index f384a990dcc..5dd407d5c9b 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -41,7 +41,7 @@ VDev *virtio_get_device(void)
VirtioDevType virtio_get_device_type(void)
{
- return vdev.senseid.cu_model;
+ return vdev.dev_type;
}
/* virtio spec v1.0 para 4.3.3.2 */
@@ -248,7 +248,7 @@ int virtio_setup_ccw(VDev *vdev)
return -EIO;
}
- switch (vdev->senseid.cu_model) {
+ switch (vdev->dev_type) {
case VIRTIO_ID_NET:
vdev->nr_vqs = 2;
vdev->cmd_vr_idx = 0;
@@ -346,12 +346,17 @@ bool virtio_is_supported(SubChannelId schid)
true)) {
return false;
}
+
+ vdev.dev_type = vdev.senseid.cu_model;
+
if (vdev.senseid.cu_type == 0x3832) {
- switch (vdev.senseid.cu_model) {
+ switch (vdev.dev_type) {
case VIRTIO_ID_BLOCK:
case VIRTIO_ID_SCSI:
case VIRTIO_ID_NET:
return true;
+ default:
+ return false;
}
}
return false;
--
2.53.0
next prev parent reply other threads:[~2026-03-10 5:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 5:55 [PULL 00/25] s390x & functional tests pull request for the softfreeze Thomas Huth
2026-03-10 5:55 ` [PULL 01/25] tests/qemu-iotests: Mark 182 as Linux-only Thomas Huth
2026-03-10 5:55 ` [PULL 02/25] tests/functional: Don't try to run functional tests on Windows Thomas Huth
2026-03-10 5:55 ` [PULL 03/25] tests/functional/ppc/test_40: Fix the URL of the NetBSD-7.1.2-prep.iso asset Thomas Huth
2026-03-19 17:41 ` Peter Maydell
2026-03-10 5:55 ` [PULL 04/25] tests/functional/x86_64: Disable memlock test for asan builds Thomas Huth
2026-03-10 5:55 ` [PULL 05/25] tests/functional/migration: Use socket_dir Thomas Huth
2026-03-10 5:55 ` [PULL 06/25] tests/functional/migration: Add migrate_vms Thomas Huth
2026-03-10 5:55 ` [PULL 07/25] tests/functional/migration: Use the migrate_vms helper Thomas Huth
2026-03-10 5:55 ` [PULL 08/25] tests/functional/ppc64/pseries: Remove custom migration routine Thomas Huth
2026-03-10 5:55 ` [PULL 09/25] pc-bios/s390-ccw: Fix misattributed function prototypes Thomas Huth
2026-03-10 5:55 ` [PULL 10/25] pc-bios/s390-ccw: Remove redundant vring schid attribute Thomas Huth
2026-03-10 5:55 ` [PULL 11/25] pc-bios/s390-ccw: Always reset virtio device on failed boot attempt Thomas Huth
2026-03-10 5:55 ` [PULL 12/25] s390x: Remove duplicate definitions of IPL types Thomas Huth
2026-03-10 5:55 ` Thomas Huth [this message]
2026-03-10 5:55 ` [PULL 14/25] pc-bios/s390-ccw: Split virtio-ccw and generic virtio Thomas Huth
2026-03-10 5:55 ` [PULL 15/25] include/hw/s390x: Move CLP definitions for easier BIOS access Thomas Huth
2026-03-10 5:55 ` [PULL 16/25] pc-bios/s390-ccw: Introduce CLP Architecture Thomas Huth
2026-03-10 5:55 ` [PULL 17/25] s390x: Add definitions for PCI IPL type Thomas Huth
2026-03-10 5:55 ` [PULL 18/25] pc-bios/s390-ccw: Introduce PCI device Thomas Huth
2026-03-10 5:55 ` [PULL 19/25] pc-bios/s390-ccw: Introduce virtio-pci functions Thomas Huth
2026-03-10 5:55 ` [PULL 20/25] pc-bios/s390-ccw: Add support for virtio-blk-pci IPL Thomas Huth
2026-03-10 5:55 ` [PULL 21/25] s390x: Build IPLB for virtio-pci devices Thomas Huth
2026-03-10 5:55 ` [PULL 22/25] hw: Add "loadparm" property to virtio block PCI devices booting on s390x Thomas Huth
2026-03-10 5:55 ` [PULL 23/25] tests/qtest: Add s390x PCI boot test to cdrom-test.c Thomas Huth
2026-03-10 5:55 ` [PULL 24/25] pc-bios/s390-ccw: Fix compiler warning when compiling with DEBUG enabled Thomas Huth
2026-03-10 5:55 ` [PULL 25/25] pc-bios/s390-ccw.img: Update the s390 bios blog with the latest changes Thomas Huth
2026-03-10 13:31 ` [PULL 00/25] s390x & functional tests pull request for the softfreeze Peter Maydell
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=20260310055530.8893-14-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=alifm@linux.ibm.com \
--cc=jrossi@linux.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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.