From nobody Mon Feb 9 23:02:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522072120511311.3710528405285; Mon, 26 Mar 2018 06:48:40 -0700 (PDT) Received: from localhost ([::1]:56857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0SUJ-0008SK-Ey for importer@patchew.org; Mon, 26 Mar 2018 09:48:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0SJ6-0006ee-FO for qemu-devel@nongnu.org; Mon, 26 Mar 2018 09:37:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0SJ5-00071e-IV for qemu-devel@nongnu.org; Mon, 26 Mar 2018 09:37:04 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:45504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f0SJ5-00071I-C1 for qemu-devel@nongnu.org; Mon, 26 Mar 2018 09:37:03 -0400 Received: by mail-wr0-x22b.google.com with SMTP id u11so6645037wri.12 for ; Mon, 26 Mar 2018 06:37:03 -0700 (PDT) Received: from 640k.lan (94-36-194-48.adsl-ull.clienti.tiscali.it. [94.36.194.48]) by smtp.gmail.com with ESMTPSA id g186sm6710105wmd.41.2018.03.26.06.37.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 06:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=KHzjZWRFoeyCQvdnh45DI5gmS63JZJCa6vUxT1Aa1vg=; b=OjbXSl+4vuE86vddgSFxoeDezmoSWawoQVf3OUxGZuoMXC2MGOqskZZxIBe48fChnX kaSIoxmz5WM8UngQYBngAqL34V07vROJK2rB9gYwdDmaBAcgqhNzjNtF5uWba4dSQRL4 sfaAI2oWbu4g5ND7jKfrw8mGeSnTVK9mEVyYE6Y7ETD76ncd05LIdBmeLEVad4LGAgsc iWdcHE8TJZF+NaQpXdObfj4OIy0dsMl1LYXyY/qQTi8i3kT3UB6OCpwel/ByteMNJTG5 ot5/+ddCEjbekAG/e2FY8vDZtPT1lZXEdJWky3Yr/JCmXsSMJVJreY/ketg7IgkPUoee Ls1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=KHzjZWRFoeyCQvdnh45DI5gmS63JZJCa6vUxT1Aa1vg=; b=LsslCZmCnZH79i0OPdvNDXImii9wcbr+0+HqNMr0yNFPy1mYH96fyHmpNRB0148Uj9 aLIxHTAQAz+Oo/989P4AbA4NXO1VFjv8Zsi1I2aCMUHZQd1dM3bZFaJH9OT3qwIHhRQS OETwQSIoX12/+y2PTclKImcy1OqI1I6tZ+8axXUiVdpsKjObxUyd/JiFTLscKmtdy6zH KTDP7FPIhIU8ohwlaSb7Tp0Rae6Ak62gG33oGUWj9t8qQXAdujQT+TPS9VWgjxaaHRm1 aqzEBusS2rIaIP5ZHVGljFKUWtvPt1StNrAneWMA0CNpGXTTbgO41S4wfxBVfCNO40jE /qgA== X-Gm-Message-State: AElRT7Ffa2Vo7XtjTHN2CxePDcHdCNTxZXHoaCvUaZDY8GrppDoiP+VW voLOtJCbBHJAqOhE32M/tEvHv6o4 X-Google-Smtp-Source: AG47ELslLBfv8Qb9lESAlg0d8/ijIw4qjhR0ojLeO7NfvLqoG0AAhvbU8CORt7r8Sqfu7No6la4ePg== X-Received: by 10.223.195.124 with SMTP id e57mr28990794wrg.135.1522071421898; Mon, 26 Mar 2018 06:37:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 15:36:40 +0200 Message-Id: <1522071403-52486-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1522071403-52486-1-git-send-email-pbonzini@redhat.com> References: <1522071403-52486-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b Subject: [Qemu-devel] [PULL 13/16] scsi: turn "is this a SCSI device?" into a conditional hint X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=3Ddisk: 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 Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 7 ++++--- hw/scsi/scsi-generic.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 5b7a48f..f5ab767 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2607,9 +2607,10 @@ static void scsi_block_realize(SCSIDevice *dev, Erro= r **errp) /* check we are using a driver managing SG_IO (version 3 and after) */ rc =3D blk_ioctl(s->qdev.conf.blk, SG_GET_VERSION_NUM, &sg_version); if (rc < 0) { - error_setg(errp, "cannot get SG_IO version number: %s. " - "Is this a SCSI device?", - strerror(-rc)); + error_setg_errno(errp, -rc, "cannot get SG_IO version number"); + if (rc !=3D -EPERM) { + error_append_hint(errp, "Is this a SCSI device?\n"); + } return; } if (sg_version < 30000) { diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 7414fe2..4753f87 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -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 */ rc =3D blk_ioctl(s->conf.blk, SG_GET_VERSION_NUM, &sg_version); if (rc < 0) { - error_setg(errp, "cannot get SG_IO version number: %s. " - "Is this a SCSI device?", - strerror(-rc)); + error_setg_errno(errp, -rc, "cannot get SG_IO version number"); + if (rc !=3D -EPERM) { + error_append_hint(errp, "Is this a SCSI device?\n"); + } return; } if (sg_version < 30000) { --=20 1.8.3.1