From patchwork Mon Jul 11 13:02:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 964852 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6BD40DN030601 for ; Mon, 11 Jul 2011 13:04:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757156Ab1GKND6 (ORCPT ); Mon, 11 Jul 2011 09:03:58 -0400 Received: from cantor2.suse.de ([195.135.220.15]:36859 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753604Ab1GKND6 (ORCPT ); Mon, 11 Jul 2011 09:03:58 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 3A23D8F71C; Mon, 11 Jul 2011 15:03:57 +0200 (CEST) From: Hannes Reinecke To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Stefan Haynoczi , kvm@vger.kernel.org, Alexander Graf , Hannes Reinecke Subject: [PATCH 4/4] scsi-disk: Mask out serial number EVPD Date: Mon, 11 Jul 2011 15:02:26 +0200 Message-Id: <1310389346-30790-5-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1310389346-30790-4-git-send-email-hare@suse.de> References: <1310389346-30790-1-git-send-email-hare@suse.de> <1310389346-30790-2-git-send-email-hare@suse.de> <1310389346-30790-3-git-send-email-hare@suse.de> <1310389346-30790-4-git-send-email-hare@suse.de> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 11 Jul 2011 13:04:00 +0000 (UTC) If the serial number is not set we should mask it out in the list of supported VPD pages and mark it as not supported. Signed-off-by: Hannes Reinecke Acked-by: Paolo Bonzini --- hw/scsi-disk.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 5804662..05d14ab 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -398,7 +398,8 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) "buffer size %zd\n", req->cmd.xfer); pages = buflen++; outbuf[buflen++] = 0x00; // list of supported pages (this page) - outbuf[buflen++] = 0x80; // unit serial number + if (s->serial) + outbuf[buflen++] = 0x80; // unit serial number outbuf[buflen++] = 0x83; // device identification if (s->drive_kind == SCSI_HD) { outbuf[buflen++] = 0xb0; // block limits @@ -409,8 +410,14 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) } case 0x80: /* Device serial number, optional */ { - int l = strlen(s->serial); + int l; + if (!s->serial) { + DPRINTF("Inquiry (EVPD[Serial number] not supported\n"); + return -1; + } + + l = strlen(s->serial); if (l > req->cmd.xfer) l = req->cmd.xfer; if (l > 20) @@ -1203,7 +1210,9 @@ static int scsi_initfn(SCSIDevice *dev, SCSIDriveKind kind) if (!s->serial) { /* try to fall back to value set with legacy -drive serial=... */ dinfo = drive_get_by_blockdev(s->bs); - s->serial = qemu_strdup(*dinfo->serial ? dinfo->serial : "0"); + if (*dinfo->serial) { + s->serial = qemu_strdup(dinfo->serial); + } } if (!s->version) {