scsi: Make device scsi-disk reject /dev/sg*
PATCH 1/1 scsi: Make device scsi-disk reject /dev/sg*
You're supposed to use scsi-generic for that. Which rejects anything but /dev/sg*.
--- hw/scsi-disk.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
hw/scsi-disk.c +5 -0
@@ -1027,6 +1027,11 @@ static int scsi_disk_initfn(SCSIDevice *dev) } s->bs = s->qdev.conf.dinfo->bdrv; +if (bdrv_is_sg (s->bs)) { +qemu_error ("scsi-disk: unwanted /dev/sg*\n" ); +return -1 ; + } +if (bdrv_get_type_hint (s->bs) ==BDRV_TYPE_CDROM ) { s->cluster_size =4 ; }else {
Signature · 1 line
1.6.6
Quoted 2 lines · Markus Armbruster
You're supposed to use scsi-generic for that. Which rejects anything but
/dev/sg*.
Well, it isn't *that* easy. The SG_IO ioctl used by scsi-generic works on tons of devices in linux, not only /dev/sg*. I've seen patches floading around which change the check bdrv_is_sg() into "try SG_IO and see if it works", which would allow to use /dev/sda with both scsi-disk and scsi-generic depending on what you want. Which makes alot of sense.
Making that change needs some extra care though to avoid existing configurations switching from scsi-disk to scsi-generic unnoticed.
cheers,
Gerd
Quoted 6 lines · Gerd Hoffmann
Quoted 2 lines · Markus Armbruster
You're supposed to use scsi-generic for that. Which rejects anything but
/dev/sg*.Well, it isn't *that* easy. The
SG_IOioctl used by scsi-generic works on tons of devices in linux, not only/dev/sg*. I've seen
Yes, the existing check in scsi-generic is pretty cheesy. My patch just makes scsi-disk consistently cheesy ;)
Quoted 7 lines
patches floading around which change the check
bdrv_is_sg()into "trySG_IOand see if it works", which would allow to use/dev/sdawith both scsi-disk and scsi-generic depending on what you want. Which makes alot of sense.Making that change needs some extra care though to avoid existing configurations switching from scsi-disk to scsi-generic unnoticed.
Would be nice to have some day.
Quoted 12 lines · Markus Armbruster
Quoted 2 lines
You're supposed to use scsi-generic for that. Which rejects anything but
/dev/sg*.Well, it isn't *that* easy. The
SG_IOioctl used by scsi-generic works on tons of devices in linux, not only/dev/sg*. I've seen patches floading around which change the checkbdrv_is_sg()into "trySG_IOand see if it works", which would allow to use/dev/sdawith both scsi-disk and scsi-generic depending on what you want. Which makes alot of sense.Making that change needs some extra care though to avoid existing configurations switching from scsi-disk to scsi-generic unnoticed.
Don't we really want to be testing !bdrv_is_block() ?
Paul
Quoted 10 lines · Paul Brook
Quoted 10 lines · Markus Armbruster
Quoted 2 lines
You're supposed to use scsi-generic for that. Which rejects anything but
/dev/sg*.Well, it isn't *that* easy. The
SG_IOioctl used by scsi-generic works on tons of devices in linux, not only/dev/sg*. I've seen patches floading around which change the checkbdrv_is_sg()into "trySG_IOand see if it works", which would allow to use/dev/sdawith both scsi-disk and scsi-generic depending on what you want. Which makes alot of sense.
Quoted 4 lines
Quoted 2 lines
Making that change needs some extra care though to avoid existing configurations switching from scsi-disk to scsi-generic unnoticed.
Don't we really want to be testing !bdrv_is_block() ?
That would work for linux. Dunno about the BSD.
cheers,
Gerd
Quoted 13 lines · Markus Armbruster
You're supposed to use scsi-generic for that. Which rejects anything but
/dev/sg*.Signed-off-by Markus Armbruster <[email protected]>--- hw/scsi-disk.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)hw/scsi-disk.c +0
-0
hw/scsi-disk.c static int scsi_disk_initfn(SCSIDevice *dev) · line 1032
Quoted 6 lines
hw/scsi-disk.c +3
-0@@ -1027,6 +1027,11 @@ static int scsi_disk_initfn(SCSIDevice *dev) } s->bs = s->qdev.conf.dinfo->bdrv; +if (bdrv_is_sg (s->bs)) { +qemu_error ("scsi-disk: unwanted /dev/sg*\n" ); +return -1 ;
Can we make the error message a bit more verbose?
E.g. "scsi-disk does not support /dev/sg*, please use *** instead". Where *** tells user what to do.
Quoted 9 lines
hw/scsi-disk.c +2
-0+ } +if (bdrv_get_type_hint (s->bs) ==BDRV_TYPE_CDROM ) { s->cluster_size =4 ; }else {Signature · 1 line
1.6.6
Anthony Liguori
AppliedQuoted 6 lines · Markus Armbruster
You're supposed to use scsi-generic for that. Which rejects anything but
/dev/sg*.Signed-off-by Markus Armbruster<[email protected]>---
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 20 lines
hw/scsi-disk.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)hw/scsi-disk.c +5
-0@@ -1027,6 +1027,11 @@ static int scsi_disk_initfn(SCSIDevice *dev) } s->bs = s->qdev.conf.dinfo->bdrv; +if (bdrv_is_sg (s->bs)) { +qemu_error ("scsi-disk: unwanted /dev/sg*\n" ); +return -1 ; + } +if (bdrv_get_type_hint (s->bs) ==BDRV_TYPE_CDROM ) { s->cluster_size =4 ; }else {