From patchwork Thu Aug 3 13:27:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9879111 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 767DF603B4 for ; Thu, 3 Aug 2017 13:28:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A4BA2860E for ; Thu, 3 Aug 2017 13:28:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F4B4288F4; Thu, 3 Aug 2017 13:28:16 +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 104D5288EC for ; Thu, 3 Aug 2017 13:28:16 +0000 (UTC) Received: from localhost ([::1]:42679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddGAh-0006OF-6F for patchwork-qemu-devel@patchwork.kernel.org; Thu, 03 Aug 2017 09:28:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddG9e-0006Kz-Dd for qemu-devel@nongnu.org; Thu, 03 Aug 2017 09:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddG9a-0007CT-LJ for qemu-devel@nongnu.org; Thu, 03 Aug 2017 09:27:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:47249 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 1ddG9a-00075N-Ch for qemu-devel@nongnu.org; Thu, 03 Aug 2017 09:27:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A0884AF11; Thu, 3 Aug 2017 13:27:03 +0000 (UTC) From: Hannes Reinecke To: Paolo Bonzini Date: Thu, 3 Aug 2017 15:27:01 +0200 Message-Id: <1501766821-76419-3-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1501766821-76419-1-git-send-email-hare@suse.de> References: <1501766821-76419-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] [PATCH 2/2] 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());