Received: from eggs.gnu.org ([2001:4830:134:3::10]:55291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xr4Nw-00086U-Gb for qemu-devel@nongnu.org; Wed, 19 Nov 2014 07:29:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xr4Nr-00076r-CX for qemu-devel@nongnu.org; Wed, 19 Nov 2014 07:29:24 -0500 From: Markus Armbruster References: <1416259239-13281-1-git-send-email-dslutz@verizon.com> Date: Wed, 19 Nov 2014 13:29:11 +0100 In-Reply-To: <1416259239-13281-1-git-send-email-dslutz@verizon.com> (Don Slutz's message of "Mon, 17 Nov 2014 16:20:39 -0500") Message-ID: <87k32r8jc8.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [BUGFIX][PATCH for 2.2 1/1] hw/ide/core.c: Prevent SIGSEGV during migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Don Slutz Cc: Kevin Wolf , Stefano Stabellini , qemu-devel@nongnu.org, Stefan Hajnoczi , qemu-stable@nongnu.org Don Slutz writes: > The other callers to blk_set_enable_write_cache() in this file > already check for s->blk == NULL. > > Signed-off-by: Don Slutz > --- > > I think this is a bugfix that should be back ported to stable > releases. > > I also think this should be done in xen's copy of QEMU for 4.5 with > back port(s) to active stable releases. > > Note: In 2.1 and earlier the routine is > bdrv_set_enable_write_cache(); variable is s->bs. Got a reproducer? I'm asking because I believe s->identify_set implies s->blk. s->identify_set is initialized to zero, and gets set to non-zero exactly on the first successful IDENTIFY DEVICE or IDENTIFY PACKET DEVICE, in ide_identify(), ide_atapi_identify() or ide_cfata_identify(), respectively. Only called via cmd_identify() / cmd_identify_packet() via ide_exec_cmd(). The latter immediately fails when !s->blk: s = idebus_active_if(bus); /* ignore commands to non existent slave */ if (s != bus->ifs && !s->blk) { return; } Even if I'm right, your patch is fine, because it makes this spot more obviously correct, and consistent with the other uses of blk_set_enable_write_cache(). The case for stable is weak, though. > > hw/ide/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/ide/core.c b/hw/ide/core.c > index 00e21cf..d4af5e2 100644 > --- a/hw/ide/core.c > +++ b/hw/ide/core.c > @@ -2401,7 +2401,7 @@ static int ide_drive_post_load(void *opaque, int version_id) > { > IDEState *s = opaque; > > - if (s->identify_set) { > + if (s->blk && s->identify_set) { > blk_set_enable_write_cache(s->blk, !!(s->identify_data[85] & (1 << 5))); > } > return 0;