From: Karolina Stolarek <karolina.stolarek@oracle.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, "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: Re: [PATCH 1/2] virtio-scsi: Make max_target value configurable
Date: Wed, 10 Dec 2025 17:55:36 +0100 [thread overview]
Message-ID: <2929f151-0f5e-40c0-ab76-632649f328a7@oracle.com> (raw)
In-Reply-To: <87h5u1hye5.fsf@draig.linaro.org>
On 08/12/2025 14:54, Alex Bennée wrote:
> Karolina Stolarek <karolina.stolarek@oracle.com> writes:
>
>> -static struct SCSIBusInfo virtio_scsi_scsi_info = {
>> - .tcq = true,
>> - .max_channel = VIRTIO_SCSI_MAX_CHANNEL,
>> - .max_target = VIRTIO_SCSI_MAX_TARGET,
>> - .max_lun = VIRTIO_SCSI_MAX_LUN,
>
> See bellow.
>
>> -
>> - .complete = virtio_scsi_command_complete,
>> - .fail = virtio_scsi_command_failed,
>> - .cancel = virtio_scsi_request_cancelled,
>> - .change = virtio_scsi_change,
>> - .parse_cdb = virtio_scsi_parse_cdb,
>> - .get_sg_list = virtio_scsi_get_sg_list,
>> - .save_request = virtio_scsi_save_request,
>> - .load_request = virtio_scsi_load_request,
>> - .drained_begin = virtio_scsi_drained_begin,
>> - .drained_end = virtio_scsi_drained_end,
>> -};
>> +static struct SCSIBusInfo virtio_scsi_scsi_info;
>> +
>
> We can't have a static structure here otherwise all the VirtIO scsi
> devices will share the same configuration.
Ah, that is true, it escaped me.
>
>> +static void virtio_scsi_init_scsi_info(struct VirtIOSCSIConf *conf)
>> +{
>> + virtio_scsi_scsi_info.tcq = true;
>> + virtio_scsi_scsi_info.max_channel = VIRTIO_SCSI_MAX_CHANNEL;
>> + virtio_scsi_scsi_info.max_lun = VIRTIO_SCSI_MAX_LUN;
>> + virtio_scsi_scsi_info.max_target = conf->max_target;
>
> I think we need to allocate a dynamic configuration block for this
> stuff. Although given we have ops and config mixed in this structure I
> suspect the cleaner option is to re-factor SCSIBusInfo into
> SCSIBusConfig and SCSIBusOps so you can keep the static around. But this
> would touch quite a bit of code.
I understand, that sounds like a better solution. It might take some
time to finalize this, but I'd like to try it for v2.
Many thanks for your review, really appreciate it.
All the best,
Karolina
>
>> +
>> + virtio_scsi_scsi_info.complete = virtio_scsi_command_complete;
>> + virtio_scsi_scsi_info.fail = virtio_scsi_command_failed;
>> + virtio_scsi_scsi_info.cancel = virtio_scsi_request_cancelled;
>> + virtio_scsi_scsi_info.change = virtio_scsi_change;
>> + virtio_scsi_scsi_info.parse_cdb = virtio_scsi_parse_cdb;
>> + virtio_scsi_scsi_info.get_sg_list = virtio_scsi_get_sg_list;
>> + virtio_scsi_scsi_info.save_request = virtio_scsi_save_request;
>> + virtio_scsi_scsi_info.load_request = virtio_scsi_load_request;
>> + virtio_scsi_scsi_info.drained_begin = virtio_scsi_drained_begin;
>> + virtio_scsi_scsi_info.drained_end = virtio_scsi_drained_end;
>> +}
>>
>> void virtio_scsi_common_realize(DeviceState *dev,
>> VirtIOHandleOutput ctrl,
>> @@ -1289,6 +1292,7 @@ void virtio_scsi_common_realize(DeviceState *dev,
>> int i;
>>
>> virtio_init(vdev, VIRTIO_ID_SCSI, sizeof(VirtIOSCSIConfig));
>> + virtio_scsi_init_scsi_info(&s->conf);
>>
>> if (s->conf.num_queues == VIRTIO_SCSI_AUTO_NUM_QUEUES) {
>> s->conf.num_queues = 1;
>> @@ -1379,6 +1383,8 @@ static const Property virtio_scsi_properties[] = {
>> parent_obj.conf.virtqueue_size, 256),
>> DEFINE_PROP_BOOL("seg_max_adjust", VirtIOSCSI,
>> parent_obj.conf.seg_max_adjust, true),
>> + DEFINE_PROP_UINT16("max_target", VirtIOSCSICommon, conf.max_target,
>> + VIRTIO_SCSI_MAX_TARGET),
>> DEFINE_PROP_UINT32("max_sectors", VirtIOSCSI, parent_obj.conf.max_sectors,
>> 0xFFFF),
>> DEFINE_PROP_UINT32("cmd_per_lun", VirtIOSCSI, parent_obj.conf.cmd_per_lun,
>> diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
>> index b6028bb5cd..3998b241f6 100644
>> --- a/include/hw/virtio/virtio-scsi.h
>> +++ b/include/hw/virtio/virtio-scsi.h
>> @@ -54,6 +54,7 @@ struct VirtIOSCSIConf {
>> uint32_t virtqueue_size;
>> bool worker_per_virtqueue;
>> bool seg_max_adjust;
>> + uint16_t max_target;
>> uint32_t max_sectors;
>> uint32_t cmd_per_lun;
>> char *vhostfd;
>
next prev parent reply other threads:[~2025-12-10 16:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 11:01 [PATCH 0/2] virtio-scsi: Flexible max_target and max_lun params Karolina Stolarek
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 [this message]
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=2929f151-0f5e-40c0-ab76-632649f328a7@oracle.com \
--to=karolina.stolarek@oracle.com \
--cc=alex.bennee@linaro.org \
--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).