[PATCH] qemu: Use virDomainObjCheckActive() more

Ján Tomko jtomko at redhat.com
Mon Feb 21 13:27:10 UTC 2022


On a Monday in 2022, Michal Privoznik wrote:
>Using the following spatch, I've identified two places which
>could be switched from explicit virDomainObjIsActive() +
>virReportError() to virDomainObjCheckActive():
>
>  @@
>  expression dom;
>  @@
>      if (
>  -        !virDomainObjIsActive(dom)
>  +        virDomainObjCheckActive(dom) < 0
>      ) {
>  -        virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not running"));
>          ...
>      }
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
>
>BTW. if I'm more aggressive and let virReportError() have just any args
>then even more places fit the rule (approx. two dozen more).
>

Had you sent that as a patch, we would have been able to see what kind
of error messages are used in those places without having to run the
spatch.

> src/qemu/qemu_driver.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220221/70ab61da/attachment-0001.sig>


More information about the libvir-list mailing list