root@dbkvm:~# virt-cat -d vm1 /etc/network/interfaces
# This file describes the network interfaces available on your
system
# and how to activate them. For more information, see
interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.51
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if
installed
dns-nameservers 8.8.8.8
dns-search localdomain
# ttyS0.conf - getty
# This service maintains a getty on ttyS0 from the point the system
is
# started until it is shut down again.
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
安装guestfish程序:
apt-get install guestfish
现在用virt-copy-in将文件复制到vm的/etc/init目录中:
virt-copy-in -d vm1 ttyS0.conf /etc/init
然后调用virsh edit vm1 来编辑vm1的配置文件,添加下面的内容:
...
最后试用一下:
virsh start vm1
Domain vm1 started
root@dbkvm:~/kvm_scripts# virsh console vm1
Connected to domain vm1
Escape character is ^]
Ubuntu 12.04.2 LTS vm1 ttyS0
vm1 login: root
Password:
Last login: Thu May 2 09:21:03 UTC 2013 from 192.168.1.4 on
pts/1
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-41-virtual
x86_64)