3

I am using Ubuntu 18.04 for KVM host. On a jumphost, I tried to execute virsh command:

ssh user@ip "virsh dominfo vm1"

I got an error: failed to get domain 'vm1' But this command worked well on KVM host. I figured out that this problem does not happen if the KVM host is Ubuntu 16.04.

3
  • The VM that name must exist. Use the correct name. Aug 17, 2018 at 17:57
  • Hi @MichaelHampton, the VM has existed. I even use domain ID but still got the same issue
    – Shayne
    Aug 19, 2018 at 8:45
  • FYI: reported in LP bug Aug 20, 2018 at 6:46

1 Answer 1

6

The default URI of virsh to connect to can change (and it did change upstream).

You can check that with:

$ ssh ubuntu@ip -t 'bash -l -c "virsh uri"'
qemu:///system
$ ssh ubuntu@ip "virsh uri"
qemu:///session

Ubuntu tries to help with an environment variable LIBVIRT_DEFAULT_URI=qemu:///system but that is only available in login shells.

So you'd either need to make sure you use full login shells e.g.:

  $ ssh ubuntu@ip -t 'bash -l -c "virsh dominfo vm1"'

Or to augment your call with the env var on your own:

  $ ssh ubuntu@ip "LIBVIRT_DEFAULT_URI=qemu:///system virsh dominfo vm1"
1
  • I was hit by this change in behavior recently and could not figure out what is happening, this explains it, thank you.
    – marosg
    Mar 25, 2019 at 20:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .