[PATCH v2 1/3] src: Don't use virReportSystemError() on virProcessGetStatInfo() failure

Martin Kletzander mkletzan at redhat.com
Mon Jan 23 15:12:37 UTC 2023


On Wed, Jan 18, 2023 at 10:58:17AM +0100, Michal Privoznik wrote:
>Firstly, the virProcessGetStatInfo() does not fail really. But
>even if it did, it sets correct errno only sometimes (and even
>that is done in a helper it's calling - virProcessGetStat() and
>even there it's the case only in very few error paths).
>
>Therefore, using virReportSystemError() to report errors is very
>misleading. Use plain virReportError() instead. Luckily, there
>are only two places where the former was used:
>chDomainHelperGetVcpus() and qemuDomainHelperGetVcpus() (not a
>big surprise since CH driver is heavily inspired by QEMU driver).
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>

Reviewed-by: Martin Kletzander <mkletzan at redhat.com>

>---
> src/ch/ch_driver.c     | 4 ++--
> src/qemu/qemu_driver.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c
>index db2a66d131..12fbe31c24 100644
>--- a/src/ch/ch_driver.c
>+++ b/src/ch/ch_driver.c
>@@ -1079,8 +1079,8 @@ chDomainHelperGetVcpus(virDomainObj *vm,
>                                       NULL, NULL,
>                                       &vcpuinfo->cpu, NULL,
>                                       vm->pid, vcpupid) < 0) {
>-                virReportSystemError(errno, "%s",
>-                                      _("cannot get vCPU placement & pCPU time"));
>+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>+                               _("cannot get vCPU placement & pCPU time"));
>                 return -1;
>             }
>         }
>diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>index d6879175fe..c576c601ad 100644
>--- a/src/qemu/qemu_driver.c
>+++ b/src/qemu/qemu_driver.c
>@@ -1355,8 +1355,8 @@ qemuDomainHelperGetVcpus(virDomainObj *vm,
>                                       NULL, NULL,
>                                       &vcpuinfo->cpu, NULL,
>                                       vm->pid, vcpupid) < 0) {
>-                virReportSystemError(errno, "%s",
>-                                     _("cannot get vCPU placement & pCPU time"));
>+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>+                               _("cannot get vCPU placement & pCPU time"));
>                 return -1;
>             }
>         }
>-- 
>2.38.2
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230123/e8ad93a5/attachment.sig>


More information about the libvir-list mailing list