[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [libvirt-sandbox][PATCH v2] Fix logical judgement in get_name



As usual, this issue can't be hit, but from codes point of view,
if deliberately remove 'name' in the configuration, and then the
'Name not congfigured' error message can't be raised unless the
configuration file doesn't exist, in fact, the get_name() will 
directly return None without expected error.    

Signed-off-by: Alex Jia <ajia redhat com>
---
 bin/virt-sandbox-service | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index 03873c9..26b4a40 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -453,8 +453,12 @@ WantedBy=multi-user.target
 
     def get_name(self):
         if self.config:
-            return self.config.get_name()
-        raise ValueError([_("Name not configured")])
+            name = self.config.get_name()
+            if not name:
+                raise ValueError([_("Name not configured")])
+            return name
+        sys.stderr.write("The configuration %s does not exist\n" % self.config)
+        sys.exit(1)
 
     def set_copy(self, copy):
         self.copy = copy
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]