<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linux-kvm.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Avishay</id>
	<title>KVM - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://linux-kvm.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Avishay"/>
	<link rel="alternate" type="text/html" href="https://linux-kvm.org/page/Special:Contributions/Avishay"/>
	<updated>2026-05-09T08:25:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Hotadd_pci_devices&amp;diff=2596</id>
		<title>Hotadd pci devices</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Hotadd_pci_devices&amp;diff=2596"/>
		<updated>2009-10-04T07:31:35Z</updated>

		<summary type="html">&lt;p&gt;Avishay: Changed bus 0 to &amp;#039;auto&amp;#039; in examples: 0 causes segfault (https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/419590)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using PCI Hotplug Support ==&lt;br /&gt;
PCI Hotplug support is now available in kvm.git, here is how to use it.&lt;br /&gt;
&lt;br /&gt;
== Install PCI Hotplug drivers in the guest (Linux) ==&lt;br /&gt;
I loaded the following modules to get pci hotplug working:&lt;br /&gt;
* acpiphp                                               &lt;br /&gt;
* pci_hotplug                                           &lt;br /&gt;
&lt;br /&gt;
You can either add these to your distro&#039;s module list to load on boot, or run a command like this.&lt;br /&gt;
&lt;br /&gt;
 for m in acpiphp pci_hotplug; do sudo modprobe ${m}; done&lt;br /&gt;
&lt;br /&gt;
== Use QEMU monitor to hot add devices ==&lt;br /&gt;
&lt;br /&gt;
The QEMU monitor has a new command, &#039;&#039;&#039;pci_add&#039;&#039;&#039;, which is used to hotadd the pci devices.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 QEMU 0.9.1 monitor - type &#039;help&#039; for more information&lt;br /&gt;
 (qemu) help pci_add &lt;br /&gt;
 pci_add bus nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]... -- hot-add PCI device&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Add a NIC ===&lt;br /&gt;
The following command in the QEMU monitor hot-adds a nic to the guest.&lt;br /&gt;
* &#039;&#039;&#039;pci_add auto nic model=e1000&#039;&#039;&#039;                                   &lt;br /&gt;
You can replace &#039;&#039;&#039;model=e1000&#039;&#039;&#039; with either &#039;&#039;&#039;model=rtl8139&#039;&#039;&#039;, &#039;&#039;&#039;model=virtio&#039;&#039;&#039;, or &#039;&#039;&#039;model=ne2k_pci&#039;&#039;&#039;. Note that &#039;&#039;&#039;model=ne2000&#039;&#039;&#039; isn&#039;t pci-based but rather ISA-based and cannot be used for hotplug. &lt;br /&gt;
                                   &lt;br /&gt;
 (qemu) pci_add auto nic  model=e1000 WARNING: PCI region size must be pow2 type=0x0, size=0x60000  OK bus 0, slot 5, function 0 (devfn 40)&lt;br /&gt;
                                                                                                &lt;br /&gt;
&lt;br /&gt;
In the guest we can check if the device was added by looking at dmesg.&lt;br /&gt;
 [   91.808265] acpiphp: Slot [30] registered                          &lt;br /&gt;
 [   91.808276] acpiphp: Slot [31] registered                          &lt;br /&gt;
 [  110.828130] PCI: Ignore bogus resource 6 [0:0] of 0000:00:02.0     &lt;br /&gt;
 [  110.828333] decode_hpp: Could not get hotplug parameters. Use defaults&lt;br /&gt;
 [  110.903259] Intel(R) PRO/1000 Network Driver - version 7.3.20-k2-NAPI &lt;br /&gt;
 [  110.903264] Copyright (c) 1999-2006 Intel Corporation.                &lt;br /&gt;
 [  110.903489] ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 10         &lt;br /&gt;
 [  110.903492] ACPI: PCI Interrupt 0000:00:05.0[A] -&amp;gt; Link [LNKA] -&amp;gt; GSI 10 (level, high) -&amp;gt; IRQ 10&lt;br /&gt;
 [  111.238713] e1000: 0000:00:05.0: e1000_probe: (PCI:33MHz:32-bit) 52:54:00:12:34:57              &lt;br /&gt;
 [  111.292550] e1000: eth1: e1000_probe: Intel(R) PRO/1000 Network Connection                      &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Add a disk ===&lt;br /&gt;
