- drive参数很简单,可以理解成是定义了一个实际的硬盘(或者是cd)与drive对应的是device-drive option[,option[,option[,...]]]
-
Define a new drive. This includes creating a block driver node (the backend) as well as a guest device, and is mostly a shortcut for defining the corresponding-blockdev and -device options.
定义一个新的驱动,包括后端的驱动节点(可以理解成后端具体的设备)还有guest文件系统中的一个具体的设备。
-driveaccepts all options that are accepted by-blockdev. In addition, it knows the following options:
- file=file
-
This option defines which disk image (see disk_images) to use with this drive. If the filename contains comma, you must double it (for instance, "file=my,,file" to use file "my,file").
Special files such as iSCSI devices can be specified using protocol specific URLs. See the section for "Device URL Syntax" for more information.
- if=interface
-
This option defines on which type on interface the drive is connected. Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio, none.
- bus=bus,unit=unit
-
These options define where is connected the drive by defining the bus number and the unit id.
- index=index
-
This option defines where is connected the drive by using an index in the list of available connectors of a given interface type.
- media=media
-
This option defines the type of the media: disk or cdrom.
- cyls=c,heads=h,secs=s[,trans=t]
-
These options have the same definition as they have in-hdachs. These parameters are deprecated, use the corresponding parameters of
-device
instead. - snapshot=snapshot
-
snapshot is "on" or "off" and controls snapshot mode for the given drive (see-snapshot).
- cache=cache
-
cache is "none", "writeback", "unsafe", "directsync" or "writethrough" and controls how the host cache is used to access block data. This is a shortcut that sets thecache.directandcache.no-flushoptions (as in-blockdev), and additionallycache.writeback, which provides a default for thewrite-cacheoption of block guest devices (as in-device). The modes correspond to the following settings:
│ cache.writeback cache.direct cache.no-flush
─────────────┼─────────────────────────────────────────────────
writeback │ on off off
none │ on on off
writethrough │ off off off
directsync │ off on off
unsafe │ on off onThe default mode iscache=writeback.
- aio=aio
-
aio is "threads", or "native" and selects between pthread based disk I/O and native Linux AIO.
- format=format
-
Specify which disk format will be used rather than detecting the format. Can be used to specify format=raw to avoid interpreting an untrusted format header.
- serial=serial
-
This option specifies the serial number to assign to the device. This parameter is deprecated, use the corresponding parameter of
-device
instead. - addr=addr
-
Specify the controller’s PCI address (if=virtio only). This parameter is deprecated, use the corresponding parameter of
-device
instead. - werror=action,rerror=action
-
Specify which action to take on write and read errors. Valid actions are: "ignore" (ignore the error and try to continue), "stop" (pause QEMU), "report" (report the error to the guest), "enospc" (pause QEMU only if the host disk is full; report the error to the guest otherwise). The default setting iswerror=enospcandrerror=report.
- copy-on-read=copy-on-read
-
copy-on-read is "on" or "off" and enables whether to copy read backing file sectors into the image file.
- bps=b,bps_rd=r,bps_wr=w
-
Specify bandwidth throttling limits in bytes per second, either for all request types or for reads or writes only. Small values can lead to timeouts or hangs inside the guest. A safe minimum for disks is 2 MB/s.
- bps_max=bm,bps_rd_max=rm,bps_wr_max=wm
-
Specify bursts in bytes per second, either for all request types or for reads or writes only. Bursts allow the guest I/O to spike above the limit temporarily.
- iops=i,iops_rd=r,iops_wr=w
-
Specify request rate limits in requests per second, either for all request types or for reads or writes only.
- iops_max=bm,iops_rd_max=rm,iops_wr_max=wm
-
Specify bursts in requests per second, either for all request types or for reads or writes only. Bursts allow the guest I/O to spike above the limit temporarily.
- iops_size=is
-
Let every is bytes of a request count as a new request for iops throttling purposes. Use this option to prevent guests from circumventing iops limits by sending fewer but larger requests.
- group=g
-
Join a throttling quota group with given name g. All drives that are members of the same group are accounted for together. Use this option to prevent guests from circumventing throttling limits by using many small disks instead of a single larger disk.
By default, thecache.writeback=onmode is used. It will report data writes as completed as soon as the data is present in the host page cache. This is safe as long as your guest OS makes sure to correctly flush disk caches where needed. If your guest OS does not handle volatile disk write caches correctly and your host crashes or loses power, then the guest may experience data corruption.
For such guests, you should consider usingcache.writeback=off. This means that the host page cache will be used to read and write data, but write notification will be sent to the guest only after QEMU has made sure to flush each write to the disk. Be aware that this has a major impact on performance.
When using the-snapshotoption, unsafe caching is always used.
Copy-on-read avoids accessing the same backing file sectors repeatedly and is useful when the backing file is over a slow network. By default copy-on-read is off.
Instead of-cdromyou can use:
qemu-system-i386 -drive file=file,index=2,media=cdrom
Instead of-hda,-hdb,-hdc,-hdd, you can use:
qemu-system-i386 -drive file=file,index=0,media=disk
qemu-system-i386 -drive file=file,index=1,media=disk
qemu-system-i386 -drive file=file,index=2,media=disk
qemu-system-i386 -drive file=file,index=3,media=diskYou can open an image using pre-opened file descriptors from an fd set:
qemu-system-i386
-add-fd fd=3,set=2,opaque="rdwr:/path/to/file"
-add-fd fd=4,set=2,opaque="rdonly:/path/to/file"
-drive file=/dev/fdset/2,index=0,media=diskYou can connect a CDROM to the slave of ide0:
qemu-system-i386 -drive file=file,if=ide,index=1,media=cdrom
If you don’t specify the "file=" argument, you define an empty drive:
qemu-system-i386 -drive if=ide,index=1,media=cdrom
Instead of-fda,-fdb, you can use:
qemu-system-i386 -drive file=file,index=0,if=floppy
qemu-system-i386 -drive file=file,index=1,if=floppyBy default, interface is "ide" and index is automatically incremented:
qemu-system-i386 -drive file=a -drive file=b"
is interpreted like:
qemu-system-i386 -hda a -hdb b
相关文章
- docopt——好用的Python命令行参数解释器
- .NET 4.5: XMLSerializer构造函数重载的无法解释的参数(“位置”)
- 终极解释: java方法传递参数的方式
- VSCode下.json文件的编写之(1) linux/g++ (2).json中参数与预定义变量的意义解释
- MySQL5.7中 performance和sys schema中的监控参数解释(推荐)
- java中方法drawImage()的参数详细解释
- qemu的drive参数解释
- android中OnItemClickListener的参数解释
- NFS客户端访问行为相关的几个参数解释
- VSCode下.json文件的编写之(1) linux/g++ (2).json中参数与预定义变量的意义解释