admin 管理员组

文章数量: 1086019


2024年4月23日发(作者:pc版管理系统)

qemu-kvm命令行虚拟系统参数

虽然在Fedora上安装了Virt-manager,有比较好的界面可以操作和监视虚拟机,但是必须要

在root用户下才可以,而Xmanager不可以使用root用户远程fedora,再者要在KVM-Qemu

上进行开发的话,其命令行参数的了解是必须的。

下面以一个例子说明:

虚拟一个Windows7的系统安装,常用参数如下:

qemu-kvm -m 1024 -localtime -M pc -smp 1 -drive

file=Windows7_,cache=writeback,boot、=on -net

nic,macaddr=52:54:00:12:34:80 –net

tap-cdrom -boot d -name kvm-win7,process=kvm-win7 -vnc :2

-usb -usbdevice tablet

尝试过:qemu -m 512 -hda /home/ibm/Desktop/KVM/

-localtime -net nic,vlan=0,macaddr=52-54-00-12-34-02 -net

tap,vlan=0,ifname=tap0,script=no -boot d -cdrom

/home/ibm/Desktop/KVM/ -smp 2 -clock rtc -soundhw es1370

-m 1024 设置虚拟系统内存1024MB

-localtime 使虚拟系统与宿主系统时间一致

-M pc 虚拟系统类型为pc

-smp 1 1个CPU

-drive file=Windows7_,cache=writeback,boot=on

硬盘选项,虚拟磁盘是Windows7_,cache方式为writeback,可引导型

磁盘。

-net nic,macaddr=52:54:00:12:34:80 网卡选项,手工指定mac地址。

-net tap tap类型网络,相当于“桥模式”

-cdrom 光驱

-boot d 启动顺序。d代表光驱。

-name kvm-win7,process=kvm-win7 为虚拟机取名,便于识别

-vnc :2 这里是通过vnc连接控制窗口,这里是在5902端口。client可用IP:2

连接。

-usb -usbdevice tablet 启用usb设备中的tablet功能。开启该功能可使虚

拟机内外的鼠标同步。

另外,在安装了磁盘和网卡的半虚拟化驱动后,可以在-drive中加入if=virtio

使用磁盘半虚拟化,在-net nic中加入model=virtio使用网卡半虚拟化驱动。

qemu-system-x86_64 –help所得到的帮助信息如下:

QEMU emulator version 0.13.0 (qemu-kvm-0.13.0), Copyright (c) 2003-2008 Fabrice

Bellard

usage: qemu [options] [disk_image]

'disk_image' is a raw hard disk image for IDE hard disk 0

Standard options:

-h or -help display this help and exit

-version display version information and exit

-M machine select emulated machine (-M ? for list)

-cpu cpu select CPU (-cpu ? for list)

-smp n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets]

set the number of CPUs to 'n' [default=1]

maxcpus= maximum number of total cpus, including

offline CPUs for hotplug, etc

cores= number of CPU cores on one socket

threads= number of threads on one CPU core

sockets= number of discrete sockets in the system

-numa node[,mem=size][,cpus=cpu[-cpu]][,nodeid=node]

-fda/-fdb file use 'file' as floppy disk 0/1 image

-hda/-hdb file use 'file' as IDE hard disk 0/1 image

-hdc/-hdd file use 'file' as IDE hard disk 2/3 image

-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master)

-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]

[,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]

[,cache=writethrough|writeback|none|unsafe][,format=f]

[,serial=s][,addr=A][,id=name][,aio=threads|native]

[,readonly=on|off][,boot=on|off]

use 'file' as a drive image

-set =value

set parameter for item of type

i.e. -set drive.$=/path/to/image

-global ty=value

set a global default for a driver property

-mtdblock file use 'file' as on-board Flash memory image

-sd file use 'file' as SecureDigital card image

-pflash file use 'file' as a parallel flash image

-boot [order=drives][,once=drives][,menu=on|off]

'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)

-snapshot write to temporary files instead of disk image files

-m megs set virtual RAM size to megs MB [default=128]

-mem-path FILE provide backing storage for guest RAM

-mem-prealloc preallocate guest memory (use with -mem-path)

-k language use keyboard layout (for example 'fr' for French)

-audio-help print list of audio drivers and their options

-soundhw c1,... enable audio support


本文标签: 系统 虚拟 网卡 使用 功能