|
|
0a122b |
From 2c5f92a08224373b01d7d46053f46294fa02d00a Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
0a122b |
Date: Tue, 29 Nov 2011 11:35:47 +0100
|
|
|
0a122b |
Subject: [PATCH 09/37] block: rename buffer_alignment to guest_block_size
|
|
|
0a122b |
|
|
|
0a122b |
Message-id: <1392117622-28812-10-git-send-email-kwolf@redhat.com>
|
|
|
0a122b |
Patchwork-id: 57174
|
|
|
0a122b |
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 09/37] block: rename buffer_alignment to guest_block_size
|
|
|
0a122b |
Bugzilla: 748906
|
|
|
0a122b |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
The alignment field is now set to the value that is promised to the
|
|
|
0a122b |
guest, rather than required by the host. The next patches will make
|
|
|
0a122b |
QEMU aware of the host-provided values, so make this clear.
|
|
|
0a122b |
|
|
|
0a122b |
The alignment is also not about memory buffers, but about the sectors on
|
|
|
0a122b |
the disk, change the documentation of the field.
|
|
|
0a122b |
|
|
|
0a122b |
At this point, the field is set by the device emulation, but completely
|
|
|
0a122b |
ignored by the block layer.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
0a122b |
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
|
|
|
0a122b |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
0a122b |
Reviewed-by: Benoit Canet <benoit@irqsave.net>
|
|
|
0a122b |
(cherry picked from commit 1b7fd729559c6d3b273303aa48bc653ceef08747)
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
block.c | 10 +++++-----
|
|
|
0a122b |
hw/block/virtio-blk.c | 2 +-
|
|
|
0a122b |
hw/ide/core.c | 2 +-
|
|
|
0a122b |
hw/scsi/scsi-disk.c | 2 +-
|
|
|
0a122b |
hw/scsi/scsi-generic.c | 2 +-
|
|
|
0a122b |
include/block/block.h | 2 +-
|
|
|
0a122b |
include/block/block_int.h | 4 ++--
|
|
|
0a122b |
7 files changed, 12 insertions(+), 12 deletions(-)
|
|
|
0a122b |
---
|
|
|
0a122b |
block.c | 10 +++++-----
|
|
|
0a122b |
hw/block/virtio-blk.c | 2 +-
|
|
|
0a122b |
hw/ide/core.c | 2 +-
|
|
|
0a122b |
hw/scsi/scsi-disk.c | 2 +-
|
|
|
0a122b |
hw/scsi/scsi-generic.c | 2 +-
|
|
|
0a122b |
include/block/block.h | 2 +-
|
|
|
0a122b |
include/block/block_int.h | 4 ++--
|
|
|
0a122b |
7 files changed, 12 insertions(+), 12 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/block.c b/block.c
|
|
|
0a122b |
index c85f43e..f2102bc 100644
|
|
|
0a122b |
--- a/block.c
|
|
|
0a122b |
+++ b/block.c
|
|
|
0a122b |
@@ -779,7 +779,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
bs->open_flags = flags;
|
|
|
0a122b |
- bs->buffer_alignment = 512;
|
|
|
0a122b |
+ bs->guest_block_size = 512;
|
|
|
0a122b |
bs->zero_beyond_eof = true;
|
|
|
0a122b |
open_flags = bdrv_open_flags(bs, flags);
|
|
|
0a122b |
bs->read_only = !(open_flags & BDRV_O_RDWR);
|
|
|
0a122b |
@@ -1614,7 +1614,7 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest,
|
|
|
0a122b |
bs_dest->dev_ops = bs_src->dev_ops;
|
|
|
0a122b |
bs_dest->dev_opaque = bs_src->dev_opaque;
|
|
|
0a122b |
bs_dest->dev = bs_src->dev;
|
|
|
0a122b |
- bs_dest->buffer_alignment = bs_src->buffer_alignment;
|
|
|
0a122b |
+ bs_dest->guest_block_size = bs_src->guest_block_size;
|
|
|
0a122b |
bs_dest->copy_on_read = bs_src->copy_on_read;
|
|
|
0a122b |
|
|
|
0a122b |
bs_dest->enable_write_cache = bs_src->enable_write_cache;
|
|
|
0a122b |
@@ -1766,7 +1766,7 @@ void bdrv_detach_dev(BlockDriverState *bs, void *dev)
|
|
|
0a122b |
bs->dev = NULL;
|
|
|
0a122b |
bs->dev_ops = NULL;
|
|
|
0a122b |
bs->dev_opaque = NULL;
|
|
|
0a122b |
- bs->buffer_alignment = 512;
|
|
|
0a122b |
+ bs->guest_block_size = 512;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
/* TODO change to return DeviceState * when all users are qdevified */
|
|
|
0a122b |
@@ -4738,9 +4738,9 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
|
|
|
0a122b |
return NULL;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
-void bdrv_set_buffer_alignment(BlockDriverState *bs, int align)
|
|
|
0a122b |
+void bdrv_set_guest_block_size(BlockDriverState *bs, int align)
|
|
|
0a122b |
{
|
|
|
0a122b |
- bs->buffer_alignment = align;
|
|
|
0a122b |
+ bs->guest_block_size = align;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
void *qemu_blockalign(BlockDriverState *bs, size_t size)
|
|
|
0a122b |
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
|
|
|
0a122b |
index aa37cc9..a96207d 100644
|
|
|
0a122b |
--- a/hw/block/virtio-blk.c
|
|
|
0a122b |
+++ b/hw/block/virtio-blk.c
|
|
|
0a122b |
@@ -721,7 +721,7 @@ static int virtio_blk_device_init(VirtIODevice *vdev)
|
|
|
0a122b |
register_savevm(qdev, "virtio-blk", virtio_blk_id++, 2,
|
|
|
0a122b |
virtio_blk_save, virtio_blk_load, s);
|
|
|
0a122b |
bdrv_set_dev_ops(s->bs, &virtio_block_ops, s);
|
|
|
0a122b |
- bdrv_set_buffer_alignment(s->bs, s->conf->logical_block_size);
|
|
|
0a122b |
+ bdrv_set_guest_block_size(s->bs, s->conf->logical_block_size);
|
|
|
0a122b |
|
|
|
0a122b |
bdrv_iostatus_enable(s->bs);
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/hw/ide/core.c b/hw/ide/core.c
|
|
|
0a122b |
index 8b3dde6..c172c71 100644
|
|
|
0a122b |
--- a/hw/ide/core.c
|
|
|
0a122b |
+++ b/hw/ide/core.c
|
|
|
0a122b |
@@ -2007,7 +2007,7 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
|
|
|
0a122b |
s->smart_selftest_count = 0;
|
|
|
0a122b |
if (kind == IDE_CD) {
|
|
|
0a122b |
bdrv_set_dev_ops(bs, &ide_cd_block_ops, s);
|
|
|
0a122b |
- bdrv_set_buffer_alignment(bs, 2048);
|
|
|
0a122b |
+ bdrv_set_guest_block_size(bs, 2048);
|
|
|
0a122b |
} else {
|
|
|
0a122b |
if (!bdrv_is_inserted(s->bs)) {
|
|
|
0a122b |
error_report("Device needs media, but drive is empty");
|
|
|
0a122b |
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
|
|
|
0a122b |
index bce617c..6491091 100644
|
|
|
0a122b |
--- a/hw/scsi/scsi-disk.c
|
|
|
0a122b |
+++ b/hw/scsi/scsi-disk.c
|
|
|
0a122b |
@@ -2254,7 +2254,7 @@ static int scsi_initfn(SCSIDevice *dev)
|
|
|
0a122b |
} else {
|
|
|
0a122b |
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_block_ops, s);
|
|
|
0a122b |
}
|
|
|
0a122b |
- bdrv_set_buffer_alignment(s->qdev.conf.bs, s->qdev.blocksize);
|
|
|
0a122b |
+ bdrv_set_guest_block_size(s->qdev.conf.bs, s->qdev.blocksize);
|
|
|
0a122b |
|
|
|
0a122b |
bdrv_iostatus_enable(s->qdev.conf.bs);
|
|
|
0a122b |
add_boot_device_path(s->qdev.conf.bootindex, &dev->qdev, NULL);
|
|
|
0a122b |
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
|
|
|
0a122b |
index 8f195be..f08b64e 100644
|
|
|
0a122b |
--- a/hw/scsi/scsi-generic.c
|
|
|
0a122b |
+++ b/hw/scsi/scsi-generic.c
|
|
|
0a122b |
@@ -210,7 +210,7 @@ static void scsi_read_complete(void * opaque, int ret)
|
|
|
0a122b |
s->blocksize = ldl_be_p(&r->buf[8]);
|
|
|
0a122b |
s->max_lba = ldq_be_p(&r->buf[0]);
|
|
|
0a122b |
}
|
|
|
0a122b |
- bdrv_set_buffer_alignment(s->conf.bs, s->blocksize);
|
|
|
0a122b |
+ bdrv_set_guest_block_size(s->conf.bs, s->blocksize);
|
|
|
0a122b |
|
|
|
0a122b |
scsi_req_data(&r->req, len);
|
|
|
0a122b |
if (!r->req.io_canceled) {
|
|
|
0a122b |
diff --git a/include/block/block.h b/include/block/block.h
|
|
|
0a122b |
index 9d1ce59..2a9aa5b 100644
|
|
|
0a122b |
--- a/include/block/block.h
|
|
|
0a122b |
+++ b/include/block/block.h
|
|
|
0a122b |
@@ -409,7 +409,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
|
|
0a122b |
/* Returns the alignment in bytes that is required so that no bounce buffer
|
|
|
0a122b |
* is required throughout the stack */
|
|
|
0a122b |
size_t bdrv_opt_mem_align(BlockDriverState *bs);
|
|
|
0a122b |
-void bdrv_set_buffer_alignment(BlockDriverState *bs, int align);
|
|
|
0a122b |
+void bdrv_set_guest_block_size(BlockDriverState *bs, int align);
|
|
|
0a122b |
void *qemu_blockalign(BlockDriverState *bs, size_t size);
|
|
|
0a122b |
bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov);
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
|
0a122b |
index ddbd53d..0445e6b 100644
|
|
|
0a122b |
--- a/include/block/block_int.h
|
|
|
0a122b |
+++ b/include/block/block_int.h
|
|
|
0a122b |
@@ -307,8 +307,8 @@ struct BlockDriverState {
|
|
|
0a122b |
/* Whether produces zeros when read beyond eof */
|
|
|
0a122b |
bool zero_beyond_eof;
|
|
|
0a122b |
|
|
|
0a122b |
- /* the memory alignment required for the buffers handled by this driver */
|
|
|
0a122b |
- int buffer_alignment;
|
|
|
0a122b |
+ /* the block size for which the guest device expects atomicity */
|
|
|
0a122b |
+ int guest_block_size;
|
|
|
0a122b |
|
|
|
0a122b |
/* do we need to tell the quest if we have a volatile write cache? */
|
|
|
0a122b |
int enable_write_cache;
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.1
|
|
|
0a122b |
|