- KVM Virtualization Cookbook
- Konstantin Ivanov
- 81字
- 2021-07-02 22:07:11
How to do it...
To define a new KVM virtual machine, run the commands outlined here:
- List all virtual machines on the host OS:
root@kvm:~# virsh list --all
Id Name State
----------------------------------------------------
root@kvm:~#
- Create the following XML definition file:
root@kvm:~# cat kvm1.xml
<domain type='kvm' id='1'>
<name>kvm1</name>
<memory unit='KiB'>1048576</memory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
<boot dev='hd'/>
</os>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/tmp/debian.img'/>
<target dev='hda' bus='ide'/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<interface type='network'>
<source network='default'/>
<target dev='vnet0'/>
<model type='rtl8139'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<graphics type='vnc' port='5900' autoport='yes' listen='146.20.141.158'>
<listen type='address' address='146.20.141.158'/>
</graphics>
</devices>
<seclabel type='none'/>
</domain>
root@kvm:~#
- Define the virtual machine:
root@kvm:~# virsh define kvm1.xml
Domain kvm1 defined from kvm1.xml
root@kvm:~#
- List all instances in all states:
root@kvm:~# virsh list --all
Id Name State
----------------------------------------------------
- kvm1 shut off
root@kvm:~#
推薦閱讀
- Intel Galileo Essentials
- Visual C++程序設(shè)計學(xué)習(xí)筆記
- UI智能化與前端智能化:工程技術(shù)、實現(xiàn)方法與編程思想
- 嚴(yán)密系統(tǒng)設(shè)計:方法、趨勢與挑戰(zhàn)
- 全棧自動化測試實戰(zhàn):基于TestNG、HttpClient、Selenium和Appium
- Python Data Analysis Cookbook
- Learning R for Geospatial Analysis
- 微服務(wù)架構(gòu)深度解析:原理、實踐與進階
- Test-Driven Machine Learning
- Kivy Cookbook
- 零基礎(chǔ)學(xué)C語言第2版
- Machine Learning With Go
- C++語言程序設(shè)計
- Python網(wǎng)絡(luò)爬蟲技術(shù)與應(yīng)用
- ActionScript 3.0從入門到精通(視頻實戰(zhàn)版)