qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 08/17] block: rename buffer_alignment to guest_block_size
Date: Tue, 13 Dec 2011 13:37:11 +0100	[thread overview]
Message-ID: <1323779840-4235-9-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1323779840-4235-1-git-send-email-pbonzini@redhat.com>

The alignment field is now set to the value that is promised by the guest,
rather than required by the host.  The next patches will make QEMU aware
of the host-provided values, so make this clear.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block.c           |   10 +++++-----
 block.h           |    2 +-
 block/raw-posix.c |    2 +-
 block_int.h       |    4 ++--
 hw/ide/core.c     |    2 +-
 hw/scsi-disk.c    |    2 +-
 hw/scsi-generic.c |    2 +-
 hw/virtio-blk.c   |    2 +-
 8 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/block.c b/block.c
index 4cf441b..9e8ffb8 100644
--- a/block.c
+++ b/block.c
@@ -587,7 +587,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename,
     bs->sg = 0;
     bs->open_flags = open_flags;
     bs->growable = 0;
-    bs->buffer_alignment = 512;
+    bs->guest_block_size = 512;
 
     assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
     if ((flags & BDRV_O_RDWR) && (flags & BDRV_O_COPY_ON_READ)) {
@@ -917,7 +917,7 @@ void bdrv_detach_dev(BlockDriverState *bs, void *dev)
     bs->dev = NULL;
     bs->dev_ops = NULL;
     bs->dev_opaque = NULL;
-    bs->buffer_alignment = 512;
+    bs->guest_block_size = 512;
 }
 
 /* TODO change to return DeviceState * when all users are qdevified */
@@ -3557,14 +3557,14 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
     return NULL;
 }
 
-void bdrv_set_buffer_alignment(BlockDriverState *bs, int align)
+void bdrv_set_guest_block_size(BlockDriverState *bs, int align)
 {
-    bs->buffer_alignment = align;
+    bs->guest_block_size = align;
 }
 
 void *qemu_blockalign(BlockDriverState *bs, size_t size)
 {
-    return qemu_memalign((bs && bs->buffer_alignment) ? bs->buffer_alignment : 512, size);
+    return qemu_memalign((bs && bs->guest_block_size) ? bs->guest_block_size : 512, size);
 }
 
 void bdrv_set_dirty_tracking(BlockDriverState *bs, int enable)
diff --git a/block.h b/block.h
index 1790f99..e088146 100644
--- a/block.h
+++ b/block.h
@@ -303,7 +303,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
                     const char *base_filename, const char *base_fmt,
                     char *options, uint64_t img_size, int flags);
 
