-
Notifications
You must be signed in to change notification settings - Fork 50
Description
While I use CBTOOL console, I observe this error message very often although it shouldn't appear:
Domain not found: no domain with matching name 'cb-centos-MYPLM-vm3-tinyvm'
The message is emitted by libvirt API lookupByName(), which is called in get_instances(). Since get_instances() is called in various places (e.g. when attaching or detaching vm), the message shows up frequently.
The root cause seems to be with the libvirt API. When it fails to find a domain with matched name, it not only throws exception but also print the message in stderr. I don't see other libvirt API has this behavior. The following example code demonstrates it (the code is copied from https://libvirt.org/python.html).
import libvirt
import sys
try:
conn = libvirt.openReadOnly(None)
except libvirt.libvirtError:
print('Failed to open connection to the hypervisor')
sys.exit(1)
try:
dom0 = conn.lookupByName("Domain-0")
except libvirt.libvirtError:
print('Failed to find the main domain')
sys.exit(1)
print("Domain 0: id %d running %s" % (dom0.ID(), dom0.OSType()))
print(dom0.info())
So it seems the only way to fix it is to write a custom implementation by calling libvirt's listAllDomains() api to get all instances and then filtering the array by using the specified domain name. Not sure if it's worth it (though I do find the message is confusing at first).