0

I am trying to launch multiple VMs and need to have a direct console access (whether through ssh etc.)

So, far I can launch multiple VMs using virsh/KVM tools. How I do it is that I just have one template dumped xml config file and create VMs. However, I always have to reply on GUI to access VM consoles. I tried to ssh into it which gives me a following error. ssh: connect to host 192.168.122.14 port 22: Connection refused I can't get SSH to work after seeing multiple forums and maybe there are other ways that can get-around this problems. How do I get around this problem OR is there better alternatives?

I did also try vagrant which I can ssh but I would prefer using virsh/KVM tools (later I would need to perform live-migration which virsh supports better than vagrant)

2
  • Have you installed ssh on the virtual machine? Do you have a firewall blocking port 22? If so use an alternative port that is not blocked! Oct 7, 2014 at 20:37
  • openssh is installed on the VM. How would I check if a firewall is blocking port 22? and how would I use an alternative if so? I'm new to this so I'm not sure how to do that! Oct 8, 2014 at 5:29

2 Answers 2

2

While oVirt is a great solution, it doesn't answer the specific question here.

Libvirt provides the means to access a VM directly. To set that up, you need to do the following:

  1. Enable ttyS0 console in the guest (add console=ttyS0 to the grub line, enable console in /etc/securetty or /etc/inittab)
  2. Add the following code to the guest domxml:
<serial type='pty'>
  <target port='0'/>
</serial>
<console type='pty'>
  <target type='serial' port='0'/>
</console>
  1. Start the VM and use virsh console VMNAME to access the serial console
4
  • I actually have something similar on my .xml: virsh ttyconsole ubuntu-desktop1 /dev/pts/8 But when I do virsh console blah blah, I get "Escape character is ^]" which seems like I can only exit and not any other things.. any idea? Oct 7, 2014 at 20:22
  • if you're properly configured, hit enter at this point a couple of times
    – dyasny
    Oct 7, 2014 at 20:40
  • Thanks. I think I was not configured properly. editing /etc/init/ttyS0.conf helped. Just curious how is this alternative different to your suggestion in editing grub? Also, I was avoiding the use of GUI at all costs but it seems like for initial set-up for the console on guest VM, I need to access via GUI because I won't have an direct access to console initially? DO you know any work-around this initial set-up (can i do it all via cmd?) Oct 8, 2014 at 5:23
  • Well, do automatic deployments with all the console options in the config scripts or the template and you will not have these issues. As for grub - the console option there is just to be able to see the server boot, after that, you need the ttyS0 setup in the guest as well
    – dyasny
    Oct 8, 2014 at 14:03
0

Have you looked at oVirt? It adds a nice management layer on top of libvirt tools which will help a lot if you start supporting multiple machines. One of it's biggest assets is simplification of network management. And if you want a SPICE console window just click the icon. If you don't want to use the GUI I'd look at the console.vv file you download when clicking the GUI icon, I'm sure you can mimic the same action in a script if you can get the VM ids.

I'm not sure whether or not it's an option today, but an option that automatically opened a console upon machine startup is a reasonable feature request in my opinion.

1
  • thanks i'll take a look at oVirt too maybe it will be of use later Oct 8, 2014 at 5:28

You must log in to answer this question.

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