-void bdrv_set_buffer_alignment(BlockDriverState *bs, int align);
+void bdrv_set_guest_block_size(BlockDriverState *bs, int align);
 void *qemu_blockalign(BlockDriverState *bs, size_t size);
 
 #define BDRV_SECTORS_PER_DIRTY_CHUNK 2048
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 007d1d3..49a8c21 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -287,7 +287,7 @@ static int qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
     int i;
 
     for (i = 0; i < qiov->niov; i++) {
-        if ((uintptr_t) qiov->iov[i].iov_base % bs->buffer_alignment) {
+        if ((uintptr_t) qiov->iov[i].iov_base % bs->guest_block_size) {
             return 0;
         }
     }
diff --git a/block_int.h b/block_int.h
index 9324866..99f29e2 100644
--- a/block_int.h
+++ b/block_int.h
@@ -240,8 +240,8 @@ struct BlockDriverState {
     uint64_t total_time_ns[BDRV_MAX_IOTYPE];
     uint64_t wr_highest_sector;
 
-    /* the memory alignment required for the buffers handled by this driver */
-    int buffer_alignment;
+    /* the memory alignment used by the guest for the buffers handled by this driver */
+    int guest_block_size;
 
     /* NOTE: the following infos are only hints for real hardware
        drivers. They are not used by the block driver */
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 600eb28..3cceaea 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -1852,7 +1852,7 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
     s->smart_selftest_count = 0;
     if (kind == IDE_CD) {
         bdrv_set_dev_ops(bs, &ide_cd_block_ops, s);
-        bdrv_set_buffer_alignment(bs, 2048);
+        bdrv_set_guest_block_size(bs, 2048);
     } else {
         if (!bdrv_is_inserted(s->bs)) {
             error_report("Device needs media, but drive is empty");
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 505accd..f9b11e4 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1544,7 +1544,7 @@ static int scsi_initfn(SCSIDevice *dev)
     if (s->removable) {
         bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_cd_block_ops, s);
     }
-    bdrv_set_buffer_alignment(s->qdev.conf.bs, s->qdev.blocksize);
+    bdrv_set_guest_block_size(s->qdev.conf.bs, s->qdev.blocksize);
 
     bdrv_iostatus_enable(s->qdev.conf.bs);
     add_boot_device_path(s->qdev.conf.bootindex, &dev->qdev, NULL);
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 6f7d3db..b2feb04 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -184,7 +184,7 @@ static void scsi_read_complete(void * opaque, int ret)
             s->blocksize = ldl_be_p(&r->buf[8]);
             s->max_lba = ldq_be_p(&r->buf[0]);
         }
-        bdrv_set_buffer_alignment(s->conf.bs, s->blocksize);
+        bdrv_set_guest_block_size(s->conf.bs, s->blocksize);
 
         scsi_req_data(&r->req, len);
         if (!r->req.io_canceled) {
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index ef27421..d64ec72 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -606,7 +606,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
     register_savevm(dev, "virtio-blk", virtio_blk_id++, 2,
                     virtio_blk_save, virtio_blk_load, s);
     bdrv_set_dev_ops(s->bs, &virtio_block_ops, s);
-    bdrv_set_buffer_alignment(s->bs, conf->logical_block_size);
+    bdrv_set_guest_block_size(s->bs, conf->logical_block_size);
 
     bdrv_iostatus_enable(s->bs);
     add_boot_device_path(conf->bootindex, dev, "/disk@0,0");
-- 
1.7.7.1

  parent reply	other threads:[~2011-12-13 12:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-13 12:37 [Qemu-devel] [PATCH 00/17] Support mismatched host and guest logical block sizes Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 01/17] block: do not rely on open_flags for bdrv_is_snapshot Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 02/17] block: store actual flags in bs->open_flags Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 03/17] block: pass protocol flags up to the format Paolo Bonzini
2011-12-15  4:10   ` Zhi Yong Wu
2011-12-13 12:37 ` [Qemu-devel] [PATCH 04/17] block: non-raw protocols never cache Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 05/17] block: remove enable_write_cache Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 06/17] block: move flag bits together Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 07/17] raw: remove the aligned_buf Paolo Bonzini
2011-12-13 12:37 ` Paolo Bonzini [this message]
2011-12-13 12:37 ` [Qemu-devel] [PATCH 09/17] block: add host_block_size Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 10/17] raw: probe host_block_size Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 11/17] iscsi: save host block size Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 12/17] block: allow waiting only for overlapping writes Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 13/17] block: allow waiting at arbitrary granularity Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 14/17] block: protect against "torn reads" for guest_block_size > host_block_size Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 15/17] block: align and serialize I/O when guest_block_size < host_block_size Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 16/17] block: default physical block size to host block size Paolo Bonzini
2011-12-13 12:37 ` [Qemu-devel] [PATCH 17/17] qemu-io: add blocksize argument to open Paolo Bonzini
2011-12-14 11:13 ` [Qemu-devel] [PATCH 00/17] Support mismatched host and guest logical block sizes Kevin Wolf
2011-12-14 11:47   ` Paolo Bonzini
2011-12-14 12:05     ` Kevin Wolf
2011-12-14 12:40       ` Paolo Bonzini
2011-12-21 16:55         ` Christoph Hellwig
2011-12-21 17:00           ` Paolo Bonzini

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=1323779840-4235-9-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@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).