uvt-kvm list requires sudo on non-login shells
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
uvtool |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
As per the current implementation, `uvtool list` is a wrapper over `virsh`.
def main_list(parser, args):
# Hack for now. In time this should properly use the API and list
# only instances created with this tool.
subprocess.
In a non-login shell, listing VMs with virsh would require elevated permissions (sudo) when default configuration is used (at all levels: client configuration, env variables etc.):
┌─ ~
└─❯ sudo uvt-kvm list
test
┌─ ~
└─❯ uvt-kvm list
┌─ ~
└─❯
For default connection, libvirt uses the following rule to determine its value[1]:
1. The environment variable LIBVIRT_DEFAULT_URI
2. The client configuration file uri_default parameter
3. Probe each hypervisor in turn until one that works is found
`
So when none apply (configuration-
libvirt-clients provides a profile.d script to default the connection to the system daemon but, obviously, that only applies for login shells:
┌─ ~
└─❯ shopt -q login_shell; echo $?
1
┌─ ~
└─❯ echo $LIBVIRT_
┌─ ~
└─❯ bash -l
┌─ ~
└─❯ shopt -q login_shell; echo $?
0
┌─ ~
└─❯ echo $LIBVIRT_
qemu:///system
There is also worth mentioning that this bug report assumes that the user is part of the libvirt system group. Otherwise not only listing but also other operations are affected due to a lack of permissions on the libvirt socket.
[1] https:/
[2] https:/
Related branches
- Robie Basak: Pending requested
-
Diff: 93 lines (+10/-9)1 file modifieduvtool/libvirt/kvm.py (+10/-9)
- Robie Basak: Approve
-
Diff: 19 lines (+5/-3)1 file modifieduvtool/libvirt/kvm.py (+5/-3)
Changed in uvtool: | |
status: | New → Fix Committed |