From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMiFp-0005JB-RU for qemu-devel@nongnu.org; Thu, 19 Sep 2013 13:43:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMiFg-0007Zx-Nx for qemu-devel@nongnu.org; Thu, 19 Sep 2013 13:43:01 -0400 Message-ID: <523B3798.7040105@redhat.com> Date: Thu, 19 Sep 2013 11:42:48 -0600 From: Eric Blake MIME-Version: 1.0 References: <1379609334-20811-1-git-send-email-pbonzini@redhat.com> <1379609334-20811-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1379609334-20811-3-git-send-email-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QhOR9JfHIMWaeK4DK90oHGau95ihM3dq3" Subject: Re: [Qemu-devel] [PATCH 2/2] virtio-blk: do not relay a previous driver's WCE configuration to the current List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, rusty@au1.ibm.com, qemu-devel@nongnu.org, stefanha@redhat.com, qemu-stable@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QhOR9JfHIMWaeK4DK90oHGau95ihM3dq3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/19/2013 10:48 AM, Paolo Bonzini wrote: > The following sequence happens: > Hence, whenever the guest is reset, the cache mode of the disk should > be reset to whatever was specified in the "-drive" option. With this > change, the Linux virtio-blk driver finds that writeback caching is > enabled, and tells the block layer to send cache flush commands > appropriately. >=20 > Reported-by: Rusty Russell Cc: qemu-stable@nongnu.org > Signed-off-by: Paolo Bonzini > --- > hw/block/virtio-blk.c | 8 ++++++-- > include/hw/virtio/virtio-blk.h | 1 + > 2 files changed, 7 insertions(+), 2 deletions(-) Reviewed-by: Eric Blake > =20 > features =3D vdev->guest_features; > - bdrv_set_enable_write_cache(s->bs, !!(features & (1 << VIRTIO_BLK_= F_WCE))); > + if (!(features & (1 << VIRTIO_BLK_F_CONFIG_WCE))) { > + bdrv_set_enable_write_cache(s->bs, > + !!(features & (1 << VIRTIO_BLK_F_W= CE))); > + } > } > =20 > static void virtio_blk_save(QEMUFile *f, void *opaque) > @@ -674,6 +678,7 @@ static int virtio_blk_device_init(VirtIODevice *vde= v) > } > =20 > blkconf_serial(&blk->conf, &blk->serial); > + s->original_wce =3D bdrv_enable_write_cache(blk->conf.bs); At first, I was worried that this does 'bool =3D int', and whether that was correct in all cases. But looking further, bdrv_enable_write_cache merely returns bs->enable_write_cache (also an int), but that all assignments to bs->enable_write_cache are careful to only assign 0 or 1. A followup patch that changes the types to bool might be in order, but doesn't invalidate this patch. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --QhOR9JfHIMWaeK4DK90oHGau95ihM3dq3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSOzeYAAoJEKeha0olJ0Nq+nIIAI6aSpMaLpue2PSmStDzI3/+ oKlB4hoqVQo+u/a8L+Abg1RTyYVfNuaYNY99Ij+/TlQcXvZmasJWYag0L7U4mTX1 TutWI8cL687nlyCRcKUsPSopt0gbQikSqm76oNUUhBq1RBbhNGjrfZ3wbW3OUFtQ zsP72tiAmLq41T9BvAkpOJahbI1gTGzNdvobQ8APIueukTdZGax588SSkmQ4yW4p z1Gg55U8m1D8HkJ0XNoP5O6ixBY50diDPwl81hpCNm9H1Tez6LwyMuFiNXnEVIga /wg689E49shKC4pcN6Pn31SJc4WhS+h0Fz2fQ4LiDCm8zJ4NEiPdRKqhebChdwY= =apA8 -----END PGP SIGNATURE----- --QhOR9JfHIMWaeK4DK90oHGau95ihM3dq3--