On 6/6/21 12:15 PM, Fabiano Fidêncio wrote: > Currently `virt-host-validate` will fail whenever one of its calls fail, > regardless of virHostValidateLevel set. > > This behaviour is not optimal and makes it not exactly reliable as a > command line tool as other tools or scripts using it would have to check > its output to figure out whether something really failed or if a warning > was mistakenly treated as failure. > > With this change, the behaviour of whether to fail or not, is defined by > the caller of those functions, based on the virHostValidateLevel passed > to them. > > Signed-off-by: Fabiano Fidêncio <fabiano@xxxxxxxxxxxx> > --- > tools/virt-host-validate-common.c | 129 ++++++++++++++++++++++-------- > 1 file changed, 94 insertions(+), 35 deletions(-) > > diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c > index 6dd851f07d..2bf97bad75 100644 > --- a/tools/virt-host-validate-common.c > +++ b/tools/virt-host-validate-common.c > @@ -138,15 +138,21 @@ int virHostValidateDeviceExists(const char *hvname, > virHostValidateLevel level, > const char *hint) > { > + int ret = 0; > + > virHostMsgCheck(hvname, "if device %s exists", dev_name); > > if (access(dev_name, F_OK) < 0) { > virHostMsgFail(level, "%s", hint); > - return -1; > + if (level == VIR_HOST_VALIDATE_FAIL) > + ret = -1; > + goto out; > } > > virHostMsgPass(); > - return 0; > + > + out: > + return ret; > } > > The patch, or idea it implements is correct. However, I think a lot of these 'out' labels can be dropped and 'goto out' can be replaced with 'return -1' or 'return 0'. Does that work for you? Michal