Is there any possible (not necessary native) ways to get access (e.g., terminal usage is the main purpose for me) to guest OS with *nix using libvirt/LXC(not as libvirt module) capabilities? And I don't mean to use methods like lxc-console commands.

up vote 2 down vote accepted

If the guest is set up with a serial console, you can use virsh console. This works well with kvm, never tried it with LXC though

To access the serial console directly, without libvirt: Add this to the qemu-kvm cmd line

-chardev socket,id=monitor,path=/srv/kvm/${VMNAME}/run/monitor.sock,server,nowait \
-monitor chardev:monitor \
-chardev socket,id=serial0,path=/srv/kvm/${VMNAME}/run/console.sock,server,nowait \
-serial chardev:serial0

I pointed the socket to /srv/kvm/VMNAME/run in this case Then you can use minicom

cd /srv/kvm/VMNAME/run
minicom -D unix\#console.sock

On most distributions, you also need to have console=tty0 console=ttyS0,115200n8 or something similar in the kernel boot line

  • In my question, I mean is there any some other ways to do the same as virsh console? Or it's impossible? – zerospiel Nov 20 '13 at 18:22
  • You can do what libvirt does manually, through the sockets qemu has. But if you are using libvirt already, why bother? – dyasny Nov 20 '13 at 18:30
  • I just need to know all possible ways for my project. Can u link on proper functions, that can do the same as virsh console? – zerospiel Nov 20 '13 at 19:12
  • see the post update – dyasny Nov 20 '13 at 22:50

virsh domdisplay <VM-name> will give you a URL for connecting to a graphical console for a guest, if the guest doesn't have a serial console enabled.

virsh console <VM-name> will connect to the guest's serial console.

If all of this command line crap just annoys you, install the virt-manager GUI and you can point and click your way around managing your guests. (Note that virt-manager cannot yet install LXC guests.)

You could define a private network that is not accessible outside the LXC-server and use that network to access the LXC-guests via SSH (and bind SSH only to that network within the LXC guest).

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.