Received: from eggs.gnu.org ([2001:4830:134:3::10]:40180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK4uB-0007xU-Ht for qemu-devel@nongnu.org; Thu, 12 Sep 2013 07:17:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK4u5-00051g-OQ for qemu-devel@nongnu.org; Thu, 12 Sep 2013 07:17:47 -0400 Received: from mail-ea0-x22f.google.com ([2a00:1450:4013:c01::22f]:35760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK4u5-00051V-Gm for qemu-devel@nongnu.org; Thu, 12 Sep 2013 07:17:41 -0400 Received: by mail-ea0-f175.google.com with SMTP id m14so5186218eaj.20 for ; Thu, 12 Sep 2013 04:17:40 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 12 Sep 2013 13:17:14 +0200 Message-Id: <1378984634-765-12-git-send-email-pbonzini@redhat.com> In-Reply-To: <1378984634-765-1-git-send-email-pbonzini@redhat.com> References: <1378984634-765-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 11/11] spapr-vscsi: Report error on unsupported MAD requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy From: Alexey Kardashevskiy The existing driver just dropped unsupported requests. This adds error responses to those unhandled requests. Signed-off-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini --- hw/scsi/spapr_vscsi.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index f206452..2a26042 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -977,29 +977,43 @@ static int vscsi_send_capabilities(VSCSIState *s, vscsi_req *req) static int vscsi_handle_mad_req(VSCSIState *s, vscsi_req *req) { union mad_iu *mad = &req->iu.mad; + bool request_handled = false; + uint64_t retlen = 0; switch (be32_to_cpu(mad->empty_iu.common.type)) { case VIOSRP_EMPTY_IU_TYPE: fprintf(stderr, "Unsupported EMPTY MAD IU\n"); + retlen = sizeof(mad->empty_iu); break; case VIOSRP_ERROR_LOG_TYPE: fprintf(stderr, "Unsupported ERROR LOG MAD IU\n"); - mad->error_log.common.status = cpu_to_be16(1); - vscsi_send_iu(s, req, sizeof(mad->error_log), VIOSRP_MAD_FORMAT); + retlen = sizeof(mad->error_log); break; case VIOSRP_ADAPTER_INFO_TYPE: vscsi_send_adapter_info(s, req); + request_handled = true; break; case VIOSRP_HOST_CONFIG_TYPE: - mad->host_config.common.status = cpu_to_be16(1); - vscsi_send_iu(s, req, sizeof(mad->host_config), VIOSRP_MAD_FORMAT); + retlen = sizeof(mad->host_config); break; case VIOSRP_CAPABILITIES_TYPE: vscsi_send_capabilities(s, req); + request_handled = true; break; default: fprintf(stderr, "VSCSI: Unknown MAD type %02x\n", be32_to_cpu(mad->empty_iu.common.type)); + /* + * PAPR+ says that "The length field is set to the length + * of the data structure(s) used in the command". + * As we did not recognize the request type, put zero there. + */ + retlen = 0; + } + + if (!request_handled) { + mad->empty_iu.common.status = cpu_to_be16(VIOSRP_MAD_NOT_SUPPORTED); + vscsi_send_iu(s, req, retlen, VIOSRP_MAD_FORMAT); } return 1; -- 1.8.3.1