qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: yc-core@yandex-team.ru, qemu-block@nongnu.org,
	stefanha@redhat.com, Evgeny Yakovlev <wrfsh@yandex-team.ru>,
	qemu-devel@nongnu.org
Subject: Re: [RFC PATCH] virtio-blk: advertise F_WCE (F_FLUSH) if F_CONFIG_WCE is also advertised
Date: Wed, 9 Oct 2019 15:14:38 -0400	[thread overview]
Message-ID: <20191009151337-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20191008132416.GA28104@stefanha-x1.localdomain>

On Tue, Oct 08, 2019 at 02:24:16PM +0100, Stefan Hajnoczi wrote:
> On Fri, Sep 20, 2019 at 02:56:30PM +0300, Evgeny Yakovlev wrote:
> > Virtio spec 1.1 (and earlier), 5.2.5.1 Driver Requirements: Device
> > Initialization:
> > 
> > "Devices SHOULD always offer VIRTIO_BLK_F_FLUSH, and MUST offer it if
> > they offer VIRTIO_BLK_F_CONFIG_WCE.
> > 
> > It looks like currently F_CONFIG_WCE and F_WCE are not connected to each
> > other. qemu will advertise F_CONFIG_WCE if config-wce argument is
> > set for virtio-blk device. While F_WCE is advertised if underlying block
> > backend actually has it's caching enabled.
> > Those two things are not related to each other.
> > 
> > Signed-off-by: Evgeny Yakovlev <wrfsh@yandex-team.ru>
> > ---
> >  hw/block/virtio-blk.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> > index 1885160..b45dc0c 100644
> > --- a/hw/block/virtio-blk.c
> > +++ b/hw/block/virtio-blk.c
> > @@ -990,7 +990,8 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
> >          virtio_add_feature(&features, VIRTIO_BLK_F_SCSI);
> >      }
> >  
> > -    if (blk_enable_write_cache(s->blk)) {
> > +    if (blk_enable_write_cache(s->blk) ||
> > +        virtio_has_feature(features, VIRTIO_BLK_F_CONFIG_WCE)) {
> >          virtio_add_feature(&features, VIRTIO_BLK_F_WCE);
> >      }
> >      if (blk_is_read_only(s->blk)) {
> > -- 
> > 2.7.4
> 
> Sorry for the very late response.  I have been ill and am still
> recovering.
> 
> The motivation for this change looks correct but this patch may cause
> host_features to change across live migration to a newer QEMU version.
> If the guest accesses VIRTIO_PCI_HOST_FEATURES before and after live
> migration it may see different values, which is unexpected.
> 
> The safe way of introducing guest-visible changes like this is to make
> the change conditional on the machine type version so that old guests
> see old behavior and new guests see new behavior.
> 
> Live migration compatibility can be guaranteed by adding a new property
> to virtio_blk_properties[]:
> 
>   DEFINE_PROP_BOOL("enable-wce-if-config-wce", VirtIOBlock,
>                    conf.enable_wce_if_config_wce, true),


is this a useful thing for users to control?
If not we don't need to make this property part of
the stable API - blacklist it by prefixing x- to the name:
x-enable-wce-if-config-wce

> Then tweak the patch:
> 
>   if (blk_enable_write_cache(s->blk) ||
>       (s->conf.enable_wce_if_config_wce &&
>        virtio_has_feature(features, VIRTIO_BLK_F_CONFIG_WCE))) {
> 
> And finally disable enable_wce_if_config_wce for older machine types to
> retain compatibility:
> 
>   GlobalProperty hw_compat_4_2[] = {
>       { "virtio-blk-device", "enable-wce-if-config-wce", "off" },
>   };
> 
> (I have omitted some steps like defining
> VirtIOBlkConf.enable_wce_if_config_wce field and hooking up
> hw_compat_4_2[], but you can figure that out from the existing code.)
> 
> Stefan




  parent reply	other threads:[~2019-10-09 21:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-20 11:56 [RFC PATCH] virtio-blk: advertise F_WCE (F_FLUSH) if F_CONFIG_WCE is also advertised Evgeny Yakovlev
2019-10-08 13:24 ` Stefan Hajnoczi
2019-10-09 12:37   ` Evgeny Yakovlev
2019-10-09 17:20     ` Stefan Hajnoczi
2019-10-09 19:14   ` Michael S. Tsirkin [this message]
2019-10-10 11:52     ` Evgeny Yakovlev

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=20191009151337-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.com \
    --cc=wrfsh@yandex-team.ru \
    --cc=yc-core@yandex-team.ru \
    /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).