Hi Tung,
as other people have stated on [1] I first assumed that just the guest is 
missing.
I tried to recreate with 18.04 and as expected found this:

ubuntu@node-horsea:~$ virsh dominfo c3
Id:             340
Name:           c3
UUID:           eac4d5b1-1503-43cd-8f6a-b89c1b04d794
OS Type:        hvm
State:          running
CPU(s):         1
CPU time:       5,5s
Max memory:     524288 KiB
Used memory:    524288 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: apparmor
Security DOI:   0
Security label: libvirt-eac4d5b1-1503-43cd-8f6a-b89c1b04d794 (enforcing)

ubuntu@node-horsea:~$ logout
Connection to horsea closed.

$ ssh ubuntu@horsea "virsh dominfo c3"
error: failed to get domain 'c3'
error: Domain not found: no domain with matching name 'c3'

Ok, so far this seems to confirm your finding.
There sometimes are some security things about libvirt sockets and also 
dependent on the interactive/non-interactive login there could be some 
differences here.

And e voila:
$ ssh ubuntu@horsea -t 'bash -l -c "virsh dominfo c3"'
worked just fine.

So it is the difference of having a login shell or not.
I don't have any 16.04 systems left to easily retry atm.

I know that a login shell will set "LIBVIRT_DEFAULT_URI=qemu:///system"
as that is the most common default people in ubuntu want. There actually
are discussions every now and then if you'd want that or not but that is
what people are used to.

Now without a login shell that isn't set, and the probing/default
without might have changed due to libvirt upstream.

That known you can compare:
$ ssh ubuntu@horsea -t 'bash -l -c "virsh uri"'
qemu:///system
Connection to horsea closed.
$ ssh ubuntu@horsea "virsh uri"
qemu:///session

So by default you now get a per user session scope.

This isn't as much a bug as more of a change in defaults (where Ubuntu even 
tries to stick with the old defaults a bit more with the env var).
IMHO I'd call it not a bug atm.

To avoid that use login shells or guide your calls with the env variable 
yourself, example:
$ ssh ubuntu@horsea "LIBVIRT_DEFAULT_URI=qemu:///system virsh dominfo c3"

[1]: https://askubuntu.com/questions/1066230/cannot-execute-virsh-
command-through-ssh-on-ubuntu-18-04#

** Changed in: libvirt (Ubuntu)
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1787800

Title:
  Cannot execute Virsh command through SSH on Ubuntu 18.04

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1787800/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to