1 = How to convert to -device & friends =
3 === Specifying Bus and Address on Bus ===
5 In qdev, each device has a parent bus. Some devices provide one or
6 more buses for children. You can specify a device's parent bus with
9 A device typically has a device address on its parent bus. For buses
10 where this address can be configured, devices provide a bus-specific
13 bus property name value format
14 PCI addr %x.%x (dev.fn, .fn optional)
18 Example: device i440FX-pcihost is on the root bus, and provides a PCI
19 bus named pci.0. To put a FOO device into its slot 4, use -device
20 FOO,bus=/i440FX-pcihost/pci.0,addr=4. The abbreviated form bus=pci.0
21 also works as long as the bus name is unique.
23 Note: the USB device address can't be controlled at this time.
27 A QEMU block device (drive) has a host and a guest part.
29 In the general case, the guest device is connected to a controller
30 device. For instance, the IDE controller provides two IDE buses, each
31 of which can have up to two ide-drive devices, and each ide-drive
32 device is a guest part, and is connected to a host part.
34 Except we sometimes lump controller, bus(es) and drive device(s) all
35 together into a single device. For instance, the ISA floppy
36 controller is connected to up to two host drives.
38 The old ways to define block devices define host and guest part
39 together. Sometimes, they can even define a controller device in
40 addition to the block device.
42 The new way keeps the parts separate: you create the host part with
43 -drive, and guest device(s) with -device.
45 The various old ways to define drives all boil down to the common form
47 -drive if=TYPE,index=IDX,bus=BUS,unit=UNIT,HOST-OPTS...
49 TYPE, BUS and UNIT identify the controller device, which of its buses
50 to use, and the drive's address on that bus. Details depend on TYPE.
51 IDX is an alternative way to specify BUS and UNIT.
53 In the new way, this becomes something like
55 -drive if=none,id=DRIVE-ID,HOST-OPTS...
56 -device DEVNAME,drive=DRIVE-ID,DEV-OPTS...
58 The -device argument differs in detail for each kind of drive:
62 -device ide-drive,drive=DRIVE-ID,bus=IDE-BUS,unit=UNIT
64 where IDE-BUS identifies an IDE bus, normally either ide.0 or ide.1,
65 and UNIT is either 0 or 1.
67 Bug: new way does not work for ide.1 unit 0 (in old terms: index=2)
68 unless you disable the default CD-ROM with -nodefaults.
72 The old way implicitly creates SCSI controllers as needed. The new
73 way makes that explicit:
75 -device lsi53c895a,id=ID
77 As for all PCI devices, you can add bus=PCI-BUS,addr=DEVFN to
78 control the PCI device address.
80 This SCSI controller a single SCSI bus, named ID.0. Put a disk on
83 -device scsi-disk,drive=DRIVE-ID,bus=ID.0,scsi-id=SCSI-ID
87 -global isa-fdc,driveA=DRIVE-ID,driveB=DRIVE-ID
89 This is -global instead of -device, because the floppy controller is
90 created automatically, and we want to configure that one, not create
91 a second one (which isn't possible anyway).
93 Omitting a drive parameter makes that drive empty.
95 Bug: driveA works only if you disable the default floppy drive with
100 -device virtio-blk-pci,drive=DRIVE-ID,class=C,vectors=V
102 This lets you control PCI device class and MSI-X vectors.
104 As for all PCI devices, you can add bus=PCI-BUS,addr=DEVFN to
105 control the PCI device address.
107 * if=pflash, if=mtd, if=sd, if=xen are not yet available with -device
109 For USB devices, the old way is actually different:
111 -usbdevice disk:format=FMT:FILENAME
113 Provides much less control than -drive's HOST-OPTS... The new way
116 -device usb-storage,drive=DRIVE-ID
118 === Character Devices ===
120 A QEMU character device has a host and a guest part.
122 The old ways to define character devices define host and guest part
125 The new way keeps the parts separate: you create the host part with
126 -chardev, and the guest device with -device.
128 The various old ways to define a character device are all of the
131 -FOO FOO-OPTS...,LEGACY-CHARDEV
133 where FOO-OPTS... is specific to -FOO, and the host part
134 LEGACY-CHARDEV is the same everywhere.
136 In the new way, this becomes
138 -chardev HOST-OPTS...,id=CHR-ID
139 -device DEVNAME,chardev=CHR-ID,DEV-OPTS...
141 The appropriate DEVNAME depends on the machine type. For type "pc":
143 * -serial becomes -device isa-serial,iobase=IOADDR,irq=IRQ,index=IDX
145 This lets you control I/O ports and IRQs.
147 * -parallel becomes -device isa-parallel,iobase=IOADDR,irq=IRQ,index=IDX
149 This lets you control I/O ports and IRQs.
151 * -usbdevice serial:vendorid=VID,productid=PRID becomes
152 -device usb-serial,vendorid=VID,productid=PRID
154 * -usbdevice braille doesn't support LEGACY-CHARDEV syntax. It always
155 uses "braille". With -device, this useful default is gone, so you
156 have to use something like
158 -device usb-braille,chardev=braille,vendorid=VID,productid=PRID
159 -chardev braille,id=braille
161 * -virtioconsole is still being worked on
163 LEGACY-CHARDEV translates to -chardev HOST-OPTS... as follows:
165 * null becomes -chardev null
167 * pty, msmouse, braille, stdio likewise
169 * vc:WIDTHxHEIGHT becomes -chardev vc,width=WIDTH,height=HEIGHT
171 * vc:<COLS>Cx<ROWS>C becomes -chardev vc,cols=<COLS>,rows=<ROWS>
173 * con: becomes -chardev console
175 * COM<NUM> becomes -chardev serial,path=<NUM>
177 * file:FNAME becomes -chardev file,path=FNAME
179 * pipe:FNAME becomes -chardev pipe,path=FNAME
181 * tcp:HOST:PORT,OPTS... becomes -chardev socket,host=HOST,port=PORT,OPTS...
183 * telnet:HOST:PORT,OPTS... becomes
184 -chardev socket,host=HOST,port=PORT,OPTS...,telnet=on
186 * udp:HOST:PORT@LOCALADDR:LOCALPORT becomes
187 -chardev udp,host=HOST,port=PORT,localaddr=LOCALADDR,localport=LOCALPORT
189 * unix:FNAME becomes -chardev socket,path=FNAME
191 * /dev/parportN becomes -chardev parport,file=/dev/parportN
195 * Any other /dev/FNAME becomes -chardev tty,path=/dev/FNAME
197 * mon:LEGACY-CHARDEV is special: it multiplexes the monitor onto the
198 character device defined by LEGACY-CHARDEV. -chardev provides more
199 general multiplexing instead: you can connect up to four users to a
200 single host part. You need to pass mux=on to -chardev to enable
201 switching the input focus.
203 QEMU uses LEGACY-CHARDEV syntax not just to set up guest devices, but
204 also in various other places such as -monitor or -net
205 user,guestfwd=... You can use chardev:CHR-ID in place of
206 LEGACY-CHARDEV to refer to a host part defined with -chardev.
208 === Network Devices ===
210 A QEMU network device (NIC) has a host and a guest part.
212 The old ways to define NICs define host and guest part together. It
215 -net nic,vlan=VLAN,macaddr=MACADDR,model=MODEL,name=ID,addr=STR,vectors=V
217 Except for USB it looks like this:
219 -usbdevice net:vlan=VLAN,macaddr=MACADDR,name=ID,addr=STR,vectors=V
221 The new way keeps the parts separate: you create the host part with
222 -netdev, and the guest device with -device, like this:
224 -netdev type=TYPE,id=NET-ID
225 -device DEVNAME,netdev=NET-ID,mac=MACADDR,DEV-OPTS...
227 Unlike the old way, this creates just a network device, not a VLAN.
228 If you really want a VLAN, create it the usual way, then create the
229 guest device like this:
231 -device DEVNAME,vlan=VLAN,mac=MACADDR,DEV-OPTS...
233 DEVNAME equals MODEL, except for virtio you have to name the virtio
234 device appropriate for the bus (virtio-net-pci for PCI), and for USB
235 NIC you have to use usb-net.
237 The old name=ID parameter becomes the usual id=ID with -device.
239 For PCI devices, you can add bus=PCI-BUS,addr=DEVFN to control the PCI
240 device address, as usual. The old -net nic provides parameter addr
241 for that, it is silently ignored when the NIC is not a PCI device.
243 -net nic accepts vectors=V for all models, but it's silently ignored
244 except for virtio-net-pci (model=virtio). With -device, only devices
245 that support it accept it.
247 Not all devices are available with -device at this time. All PCI
248 devices and ne2k_isa are.
250 Some PCI devices aren't available with -net nic, e.g. i82558a.
252 Bug: usb-net does not work, yet. Patch posted.
254 === Graphics Devices ===
256 Host and guest part of graphics devices have always been separate.
258 The old way to define the guest graphics device is -vga VGA.
260 The new way is -device. Map from -vga argument to -device:
263 cirrus -device cirrus-vga
264 vmware -device vmware-svga
265 xenfb not yet available with -device
267 As for all PCI devices, you can add bus=PCI-BUS,addr=DEVFN to control
268 the PCI device address.
270 -device VGA supports properties bios-offset and bios-size, but they
271 aren't used with machine type "pc".
273 Bug: -device cirrus-vga and -device vmware-svga require -nodefaults.
275 Bug: the new way requires PCI; ISA VGA is not yet available with
278 Bug: the new way doesn't work for machine type "pc", because it
279 violates obscure device initialization ordering constraints.
281 === Audio Devices ===
283 Host and guest part of audio devices have always been separate.
285 The old way to define guest audio devices is -soundhw C1,...
287 The new way is to define each guest audio device separately with
290 Map from -soundhw sound card name to -device:
293 cs4231a -device cs4231a,iobase=IOADDR,irq=IRQ,dma=DMA
294 es1370 -device ES1370
295 gus -device gus,iobase=IOADDR,irq=IRQ,dma=DMA,freq=F
296 sb16 -device sb16,iobase=IOADDR,irq=IRQ,dma=DMA,dma16=DMA16,version=V
297 adlib not yet available with -device
298 pcspk not yet available with -device
300 For PCI devices, you can add bus=PCI-BUS,addr=DEVFN to control the PCI
301 device address, as usual.
305 The old way to define a virtual USB device is -usbdevice DRIVER:OPTS...
307 The new way is -device DEVNAME,DEV-OPTS... Details depend on DRIVER:
309 * mouse -device usb-mouse
310 * tablet -device usb-tablet
311 * keyboard -device usb-kdb
312 * wacom-tablet -device usb-wacom-tablet
313 * host:... See "Host Device Assignment"
314 * disk:... See "Block Devices"
315 * serial:... See "Character Devices"
316 * braille See "Character Devices"
317 * net:... See "Network Devices"
318 * bt:... not yet available with -device
320 === Watchdog Devices ===
322 Host and guest part of watchdog devices have always been separate.
324 The old way to define a guest watchdog device is -watchdog DEVNAME.
325 The new way is -device DEVNAME. For PCI devices, you can add
326 bus=PCI-BUS,addr=DEVFN to control the PCI device address, as usual.
328 === Host Device Assignment ===
330 QEMU supports assigning host PCI devices (qemu-kvm only at this time)
331 and host USB devices.
333 The old way to assign a host PCI device is
335 -pcidevice host=ADDR,dma=none,id=ID
339 -device pci-assign,host=ADDR,iommu=IOMMU,id=ID
341 The old dma=none becomes iommu=0 with -device.
343 The old way to assign a host USB device is
345 -usbdevice host:auto:BUS.ADDR:VID:PRID
347 where any of BUS, ADDR, VID, PRID can be the wildcard *.
351 -device usb-host,hostbus=BUS,hostaddr=ADDR,vendorid=VID,productid=PRID
353 where left out or zero BUS, ADDR, VID, PRID serve as wildcard.