qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, afaerber@suse.de, stefanha@redhat.com, agraf@suse.de
Subject: [Qemu-devel] [PATCH v3 6/9] ide: Drop redundant IDEState member version
Date: Thu, 30 Jan 2014 13:16:35 +0100	[thread overview]
Message-ID: <1391084198-21021-7-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1391084198-21021-1-git-send-email-armbru@redhat.com>

It's a copy of dev->version.  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/atapi.c    |  2 +-
 hw/ide/core.c     | 14 ++++----------
 hw/ide/internal.h |  3 +--
 hw/ide/qdev.c     |  9 +++++----
 4 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 3dc2de0..f20b3a6 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -634,7 +634,7 @@ static void cmd_inquiry(IDEState *s, uint8_t *buf)
     buf[7] = 0; /* reserved */
     padstr8(buf + 8, 8, "QEMU");
     padstr8(buf + 16, 16, "QEMU DVD-ROM");
-    padstr8(buf + 32, 4, s->version);
+    padstr8(buf + 32, 4, s->dev->version);
     ide_atapi_cmd_reply(s, 36, max_len);
 }
 
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 93ccb6e..564ad71 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -98,7 +98,7 @@ static void ide_identify(IDEState *s)
     put_le16(p + 20, 3); /* XXX: retired, remove ? */
     put_le16(p + 21, 512); /* cache size in sectors */
     put_le16(p + 22, 4); /* ecc bytes */
-    padstr((char *)(p + 23), s->version, 8); /* firmware version */
+    padstr((char *)(p + 23), s->dev->version, 8); /* firmware version */
     padstr((char *)(p + 27), s->drive_model_str, 40); /* model */
 #if MAX_MULT_SECTORS > 1
     put_le16(p + 47, 0x8000 | MAX_MULT_SECTORS);
@@ -202,7 +202,7 @@ static void ide_atapi_identify(IDEState *s)
     put_le16(p + 20, 3); /* buffer type */
     put_le16(p + 21, 512); /* cache size in sectors */
     put_le16(p + 22, 4); /* ecc bytes */
-    padstr((char *)(p + 23), s->version, 8); /* firmware version */
+    padstr((char *)(p + 23), s->dev->version, 8); /* firmware version */
     padstr((char *)(p + 27), s->drive_model_str, 40); /* model */
     put_le16(p + 48, 1); /* dword I/O (XXX: should not be set on CDROM) */
 #ifdef USE_DMA_CDROM
@@ -259,7 +259,7 @@ static void ide_cfata_identify(IDEState *s)
     put_le16(p + 8, s->nb_sectors);		/* Sectors per card */
     padstr((char *)(p + 10), s->drive_serial_str, 20); /* serial number */
     put_le16(p + 22, 0x0004);			/* ECC bytes */
-    padstr((char *) (p + 23), s->version, 8);	/* Firmware Revision */
+    padstr((char *) (p + 23), s->dev->version, 8); /* Firmware Revision */
     padstr((char *) (p + 27), s->drive_model_str, 40);/* Model number */
 #if MAX_MULT_SECTORS > 1
     put_le16(p + 47, 0x8000 | MAX_MULT_SECTORS);
@@ -2089,7 +2089,7 @@ static const BlockDevOps ide_cd_block_ops = {
 };
 
 int ide_init_drive(IDEState *s, IDEDriveKind kind,
-                   const char *version, const char *serial, const char *model,
+                   const char *serial, const char *model,
                    uint64_t wwn)
 {
     BlockDriverState *bs = s->dev->conf.bs;
@@ -2141,12 +2141,6 @@ int ide_init_drive(IDEState *s, IDEDriveKind kind,
         }
     }
 
-    if (version) {
-        pstrcpy(s->version, sizeof(s->version), version);
-    } else {
-        pstrcpy(s->version, sizeof(s->version), qemu_get_version());
-    }
-
     ide_reset(s);
     bdrv_iostatus_enable(bs);
     return 0;
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index 7a39d44..4c0fb8e 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -372,7 +372,6 @@ struct IDEState {
 
     /* set for lba48 access */
     uint8_t lba48;
-    char version[9];
     /* ATAPI specific */
     struct unreported_events events;
     uint8_t sense_key;
@@ -545,7 +544,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 *version, const char *serial, const char *model,
+                   const char *serial, 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 c233d66..0326360 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -160,14 +160,15 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
         return -1;
     }
 
+    if (!dev->version) {
+        dev->version = g_strdup(qemu_get_version());
+    }
+
     if (ide_init_drive(s, kind,
-                       dev->version, dev->serial, dev->model, dev->wwn) < 0) {
+                       dev->serial, dev->model, dev->wwn) < 0) {
         return -1;
     }
 
-    if (!dev->version) {
-        dev->version = g_strdup(s->version);
-    }
     if (!dev->serial) {
         dev->serial = g_strdup(s->drive_serial_str);
     }
-- 
1.8.1.4

  parent reply	other threads:[~2014-01-30 12:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-30 12:16 [Qemu-devel] [PATCH v3 0/9] Clean up IDE after completion of qdevification Markus Armbruster
2014-01-30 12:16 ` [Qemu-devel] [PATCH v3 1/9] ide: Move IDEDevice pointer from IDEBus to IDEState Markus Armbruster
2014-01-30 12:16 ` [Qemu-devel] [PATCH v3 2/9] ide: Use IDEState member dev for "device connected" test Markus Armbruster
2014-01-30 12:16 ` [Qemu-devel] [PATCH v3 3/9] ide: Don't block-align IDEState member smart_selftest_data Markus Armbruster
2014-01-30 12:16 ` [Qemu-devel] [PATCH v3 4/9] ide: Drop redundant IDEState member bs Markus Armbruster
2014-02-03 14:54   ` Kevin Wolf
2014-02-05 14:07     ` Markus Armbruster
2014-02-05 17:09       ` Stefano Stabellini
2014-02-06  7:02         ` Markus Armbruster
2014-02-07 12:58           ` Stefano Stabellini
2014-02-11 14:41             ` Markus Armbruster
2014-02-12  9:16               ` Markus Armbruster
2014-02-12 13:48                 ` Stefano Stabellini
2014-01-30 12:16 ` [Qemu-devel] [PATCH v3 5/9] ide: Drop redundant IDEState geometry members Markus Armbruster
2014-01-30 12:16 ` Markus Armbruster [this message]
2014-01-30 12:16 ` [Qemu-devel] [PATCH v3 7/9] ide: Drop redundant IDEState member drive_serial_str Markus Armbruster
2014-01-30 12:16 ` [Qemu-devel] [PATCH v3 8/9] ide: Drop redundant IDEState member model Markus Armbruster
2014-01-30 12:16 ` [Qemu-devel] [PATCH v3 9/9] ide: Drop redundant IDEState member wwn Markus Armbruster

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=1391084198-21021-7-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).