[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/13] pci: Improve do_pcie_aer_inject_error()'s error message
From: |
Markus Armbruster |
Subject: |
[PATCH v2 12/13] pci: Improve do_pcie_aer_inject_error()'s error messages |
Date: |
Thu, 1 Dec 2022 13:11:32 +0100 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
hw/pci/pci-hmp-cmds.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/hw/pci/pci-hmp-cmds.c b/hw/pci/pci-hmp-cmds.c
index 2dd65ca6ee..7a3175ab4b 100644
--- a/hw/pci/pci-hmp-cmds.c
+++ b/hw/pci/pci-hmp-cmds.c
@@ -161,6 +161,7 @@ void pcibus_dev_print(Monitor *mon, DeviceState *dev, int
indent)
void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict)
{
+ Error *err = NULL;
const char *id = qdict_get_str(qdict, "id");
const char *error_name;
uint32_t error_status;
@@ -171,24 +172,20 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict
*qdict)
int ret;
ret = pci_qdev_find_device(id, &dev);
- if (ret < 0) {
- monitor_printf(mon,
- "id or pci device path is invalid or device not "
- "found. %s\n", id);
- return;
+ if (ret == -ENODEV) {
+ error_setg(&err, "device '%s' not found", id);
+ goto out;
}
- if (!pci_is_express(dev)) {
- monitor_printf(mon, "the device doesn't support pci express. %s\n",
- id);
- return;
+ if (ret < 0 || !pci_is_express(dev)) {
+ error_setg(&err, "device '%s' is not a PCIe device", id);
+ goto out;
}
error_name = qdict_get_str(qdict, "error_status");
if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) {
if (qemu_strtoui(error_name, NULL, 0, &num) < 0) {
- monitor_printf(mon, "invalid error status value. \"%s\"",
- error_name);
- return;
+ error_setg(&err, "invalid error status value '%s'", error_name);
+ goto out;
}
error_status = num;
correctable = qdict_get_try_bool(qdict, "correctable", false);
@@ -222,12 +219,15 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict
*qdict)
ret = pcie_aer_inject_error(dev, &aer_err);
if (ret < 0) {
- monitor_printf(mon, "failed to inject error: %s\n",
- strerror(-ret));
- return;
+ error_setg_errno(&err, -ret, "failed to inject error");
+ goto out;
}
+
monitor_printf(mon, "OK id: %s root bus: %s, bus: %x devfn: %x.%x\n",
id, pci_root_bus_path(dev), pci_dev_bus_num(dev),
PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
+
+out:
+ hmp_handle_error(mon, err);
}
--
2.37.3
- [PATCH v2 05/13] pci: Build hw/pci/pci-hmp-cmds.c only when CONFIG_PCI, (continued)
- [PATCH v2 05/13] pci: Build hw/pci/pci-hmp-cmds.c only when CONFIG_PCI, Markus Armbruster, 2022/12/01
- [PATCH v2 08/13] pci: Fix silent truncation of pcie_aer_inject_error argument, Markus Armbruster, 2022/12/01
- [PATCH v2 06/13] pci: Deduplicate get_class_desc(), Markus Armbruster, 2022/12/01
- [PATCH v2 10/13] pci: Inline do_pcie_aer_inject_error() into its only caller, Markus Armbruster, 2022/12/01
- [PATCH v2 07/13] pci: Move pcibus_dev_print() to pci-hmp-cmds.c, Markus Armbruster, 2022/12/01
- [PATCH v2 11/13] pci: Rename hmp_pcie_aer_inject_error()'s local variable @err, Markus Armbruster, 2022/12/01
- [PATCH v2 09/13] pci: Move HMP command from hw/pci/pcie_aer.c to pci-hmp-cmds.c, Markus Armbruster, 2022/12/01
- [PATCH v2 13/13] pci: Reject pcie_aer_inject_error -c with symbolic error status, Markus Armbruster, 2022/12/01
- [PATCH v2 03/13] pci: Move HMP commands from monitor/ to new hw/pci/pci-hmp-cmds.c, Markus Armbruster, 2022/12/01
- [PATCH v2 01/13] pci: Clean up a few things checkpatch.pl would flag later on, Markus Armbruster, 2022/12/01
- [PATCH v2 12/13] pci: Improve do_pcie_aer_inject_error()'s error messages,
Markus Armbruster <=