From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Urwnv-0007H0-Ol for qemu-devel@nongnu.org; Wed, 26 Jun 2013 16:59:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Urwnu-0003U6-Gy for qemu-devel@nongnu.org; Wed, 26 Jun 2013 16:59:03 -0400 Received: from mail-yh0-x235.google.com ([2607:f8b0:4002:c01::235]:38477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Urwnu-0003U0-CN for qemu-devel@nongnu.org; Wed, 26 Jun 2013 16:59:02 -0400 Received: by mail-yh0-f53.google.com with SMTP id a41so6719305yho.40 for ; Wed, 26 Jun 2013 13:59:01 -0700 (PDT) From: Anthony Liguori In-Reply-To: References: Date: Wed, 26 Jun 2013 15:58:59 -0500 Message-ID: <87r4folhbg.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH] xen_disk: support cache backend option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefano Stabellini , xen-devel@lists.xensource.com Cc: Ian Jackson , qemu-devel@nongnu.org, Stefano Stabellini Stefano Stabellini writes: > Support a backend option "cache" that specifies the cache mode that > should be used to open the disk file or device. > > See: http://marc.info/?l=xen-devel&m=137226872905057 > > Signed-off-by: Stefano Stabellini Is the guest setting this or a management tool? I thought we were moving to having the Xen management tools use QMP and the command line instead of putting this stuff in XenStore... Regards, Anthony Liguori > > diff --git a/hw/xen_disk.c b/hw/xen_disk.c > index f484404..092aa6b 100644 > --- a/hw/block/xen_disk.c > +++ b/hw/block/xen_disk.c > @@ -94,6 +94,7 @@ struct XenBlkDev { > char *type; > char *dev; > char *devtype; > + char *cache; > const char *fileproto; > const char *filename; > int ring_ref; > @@ -734,6 +735,12 @@ static int blk_init(struct XenDevice *xendev) > if (blkdev->devtype == NULL) { > blkdev->devtype = xenstore_read_be_str(&blkdev->xendev, "device-type"); > } > + if (blkdev->cache == NULL) { > + blkdev->cache = xenstore_read_be_str(&blkdev->xendev, "cache"); > + } > + if (blkdev->cache == NULL) { > + blkdev->cache = g_strdup("writeback"); > + } > > /* do we have all we need? */ > if (blkdev->params == NULL || > @@ -774,6 +781,8 @@ out_error: > blkdev->dev = NULL; > g_free(blkdev->devtype); > blkdev->devtype = NULL; > + g_free(blkdev->cache); > + blkdev->cache = NULL; > return -1; > } > > @@ -782,8 +791,14 @@ static int blk_connect(struct XenDevice *xendev) > struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); > int pers, index, qflags; > > - /* read-only ? */ > - qflags = BDRV_O_CACHE_WB | BDRV_O_NATIVE_AIO; > + if (!strcmp(blkdev->cache, "none")) { > + qflags = BDRV_O_NATIVE_AIO | BDRV_O_NOCACHE; > + } else if (!strcmp(blkdev->cache, "writethrough")) { > + qflags = 0; > + } else { > + /* default to writeback */ > + qflags = BDRV_O_NATIVE_AIO | BDRV_O_CACHE_WB; > + } > if (strcmp(blkdev->mode, "w") == 0) { > qflags |= BDRV_O_RDWR; > } > @@ -950,6 +965,7 @@ static int blk_free(struct XenDevice *xendev) > g_free(blkdev->type); > g_free(blkdev->dev); > g_free(blkdev->devtype); > + g_free(blkdev->cache); > qemu_bh_delete(blkdev->bh); > return 0; > } From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH] xen_disk: support cache backend option Date: Wed, 26 Jun 2013 15:58:59 -0500 Message-ID: <87r4folhbg.fsf@codemonkey.ws> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org To: Stefano Stabellini , xen-devel@lists.xensource.com Cc: Ian Jackson , qemu-devel@nongnu.org, Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Stefano Stabellini writes: > Support a backend option "cache" that specifies the cache mode that > should be used to open the disk file or device. > > See: http://marc.info/?l=xen-devel&m=137226872905057 > > Signed-off-by: Stefano Stabellini Is the guest setting this or a management tool? I thought we were moving to having the Xen management tools use QMP and the command line instead of putting this stuff in XenStore... Regards, Anthony Liguori > > diff --git a/hw/xen_disk.c b/hw/xen_disk.c > index f484404..092aa6b 100644 > --- a/hw/block/xen_disk.c > +++ b/hw/block/xen_disk.c > @@ -94,6 +94,7 @@ struct XenBlkDev { > char *type; > char *dev; > char *devtype; > + char *cache; > const char *fileproto; > const char *filename; > int ring_ref; > @@ -734,6 +735,12 @@ static int blk_init(struct XenDevice *xendev) > if (blkdev->devtype == NULL) { > blkdev->devtype = xenstore_read_be_str(&blkdev->xendev, "device-type"); > } > + if (blkdev->cache == NULL) { > + blkdev->cache = xenstore_read_be_str(&blkdev->xendev, "cache"); > + } > + if (blkdev->cache == NULL) { > + blkdev->cache = g_strdup("writeback"); > + } > > /* do we have all we need? */ > if (blkdev->params == NULL || > @@ -774,6 +781,8 @@ out_error: > blkdev->dev = NULL; > g_free(blkdev->devtype); > blkdev->devtype = NULL; > + g_free(blkdev->cache); > + blkdev->cache = NULL; > return -1; > } > > @@ -782,8 +791,14 @@ static int blk_connect(struct XenDevice *xendev) > struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); > int pers, index, qflags; > > - /* read-only ? */ > - qflags = BDRV_O_CACHE_WB | BDRV_O_NATIVE_AIO; > + if (!strcmp(blkdev->cache, "none")) { > + qflags = BDRV_O_NATIVE_AIO | BDRV_O_NOCACHE; > + } else if (!strcmp(blkdev->cache, "writethrough")) { > + qflags = 0; > + } else { > + /* default to writeback */ > + qflags = BDRV_O_NATIVE_AIO | BDRV_O_CACHE_WB; > + } > if (strcmp(blkdev->mode, "w") == 0) { > qflags |= BDRV_O_RDWR; > } > @@ -950,6 +965,7 @@ static int blk_free(struct XenDevice *xendev) > g_free(blkdev->type); > g_free(blkdev->dev); > g_free(blkdev->devtype); > + g_free(blkdev->cache); > qemu_bh_delete(blkdev->bh); > return 0; > }