From patchwork Fri Aug 4 08:36:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9880835 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 28F75603B4 for ; Fri, 4 Aug 2017 08:37:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AA7A289B8 for ; Fri, 4 Aug 2017 08:37:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F668289BA; Fri, 4 Aug 2017 08:37:53 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 B5640288BE for ; Fri, 4 Aug 2017 08:37:52 +0000 (UTC) Received: from localhost ([::1]:45653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddY7D-0005JE-P8 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 04 Aug 2017 04:37:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddY68-0005HK-5e for qemu-devel@nongnu.org; Fri, 04 Aug 2017 04:36:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddY63-00067C-KR for qemu-devel@nongnu.org; Fri, 04 Aug 2017 04:36:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:50540 helo=mx1.suse.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ddY63-00065N-DG for qemu-devel@nongnu.org; Fri, 04 Aug 2017 04:36:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B36CFAC17; Fri, 4 Aug 2017 08:36:37 +0000 (UTC) From: Hannes Reinecke To: Paolo Bonzini Date: Fri, 4 Aug 2017 10:36:33 +0200 Message-Id: <1501835795-92331-3-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1501835795-92331-1-git-send-email-hare@suse.de> References: <1501835795-92331-1-git-send-email-hare@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 195.135.220.15 Subject: [Qemu-devel] [PATCHv2 2/4] scsi: use qemu_uuid to generate logical identifier for SES 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: Hannes Reinecke , qemu-devel@nongnu.org, Hannes Reinecke Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The SES enclosure descriptor requires a logical identifier, so generate one using the qemu_uuid and the Qumranet OUI. Signed-off-by: Hannes Reinecke --- hw/scsi/scsi-bus.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index c89e82d..8419c75 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -10,6 +10,7 @@ #include "trace.h" #include "sysemu/dma.h" #include "qemu/cutils.h" +#include "qemu/crc32c.h" static char *scsibus_get_dev_path(DeviceState *dev); static char *scsibus_get_fw_dev_path(DeviceState *dev); @@ -533,6 +534,22 @@ static bool scsi_target_emulate_receive_diagnostic(SCSITargetReq *r) enc_desc[0] = 0x09; enc_desc[2] = 1; enc_desc[3] = 0x24; + if (qemu_uuid_set) { + uint32_t crc; + + /* + * Make this a NAA IEEE Registered identifier + * using Qumranet OUI (0x001A4A) and the + * crc32 from the system UUID. + */ + enc_desc[4] = 0x50; + enc_desc[5] = 0x01; + enc_desc[6] = 0xa4; + enc_desc[7] = 0xa0; + crc = crc32c(0xffffffff, qemu_uuid.data, 16); + cpu_to_le32s(&crc); + memcpy(&enc_desc[8], &crc, 4); + } memcpy(&enc_desc[12], "QEMU ", 8); memcpy(&enc_desc[20], "QEMU TARGET ", 16); pstrcpy((char *)&enc_desc[36], 4, qemu_hw_version());