From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wk6o1-0008Pv-7m for qemu-devel@nongnu.org; Tue, 13 May 2014 03:07:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wk6ns-0002AJ-4x for qemu-devel@nongnu.org; Tue, 13 May 2014 03:07:17 -0400 Received: from mail-ee0-x236.google.com ([2a00:1450:4013:c00::236]:43937) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wk6nr-0002AF-Ux for qemu-devel@nongnu.org; Tue, 13 May 2014 03:07:08 -0400 Received: by mail-ee0-f54.google.com with SMTP id b57so48826eek.13 for ; Tue, 13 May 2014 00:07:06 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5371C495.7090809@redhat.com> Date: Tue, 13 May 2014 09:07:01 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1399947893-25843-1-git-send-email-famz@redhat.com> In-Reply-To: <1399947893-25843-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-blk: Allow config-wce in dataplane List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Stefan Hajnoczi Il 13/05/2014 04:24, Fam Zheng ha scritto: > Dataplane now uses block layer. Protect bdrv_set_enable_write_cache with > aio_context_acquire and aio_context_release, so we can enable config-wce > to allow guest to modify the write cache online. > > Signed-off-by: Fam Zheng > > --- > This applies on top of Stefan's "dataplane: use QEMU block layer" > series. > > Signed-off-by: Fam Zheng > --- > hw/block/dataplane/virtio-blk.c | 6 ------ > hw/block/virtio-blk.c | 9 ++++++++- > 2 files changed, 8 insertions(+), 7 deletions(-) > > diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c > index 79fb612..46a6824 100644 > --- a/hw/block/dataplane/virtio-blk.c > +++ b/hw/block/dataplane/virtio-blk.c > @@ -332,12 +332,6 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk, > return; > } > > - if (blk->config_wce) { > - error_setg(errp, "device is incompatible with x-data-plane, " > - "use config-wce=off"); > - return; > - } > - > /* If dataplane is (re-)enabled while the guest is running there could be > * block jobs that can conflict. > */ > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c > index 8a568e5..a031e56 100644 > --- a/hw/block/virtio-blk.c > +++ b/hw/block/virtio-blk.c > @@ -26,6 +26,7 @@ > # include > #endif > #include "hw/virtio/virtio-bus.h" > +#include "block/block_int.h" You shouldn't need to include this header file. Apart from this, the patch looks good. Paolo > > typedef struct VirtIOBlockReq > { > @@ -523,7 +524,10 @@ static void virtio_blk_set_config(VirtIODevice *vdev, const uint8_t *config) > struct virtio_blk_config blkcfg; > > memcpy(&blkcfg, config, sizeof(blkcfg)); > + > + aio_context_acquire(bdrv_get_aio_context(s->bs)); > bdrv_set_enable_write_cache(s->bs, blkcfg.wce != 0); > + aio_context_release(bdrv_get_aio_context(s->bs)); > } > > static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features) > @@ -582,7 +586,10 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) > * s->bs would erroneously be placed in writethrough mode. > */ > if (!(features & (1 << VIRTIO_BLK_F_CONFIG_WCE))) { > - bdrv_set_enable_write_cache(s->bs, !!(features & (1 << VIRTIO_BLK_F_WCE))); > + aio_context_acquire(bdrv_get_aio_context(s->bs)); > + bdrv_set_enable_write_cache(s->bs, > + !!(features & (1 << VIRTIO_BLK_F_WCE))); > + aio_context_release(bdrv_get_aio_context(s->bs)); > } > } > >