From: armbru@redhat.com
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, afaerber@suse.de
Subject: [Qemu-devel] [PATCH v2 8/9] ide: Drop redundant IDEState member model
Date: Wed, 20 Nov 2013 10:55:19 +0100 [thread overview]
Message-ID: <1384941320-30987-9-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1384941320-30987-1-git-send-email-armbru@redhat.com>
From: Markus Armbruster <armbru@redhat.com>
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 <armbru@redhat.com>
---
hw/ide/core.c | 22 +++-------------------
hw/ide/internal.h | 2 --
hw/ide/qdev.c | 16 +++++++++++++++-
3 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 153e7cf..be5be61 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -99,7 +99,7 @@ static void ide_identify(IDEState *s)
put_le16(p + 21, 512); /* cache size in sectors */
put_le16(p + 22, 4); /* ecc bytes */
padstr((char *)(p + 23), s->dev->version, 8); /* firmware version */
- padstr((char *)(p + 27), s->drive_model_str, 40); /* model */
+ padstr((char *)(p + 27), s->dev->model, 40); /* model */
#if MAX_MULT_SECTORS > 1
put_le16(p + 47, 0x8000 | MAX_MULT_SECTORS);
#endif
@@ -203,7 +203,7 @@ static void ide_atapi_identify(IDEState *s)
put_le16(p + 21, 512); /* cache size in sectors */
put_le16(p + 22, 4); /* ecc bytes */
padstr((char *)(p + 23), s->dev->version, 8); /* firmware version */
- padstr((char *)(p + 27), s->drive_model_str, 40); /* model */
+ padstr((char *)(p + 27), s->dev->model, 40); /* model */
put_le16(p + 48, 1); /* dword I/O (XXX: should not be set on CDROM) */
#ifdef USE_DMA_CDROM
put_le16(p + 49, 1 << 9 | 1 << 8); /* DMA and LBA supported */
@@ -260,7 +260,7 @@ static void ide_cfata_identify(IDEState *s)
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 */
+ padstr((char *) (p + 27), s->dev->model, 40); /* Model number */
#if MAX_MULT_SECTORS > 1
put_le16(p + 47, 0x8000 | MAX_MULT_SECTORS);
#else
@@ -2089,7 +2089,6 @@ static const BlockDevOps ide_cd_block_ops = {
};
int ide_init_drive(IDEState *s, IDEDriveKind kind,
- const char *model,
uint64_t wwn)
{
BlockDriverState *bs = s->dev->conf.bs;
@@ -2119,21 +2118,6 @@ int ide_init_drive(IDEState *s, IDEDriveKind kind,
return -1;
}
}
- if (model) {
- pstrcpy(s->drive_model_str, sizeof(s->drive_model_str), model);
- } else {
- switch (kind) {
- case IDE_CD:
- strcpy(s->drive_model_str, "QEMU DVD-ROM");
- break;
- case IDE_CFATA:
- strcpy(s->drive_model_str, "QEMU MICRODRIVE");
- break;
- default:
- strcpy(s->drive_model_str, "QEMU HARDDISK");
- break;
- }
- }
ide_reset(s);
bdrv_iostatus_enable(bs);
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index f6b5b7a..c4a5773 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -350,7 +350,6 @@ struct IDEState {
int identify_set;
uint8_t identify_data[512];
int drive_serial;
- char drive_model_str[41];
uint64_t wwn;
/* ide regs */
uint8_t feature;
@@ -543,7 +542,6 @@ 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 *model,
uint64_t wwn);
void ide_init2(IDEBus *bus, qemu_irq irq);
void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2);
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index c1a4cb6..915bc27 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -168,8 +168,22 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
dev->version = g_strdup(qemu_get_version());
}
+ if (!dev->model) {
+ switch (kind) {
+ case IDE_CD:
+ dev->model = g_strdup("QEMU DVD-ROM");
+ break;
+ case IDE_CFATA:
+ dev->model = g_strdup("QEMU MICRODRIVE");
+ break;
+ default:
+ dev->model = g_strdup("QEMU HARDDISK");
+ break;
+ }
+ }
+
if (ide_init_drive(s, kind,
- dev->model, dev->wwn) < 0) {
+ dev->wwn) < 0) {
return -1;
}
--
1.8.1.4
next prev parent reply other threads:[~2013-11-20 9:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-20 9:55 [Qemu-devel] [PATCH v2 0/9] Clean up IDE after completion of qdevification armbru
2013-11-20 9:55 ` [Qemu-devel] [PATCH v2 1/9] ide: Move IDEDevice pointer from IDEBus to IDEState armbru
2013-11-20 9:55 ` [Qemu-devel] [PATCH v2 2/9] ide: Use IDEState member dev for "device connected" test armbru
2013-11-20 9:55 ` [Qemu-devel] [PATCH v2 3/9] ide: Don't block-align IDEState member smart_selftest_data armbru
2013-11-20 9:55 ` [Qemu-devel] [PATCH v2 4/9] ide: Drop redundant IDEState member bs armbru
2013-11-20 9:55 ` [Qemu-devel] [PATCH v2 5/9] ide: Drop redundant IDEState geometry members armbru
2013-11-20 9:55 ` [Qemu-devel] [PATCH v2 6/9] ide: Drop redundant IDEState member version armbru
2013-11-20 9:55 ` [Qemu-devel] [PATCH v2 7/9] ide: Drop redundant IDEState member drive_serial_str armbru
2013-11-20 9:55 ` armbru [this message]
2013-11-20 9:55 ` [Qemu-devel] [PATCH v2 9/9] ide: Drop redundant IDEState member wwn armbru
2013-12-18 14:54 ` [Qemu-devel] [PATCH v2 0/9] Clean up IDE after completion of qdevification Markus Armbruster
2013-12-18 15:38 ` Andreas Färber
2013-12-18 17:05 ` Markus Armbruster
2013-12-19 9:30 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1384941320-30987-9-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=afaerber@suse.de \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).