device-url-syntax.rst.inc 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. In addition to using normal file images for the emulated storage
  2. devices, QEMU can also use networked resources such as iSCSI devices.
  3. These are specified using a special URL syntax.
  4. ``iSCSI``
  5. iSCSI support allows QEMU to access iSCSI resources directly and use
  6. as images for the guest storage. Both disk and cdrom images are
  7. supported.
  8. Syntax for specifying iSCSI LUNs is
  9. "iscsi://<target-ip>[:<port>]/<target-iqn>/<lun>"
  10. By default qemu will use the iSCSI initiator-name
  11. 'iqn.2008-11.org.linux-kvm[:<name>]' but this can also be set from
  12. the command line or a configuration file.
  13. Since version QEMU 2.4 it is possible to specify a iSCSI request
  14. timeout to detect stalled requests and force a reestablishment of the
  15. session. The timeout is specified in seconds. The default is 0 which
  16. means no timeout. Libiscsi 1.15.0 or greater is required for this
  17. feature.
  18. Example (without authentication):
  19. .. parsed-literal::
  20. |qemu_system| -iscsi initiator-name=iqn.2001-04.com.example:my-initiator \\
  21. -cdrom iscsi://192.0.2.1/iqn.2001-04.com.example/2 \\
  22. -drive file=iscsi://192.0.2.1/iqn.2001-04.com.example/1
  23. Example (CHAP username/password via URL):
  24. .. parsed-literal::
  25. |qemu_system| -drive file=iscsi://user%password@192.0.2.1/iqn.2001-04.com.example/1
  26. Example (CHAP username/password via environment variables):
  27. .. parsed-literal::
  28. LIBISCSI_CHAP_USERNAME="user" \\
  29. LIBISCSI_CHAP_PASSWORD="password" \\
  30. |qemu_system| -drive file=iscsi://192.0.2.1/iqn.2001-04.com.example/1
  31. ``NBD``
  32. QEMU supports NBD (Network Block Devices) both using TCP protocol as
  33. well as Unix Domain Sockets. With TCP, the default port is 10809.
  34. Syntax for specifying a NBD device using TCP, in preferred URI form:
  35. "nbd://<server-ip>[:<port>]/[<export>]"
  36. Syntax for specifying a NBD device using Unix Domain Sockets;
  37. remember that '?' is a shell glob character and may need quoting:
  38. "nbd+unix:///[<export>]?socket=<domain-socket>"
  39. Older syntax that is also recognized:
  40. "nbd:<server-ip>:<port>[:exportname=<export>]"
  41. Syntax for specifying a NBD device using Unix Domain Sockets
  42. "nbd:unix:<domain-socket>[:exportname=<export>]"
  43. Example for TCP
  44. .. parsed-literal::
  45. |qemu_system| --drive file=nbd:192.0.2.1:30000
  46. Example for Unix Domain Sockets
  47. .. parsed-literal::
  48. |qemu_system| --drive file=nbd:unix:/tmp/nbd-socket
  49. ``SSH``
  50. QEMU supports SSH (Secure Shell) access to remote disks.
  51. Examples:
  52. .. parsed-literal::
  53. |qemu_system| -drive file=ssh://user@host/path/to/disk.img
  54. |qemu_system| -drive file.driver=ssh,file.user=user,file.host=host,file.port=22,file.path=/path/to/disk.img
  55. Currently authentication must be done using ssh-agent. Other
  56. authentication methods may be supported in future.
  57. ``GlusterFS``
  58. GlusterFS is a user space distributed file system. QEMU supports the
  59. use of GlusterFS volumes for hosting VM disk images using TCP, Unix
  60. Domain Sockets and RDMA transport protocols.
  61. Syntax for specifying a VM disk image on GlusterFS volume is
  62. .. parsed-literal::
  63. URI:
  64. gluster[+type]://[host[:port]]/volume/path[?socket=...][,debug=N][,logfile=...]
  65. JSON:
  66. 'json:{"driver":"qcow2","file":{"driver":"gluster","volume":"testvol","path":"a.img","debug":N,"logfile":"...",
  67.   "server":[{"type":"tcp","host":"...","port":"..."},
  68.   {"type":"unix","socket":"..."}]}}'
  69. Example
  70. .. parsed-literal::
  71. URI:
  72. |qemu_system| --drive file=gluster://192.0.2.1/testvol/a.img,
  73.   file.debug=9,file.logfile=/var/log/qemu-gluster.log
  74. JSON:
  75. |qemu_system| 'json:{"driver":"qcow2",
  76.   "file":{"driver":"gluster",
  77.   "volume":"testvol","path":"a.img",
  78.   "debug":9,"logfile":"/var/log/qemu-gluster.log",
  79.   "server":[{"type":"tcp","host":"1.2.3.4","port":24007},
  80.   {"type":"unix","socket":"/var/run/glusterd.socket"}]}}'
  81. |qemu_system| -drive driver=qcow2,file.driver=gluster,file.volume=testvol,file.path=/path/a.img,
  82.   file.debug=9,file.logfile=/var/log/qemu-gluster.log,
  83.   file.server.0.type=tcp,file.server.0.host=1.2.3.4,file.server.0.port=24007,
  84.   file.server.1.type=unix,file.server.1.socket=/var/run/glusterd.socket
  85. See also http://www.gluster.org.
  86. ``HTTP/HTTPS/FTP/FTPS``
  87. QEMU supports read-only access to files accessed over http(s) and
  88. ftp(s).
  89. Syntax using a single filename:
  90. ::
  91. <protocol>://[<username>[:<password>]@]<host>/<path>
  92. where:
  93. ``protocol``
  94. 'http', 'https', 'ftp', or 'ftps'.
  95. ``username``
  96. Optional username for authentication to the remote server.
  97. ``password``
  98. Optional password for authentication to the remote server.
  99. ``host``
  100. Address of the remote server.
  101. ``path``
  102. Path on the remote server, including any query string.
  103. The following options are also supported:
  104. ``url``
  105. The full URL when passing options to the driver explicitly.
  106. ``readahead``
  107. The amount of data to read ahead with each range request to the
  108. remote server. This value may optionally have the suffix 'T', 'G',
  109. 'M', 'K', 'k' or 'b'. If it does not have a suffix, it will be
  110. assumed to be in bytes. The value must be a multiple of 512 bytes.
  111. It defaults to 256k.
  112. ``sslverify``
  113. Whether to verify the remote server's certificate when connecting
  114. over SSL. It can have the value 'on' or 'off'. It defaults to
  115. 'on'.
  116. ``cookie``
  117. Send this cookie (it can also be a list of cookies separated by
  118. ';') with each outgoing request. Only supported when using
  119. protocols such as HTTP which support cookies, otherwise ignored.
  120. ``timeout``
  121. Set the timeout in seconds of the CURL connection. This timeout is
  122. the time that CURL waits for a response from the remote server to
  123. get the size of the image to be downloaded. If not set, the
  124. default timeout of 5 seconds is used.
  125. Note that when passing options to qemu explicitly, ``driver`` is the
  126. value of <protocol>.
  127. Example: boot from a remote Fedora 20 live ISO image
  128. .. parsed-literal::
  129. |qemu_system_x86| --drive media=cdrom,file=https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/20/Live/x86_64/Fedora-Live-Desktop-x86_64-20-1.iso,readonly
  130. |qemu_system_x86| --drive media=cdrom,file.driver=http,file.url=http://archives.fedoraproject.org/pub/fedora/linux/releases/20/Live/x86_64/Fedora-Live-Desktop-x86_64-20-1.iso,readonly
  131. Example: boot from a remote Fedora 20 cloud image using a local
  132. overlay for writes, copy-on-read, and a readahead of 64k
  133. .. parsed-literal::
  134. qemu-img create -f qcow2 -o backing_file='json:{"file.driver":"http",, "file.url":"http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/20/Images/x86_64/Fedora-x86_64-20-20131211.1-sda.qcow2",, "file.readahead":"64k"}' /tmp/Fedora-x86_64-20-20131211.1-sda.qcow2
  135. |qemu_system_x86| -drive file=/tmp/Fedora-x86_64-20-20131211.1-sda.qcow2,copy-on-read=on
  136. Example: boot from an image stored on a VMware vSphere server with a
  137. self-signed certificate using a local overlay for writes, a readahead
  138. of 64k and a timeout of 10 seconds.
  139. .. parsed-literal::
  140. qemu-img create -f qcow2 -o backing_file='json:{"file.driver":"https",, "file.url":"https://user:password@vsphere.example.com/folder/test/test-flat.vmdk?dcPath=Datacenter&dsName=datastore1",, "file.sslverify":"off",, "file.readahead":"64k",, "file.timeout":10}' /tmp/test.qcow2
  141. |qemu_system_x86| -drive file=/tmp/test.qcow2