virsh命令管理虚拟机 

   libvirt有两种控制方式,命令行和图形界面。

  1.图形界面:通过执行名virt-manager,启动libvirt的图形界面,在图形界面下可以一步一步的创建虚拟机,管理虚拟机,还可以直接控制虚拟机的桌面。

  2.命令行就是接下来我所说的。如何通过命令行来控制虚拟机。

创建虚拟机

  在/etc/libvirt/qemu下新建xml文件,如node.xml。需要有内存、cpu、硬盘设置、光驱以及vnc等等。以下是我根据Openstack启的虚机修改而成,没办法,直接用Openstack的文件启动虚机会失败的,网桥不兼容什么的原因,具体的我忘了,原谅我那只有7秒钟的记忆吧~代码贴到下面了:

 1 <domain type='qemu'>
 2   <name>node3</name>
 3   <uuid>84b31010-6124-4529-baf9-bae25e18d933</uuid>
 4   <memory unit='KiB'>524288</memory>
 5   <currentMemory unit='KiB'>524288</currentMemory>
 6   <vcpu placement='static'>1</vcpu>
 7   <sysinfo type='smbios'>
 8     <system>
 9       <entry name='manufacturer'>Red Hat Inc.</entry>
10       <entry name='product'>OpenStack Nova</entry>
11       <entry name='version'>2014.1.1-2.el6</entry>
12       <entry name='serial'>421c7a3a-7f61-cde9-13cb-8b5804fc62cc</entry>
13       <entry name='uuid'>84b31010-6124-4529-baf9-bae25e18d933</entry>
14     </system>
15   </sysinfo>
16   <os>
17     <type arch='x86_64' machine='rhel6.5.0'>hvm</type>
18     <boot dev='hd'/>    //硬盘启动
19     <smbios mode='sysinfo'/>
20   </os>
21   <features>
22     <acpi/>
23     <apic/>
24   </features>
25   <cpu mode='host-model'>
26     <model fallback='allow'/>
27   </cpu>
28   <clock offset='utc'/>
29   <on_poweroff>destroy</on_poweroff>
30   <on_reboot>restart</on_reboot>
31   <on_crash>destroy</on_crash>
32   <devices>
33     <emulator>/usr/libexec/qemu-kvm</emulator>
34     <controller type='usb' index='0'>
35       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
36     </controller>
37     <memballoon model='virtio'>
38       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
39     </memballoon>
40   </devices>
41 </domain>
View Code

相关文章:

  • 2021-06-29
  • 2021-11-23
  • 2021-05-22
  • 2021-09-16
  • 2021-06-07
  • 2021-08-05
猜你喜欢
  • 2021-12-15
  • 2021-11-23
  • 2021-08-24
  • 2021-05-19
  • 2021-09-13
  • 2021-12-15
  • 2021-12-15
相关资源
相似解决方案