qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot
@ 2020-04-27 18:24 Julia Suvorova
  2020-04-27 18:24 ` [PATCH v2 1/2] " Julia Suvorova
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Julia Suvorova @ 2020-04-27 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: Igor Mammedov, Daniel P. Berrangé, Julia Suvorova,
	Michael S. Tsirkin

Julia Suvorova (2):
  hw/pci/pcie: Forbid hot-plug if it's disabled on the slot
  hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable

 hw/pci/pcie.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

-- 
2.25.3



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot
  2020-04-27 18:24 [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot Julia Suvorova
@ 2020-04-27 18:24 ` Julia Suvorova
  2020-05-03  7:46   ` Marcel Apfelbaum
  2020-04-27 18:24 ` [PATCH v2 2/2] hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable Julia Suvorova
  2020-04-27 20:10 ` [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot no-reply
  2 siblings, 1 reply; 7+ messages in thread
From: Julia Suvorova @ 2020-04-27 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: Igor Mammedov, Daniel P. Berrangé, Julia Suvorova,
	Michael S. Tsirkin

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 <jusual@redhat.com>
---
v2:
    * Change error text [Igor, Michael]
    * Move cleanup to a separate patch [Marcel]

 hw/pci/pcie.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 0eb3a2a5d2..6b48d04d2c 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -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;
     }
 
+    /* Check if hot-plug is disabled on the slot */
+    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
+        error_setg(errp, "Hot-plug failed: unsupported by the port device '%s'",
+                         DEVICE(hotplug_pdev)->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.
@@ -470,6 +478,17 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
     Error *local_err = NULL;
     PCIDevice *pci_dev = PCI_DEVICE(dev);
     PCIBus *bus = pci_get_bus(pci_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);
+
+    /* Check if hot-unplug is disabled on the slot */
+    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
+        error_setg(errp, "Hot-unplug failed: "
+                         "unsupported by the port device '%s'",
+                         DEVICE(hotplug_pdev)->id);
+        return;
+    }
 
     pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, &local_err);
     if (local_err) {
-- 
2.25.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable
  2020-04-27 18:24 [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot Julia Suvorova
  2020-04-27 18:24 ` [PATCH v2 1/2] " Julia Suvorova