The following command in the QEMU monitor will add a scsi disk to the guest:&lt;br /&gt;
  * &#039;&#039;&#039;pci_add auto storage file=/home/rharper/work/images/empty.img,if=scsi&#039;&#039;&#039;&lt;br /&gt;
You can replace &#039;&#039;&#039;if=scsi&#039;&#039;&#039; with &#039;&#039;&#039;if=virtio&#039;&#039;&#039;, but IDE is not hotpluggable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 QEMU 0.9.1 monitor - type &#039;help&#039; for more information&lt;br /&gt;
(qemu) pci_add auto storage file=/home/rharper/work/images/empty.img,if=scsi&lt;br /&gt;
 OK bus 0, slot 5, function 0 (devfn 40)                                  &lt;br /&gt;
                                                                  &lt;br /&gt;
In the guest we see via dmesg that the device was added.                 &lt;br /&gt;
&lt;br /&gt;
 [  150.581752] PCI: Enabling device 0000:00:05.0 (0000 -&amp;gt; 0003)&lt;br /&gt;
 [  150.582634] ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 10&lt;br /&gt;
 [  150.582637] ACPI: PCI Interrupt 0000:00:05.0[A] -&amp;gt; Link [LNKA] -&amp;gt; GSI 10 (level, high) -&amp;gt; IRQ 10&lt;br /&gt;
 [  150.585099] sym0: &amp;lt;895a&amp;gt; rev 0x0 at pci 0000:00:05.0 irq 10&lt;br /&gt;
 [  150.594628] sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking&lt;br /&gt;
 [  150.607861] sym0: SCSI BUS has been reset.&lt;br /&gt;
 [  150.607883] scsi2 : sym-2.2.3&lt;br /&gt;
 [  153.608433] scsi 2:0:0:0: Direct-Access     QEMU     QEMU HARDDISK    0.9. PQ: 0 ANSI: 3                                                     &lt;br /&gt;
 [  153.608462]  target2:0:0: tagged command queuingenabled, command queue depth 16. &lt;br /&gt;
 [  153.608484]  target2:0:0: Beginning Domain Validation&lt;br /&gt;
 [  153.609517]  target2:0:0: Domain Validation skipping write tests&lt;br /&gt;
 [  153.609522]  target2:0:0: Ending Domain Validation&lt;br /&gt;
 [  153.618880] scsi 2:0:0:0: Attached scsi generic sg1 type 0&lt;br /&gt;
 [  153.749967] Driver &#039;sd&#039; needs updating - please use bus_type methods&lt;br /&gt;
 [  153.750204] sd 2:0:0:0: [sda] 20971520 512-byte hardware sectors (10737 MB)&lt;br /&gt;
 [  153.750253] sd 2:0:0:0: [sda] Write Protect is off&lt;br /&gt;
 [  153.750255] sd 2:0:0:0: [sda] Mode Sense: 14 00 00 00&lt;br /&gt;
 [  153.750354] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn&#039;t support DPO or FUA&lt;br /&gt;
 [  153.750478] sd 2:0:0:0: [sda] 20971520 512-byte hardware sectors (10737 MB)&lt;br /&gt;
 [  153.750253] sd 2:0:0:0: [sda] Write Protect is off&lt;br /&gt;
 [  153.750255] sd 2:0:0:0: [sda] Mode Sense: 14 00 00 00&lt;br /&gt;
 [  153.750354] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn&#039;t support DPO or FUA&lt;br /&gt;
 [  153.750478] sd 2:0:0:0: [sda] 20971520 512-byte hardware sectors (10737 MB)&lt;br /&gt;
 [  153.750534] sd 2:0:0:0: [sda] Write Protect is off&lt;br /&gt;
 [  153.750536] sd 2:0:0:0: [sda] Mode Sense: 14 00 00 00&lt;br /&gt;
 [  153.750634] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn&#039;t support DPO or FUA&lt;br /&gt;
 [  153.750637]  sda: unknown partition table&lt;br /&gt;
 [  153.759275] sd 2:0:0:0: [sda] Attached SCSI disk&lt;/div&gt;</summary>
		<author><name>Avishay</name></author>
	</entry>
</feed>