Received: from [140.186.70.92] (port=37030 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJWDm-000241-2p for qemu-devel@nongnu.org; Tue, 01 Jun 2010 14:29:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJWDl-0006A7-6u for qemu-devel@nongnu.org; Tue, 01 Jun 2010 14:29:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22979) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJWDk-00069z-TU for qemu-devel@nongnu.org; Tue, 01 Jun 2010 14:29:49 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o51ITl82025161 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 1 Jun 2010 14:29:47 -0400 From: Markus Armbruster References: <1275053935-10627-1-git-send-email-armbru@redhat.com> <1275053935-10627-8-git-send-email-armbru@redhat.com> <4C051FD7.6050606@redhat.com> Date: Tue, 01 Jun 2010 20:29:15 +0200 In-Reply-To: <4C051FD7.6050606@redhat.com> (Kevin Wolf's message of "Tue, 01 Jun 2010 16:57:27 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 07/14] ide: Change ide_init_drive() to require valid dinfo argument List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, kraxel@redhat.com Kevin Wolf writes: > Am 28.05.2010 15:38, schrieb Markus Armbruster: >> 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..f72d37f 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) { > > This should be the other way round. It breaks the serial number in both > cases. I have no idea how that could get past my testing. I'll respin. Thanks!