[libvirt] [PATCH] conf: fix virtType FromString check

Cole Robinson crobinso at redhat.com
Thu Jul 26 15:30:07 UTC 2018


In the domain definition, virtType is virDomainVirtType which is
unsigned, so comparing against -1 doesn't work. Cast to int first

Fixes 8e2982b5767

Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
This regressed in the past as well, when virtType was changed to
virDomainVirtType in 7383b8cc068, fixed by the follow up 5e06a4f063.
It's strange that virDomainVirtType is unsigned but VirtTypeFromString
can return -1... it should probably either work like virArch, or we
should switch virDomainVirtType to int in the DomainDef, but that
requires fixing a few other places too

 src/conf/domain_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c27c874d9e..30806d1e59 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19140,7 +19140,7 @@ virDomainDefParseCaps(virDomainDefPtr def,
                        "%s", _("missing domain type attribute"));
         goto cleanup;
     }
-    if ((def->virtType = virDomainVirtTypeFromString(virttype)) < 0) {
+    if ((int)(def->virtType = virDomainVirtTypeFromString(virttype)) < 0) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("invalid domain type %s"), virttype);
         goto cleanup;
-- 
2.17.1




More information about the libvir-list mailing list