scsi: turn "is this a SCSI device?" into a conditional hint
If the user does not have permissions to send ioctls to the device (due to SELinux or cgroups, for example), the output can look like qemu-kvm: -device scsi-block,drive=disk: cannot get SG_IO version number: Operation not permitted. Is this a SCSI device? but this is confusing because the ioctl was blocked _before_ the device even received the SG_GET_VERSION_NUM ioctl. Therefore, for EPERM errors the suggestion should be eliminated. To make that simpler, change the code to use error_append_hint. Reported-by: Ala Hino <ahino@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
ff82fab792
commit
09c2c6ffda
|
@ -2607,9 +2607,10 @@ static void scsi_block_realize(SCSIDevice *dev, Error **errp)
|
||||||
/* check we are using a driver managing SG_IO (version 3 and after) */
|
/* check we are using a driver managing SG_IO (version 3 and after) */
|
||||||
rc = blk_ioctl(s->qdev.conf.blk, SG_GET_VERSION_NUM, &sg_version);
|
rc = blk_ioctl(s->qdev.conf.blk, SG_GET_VERSION_NUM, &sg_version);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
error_setg(errp, "cannot get SG_IO version number: %s. "
|
error_setg_errno(errp, -rc, "cannot get SG_IO version number");
|
||||||
"Is this a SCSI device?",
|
if (rc != -EPERM) {
|
||||||
strerror(-rc));
|
error_append_hint(errp, "Is this a SCSI device?\n");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sg_version < 30000) {
|
if (sg_version < 30000) {
|
||||||
|
|
|
@ -500,9 +500,10 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp)
|
||||||
/* check we are using a driver managing SG_IO (version 3 and after */
|
/* check we are using a driver managing SG_IO (version 3 and after */
|
||||||
rc = blk_ioctl(s->conf.blk, SG_GET_VERSION_NUM, &sg_version);
|
rc = blk_ioctl(s->conf.blk, SG_GET_VERSION_NUM, &sg_version);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
error_setg(errp, "cannot get SG_IO version number: %s. "
|
error_setg_errno(errp, -rc, "cannot get SG_IO version number");
|
||||||
"Is this a SCSI device?",
|
if (rc != -EPERM) {
|
||||||
strerror(-rc));
|
error_append_hint(errp, "Is this a SCSI device?\n");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sg_version < 30000) {
|
if (sg_version < 30000) {
|
||||||
|
|
Loading…
Reference in a new issue