On Wed, Jul 30, 2014 at 07:29:56AM +0000, Gonglei (Arei) wrote: > Hi, > > > -----Original Message----- > > From: Gerd Hoffmann [mailto:kra...@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