From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54189 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJSuZ-0000pa-Ib for qemu-devel@nongnu.org; Tue, 01 Jun 2010 10:57:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJSuY-0002SJ-5C for qemu-devel@nongnu.org; Tue, 01 Jun 2010 10:57:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8510) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJSuX-0002S9-SV for qemu-devel@nongnu.org; Tue, 01 Jun 2010 10:57:46 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o51Evii4014928 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 1 Jun 2010 10:57:44 -0400 Message-ID: <4C051FD7.6050606@redhat.com> Date: Tue, 01 Jun 2010 16:57:27 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1275053935-10627-1-git-send-email-armbru@redhat.com> <1275053935-10627-8-git-send-email-armbru@redhat.com> In-Reply-To: <1275053935-10627-8-git-send-email-armbru@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit 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: Markus Armbruster Cc: qemu-devel@nongnu.org, kraxel@redhat.com 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. Kevin