From patchwork Sat Jul 7 05:03:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deep Debroy X-Patchwork-Id: 169557 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 49A7C2C0083 for ; Sat, 7 Jul 2012 15:03:49 +1000 (EST) Received: from localhost ([::1]:37317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnNBL-00067c-0s for incoming@patchwork.ozlabs.org; Sat, 07 Jul 2012 01:03:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnNBD-00067X-UJ for qemu-devel@nongnu.org; Sat, 07 Jul 2012 01:03:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SnNBC-00007p-5A for qemu-devel@nongnu.org; Sat, 07 Jul 2012 01:03:39 -0400 Received: from mail-lb0-f173.google.com ([209.85.217.173]:40571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnNBB-00007X-RQ for qemu-devel@nongnu.org; Sat, 07 Jul 2012 01:03:38 -0400 Received: by lbok6 with SMTP id k6so14264245lbo.4 for ; Fri, 06 Jul 2012 22:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=rYlsDtWs4s6fSdNJjAhNwjZMzuWWSWRzY1JefIXg9VU=; b=xlorgX08gVwHdlLdose/TP7YF4FxN3zHjFSeStw9O54Mde1lyNXgZ51W8UbF6lwqUD eqmDSOcLT/tJCz/vqxD8T3Wf3masXjnHkhPzkr0x972Wh0N6eFu5X0M+eXkVyAiBareC u2UawKDGLNmyI2vWt85mpwKVBnxkn91m4CRGK9+t0SIJZyLz9w3jC0/O52XFVzSLKKwd J4PwucFiuaM7niVSHXj1mi/Wu9IzIb2vjVbgPRsf9zgPHPrmySr1c+qvEFLe+7bWeNxL +f1DhEhveJ48p5BDBI79m48PSJgLHwhNBZfq60wjO/4J7NtUktKmeJBywEe4xiRKGTD1 lDvA== MIME-Version: 1.0 Received: by 10.152.136.18 with SMTP id pw18mr32440418lab.17.1341637415530; Fri, 06 Jul 2012 22:03:35 -0700 (PDT) Received: by 10.114.62.78 with HTTP; Fri, 6 Jul 2012 22:03:35 -0700 (PDT) Date: Fri, 6 Jul 2012 22:03:35 -0700 Message-ID: From: Deep Debroy To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.217.173 Cc: Paolo Bonzini Subject: [Qemu-devel] [PATCH 2/4] Vendor name and product name parameters for SCSI devices 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 Options vendor_name and product_nameadded for SCSI disks. Signed-off-by: Deep Debroy --- hw/scsi-disk.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) /* @@ -1914,10 +1926,13 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag, } #endif -#define DEFINE_SCSI_DISK_PROPERTIES() \ - DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf), \ - DEFINE_PROP_STRING("ver", SCSIDiskState, version), \ - DEFINE_PROP_STRING("serial", SCSIDiskState, serial) +#define DEFINE_SCSI_DISK_PROPERTIES() \ + DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf), \ + DEFINE_PROP_STRING("ver", SCSIDiskState, version), \ + DEFINE_PROP_STRING("serial", SCSIDiskState, serial), \ + DEFINE_PROP_STRING("vendor_name", SCSIDiskState, vname), \ + DEFINE_PROP_STRING("product_name", SCSIDiskState, pname) + static Property scsi_hd_properties[] = { DEFINE_SCSI_DISK_PROPERTIES(), diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index ae25194..a774c3c 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -70,6 +70,8 @@ struct SCSIDiskState QEMUBH *bh; char *version; char *serial; + char *vname; + char *pname; bool tray_open; bool tray_locked; }; @@ -660,12 +662,22 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) outbuf[0] = s->qdev.type & 0x1f; outbuf[1] = (s->features & (1 << SCSI_DISK_F_REMOVABLE)) ? 0x80 : 0; - if (s->qdev.type == TYPE_ROM) { - memcpy(&outbuf[16], "QEMU CD-ROM ", 16); + + if (NULL != s->pname) { + strpadcpy((char *) &outbuf[16], 16, s->pname, ' '); + } else { + if (s->qdev.type == TYPE_ROM) { + memcpy(&outbuf[16], "QEMU CD-ROM ", 16); + } else { + memcpy(&outbuf[16], "QEMU HARDDISK ", 16); + } + } + if (NULL != s->vname) { + strpadcpy((char *) &outbuf[8], 8, s->vname, ' '); } else { - memcpy(&outbuf[16], "QEMU HARDDISK ", 16); + memcpy(&outbuf[8], "QEMU ", 8); } - memcpy(&outbuf[8], "QEMU ", 8); + memset(&outbuf[32], 0, 4); memcpy(&outbuf[32], s->version, MIN(4, strlen(s->version)));