最后,配置虚拟机的网络:(/etc/sysconfig/network
和 /etc/resolv.conf文件可以不考虑重新配置 )
[root@1005vm ~]# cat
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.77.255
HWADDR=52:54:00:88:F8:03
#mac地址可写可不写,因为xml配置文件中已制定了mac地址
IPADDR=192.168.77.93
NETMASK=255.255.255.0
NETWORK=192.168.77.0
NETWORKING_IPV6=no
GATEWAY=192.168.77.254
OnBOOT=yes
DNS1=210.42.35.35
DNS2=8.8.8.8
[root@1005vm ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=1003vm
NETWORKING_IPV6=no
GATEWAY=192.168.77.254
[root@1005vm ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 210.42.35.35
nameserver 8.8.8.8
[root@1005vm ~]# service network restart
Shutting down interface eth0: Device state: 3
(disconnected)
[ OK ]
Shutting down loopback interface: [ OK
]
Bringing up loopback interface: [ OK
]
Bringing up interface eth0: Active connection
state: activated
Active connection path:
/org/freedesktop/NetworkManager/ActiveConnection/1
[ OK ]
[root@1005vm ~]# ping www.baidu.com
PING www.a.shifen.com (119.75.217.109) 56(84) bytes of
data.
64 bytes from 119.75.217.109: icmp_seq=1 ttl=50 time=39.3
ms
64 bytes from 119.75.217.109: icmp_seq=2 ttl=50 time=33.3
ms
64 bytes from 119.75.217.109: icmp_seq=3 ttl=50 time=36.7
ms
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time
2494ms
rtt min/avg/max/mdev = 33.318/36.483/39.370/2.483 ms
五 其余需要注意及说明的情况
1:这种方式创建的虚拟机虚拟磁盘的格式为raw,此格式不能使用快照功能。
2:虚拟机镜像的默认位置在/var/lib/libvirt/images/文件夹下。
3:虚拟机的xml配置文件默认在/etc/libvirt/qemu/目录下。
待续.......