Received: from eggs.gnu.org ([2001:4830:134:3::10]:50091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDDtv-0004eV-GM for qemu-devel@nongnu.org; Fri, 01 Aug 2014 10:33:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XDDtp-0000vC-Av for qemu-devel@nongnu.org; Fri, 01 Aug 2014 10:33:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDDtp-0000uz-2Y for qemu-devel@nongnu.org; Fri, 01 Aug 2014 10:33:37 -0400 Date: Fri, 1 Aug 2014 11:33:11 -0300 From: Eduardo Habkost Message-ID: <20140801143311.GB28519@thinpad.lan.raisama.net> References: <1406271172-1192-1-git-send-email-arei.gonglei@huawei.com> <1406271172-1192-5-git-send-email-arei.gonglei@huawei.com> <1406281909.20767.5.camel@nilsson.home.kraxel.org> <33183CC9F5247A488A2544077AF1902086C1DA82@SZXEMA503-MBS.china.huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <33183CC9F5247A488A2544077AF1902086C1DA82@SZXEMA503-MBS.china.huawei.com> Subject: Re: [Qemu-devel] [PATCH v2 4/7] bootindex: delete bootindex when device is removed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gonglei (Arei)" Cc: "peter.maydell@linaro.org" , "Huangweidong (C)" , "mst@redhat.com" , "aik@ozlabs.ru" , "qemu-devel@nongnu.org" , "agraf@suse.de" , Gerd Hoffmann , "dmitry@daynix.com" , "akong@redhat.com" , "armbru@redhat.com" , "lersek@redhat.com" , "marcel.a@redhat.com" , "somlo@cmu.edu" , Luonengjun , "Huangpeng (Peter)" , "alex.williamson@redhat.com" , "stefanha@redhat.com" , "imammedo@redhat.com" , "lcapitulino@redhat.com" , "rth@twiddle.net" , "kwolf@redhat.com" , "peter.crosthwaite@xilinx.com" , "chenliang (T)" , "pbonzini@redhat.com" , "afaerber@suse.de" On Wed, Jul 30, 2014 at 07:29:56AM +0000, Gonglei (Arei) wrote: > Hi, > > > -----Original Message----- > > From: Gerd Hoffmann [mailto:kraxel@redhat.com] > > Sent: Friday, July 25, 2014 5:52 PM > > > > > + del_boot_device_path(dev); > > > > You can call this from device_finalize() instead of placing it into each > > individual device. > > > Maybe put this call in device_finalize is not a good idea. > I have three reasons: > > 1. the device's some memory have been freed before call device_finalize, > such as device->id. It is too later. I don't think you even need id. See my reply to v4 2/8. But you have a point about being too late: some devices call add_boot_device_path() on realize, so those would need to revert the operation on unrealize; others do it on init, so they need to do it on finalize. On either case, I believe an extra check inside device_finalize() wouldn't hurt, even if it becomes redundant on some devices. > 2. not every kinds of device can configure bootindex property, such as usb > host adapters. It is a waste and useless for those devices. This is the > main reason. I would prefer to waste a few cycles scanning the boot index list every time a device is removed, than risking crashing QEMU in case somebody forget to add a del_boot_device_path() call. > 3. virtio-net device's parent is virtio-pci device, which configured id property, > But the device saved in global fw_boot_order list is virtio-net device have not > id property. If we put call del_boot_device_path(dev) in virtio_net_device_unrealize > we can delete it from fw_boot_order directly. Sorry, I don't understand what you mean here. If virtio-net doesn't have an id property, would the current version of del_boot_device_path() even work? -- Eduardo