From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 10/46] ide: Adds wwn=hex qdev option
Date: Thu, 5 Apr 2012 17:51:48 +0200 [thread overview]
Message-ID: <1333641144-13612-11-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1333641144-13612-1-git-send-email-kwolf@redhat.com>
From: Floris Bos <bos@je-eigen-domein.nl>
Allow the user to specify a disk's World Wide Name.
Linux guests can address disks by their unique World Wide Name number
(e.g. /dev/disk/by-id/wwn-0x5001517959123522). This patch adds support
for assigning a World Wide Name number to a virtual IDE disk.
Cc: kwolf@redhat.com
Signed-off-by: Floris Bos <dev@noc-ps.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/ide/core.c | 29 +++++++++++++++++++++++------
hw/ide/internal.h | 5 ++++-
hw/ide/qdev.c | 3 ++-
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 5647694..6e25338 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -142,8 +142,12 @@ static void ide_identify(IDEState *s)
put_le16(p + 82, (1 << 14) | (1 << 5) | 1);
/* 13=flush_cache_ext,12=flush_cache,10=lba48 */
put_le16(p + 83, (1 << 14) | (1 << 13) | (1 <<12) | (1 << 10));
- /* 14=set to 1, 1=SMART self test, 0=SMART error logging */
- put_le16(p + 84, (1 << 14) | 0);
+ /* 14=set to 1, 8=has WWN, 1=SMART self test, 0=SMART error logging */
+ if (s->wwn) {
+ put_le16(p + 84, (1 << 14) | (1 << 8) | 0);
+ } else {
+ put_le16(p + 84, (1 << 14) | 0);
+ }
/* 14 = NOP supported, 5=WCACHE enabled, 0=SMART feature set enabled */
if (bdrv_enable_write_cache(s->bs))
put_le16(p + 85, (1 << 14) | (1 << 5) | 1);
@@ -151,8 +155,12 @@ static void ide_identify(IDEState *s)
put_le16(p + 85, (1 << 14) | 1);
/* 13=flush_cache_ext,12=flush_cache,10=lba48 */
put_le16(p + 86, (1 << 13) | (1 <<12) | (1 << 10));
- /* 14=set to 1, 1=smart self test, 0=smart error logging */
- put_le16(p + 87, (1 << 14) | 0);
+ /* 14=set to 1, 8=has WWN, 1=SMART self test, 0=SMART error logging */
+ if (s->wwn) {
+ put_le16(p + 87, (1 << 14) | (1 << 8) | 0);
+ } else {
+ put_le16(p + 87, (1 << 14) | 0);
+ }
put_le16(p + 88, 0x3f | (1 << 13)); /* udma5 set and supported */
put_le16(p + 93, 1 | (1 << 14) | 0x2000);
put_le16(p + 100, s->nb_sectors);
@@ -162,6 +170,13 @@ static void ide_identify(IDEState *s)
if (dev && dev->conf.physical_block_size)
put_le16(p + 106, 0x6000 | get_physical_block_exp(&dev->conf));
+ if (s->wwn) {
+ /* LE 16-bit words 111-108 contain 64-bit World Wide Name */
+ put_le16(p + 108, s->wwn >> 48);
+ put_le16(p + 109, s->wwn >> 32);
+ put_le16(p + 110, s->wwn >> 16);
+ put_le16(p + 111, s->wwn);
+ }
if (dev && dev->conf.discard_granularity) {
put_le16(p + 169, 1); /* TRIM support */
}
@@ -1833,7 +1848,8 @@ static const BlockDevOps ide_cd_block_ops = {
};
int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
- const char *version, const char *serial, const char *model)
+ const char *version, const char *serial, const char *model,
+ uint64_t wwn)
{
int cylinders, heads, secs;
uint64_t nb_sectors;
@@ -1859,6 +1875,7 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
s->heads = heads;
s->sectors = secs;
s->nb_sectors = nb_sectors;
+ s->wwn = wwn;
/* The SMART values should be preserved across power cycles
but they aren't. */
s->smart_enabled = 1;
@@ -1993,7 +2010,7 @@ void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
if (ide_init_drive(&bus->ifs[i], dinfo->bdrv,
dinfo->media_cd ? IDE_CD : IDE_HD, NULL,
*dinfo->serial ? dinfo->serial : NULL,
- NULL) < 0) {
+ NULL, 0) < 0) {
error_report("Can't set up IDE drive %s", dinfo->id);
exit(1);
}
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index b1319dc..100efd3 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -349,6 +349,7 @@ struct IDEState {
int drive_serial;
char drive_serial_str[21];
char drive_model_str[41];
+ uint64_t wwn;
/* ide regs */
uint8_t feature;
uint8_t error;
@@ -470,6 +471,7 @@ struct IDEDevice {
char *version;
char *serial;
char *model;
+ uint64_t wwn;
};
#define BM_STATUS_DMAING 0x01
@@ -536,7 +538,8 @@ 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, BlockDriverState *bs, IDEDriveKind kind,
- const char *version, const char *serial, const char *model);
+ const char *version, const char *serial, const char *model,
+ uint64_t wwn);
void ide_init2(IDEBus *bus, qemu_irq irq);
void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
DriveInfo *hd1, qemu_irq irq);
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 07227c7..a46578d 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -137,7 +137,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
}
if (ide_init_drive(s, dev->conf.bs, kind,
- dev->version, serial, dev->model) < 0) {
+ dev->version, serial, dev->model, dev->wwn) < 0) {
return -1;
}
@@ -174,6 +174,7 @@ static int ide_drive_initfn(IDEDevice *dev)
#define DEFINE_IDE_DEV_PROPERTIES() \
DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf), \
DEFINE_PROP_STRING("ver", IDEDrive, dev.version), \
+ DEFINE_PROP_HEX64("wwn", IDEDrive, dev.wwn, 0), \
DEFINE_PROP_STRING("serial", IDEDrive, dev.serial),\
DEFINE_PROP_STRING("model", IDEDrive, dev.model)
--
1.7.6.5
next prev parent reply other threads:[~2012-04-05 15:49 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-05 15:51 [Qemu-devel] [PULL 00/46] Block patches Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 01/46] trace-events: Rename 'next' argument Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 02/46] tracetool: Forbid argument name 'next' Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 03/46] qcow2: Remove unused parameter in get_cluster_table() Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 04/46] qemu-io: add option to enable tracing Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 05/46] block: push recursive flushing up from drivers Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 07/46] ide: IDENTIFY word 86 bit 14 is reserved Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 08/46] ide: Add "model=s" qdev option Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 09/46] ide: Change serial number strncpy() to pstrcpy() Kevin Wolf
2012-04-05 15:51 ` Kevin Wolf [this message]
2012-04-05 15:51 ` [Qemu-devel] [PATCH 11/46] block/vpc: write checksum back to footer after check Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 12/46] qerror: fix QERR_PROPERTY_VALUE_OUT_OF_RANGE description Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 13/46] qdev: add blocksize property type Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 14/46] block: enforce constraints on block size properties Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 15/46] vdi: basic conversion to coroutines Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 16/46] vdi: move end-of-I/O handling at the end Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 17/46] vdi: merge aio_read_cb and aio_write_cb into callers Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 18/46] vdi: move aiocb fields to locals Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 19/46] vdi: leave bounce buffering to block layer Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 20/46] vdi: do not create useless iovecs Kevin Wolf
2012-04-05 15:51 ` [Qemu-devel] [PATCH 21/46] vdi: change goto to loop Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 22/46] Use DMADirection type for dma_bdrv_io Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 23/46] block: disable I/O throttling on sync api Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 25/46] block: fix streaming/closing race Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 27/46] block: document job API Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 28/46] qemu-img: add image fragmentation statistics Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 29/46] qed: " Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 30/46] qemu-img: add dirty flag status Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 31/46] qed: track " Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 32/46] block: bdrv_append() fixes Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 33/46] sheepdog: implement SD_OP_FLUSH_VDI operation Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 34/46] sheepdog: fix send req helpers Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 36/46] qemu-iotests: Test unknown qcow2 header extensions Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 37/46] qemu-iotests: Fix call syntax for qemu-img Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 38/46] qemu-iotests: Fix call syntax for qemu-io Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 40/46] block: Add new BDRV_O_INCOMING flag to notice incoming live migration Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 42/46] blockdev: open images with BDRV_O_INCOMING on " Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 43/46] qed: add bdrv_invalidate_cache to be called after " Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 44/46] migration: clear BDRV_O_INCOMING flags on end of " Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 45/46] qed: honor BDRV_O_INCOMING for " Kevin Wolf
2012-04-05 15:52 ` [Qemu-devel] [PATCH 46/46] qed: remove incoming live migration blocker Kevin Wolf
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=1333641144-13612-11-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=anthony@codemonkey.ws \
--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).