From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bh5yU-0005UA-C0 for qemu-devel@nongnu.org; Mon, 05 Sep 2016 22:18:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bh5yQ-0000sb-4i for qemu-devel@nongnu.org; Mon, 05 Sep 2016 22:18:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bh5yP-0000sW-Sc for qemu-devel@nongnu.org; Mon, 05 Sep 2016 22:18:54 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1DEFC4E4CD for ; Tue, 6 Sep 2016 02:18:52 +0000 (UTC) Date: Mon, 5 Sep 2016 20:18:51 -0600 From: Alex Williamson Message-ID: <20160905201851.68fac3c3@t450s.home> In-Reply-To: <4b642f96-9fd6-844b-8d1f-395ad4b7bf79@redhat.com> References: <20160901171148.697e696b@t450s.home> <5abeb25c-a8a9-9144-cb6f-724647c5f35a@redhat.com> <87d1ki3djk.fsf@dusky.pond.sub.org> <4b642f96-9fd6-844b-8d1f-395ad4b7bf79@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [libvirt] qapi DEVICE_DELETED event issued *before* instance_finalize?! List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Markus Armbruster , Michal Privoznik , libvir-list@redhat.com, qemu-devel On Mon, 5 Sep 2016 11:36:55 +0200 Paolo Bonzini wrote: > On 05/09/2016 11:23, Markus Armbruster wrote: > >> > > >> > On the other hand, it is clearly documented that the DEVICE_DELETED > >> > event is sent as soon as guest acknowledges completion of device > >> > removal. So libvirt's buggy if we'd follow documentation strictly. But > >> > then again, I don't see much information value in "guest has detached > >> > device but qemu hasn't yet" event. Libvirt would ignore such event. > > Unless I'm missing something, libvirt needs an event that signals "Guest > > and QEMU are done with this device". Current DEVICE_DELETED isn't. > > > > Can we imagine a use for current DEVICE_DELETED, i.e. "Guest is done, > > but QEMU isn't"? > > > > Would anything break if we changed semantics of DEVICE_DELETED to what > > libvirt actually needs? > > > > If the answers are "no" and "no", let's do it. > > There is a subtle aspect of this. After the current DEVICE_DELETED, the > device id is not used any more. So technically you could have > > device_add bar,id=foo > device_del foo > > // something in QEMU prevents the device from going away? > // for example there is a storage issue that blocks completion > // of a read(), and bar is a storage device > > device_add bar,id=foo > device_del foo > > // which foo is being deleted? The old one or the new one? > event DEVICE_DELETED > > DEVICE_DELETED does have a meaning: management cannot talk to the device > anymore in QMP once it is raised. It seems like this is just pointing out another flaw in the semantics of DEVICE_DELETED, a device can linger without a device id, so there's no way to reference it via QMP. QEMU can't signal anything more about the device, nor can the VM admin perform any further operations on it. It's like detecting planets around distant stars, libvirt can't actually see the device, it can only monitor the affects the device has on the VM. This is broken and it seems like the fix is to push both the release of the device id and the DEVICE_DELETED notification until after the instance_finalize callback. Doesn't that solve the nuance you've identified here as well? > Technically what libvirt wants to know for VFIO is not whether the > device is gone; it's whether the device's _backend_ (the VFIO file > descriptor) is gone. The device backend could have been a separate QOM > object, but it isn't. > > So perhaps we need a new event that is specific to VFIO? This immediately sounds like the wrong path. A) Why is this vfio specific? B) Without a device id, how are we going to signal an event? It seems that nobody actually cares about this interim event in QEMU and releasing the device id prior to the actual device itself is just as problematic as the premature signal itself. Thanks, Alex