diff mbox

[v4,4/8] bootindex: delete bootindex when device is removed

Message ID 1406800053-6480-5-git-send-email-arei.gonglei@huawei.com
State New
Headers show

Commit Message

Gonglei (Arei) July 31, 2014, 9:47 a.m. UTC
From: Gonglei <arei.gonglei@huawei.com>

Device should be removed from global boot list when
it is hot-unplugged.

Signed-off-by: Chenliang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/block/virtio-blk.c    | 1 +
 hw/i386/kvm/pci-assign.c | 1 +
 hw/misc/vfio.c           | 1 +
 hw/net/e1000.c           | 1 +
 hw/net/eepro100.c        | 1 +
 hw/net/ne2000.c          | 1 +
 hw/net/rtl8139.c         | 1 +
 hw/net/virtio-net.c      | 1 +
 hw/net/vmxnet3.c         | 1 +
 hw/scsi/scsi-generic.c   | 1 +
 hw/usb/dev-network.c     | 1 +
 hw/usb/host-libusb.c     | 1 +
 hw/usb/redirect.c        | 1 +
 13 files changed, 13 insertions(+)

Comments

Eduardo Habkost Aug. 1, 2014, 2:45 p.m. UTC | #1
On Thu, Jul 31, 2014 at 05:47:29PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> Device should be removed from global boot list when
> it is hot-unplugged.
> 
> Signed-off-by: Chenliang <chenliang88@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  hw/block/virtio-blk.c    | 1 +
>  hw/i386/kvm/pci-assign.c | 1 +
>  hw/misc/vfio.c           | 1 +
>  hw/net/e1000.c           | 1 +
>  hw/net/eepro100.c        | 1 +
>  hw/net/ne2000.c          | 1 +
>  hw/net/rtl8139.c         | 1 +
>  hw/net/virtio-net.c      | 1 +
>  hw/net/vmxnet3.c         | 1 +
>  hw/scsi/scsi-generic.c   | 1 +
>  hw/usb/dev-network.c     | 1 +
>  hw/usb/host-libusb.c     | 1 +
>  hw/usb/redirect.c        | 1 +
>  13 files changed, 13 insertions(+)

