From patchwork Wed Jul 11 20:58:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 10520543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8A6D76028E for ; Wed, 11 Jul 2018 21:00:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A9EF299E2 for ; Wed, 11 Jul 2018 21:00:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 791CC299E9; Wed, 11 Jul 2018 21:00:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 225DB299F6 for ; Wed, 11 Jul 2018 21:00:05 +0000 (UTC) Received: from localhost ([::1]:55458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdMDU-0001Mh-V2 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 Jul 2018 17:00:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdMCo-0000f6-IU for qemu-devel@nongnu.org; Wed, 11 Jul 2018 16:59:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdMCn-0005ge-Go for qemu-devel@nongnu.org; Wed, 11 Jul 2018 16:59:22 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:41826) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fdMCn-0005ff-Ck for qemu-devel@nongnu.org; Wed, 11 Jul 2018 16:59:21 -0400 Received: by mail-qt0-x241.google.com with SMTP id e19-v6so8129822qtp.8 for ; Wed, 11 Jul 2018 13:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=TDbABxHQSRdi7m08KwvwMtBAYKsObbVl5CcZx6iBxG8=; b=IbLldWRsfCq69fESMiFppAvQNsAy2KAcihWkITrK9bMBFFg/0DZsXNPqaiO8GfQDqD lJJI9eVTChjwoQYKQtMp/QeqX8Ghzeop7PeJWrzdFdF8Nf0vP25gzmIiBTi7lPmQc1/u +P2Mh+6T0qoj+afrg6INok2Ynt6CPq5LjpmJMs0Lrn6DcFJdumKyrelDO3ViKR5Zdj3V 7FvaOITkde/pvIs+pimtLk3fLkQ+UL+LIVfTPF0BFAHZeg5kAj2D8hbtpIWzcxyJZxW5 jPdOJkrXxPHz22fQIiKAgj2j+6uMtvS2BgH1QQq6KZULgp97j762yK27INUEBzAKjSJl iKpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TDbABxHQSRdi7m08KwvwMtBAYKsObbVl5CcZx6iBxG8=; b=ktzlK82A/WmBOQ+6rfjhb3sdbjZEwW/RZOxFrSgisGYZ+m7ioJdD7gCVyo6AE2qPv5 y1QlnrWsU0w0+GVSIA64uA+XhoCQvCahtSS1NM8xYBsEGmMOUBMxun7wIoDBCeMaRujg rJHruAcR8/Won56myToFSh0mTqVh7bq1LdcR0jdUg9Fha4M9t8fGEsiSyqYVlu6lc1E3 Nv6+Wuo+MKP1m8QhrYP1J8MO3KtuQfeL64smxOgVS2sVpmQbjYHL2gdAq3rSoOKkSH6s 4fEr59eEyXLMiCglMkwqdqylAam2m6aI65KPuDNZaleiZ9AVhaxg0QhYLchfeaB2R11+ J6Og== X-Gm-Message-State: AOUpUlHYoiO/2gp7SSK0ArCf8pEP8aWtHq3hMGZU1bH8Rj5FUMXTkPIa vJEgkl/0jsFlk5l673k/1JiIBQ== X-Google-Smtp-Source: AAOMgpc/SNXZhbquuAwNVNx1Nywf0XkQoUaFgndAlVlJnuTDQo4tW102TLVF/j14E3VX+mfkXv8IcA== X-Received: by 2002:a0c:9b83:: with SMTP id o3-v6mr272400qve.21.1531342760495; Wed, 11 Jul 2018 13:59:20 -0700 (PDT) Received: from localhost.localdomain ([2804:431:f700:90d4:66ed:495e:29d6:30b7]) by smtp.gmail.com with ESMTPSA id m51-v6sm6601123qtc.85.2018.07.11.13.59.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 13:59:20 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Wed, 11 Jul 2018 17:58:13 -0300 Message-Id: <20180711205813.22346-1-danielhb413@gmail.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PATCH v1 1/1] scsi-disk: Block Device Characteristics emulation fix 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: , Cc: pbonzini@redhat.com, Daniel Henrique Barboza , famz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current BDC VPD page (page 0xb1) is too short. This can be seen running sg_utils: $ sg_vpd --page=bdc /dev/sda Block device characteristics VPD page (SBC): Block device characteristics VPD page length too short=8 By the SCSI spec, the expected size of the SBC page is 0x40. There is no telling how the guest will behave with a shorter message - it can ignore it, or worse, make (wrong) assumptions. This patch fixes the emulation by setting the size to 0x40. This is the output of the previous sg_vpd command after applying it: $ sg_vpd --page=bdc /dev/sda -v inquiry cdb: 12 01 b1 00 fc 00 Block device characteristics VPD page (SBC): [PQual=0 Peripheral device type: disk] Medium rotation rate is not reported Product type: Not specified WABEREQ=0 WACEREQ=0 Nominal form factor not reported FUAB=0 VBULS=0 To improve readability, this patch also adds the VBULS value explictly and add comments on the existing fields we're setting. Signed-off-by: Daniel Henrique Barboza Acked-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 32f3f96ff8..5ae7baa082 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -775,11 +775,12 @@ int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf) } case 0xb1: /* block device characteristics */ { - buflen = 8; + buflen = 0x40; outbuf[4] = (s->rotation_rate >> 8) & 0xff; outbuf[5] = s->rotation_rate & 0xff; - outbuf[6] = 0; - outbuf[7] = 0; + outbuf[6] = 0; /* PRODUCT TYPE */ + outbuf[7] = 0; /* WABEREQ | WACEREQ | NOMINAL FORM FACTOR */ + outbuf[8] = 0; /* VBULS */ break; } case 0xb2: /* thin provisioning */