From: Karolina Stolarek <karolina.stolarek@oracle.com>
To: qemu-devel@nongnu.org
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>,
Mike Christie <michael.christie@oracle.com>
Subject: [PATCH 0/2] virtio-scsi: Flexible max_target and max_lun params
Date: Tue, 25 Nov 2025 11:01:49 +0000 [thread overview]
Message-ID: <cover.1763999544.git.karolina.stolarek@oracle.com> (raw)
Currently, the maximum number of targets is set and dictated
by virtio-scsi. On probe, the driver walks through all possible
targets to discover which of them are available. In the process,
it sends INQUIRY commands to request device information, also
querying devices that don't exist. This can be observed in
a guest with a single scsi-hd device and verbose SCSI logging
enabled:
scsi 0:0:0:0: scsi scan: REPORT LUN scan
scsi 0:0:0:0: scsi scan: device exists on 0:0:0:0
scsi 0:0:1:0: scsi scan: INQUIRY pass 1 length 36
scsi 0:0:1:0: scsi scan: INQUIRY failed with code 0x40000
(...)
scsi 0:0:255:0: scsi scan: INQUIRY pass 1 length 36
scsi 0:0:255:0: scsi scan: INQUIRY failed with code 0x40000
In the vhost-scsi backend, without the kernel patch [1], the issue
is far more noticeable. Each command queued up for a non-existing
target triggers vq_error(), registered by
vhost_virtqueue_error_notifier(), resulting in a flood of
"vhost vring error in virtqueue X" messages when booting up a VM.
Even with the [1] patch in place, we are still sending commands
to phantom targets with no way of limiting the scan. The first
patch in the series addresses this issue by introducing "max_target"
property for virtio-scsi and vhost-scsi devices. A user gets
an option to specify how many targets are used by the guest,
and to stop scanning before hitting VIRTIO_SCSI_MAX_TARGET.
A similar issue can be seen with Logical Units in the existing
devices. By default, the SCSI Host Adapter instance expects
8 LUNs, and some drivers assume this to be the actual number
of exposed LUNs. This results in executing SCSI commands that
refer to non-existing Logical Units. This can be easily observed
when using vhost-scsi backend, as such messages appear in
the host's dmesg when booting up a guest:
TARGET_CORE[vhost]: Detected NON_EXISTENT_LUN Access for 0x00000001 from
naa.5001405277e02c68
TARGET_CORE[vhost]: Detected NON_EXISTENT_LUN Access for 0x00000002 from
naa.5001405277e02c68
TARGET_CORE[vhost]: Detected NON_EXISTENT_LUN Access for 0x00000003 from
naa.5001405277e02c68
TARGET_CORE[vhost]: Detected NON_EXISTENT_LUN Access for 0x00000004 from
naa.5001405277e02c68
TARGET_CORE[vhost]: Detected NON_EXISTENT_LUN Access for 0x00000005 from
naa.5001405277e02c68
TARGET_CORE[vhost]: Detected NON_EXISTENT_LUN Access for 0x00000006 from
naa.5001405277e02c68
TARGET_CORE[vhost]: Detected NON_EXISTENT_LUN Access for 0x00000007 from
naa.5001405277e02c68
The second patch provides a way to say how many LUNs are actually
there by setting "max_lun" property in virtio-scsi and vhost-scsi
devices. If neither property is defined, max_target and max_lun are
set to the default values, making these definitions optional.
----------------------------
[1] -
https://lore.kernel.org/virtualization/20250607171815.111030-1-michael.christie@oracle.com/T/#u
Karolina Stolarek (2):
virtio-scsi: Make max_target value configurable
virtio-scsi: Make max_lun value configurable
hw/scsi/vhost-scsi.c | 4 +++
hw/scsi/virtio-scsi.c | 46 +++++++++++++++++++--------------
include/hw/virtio/virtio-scsi.h | 2 ++
3 files changed, 33 insertions(+), 19 deletions(-)
--
2.47.1
next reply other threads:[~2025-11-25 11:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 11:01 Karolina Stolarek [this message]
2025-11-25 11:01 ` [PATCH 1/2] virtio-scsi: Make max_target value configurable Karolina Stolarek
2025-12-08 13:54 ` Alex Bennée
2025-12-10 16:55 ` Karolina Stolarek
2025-11-25 11:01 ` [PATCH 2/2] virtio-scsi: Make max_lun " Karolina Stolarek
2025-12-08 12:18 ` [PATCH 0/2] virtio-scsi: Flexible max_target and max_lun params Karolina Stolarek
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=cover.1763999544.git.karolina.stolarek@oracle.com \
--to=karolina.stolarek@oracle.com \
--cc=fam@euphon.net \
--cc=michael.christie@oracle.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).