From patchwork Mon Dec 17 14:05:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 206875 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 AF7282C0089 for ; Tue, 18 Dec 2012 01:18:26 +1100 (EST) Received: from localhost ([::1]:46184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkbLY-0000MP-Ub for incoming@patchwork.ozlabs.org; Mon, 17 Dec 2012 09:07:08 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkbKg-0006ct-VS for qemu-devel@nongnu.org; Mon, 17 Dec 2012 09:06:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkbKZ-0004L1-RR for qemu-devel@nongnu.org; Mon, 17 Dec 2012 09:06:14 -0500 Received: from oxygen.pond.sub.org ([2a01:4f8:121:10e4::3]:58461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkbKZ-0004KG-HH for qemu-devel@nongnu.org; Mon, 17 Dec 2012 09:06:07 -0500 Received: from blackfin.pond.sub.org (p5B32A939.dip.t-dialin.net [91.50.169.57]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 12859A2468; Mon, 17 Dec 2012 15:06:03 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 92EAE200AD; Mon, 17 Dec 2012 15:06:01 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2012 15:05:58 +0100 Message-Id: <1355753160-17544-9-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1355753160-17544-1-git-send-email-armbru@redhat.com> References: <1355753160-17544-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:4f8:121:10e4::3 Cc: kwolf@redhat.com, qemu-ppc@nongnu.org, agraf@suse.de Subject: [Qemu-devel] [PATCH 08/10] ide: Drop redundant IDEState member drive_serial_str 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 It's a copy of dev->serial. The copy was needed for non-qdevified controllers, which lacked dev. Note that pci_piix3_xen_ide_unplug() did not clear the copy (it only cleared the copy of bs). Begs the question whether stale data could have been used after unplug. As far as I can tell, the copy was used only when the copy of bs was non-null, thus no bug there. Signed-off-by: Markus Armbruster --- hw/ide/core.c | 14 ++++---------- hw/ide/internal.h | 3 +-- hw/ide/qdev.c | 10 +++++----- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 05a2e61..2608f67 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -94,7 +94,7 @@ static void ide_identify(IDEState *s) put_le16(p + 4, 512 * s->dev->conf.secs); /* XXX: retired, remove ? */ put_le16(p + 5, 512); /* XXX: retired, remove ? */ put_le16(p + 6, s->dev->conf.secs); - padstr((char *)(p + 10), s->drive_serial_str, 20); /* serial number */ + padstr((char *)(p + 10), s->dev->serial, 20); /* serial number */ put_le16(p + 20, 3); /* XXX: retired, remove ? */ put_le16(p + 21, 512); /* cache size in sectors */ put_le16(p + 22, 4); /* ecc bytes */ @@ -198,7 +198,7 @@ static void ide_atapi_identify(IDEState *s) p = (uint16_t *)s->io_buffer; /* Removable CDROM, 50us response, 12 byte packets */ put_le16(p + 0, (2 << 14) | (5 << 8) | (1 << 7) | (2 << 5) | (0 << 0)); - padstr((char *)(p + 10), s->drive_serial_str, 20); /* serial number */ + padstr((char *)(p + 10), s->dev->serial, 20); /* serial number */ put_le16(p + 20, 3); /* buffer type */ put_le16(p + 21, 512); /* cache size in sectors */ put_le16(p + 22, 4); /* ecc bytes */ @@ -257,7 +257,7 @@ static void ide_cfata_identify(IDEState *s) put_le16(p + 6, s->dev->conf.secs); /* Default sectors per track */ put_le16(p + 7, s->nb_sectors >> 16); /* Sectors per card */ put_le16(p + 8, s->nb_sectors); /* Sectors per card */ - padstr((char *)(p + 10), s->drive_serial_str, 20); /* serial number */ + padstr((char *)(p + 10), s->dev->serial, 20); /* serial number */ put_le16(p + 22, 0x0004); /* ECC bytes */ padstr((char *) (p + 23), s->dev->version, 8); /* Firmware Revision */ padstr((char *) (p + 27), s->drive_model_str, 40);/* Model number */ @@ -1931,7 +1931,7 @@ static const BlockDevOps ide_cd_block_ops = { }; int ide_init_drive(IDEState *s, IDEDriveKind kind, - const char *serial, const char *model, + const char *model, uint64_t wwn) { BlockDriverState *bs = s->dev->conf.bs; @@ -1961,12 +1961,6 @@ int ide_init_drive(IDEState *s, IDEDriveKind kind, return -1; } } - if (serial) { - pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), serial); - } else { - snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), - "QM%05d", s->drive_serial); - } if (model) { pstrcpy(s->drive_model_str, sizeof(s->drive_model_str), model); } else { diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 544f3b1..28b60aa 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -351,7 +351,6 @@ struct IDEState { int identify_set; uint8_t identify_data[512]; int drive_serial; - char drive_serial_str[21]; char drive_model_str[41]; uint64_t wwn; /* ide regs */ @@ -543,7 +542,7 @@ void ide_data_writel(void *opaque, uint32_t addr, uint32_t val); uint32_t ide_data_readl(void *opaque, uint32_t addr); int ide_init_drive(IDEState *s, IDEDriveKind kind, - const char *serial, const char *model, + const char *model, uint64_t wwn); void ide_init2(IDEBus *bus, qemu_irq irq); void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0, diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 0139cd1..ef7af1f 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -148,19 +148,19 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) return -1; } + if (!dev->serial) { + dev->serial = g_strdup_printf("QM%05d", s->drive_serial); + } + if (!dev->version) { dev->version = g_strdup(qemu_get_version()); } if (ide_init_drive(s, kind, - dev->serial, dev->model, dev->wwn) < 0) { + dev->model, dev->wwn) < 0) { return -1; } - if (!dev->serial) { - dev->serial = g_strdup(s->drive_serial_str); - } - add_boot_device_path(dev->conf.bootindex, &dev->qdev, dev->unit ? "/disk@1" : "/disk@0");