게스트 비디오 어댑터 모델 변경하기
말이 나온 김에, 게스트 환경 설정 파일에 대해 살펴봅시다. 게스트 환경 설정 파일은 XML 형식 문서로 각 속성이 HTML 문서의 태그처럼 정의되어 있습니다. 이 파일을 이용하면 ‘가상 머신 관리자로 게스트 관리하기’와 ‘가상 머신 하드디스크 추가하기’에서 살펴본 가상 머신 관리자의 가상 머신 상세 정보 창에서 할 수 있는 일을 확인하거나 편집해볼 수 있습니다. 처음에는 이해하기 어렵지만 나중을 위해서라도 각 항목을 훑어볼 필요가 있습니다.
환경 설정 파일을 수정해서 게스트에 반영하려면 먼저 각 게스트가 종료된 상태여야 합니다.
shinjaehun@losttemple:~$ virsh list --all
Id 이름 상태
----------------------------------
- guest 종료
virsh edit 명령으로 게스트의 환경 설정을 수정합니다.
shinjaehun@losttemple:~$ virsh edit guest
virsh edit으로 게스트의 환경 설정 내용을 수정하면 실제 환경 설정 파일 ‘/etc/libvirt/qemu/[게스트].xml’을 수정하게 됩니다.
virsh edit 명령을 내리면 vi 편집기가 실행됩니다. 게스트에 대한 속성이 xml 형식으로 정의되어 있습니다. <domain type>에는 도메인 유형으로 kvm이 정의되어 있으며 <name>에는 게스트 이름이 설정되어 있습니다. <uuid>는 게스트에 부여된 고유 번호로 자동으로 할당되는 태그입니다. <memory>와 <vcpu>는 게스트에 할당된 메모리와 CPU 수를 의미합니다.
<domain type='kvm'> <name>guest</name> <uuid>40290cba-e71f-0a3e-2225-885bff08dc63</uuid> <memory unit='KiB'>1048576</memory> <currentMemory unit='KiB'>1048576</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type arch='i686' machine='pc-i440fx-trusty'>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>
다음은 장치 속성입니다. 시스템에 설치된 하드디스크와 CD 롬 드라이브, USB 컨트롤러가 정의되어 있습니다. virt-install로 게스트를 생성하면서 지정한 하드디스크 이미지의 파일 경로가 보입니다.
<devices> <emulator>/usr/bin/kvm-spice</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/home/shinjaehun/virtual_machines/guest.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk> <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller>
네트워크 인터페이스 속성입니다. <mac address>에서 네트워크 어댑터에 부여된 하드웨어 주소를 확인할 수 있습니다.
<interface type='network'> <mac address='52:54:00:da:92:4a'/> <source network='default'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>
나머지 내용은 게스트가 사용하는 장치에 대한 속성이 정의되어 있습니다. <video>의 속성인 <model type>에서 비디오 어댑터 모델을 변경할 수 있습니다. 해상도를 떨어뜨리기 위해 cirrus에서 vga로 변경해봅시다. 파일을 저장하고 명령 프롬프트로 나갑니다.
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
<model type='vga' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>
오타 또는 구문 오류가 발생하면 방금 입력했던 내용이 자동으로 취소됩니다.
libvirt-bin 서비스를 재시작하여 변경된 환경 설정 내용을 적용합니다. libvirt-bin 서비스를 재시작했기 때문에 게스트 ID는 1로 초기화됩니다.
shinjaehun@losttemple:~$ sudo service libvirt-bin restart
libvirt-bin stop/waiting
libvirt-bin start/running, process 16542
게스트를 실행하고 접속하여 변경 여부를 확인합니다.
shinjaehun@losttemple:~$ virsh start guest shinjaehun@losttemple:~$ vv guest
‘가상 콘솔에 접속하는 데 쉬운 방법이 없을까요?’에서 만들어 놓은 vv는 virt-viewer로 가상 콘솔에 접속하는 셸 스크립트입니다. 다음과 같이 직접 명령해도 문제없습니다.
shinjaehun@losttemple:~$ virt-viewer -c qemu:///system guest &