Grepping for add_boot_device_path, I don't see corresponding
del_boot_device_path() calls in this patch for the following:

  hw/ide/qdev.c:    add_boot_device_path(dev->conf.bootindex, &dev->qdev,
  hw/block/fdc.c:    add_boot_device_path(isa->bootindexA, dev, "/floppy@0");
  hw/block/fdc.c:    add_boot_device_path(isa->bootindexB, dev, "/floppy@1");
  hw/net/pcnet.c:    add_boot_device_path(s->conf.bootindex, dev, "/ethernet-phy@0");
  hw/net/spapr_llan.c:    add_boot_device_path(dev->nicconf.bootindex, DEVICE(dev), "");
  hw/scsi/scsi-disk.c:    add_boot_device_path(s->qdev.conf.bootindex, &dev->qdev, NULL);

Why we don't need del_boot_device_path() calls for those?

These seem to be OK, and are handled by this patch:

  hw/i386/kvm/pci-assign.c:    add_boot_device_path(dev->bootindex, &pci_dev->qdev, NULL);
  hw/block/virtio-blk.c:    add_boot_device_path(s->conf->bootindex, dev, "/disk@0,0");
  hw/misc/vfio.c:    add_boot_device_path(vdev->bootindex, &pdev->qdev, NULL);
  hw/net/rtl8139.c:    add_boot_device_path(s->conf.bootindex, d, "/ethernet-phy@0");
  hw/net/e1000.c:    add_boot_device_path(d->conf.bootindex, dev, "/ethernet-phy@0");
  hw/net/eepro100.c:    add_boot_device_path(s->conf.bootindex, &pci_dev->qdev, "/ethernet-phy@0");
  hw/net/ne2000.c:    add_boot_device_path(s->c.bootindex, &pci_dev->qdev, "/ethernet-phy@0");
  hw/net/virtio-net.c:    add_boot_device_path(n->nic_conf.bootindex, dev, "/ethernet-phy@0");
  hw/net/vmxnet3.c:    add_boot_device_path(s->conf.bootindex, dev, "/ethernet-phy@0");
  hw/scsi/scsi-generic.c:        add_boot_device_path(s->conf.bootindex, &s->qdev, NULL);
  hw/usb/dev-network.c:    add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet@0");
  hw/usb/host-libusb.c:    add_boot_device_path(s->bootindex, &udev->qdev, NULL);
  hw/usb/redirect.c:    add_boot_device_path(dev->bootindex, &udev->qdev, NULL);

This one has dev==NULL, so it looks OK:

  hw/core/loader.c:    add_boot_device_path(bootindex, NULL, devpath);

This is modify_boot_device_path(), so it's OK:

  vl.c:    add_boot_device_path(bootindex, dev, old_entry->suffix);
Gonglei (Arei) Aug. 4, 2014, 6:33 a.m. UTC | #2
Best regards,
-Gonglei


> -----Original Message-----
> From: Eduardo Habkost [mailto:ehabkost@redhat.com]
> Sent: Friday, August 01, 2014 10:46 PM
> To: Gonglei (Arei)
> Cc: qemu-devel@nongnu.org; chenliang (T); Huangweidong (C);
> mst@redhat.com; aik@ozlabs.ru; hutao@cn.fujitsu.com;
> armbru@redhat.com; kraxel@redhat.com; akong@redhat.com;
> agraf@suse.de; aliguori@amazon.com; gaowanlong@cn.fujitsu.com;
> Luonengjun; Huangpeng (Peter); hani@linux.com; stefanha@redhat.com;
> pbonzini@redhat.com; lcapitulino@redhat.com; kwolf@redhat.com;
> peter.crosthwaite@xilinx.com; imammedo@redhat.com; afaerber@suse.de
> Subject: Re: [Qemu-devel] [PATCH v4 4/8] bootindex: delete bootindex when
> device is removed
> 
> On Thu, Jul 31, 2014 at 05:47:29PM +0800, arei.gonglei@huawei.com wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > Device should be removed from global boot list when
> > it is hot-unplugged.
> >
> > Signed-off-by: Chenliang <chenliang88@huawei.com>
> > Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> > ---
> >  hw/block/virtio-blk.c    | 1 +
> >  hw/i386/kvm/pci-assign.c | 1 +
> >  hw/misc/vfio.c           | 1 +
> >  hw/net/e1000.c           | 1 +
> >  hw/net/eepro100.c        | 1 +
> >  hw/net/ne2000.c          | 1 +
> >  hw/net/rtl8139.c         | 1 +
> >  hw/net/virtio-net.c      | 1 +
> >  hw/net/vmxnet3.c         | 1 +
> >  hw/scsi/scsi-generic.c   | 1 +
> >  hw/usb/dev-network.c     | 1 +
> >  hw/usb/host-libusb.c     | 1 +
> >  hw/usb/redirect.c        | 1 +
> >  13 files changed, 13 insertions(+)
> 
> Grepping for add_boot_device_path, I don't see corresponding
> del_boot_device_path() calls in this patch for the following:
> 
>   hw/ide/qdev.c:    add_boot_device_path(dev->conf.bootindex,
> &dev->qdev,
>   hw/block/fdc.c:    add_boot_device_path(isa->bootindexA, dev,
> "/floppy@0");
>   hw/block/fdc.c:    add_boot_device_path(isa->bootindexB, dev,
> "/floppy@1");
>   hw/net/pcnet.c:    add_boot_device_path(s->conf.bootindex, dev,
> "/ethernet-phy@0");
>   hw/net/spapr_llan.c:    add_boot_device_path(dev->nicconf.bootindex,
> DEVICE(dev), "");
>   hw/scsi/scsi-disk.c:    add_boot_device_path(s->qdev.conf.bootindex,
> &dev->qdev, NULL);
> 
> Why we don't need del_boot_device_path() calls for those?
> 
I think those device don't support hot-plug/hot-unplug. So, needn't call 
del_boot_device_path(). But maybe I make a mistake for pcnet and scsi-disk.

I will adopt Gerd's suggestion in v5: 
call this from device_finalize() instead of placing it into each
individual device.

Thanks.

> These seem to be OK, and are handled by this patch:
> 
>   hw/i386/kvm/pci-assign.c:    add_boot_device_path(dev->bootindex,
> &pci_dev->qdev, NULL);
>   hw/block/virtio-blk.c:    add_boot_device_path(s->conf->bootindex, dev,
> "/disk@0,0");
>   hw/misc/vfio.c:    add_boot_device_path(vdev->bootindex, &pdev->qdev,
> NULL);
>   hw/net/rtl8139.c:    add_boot_device_path(s->conf.bootindex, d,
> "/ethernet-phy@0");
>   hw/net/e1000.c:    add_boot_device_path(d->conf.bootindex, dev,
> "/ethernet-phy@0");
>   hw/net/eepro100.c:    add_boot_device_path(s->conf.bootindex,
> &pci_dev->qdev, "/ethernet-phy@0");
>   hw/net/ne2000.c:    add_boot_device_path(s->c.bootindex,
> &pci_dev->qdev, "/ethernet-phy@0");
>   hw/net/virtio-net.c:    add_boot_device_path(n->nic_conf.bootindex, dev,
> "/ethernet-phy@0");
>   hw/net/vmxnet3.c:    add_boot_device_path(s->conf.bootindex, dev,
> "/ethernet-phy@0");
>   hw/scsi/scsi-generic.c:        add_boot_device_path(s->conf.bootindex,
> &s->qdev, NULL);
>   hw/usb/dev-network.c:    add_boot_device_path(s->conf.bootindex,
> &dev->qdev, "/ethernet@0");
>   hw/usb/host-libusb.c:    add_boot_device_path(s->bootindex,
> &udev->qdev, NULL);
>   hw/usb/redirect.c:    add_boot_device_path(dev->bootindex,
> &udev->qdev, NULL);
> 
> This one has dev==NULL, so it looks OK:
> 
>   hw/core/loader.c:    add_boot_device_path(bootindex, NULL, devpath);
> 
> This is modify_boot_device_path(), so it's OK:
> 
>   vl.c:    add_boot_device_path(bootindex, dev, old_entry->suffix);
> 
> --
> Eduardo
diff mbox

Patch

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index c241c50..49813d5 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -786,6 +786,7 @@  static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIOBlock *s = VIRTIO_BLK(dev);
 
+    del_boot_device_path(dev);
 #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
     remove_migration_state_change_notifier(&s->migration_state_notifier);
     virtio_blk_data_plane_destroy(s->dataplane);
diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index de33657..1322479 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -1853,6 +1853,7 @@  static void assigned_exitfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
 
+    del_boot_device_path(&pci_dev->qdev);
     deassign_device(dev);
     free_assigned_device(dev);
 }
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index 0b9eba0..f891312 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -4304,6 +4304,7 @@  static void vfio_exitfn(PCIDevice *pdev)
     VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
     VFIOGroup *group = vdev->group;
 
+    del_boot_device_path(&pdev->qdev);
     vfio_unregister_err_notifier(vdev);
     pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
     vfio_disable_interrupts(vdev);
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 0fc29a0..fa4e858 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1492,6 +1492,7 @@  pci_e1000_uninit(PCIDevice *dev)
 {
     E1000State *d = E1000(dev);
 
+    del_boot_device_path(DEVICE(dev));
     timer_del(d->autoneg_timer);
     timer_free(d->autoneg_timer);
     timer_del(d->mit_timer);
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index 3263e3f..62951e4 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1843,6 +1843,7 @@  static void pci_nic_uninit(PCIDevice *pci_dev)
 {
     EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
 
+    del_boot_device_path(&pci_dev->qdev);
     memory_region_destroy(&s->mmio_bar);
     memory_region_destroy(&s->io_bar);
     memory_region_destroy(&s->flash_bar);
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index d558b8c..62afa65 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -748,6 +748,7 @@  static void pci_ne2000_exit(PCIDevice *pci_dev)
     PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
     NE2000State *s = &d->ne2000;
 
+    del_boot_device_path(&pci_dev->qdev);
     memory_region_destroy(&s->io);
     qemu_del_nic(s->nic);
     qemu_free_irq(s->irq);
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 90bc5ec..b34c91a 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -3462,6 +3462,7 @@  static void pci_rtl8139_uninit(PCIDevice *dev)
 {
     RTL8139State *s = RTL8139(dev);
 
+    del_boot_device_path(DEVICE(dev));
     memory_region_destroy(&s->bar_io);
     memory_region_destroy(&s->bar_mem);
     if (s->cplus_txbuffer) {
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 268eff9..0419575 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1654,6 +1654,7 @@  static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
     virtio_net_set_status(vdev, 0);
 
     unregister_savevm(dev, "virtio-net", n);
+    del_boot_device_path(dev);
 
     g_free(n->netclient_name);
     n->netclient_name = NULL;
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 77bea6f..c10d84e 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2176,6 +2176,7 @@  static void vmxnet3_pci_uninit(PCIDevice *pci_dev)
     VMW_CBPRN("Starting uninit...");
 
     unregister_savevm(dev, "vmxnet3-msix", s);
+    del_boot_device_path(dev);
 
     vmxnet3_net_uninit(s);
 
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 3733d2c..b270bc7 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -388,6 +388,7 @@  static void scsi_generic_reset(DeviceState *dev)
 
 static void scsi_destroy(SCSIDevice *s)
 {
+    del_boot_device_path(&s->qdev);
     scsi_device_purge_requests(s, SENSE_CODE(NO_SENSE));
     blockdev_mark_auto_del(s->conf.bs);
 }
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 518d536..be39802 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1331,6 +1331,7 @@  static void usb_net_handle_destroy(USBDevice *dev)
     /* TODO: remove the nd_table[] entry */
     rndis_clear_responsequeue(s);
     qemu_del_nic(s->nic);
+    del_boot_device_path(&dev->qdev);
 }
 
 static NetClientInfo net_usbnet_info = {
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index c189147..919a0d2 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -984,6 +984,7 @@  static void usb_host_handle_destroy(USBDevice *udev)
 {
     USBHostDevice *s = USB_HOST_DEVICE(udev);
 
+    del_boot_device_path(&udev->qdev);
     qemu_remove_exit_notifier(&s->exit);
     QTAILQ_REMOVE(&hostdevs, s, next);
     usb_host_close(s);
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 44522d9..33df3af 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1416,6 +1416,7 @@  static void usbredir_handle_destroy(USBDevice *udev)
 {
     USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev);
 
+    del_boot_device_path(&udev->qdev);
     qemu_chr_delete(dev->cs);
     dev->cs = NULL;
     /* Note must be done after qemu_chr_close, as that causes a close event */