pci hotplug: make pci hotplug return value to caller.
PATCH 1/1 pci hotplug: make pci hotplug return value to caller.
Make pci hotplug callback return value to caller.
There is no reason to discard return value.
--- hw/pci.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
hw/pci.c +7 -4
@@ -1623,8 +1623,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_dev->romfile =qemu_strdup (info->romfile);pci_add_option_rom (pci_dev); -if (qdev->hotplugged) - bus->hotplug (bus->hotplug_qdev, pci_dev,1 ); +if (qdev->hotplugged) { + rc = bus->hotplug (bus->hotplug_qdev, pci_dev,1 ); +if (rc !=0 ) { +return rc; + } + }return 0 ; }
@@ -1632,8 +1636,7 @@ static int pci_unplug_device(DeviceState *qdev) {PCIDevice *dev =DO_UPCAST (PCIDevice, qdev, qdev); - dev->bus->hotplug (dev->bus->hotplug_qdev, dev,0 ); -return 0 ; +return dev->bus->hotplug (dev->bus->hotplug_qdev, dev,0 ); }void pci_qdev_register (PCIDeviceInfo *info)
Signature · 1 line
1.6.6.1
Quoted 2 lines · Isaku Yamahata
Make pci hotplug callback return value to caller.
There is no reason to discard return value.
cheers,
Gerd
Ping.
Michael, is there any issues to address?
Quoted 42 lines · Isaku Yamahata
Make pci hotplug callback return value to caller.
There is no reason to discard return value.Signed-off-by Isaku Yamahata <[email protected]>--- hw/pci.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)hw/pci.c +7
-4@@ -1623,8 +1623,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_dev->romfile =qemu_strdup (info->romfile);pci_add_option_rom (pci_dev); -if (qdev->hotplugged) - bus->hotplug (bus->hotplug_qdev, pci_dev,1 ); +if (qdev->hotplugged) { + rc = bus->hotplug (bus->hotplug_qdev, pci_dev,1 ); +if (rc !=0 ) { +return rc; + } + }return 0 ; }@@ -1632,8 +1636,7 @@ static int pci_unplug_device(DeviceState *qdev) {PCIDevice *dev =DO_UPCAST (PCIDevice, qdev, qdev); - dev->bus->hotplug (dev->bus->hotplug_qdev, dev,0 ); -return 0 ; +return dev->bus->hotplug (dev->bus->hotplug_qdev, dev,0 ); }void pci_qdev_register (PCIDeviceInfo *info)Signature · 1 line
1.6.6.1
Signature · 1 line
yamahata
Quoted 13 lines · Isaku Yamahata
Make pci hotplug callback return value to caller.
There is no reason to discard return value.Signed-off-by Isaku Yamahata <[email protected]>--- hw/pci.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)hw/pci.c +0
-0
hw/pci.c static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) · line 1629
Quoted 9 lines
hw/pci.c +4
-2@@ -1623,8 +1623,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_dev->romfile =qemu_strdup (info->romfile);pci_add_option_rom (pci_dev); -if (qdev->hotplugged) - bus->hotplug (bus->hotplug_qdev, pci_dev,1 ); +if (qdev->hotplugged) { + rc = bus->hotplug (bus->hotplug_qdev, pci_dev,1 ); +if (rc !=0 ) { +return rc;
I think we need to unregister the device (and remove option rom?), otherwise there's a resource leak here.
Can it really fail? If not we can just make it void.
Quoted 18 lines
hw/pci.c +3
-2+ } + }return 0 ; }@@ -1632,8 +1636,7 @@ static int pci_unplug_device(DeviceState *qdev) {PCIDevice *dev =DO_UPCAST (PCIDevice, qdev, qdev); - dev->bus->hotplug (dev->bus->hotplug_qdev, dev,0 ); -return 0 ; +return dev->bus->hotplug (dev->bus->hotplug_qdev, dev,0 ); }void pci_qdev_register (PCIDeviceInfo *info)Signature · 1 line
1.6.6.1
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Isaku Yamahata
Make pci hotplug callback return value to caller.
There is no reason to discard return value.Signed-off-by Isaku Yamahata <[email protected]>--- hw/pci.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)hw/pci.c +0
-0@@ -1623,8 +1623,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) pci_dev->romfile =qemu_strdup (info->romfile);pci_add_option_rom (pci_dev);
Quoted 9 lines
hw/pci.c static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) · line 1629
Quoted 6 lines
hw/pci.c +4
-2-if (qdev->hotplugged) - bus->hotplug (bus->hotplug_qdev, pci_dev,1 ); +if (qdev->hotplugged) { + rc = bus->hotplug (bus->hotplug_qdev, pci_dev,1 ); +if (rc !=0 ) { +return rc;I think we need to unregister the device (and remove option rom?), otherwise there's a resource leak here.
Okay. I'll look into it.
Quoted 1 line
Can it really fail? If not we can just make it void.
The current pci hot plug(acpi_piix4.c) always successes. But in the pcie native hot plug case it can fail because a slot can have a electromechanical lock.
If the slot is locked, a card can't be inserted/removed.
There are also other pci hot plug controllers which have a lock. Hot plug can fail with such a controller.
Quoted 21 lines
Quoted 20 lines
hw/pci.c +3
-2+ } + }return 0 ; }@@ -1632,8 +1636,7 @@ static int pci_unplug_device(DeviceState *qdev) {PCIDevice *dev =DO_UPCAST (PCIDevice, qdev, qdev); - dev->bus->hotplug (dev->bus->hotplug_qdev, dev,0 ); -return 0 ; +return dev->bus->hotplug (dev->bus->hotplug_qdev, dev,0 ); }void pci_qdev_register (PCIDeviceInfo *info)Signature · 1 line
1.6.6.1
Signature · 1 line
yamahata