@ 2020-04-27 18:24 ` Julia Suvorova
  2020-05-03  7:47   ` Marcel Apfelbaum
  2020-04-27 20:10 ` [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot no-reply
  2 siblings, 1 reply; 7+ messages in thread
From: Julia Suvorova @ 2020-04-27 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: Igor Mammedov, Daniel P. Berrangé, Julia Suvorova,
	Michael S. Tsirkin

A little cleanup is possible because of hotplug_pdev introduction.

Signed-off-by: Julia Suvorova <jusual@redhat.com>
---
 hw/pci/pcie.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 6b48d04d2c..abc99b6eff 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -449,7 +449,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
             pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
                                        PCI_EXP_LNKSTA_DLLLA);
         }
-        pcie_cap_slot_event(PCI_DEVICE(hotplug_dev),
+        pcie_cap_slot_event(hotplug_pdev,
                             PCI_EXP_HP_EV_PDC | PCI_EXP_HP_EV_ABP);
     }
 }
@@ -490,7 +490,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
         return;
     }
 
-    pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, &local_err);
+    pcie_cap_slot_plug_common(hotplug_pdev, dev, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
@@ -509,7 +509,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_pdev);
 }
 
 /* pci express slot for pci express root/downstream port
-- 
2.25.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot
  2020-04-27 18:24 [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot Julia Suvorova
  2020-04-27 18:24 ` [PATCH v2 1/2] " Julia Suvorova
  2020-04-27 18:24 ` [PATCH v2 2/2] hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable Julia Suvorova
@ 2020-04-27 20:10 ` no-reply
  2020-04-28 18:10   ` Julia Suvorova
  2 siblings, 1 reply; 7+ messages in thread
From: no-reply @ 2020-04-27 20:10 UTC (permalink / raw)
  To: jusual; +Cc: imammedo, berrange, qemu-devel, jusual, mst

Patchew URL: https://patchew.org/QEMU/20200427182440.92433-1-jusual@redhat.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

  TEST    check-unit: tests/test-qht
socket_accept failed: Resource temporarily unavailable
**
ERROR:/tmp/qemu-test/src/tests/qtest/libqtest.c:301:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
/tmp/qemu-test/src/tests/qtest/libqtest.c:166: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/qtest/libqtest.c:301:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
make: *** [check-qtest-aarch64] Error 1
make: *** Waiting for unfinished jobs....
  TEST    iotest-qcow2: 022
  TEST    check-unit: tests/test-qht-par
---
  TEST    iotest-qcow2: 039
socket_accept failed: Resource temporarily unavailable
**
ERROR:/tmp/qemu-test/src/tests/qtest/libqtest.c:301:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
/tmp/qemu-test/src/tests/qtest/libqtest.c:166: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/qtest/libqtest.c:301:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
make: *** [check-qtest-x86_64] Error 1
  TEST    iotest-qcow2: 040
  TEST    iotest-qcow2: 041
  TEST    iotest-qcow2: 042
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=c66f60264261441e87b973b137ab56d7', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-ksshgsdx/src/docker-src.2020-04-27-15.54.25.26190:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=c66f60264261441e87b973b137ab56d7
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-ksshgsdx/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    16m11.272s
user    0m9.880s


The full log is available at
http://patchew.org/logs/20200427182440.92433-1-jusual@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot
  2020-04-27 20:10 ` [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot no-reply
@ 2020-04-28 18:10   ` Julia Suvorova
  0 siblings, 0 replies; 7+ messages in thread
From: Julia Suvorova @ 2020-04-28 18:10 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Igor Mammedov, Daniel Berrange, Michael Tsirkin

On Mon, Apr 27, 2020 at 10:11 PM <no-reply@patchew.org> wrote:
>
> Patchew URL: https://patchew.org/QEMU/20200427182440.92433-1-jusual@redhat.com/
>
>
>
> Hi,
>
> This series failed the docker-quick@centos7 build test. Please find the testing commands and
> their output below. If you have Docker installed, you can probably reproduce it
> locally.
>
> === TEST SCRIPT BEGIN ===
> #!/bin/bash
> make docker-image-centos7 V=1 NETWORK=1
> time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
> === TEST SCRIPT END ===
>
>   TEST    check-unit: tests/test-qht
> socket_accept failed: Resource temporarily unavailable
> **
> ERROR:/tmp/qemu-test/src/tests/qtest/libqtest.c:301:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
> /tmp/qemu-test/src/tests/qtest/libqtest.c:166: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)
> ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/qtest/libqtest.c:301:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
> make: *** [check-qtest-aarch64] Error 1
> make: *** Waiting for unfinished jobs....
>   TEST    iotest-qcow2: 022
>   TEST    check-unit: tests/test-qht-par
> ---
>   TEST    iotest-qcow2: 039
> socket_accept failed: Resource temporarily unavailable
> **
> ERROR:/tmp/qemu-test/src/tests/qtest/libqtest.c:301:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
> /tmp/qemu-test/src/tests/qtest/libqtest.c:166: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)
> ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/qtest/libqtest.c:301:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
> make: *** [check-qtest-x86_64] Error 1
>   TEST    iotest-qcow2: 040
>   TEST    iotest-qcow2: 041
>   TEST    iotest-qcow2: 042
> ---
>     raise CalledProcessError(retcode, cmd)
> subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=c66f60264261441e87b973b137ab56d7', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-ksshgsdx/src/docker-src.2020-04-27-15.54.25.26190:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
> filter=--filter=label=com.qemu.instance.uuid=c66f60264261441e87b973b137ab56d7
> make[1]: *** [docker-run] Error 1
> make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-ksshgsdx/src'
> make: *** [docker-run-test-quick@centos7] Error 2
>
> real    16m11.272s
> user    0m9.880s
>
>
> The full log is available at
> http://patchew.org/logs/20200427182440.92433-1-jusual@redhat.com/testing.docker-quick@centos7/?type=message.
> ---
> Email generated automatically by Patchew [https://patchew.org/].
> Please send your feedback to patchew-devel@redhat.com

Looks like false positive.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot
  2020-04-27 18:24 ` [PATCH v2 1/2] " Julia Suvorova
@ 2020-05-03  7:46   ` Marcel Apfelbaum
  0 siblings, 0 replies; 7+ messages in thread
From: Marcel Apfelbaum @ 2020-05-03  7:46 UTC (permalink / raw)
  To: Julia Suvorova, qemu-devel
  Cc: Igor Mammedov, Daniel P. Berrangé, Michael S. Tsirkin



On 4/27/20 9:24 PM, Julia Suvorova 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.
>
> Signed-off-by: Julia Suvorova <jusual@redhat.com>
> ---
> v2:
>      * Change error text [Igor, Michael]
>      * Move cleanup to a separate patch [Marcel]
>
>   hw/pci/pcie.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
>
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 0eb3a2a5d2..6b48d04d2c 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -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;
>       }
>   
> +    /* Check if hot-plug is disabled on the slot */
> +    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
> +        error_setg(errp, "Hot-plug failed: unsupported by the port device '%s'",
> +                         DEVICE(hotplug_pdev)->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.
> @@ -470,6 +478,17 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
>       Error *local_err = NULL;
>       PCIDevice *pci_dev = PCI_DEVICE(dev);
>       PCIBus *bus = pci_get_bus(pci_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);
> +
> +    /* Check if hot-unplug is disabled on the slot */
> +    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
> +        error_setg(errp, "Hot-unplug failed: "
> +                         "unsupported by the port device '%s'",
> +                         DEVICE(hotplug_pdev)->id);
> +        return;
> +    }
>   
>       pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, &local_err);
>       if (local_err) {

Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>

Thanks,
Marcel



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable
  2020-04-27 18:24 ` [PATCH v2 2/2] hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable Julia Suvorova
@ 2020-05-03  7:47   ` Marcel Apfelbaum
  0 siblings, 0 replies; 7+ messages in thread
From: Marcel Apfelbaum @ 2020-05-03  7:47 UTC (permalink / raw)
  To: Julia Suvorova, qemu-devel
  Cc: Igor Mammedov, Daniel P. Berrangé, Michael S. Tsirkin



On 4/27/20 9:24 PM, Julia Suvorova wrote:
> A little cleanup is possible because of hotplug_pdev introduction.
>
> Signed-off-by: Julia Suvorova <jusual@redhat.com>
> ---
>   hw/pci/pcie.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 6b48d04d2c..abc99b6eff 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -449,7 +449,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
>               pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
>                                          PCI_EXP_LNKSTA_DLLLA);
>           }
> -        pcie_cap_slot_event(PCI_DEVICE(hotplug_dev),
> +        pcie_cap_slot_event(hotplug_pdev,
>                               PCI_EXP_HP_EV_PDC | PCI_EXP_HP_EV_ABP);
>       }
>   }
> @@ -490,7 +490,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
>           return;
>       }
>   
> -    pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, &local_err);
> +    pcie_cap_slot_plug_common(hotplug_pdev, dev, &local_err);
>       if (local_err) {
>           error_propagate(errp, local_err);
>           return;
> @@ -509,7 +509,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_pdev);
>   }
>   
>   /* pci express slot for pci express root/downstream port

Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>

Thanks,
Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-03  7:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-27 18:24 [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot Julia Suvorova
2020-04-27 18:24 ` [PATCH v2 1/2] " Julia Suvorova
2020-05-03  7:46   ` Marcel Apfelbaum
2020-04-27 18:24 ` [PATCH v2 2/2] hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable Julia Suvorova
2020-05-03  7:47   ` Marcel Apfelbaum
2020-04-27 20:10 ` [PATCH v2 0/2] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot no-reply
2020-04-28 18:10   ` Julia Suvorova

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).