From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96DFAC48BE8 for ; Tue, 15 Jun 2021 13:44:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 47D9661439 for ; Tue, 15 Jun 2021 13:44:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47D9661439 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lt9Mw-0005pZ-E0 for qemu-devel@archiver.kernel.org; Tue, 15 Jun 2021 09:44:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lt9HV-0005a9-Ve for qemu-devel@nongnu.org; Tue, 15 Jun 2021 09:39:06 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:41617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lt9HS-0002ej-HJ for qemu-devel@nongnu.org; Tue, 15 Jun 2021 09:39:04 -0400 Received: by mail-ed1-x531.google.com with SMTP id g18so49204376edq.8 for ; Tue, 15 Jun 2021 06:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A7t2qX0fg1RYkfLkBI/P/I/raO7zJCJeZ8mm+rgtgLc=; b=mjYTPHNzZvpUzEftkcPlsqlVnpbU6r0LsnjdCvUoj58V4zCEY1Okq/jesDXnEOB1qB +nifTe68//m9R+lLDqHYUSyosSNOUm6E2r4Znydch4Tv26RSyXY3SO0kfq9ZQELHrMq9 RhTQIlecDvDw7kAzWWTM2MvQVeZy/+SiUu75JCtfJkXoK2lmbicd5xo6kSwd63508FQ+ 7ID/qqSVfh6MZGRxdkkxm0Vx1bS519SMEdiYPYjD8VGSZBvlawdxn48zNV3KOM/S7hTE IlrsVdoY60x69o4mi5n1BYnfmErxPwW6FYX6I+gtpCqyP5pSRdFkprByAZbtcEp6ml94 wUkg== 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:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=A7t2qX0fg1RYkfLkBI/P/I/raO7zJCJeZ8mm+rgtgLc=; b=BoyvJDfARqlXT3BWX5CFjTol6u1zgzzJkGchzcfuJy5q99CczVJ/2xea8UzpYxOYEB oyAKEgLy9KD1Myi34TvfkNFZQmyPIKILIe2DQfMJWnD3cHxeUzn3rNy+pY0/E3g5yK5+ yBCbl+0Pmt7RZpz9t9N1UzNDvCeKxtxql3jeEZHnsJanQpa7Ov8Y5GWU3KGJ1g1o+WjR khiJEcbcpyLt7MMD5h6JwG7ir/9TWh8FnapXHDOOcz2Dxx2gsFc4v7YDLwtbWiEuM996 Eq9wwHSANb5OFa73RuR3Ley45UgCbpS4rS8fvXmZA0vD9HQvCD6UvfPZviR++iH96zVI jnyA== X-Gm-Message-State: AOAM533aHEyxqNklO83QeYgW6EEH2ELYetyP4H1XqQmkX1T0FtSDDscc paQ5F8Fb0VxNaEGpeWFFhNpzkK9yYj0= X-Google-Smtp-Source: ABdhPJyMQqspfv5a8wg4akg2vaLyxGZ0ptgiI1WgGg38O4gx/BrHtEETpCQBQJaldAcygJMnSFSgPA== X-Received: by 2002:a05:6402:1ac9:: with SMTP id ba9mr23850945edb.250.1623764340490; Tue, 15 Jun 2021 06:39:00 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id r17sm11843769edt.33.2021.06.15.06.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 06:39:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/33] block/scsi: correctly emulate the VPD block limits page Date: Tue, 15 Jun 2021 15:38:26 +0200 Message-Id: <20210615133855.775687-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210615133855.775687-1-pbonzini@redhat.com> References: <20210615133855.775687-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Reitz , Maxim Levitsky Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Maxim Levitsky When the device doesn't support the VPD block limits page, we emulate it even for SCSI passthrough. As a part of the emulation we need to add it to the 'Supported VPD Pages' The code that does this adds it to the page, but it doesn't increase the length of the data to be copied to the guest, thus the guest never sees the VPD block limits page as supported. Bump the transfer size by 1 in this case. Signed-off-by: Maxim Levitsky Reviewed-by: Max Reitz Message-Id: <20201217165612.942849-6-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-generic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 98c30c5d5c..40e039864f 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -147,7 +147,7 @@ static int execute_command(BlockBackend *blk, return 0; } -static void scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s) +static int scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s, int len) { uint8_t page, page_idx; @@ -213,8 +213,13 @@ static void scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s) r->buf[page_idx] = 0xb0; } stw_be_p(r->buf + 2, lduw_be_p(r->buf + 2) + 1); + + if (len < r->buflen) { + len++; + } } } + return len; } static int scsi_generic_emulate_block_limits(SCSIGenericReq *r, SCSIDevice *s) @@ -332,7 +337,7 @@ static void scsi_read_complete(void * opaque, int ret) } } if (r->req.cmd.buf[0] == INQUIRY) { - scsi_handle_inquiry_reply(r, s); + len = scsi_handle_inquiry_reply(r, s, len); } req_complete: -- 2.31.1