1 <?xml version=
"1.0" encoding=
"UTF-8"?>
3 <html xmlns=
"http://www.w3.org/1999/xhtml">
5 <h1>PCI topology and hotplug
</h1>
10 Perhaps surprisingly, most libvirt guests support only limited PCI
11 device hotplug out of the box, or even none at all.
14 The reason for this apparent limitation is the fact that each
15 hotplugged PCI device might require additional PCI controllers to
16 be added to the guest. Since most PCI controllers can't be
17 hotplugged, they need to be added before the guest is started;
18 however, libvirt has no way of knowing in advance how many devices
19 will be hotplugged during the guest's lifetime, thus making it
20 impossible to automatically provide the right amount of PCI
21 controllers: any arbitrary number would end up being too big
22 for some users, and too small for others.
25 Ultimately, the user is the only one who knows how much the guest
26 will need to grow dynamically, so the responsibility of planning
27 a suitable PCI topology in advance falls on them.
30 This document aims at providing all the information needed to
31 successfully plan the PCI topology of a guest. Note that the
32 details can vary a lot between architectures and even machine
33 types, hence the way it's organized.
36 <h2><a id=
"x86_64">x86_64 architecture
</a></h2>
38 <h3><a id=
"x86_64-q35">q35 machine type
</a></h3>
41 This is a PCI Express native machine type. The default PCI topology
46 <controller type='pci' index='
0' model='pcie-root'/
>
47 <controller type='pci' index='
1' model='pcie-root-port'
>
48 <model name='pcie-root-port'/
>
49 <target chassis='
1' port='
0x10'/
>
50 <address type='pci' domain='
0x0000' bus='
0x00' slot='
0x01' function='
0x0'/
>
51 </controller
></pre>
54 and supports hotplugging a single PCI Express device, either
55 emulated or assigned from the host.
58 If you have a very specific use case, such as the appliances
59 used by
<a href=
"http://libguestfs.org/">libguestfs
</a> behind
60 the scenes to access disk images, and this automatically-added
61 <code>pcie-root-port
</code> controller ends up being a nuisance,
62 you can prevent libvirt from adding it by manually managing PCI
63 controllers and addresses according to your needs.
66 Slots on the
<code>pcie-root
</code> controller do not support
67 hotplug, so the device will be hotplugged into the
68 <code>pcie-root-port
</code> controller. If you plan to hotplug
69 more than a single PCI Express device, you should add a suitable
70 number of
<code>pcie-root-port
</code> controllers when defining
71 the guest: for example, add
75 <controller type='pci' model='pcie-root'/
>
76 <controller type='pci' model='pcie-root-port'/
>
77 <controller type='pci' model='pcie-root-port'/
>
78 <controller type='pci' model='pcie-root-port'/
></pre>
81 if you expect to hotplug up to three PCI Express devices,
82 either emulated or assigned from the host. That's all the
83 information you need to provide: libvirt will fill in the
84 remaining details automatically. Note that you need to add
85 the
<code>pcie-root
</code> controller along with the
86 <code>pcie-root-port
</code> controllers or you will get an
90 Note that if you're adding PCI controllers to a guest and at
91 the same time you're also adding PCI devices, some of the
92 controllers will be used for the newly-added devices and won't
93 be available for hotplug once the guest has been started.
96 If you expect to hotplug legacy PCI devices, then you will need
97 specialized controllers, since all those mentioned above are
98 intended for PCI Express devices only: add
102 <controller type='pci' model='pcie-to-pci-bridge'/
></pre>
105 and you'll be able to hotplug up to
31 legacy PCI devices,
106 either emulated or assigned from the host, in the slots
107 from
0x01 to
0x1f of the
<code>pcie-to-pci-bridge
</code> controller.
110 <h3><a id=
"x86_64-i440fx">i440fx (pc) machine type
</a></h3>
113 This is a legacy PCI native machine type. The default PCI
118 <controller type='pci' index='
0' model='pci-root'/
></pre>
121 where each of the
31 slots (from
0x01 to
0x1f) on the
122 <code>pci-root
</code> controller is hotplug capable and
123 can accept a legacy PCI device, either emulated or
124 assigned from the guest.
127 <h2><a id=
"ppc64">ppc64 architecture
</a></h2>
129 <h3><a id=
"ppc64-pseries">pseries machine type
</a></h3>
132 The default PCI topology for the
<code>pseries
</code> machine
137 <controller type='pci' index='
0' model='pci-root'
>
138 <model name='spapr-pci-host-bridge'/
>
139 <target index='
0'/
>
140 </controller
></pre>
143 The
31 slots, from
0x01 to
0x1f, on a
<code>pci-root
</code>
144 controller are all hotplug capable and, despite the name
145 suggesting otherwise, starting with QEMU
2.9 all of them
146 can accept PCI Express devices in addition to legacy PCI
147 devices; however, libvirt will only place emulated devices
148 on the default
<code>pci-root
</code> controller.
151 In order to take advantage of improved error reporting and
152 recovering capabilities, PCI devices assigned from the
153 host need to be isolated by placing each on a separate
154 <code>pci-root
</code> controller, which has to be prepared
155 in advance for hotplug to work: for example, add
159 <controller type='pci' model='pci-root'/
>
160 <controller type='pci' model='pci-root'/
>
161 <controller type='pci' model='pci-root'/
></pre>
164 if you expect to hotplug up to three PCI devices assigned
168 <h2><a id=
"aarch64">aarch64 architecture
</a></h2>
170 <h3><a id=
"aarch64-virt">mach-virt (virt) machine type
</a></h3>
173 This machine type mostly behaves the same as the
174 <a href=
"#x86_64-q35">q35 machine type
</a>, so you can just
175 refer to that section for information.
178 The only difference worth mentioning is that using legacy
179 PCI for
<code>mach-virt
</code> guests is extremely uncommon,
180 so you'll probably never need to add controllers other than
181 <code>pcie-root-port
</code>.