From patchwork Tue Jun 1 18:32:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 54275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 99196B6F11 for ; Wed, 2 Jun 2010 04:55:13 +1000 (EST) Received: from localhost ([127.0.0.1]:51548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJWcH-0005nR-CZ for incoming@patchwork.ozlabs.org; Tue, 01 Jun 2010 14:55:09 -0400 Received: from [140.186.70.92] (port=50034 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJWVd-0000fQ-Iy for qemu-devel@nongnu.org; Tue, 01 Jun 2010 14:48:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJWGW-0006pi-St for qemu-devel@nongnu.org; Tue, 01 Jun 2010 14:32:44 -0400 Received: from oxygen.pond.sub.org ([213.239.205.148]:44337) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJWGW-0006oJ-Ev for qemu-devel@nongnu.org; Tue, 01 Jun 2010 14:32:40 -0400 Received: from blackfin.pond.sub.org (pD9E39C24.dip.t-dialin.net [217.227.156.36]) by oxygen.pond.sub.org (Postfix) with ESMTPA id D513031287C for ; Tue, 1 Jun 2010 20:32:36 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 11BB5358; Tue, 1 Jun 2010 20:32:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 1 Jun 2010 20:32:28 +0200 Message-Id: <1275417155-28244-8-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1275417155-28244-1-git-send-email-armbru@redhat.com> References: <1275417155-28244-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: kwolf@redhat.com, kraxel@redhat.com Subject: [Qemu-devel] [PATCH 07/14] ide: Change ide_init_drive() to require valid dinfo argument X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org IDEState members drive_serial_str and version are now left empty until an actual drive is connected. Before, they got a default value that was overwritten when a drive got connected. Doesn't matter, because they're used only while a drive is connected. Signed-off-by: Markus Armbruster --- hw/ide/core.c | 47 +++++++++++++++++++++++++---------------------- 1 files changed, 25 insertions(+), 22 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 443ff10..cb7af38 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2601,30 +2601,29 @@ void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version) int cylinders, heads, secs; uint64_t nb_sectors; - if (dinfo && dinfo->bdrv) { - s->bs = dinfo->bdrv; - bdrv_get_geometry(s->bs, &nb_sectors); - bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); - s->cylinders = cylinders; - s->heads = heads; - s->sectors = secs; - s->nb_sectors = nb_sectors; - /* The SMART values should be preserved across power cycles - but they aren't. */ - s->smart_enabled = 1; - s->smart_autosave = 1; - s->smart_errors = 0; - s->smart_selftest_count = 0; - if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) { - s->is_cdrom = 1; - bdrv_set_change_cb(s->bs, cdrom_change_cb, s); - } - strncpy(s->drive_serial_str, drive_get_serial(s->bs), - sizeof(s->drive_serial_str)); + s->bs = dinfo->bdrv; + bdrv_get_geometry(s->bs, &nb_sectors); + bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); + s->cylinders = cylinders; + s->heads = heads; + s->sectors = secs; + s->nb_sectors = nb_sectors; + /* The SMART values should be preserved across power cycles + but they aren't. */ + s->smart_enabled = 1; + s->smart_autosave = 1; + s->smart_errors = 0; + s->smart_selftest_count = 0; + if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) { + s->is_cdrom = 1; + bdrv_set_change_cb(s->bs, cdrom_change_cb, s); } - if (strlen(s->drive_serial_str) == 0) + strncpy(s->drive_serial_str, drive_get_serial(s->bs), + sizeof(s->drive_serial_str)); + if (!*s->drive_serial_str) { snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), "QM%05d", s->drive_serial); + } if (version) { pstrcpy(s->version, sizeof(s->version), version); } else { @@ -2646,7 +2645,11 @@ static void ide_init1(IDEBus *bus, int unit, DriveInfo *dinfo) s->smart_selftest_data = qemu_blockalign(s->bs, 512); s->sector_write_timer = qemu_new_timer(vm_clock, ide_sector_write_timer_cb, s); - ide_init_drive(s, dinfo, NULL); + if (dinfo) { + ide_init_drive(s, dinfo, NULL); + } else { + ide_reset(s); + } } void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,