Received: from eggs.gnu.org ([2001:4830:134:3::10]:47114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhHJF-0003R0-8R for qemu-devel@nongnu.org; Tue, 06 Sep 2016 10:25:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhHJA-0005j0-3Y for qemu-devel@nongnu.org; Tue, 06 Sep 2016 10:25:08 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35007) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhHJ9-0005ij-Sr for qemu-devel@nongnu.org; Tue, 06 Sep 2016 10:25:04 -0400 Received: by mail-wm0-x243.google.com with SMTP id a6so7592684wmc.2 for ; Tue, 06 Sep 2016 07:25:03 -0700 (PDT) Sender: Paolo Bonzini 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> <20160905201851.68fac3c3@t450s.home> From: Paolo Bonzini Message-ID: <01957bbc-9fdd-a832-173b-ce3bcb21685a@redhat.com> Date: Tue, 6 Sep 2016 16:25:01 +0200 MIME-Version: 1.0 In-Reply-To: <20160905201851.68fac3c3@t450s.home> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit 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: Alex Williamson Cc: Markus Armbruster , Michal Privoznik , libvir-list@redhat.com, qemu-devel On 06/09/2016 04:18, Alex Williamson wrote: > On Mon, 5 Sep 2016 11:36:55 +0200 > Paolo Bonzini wrote: >> 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. You can't do that. Think of it as DEVICE_DELETED being "removal" and instance_finalize being "reference count has gone to 0". You cannot make the reference count go to 0 unless you have disconnected the device from the parent, and the parent is the one that remembers the device id. >> 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? Because VFIO doesn't have a separate backend object. instance_finalize is already where the backends are released. You cannot for example reuse a character device until instance_finalize (no event is generated, but we could certainly add one to qemu-char.c if deemed useful). VFIO_DELETED is just another example of the same thing. It just happens that the host device is not a separate "-object vfio-backend-pci,sysfs=..." but it's embedded in "-device vfio-pci" so the code for the new event must go in hw/vfio rather than a hypothetical backends/vfio. I'm not saying that VFIO should have a separate backend object, that would probably be overengineering. But in some cases you get saner semantics if you think of VFIO as a composition of two things. > B) Without a device id, how are we going to signal an > event? For example by sysfs path or host device path---it makes sense to use properties of the backend since this signals that the backend is now free. Paolo