+
Skip to content

PLM: unintended error message displayed in CLI console #449

Open
@rayx

Description

@rayx

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载