KVM虚拟化:使用VNC访问客户机VM

来源:互联网 发布:mac查找文件路径 编辑:程序博客网 时间:2024/06/07 01:47

简介

如果你想通过VNC访问客户机VM的窗口,你需要将客户机窗口添加到VNC服务器中。本文介绍如何通过修改xml配置文件来设置VNC参数,并通过VNC client来访问VM的VGA窗口。

修改配置文件

KVM客户机的配置文件放置在/etc/libvirt/qemu目录下。使用vi可以查看虚拟机的xml配置文件。
[root@CentOS65 ~]# vi /etc/libvirt/qemu/centos65.xml <!--WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:  virsh edit centos65or other application using the libvirt API.--><domain type='kvm'>  <name>centos65</name>  <uuid>9a1e6c72-47df-f5a5-a5b5-71311472248a</uuid>  <memory unit='KiB'>2097152</memory>  <currentMemory unit='KiB'>2097152</currentMemory>  <vcpu placement='static'>1</vcpu>  <os>    <type arch='x86_64' machine='rhel6.6.0'>hvm</type>    <boot dev='hd'/>  </os>  <features>    <acpi/>    <apic/>    <pae/>  </features>  <clock offset='utc'/>  <on_poweroff>destroy</on_poweroff>  <on_reboot>restart</on_reboot>  <on_crash>restart</on_crash>  <devices>......    <graphics type='vnc' port='5920' autoport='no'/>...  </devices></domain>
xml文件的devices元素包含对虚拟机的设备配置,通过配置其中的graphics元素,可以设置VNC连接。graphics元素包含以下可以配置属性:
  • type属性: 此属性为必须配置的属性,可以设置为"sdl", "vnc", "rdp" or "desktop". 在上面的例子中,设置为vnc,以可通过VNC进行远程访问。
  • port属性:VNC服务端口号,是属性在autoport属性值设置为"no"时有效
  • autoport属性: 是否自动分配VNC TCP端口,配置为"yes"或"no"。与port属性配合使用。
  • passwd属性: 以明文方式设置VNC登录密码
  • keymap属性: 键盘配置
  • listen属性: VNC服务侦听的IP地址.
可以通过virsh命令查看当前VNC端口配置信息
[root@CentOS65 ~]# virsh vncdisplayerror: command 'vncdisplay' requires <domain> option[root@CentOS65 ~]# virsh vncdisplay centos65127.0.0.1:20
配置完成后,重启相关服务:
# service libvirtd restart# virsh shutdown centos65# virsh start centos65

0 0
原创粉丝点击