mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
inspection: report guest inspection errors
Add an `error' flag to the inspection data for a guest and set it when the inspection failed. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
02f3546e02
commit
b3131e828e
@ -142,6 +142,7 @@ class vmmInspectionData(object):
|
|||||||
self.product_variant = None
|
self.product_variant = None
|
||||||
self.icon = None
|
self.icon = None
|
||||||
self.applications = None
|
self.applications = None
|
||||||
|
self.error = False
|
||||||
|
|
||||||
|
|
||||||
class vmmDomainSnapshot(vmmLibvirtObject):
|
class vmmDomainSnapshot(vmmLibvirtObject):
|
||||||
|
@ -122,6 +122,11 @@ class vmmInspection(vmmGObject):
|
|||||||
if not conn.is_active():
|
if not conn.is_active():
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def set_inspection_error(vm):
|
||||||
|
data = vmmInspectionData()
|
||||||
|
data.error = True
|
||||||
|
self._set_vm_inspection_data(vm, data)
|
||||||
|
|
||||||
prettyvm = vmuuid
|
prettyvm = vmuuid
|
||||||
try:
|
try:
|
||||||
vm = conn.get_vm(vmuuid)
|
vm = conn.get_vm(vmuuid)
|
||||||
@ -139,7 +144,15 @@ class vmmInspection(vmmGObject):
|
|||||||
|
|
||||||
# Whether success or failure, we've "seen" this VM now.
|
# Whether success or failure, we've "seen" this VM now.
|
||||||
self._vmseen[vmuuid] = True
|
self._vmseen[vmuuid] = True
|
||||||
self._process(conn, vm, vmuuid)
|
try:
|
||||||
|
data = self._process(conn, vm, vmuuid)
|
||||||
|
if data:
|
||||||
|
self._set_vm_inspection_data(vm, data)
|
||||||
|
else:
|
||||||
|
set_inspection_error(vm)
|
||||||
|
except:
|
||||||
|
set_inspection_error(vm)
|
||||||
|
raise
|
||||||
except:
|
except:
|
||||||
logging.exception("%s: exception while processing",
|
logging.exception("%s: exception while processing",
|
||||||
prettyvm)
|
prettyvm)
|
||||||
@ -148,7 +161,7 @@ class vmmInspection(vmmGObject):
|
|||||||
if re.search(r"^guestfs-", vm.get_name()):
|
if re.search(r"^guestfs-", vm.get_name()):
|
||||||
logging.debug("ignore libvirt/guestfs temporary VM %s",
|
logging.debug("ignore libvirt/guestfs temporary VM %s",
|
||||||
vm.get_name())
|
vm.get_name())
|
||||||
return
|
return None
|
||||||
|
|
||||||
g = GuestFS()
|
g = GuestFS()
|
||||||
prettyvm = conn.get_uri() + ":" + vm.get_name()
|
prettyvm = conn.get_uri() + ":" + vm.get_name()
|
||||||
@ -163,7 +176,7 @@ class vmmInspection(vmmGObject):
|
|||||||
|
|
||||||
if not disks:
|
if not disks:
|
||||||
logging.debug("%s: nothing to inspect", prettyvm)
|
logging.debug("%s: nothing to inspect", prettyvm)
|
||||||
return
|
return None
|
||||||
|
|
||||||
# Add the disks. Note they *must* be added with readonly flag set.
|
# Add the disks. Note they *must* be added with readonly flag set.
|
||||||
for disk in disks:
|
for disk in disks:
|
||||||
@ -173,7 +186,7 @@ class vmmInspection(vmmGObject):
|
|||||||
if not (os.path.exists(path) and os.access(path, os.R_OK)):
|
if not (os.path.exists(path) and os.access(path, os.R_OK)):
|
||||||
logging.debug("%s: cannot access '%s', skipping inspection",
|
logging.debug("%s: cannot access '%s', skipping inspection",
|
||||||
prettyvm, path)
|
prettyvm, path)
|
||||||
return
|
return None
|
||||||
|
|
||||||
g.add_drive_opts(path, readonly=1, format=driver_type)
|
g.add_drive_opts(path, readonly=1, format=driver_type)
|
||||||
|
|
||||||
@ -183,7 +196,7 @@ class vmmInspection(vmmGObject):
|
|||||||
roots = g.inspect_os()
|
roots = g.inspect_os()
|
||||||
if len(roots) == 0:
|
if len(roots) == 0:
|
||||||
logging.debug("%s: no operating systems found", prettyvm)
|
logging.debug("%s: no operating systems found", prettyvm)
|
||||||
return
|
return None
|
||||||
|
|
||||||
# Arbitrarily pick the first root device.
|
# Arbitrarily pick the first root device.
|
||||||
root = roots[0]
|
root = roots[0]
|
||||||
@ -264,8 +277,9 @@ class vmmInspection(vmmGObject):
|
|||||||
data.product_variant = str(product_variant)
|
data.product_variant = str(product_variant)
|
||||||
data.icon = icon
|
data.icon = icon
|
||||||
data.applications = list(apps)
|
data.applications = list(apps)
|
||||||
|
data.error = False
|
||||||
|
|
||||||
self._set_vm_inspection_data(vm, data)
|
return data
|
||||||
|
|
||||||
def _set_vm_inspection_data(self, vm, data):
|
def _set_vm_inspection_data(self, vm, data):
|
||||||
vm.inspection = data
|
vm.inspection = data
|
||||||
|
Loading…
Reference in New Issue
Block a user