Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLM: unintended error message displayed in CLI console #449

Open
rayx opened this issue Jul 4, 2024 · 0 comments
Open

PLM: unintended error message displayed in CLI console #449

rayx opened this issue Jul 4, 2024 · 0 comments

Comments

@rayx
Copy link
Contributor

rayx commented Jul 4, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant