hw/pci/pcie: Forbid hot-plug via QMP if it's disabled on the slot
PATCH 1/1 hw/pci/pcie: Forbid hot-plug via QMP if it's disabled on the slot
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
hw/pci/pcie.c +21 -3
@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation:
@@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id); +return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification.
@@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); } -void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ; + } -pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &local_err); +pcie_cap_slot_plug_common (hotplug_dev, dev, &local_err);if (local_err) {error_propagate (errp, local_err);return ;
@@ -490,7 +508,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,return ; } -pcie_cap_slot_push_attention_button (PCI_DEVICE (hotplug_dev)); +pcie_cap_slot_push_attention_button (hotplug_dev); }/* pci express slot for pci express root/downstream port
Signature · 1 line
2.24.1
Quoted 4 lines · On Tue, 7 Apr 2020 16:50:17 +0200 Julia Suvorova <[email protected]> wrote:
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
it applies to hotplug in general (i.e. not only QMP)
Quoted 19 lines
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +1
-0@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation:
hw/pci/pcie.c void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, · line 437
Quoted 7 lines
hw/pci/pcie.c +4
-0@@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id);
plug and unplug_req are synchronous. so one can skip on "Device '%s'", user will get this error message as response to device_add/del command.
and more exactly it's concrete slot that does not support hotplug, how about "slot doesn't support ..." or just "hotlpug is not supported"
Quoted 42 lines
hw/pci/pcie.c +16
-3+return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); } -void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ; + } -pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &local_err); +pcie_cap_slot_plug_common (hotplug_dev, dev, &local_err);if (local_err) {error_propagate (errp, local_err);return ;@@ -490,7 +508,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,return ; } -pcie_cap_slot_push_attention_button (PCI_DEVICE (hotplug_dev)); +pcie_cap_slot_push_attention_button (hotplug_dev); }/* pci express slot for pci express root/downstream port
Quoted 39 lines · Igor Mammedov
Quoted 4 lines · On Tue, 7 Apr 2020 16:50:17 +0200 Julia Suvorova <[email protected]> wrote:
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
it applies to hotplug in general (i.e. not only QMP)
Quoted 19 lines
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +1
-0@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation: hw/pci/pcie.c void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, · line 437
Quoted 7 lines
hw/pci/pcie.c +4
-0@@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id);plug and
unplug_reqare synchronous. so one can skip on "Device '%s'", user will get this error message as response to device_add/del command.
Quoted 2 lines
and more exactly it's concrete slot that does not support hotplug, how about "slot doesn't support ..." or just "hotlpug is not supported"
Well device name is useful here, while these commands are synchronous others aren't so log parsing might not be synchronous.
I do think we should mention slot since that's the reason hotplug failed:
"Device '%s' hot-plug failed: unsupported by slot"
Quoted 10 lines
Quoted 10 lines
hw/pci/pcie.c +3
-0+return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); }
Quoted 16 lines
Quoted 6 lines
hw/pci/pcie.c +1
-1-void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 489
Quoted 10 lines
hw/pci/pcie.c +9
-0PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ;
Here too let's mention slot since that's the reason hotplug failed:
"Device '%s' hot-unplug failed: unsupported by slot"
?
Quoted 16 lines
Quoted 16 lines
hw/pci/pcie.c +3
-2+ } -pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &local_err); +pcie_cap_slot_plug_common (hotplug_dev, dev, &local_err);if (local_err) {error_propagate (errp, local_err);return ;@@ -490,7 +508,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,return ; } -pcie_cap_slot_push_attention_button (PCI_DEVICE (hotplug_dev)); +pcie_cap_slot_push_attention_button (hotplug_dev); }/* pci express slot for pci express root/downstream port
Quoted 82 lines · Michael S. Tsirkin
Quoted 39 lines · Igor Mammedov
Quoted 4 lines · On Tue, 7 Apr 2020 16:50:17 +0200 Julia Suvorova <[email protected]> wrote:
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
it applies to hotplug in general (i.e. not only QMP)
Quoted 19 lines
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +1
-0@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation: hw/pci/pcie.c void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, · line 437
Quoted 7 lines
hw/pci/pcie.c +4
-0@@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id);plug and
unplug_reqare synchronous. so one can skip on "Device '%s'", user will get this error message as response to device_add/del command.Quoted 2 lines
and more exactly it's concrete slot that does not support hotplug, how about "slot doesn't support ..." or just "hotlpug is not supported"
Well device name is useful here, while these commands are synchronous others aren't so log parsing might not be synchronous.
I do think we should mention slot since that's the reason hotplug failed:
"Device '%s' hot-plug failed: unsupported by slot"Quoted 10 lines
Quoted 10 lines
hw/pci/pcie.c +3
-0+return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); }Quoted 16 lines
Quoted 6 lines
hw/pci/pcie.c +1
-1-void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 489
Quoted 10 lines
hw/pci/pcie.c +9
-0PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ;Here too let's mention slot since that's the reason hotplug failed:
"Device '%s' hot-unplug failed: unsupported by slot"
Quoted 1 line
?
Just to mention, for a user it's disabled on the device, and they don't have to know how it's implemented. This is the reason for the difference between the error text and comments in code.
Best regards, Julia Suvorova.
Quoted 83 lines · Julia Suvorova
Quoted 82 lines · Michael S. Tsirkin
Quoted 39 lines · Igor Mammedov
Quoted 4 lines · On Tue, 7 Apr 2020 16:50:17 +0200 Julia Suvorova <[email protected]> wrote:
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
it applies to hotplug in general (i.e. not only QMP)
Quoted 19 lines
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +1
-0@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation: hw/pci/pcie.c void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, · line 437
Quoted 7 lines
hw/pci/pcie.c +4
-0@@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id);plug and
unplug_reqare synchronous. so one can skip on "Device '%s'", user will get this error message as response to device_add/del command.Quoted 2 lines
and more exactly it's concrete slot that does not support hotplug, how about "slot doesn't support ..." or just "hotlpug is not supported"
Well device name is useful here, while these commands are synchronous others aren't so log parsing might not be synchronous.
I do think we should mention slot since that's the reason hotplug failed:
"Device '%s' hot-plug failed: unsupported by slot"Quoted 10 lines
Quoted 10 lines
hw/pci/pcie.c +3
-0+return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); }Quoted 16 lines
Quoted 6 lines
hw/pci/pcie.c +1
-1-void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 489
Quoted 10 lines
hw/pci/pcie.c +9
-0PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ;Here too let's mention slot since that's the reason hotplug failed:
"Device '%s' hot-unplug failed: unsupported by slot"
Quoted 3 lines
Quoted 1 line
?
Just to mention, for a user it's disabled on the device,
How?
I assumed this is what is used:
commit 530a0963184e57e71a5b538e9161f115df533e96
Author: Julia Suvorova <[email protected]> Date: Wed Feb 26 18:46:07 2020 +0100
pcie_root_port: Add hotplug disabling option
Make hot-plug/hot-unplug on PCIe Root Ports optional to allow libvirt manage it and restrict unplug for the whole machine. This is going to prevent user-initiated unplug in guests (Windows mostly). Hotplug is enabled by default.
Usage:
-device pcie-root-port,hotplug=off,...
so it looks like user has to disable it on the slot.
Quoted 5 lines
and they
don't have to know how it's implemented. This is the reason for the difference between the error text and comments in code.Best regards, Julia Suvorova.
Quoted 106 lines · Michael S. Tsirkin
Quoted 83 lines · Julia Suvorova
Quoted 82 lines · Michael S. Tsirkin
Quoted 39 lines · Igor Mammedov
Quoted 4 lines · On Tue, 7 Apr 2020 16:50:17 +0200 Julia Suvorova <[email protected]> wrote:
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
it applies to hotplug in general (i.e. not only QMP)
Quoted 19 lines
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +1
-0@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation: hw/pci/pcie.c void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, · line 437
Quoted 7 lines
hw/pci/pcie.c +4
-0@@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id);plug and
unplug_reqare synchronous. so one can skip on "Device '%s'", user will get this error message as response to device_add/del command.Quoted 2 lines
and more exactly it's concrete slot that does not support hotplug, how about "slot doesn't support ..." or just "hotlpug is not supported"
Well device name is useful here, while these commands are synchronous others aren't so log parsing might not be synchronous.
I do think we should mention slot since that's the reason hotplug failed:
"Device '%s' hot-plug failed: unsupported by slot"Quoted 10 lines
Quoted 10 lines
hw/pci/pcie.c +3
-0+return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); }Quoted 16 lines
Quoted 6 lines
hw/pci/pcie.c +1
-1-void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 489
Quoted 10 lines
hw/pci/pcie.c +9
-0PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ;Here too let's mention slot since that's the reason hotplug failed:
"Device '%s' hot-unplug failed: unsupported by slot"Quoted 3 lines
Quoted 1 line
?
Just to mention, for a user it's disabled on the device,
How?
I assumed this is what is used:commit
530a0963184e57e71a5b538e9161f115df533e96Author: Julia Suvorova <[email protected]> Date: Wed Feb 26 18:46:07 2020 +0100
pcie_root_port: Add hotplug disabling optionMake hot-plug/hot-unplug on PCIe Root Ports optional to allow libvirt manage it and restrict unplug for the whole machine. This is going to prevent user-initiated unplug in guests (Windows mostly). Hotplug is enabled by default.
Usage:
-device pcie-root-port,hotplug=off,...
Quoted 1 line
so it looks like user has to disable it on the slot.
By device I mean root port, and it's shown in the error message. If you think it's not correct, I'll change it.
Quoted 107 lines · Julia Suvorova
Quoted 106 lines · Michael S. Tsirkin
Quoted 83 lines · Julia Suvorova
Quoted 82 lines · Michael S. Tsirkin
Quoted 39 lines · Igor Mammedov
Quoted 4 lines · On Tue, 7 Apr 2020 16:50:17 +0200 Julia Suvorova <[email protected]> wrote:
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
it applies to hotplug in general (i.e. not only QMP)
Quoted 19 lines
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +1
-0@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation: hw/pci/pcie.c void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, · line 437
Quoted 7 lines
hw/pci/pcie.c +4
-0@@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id);plug and
unplug_reqare synchronous. so one can skip on "Device '%s'", user will get this error message as response to device_add/del command.Quoted 2 lines
and more exactly it's concrete slot that does not support hotplug, how about "slot doesn't support ..." or just "hotlpug is not supported"
Well device name is useful here, while these commands are synchronous others aren't so log parsing might not be synchronous.
I do think we should mention slot since that's the reason hotplug failed:
"Device '%s' hot-plug failed: unsupported by slot"Quoted 10 lines
Quoted 10 lines
hw/pci/pcie.c +3
-0+return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); }Quoted 16 lines
Quoted 6 lines
hw/pci/pcie.c +1
-1-void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 489
Quoted 10 lines
hw/pci/pcie.c +9
-0PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ;Here too let's mention slot since that's the reason hotplug failed:
"Device '%s' hot-unplug failed: unsupported by slot"Quoted 3 lines
Quoted 1 line
?
Just to mention, for a user it's disabled on the device,
How?
I assumed this is what is used:commit
530a0963184e57e71a5b538e9161f115df533e96Author: Julia Suvorova <[email protected]> Date: Wed Feb 26 18:46:07 2020 +0100
pcie_root_port: Add hotplug disabling optionMake hot-plug/hot-unplug on PCIe Root Ports optional to allow libvirt manage it and restrict unplug for the whole machine. This is going to prevent user-initiated unplug in guests (Windows mostly). Hotplug is enabled by default.
Usage:
-device pcie-root-port,hotplug=off,...
Quoted 4 lines
Quoted 1 line
so it looks like user has to disable it on the slot.
By device I mean root port, and it's shown in the error message. If you think it's not correct, I'll change it.
Oh I see. It might be confusing for user: I add device A and get a report "Device B does not support hot-plug". How about:
"Hot-plug failed: unsupported by port device %s"?
Signature · 1 line
MST
Quoted 111 lines · Michael S. Tsirkin
Quoted 109 lines · Julia Suvorova
Quoted 107 lines · Michael S. Tsirkin
Quoted 83 lines · Julia Suvorova
Quoted 82 lines · Michael S. Tsirkin
Quoted 39 lines · Igor Mammedov
Quoted 4 lines · On Tue, 7 Apr 2020 16:50:17 +0200 Julia Suvorova <[email protected]> wrote:
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
it applies to hotplug in general (i.e. not only QMP)
Quoted 19 lines
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +1
-0@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation: hw/pci/pcie.c void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, · line 437
Quoted 7 lines
hw/pci/pcie.c +4
-0@@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id);plug and
unplug_reqare synchronous. so one can skip on "Device '%s'", user will get this error message as response to device_add/del command.Quoted 2 lines
and more exactly it's concrete slot that does not support hotplug, how about "slot doesn't support ..." or just "hotlpug is not supported"
Well device name is useful here, while these commands are synchronous others aren't so log parsing might not be synchronous.
I do think we should mention slot since that's the reason hotplug failed:
"Device '%s' hot-plug failed: unsupported by slot"Quoted 10 lines
Quoted 10 lines
hw/pci/pcie.c +3
-0+return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); }Quoted 16 lines
Quoted 6 lines
hw/pci/pcie.c +1
-1-void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 489
Quoted 10 lines
hw/pci/pcie.c +9
-0PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ;Here too let's mention slot since that's the reason hotplug failed:
"Device '%s' hot-unplug failed: unsupported by slot"Quoted 3 lines
Quoted 1 line
?
Just to mention, for a user it's disabled on the device,
How?
I assumed this is what is used:commit
530a0963184e57e71a5b538e9161f115df533e96Author: Julia Suvorova <[email protected]> Date: Wed Feb 26 18:46:07 2020 +0100
pcie_root_port: Add hotplug disabling optionMake hot-plug/hot-unplug on PCIe Root Ports optional to allow libvirt manage it and restrict unplug for the whole machine. This is going to prevent user-initiated unplug in guests (Windows mostly). Hotplug is enabled by default.
Usage:
-device pcie-root-port,hotplug=off,...so it looks like user has to disable it on the slot.
Quoted 7 lines
Quoted 2 lines
By device I mean root port, and it's shown in the error message. If you think it's not correct, I'll change it.
Oh I see. It might be confusing for user: I add device A and get a report "Device B does not support hot-plug". How about:
"Hot-plug failed: unsupported by port device %s"?
Looks good.
Best regards, Julia Suvorova.
Hi Julia,
Quoted 47 lines · Julia Suvorova
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +9
-1@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation: @@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id); +return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); } -void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev);
hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 490
Quoted 10 lines
hw/pci/pcie.c +10
-0+PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ; + }
Since this chunk appears twice I would consider refactoring it into
a helper function. (I see the error message is different, but I suppose it can be tweaked)
hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 492
Quoted 3 lines
hw/pci/pcie.c +1
-1-pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &local_err); +pcie_cap_slot_plug_common (hotplug_dev, dev, &local_err);
It doesn't seems related to this patch.
hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 511
Quoted 9 lines
hw/pci/pcie.c +1
-1if (local_err) {error_propagate (errp, local_err);return ;@@ -490,7 +508,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,return ; } -pcie_cap_slot_push_attention_button (PCI_DEVICE (hotplug_dev)); +pcie_cap_slot_push_attention_button (hotplug_dev);
Same here, maybe you can split it in 2 patches.
Thanks,
Marcel
Quoted 3 lines
hw/pci/pcie.c +0
-0}/* pci express slot for pci express root/downstream port
Quoted 57 lines · Marcel Apfelbaum
Hi Julia,
Quoted 53 lines · Julia Suvorova
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +15
-1@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation: @@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id); +return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); } -void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) {
Quoted 8 lines
hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 490
Quoted 4 lines
hw/pci/pcie.c +4
-0+error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ; + }Since this chunk appears twice I would consider refactoring it into a helper function. (I see the error message is different, but I suppose it can be tweaked)
Okay.
Quoted 13 lines
hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 492
Quoted 3 lines
hw/pci/pcie.c +1
-1-pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &local_err); +pcie_cap_slot_plug_common (hotplug_dev, dev, &local_err);It doesn't seems related to this patch.
Quoted 7 lines
hw/pci/pcie.c +0
-0if (local_err) {error_propagate (errp, local_err);return ;@@ -490,7 +508,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,return ; }
Quoted 4 lines
hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 511
Quoted 2 lines
hw/pci/pcie.c +1
-1-pcie_cap_slot_push_attention_button (PCI_DEVICE (hotplug_dev)); +pcie_cap_slot_push_attention_button (hotplug_dev);Same here, maybe you can split it in 2 patches.
Yes, but it doesn't make sense by itself. Just cleaning necessary with a new variable introduced.
Best regards, Julia Suvorova.
Quoted 57 lines · Marcel Apfelbaum
Hi Julia,
Quoted 53 lines · Julia Suvorova
Raise an error when trying to hot-plug/unplug a device through QMP to a device with disabled hot-plug capability. This makes the device behaviour more consistent and provides an explanation of the failure in the case of asynchronous unplug.
Signed-off-by Julia Suvorova <[email protected]>--- hw/pci/pcie.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)hw/pci/pcie.c +15
-1@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev);uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP );PCIDevice *pci_dev =PCI_DEVICE (dev);/* Don't send event when device is enabled during qemu machine creation: @@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,return ; } +/* Hot-plug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) { +error_setg (errp,"Device '%s' does not support hot-plug" , +DEVICE (hotplug_dev)->id); +return ; + } +/* To enable multifunction hot-plug, we just ensure the function * 0 added last. When function 0 is added, we set the sltsta and * inform OS via event notification. @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); } -void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_handler,DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); +PCIDevice *hotplug_dev =PCI_DEVICE (hotplug_handler); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint32_t sltcap =pci_get_word (exp_cap +PCI_EXP_SLTCAP ); + +/* Hot-unplug is disabled on the slot */ +if ((sltcap &PCI_EXP_SLTCAP_HPC ) ==0 ) {
Quoted 8 lines
hw/pci/pcie.c static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) · line 490
Quoted 4 lines
hw/pci/pcie.c +4
-0+error_setg (errp,"Device '%s' does not support hot-unplug" , +DEVICE (hotplug_dev)->id); +return ; + }Since this chunk appears twice I would consider refactoring it into a helper function. (I see the error message is different, but I suppose it can be tweaked)
This only increases the amount of code, since you need to do error_propagate() after the function call.