.\" Man page generated from reStructuredText. . .TH "QEMU-BLOCK-DRIVERS" "7" "Apr 05, 2021" "5.2.0" "QEMU" .SH NAME qemu-block-drivers \- QEMU block drivers reference . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH SYNOPSIS .sp QEMU block driver reference manual .SH DESCRIPTION .SS Disk image file formats .sp QEMU supports many image file formats that can be used with VMs as well as with any of the tools (like \fBqemu\-img\fP). This includes the preferred formats raw and qcow2 as well as formats that are supported for compatibility with older QEMU versions or other hypervisors. .sp Depending on the image format, different options can be passed to \fBqemu\-img create\fP and \fBqemu\-img convert\fP using the \fB\-o\fP option. This section describes each format and the options that are supported for it. .INDENT 0.0 .TP .B raw Raw disk image format. This format has the advantage of being simple and easily exportable to all other emulators. If your file system supports \fIholes\fP (for example in ext2 or ext3 on Linux or NTFS on Windows), then only the written sectors will reserve space. Use \fBqemu\-img info\fP to know the real size used by the image or \fBls \-ls\fP on Unix/Linux. .sp Supported options: .INDENT 7.0 .TP .B preallocation Preallocation mode (allowed values: \fBoff\fP, \fBfalloc\fP, \fBfull\fP). \fBfalloc\fP mode preallocates space for image by calling \fBposix_fallocate()\fP\&. \fBfull\fP mode preallocates space for image by writing data to underlying storage. This data may or may not be zero, depending on the storage location. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B qcow2 QEMU image format, the most versatile format. Use it to have smaller images (useful if your filesystem does not supports holes, for example on Windows), zlib based compression and support of multiple VM snapshots. .sp Supported options: .INDENT 7.0 .TP .B compat Determines the qcow2 version to use. \fBcompat=0.10\fP uses the traditional image format that can be read by any QEMU since 0.10. \fBcompat=1.1\fP enables image format extensions that only QEMU 1.1 and newer understand (this is the default). Amongst others, this includes zero clusters, which allow efficient copy\-on\-read for sparse images. .UNINDENT .INDENT 7.0 .TP .B backing_file File name of a base image (see \fBcreate\fP subcommand) .UNINDENT .INDENT 7.0 .TP .B backing_fmt Image format of the base image .UNINDENT .INDENT 7.0 .TP .B encryption This option is deprecated and equivalent to \fBencrypt.format=aes\fP .UNINDENT .INDENT 7.0 .TP .B encrypt.format If this is set to \fBluks\fP, it requests that the qcow2 payload (not qcow2 header) be encrypted using the LUKS format. The passphrase to use to unlock the LUKS key slot is given by the \fBencrypt.key\-secret\fP parameter. LUKS encryption parameters can be tuned with the other \fBencrypt.*\fP parameters. .sp If this is set to \fBaes\fP, the image is encrypted with 128\-bit AES\-CBC. The encryption key is given by the \fBencrypt.key\-secret\fP parameter. This encryption format is considered to be flawed by modern cryptography standards, suffering from a number of design problems: .INDENT 7.0 .IP \(bu 2 The AES\-CBC cipher is used with predictable initialization vectors based on the sector number. This makes it vulnerable to chosen plaintext attacks which can reveal the existence of encrypted data. .IP \(bu 2 The user passphrase is directly used as the encryption key. A poorly chosen or short passphrase will compromise the security of the encryption. .IP \(bu 2 In the event of the passphrase being compromised there is no way to change the passphrase to protect data in any qcow images. The files must be cloned, using a different encryption passphrase in the new file. The original file must then be securely erased using a program like shred, though even this is ineffective with many modern storage technologies. .UNINDENT .sp The use of this is no longer supported in system emulators. Support only remains in the command line utilities, for the purposes of data liberation and interoperability with old versions of QEMU. The \fBluks\fP format should be used instead. .UNINDENT .INDENT 7.0 .TP .B encrypt.key\-secret Provides the ID of a \fBsecret\fP object that contains the passphrase (\fBencrypt.format=luks\fP) or encryption key (\fBencrypt.format=aes\fP). .UNINDENT .INDENT 7.0 .TP .B encrypt.cipher\-alg Name of the cipher algorithm and key length. Currently defaults to \fBaes\-256\fP\&. Only used when \fBencrypt.format=luks\fP\&. .UNINDENT .INDENT 7.0 .TP .B encrypt.cipher\-mode Name of the encryption mode to use. Currently defaults to \fBxts\fP\&. Only used when \fBencrypt.format=luks\fP\&. .UNINDENT .INDENT 7.0 .TP .B encrypt.ivgen\-alg Name of the initialization vector generator algorithm. Currently defaults to \fBplain64\fP\&. Only used when \fBencrypt.format=luks\fP\&. .UNINDENT .INDENT 7.0 .TP .B encrypt.ivgen\-hash\-alg Name of the hash algorithm to use with the initialization vector generator (if required). Defaults to \fBsha256\fP\&. Only used when \fBencrypt.format=luks\fP\&. .UNINDENT .INDENT 7.0 .TP .B encrypt.hash\-alg Name of the hash algorithm to use for PBKDF algorithm Defaults to \fBsha256\fP\&. Only used when \fBencrypt.format=luks\fP\&. .UNINDENT .INDENT 7.0 .TP .B encrypt.iter\-time Amount of time, in milliseconds, to use for PBKDF algorithm per key slot. Defaults to \fB2000\fP\&. Only used when \fBencrypt.format=luks\fP\&. .UNINDENT .INDENT 7.0 .TP .B cluster_size Changes the qcow2 cluster size (must be between 512 and 2M). Smaller cluster sizes can improve the image file size whereas larger cluster sizes generally provide better performance. .UNINDENT .INDENT 7.0 .TP .B preallocation Preallocation mode (allowed values: \fBoff\fP, \fBmetadata\fP, \fBfalloc\fP, \fBfull\fP). An image with preallocated metadata is initially larger but can improve performance when the image needs to grow. \fBfalloc\fP and \fBfull\fP preallocations are like the same options of \fBraw\fP format, but sets up metadata also. .UNINDENT .INDENT 7.0 .TP .B lazy_refcounts If this option is set to \fBon\fP, reference count updates are postponed with the goal of avoiding metadata I/O and improving performance. This is particularly interesting with \fBcache=writethrough\fP which doesn\(aqt batch metadata updates. The tradeoff is that after a host crash, the reference count tables must be rebuilt, i.e. on the next open an (automatic) \fBqemu\-img check \-r all\fP is required, which may take some time. .sp This option can only be enabled if \fBcompat=1.1\fP is specified. .UNINDENT .INDENT 7.0 .TP .B nocow If this option is set to \fBon\fP, it will turn off COW of the file. It\(aqs only valid on btrfs, no effect on other file systems. .sp Btrfs has low performance when hosting a VM image file, even more when the guest on the VM also using btrfs as file system. Turning off COW is a way to mitigate this bad performance. Generally there are two ways to turn off COW on btrfs: .INDENT 7.0 .IP \(bu 2 Disable it by mounting with nodatacow, then all newly created files will be NOCOW. .IP \(bu 2 For an empty file, add the NOCOW file attribute. That\(aqs what this option does. .UNINDENT .sp Note: this option is only valid to new or empty files. If there is an existing file which is COW and has data blocks already, it couldn\(aqt be changed to NOCOW by setting \fBnocow=on\fP\&. One can issue \fBlsattr filename\fP to check if the NOCOW flag is set or not (Capital \(aqC\(aq is NOCOW flag). .UNINDENT .UNINDENT .INDENT 0.0 .TP .B qed Old QEMU image format with support for backing files and compact image files (when your filesystem or transport medium does not support holes). .sp When converting QED images to qcow2, you might want to consider using the \fBlazy_refcounts=on\fP option to get a more QED\-like behaviour. .sp Supported options: .INDENT 7.0 .TP .B backing_file File name of a base image (see \fBcreate\fP subcommand). .UNINDENT .INDENT 7.0 .TP .B backing_fmt Image file format of backing file (optional). Useful if the format cannot be autodetected because it has no header, like some vhd/vpc files. .UNINDENT .INDENT 7.0 .TP .B cluster_size Changes the cluster size (must be power\-of\-2 between 4K and 64K). Smaller cluster sizes can improve the image file size whereas larger cluster sizes generally provide better performance. .UNINDENT .INDENT 7.0 .TP .B table_size Changes the number of clusters per L1/L2 table (must be power\-of\-2 between 1 and 16). There is normally no need to change this value but this option can between used for performance benchmarking. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B qcow Old QEMU image format with support for backing files, compact image files, encryption and compression. .sp Supported options: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .TP .B backing_file File name of a base image (see \fBcreate\fP subcommand) .UNINDENT .INDENT 0.0 .TP .B encryption This option is deprecated and equivalent to \fBencrypt.format=aes\fP .UNINDENT .INDENT 0.0 .TP .B encrypt.format If this is set to \fBaes\fP, the image is encrypted with 128\-bit AES\-CBC. The encryption key is given by the \fBencrypt.key\-secret\fP parameter. This encryption format is considered to be flawed by modern cryptography standards, suffering from a number of design problems enumerated previously against the \fBqcow2\fP image format. .sp The use of this is no longer supported in system emulators. Support only remains in the command line utilities, for the purposes of data liberation and interoperability with old versions of QEMU. .sp Users requiring native encryption should use the \fBqcow2\fP format instead with \fBencrypt.format=luks\fP\&. .UNINDENT .INDENT 0.0 .TP .B encrypt.key\-secret Provides the ID of a \fBsecret\fP object that contains the encryption key (\fBencrypt.format=aes\fP). .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B luks LUKS v1 encryption format, compatible with Linux dm\-crypt/cryptsetup .sp Supported options: .INDENT 7.0 .TP .B key\-secret Provides the ID of a \fBsecret\fP object that contains the passphrase. .UNINDENT .INDENT 7.0 .TP .B cipher\-alg Name of the cipher algorithm and key length. Currently defaults to \fBaes\-256\fP\&. .UNINDENT .INDENT 7.0 .TP .B cipher\-mode Name of the encryption mode to use. Currently defaults to \fBxts\fP\&. .UNINDENT .INDENT 7.0 .TP .B ivgen\-alg Name of the initialization vector generator algorithm. Currently defaults to \fBplain64\fP\&. .UNINDENT .INDENT 7.0 .TP .B ivgen\-hash\-alg Name of the hash algorithm to use with the initialization vector generator (if required). Defaults to \fBsha256\fP\&. .UNINDENT .INDENT 7.0 .TP .B hash\-alg Name of the hash algorithm to use for PBKDF algorithm Defaults to \fBsha256\fP\&. .UNINDENT .INDENT 7.0 .TP .B iter\-time Amount of time, in milliseconds, to use for PBKDF algorithm per key slot. Defaults to \fB2000\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B vdi VirtualBox 1.1 compatible image format. .sp Supported options: .INDENT 7.0 .TP .B static If this option is set to \fBon\fP, the image is created with metadata preallocation. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B vmdk VMware 3 and 4 compatible image format. .sp Supported options: .INDENT 7.0 .TP .B backing_file File name of a base image (see \fBcreate\fP subcommand). .UNINDENT .INDENT 7.0 .TP .B compat6 Create a VMDK version 6 image (instead of version 4) .UNINDENT .INDENT 7.0 .TP .B hwversion Specify vmdk virtual hardware version. Compat6 flag cannot be enabled if hwversion is specified. .UNINDENT .INDENT 7.0 .TP .B subformat Specifies which VMDK subformat to use. Valid options are \fBmonolithicSparse\fP (default), \fBmonolithicFlat\fP, \fBtwoGbMaxExtentSparse\fP, \fBtwoGbMaxExtentFlat\fP and \fBstreamOptimized\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B vpc VirtualPC compatible image format (VHD). .sp Supported options: .INDENT 7.0 .TP .B subformat Specifies which VHD subformat to use. Valid options are \fBdynamic\fP (default) and \fBfixed\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B VHDX Hyper\-V compatible image format (VHDX). .sp Supported options: .INDENT 7.0 .TP .B subformat Specifies which VHDX subformat to use. Valid options are \fBdynamic\fP (default) and \fBfixed\fP\&. .INDENT 7.0 .TP .B block_state_zero Force use of payload blocks of type \(aqZERO\(aq. Can be set to \fBon\fP (default) or \fBoff\fP\&. When set to \fBoff\fP, new blocks will be created as \fBPAYLOAD_BLOCK_NOT_PRESENT\fP, which means parsers are free to return arbitrary data for those blocks. Do not set to \fBoff\fP when using \fBqemu\-img convert\fP with \fBsubformat=dynamic\fP\&. .UNINDENT .INDENT 7.0 .TP .B block_size Block size; min 1 MB, max 256 MB. 0 means auto\-calculate based on image size. .UNINDENT .INDENT 7.0 .TP .B log_size Log size; min 1 MB. .UNINDENT .UNINDENT .UNINDENT .SS Read\-only formats .sp More disk image file formats are supported in a read\-only mode. .INDENT 0.0 .TP .B bochs Bochs images of \fBgrowing\fP type. .UNINDENT .INDENT 0.0 .TP .B cloop Linux Compressed Loop image, useful only to reuse directly compressed CD\-ROM images present for example in the Knoppix CD\-ROMs. .UNINDENT .INDENT 0.0 .TP .B dmg Apple disk image. .UNINDENT .INDENT 0.0 .TP .B parallels Parallels disk image format. .UNINDENT .SS Using host drives .sp In addition to disk image files, QEMU can directly access host devices. We describe here the usage for QEMU version >= 0.8.3. .SS Linux .sp On Linux, you can directly use the host device filename instead of a disk image filename provided you have enough privileges to access it. For example, use \fB/dev/cdrom\fP to access to the CDROM. .INDENT 0.0 .TP .B CD You can specify a CDROM device even if no CDROM is loaded. QEMU has specific code to detect CDROM insertion or removal. CDROM ejection by the guest OS is supported. Currently only data CDs are supported. .TP .B Floppy You can specify a floppy device even if no floppy is loaded. Floppy removal is currently not detected accurately (if you change floppy without doing floppy access while the floppy is not loaded, the guest OS will think that the same floppy is loaded). Use of the host\(aqs floppy device is deprecated, and support for it will be removed in a future release. .TP .B Hard disks Hard disks can be used. Normally you must specify the whole disk (\fB/dev/hdb\fP instead of \fB/dev/hdb1\fP) so that the guest OS can see it as a partitioned disk. WARNING: unless you know what you do, it is better to only make READ\-ONLY accesses to the hard disk otherwise you may corrupt your host data (use the \fB\-snapshot\fP command line option or modify the device permissions accordingly). .UNINDENT .SS Windows .INDENT 0.0 .TP .B CD The preferred syntax is the drive letter (e.g. \fBd:\fP). The alternate syntax \fB\e\e.\ed:\fP is supported. \fB/dev/cdrom\fP is supported as an alias to the first CDROM drive. .sp Currently there is no specific code to handle removable media, so it is better to use the \fBchange\fP or \fBeject\fP monitor commands to change or eject media. .TP .B Hard disks Hard disks can be used with the syntax: \fB\e\e.\ePhysicalDriveN\fP where \fIN\fP is the drive number (0 is the first hard disk). .sp WARNING: unless you know what you do, it is better to only make READ\-ONLY accesses to the hard disk otherwise you may corrupt your host data (use the \fB\-snapshot\fP command line so that the modifications are written in a temporary file). .UNINDENT .SS Mac OS X .sp \fB/dev/cdrom\fP is an alias to the first CDROM. .sp Currently there is no specific code to handle removable media, so it is better to use the \fBchange\fP or \fBeject\fP monitor commands to change or eject media. .SS Virtual FAT disk images .sp QEMU can automatically create a virtual FAT disk image from a directory tree. In order to use it, just type: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 linux.img \-hdb fat:/my_directory .ft P .fi .UNINDENT .UNINDENT .sp Then you access access to all the files in the \fB/my_directory\fP directory without having to copy them in a disk image or to export them via SAMBA or NFS. The default access is \fIread\-only\fP\&. .sp Floppies can be emulated with the \fB:floppy:\fP option: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 linux.img \-fda fat:floppy:/my_directory .ft P .fi .UNINDENT .UNINDENT .sp A read/write support is available for testing (beta stage) with the \fB:rw:\fP option: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 linux.img \-fda fat:floppy:rw:/my_directory .ft P .fi .UNINDENT .UNINDENT .sp What you should \fInever\fP do: .INDENT 0.0 .IP \(bu 2 use non\-ASCII filenames .IP \(bu 2 use "\-snapshot" together with ":rw:" .IP \(bu 2 expect it to work when loadvm\(aqing .IP \(bu 2 write to the FAT directory on the host system while accessing it with the guest system .UNINDENT .SS NBD access .sp QEMU can access directly to block device exported using the Network Block Device protocol. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 linux.img \-hdb nbd://my_nbd_server.mydomain.org:1024/ .ft P .fi .UNINDENT .UNINDENT .sp If the NBD server is located on the same host, you can use an unix socket instead of an inet socket: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 linux.img \-hdb nbd+unix://?socket=/tmp/my_socket .ft P .fi .UNINDENT .UNINDENT .sp In this case, the block device must be exported using qemu\-nbd: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-nbd \-\-socket=/tmp/my_socket my_disk.qcow2 .ft P .fi .UNINDENT .UNINDENT .sp The use of qemu\-nbd allows sharing of a disk between several guests: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-nbd \-\-socket=/tmp/my_socket \-\-share=2 my_disk.qcow2 .ft P .fi .UNINDENT .UNINDENT .sp and then you can use it with two guests: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 linux1.img \-hdb nbd+unix://?socket=/tmp/my_socket qemu\-system\-x86_64 linux2.img \-hdb nbd+unix://?socket=/tmp/my_socket .ft P .fi .UNINDENT .UNINDENT .sp If the nbd\-server uses named exports (supported since NBD 2.9.18, or with QEMU\(aqs own embedded NBD server), you must specify an export name in the URI: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 \-cdrom nbd://localhost/debian\-500\-ppc\-netinst qemu\-system\-x86_64 \-cdrom nbd://localhost/openSUSE\-11.1\-ppc\-netinst .ft P .fi .UNINDENT .UNINDENT .sp The URI syntax for NBD is supported since QEMU 1.3. An alternative syntax is also available. Here are some example of the older syntax: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 linux.img \-hdb nbd:my_nbd_server.mydomain.org:1024 qemu\-system\-x86_64 linux2.img \-hdb nbd:unix:/tmp/my_socket qemu\-system\-x86_64 \-cdrom nbd:localhost:10809:exportname=debian\-500\-ppc\-netinst .ft P .fi .UNINDENT .UNINDENT .SS Sheepdog disk images .sp Sheepdog is a distributed storage system for QEMU. It provides highly available block level storage volumes that can be attached to QEMU\-based virtual machines. .sp You can create a Sheepdog disk image with the command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-img create sheepdog:///IMAGE SIZE .ft P .fi .UNINDENT .UNINDENT .sp where \fIIMAGE\fP is the Sheepdog image name and \fISIZE\fP is its size. .sp To import the existing \fIFILENAME\fP to Sheepdog, you can use a convert command. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-img convert FILENAME sheepdog:///IMAGE .ft P .fi .UNINDENT .UNINDENT .sp You can boot from the Sheepdog disk image with the command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 sheepdog:///IMAGE .ft P .fi .UNINDENT .UNINDENT .sp You can also create a snapshot of the Sheepdog image like qcow2. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-img snapshot \-c TAG sheepdog:///IMAGE .ft P .fi .UNINDENT .UNINDENT .sp where \fITAG\fP is a tag name of the newly created snapshot. .sp To boot from the Sheepdog snapshot, specify the tag name of the snapshot. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 sheepdog:///IMAGE#TAG .ft P .fi .UNINDENT .UNINDENT .sp You can create a cloned image from the existing snapshot. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-img create \-b sheepdog:///BASE#TAG sheepdog:///IMAGE .ft P .fi .UNINDENT .UNINDENT .sp where \fIBASE\fP is an image name of the source snapshot and \fITAG\fP is its tag name. .sp You can use an unix socket instead of an inet socket: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 sheepdog+unix:///IMAGE?socket=PATH .ft P .fi .UNINDENT .UNINDENT .sp If the Sheepdog daemon doesn\(aqt run on the local host, you need to specify one of the Sheepdog servers to connect to. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-img create sheepdog://HOSTNAME:PORT/IMAGE SIZE qemu\-system\-x86_64 sheepdog://HOSTNAME:PORT/IMAGE .ft P .fi .UNINDENT .UNINDENT .SS iSCSI LUNs .sp iSCSI is a popular protocol used to access SCSI devices across a computer network. .sp There are two different ways iSCSI devices can be used by QEMU. .sp The first method is to mount the iSCSI LUN on the host, and make it appear as any other ordinary SCSI device on the host and then to access this device as a /dev/sd device from QEMU. How to do this differs between host OSes. .sp The second method involves using the iSCSI initiator that is built into QEMU. This provides a mechanism that works the same way regardless of which host OS you are running QEMU on. This section will describe this second method of using iSCSI together with QEMU. .sp In QEMU, iSCSI devices are described using special iSCSI URLs. URL syntax: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C iscsi://[[%]@][:]// .ft P .fi .UNINDENT .UNINDENT .sp Username and password are optional and only used if your target is set up using CHAP authentication for access control. Alternatively the username and password can also be set via environment variables to have these not show up in the process list: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C export LIBISCSI_CHAP_USERNAME= export LIBISCSI_CHAP_PASSWORD= iscsi://// .ft P .fi .UNINDENT .UNINDENT .sp Various session related parameters can be set via special options, either in a configuration file provided via \(aq\-readconfig\(aq or directly on the command line. .sp If the initiator\-name is not specified qemu will use a default name of \(aqiqn.2008\-11.org.linux\-kvm[:\(aq] where is the UUID of the virtual machine. If the UUID is not specified qemu will use \(aqiqn.2008\-11.org.linux\-kvm[:\(aq] where is the name of the virtual machine. .sp Setting a specific initiator name to use when logging in to the target: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-iscsi initiator\-name=iqn.qemu.test:my\-initiator .ft P .fi .UNINDENT .UNINDENT .sp Controlling which type of header digest to negotiate with the target: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-iscsi header\-digest=CRC32C|CRC32C\-NONE|NONE\-CRC32C|NONE .ft P .fi .UNINDENT .UNINDENT .sp These can also be set via a configuration file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [iscsi] user = "CHAP username" password = "CHAP password" initiator\-name = "iqn.qemu.test:my\-initiator" # header digest is one of CRC32C|CRC32C\-NONE|NONE\-CRC32C|NONE header\-digest = "CRC32C" .ft P .fi .UNINDENT .UNINDENT .sp Setting the target name allows different options for different targets: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [iscsi "iqn.target.name"] user = "CHAP username" password = "CHAP password" initiator\-name = "iqn.qemu.test:my\-initiator" # header digest is one of CRC32C|CRC32C\-NONE|NONE\-CRC32C|NONE header\-digest = "CRC32C" .ft P .fi .UNINDENT .UNINDENT .sp How to use a configuration file to set iSCSI configuration options: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cat >iscsi.conf < /sys/bus/pci/devices/0000:06:0d.0/driver/unbind # echo 1102 0002 > /sys/bus/pci/drivers/vfio\-pci/new_id # qemu\-system\-x86_64 \-drive file=nvme://HOST:BUS:SLOT.FUNC/NAMESPACE .ft P .fi .UNINDENT .UNINDENT .sp Alternative syntax using properties: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C qemu\-system\-x86_64 \-drive file.driver=nvme,file.device=HOST:BUS:SLOT.FUNC,file.namespace=NAMESPACE .ft P .fi .UNINDENT .UNINDENT .sp \fIHOST\fP:\fIBUS\fP:\fISLOT\fP\&.\fIFUNC\fP is the NVMe controller\(aqs PCI device address on the host. .sp \fINAMESPACE\fP is the NVMe namespace number, starting from 1. .SS Disk image file locking .sp By default, QEMU tries to protect image files from unexpected concurrent access, as long as it\(aqs supported by the block protocol driver and host operating system. If multiple QEMU processes (including QEMU emulators and utilities) try to open the same image with conflicting accessing modes, all but the first one will get an error. .sp This feature is currently supported by the file protocol on Linux with the Open File Descriptor (OFD) locking API, and can be configured to fall back to POSIX locking if the POSIX host doesn\(aqt support Linux OFD locking. .sp To explicitly enable image locking, specify "locking=on" in the file protocol driver options. If OFD locking is not possible, a warning will be printed and the POSIX locking API will be used. In this case there is a risk that the lock will get silently lost when doing hot plugging and block jobs, due to the shortcomings of the POSIX locking API. .sp QEMU transparently handles lock handover during shared storage migration. For shared virtual disk images between multiple VMs, the "share\-rw" device option should be used. .sp By default, the guest has exclusive write access to its disk image. If the guest can safely share the disk image with other writers the \fB\-device ...,share\-rw=on\fP parameter can be used. This is only safe if the guest is running software, such as a cluster file system, that coordinates disk accesses to avoid corruption. .sp Note that share\-rw=on only declares the guest\(aqs ability to share the disk. Some QEMU features, such as image file formats, require exclusive write access to the disk image and this is unaffected by the share\-rw=on option. .sp Alternatively, locking can be fully disabled by "locking=off" block device option. In the command line, the option is usually in the form of "file.locking=off" as the protocol driver is normally placed as a "file" child under a format driver. For example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-blockdev driver=qcow2,file.filename=/path/to/image,file.locking=off,file.driver=file .ft P .fi .UNINDENT .UNINDENT .sp To check if image locking is active, check the output of the "lslocks" command on host and see if there are locks held by the QEMU process on the image file. More than one byte could be locked by the QEMU instance, each byte of which reflects a particular permission that is acquired or protected by the running block driver. .SH SEE ALSO .sp The HTML documentation of QEMU for more precise information and Linux user mode emulator invocation. .SH AUTHOR Fabrice Bellard and the QEMU Project developers .SH COPYRIGHT 2021, The QEMU Project Developers .\" Generated by docutils manpage writer. .