From patchwork Mon Jul 2 09:41:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 168531 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CE0DE2C01FD for ; Mon, 2 Jul 2012 19:42:06 +1000 (EST) Received: from localhost ([::1]:42016 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sld8u-0003uj-JQ for incoming@patchwork.ozlabs.org; Mon, 02 Jul 2012 05:42:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sld8a-0003kj-3S for qemu-devel@nongnu.org; Mon, 02 Jul 2012 05:41:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sld8T-0006YH-31 for qemu-devel@nongnu.org; Mon, 02 Jul 2012 05:41:43 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:46516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sld8S-0006YB-RL for qemu-devel@nongnu.org; Mon, 02 Jul 2012 05:41:37 -0400 Received: by wibhm2 with SMTP id hm2so2425777wib.10 for ; Mon, 02 Jul 2012 02:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=yG28CUQEwDQA2W4u9jb87ELtK5lU8ALe0jL2JFwrzgU=; b=T4ZV0ExlXrlwfIn8IKbIvtTk1KH4Rfuj7/0FXDxmQ4aEVJT/HSIGFMncpV3vEH0i4X Qn9g0Phz8An5kR7hiYbL5BaaTBhnS/IGa7QbkwDIlUgtRMqe8tvjSlu23eGdpgI2ccqd nsaH6EHrvwZRe85QqeubR2mi3HnK+ea85xtNtQAhuaglRRjzZLfl7oek+ZP5vv/64Ouh QAKXH2iCcuQ5eDvFw0XWZBVpVZ//CwLv95k2GwmAO09yw7XL17LKm+/5OoZsKO34IGcS MKlknPZmS8t6X/AatQOE3nG4u2KPxNk8BAD1EbucApzLSOH5Qo0uzbk7J52O5hXXGa9g ufyw== Received: by 10.216.131.170 with SMTP id m42mr935364wei.82.1341222094623; Mon, 02 Jul 2012 02:41:34 -0700 (PDT) Received: from yakj.usersys.redhat.com (nat-pool-mxp-t.redhat.com. [209.132.186.18]) by mx.google.com with ESMTPS id bg10sm43224317wib.9.2012.07.02.02.41.32 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 02 Jul 2012 02:41:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 2 Jul 2012 11:41:15 +0200 Message-Id: <1341222087-24920-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.2 In-Reply-To: <1341222087-24920-1-git-send-email-pbonzini@redhat.com> References: <1341222087-24920-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.175 Subject: [Qemu-devel] [PATCH 02/14] scsi: add a qdev property for the disk's WWN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- hw/scsi-disk.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 747e756..e87e57c 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -67,6 +67,7 @@ struct SCSIDiskState bool media_changed; bool media_event; bool eject_request; + uint64_t wwn; QEMUBH *bh; char *version; char *serial; @@ -587,9 +588,17 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) outbuf[buflen++] = 0; // not officially assigned outbuf[buflen++] = 0; // reserved outbuf[buflen++] = id_len; // length of data following - memcpy(outbuf+buflen, str, id_len); buflen += id_len; + + if (s->wwn) { + outbuf[buflen++] = 0x1; // Binary + outbuf[buflen++] = 0x3; // NAA + outbuf[buflen++] = 0; // reserved + outbuf[buflen++] = 8; + stq_be_p(&outbuf[buflen], s->wwn); + buflen += 8; + } break; } case 0xb0: /* block limits */ @@ -1924,6 +1933,7 @@ static Property scsi_hd_properties[] = { SCSI_DISK_F_REMOVABLE, false), DEFINE_PROP_BIT("dpofua", SCSIDiskState, features, SCSI_DISK_F_DPOFUA, false), + DEFINE_PROP_HEX64("wwn", SCSIDiskState, wwn, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -1968,6 +1978,7 @@ static TypeInfo scsi_hd_info = { static Property scsi_cd_properties[] = { DEFINE_SCSI_DISK_PROPERTIES(), + DEFINE_PROP_HEX64("wwn", SCSIDiskState, wwn, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -2029,6 +2040,7 @@ static Property scsi_disk_properties[] = { SCSI_DISK_F_REMOVABLE, false), DEFINE_PROP_BIT("dpofua", SCSIDiskState, features, SCSI_DISK_F_DPOFUA, false), + DEFINE_PROP_HEX64("wwn", SCSIDiskState, wwn, 0), DEFINE_PROP_END_OF_LIST(), };