#116 Tries to talk to system libvirt despite `-c qemu:///session`
Closed: Fixed by frantisekz. Opened by martinpitt.

This works through the tmt run --how virtual API, but somehow doesn't through testcloud directly:

❱❱❱ testcloud instance -c qemu:///session create fedora:34
libvirt: XML-RPC error : Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory
Traceback (most recent call last):
  File "/usr/bin/testcloud", line 33, in <module>
    sys.exit(load_entry_point('testcloud==0.6.1', 'console_scripts', 'testcloud')())
  File "/usr/lib/python3.9/site-packages/testcloud/cli.py", line 864, in main
    args.func(args)
  File "/usr/lib/python3.9/site-packages/testcloud/cli.py", line 311, in _create_instance
    _clean_backingstore(args)
  File "/usr/lib/python3.9/site-packages/testcloud/cli.py", line 182, in _clean_backingstore
    instances = instance.list_instances()
  File "/usr/lib/python3.9/site-packages/testcloud/instance.py", line 167, in list_instances
    domains = _prepare_domain_list(connection)
  File "/usr/lib/python3.9/site-packages/testcloud/instance.py", line 130, in _prepare_domain_list
    domains_system = _list_domains("qemu:///system")
  File "/usr/lib/python3.9/site-packages/testcloud/instance.py", line 88, in _list_domains
    conn = libvirt.openReadOnly(connection)
  File "/usr/lib64/python3.9/site-packages/libvirt.py", line 350, in openReadOnly
    raise libvirtError('virConnectOpenReadOnly() failed')
libvirt.libvirtError: Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory

A simple testcloud instance create fedora:34 fails in the same way (but that could be excused as defaulting to system libvirt).


This should fix the issue: https://pagure.io/testcloud/pull-request/115

I've created a COPR: https://copr.fedorainfracloud.org/coprs/frantisekz/testcloud-PR118/ containing that, can you try give it a shot when you have time?

Thanks and sorry for the trouble!

Nice, thanks! Updated, and this works now:

❱❱❱ sudo dnf update https://download.copr.fedorainfracloud.org/results/frantisekz/testcloud-PR118/fedora-34-x86_64/02828982-testcloud/python3-testcloud-0.6.1-10.fc34.noarch.rpm https://download.copr.fedorainfracloud.org/results/frantisekz/testcloud-PR118/fedora-34-x86_64/02828982-testcloud/testcloud-0.6.1-10.fc34.noarch.rpm
❱❱❱ testcloud instance -c qemu:///session create fedora:34
libvirt: XML-RPC error : Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory
libvirt: XML-RPC error : Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory
[...]
INFO:Successfully booted instance unruffled_clarke
The IP of vm unruffled_clarke:  127.0.0.1
The SSH port of vm unruffled_clarke:  10023
------------------------------------------------------------
To connect to the VM, use the following command (password is 'passw0rd'):
ssh fedora@127.0.0.1 -p 10023

I can log in through SSH. There are still two warnings about system libvirt, but that doesn't hurt.

Removal works, too:

❱❱❱ testcloud instance -c qemu:///session remove -f unruffled_clarke
DEBUG:remove instance: unruffled_clarke
libvirt: XML-RPC error : Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory
DEBUG:removing instance unruffled_clarke from libvirt.
DEBUG:stopping instance unruffled_clarke.
DEBUG:Unregistering instance from libvirt.
DEBUG:removing instance /var/lib/testcloud/instances/unruffled_clarke from disk

I also validated that updated version with tmt run, and it still works as expected.

Commit 6fbda2c8 fixes this issue

Thanks for confirmation!

I can log in through SSH. There are still two warnings about system libvirt, but that doesn't hurt.

If those warnings are okay-ish with you, I'll leave it as it is for now. I'll get back to these after finishing some other feature work. Fixing it would require a bit of code re-shuffling as it is now.

testcloud-0.6.2 is on pypi and should hit updates-testing tomorrow with this fixed.

Metadata
Related Pull Requests