* [patch 01/23] QEMU/KVM: add PCI IRQ routing information up to slot 32
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-05 5:40 ` Avi Kivity
2008-03-04 18:34 ` [patch 02/23] QEMU/KVM: add devices to represent PCI slots with _EJ0 method Marcelo Tosatti
` (22 subsequent siblings)
23 siblings, 1 reply; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: devicehotplug.0 --]
[-- Type: text/plain, Size: 7155 bytes --]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/bios/acpi-dsdt.dsl
===================================================================
--- kvm-userspace.hotplug.orig/bios/acpi-dsdt.dsl
+++ kvm-userspace.hotplug/bios/acpi-dsdt.dsl
@@ -249,6 +249,162 @@ DefinitionBlock (
Package() {0x0005ffff, 1, LNKB, 0},
Package() {0x0005ffff, 2, LNKC, 0},
Package() {0x0005ffff, 3, LNKD, 0},
+
+ // PCI Slot 6
+ Package() {0x0006ffff, 0, LNKB, 0},
+ Package() {0x0006ffff, 1, LNKC, 0},
+ Package() {0x0006ffff, 2, LNKD, 0},
+ Package() {0x0006ffff, 3, LNKA, 0},
+
+ // PCI Slot 7
+ Package() {0x0007ffff, 0, LNKC, 0},
+ Package() {0x0007ffff, 1, LNKD, 0},
+ Package() {0x0007ffff, 2, LNKA, 0},
+ Package() {0x0007ffff, 3, LNKB, 0},
+
+ // PCI Slot 8
+ Package() {0x0008ffff, 0, LNKD, 0},
+ Package() {0x0008ffff, 1, LNKA, 0},
+ Package() {0x0008ffff, 2, LNKB, 0},
+ Package() {0x0008ffff, 3, LNKC, 0},
+
+ // PCI Slot 9
+ Package() {0x0009ffff, 0, LNKA, 0},
+ Package() {0x0009ffff, 1, LNKB, 0},
+ Package() {0x0009ffff, 2, LNKC, 0},
+ Package() {0x0009ffff, 3, LNKD, 0},
+
+ // PCI Slot 10
+ Package() {0x000affff, 0, LNKB, 0},
+ Package() {0x000affff, 1, LNKC, 0},
+ Package() {0x000affff, 2, LNKD, 0},
+ Package() {0x000affff, 3, LNKA, 0},
+
+ // PCI Slot 11
+ Package() {0x000bffff, 0, LNKC, 0},
+ Package() {0x000bffff, 1, LNKD, 0},
+ Package() {0x000bffff, 2, LNKA, 0},
+ Package() {0x000bffff, 3, LNKB, 0},
+
+ // PCI Slot 12
+ Package() {0x000cffff, 0, LNKD, 0},
+ Package() {0x000cffff, 1, LNKA, 0},
+ Package() {0x000cffff, 2, LNKB, 0},
+ Package() {0x000cffff, 3, LNKC, 0},
+
+ // PCI Slot 13
+ Package() {0x000dffff, 0, LNKA, 0},
+ Package() {0x000dffff, 1, LNKB, 0},
+ Package() {0x000dffff, 2, LNKC, 0},
+ Package() {0x000dffff, 3, LNKD, 0},
+
+ // PCI Slot 14
+ Package() {0x000effff, 0, LNKB, 0},
+ Package() {0x000effff, 1, LNKC, 0},
+ Package() {0x000effff, 2, LNKD, 0},
+ Package() {0x000effff, 3, LNKA, 0},
+
+ // PCI Slot 15
+ Package() {0x000fffff, 0, LNKC, 0},
+ Package() {0x000fffff, 1, LNKD, 0},
+ Package() {0x000fffff, 2, LNKA, 0},
+ Package() {0x000fffff, 3, LNKB, 0},
+
+ // PCI Slot 16
+ Package() {0x0010ffff, 0, LNKD, 0},
+ Package() {0x0010ffff, 1, LNKA, 0},
+ Package() {0x0010ffff, 2, LNKB, 0},
+ Package() {0x0010ffff, 3, LNKC, 0},
+
+ // PCI Slot 17
+ Package() {0x0011ffff, 0, LNKA, 0},
+ Package() {0x0011ffff, 1, LNKB, 0},
+ Package() {0x0011ffff, 2, LNKC, 0},
+ Package() {0x0011ffff, 3, LNKD, 0},
+
+ // PCI Slot 18
+ Package() {0x0012ffff, 0, LNKB, 0},
+ Package() {0x0012ffff, 1, LNKC, 0},
+ Package() {0x0012ffff, 2, LNKD, 0},
+ Package() {0x0012ffff, 3, LNKA, 0},
+
+ // PCI Slot 19
+ Package() {0x0013ffff, 0, LNKC, 0},
+ Package() {0x0013ffff, 1, LNKD, 0},
+ Package() {0x0013ffff, 2, LNKA, 0},
+ Package() {0x0013ffff, 3, LNKB, 0},
+
+ // PCI Slot 20
+ Package() {0x0014ffff, 0, LNKD, 0},
+ Package() {0x0014ffff, 1, LNKA, 0},
+ Package() {0x0014ffff, 2, LNKB, 0},
+ Package() {0x0014ffff, 3, LNKC, 0},
+
+ // PCI Slot 21
+ Package() {0x0015ffff, 0, LNKA, 0},
+ Package() {0x0015ffff, 1, LNKB, 0},
+ Package() {0x0015ffff, 2, LNKC, 0},
+ Package() {0x0015ffff, 3, LNKD, 0},
+
+ // PCI Slot 22
+ Package() {0x0016ffff, 0, LNKB, 0},
+ Package() {0x0016ffff, 1, LNKC, 0},
+ Package() {0x0016ffff, 2, LNKD, 0},
+ Package() {0x0016ffff, 3, LNKA, 0},
+
+ // PCI Slot 23
+ Package() {0x0017ffff, 0, LNKC, 0},
+ Package() {0x0017ffff, 1, LNKD, 0},
+ Package() {0x0017ffff, 2, LNKA, 0},
+ Package() {0x0017ffff, 3, LNKB, 0},
+
+ // PCI Slot 24
+ Package() {0x0018ffff, 0, LNKD, 0},
+ Package() {0x0018ffff, 1, LNKA, 0},
+ Package() {0x0018ffff, 2, LNKB, 0},
+ Package() {0x0018ffff, 3, LNKC, 0},
+
+ // PCI Slot 25
+ Package() {0x0019ffff, 0, LNKA, 0},
+ Package() {0x0019ffff, 1, LNKB, 0},
+ Package() {0x0019ffff, 2, LNKC, 0},
+ Package() {0x0019ffff, 3, LNKD, 0},
+
+ // PCI Slot 26
+ Package() {0x001affff, 0, LNKB, 0},
+ Package() {0x001affff, 1, LNKC, 0},
+ Package() {0x001affff, 2, LNKD, 0},
+ Package() {0x001affff, 3, LNKA, 0},
+
+ // PCI Slot 27
+ Package() {0x001bffff, 0, LNKC, 0},
+ Package() {0x001bffff, 1, LNKD, 0},
+ Package() {0x001bffff, 2, LNKA, 0},
+ Package() {0x001bffff, 3, LNKB, 0},
+
+ // PCI Slot 28
+ Package() {0x001cffff, 0, LNKD, 0},
+ Package() {0x001cffff, 1, LNKA, 0},
+ Package() {0x001cffff, 2, LNKB, 0},
+ Package() {0x001cffff, 3, LNKC, 0},
+
+ // PCI Slot 29
+ Package() {0x001dffff, 0, LNKA, 0},
+ Package() {0x001dffff, 1, LNKB, 0},
+ Package() {0x001dffff, 2, LNKC, 0},
+ Package() {0x001dffff, 3, LNKD, 0},
+
+ // PCI Slot 30
+ Package() {0x001effff, 0, LNKB, 0},
+ Package() {0x001effff, 1, LNKC, 0},
+ Package() {0x001effff, 2, LNKD, 0},
+ Package() {0x001effff, 3, LNKA, 0},
+
+ // PCI Slot 31
+ Package() {0x001fffff, 0, LNKC, 0},
+ Package() {0x001fffff, 1, LNKD, 0},
+ Package() {0x001fffff, 2, LNKA, 0},
+ Package() {0x001fffff, 2, LNKB, 0},
})
Method (_CRS, 0, NotSerialized)
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [patch 01/23] QEMU/KVM: add PCI IRQ routing information up to slot 32
2008-03-04 18:34 ` [patch 01/23] QEMU/KVM: add PCI IRQ routing information up to slot 32 Marcelo Tosatti
@ 2008-03-05 5:40 ` Avi Kivity
0 siblings, 0 replies; 39+ messages in thread
From: Avi Kivity @ 2008-03-05 5:40 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm-devel, Glauber Costa
Marcelo Tosatti wrote:
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> Index: kvm-userspace.hotplug/bios/acpi-dsdt.dsl
> ===================================================================
> --- kvm-userspace.hotplug.orig/bios/acpi-dsdt.dsl
> +++ kvm-userspace.hotplug/bios/acpi-dsdt.dsl
> @@ -249,6 +249,162 @@ DefinitionBlock (
> Package() {0x0005ffff, 1, LNKB, 0},
> Package() {0x0005ffff, 2, LNKC, 0},
> Package() {0x0005ffff, 3, LNKD, 0},
> +
> + // PCI Slot 6
> + Package() {0x0006ffff, 0, LNKB, 0},
> + Package() {0x0006ffff, 1, LNKC, 0},
> + Package() {0x0006ffff, 2, LNKD, 0},
> + Package() {0x0006ffff, 3, LNKA, 0},
>
This is already in kvm-userspace.git.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread
* [patch 02/23] QEMU/KVM: add devices to represent PCI slots with _EJ0 method
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
2008-03-04 18:34 ` [patch 01/23] QEMU/KVM: add PCI IRQ routing information up to slot 32 Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 03/23] QEMU/KVM: add OperationRegion and GPE handler for add/removal notification Marcelo Tosatti
` (21 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: devicehotplug.1 --]
[-- Type: text/plain, Size: 5662 bytes --]
Presence of _EJ0 method indicates that slots are hot-pluggable.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/bios/acpi-dsdt.dsl
===================================================================
--- kvm-userspace.hotplug.orig/bios/acpi-dsdt.dsl
+++ kvm-userspace.hotplug/bios/acpi-dsdt.dsl
@@ -407,6 +407,161 @@ DefinitionBlock (
Package() {0x001fffff, 2, LNKB, 0},
})
+ Device (S1) { // Slot 1
+ Name (_ADR, 0x00010000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S2) { // Slot 2
+ Name (_ADR, 0x00020000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S3) { // Slot 3
+ Name (_ADR, 0x00030000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S4) { // Slot 4
+ Name (_ADR, 0x00040000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S5) { // Slot 5
+ Name (_ADR, 0x00050000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S6) { // Slot 6
+ Name (_ADR, 0x00060000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S7) { // Slot 7
+ Name (_ADR, 0x00070000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S8) { // Slot 8
+ Name (_ADR, 0x00080000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S9) { // Slot 9
+ Name (_ADR, 0x00090000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S10) { // Slot 10
+ Name (_ADR, 0x000A0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S11) { // Slot 11
+ Name (_ADR, 0x000B0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S12) { // Slot 12
+ Name (_ADR, 0x000C0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S13) { // Slot 13
+ Name (_ADR, 0x000D0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S14) { // Slot 14
+ Name (_ADR, 0x000E0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S15) { // Slot 15
+ Name (_ADR, 0x000F0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S16) { // Slot 16
+ Name (_ADR, 0x00100000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S17) { // Slot 17
+ Name (_ADR, 0x00110000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S18) { // Slot 18
+ Name (_ADR, 0x00120000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S19) { // Slot 19
+ Name (_ADR, 0x00130000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S20) { // Slot 20
+ Name (_ADR, 0x00140000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S21) { // Slot 21
+ Name (_ADR, 0x00150000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S22) { // Slot 22
+ Name (_ADR, 0x00160000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S23) { // Slot 23
+ Name (_ADR, 0x00170000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S24) { // Slot 24
+ Name (_ADR, 0x00180000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S25) { // Slot 25
+ Name (_ADR, 0x00190000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S26) { // Slot 26
+ Name (_ADR, 0x001A0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S27) { // Slot 27
+ Name (_ADR, 0x001B0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S28) { // Slot 28
+ Name (_ADR, 0x001C0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S29) { // Slot 29
+ Name (_ADR, 0x001D0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S30) { // Slot 30
+ Name (_ADR, 0x001E0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
+ Device (S31) { // Slot 31
+ Name (_ADR, 0x001F0000)
+ Method (_EJ0,1) { Return (0x0) }
+ }
+
Method (_CRS, 0, NotSerialized)
{
Name (MEMP, ResourceTemplate ()
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 03/23] QEMU/KVM: add OperationRegion and GPE handler for add/removal notification
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
2008-03-04 18:34 ` [patch 01/23] QEMU/KVM: add PCI IRQ routing information up to slot 32 Marcelo Tosatti
2008-03-04 18:34 ` [patch 02/23] QEMU/KVM: add devices to represent PCI slots with _EJ0 method Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 04/23] QEMU/KVM: add pci_find_bus Marcelo Tosatti
` (20 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: devicehotplug.2 --]
[-- Type: text/plain, Size: 7955 bytes --]
Use GPE _L01 to notify OSPM.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/bios/acpi-dsdt.dsl
===================================================================
--- kvm-userspace.hotplug.orig/bios/acpi-dsdt.dsl
+++ kvm-userspace.hotplug/bios/acpi-dsdt.dsl
@@ -407,6 +407,13 @@ DefinitionBlock (
Package() {0x001fffff, 2, LNKB, 0},
})
+ OperationRegion(PCST, SystemIO, 0xae00, 0x08)
+ Field (PCST, DWordAcc, NoLock, WriteAsZeros)
+ {
+ PCIU, 32,
+ PCID, 32,
+ }
+
Device (S1) { // Slot 1
Name (_ADR, 0x00010000)
Method (_EJ0,1) { Return (0x0) }
@@ -1142,6 +1149,256 @@ DefinitionBlock (
Return(0x01)
}
Method(_L01) {
+ /* Up status */
+ If (And(\_SB.PCI0.PCIU, 0x2)) {
+ Notify(\_SB.PCI0.S1, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x4)) {
+ Notify(\_SB.PCI0.S2, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x8)) {
+ Notify(\_SB.PCI0.S3, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x10)) {
+ Notify(\_SB.PCI0.S4, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x20)) {
+ Notify(\_SB.PCI0.S5, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x40)) {
+ Notify(\_SB.PCI0.S6, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x80)) {
+ Notify(\_SB.PCI0.S7, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x0100)) {
+ Notify(\_SB.PCI0.S8, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x0200)) {
+ Notify(\_SB.PCI0.S9, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x0400)) {
+ Notify(\_SB.PCI0.S10, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x0800)) {
+ Notify(\_SB.PCI0.S11, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x1000)) {
+ Notify(\_SB.PCI0.S12, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x2000)) {
+ Notify(\_SB.PCI0.S13, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x4000)) {
+ Notify(\_SB.PCI0.S14, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x8000)) {
+ Notify(\_SB.PCI0.S15, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x10000)) {
+ Notify(\_SB.PCI0.S16, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x20000)) {
+ Notify(\_SB.PCI0.S17, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x40000)) {
+ Notify(\_SB.PCI0.S18, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x80000)) {
+ Notify(\_SB.PCI0.S19, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x100000)) {
+ Notify(\_SB.PCI0.S20, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x200000)) {
+ Notify(\_SB.PCI0.S21, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x400000)) {
+ Notify(\_SB.PCI0.S22, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x800000)) {
+ Notify(\_SB.PCI0.S23, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x1000000)) {
+ Notify(\_SB.PCI0.S24, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x2000000)) {
+ Notify(\_SB.PCI0.S25, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x4000000)) {
+ Notify(\_SB.PCI0.S26, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x8000000)) {
+ Notify(\_SB.PCI0.S27, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x10000000)) {
+ Notify(\_SB.PCI0.S28, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x20000000)) {
+ Notify(\_SB.PCI0.S29, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x40000000)) {
+ Notify(\_SB.PCI0.S30, 0x1)
+ }
+
+ If (And(\_SB.PCI0.PCIU, 0x80000000)) {
+ Notify(\_SB.PCI0.S31, 0x1)
+ }
+
+ /* Down status */
+ If (And(\_SB.PCI0.PCID, 0x2)) {
+ Notify(\_SB.PCI0.S1, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x4)) {
+ Notify(\_SB.PCI0.S2, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x8)) {
+ Notify(\_SB.PCI0.S3, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x10)) {
+ Notify(\_SB.PCI0.S4, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x20)) {
+ Notify(\_SB.PCI0.S5, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x40)) {
+ Notify(\_SB.PCI0.S6, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x80)) {
+ Notify(\_SB.PCI0.S7, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x0100)) {
+ Notify(\_SB.PCI0.S8, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x0200)) {
+ Notify(\_SB.PCI0.S9, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x0400)) {
+ Notify(\_SB.PCI0.S10, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x0800)) {
+ Notify(\_SB.PCI0.S11, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x1000)) {
+ Notify(\_SB.PCI0.S12, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x2000)) {
+ Notify(\_SB.PCI0.S13, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x4000)) {
+ Notify(\_SB.PCI0.S14, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x8000)) {
+ Notify(\_SB.PCI0.S15, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x10000)) {
+ Notify(\_SB.PCI0.S16, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x20000)) {
+ Notify(\_SB.PCI0.S17, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x40000)) {
+ Notify(\_SB.PCI0.S18, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x80000)) {
+ Notify(\_SB.PCI0.S19, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x100000)) {
+ Notify(\_SB.PCI0.S20, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x200000)) {
+ Notify(\_SB.PCI0.S21, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x400000)) {
+ Notify(\_SB.PCI0.S22, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x800000)) {
+ Notify(\_SB.PCI0.S23, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x1000000)) {
+ Notify(\_SB.PCI0.S24, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x2000000)) {
+ Notify(\_SB.PCI0.S25, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x4000000)) {
+ Notify(\_SB.PCI0.S26, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x8000000)) {
+ Notify(\_SB.PCI0.S27, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x10000000)) {
+ Notify(\_SB.PCI0.S28, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x20000000)) {
+ Notify(\_SB.PCI0.S29, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x40000000)) {
+ Notify(\_SB.PCI0.S30, 0x3)
+ }
+
+ If (And(\_SB.PCI0.PCID, 0x80000000)) {
+ Notify(\_SB.PCI0.S31, 0x3)
+ }
+
Return(0x01)
}
Method(_L02) {
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 04/23] QEMU/KVM: add pci_find_bus
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (2 preceding siblings ...)
2008-03-04 18:34 ` [patch 03/23] QEMU/KVM: add OperationRegion and GPE handler for add/removal notification Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 05/23] QEMU/KVM: return PCIDevice on net device init and record devfn Marcelo Tosatti
` (19 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: pcibus --]
[-- Type: text/plain, Size: 1604 bytes --]
Return PCIBus pointer from bus number integer.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/hw/pci.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug/qemu/hw/pci.c
@@ -675,6 +675,16 @@ static void pci_bridge_write_config(PCID
pci_default_write_config(d, address, val, len);
}
+PCIBus *pci_find_bus(int bus_num)
+{
+ PCIBus *bus = first_bus;
+
+ while (bus && bus->bus_num != bus_num)
+ bus = bus->next;
+
+ return bus;
+}
+
PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
pci_map_irq_fn map_irq, const char *name)
{
Index: kvm-userspace.hotplug/qemu/hw/pci.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.h
+++ kvm-userspace.hotplug/qemu/hw/pci.h
@@ -3,6 +3,7 @@
/* PCI includes legacy ISA access. */
#include "isa.h"
+#include <linux/pci.h>
/* PCI bus */
@@ -91,6 +92,7 @@ void pci_data_write(void *opaque, uint32
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
int pci_bus_num(PCIBus *s);
void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d));
+PCIBus *pci_find_bus(int bus_num);
void pci_info(void);
PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 05/23] QEMU/KVM: return PCIDevice on net device init and record devfn
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (3 preceding siblings ...)
2008-03-04 18:34 ` [patch 04/23] QEMU/KVM: add pci_find_bus Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 06/23] QEMU/KVM: pci hotplug GPE support Marcelo Tosatti
` (18 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: return-pcidev --]
[-- Type: text/plain, Size: 10023 bytes --]
Change the PCI network drivers init functions to return the PCIDev, to
inform which slot has been hot-plugged.
Also record devfn on the NICInfo structure to locate for release
on hot-removal.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/hw/e1000.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/e1000.c
+++ kvm-userspace.hotplug/qemu/hw/e1000.c
@@ -932,7 +932,7 @@ e1000_mmio_map(PCIDevice *pci_dev, int r
cpu_register_physical_memory(addr, PNPMMIO_SIZE, d->mmio_index);
}
-void
+PCIDevice *
pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
{
E1000State *d;
@@ -996,4 +996,6 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd,
d->nd->macaddr[3], d->nd->macaddr[4], d->nd->macaddr[5]);
register_savevm(info_str, d->instance, 1, nic_save, nic_load, d);
+
+ return (PCIDevice *)d;
}
Index: kvm-userspace.hotplug/qemu/hw/eepro100.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/eepro100.c
+++ kvm-userspace.hotplug/qemu/hw/eepro100.c
@@ -1742,7 +1742,7 @@ static void nic_save(QEMUFile * f, void
qemu_put_buffer(f, s->configuration, sizeof(s->configuration));
}
-static void nic_init(PCIBus * bus, NICInfo * nd,
+static PCIDevice *nic_init(PCIBus * bus, NICInfo * nd,
const char *name, uint32_t device)
{
PCIEEPRO100State *d;
@@ -1794,22 +1794,23 @@ static void nic_init(PCIBus * bus, NICIn
/* XXX: instance number ? */
register_savevm(name, 0, 3, nic_save, nic_load, s);
+ return (PCIDevice *)d;
}
-void pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn)
+PCIDevice *pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn)
{
- nic_init(bus, nd, "i82551", i82551);
+ return nic_init(bus, nd, "i82551", i82551);
//~ uint8_t *pci_conf = d->dev.config;
}
-void pci_i82557b_init(PCIBus * bus, NICInfo * nd, int devfn)
+PCIDevice *pci_i82557b_init(PCIBus * bus, NICInfo * nd, int devfn)
{
- nic_init(bus, nd, "i82557b", i82557B);
+ return nic_init(bus, nd, "i82557b", i82557B);
}
-void pci_i82559er_init(PCIBus * bus, NICInfo * nd, int devfn)
+PCIDevice *pci_i82559er_init(PCIBus * bus, NICInfo * nd, int devfn)
{
- nic_init(bus, nd, "i82559er", i82559ER);
+ return nic_init(bus, nd, "i82559er", i82559ER);
}
/* eof */
Index: kvm-userspace.hotplug/qemu/hw/ne2000.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/ne2000.c
+++ kvm-userspace.hotplug/qemu/hw/ne2000.c
@@ -786,7 +786,7 @@ static void ne2000_map(PCIDevice *pci_de
register_ioport_read(addr + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
}
-void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
{
PCINE2000State *d;
NE2000State *s;
@@ -827,4 +827,6 @@ void pci_ne2000_init(PCIBus *bus, NICInf
/* XXX: instance number ? */
register_savevm("ne2000", ne2000_id++, 3, ne2000_save, ne2000_load, s);
+
+ return (PCIDevice *)d;
}
Index: kvm-userspace.hotplug/qemu/hw/pc.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pc.h
+++ kvm-userspace.hotplug/qemu/hw/pc.h
@@ -146,7 +146,7 @@ void isa_ne2000_init(int base, qemu_irq
/* virtio-net.c */
-void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
void virtio_net_poll(void);
/* virtio-blk.h */
Index: kvm-userspace.hotplug/qemu/hw/pci.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug/qemu/hw/pci.c
@@ -625,24 +625,26 @@ void pci_info(void)
}
/* Initialize a PCI NIC. */
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
{
+ PCIDevice *pci_dev;
+
if (strcmp(nd->model, "ne2k_pci") == 0) {
- pci_ne2000_init(bus, nd, devfn);
+ pci_dev = pci_ne2000_init(bus, nd, devfn);
} else if (strcmp(nd->model, "i82551") == 0) {
- pci_i82551_init(bus, nd, devfn);
+ pci_dev = pci_i82551_init(bus, nd, devfn);
} else if (strcmp(nd->model, "i82557b") == 0) {
- pci_i82557b_init(bus, nd, devfn);
+ pci_dev = pci_i82557b_init(bus, nd, devfn);
} else if (strcmp(nd->model, "i82559er") == 0) {
- pci_i82559er_init(bus, nd, devfn);
+ pci_dev = pci_i82559er_init(bus, nd, devfn);
} else if (strcmp(nd->model, "rtl8139") == 0) {
- pci_rtl8139_init(bus, nd, devfn);
+ pci_dev = pci_rtl8139_init(bus, nd, devfn);
} else if (strcmp(nd->model, "e1000") == 0) {
- pci_e1000_init(bus, nd, devfn);
+ pci_dev = pci_e1000_init(bus, nd, devfn);
} else if (strcmp(nd->model, "pcnet") == 0) {
- pci_pcnet_init(bus, nd, devfn);
+ pci_dev = pci_pcnet_init(bus, nd, devfn);
} else if (strcmp(nd->model, "virtio") == 0) {
- virtio_net_init(bus, nd, devfn);
+ pci_dev = virtio_net_init(bus, nd, devfn);
} else if (strcmp(nd->model, "?") == 0) {
fprintf(stderr, "qemu: Supported PCI NICs: i82551 i82557b i82559er"
" ne2k_pci pcnet rtl8139 e1000 virtio\n");
@@ -651,6 +653,8 @@ void pci_nic_init(PCIBus *bus, NICInfo *
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
exit (1);
}
+ nd->devfn = pci_dev->devfn;
+ return pci_dev;
}
typedef struct {
Index: kvm-userspace.hotplug/qemu/hw/pci.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.h
+++ kvm-userspace.hotplug/qemu/hw/pci.h
@@ -87,7 +87,7 @@ typedef int (*pci_map_irq_fn)(PCIDevice
PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
qemu_irq *pic, int devfn_min, int nirq);
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn);
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
int pci_bus_num(PCIBus *s);
@@ -116,23 +116,23 @@ void usb_ohci_init_pci(struct PCIBus *bu
/* eepro100.c */
-void pci_i82551_init(PCIBus *bus, NICInfo *nd, int devfn);
-void pci_i82557b_init(PCIBus *bus, NICInfo *nd, int devfn);
-void pci_i82559er_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_i82551_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_i82557b_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_i82559er_init(PCIBus *bus, NICInfo *nd, int devfn);
/* ne2000.c */
-void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
/* rtl8139.c */
-void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
/* e1000.c */
-void pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn);
/* pcnet.c */
-void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
/* prep_pci.c */
PCIBus *pci_prep_init(qemu_irq *pic);
Index: kvm-userspace.hotplug/qemu/hw/pcnet.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pcnet.c
+++ kvm-userspace.hotplug/qemu/hw/pcnet.c
@@ -1958,7 +1958,7 @@ static void pci_physical_memory_read(voi
cpu_physical_memory_read(addr, buf, len);
}
-void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
{
PCNetState *d;
uint8_t *pci_conf;
@@ -2006,6 +2006,7 @@ void pci_pcnet_init(PCIBus *bus, NICInfo
d->pci_dev = &d->dev;
pcnet_common_init(d, nd, "pcnet");
+ return (PCIDevice *)d;
}
/* SPARC32 interface */
Index: kvm-userspace.hotplug/qemu/hw/rtl8139.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/rtl8139.c
+++ kvm-userspace.hotplug/qemu/hw/rtl8139.c
@@ -3410,7 +3410,7 @@ static void rtl8139_timer(void *opaque)
}
#endif /* RTL8139_ONBOARD_TIMER */
-void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
{
PCIRTL8139State *d;
RTL8139State *s;
@@ -3474,5 +3474,6 @@ void pci_rtl8139_init(PCIBus *bus, NICIn
qemu_mod_timer(s->timer,
rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
#endif /* RTL8139_ONBOARD_TIMER */
+ return (PCIDevice *)d;
}
Index: kvm-userspace.hotplug/qemu/hw/virtio-net.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/virtio-net.c
+++ kvm-userspace.hotplug/qemu/hw/virtio-net.c
@@ -279,7 +279,7 @@ static void virtio_net_tx_timer(void *op
virtio_net_flush_tx(n, n->tx_vq);
}
-void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
{
VirtIONet *n;
@@ -306,5 +306,5 @@ void *virtio_net_init(PCIBus *bus, NICIn
n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
n->tx_timer_active = 0;
- return &n->vdev;
+ return (PCIDevice *)n;
}
Index: kvm-userspace.hotplug/qemu/net.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/net.h
+++ kvm-userspace.hotplug/qemu/net.h
@@ -45,6 +45,7 @@ struct NICInfo {
uint8_t macaddr[6];
const char *model;
VLANState *vlan;
+ int devfn;
};
extern int nb_nics;
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 06/23] QEMU/KVM: pci hotplug GPE support
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (4 preceding siblings ...)
2008-03-04 18:34 ` [patch 05/23] QEMU/KVM: return PCIDevice on net device init and record devfn Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 07/23] QEMU/KVM: dynamic drive/drive_opt index allocation Marcelo Tosatti
` (17 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: acpi --]
[-- Type: text/plain, Size: 3104 bytes --]
Enable the corresponding bit on the PCIST region and trigger the SCI.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/hw/acpi.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/acpi.c
+++ kvm-userspace.hotplug/qemu/hw/acpi.c
@@ -538,6 +538,7 @@ void qemu_system_powerdown(void)
#endif
#define GPE_BASE 0xafe0
#define PROC_BASE 0xaf00
+#define PCI_BASE 0xae00
struct gpe_regs {
uint16_t sts; /* status */
@@ -546,7 +547,13 @@ struct gpe_regs {
uint8_t down;
};
+struct pci_status {
+ uint32_t up;
+ uint32_t down;
+};
+
static struct gpe_regs gpe;
+static struct pci_status pci0_status;
static uint32_t gpe_readb(void *opaque, uint32_t addr)
{
@@ -614,6 +621,45 @@ static void gpe_writeb(void *opaque, uin
#endif
}
+static uint32_t pcihotplug_read(void *opaque, uint32_t addr)
+{
+ uint32_t val = 0;
+ struct pci_status *g = opaque;
+ switch (addr) {
+ case PCI_BASE:
+ val = g->up;
+ break;
+ case PCI_BASE + 4:
+ val = g->down;
+ break;
+ default:
+ break;
+ }
+
+#if defined(DEBUG)
+ printf("pcihotplug read %lx == %lx\n", addr, val);
+#endif
+ return val;
+}
+
+static void pcihotplug_write(void *opaque, uint32_t addr, uint32_t val)
+{
+ struct pci_status *g = opaque;
+ switch (addr) {
+ case PCI_BASE:
+ g->up = val;
+ break;
+ case PCI_BASE + 4:
+ g->down = val;
+ break;
+ }
+
+#if defined(DEBUG)
+ printf("pcihotplug write %lx <== %d\n", addr, val);
+#endif
+}
+
+
static char *model;
void qemu_system_hot_add_init(char *cpu_model)
@@ -624,6 +670,9 @@ void qemu_system_hot_add_init(char *cpu_
register_ioport_write(PROC_BASE, 4, 1, gpe_writeb, &gpe);
register_ioport_read(PROC_BASE, 4, 1, gpe_readb, &gpe);
+ register_ioport_write(PCI_BASE, 8, 4, pcihotplug_write, &pci0_status);
+ register_ioport_read(PCI_BASE, 8, 4, pcihotplug_read, &pci0_status);
+
model = cpu_model;
}
@@ -665,3 +714,29 @@ void qemu_system_cpu_hot_add(int cpu, in
disable_processor(&gpe, cpu);
qemu_set_irq(pm_state->irq, 0);
}
+
+static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot)
+{
+ g->sts |= 2;
+ g->en |= 2;
+ p->up |= (1 << slot);
+}
+
+static void disable_device(struct pci_status *p, struct gpe_regs *g, int slot)
+{
+ g->sts |= 2;
+ g->en |= 2;
+ p->down |= (1 << slot);
+}
+
+void qemu_system_device_hot_add(int slot, int state)
+{
+ qemu_set_irq(pm_state->irq, 1);
+ pci0_status.up = 0;
+ pci0_status.down = 0;
+ if (state)
+ enable_device(&pci0_status, &gpe, slot);
+ else
+ disable_device(&pci0_status, &gpe, slot);
+ qemu_set_irq(pm_state->irq, 0);
+}
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 07/23] QEMU/KVM: dynamic drive/drive_opt index allocation
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (5 preceding siblings ...)
2008-03-04 18:34 ` [patch 06/23] QEMU/KVM: pci hotplug GPE support Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 08/23] QEMU/KVM: dynamic nic info " Marcelo Tosatti
` (16 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: dynamic-indexing --]
[-- Type: text/plain, Size: 4259 bytes --]
Dynamically allocate drive options and drive table index, so to
reused indexes when devices are removed.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/sysemu.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug/qemu/sysemu.h
@@ -141,6 +141,7 @@ typedef struct DriveInfo {
BlockInterfaceType type;
int bus;
int unit;
+ int used;
} DriveInfo;
#define MAX_IDE_DEVS 2
Index: kvm-userspace.hotplug/qemu/vl.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/vl.c
+++ kvm-userspace.hotplug/qemu/vl.c
@@ -254,6 +254,7 @@ int nb_drives_opt;
struct drive_opt {
const char *file;
char opt[1024];
+ int used;
} drives_opt[MAX_DRIVES];
static CPUState *cur_cpu;
@@ -4915,22 +4916,50 @@ void do_info_network(void)
#define MTD_ALIAS "if=mtd"
#define SD_ALIAS "index=0,if=sd"
+static int drive_opt_get_free_idx(void)
+{
+ int index;
+
+ for (index = 0; index < MAX_DRIVES; index++)
+ if (!drives_opt[index].used) {
+ drives_opt[index].used = 1;
+ return index;
+ }
+
+ return -1;
+}
+
+static int drive_get_free_idx(void)
+{
+ int index;
+
+ for (index = 0; index < MAX_DRIVES; index++)
+ if (!drives_table[index].used) {
+ drives_table[index].used = 1;
+ return index;
+ }
+
+ return -1;
+}
+
static int drive_add(const char *file, const char *fmt, ...)
{
va_list ap;
+ int index = drive_opt_get_free_idx();
- if (nb_drives_opt >= MAX_DRIVES) {
+ if (nb_drives_opt >= MAX_DRIVES || index == -1) {
fprintf(stderr, "qemu: too many drives\n");
exit(1);
}
- drives_opt[nb_drives_opt].file = file;
+ drives_opt[index].file = file;
va_start(ap, fmt);
- vsnprintf(drives_opt[nb_drives_opt].opt,
+ vsnprintf(drives_opt[index].opt,
sizeof(drives_opt[0].opt), fmt, ap);
va_end(ap);
- return nb_drives_opt++;
+ nb_drives_opt++;
+ return index;
}
int drive_get_index(BlockInterfaceType type, int bus, int unit)
@@ -4939,10 +4968,11 @@ int drive_get_index(BlockInterfaceType t
/* seek interface, bus and unit */
- for (index = 0; index < nb_drives; index++)
+ for (index = 0; index < MAX_DRIVES; index++)
if (drives_table[index].type == type &&
drives_table[index].bus == bus &&
- drives_table[index].unit == unit)
+ drives_table[index].unit == unit &&
+ drives_table[index].used)
return index;
return -1;
@@ -4978,6 +5008,7 @@ static int drive_init(struct drive_opt *
int index;
int cache;
int bdrv_flags;
+ int drives_table_idx;
char *str = arg->opt;
char *params[] = { "bus", "unit", "if", "index", "cyls", "heads",
"secs", "trans", "media", "snapshot", "file",
@@ -5229,10 +5260,11 @@ static int drive_init(struct drive_opt *
snprintf(buf, sizeof(buf), "%s%s%i",
devname, mediastr, unit_id);
bdrv = bdrv_new(buf);
- drives_table[nb_drives].bdrv = bdrv;
- drives_table[nb_drives].type = type;
- drives_table[nb_drives].bus = bus_id;
- drives_table[nb_drives].unit = unit_id;
+ drives_table_idx = drive_get_free_idx();
+ drives_table[drives_table_idx].bdrv = bdrv;
+ drives_table[drives_table_idx].type = type;
+ drives_table[drives_table_idx].bus = bus_id;
+ drives_table[drives_table_idx].unit = unit_id;
nb_drives++;
switch(type) {
@@ -9524,8 +9556,10 @@ int main(int argc, char **argv)
if (nb_drives_opt < MAX_DRIVES)
drive_add(NULL, SD_ALIAS);
- /* open the virtual block devices */
-
+ /* open the virtual block devices
+ * note that migration with device
+ * hot add/remove is broken.
+ */
for(i = 0; i < nb_drives_opt; i++)
if (drive_init(&drives_opt[i], snapshot, machine) == -1)
exit(1);
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 08/23] QEMU/KVM: dynamic nic info index allocation
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (6 preceding siblings ...)
2008-03-04 18:34 ` [patch 07/23] QEMU/KVM: dynamic drive/drive_opt index allocation Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 09/23] QEMU/KVM: drive removal support Marcelo Tosatti
` (15 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: net-dynamic-idx --]
[-- Type: text/plain, Size: 2161 bytes --]
The same, but for nics.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/net.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/net.h
+++ kvm-userspace.hotplug/qemu/net.h
@@ -46,6 +46,7 @@ struct NICInfo {
const char *model;
VLANState *vlan;
int devfn;
+ int used;
};
extern int nb_nics;
Index: kvm-userspace.hotplug/qemu/vl.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/vl.c
+++ kvm-userspace.hotplug/qemu/vl.c
@@ -4754,6 +4754,15 @@ static int check_params(char *buf, int b
return 0;
}
+static int nic_get_free_idx(void)
+{
+ int index;
+
+ for (index = 0; index < MAX_NICS; index++)
+ if (!nd_table[index].used)
+ return index;
+ return -1;
+}
static int net_client_init(const char *str)
{
@@ -4786,19 +4795,20 @@ static int net_client_init(const char *s
if (!strcmp(device, "nic")) {
NICInfo *nd;
uint8_t *macaddr;
+ int idx = nic_get_free_idx();
- if (nb_nics >= MAX_NICS) {
+ if (idx == -1 || nb_nics >= MAX_NICS) {
fprintf(stderr, "Too Many NICs\n");
return -1;
}
- nd = &nd_table[nb_nics];
+ nd = &nd_table[idx];
macaddr = nd->macaddr;
macaddr[0] = 0x52;
macaddr[1] = 0x54;
macaddr[2] = 0x00;
macaddr[3] = 0x12;
macaddr[4] = 0x34;
- macaddr[5] = 0x56 + nb_nics;
+ macaddr[5] = 0x56 + idx;
if (get_param_value(buf, sizeof(buf), "macaddr", p)) {
if (parse_macaddr(macaddr, buf) < 0) {
@@ -4810,6 +4820,7 @@ static int net_client_init(const char *s
nd->model = strdup(buf);
}
nd->vlan = vlan;
+ nd->used = 1;
nb_nics++;
vlan->nb_guest_devs++;
ret = 0;
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 09/23] QEMU/KVM: drive removal support
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (7 preceding siblings ...)
2008-03-04 18:34 ` [patch 08/23] QEMU/KVM: dynamic nic info " Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 10/23] QEMU/KVM: record devfn on block driver instance Marcelo Tosatti
` (14 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: device-removal --]
[-- Type: text/plain, Size: 2356 bytes --]
To be used by hot-remove.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/vl.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/vl.c
+++ kvm-userspace.hotplug/qemu/vl.c
@@ -4972,6 +4972,12 @@ static int drive_add(const char *file, c
return index;
}
+void drive_remove(int index)
+{
+ drives_opt[index].used = 0;
+ nb_drives_opt--;
+}
+
int drive_get_index(BlockInterfaceType type, int bus, int unit)
{
int index;
@@ -5002,6 +5008,20 @@ int drive_get_max_bus(BlockInterfaceType
return max_bus;
}
+void drive_uninit(BlockDriverState *bdrv)
+{
+ int i;
+
+ for (i = 0; i < MAX_DRIVES; i++)
+ if (drives_table[i].bdrv == bdrv) {
+ drives_table[i].bdrv = NULL;
+ drives_table[i].used = 0;
+ drive_remove(drives_table[i].drive_opt_idx);
+ nb_drives--;
+ break;
+ }
+}
+
static int drive_init(struct drive_opt *arg, int snapshot,
QEMUMachine *machine)
{
@@ -5275,6 +5295,7 @@ static int drive_init(struct drive_opt *
drives_table[drives_table_idx].type = type;
drives_table[drives_table_idx].bus = bus_id;
drives_table[drives_table_idx].unit = unit_id;
+ drives_table[drives_table_idx].drive_opt_idx = arg - drives_opt;
nb_drives++;
switch(type) {
Index: kvm-userspace.hotplug/qemu/sysemu.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug/qemu/sysemu.h
@@ -142,6 +142,7 @@ typedef struct DriveInfo {
int bus;
int unit;
int used;
+ int drive_opt_idx;
} DriveInfo;
#define MAX_IDE_DEVS 2
@@ -155,6 +156,9 @@ int extboot_drive;
extern int drive_get_index(BlockInterfaceType type, int bus, int unit);
extern int drive_get_max_bus(BlockInterfaceType type);
+extern void drive_uninit(BlockDriverState *bdrv);
+extern void drive_remove(int index);
+
/* acpi */
void qemu_system_cpu_hot_add(int cpu, int state);
void qemu_system_hot_add_init(char *cpu_model);
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 10/23] QEMU/KVM: record devfn on block driver instance
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (8 preceding siblings ...)
2008-03-04 18:34 ` [patch 09/23] QEMU/KVM: drive removal support Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 11/23] QEMU/KVM: move drives_opt for external use Marcelo Tosatti
` (13 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: pci-info --]
[-- Type: text/plain, Size: 3088 bytes --]
Record devfn on the BlockDriverState structure to locate for release
on hot-removal.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/block_int.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/block_int.h
+++ kvm-userspace.hotplug/qemu/block_int.h
@@ -129,6 +129,8 @@ struct BlockDriverState {
int cyls, heads, secs, translation;
int type;
char device_name[32];
+ /* PCI devfn of parent */
+ int devfn;
BlockDriverState *next;
};
Index: kvm-userspace.hotplug/qemu/hw/lsi53c895a.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/lsi53c895a.c
+++ kvm-userspace.hotplug/qemu/hw/lsi53c895a.c
@@ -13,6 +13,7 @@
#include "hw.h"
#include "pci.h"
#include "scsi-disk.h"
+#include "block_int.h"
//#define DEBUG_LSI
//#define DEBUG_LSI_REG
@@ -1845,6 +1846,7 @@ void lsi_scsi_attach(void *opaque, Block
s->scsi_dev[id] = scsi_generic_init(bd, 1, lsi_command_complete, s);
if (s->scsi_dev[id] == NULL)
s->scsi_dev[id] = scsi_disk_init(bd, 1, lsi_command_complete, s);
+ bd->devfn = s->pci_dev.devfn;
}
void *lsi_scsi_init(PCIBus *bus, int devfn)
Index: kvm-userspace.hotplug/qemu/hw/virtio-blk.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/virtio-blk.c
+++ kvm-userspace.hotplug/qemu/hw/virtio-blk.c
@@ -13,6 +13,7 @@
#include "virtio.h"
#include "block.h"
+#include "block_int.h"
#include "pc.h"
/* from Linux's linux/virtio_blk.h */
@@ -156,6 +157,7 @@ void *virtio_blk_init(PCIBus *bus, uint1
s->vdev.update_config = virtio_blk_update_config;
s->vdev.get_features = virtio_blk_get_features;
s->bs = bs;
+ bs->devfn = s->vdev.pci_dev.devfn;
virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output);
Index: kvm-userspace.hotplug/qemu/hw/ide.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/ide.c
+++ kvm-userspace.hotplug/qemu/hw/ide.c
@@ -28,6 +28,7 @@
#include "scsi-disk.h"
#include "pcmcia.h"
#include "block.h"
+#include "block_int.h"
#include "qemu-timer.h"
#include "sysemu.h"
#include "ppc_mac.h"
@@ -2938,6 +2939,7 @@ void pci_piix3_ide_init(PCIBus *bus, Blo
{
PCIIDEState *d;
uint8_t *pci_conf;
+ int i;
/* register a function 1 of PIIX3 */
d = (PCIIDEState *)pci_register_device(bus, "PIIX3 IDE",
@@ -2966,6 +2968,10 @@ void pci_piix3_ide_init(PCIBus *bus, Blo
ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
+ for (i = 0; i < 4; i++)
+ if (hd_table[i])
+ hd_table[i]->devfn = d->dev.devfn;
+
register_savevm("ide", 0, 1, pci_ide_save, pci_ide_load, d);
}
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 11/23] QEMU/KVM: move drives_opt for external use
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (9 preceding siblings ...)
2008-03-04 18:34 ` [patch 10/23] QEMU/KVM: record devfn on block driver instance Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 12/23] QEMU/KVM: net/drive add/remove tweaks Marcelo Tosatti
` (12 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: drive_opt --]
[-- Type: text/plain, Size: 1484 bytes --]
Device hotplug will use that structure from a separate
file.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/sysemu.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug/qemu/sysemu.h
@@ -159,6 +159,15 @@ extern int drive_get_max_bus(BlockInterf
extern void drive_uninit(BlockDriverState *bdrv);
extern void drive_remove(int index);
+struct drive_opt {
+ const char *file;
+ char opt[1024];
+ int used;
+};
+
+extern struct drive_opt drives_opt[MAX_DRIVES];
+extern int nb_drives_opt;
+
/* acpi */
void qemu_system_cpu_hot_add(int cpu, int state);
void qemu_system_hot_add_init(char *cpu_model);
Index: kvm-userspace.hotplug/qemu/vl.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/vl.c
+++ kvm-userspace.hotplug/qemu/vl.c
@@ -251,11 +251,7 @@ unsigned int nb_prom_envs = 0;
const char *prom_envs[MAX_PROM_ENVS];
#endif
int nb_drives_opt;
-struct drive_opt {
- const char *file;
- char opt[1024];
- int used;
-} drives_opt[MAX_DRIVES];
+struct drive_opt drives_opt[MAX_DRIVES];
static CPUState *cur_cpu;
static CPUState *next_cpu;
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 12/23] QEMU/KVM: net/drive add/remove tweaks
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (10 preceding siblings ...)
2008-03-04 18:34 ` [patch 11/23] QEMU/KVM: move drives_opt for external use Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 13/23] QEMU/KVM: add net_client_uninit Marcelo Tosatti
` (11 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: drive_init_ret --]
[-- Type: text/plain, Size: 3577 bytes --]
Export net/drive add/remove functions for device hotplug usage.
Return the table index on add.
Return failure instead of exiting if limit has been reached
on drive_add.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/vl.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/vl.c
+++ kvm-userspace.hotplug/qemu/vl.c
@@ -4760,7 +4760,7 @@ static int nic_get_free_idx(void)
return -1;
}
-static int net_client_init(const char *str)
+int net_client_init(const char *str)
{
const char *p;
char *q;
@@ -4819,7 +4819,7 @@ static int net_client_init(const char *s
nd->used = 1;
nb_nics++;
vlan->nb_guest_devs++;
- ret = 0;
+ ret = idx;
} else
if (!strcmp(device, "none")) {
/* does nothing. It is needed to signal that no network cards
@@ -4949,14 +4949,14 @@ static int drive_get_free_idx(void)
return -1;
}
-static int drive_add(const char *file, const char *fmt, ...)
+int drive_add(const char *file, const char *fmt, ...)
{
va_list ap;
int index = drive_opt_get_free_idx();
if (nb_drives_opt >= MAX_DRIVES || index == -1) {
fprintf(stderr, "qemu: too many drives\n");
- exit(1);
+ return -1;
}
drives_opt[index].file = file;
@@ -5019,9 +5019,10 @@ void drive_uninit(BlockDriverState *bdrv
}
}
-static int drive_init(struct drive_opt *arg, int snapshot,
- QEMUMachine *machine)
+int drive_init(struct drive_opt *arg, int snapshot,
+ void *opaque)
{
+ QEMUMachine *machine = opaque;
char buf[128];
char file[1024];
char devname[128];
@@ -5274,7 +5275,7 @@ static int drive_init(struct drive_opt *
*/
if (drive_get_index(type, bus_id, unit_id) != -1)
- return 0;
+ return -2;
/* init */
@@ -5322,7 +5323,7 @@ static int drive_init(struct drive_opt *
break;
}
if (!file[0])
- return 0;
+ return -2;
bdrv_flags = 0;
if (snapshot)
bdrv_flags |= BDRV_O_SNAPSHOT;
@@ -5333,7 +5334,7 @@ static int drive_init(struct drive_opt *
file);
return -1;
}
- return 0;
+ return drives_table_idx;
}
/***********************************************************/
Index: kvm-userspace.hotplug/qemu/net.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/net.h
+++ kvm-userspace.hotplug/qemu/net.h
@@ -37,6 +37,8 @@ void do_info_network(void);
/* virtio hack for zero copy receive */
int hack_around_tap(void *opaque);
+int net_client_init(const char *str);
+
/* NIC info */
#define MAX_NICS 8
Index: kvm-userspace.hotplug/qemu/sysemu.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug/qemu/sysemu.h
@@ -168,6 +168,9 @@ struct drive_opt {
extern struct drive_opt drives_opt[MAX_DRIVES];
extern int nb_drives_opt;
+extern int drive_add(const char *file, const char *fmt, ...);
+extern int drive_init(struct drive_opt *arg, int snapshot, void *machine);
+
/* acpi */
void qemu_system_cpu_hot_add(int cpu, int state);
void qemu_system_hot_add_init(char *cpu_model);
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 13/23] QEMU/KVM: add net_client_uninit
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (11 preceding siblings ...)
2008-03-04 18:34 ` [patch 12/23] QEMU/KVM: net/drive add/remove tweaks Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 14/23] QEMU/KVM: device hot-add Marcelo Tosatti
` (10 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: net-dev-removal --]
[-- Type: text/plain, Size: 1150 bytes --]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/net.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/net.h
+++ kvm-userspace.hotplug/qemu/net.h
@@ -38,6 +38,7 @@ void do_info_network(void);
int hack_around_tap(void *opaque);
int net_client_init(const char *str);
+void net_client_uninit(NICInfo *nd);
/* NIC info */
Index: kvm-userspace.hotplug/qemu/vl.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/vl.c
+++ kvm-userspace.hotplug/qemu/vl.c
@@ -4900,6 +4900,14 @@ int net_client_init(const char *str)
return ret;
}
+void net_client_uninit(NICInfo *nd)
+{
+ nd->vlan->nb_guest_devs--; /* XXX: free vlan on last reference */
+ nb_nics--;
+ nd->used = 0;
+ free(nd->model);
+}
+
void do_info_network(void)
{
VLANState *vlan;
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 14/23] QEMU/KVM: device hot-add
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (12 preceding siblings ...)
2008-03-04 18:34 ` [patch 13/23] QEMU/KVM: add net_client_uninit Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 19:14 ` Daniel P. Berrange
2008-03-05 5:50 ` Avi Kivity
2008-03-04 18:34 ` [patch 15/23] QEMU/KVM: add pci_find_device Marcelo Tosatti
` (9 subsequent siblings)
23 siblings, 2 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: monitor --]
[-- Type: text/plain, Size: 5764 bytes --]
Add monitor command to hot-add PCI devices (nic and drive).
Save QEMUMachine necessary for drive_init.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/Makefile.target
===================================================================
--- kvm-userspace.hotplug.orig/qemu/Makefile.target
+++ kvm-userspace.hotplug/qemu/Makefile.target
@@ -576,6 +576,8 @@ OBJS+= hypercall.o
# virtio devices
OBJS += virtio.o virtio-net.o virtio-blk.o
+OBJS += device-hotplug.o
+
ifeq ($(TARGET_BASE_ARCH), i386)
# Hardware support
OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
Index: kvm-userspace.hotplug/qemu/hw/device-hotplug.c
===================================================================
--- /dev/null
+++ kvm-userspace.hotplug/qemu/hw/device-hotplug.c
@@ -0,0 +1,92 @@
+#include "hw.h"
+#include "boards.h"
+#include "pci.h"
+#include "net.h"
+#include "sysemu.h"
+#include "pc.h"
+#include "console.h"
+
+static PCIDevice *qemu_system_hot_add_nic(const char *opts, int bus_nr)
+{
+ int ret;
+ char buf[4096];
+ PCIBus *pci_bus;
+
+ pci_bus = pci_find_bus (bus_nr);
+ if (!pci_bus) {
+ term_printf ("Can't find pci_bus %d\n", bus_nr);
+ return NULL;
+ }
+
+ memset (buf, 0, sizeof (buf));
+
+ strcpy (buf, "nic,");
+ strncat (buf, opts, sizeof (buf) - strlen (buf) - 1);
+
+ ret = net_client_init (buf);
+ if (ret < 0 || !nd_table[ret].model)
+ return NULL;
+ return pci_nic_init (pci_bus, &nd_table[ret], -1);
+}
+
+static PCIDevice *qemu_system_hot_add_drive(const char *opts, int bus_nr)
+{
+ int drive_opt_idx, drive_idx;
+ int type = 0;
+ int bus = 0;
+ void *opaque = NULL;
+ PCIBus *pci_bus;
+
+ pci_bus = pci_find_bus(bus_nr);
+ if (!pci_bus) {
+ term_printf("Can't find pci_bus %d\n", bus_nr);
+ return NULL;
+ }
+
+ drive_opt_idx = drive_add(NULL, "%s", opts);
+ if (!drive_opt_idx)
+ return NULL;
+
+ drive_idx = drive_init(&drives_opt[drive_opt_idx], 0, current_machine);
+ if (drive_idx == -1) {
+ drive_remove(drive_opt_idx);
+ return NULL;
+ }
+
+ type = drives_table[drive_idx].type;
+ bus = drive_get_max_bus (type);
+
+ switch (type) {
+ case IF_SCSI:
+ /* XXX: additional unit on existing device? */
+ opaque = lsi_scsi_init (pci_bus, -1);
+ lsi_scsi_attach (opaque, drives_table[drive_idx].bdrv,
+ drives_table[drive_idx].unit);
+ break;
+ case IF_VIRTIO:
+ opaque = virtio_blk_init (pci_bus, 0x1AF4, 0x1001,
+ drives_table[drive_idx].bdrv);
+ break;
+ default:
+ term_printf ("type %d not a PCI device!\n", type);
+ }
+
+ return opaque;
+}
+
+void device_hot_add(const char *type, const char *opts)
+{
+ PCIDevice *dev = NULL;
+
+ if (strcmp(type, "nic") == 0)
+ dev = qemu_system_hot_add_nic(opts, 0);
+ else if (strcmp(type, "drive") == 0)
+ dev = qemu_system_hot_add_drive(opts, 0);
+ else
+ term_printf("invalid type: %s\n", type);
+
+ if (dev)
+ qemu_system_device_hot_add(PCI_SLOT(dev->devfn), 1);
+ else
+ term_printf("failed to add %s\n", opts);
+}
Index: kvm-userspace.hotplug/qemu/monitor.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/monitor.c
+++ kvm-userspace.hotplug/qemu/monitor.c
@@ -1354,6 +1354,7 @@ static term_cmd_t term_cmds[] = {
{ "migrate_set_speed", "s", do_migrate_set_speed,
"value", "set maximum speed (in bytes) for migrations" },
{ "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]", "change cpu state" },
+ { "pci_add", "ss", device_hot_add, "nic|drive [vlan=n][,macaddr=addr][,model=type] [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]", "hotadd PCI device" },
{ NULL, NULL, },
};
Index: kvm-userspace.hotplug/qemu/hw/boards.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/boards.h
+++ kvm-userspace.hotplug/qemu/hw/boards.h
@@ -19,6 +19,8 @@ typedef struct QEMUMachine {
int qemu_register_machine(QEMUMachine *m);
+extern QEMUMachine *current_machine;
+
/* Axis ETRAX. */
extern QEMUMachine bareetraxfs_machine;
Index: kvm-userspace.hotplug/qemu/sysemu.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug/qemu/sysemu.h
@@ -174,6 +174,10 @@ extern int drive_init(struct drive_opt *
/* acpi */
void qemu_system_cpu_hot_add(int cpu, int state);
void qemu_system_hot_add_init(char *cpu_model);
+void qemu_system_device_hot_add(int slot, int state);
+
+/* device-hotplug */
+void device_hot_add(const char *type, const char *opts);
/* vmchannel devices */
Index: kvm-userspace.hotplug/qemu/vl.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/vl.c
+++ kvm-userspace.hotplug/qemu/vl.c
@@ -7573,6 +7573,7 @@ void qemu_bh_delete(QEMUBH *bh)
/* machine registration */
QEMUMachine *first_machine = NULL;
+QEMUMachine *current_machine = NULL;
int qemu_register_machine(QEMUMachine *m)
{
@@ -9703,6 +9704,8 @@ int main(int argc, char **argv)
machine->init(ram_size, vga_ram_size, boot_devices, ds,
kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
+ current_machine = machine;
+
/* init USB devices */
if (usb_enabled) {
for(i = 0; i < usb_devices_index; i++) {
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [patch 14/23] QEMU/KVM: device hot-add
2008-03-04 18:34 ` [patch 14/23] QEMU/KVM: device hot-add Marcelo Tosatti
@ 2008-03-04 19:14 ` Daniel P. Berrange
2008-03-04 19:30 ` Anthony Liguori
2008-03-05 5:50 ` Avi Kivity
1 sibling, 1 reply; 39+ messages in thread
From: Daniel P. Berrange @ 2008-03-04 19:14 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm-devel, Avi Kivity, Glauber Costa
On Tue, Mar 04, 2008 at 03:34:33PM -0300, Marcelo Tosatti wrote:
> Add monitor command to hot-add PCI devices (nic and drive).
[snip]
> Index: kvm-userspace.hotplug/qemu/monitor.c
> ===================================================================
> --- kvm-userspace.hotplug.orig/qemu/monitor.c
> +++ kvm-userspace.hotplug/qemu/monitor.c
> @@ -1354,6 +1354,7 @@ static term_cmd_t term_cmds[] = {
> { "migrate_set_speed", "s", do_migrate_set_speed,
> "value", "set maximum speed (in bytes) for migrations" },
> { "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]", "change cpu state" },
> + { "pci_add", "ss", device_hot_add, "nic|drive [vlan=n][,macaddr=addr][,model=type] [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]", "hotadd PCI device" },
This syntax is not very nice IMHO. We should have explicit commands
for the different types of device,
ie
nic_add [vlan=n][,macaddr=addr][,model=type]
drive_add [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]
ie, follow naming of the command line args -nic, and -drive.
This also keeps 'pci_add' as a command name available for future use to
do generic host->guest pci device pass-through.
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [patch 14/23] QEMU/KVM: device hot-add
2008-03-04 19:14 ` Daniel P. Berrange
@ 2008-03-04 19:30 ` Anthony Liguori
2008-03-04 19:53 ` Daniel P. Berrange
0 siblings, 1 reply; 39+ messages in thread
From: Anthony Liguori @ 2008-03-04 19:30 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: kvm-devel, Marcelo Tosatti, Avi Kivity, Glauber Costa
Daniel P. Berrange wrote:
> On Tue, Mar 04, 2008 at 03:34:33PM -0300, Marcelo Tosatti wrote:
>
>> Add monitor command to hot-add PCI devices (nic and drive).
>>
>
> [snip]
>
>
>> Index: kvm-userspace.hotplug/qemu/monitor.c
>> ===================================================================
>> --- kvm-userspace.hotplug.orig/qemu/monitor.c
>> +++ kvm-userspace.hotplug/qemu/monitor.c
>> @@ -1354,6 +1354,7 @@ static term_cmd_t term_cmds[] = {
>> { "migrate_set_speed", "s", do_migrate_set_speed,
>> "value", "set maximum speed (in bytes) for migrations" },
>> { "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]", "change cpu state" },
>> + { "pci_add", "ss", device_hot_add, "nic|drive [vlan=n][,macaddr=addr][,model=type] [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]", "hotadd PCI device" },
>>
>
> This syntax is not very nice IMHO. We should have explicit commands
> for the different types of device,
>
> ie
>
> nic_add [vlan=n][,macaddr=addr][,model=type]
> drive_add [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]
>
> ie, follow naming of the command line args -nic, and -drive.
>
> This also keeps 'pci_add' as a command name available for future use to
> do generic host->guest pci device pass-through.
>
There is symmetry with pci_add and usb_add since usb_add takes either a
USB device identifier or the name of an emulated device along with
parameters. So I prefer the pci_add syntax just to maintain consistency
with the rest of QEMU.
Regards,
Anthony Liguori
> Regards,
> Dan.
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [patch 14/23] QEMU/KVM: device hot-add
2008-03-04 19:30 ` Anthony Liguori
@ 2008-03-04 19:53 ` Daniel P. Berrange
2008-03-04 21:44 ` Itamar Heim
0 siblings, 1 reply; 39+ messages in thread
From: Daniel P. Berrange @ 2008-03-04 19:53 UTC (permalink / raw)
To: Anthony Liguori; +Cc: kvm-devel, Marcelo Tosatti, Avi Kivity, Glauber Costa
On Tue, Mar 04, 2008 at 01:30:42PM -0600, Anthony Liguori wrote:
> Daniel P. Berrange wrote:
> >On Tue, Mar 04, 2008 at 03:34:33PM -0300, Marcelo Tosatti wrote:
> >>Add monitor command to hot-add PCI devices (nic and drive).
> >[snip]
> >
> >
> >>Index: kvm-userspace.hotplug/qemu/monitor.c
> >>===================================================================
> >>--- kvm-userspace.hotplug.orig/qemu/monitor.c
> >>+++ kvm-userspace.hotplug/qemu/monitor.c
> >>@@ -1354,6 +1354,7 @@ static term_cmd_t term_cmds[] = {
> >> { "migrate_set_speed", "s", do_migrate_set_speed,
> >> "value", "set maximum speed (in bytes) for migrations" },
> >> { "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]", "change
> >> cpu state" },
> >>+ { "pci_add", "ss", device_hot_add, "nic|drive
> >>[vlan=n][,macaddr=addr][,model=type]
> >>[[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]", "hotadd PCI
> >>device" },
> >>
> >
> >This syntax is not very nice IMHO. We should have explicit commands
> >for the different types of device,
> >
> >ie
> >
> > nic_add [vlan=n][,macaddr=addr][,model=type]
> > drive_add [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]
> >
> >ie, follow naming of the command line args -nic, and -drive.
> >
> >This also keeps 'pci_add' as a command name available for future use to
> >do generic host->guest pci device pass-through.
> >
>
> There is symmetry with pci_add and usb_add since usb_add takes either a
> USB device identifier or the name of an emulated device along with
> parameters. So I prefer the pci_add syntax just to maintain consistency
> with the rest of QEMU.
This is true, but the usb_add/remove syntax is horrible to work with. One
of the reasons I've not added USB hotplug/remove to libvirt yet is the
difficulty (perhaps even impossibility) of reliably finding out the USB
device number associated with the device that was added. I guess ideally
the add command would have to print out / return the number associated
with the device, which libvirt could record for use when it later comes
time to remove the device.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [patch 14/23] QEMU/KVM: device hot-add
2008-03-04 19:53 ` Daniel P. Berrange
@ 2008-03-04 21:44 ` Itamar Heim
0 siblings, 0 replies; 39+ messages in thread
From: Itamar Heim @ 2008-03-04 21:44 UTC (permalink / raw)
To: Daniel P. Berrange, Anthony Liguori
Cc: kvm-devel, Yuval Kashtan, Avi Kivity, Marcelo Tosatti,
Glauber Costa
[-- Attachment #1: Type: text/plain, Size: 3952 bytes --]
Actually, the following (old) patch by Yuval Kashtan was sent to
qemu-devel back in October (but not merged AFAIK) to facilitate usb_del
using the same string used during usb_add.
"
Hello,
This proposed patch add support for deleting usb devices by providing
the (exact) same string they were added with, thus enabling to remove a
usb device with the host string.
The old capability of deleting usb device by their internal port is not
harmed.
I had to move USBHostDevice to vl.h so that I will be able to reference
it from vl.c
and last, I've changed the output of info usb so that it will include
the saved string (for reference).
Please comment.
BR,
Yuval Kashtan.
"
-----Original Message-----
From: kvm-devel-bounces@lists.sourceforge.net
[mailto:kvm-devel-bounces@lists.sourceforge.net] On Behalf Of Daniel P.
Berrange
Sent: Tuesday, March 04, 2008 9:54 PM
To: Anthony Liguori
Cc: kvm-devel@lists.sourceforge.net; Marcelo Tosatti; Avi Kivity;
Glauber Costa
Subject: Re: [kvm-devel] [patch 14/23] QEMU/KVM: device hot-add
On Tue, Mar 04, 2008 at 01:30:42PM -0600, Anthony Liguori wrote:
> Daniel P. Berrange wrote:
> >On Tue, Mar 04, 2008 at 03:34:33PM -0300, Marcelo Tosatti wrote:
> >>Add monitor command to hot-add PCI devices (nic and drive).
> >[snip]
> >
> >
> >>Index: kvm-userspace.hotplug/qemu/monitor.c
> >>===================================================================
> >>--- kvm-userspace.hotplug.orig/qemu/monitor.c
> >>+++ kvm-userspace.hotplug/qemu/monitor.c
> >>@@ -1354,6 +1354,7 @@ static term_cmd_t term_cmds[] = {
> >> { "migrate_set_speed", "s", do_migrate_set_speed,
> >> "value", "set maximum speed (in bytes) for migrations" },
> >> { "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]",
"change
> >> cpu state" },
> >>+ { "pci_add", "ss", device_hot_add, "nic|drive
> >>[vlan=n][,macaddr=addr][,model=type]
> >>[[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]",
"hotadd PCI
> >>device" },
> >>
> >
> >This syntax is not very nice IMHO. We should have explicit commands
> >for the different types of device,
> >
> >ie
> >
> > nic_add [vlan=n][,macaddr=addr][,model=type]
> > drive_add
[[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]
> >
> >ie, follow naming of the command line args -nic, and -drive.
> >
> >This also keeps 'pci_add' as a command name available for future use
to
> >do generic host->guest pci device pass-through.
> >
>
> There is symmetry with pci_add and usb_add since usb_add takes either
a
> USB device identifier or the name of an emulated device along with
> parameters. So I prefer the pci_add syntax just to maintain
consistency
> with the rest of QEMU.
This is true, but the usb_add/remove syntax is horrible to work with.
One
of the reasons I've not added USB hotplug/remove to libvirt yet is the
difficulty (perhaps even impossibility) of reliably finding out the USB
device number associated with the device that was added. I guess ideally
the add command would have to print out / return the number associated
with the device, which libvirt could record for use when it later comes
time to remove the device.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392
2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/
-=|
|=- Projects: http://freshmeat.net/~danielpb/
-=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505
-=|
------------------------------------------------------------------------
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel
[-- Attachment #2: usb_del.patch --]
[-- Type: application/octet-stream, Size: 2797 bytes --]
diff -Naur qemu.orig/usb-linux.c qemu.usb/usb-linux.c
--- qemu.orig/usb-linux.c 2007-10-09 13:27:39.000000000 +0200
+++ qemu.usb/usb-linux.c 2007-10-09 15:04:46.000000000 +0200
@@ -56,27 +56,9 @@
#define USBDEVFS_PATH "/proc/bus/usb"
#define PRODUCT_NAME_SZ 32
#define SIG_ISOCOMPLETE (SIGRTMIN+7)
-#define MAX_ENDPOINTS 16
struct sigaction sigact;
-/* endpoint association data */
-struct endp_data {
- uint8_t type;
-};
-
-/* FIXME: move USBPacket to PendingURB */
-typedef struct USBHostDevice {
- USBDevice dev;
- int fd;
- USBPacket *packet;
- struct endp_data endp_table[MAX_ENDPOINTS];
- int configuration;
- uint8_t descr[1024];
- int descr_len;
- int urbs_ready;
-} USBHostDevice;
-
typedef struct PendingURB {
struct usbdevfs_urb *urb;
USBHostDevice *dev;
diff -Naur qemu.orig/vl.c qemu.usb/vl.c
--- qemu.orig/vl.c 2007-10-09 13:01:16.000000000 +0200
+++ qemu.usb/vl.c 2007-10-09 15:04:36.000000000 +0200
@@ -4743,6 +4743,9 @@
free_usb_ports = port->next;
port->next = used_usb_ports;
used_usb_ports = port;
+ pstrcpy (((USBHostDevice *)dev)->szDeviceName,
+ 20,
+ devname);
usb_attach(port, dev);
return 0;
}
@@ -4768,7 +4771,8 @@
lastp = &used_usb_ports;
port = used_usb_ports;
- while (port && port->dev->addr != addr) {
+ while (port && port->dev->addr != addr && strcmp (((USBHostDevice *)(port->dev))->szDeviceName,
+ devname) != 0) {
lastp = &port->next;
port = port->next;
}
@@ -4830,8 +4834,8 @@
speed_str = "?";
break;
}
- term_printf(" Device %d.%d, Speed %s Mb/s, Product %s\n",
- 0, dev->addr, speed_str, dev->devname);
+ term_printf(" Device %d.%d[%s], Speed %s Mb/s, Product %s\n",
+ 0, dev->addr, ((USBHostDevice *)dev)->szDeviceName, speed_str, dev->devname);
}
}
diff -Naur qemu.orig/vl.h qemu.usb/vl.h
--- qemu.orig/vl.h 2007-10-09 13:01:19.000000000 +0200
+++ qemu.usb/vl.h 2007-10-09 15:04:36.000000000 +0200
@@ -1394,6 +1394,30 @@
#include "hw/usb.h"
+#if defined(__linux__)
+#include <linux/compiler.h>
+#include <linux/usbdevice_fs.h>
+
+#define MAX_ENDPOINTS 16
+
+/* endpoint association data */
+struct endp_data {
+ uint8_t type;
+};
+
+/* FIXME: move USBPacket to PendingURB */
+typedef struct USBHostDevice {
+ USBDevice dev;
+ int fd;
+ USBPacket *packet;
+ struct endp_data endp_table[MAX_ENDPOINTS];
+ int configuration;
+ uint8_t descr[1024];
+ int descr_len;
+ int urbs_ready;
+ char szDeviceName[20];
+} USBHostDevice;
+#endif
/* usb ports of the VM */
void qemu_register_usb_port(USBPort *port, void *opaque, int index,
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
[-- Attachment #4: Type: text/plain, Size: 158 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch 14/23] QEMU/KVM: device hot-add
2008-03-04 18:34 ` [patch 14/23] QEMU/KVM: device hot-add Marcelo Tosatti
2008-03-04 19:14 ` Daniel P. Berrange
@ 2008-03-05 5:50 ` Avi Kivity
2008-03-11 14:18 ` Marcelo Tosatti
1 sibling, 1 reply; 39+ messages in thread
From: Avi Kivity @ 2008-03-05 5:50 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm-devel, Glauber Costa
Marcelo Tosatti wrote:
> Add monitor command to hot-add PCI devices (nic and drive).
>
>
A drive is not a pci device. One would hot-plug a scsi controller, and
then hot-plug a device to that controller.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch 14/23] QEMU/KVM: device hot-add
2008-03-05 5:50 ` Avi Kivity
@ 2008-03-11 14:18 ` Marcelo Tosatti
0 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-11 14:18 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel, Glauber Costa
On Wed, Mar 05, 2008 at 07:50:14AM +0200, Avi Kivity wrote:
> Marcelo Tosatti wrote:
> >Add monitor command to hot-add PCI devices (nic and drive).
> >
> >
>
> A drive is not a pci device. One would hot-plug a scsi controller, and
> then hot-plug a device to that controller.
Changed the syntax from "pci_add drive" to "pci_add storage".
However I'm keeping the possibility of adding a drive to a storage
controller before it is hotplugged for two reasons:
- SCSI drive hotplug is not automatic (at least with the sym53c8xx
controller that is emulated). Its necessary to manually add the drive
in the guest OS.
- Each virtio-block device is currently tied to a single valid
file/device.
A new "drive_add" command has been added to hot-add drives to SCSI
controllers.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread
* [patch 15/23] QEMU/KVM: add pci_find_device
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (13 preceding siblings ...)
2008-03-04 18:34 ` [patch 14/23] QEMU/KVM: device hot-add Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 16/23] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic Marcelo Tosatti
` (8 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: pci-find-device --]
[-- Type: text/plain, Size: 1617 bytes --]
Return PCIDevice from bus number and slot.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/hw/pci.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug/qemu/hw/pci.c
@@ -689,6 +689,23 @@ PCIBus *pci_find_bus(int bus_num)
return bus;
}
+PCIDevice *pci_find_device(int bus_num, int slot)
+{
+ int devfn;
+ PCIDevice *d;
+ PCIBus *bus = pci_find_bus(bus_num);
+
+ if (!bus)
+ return NULL;
+
+ for(devfn = 0; devfn < 256; devfn++) {
+ d = bus->devices[devfn];
+ if (d && PCI_SLOT(devfn) == slot)
+ return d;
+ }
+ return NULL;
+}
+
PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
pci_map_irq_fn map_irq, const char *name)
{
Index: kvm-userspace.hotplug/qemu/hw/pci.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.h
+++ kvm-userspace.hotplug/qemu/hw/pci.h
@@ -93,6 +93,7 @@ uint32_t pci_data_read(void *opaque, uin
int pci_bus_num(PCIBus *s);
void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d));
PCIBus *pci_find_bus(int bus_num);
+PCIDevice *pci_find_device(int bus_num, int slot);
void pci_info(void);
PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 16/23] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (14 preceding siblings ...)
2008-03-04 18:34 ` [patch 15/23] QEMU/KVM: add pci_find_device Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 17/23] QEMU/KVM: notify _EJ0 through _SEJ OperationRegion Marcelo Tosatti
` (7 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: mem-io-unregister --]
[-- Type: text/plain, Size: 3459 bytes --]
So drivers can clear their mem io table entries on exit back to unassigned
state.
Also make the io mem index allocation dynamic.
Perhaps freeing the state created during cpu_register_physical_memory()
is also necessary.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/cpu-all.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/cpu-all.h
+++ kvm-userspace.hotplug/qemu/cpu-all.h
@@ -837,6 +837,7 @@ int cpu_register_io_memory(int io_index,
CPUReadMemoryFunc **mem_read,
CPUWriteMemoryFunc **mem_write,
void *opaque);
+void cpu_unregister_io_memory(int table_address);
CPUWriteMemoryFunc **cpu_get_io_memory_write(int io_index);
CPUReadMemoryFunc **cpu_get_io_memory_read(int io_index);
Index: kvm-userspace.hotplug/qemu/exec.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/exec.c
+++ kvm-userspace.hotplug/qemu/exec.c
@@ -158,7 +158,7 @@ PhysPageDesc **l1_phys_map;
CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
void *io_mem_opaque[IO_MEM_NB_ENTRIES];
-static int io_mem_nb;
+char io_mem_used[IO_MEM_NB_ENTRIES];
#if defined(CONFIG_SOFTMMU)
static int io_mem_watch;
#endif
@@ -2493,12 +2493,28 @@ static void *subpage_init (target_phys_a
return mmio;
}
+static int get_free_io_mem_idx(void)
+{
+ int i;
+
+ for (i = 0; i<IO_MEM_NB_ENTRIES; i++)
+ if (!io_mem_used[i]) {
+ io_mem_used[i] = 1;
+ return i;
+ }
+
+ return -1;
+}
+
static void io_mem_init(void)
{
+ int i;
+
cpu_register_io_memory(IO_MEM_ROM >> IO_MEM_SHIFT, error_mem_read, unassigned_mem_write, NULL);
cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT, unassigned_mem_read, unassigned_mem_write, NULL);
cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read, notdirty_mem_write, NULL);
- io_mem_nb = 5;
+ for (i=0; i<5; i++)
+ io_mem_used[i] = 0;
#if defined(CONFIG_SOFTMMU)
io_mem_watch = cpu_register_io_memory(-1, watch_mem_read,
@@ -2525,9 +2541,9 @@ int cpu_register_io_memory(int io_index,
int i, subwidth = 0;
if (io_index <= 0) {
- if (io_mem_nb >= IO_MEM_NB_ENTRIES)
- return -1;
- io_index = io_mem_nb++;
+ io_index = get_free_io_mem_idx();
+ if (io_index == -1)
+ return io_index;
} else {
if (io_index >= IO_MEM_NB_ENTRIES)
return -1;
@@ -2543,6 +2559,19 @@ int cpu_register_io_memory(int io_index,
return (io_index << IO_MEM_SHIFT) | subwidth;
}
+void cpu_unregister_io_memory(int io_table_address)
+{
+ int i;
+ int io_index = io_table_address >> IO_MEM_SHIFT;
+
+ for (i=0;i < 3; i++) {
+ io_mem_read[io_index][i] = unassigned_mem_read[i];
+ io_mem_write[io_index][i] = unassigned_mem_write[i];
+ }
+ io_mem_opaque[io_index] = NULL;
+ io_mem_used[io_index] = 0;
+}
+
CPUWriteMemoryFunc **cpu_get_io_memory_write(int io_index)
{
return io_mem_write[io_index >> IO_MEM_SHIFT];
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 17/23] QEMU/KVM: notify _EJ0 through _SEJ OperationRegion
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (15 preceding siblings ...)
2008-03-04 18:34 ` [patch 16/23] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 18/23] QEMU/KVM: handle SEJ notifications Marcelo Tosatti
` (6 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: acpi-ost --]
[-- Type: text/plain, Size: 9792 bytes --]
The _EJ0 method is executed by the OS once it has successfully finished
device removal. Inform that event through IO port space so QEMU
can free the associated data.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/bios/acpi-dsdt.dsl
===================================================================
--- kvm-userspace.hotplug.orig/bios/acpi-dsdt.dsl
+++ kvm-userspace.hotplug/bios/acpi-dsdt.dsl
@@ -414,159 +414,258 @@ DefinitionBlock (
PCID, 32,
}
+ OperationRegion(SEJ, SystemIO, 0xae08, 0x04)
+ Field (SEJ, DWordAcc, NoLock, WriteAsZeros)
+ {
+ B0EJ, 32,
+ }
+
Device (S1) { // Slot 1
Name (_ADR, 0x00010000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x2, B0EJ)
+ Return (0x0)
+ }
}
Device (S2) { // Slot 2
Name (_ADR, 0x00020000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x4, B0EJ)
+ Return (0x0)
+ }
}
Device (S3) { // Slot 3
Name (_ADR, 0x00030000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store (0x8, B0EJ)
+ Return (0x0)
+ }
}
Device (S4) { // Slot 4
Name (_ADR, 0x00040000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x10, B0EJ)
+ Return (0x0)
+ }
}
Device (S5) { // Slot 5
Name (_ADR, 0x00050000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x20, B0EJ)
+ Return (0x0)
+ }
}
Device (S6) { // Slot 6
Name (_ADR, 0x00060000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x40, B0EJ)
+ Return (0x0)
+ }
}
Device (S7) { // Slot 7
Name (_ADR, 0x00070000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x80, B0EJ)
+ Return (0x0)
+ }
}
Device (S8) { // Slot 8
Name (_ADR, 0x00080000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x100, B0EJ)
+ Return (0x0)
+ }
}
Device (S9) { // Slot 9
Name (_ADR, 0x00090000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x200, B0EJ)
+ Return (0x0)
+ }
}
Device (S10) { // Slot 10
Name (_ADR, 0x000A0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x400, B0EJ)
+ Return (0x0)
+ }
}
Device (S11) { // Slot 11
Name (_ADR, 0x000B0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x800, B0EJ)
+ Return (0x0)
+ }
}
Device (S12) { // Slot 12
Name (_ADR, 0x000C0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x1000, B0EJ)
+ Return (0x0)
+ }
}
Device (S13) { // Slot 13
Name (_ADR, 0x000D0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x2000, B0EJ)
+ Return (0x0)
+ }
}
Device (S14) { // Slot 14
Name (_ADR, 0x000E0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x4000, B0EJ)
+ Return (0x0)
+ }
}
Device (S15) { // Slot 15
Name (_ADR, 0x000F0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x8000, B0EJ)
+ Return (0x0)
+ }
}
Device (S16) { // Slot 16
Name (_ADR, 0x00100000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x10000, B0EJ)
+ Return (0x0)
+ }
}
Device (S17) { // Slot 17
Name (_ADR, 0x00110000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x20000, B0EJ)
+ Return (0x0)
+ }
}
Device (S18) { // Slot 18
Name (_ADR, 0x00120000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x40000, B0EJ)
+ Return (0x0)
+ }
}
Device (S19) { // Slot 19
Name (_ADR, 0x00130000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x80000, B0EJ)
+ Return (0x0)
+ }
}
Device (S20) { // Slot 20
Name (_ADR, 0x00140000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x100000, B0EJ)
+ Return (0x0)
+ }
}
Device (S21) { // Slot 21
Name (_ADR, 0x00150000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x200000, B0EJ)
+ Return (0x0)
+ }
}
Device (S22) { // Slot 22
Name (_ADR, 0x00160000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x400000, B0EJ)
+ Return (0x0)
+ }
}
Device (S23) { // Slot 23
Name (_ADR, 0x00170000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x800000, B0EJ)
+ Return (0x0)
+ }
}
Device (S24) { // Slot 24
Name (_ADR, 0x00180000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x1000000, B0EJ)
+ Return (0x0)
+ }
}
Device (S25) { // Slot 25
Name (_ADR, 0x00190000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x2000000, B0EJ)
+ Return (0x0)
+ }
}
Device (S26) { // Slot 26
Name (_ADR, 0x001A0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x4000000, B0EJ)
+ Return (0x0)
+ }
}
Device (S27) { // Slot 27
Name (_ADR, 0x001B0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x8000000, B0EJ)
+ Return (0x0)
+ }
}
Device (S28) { // Slot 28
Name (_ADR, 0x001C0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x10000000, B0EJ)
+ Return (0x0)
+ }
}
Device (S29) { // Slot 29
Name (_ADR, 0x001D0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x20000000, B0EJ)
+ Return (0x0)
+ }
}
Device (S30) { // Slot 30
Name (_ADR, 0x001E0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x40000000, B0EJ)
+ Return (0x0)
+ }
}
Device (S31) { // Slot 31
Name (_ADR, 0x001F0000)
- Method (_EJ0,1) { Return (0x0) }
+ Method (_EJ0,1) {
+ Store(0x80000000, B0EJ)
+ Return (0x0)
+ }
}
Method (_CRS, 0, NotSerialized)
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 18/23] QEMU/KVM: handle SEJ notifications
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (16 preceding siblings ...)
2008-03-04 18:34 ` [patch 17/23] QEMU/KVM: notify _EJ0 through _SEJ OperationRegion Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 19/23] QEMU/KVM: add qemu_free_irqs Marcelo Tosatti
` (5 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: acpi-ej0 --]
[-- Type: text/plain, Size: 1661 bytes --]
Handle the _EJ0 notifications.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/hw/acpi.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/acpi.c
+++ kvm-userspace.hotplug/qemu/hw/acpi.c
@@ -26,6 +26,7 @@
#ifdef USE_KVM
#include "qemu-kvm.h"
#endif
+#include "string.h"
//#define DEBUG
@@ -539,6 +540,7 @@ void qemu_system_powerdown(void)
#define GPE_BASE 0xafe0
#define PROC_BASE 0xaf00
#define PCI_BASE 0xae00
+#define PCI_EJ_BASE 0xae08
struct gpe_regs {
uint16_t sts; /* status */
@@ -659,6 +661,23 @@ static void pcihotplug_write(void *opaqu
#endif
}
+static uint32_t pciej_read(void *opaque, uint32_t addr)
+{
+#if defined(DEBUG)
+ printf("pciej read %lx == %lx\n", addr, val);
+#endif
+ return 0;
+}
+
+static void pciej_write(void *opaque, uint32_t addr, uint32_t val)
+{
+ int slot = ffs(val) - 1;
+
+#if defined(DEBUG)
+ printf("pciej write %lx <== %d\n", addr, val);
+#endif
+}
+
static char *model;
@@ -673,6 +692,9 @@ void qemu_system_hot_add_init(char *cpu_
register_ioport_write(PCI_BASE, 8, 4, pcihotplug_write, &pci0_status);
register_ioport_read(PCI_BASE, 8, 4, pcihotplug_read, &pci0_status);
+ register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, NULL);
+ register_ioport_read(PCI_EJ_BASE, 4, 4, pciej_read, NULL);
+
model = cpu_model;
}
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 19/23] QEMU/KVM: add qemu_free_irqs
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (17 preceding siblings ...)
2008-03-04 18:34 ` [patch 18/23] QEMU/KVM: handle SEJ notifications Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 20/23] QEMU/KVM: add pci_unregister_device Marcelo Tosatti
` (4 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: qemu-free-irqs --]
[-- Type: text/plain, Size: 1249 bytes --]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/hw/irq.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/irq.c
+++ kvm-userspace.hotplug/qemu/hw/irq.c
@@ -56,6 +56,12 @@ qemu_irq *qemu_allocate_irqs(qemu_irq_ha
return s;
}
+void qemu_free_irqs(qemu_irq *s)
+{
+ qemu_free(s[0]);
+ qemu_free(s);
+}
+
static void qemu_notirq(void *opaque, int line, int level)
{
struct IRQState *irq = opaque;
Index: kvm-userspace.hotplug/qemu/hw/irq.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/irq.h
+++ kvm-userspace.hotplug/qemu/hw/irq.h
@@ -28,6 +28,8 @@ static inline void qemu_irq_pulse(qemu_i
/* Returns an array of N IRQs. */
qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n);
+void qemu_free_irqs(qemu_irq *s);
+
/* Returns a new IRQ with opposite polarity. */
qemu_irq qemu_irq_invert(qemu_irq irq);
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 20/23] QEMU/KVM: add pci_unregister_device
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (18 preceding siblings ...)
2008-03-04 18:34 ` [patch 19/23] QEMU/KVM: add qemu_free_irqs Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 21/23] QEMU/KVM: LSI SCSI unregister callback Marcelo Tosatti
` (3 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: pci-remove --]
[-- Type: text/plain, Size: 3534 bytes --]
Unregister the pci device, unassign its IO and memory regions, and free
associated data.
Add a callback so drivers can free device state.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/hw/pci.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug/qemu/hw/pci.c
@@ -185,6 +185,48 @@ PCIDevice *pci_register_device(PCIBus *b
return pci_dev;
}
+static target_phys_addr_t pci_to_cpu_addr(target_phys_addr_t addr)
+{
+ return addr + pci_mem_base;
+}
+
+static void pci_unregister_io_regions(PCIDevice *pci_dev)
+{
+ PCIIORegion *r;
+ int i;
+
+ for(i = 0; i < PCI_NUM_REGIONS; i++) {
+ r = &pci_dev->io_regions[i];
+ if (!r->size)
+ continue;
+ if (r->type == PCI_ADDRESS_SPACE_IO) {
+ isa_unassign_ioport(r->addr, r->size);
+ } else {
+ cpu_register_physical_memory(pci_to_cpu_addr(r->addr),
+ r->size,
+ IO_MEM_UNASSIGNED);
+ }
+ }
+}
+
+int pci_unregister_device(PCIDevice *pci_dev)
+{
+ int ret = 0;
+
+ if (pci_dev->unregister)
+ ret = pci_dev->unregister(pci_dev);
+ if (ret)
+ return ret;
+
+ pci_unregister_io_regions(pci_dev);
+
+ qemu_free_irqs(pci_dev->irq);
+ pci_irq_index--;
+ pci_dev->bus->devices[pci_dev->devfn] = NULL;
+ qemu_free(pci_dev);
+ return 0;
+}
+
void pci_register_io_region(PCIDevice *pci_dev, int region_num,
uint32_t size, int type,
PCIMapIORegionFunc *map_func)
@@ -207,10 +249,6 @@ void pci_register_io_region(PCIDevice *p
*(uint32_t *)(pci_dev->config + addr) = cpu_to_le32(type);
}
-static target_phys_addr_t pci_to_cpu_addr(target_phys_addr_t addr)
-{
- return addr + pci_mem_base;
-}
static void pci_update_mappings(PCIDevice *d)
{
Index: kvm-userspace.hotplug/qemu/hw/pci.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.h
+++ kvm-userspace.hotplug/qemu/hw/pci.h
@@ -15,6 +15,7 @@ typedef uint32_t PCIConfigReadFunc(PCIDe
uint32_t address, int len);
typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
uint32_t addr, uint32_t size, int type);
+typedef int PCIUnregisterFunc(PCIDevice *pci_dev);
#define PCI_ADDRESS_SPACE_MEM 0x00
#define PCI_ADDRESS_SPACE_IO 0x01
@@ -56,6 +57,7 @@ struct PCIDevice {
/* do not access the following fields */
PCIConfigReadFunc *config_read;
PCIConfigWriteFunc *config_write;
+ PCIUnregisterFunc *unregister;
/* ??? This is a PC-specific hack, and should be removed. */
int irq_index;
@@ -71,6 +73,8 @@ PCIDevice *pci_register_device(PCIBus *b
PCIConfigReadFunc *config_read,
PCIConfigWriteFunc *config_write);
+int pci_unregister_device(PCIDevice *pci_dev);
+
void pci_register_io_region(PCIDevice *pci_dev, int region_num,
uint32_t size, int type,
PCIMapIORegionFunc *map_func);
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 21/23] QEMU/KVM: LSI SCSI unregister callback
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (19 preceding siblings ...)
2008-03-04 18:34 ` [patch 20/23] QEMU/KVM: add pci_unregister_device Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 22/23] QEMU/KVM: zero ioport_opaque on isa_unassign_ioport Marcelo Tosatti
` (2 subsequent siblings)
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: lsi-unregister --]
[-- Type: text/plain, Size: 1134 bytes --]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/hw/lsi53c895a.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/lsi53c895a.c
+++ kvm-userspace.hotplug/qemu/hw/lsi53c895a.c
@@ -1849,6 +1849,18 @@ void lsi_scsi_attach(void *opaque, Block
bd->devfn = s->pci_dev.devfn;
}
+int lsi_scsi_uninit(PCIDevice *d)
+{
+ LSIState *s = (LSIState *) d;
+
+ cpu_unregister_io_memory(s->mmio_io_addr);
+ cpu_unregister_io_memory(s->ram_io_addr);
+
+ qemu_free(s->queue);
+
+ return 0;
+}
+
void *lsi_scsi_init(PCIBus *bus, int devfn)
{
LSIState *s;
@@ -1881,6 +1893,7 @@ void *lsi_scsi_init(PCIBus *bus, int dev
s->queue = qemu_malloc(sizeof(lsi_queue));
s->queue_len = 1;
s->active_commands = 0;
+ s->pci_dev.unregister = lsi_scsi_uninit;
lsi_soft_reset(s);
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 22/23] QEMU/KVM: zero ioport_opaque on isa_unassign_ioport
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (20 preceding siblings ...)
2008-03-04 18:34 ` [patch 21/23] QEMU/KVM: LSI SCSI unregister callback Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 23/23] QEMU/KVM: device hot-remove Marcelo Tosatti
2008-03-05 6:00 ` [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Avi Kivity
23 siblings, 0 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: isa-unassign-opaque --]
[-- Type: text/plain, Size: 837 bytes --]
If the io port is unassigned, the previous private pointer is
meaningless.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/vl.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/vl.c
+++ kvm-userspace.hotplug/qemu/vl.c
@@ -399,6 +399,8 @@ void isa_unassign_ioport(int start, int
ioport_write_table[0][i] = default_ioport_writeb;
ioport_write_table[1][i] = default_ioport_writew;
ioport_write_table[2][i] = default_ioport_writel;
+
+ ioport_opaque[i] = NULL;
}
}
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* [patch 23/23] QEMU/KVM: device hot-remove
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (21 preceding siblings ...)
2008-03-04 18:34 ` [patch 22/23] QEMU/KVM: zero ioport_opaque on isa_unassign_ioport Marcelo Tosatti
@ 2008-03-04 18:34 ` Marcelo Tosatti
2008-03-04 19:18 ` Daniel P. Berrange
2008-03-05 6:47 ` Avi Kivity
2008-03-05 6:00 ` [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Avi Kivity
23 siblings, 2 replies; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 18:34 UTC (permalink / raw)
To: kvm-devel; +Cc: Marcelo Tosatti, Avi Kivity, Glauber Costa
[-- Attachment #1: monitor-remove --]
[-- Type: text/plain, Size: 3805 bytes --]
Add monitor command to hot-remove devices.
Remove device data on _EJ0 notification.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/monitor.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/monitor.c
+++ kvm-userspace.hotplug/qemu/monitor.c
@@ -1355,6 +1355,7 @@ static term_cmd_t term_cmds[] = {
"value", "set maximum speed (in bytes) for migrations" },
{ "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]", "change cpu state" },
{ "pci_add", "ss", device_hot_add, "nic|drive [vlan=n][,macaddr=addr][,model=type] [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]", "hotadd PCI device" },
+ { "pci_remove", "i", device_hot_remove, "slot number", "hot remove PCI device" },
{ NULL, NULL, },
};
Index: kvm-userspace.hotplug/qemu/hw/device-hotplug.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/device-hotplug.c
+++ kvm-userspace.hotplug/qemu/hw/device-hotplug.c
@@ -5,6 +5,8 @@
#include "sysemu.h"
#include "pc.h"
#include "console.h"
+#include "block_int.h"
+#include <linux/pci_ids.h>
static PCIDevice *qemu_system_hot_add_nic(const char *opts, int bus_nr)
{
@@ -90,3 +92,67 @@ void device_hot_add(const char *type, co
else
term_printf("failed to add %s\n", opts);
}
+
+void device_hot_remove(int slot)
+{
+ PCIDevice *d = pci_find_device(0, slot);
+
+ if (!d) {
+ term_printf("invalid slot %d\n", slot);
+ return;
+ }
+
+ qemu_system_device_hot_add(slot, 0);
+}
+
+static void destroy_nic(int slot)
+{
+ int i;
+
+ for (i = 0; i < MAX_NICS; i++)
+ if (nd_table[i].used &&
+ PCI_SLOT(nd_table[i].devfn) == slot)
+ net_client_uninit(&nd_table[i]);
+}
+
+static void destroy_bdrvs(int slot)
+{
+ int i;
+ struct BlockDriverState *bs;
+
+ for (i = 0; i <= MAX_DRIVES; i++) {
+ bs = drives_table[i].bdrv;
+ if (bs && (PCI_SLOT(bs->devfn) == slot)) {
+ drive_uninit(bs);
+ bdrv_delete(bs);
+ }
+ }
+}
+
+/*
+ * OS has executed _EJ0 method, we now can remove the device
+ */
+void device_hot_remove_success(int slot)
+{
+ PCIDevice *d = pci_find_device(0, slot);
+ int class_code;
+
+ if (!d) {
+ term_printf("invalid slot %d\n", slot);
+ return;
+ }
+
+ class_code = d->config_read(d, PCI_CLASS_DEVICE+1, 1);
+
+ pci_unregister_device(d);
+
+ switch(class_code) {
+ case PCI_BASE_CLASS_STORAGE:
+ destroy_bdrvs(slot);
+ break;
+ case PCI_BASE_CLASS_NETWORK:
+ destroy_nic(slot);
+ break;
+ }
+
+}
Index: kvm-userspace.hotplug/qemu/sysemu.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug/qemu/sysemu.h
@@ -178,6 +178,8 @@ void qemu_system_device_hot_add(int slot
/* device-hotplug */
void device_hot_add(const char *type, const char *opts);
+void device_hot_remove(int slot);
+void device_hot_remove_success(int slot);
/* vmchannel devices */
Index: kvm-userspace.hotplug/qemu/hw/acpi.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/acpi.c
+++ kvm-userspace.hotplug/qemu/hw/acpi.c
@@ -673,6 +673,8 @@ static void pciej_write(void *opaque, ui
{
int slot = ffs(val) - 1;
+ device_hot_remove_success(slot);
+
#if defined(DEBUG)
printf("pciej write %lx <== %d\n", addr, val);
#endif
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [patch 23/23] QEMU/KVM: device hot-remove
2008-03-04 18:34 ` [patch 23/23] QEMU/KVM: device hot-remove Marcelo Tosatti
@ 2008-03-04 19:18 ` Daniel P. Berrange
2008-03-04 19:32 ` Anthony Liguori
2008-03-05 6:47 ` Avi Kivity
1 sibling, 1 reply; 39+ messages in thread
From: Daniel P. Berrange @ 2008-03-04 19:18 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm-devel, Avi Kivity, Glauber Costa
On Tue, Mar 04, 2008 at 03:34:42PM -0300, Marcelo Tosatti wrote:
> Add monitor command to hot-remove devices.
>
> Remove device data on _EJ0 notification.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> Index: kvm-userspace.hotplug/qemu/monitor.c
> ===================================================================
> --- kvm-userspace.hotplug.orig/qemu/monitor.c
> +++ kvm-userspace.hotplug/qemu/monitor.c
> @@ -1355,6 +1355,7 @@ static term_cmd_t term_cmds[] = {
> "value", "set maximum speed (in bytes) for migrations" },
> { "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]", "change cpu state" },
> { "pci_add", "ss", device_hot_add, "nic|drive [vlan=n][,macaddr=addr][,model=type] [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]", "hotadd PCI device" },
> + { "pci_remove", "i", device_hot_remove, "slot number", "hot remove PCI device" },
> { NULL, NULL, },
Removing based on pci device number is very un-pleasant, since its not something
the user of the monitor cares about. Nor do they even know what the PCI device number
assigned by 'pci_add' is.
As with addition, I'd like separate commands for NIC vs Drive, and for the removal
key to be based upon the same data used for addition. eg so one can remove the
NIC based on its MAC address, or remove the drive based on the (if,bus,unit,filename)
data items.
nic_remove [vlan=n][,macaddr=addr][,model=type]
drive_remove [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]
Though, perhaps still allow removal based on the PCI device ID as an alternative
for those who happen to have that data available.
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [patch 23/23] QEMU/KVM: device hot-remove
2008-03-04 19:18 ` Daniel P. Berrange
@ 2008-03-04 19:32 ` Anthony Liguori
2008-03-04 20:00 ` Marcelo Tosatti
2008-03-05 5:46 ` Avi Kivity
0 siblings, 2 replies; 39+ messages in thread
From: Anthony Liguori @ 2008-03-04 19:32 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: kvm-devel, Marcelo Tosatti, Avi Kivity, Glauber Costa
Daniel P. Berrange wrote:
> Removing based on pci device number is very un-pleasant, since its not something
> the user of the monitor cares about. Nor do they even know what the PCI device number
> assigned by 'pci_add' is.
>
> As with addition, I'd like separate commands for NIC vs Drive, and for the removal
> key to be based upon the same data used for addition. eg so one can remove the
> NIC based on its MAC address, or remove the drive based on the (if,bus,unit,filename)
> data items.
>
> nic_remove [vlan=n][,macaddr=addr][,model=type]
> drive_remove [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]
>
> Though, perhaps still allow removal based on the PCI device ID as an alternative
> for those who happen to have that data available.
>
pci_remove is consistent with usb_del and things like stopcapture. The
thing to add would be an "info pci" that let a user associate the slot
number with higher level information about the device.
Regards,
Anthony Liguori
> Regards,
> Dan.
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch 23/23] QEMU/KVM: device hot-remove
2008-03-04 19:32 ` Anthony Liguori
@ 2008-03-04 20:00 ` Marcelo Tosatti
2008-03-04 20:06 ` Daniel P. Berrange
2008-03-05 5:46 ` Avi Kivity
1 sibling, 1 reply; 39+ messages in thread
From: Marcelo Tosatti @ 2008-03-04 20:00 UTC (permalink / raw)
To: Anthony Liguori; +Cc: kvm-devel, Avi Kivity, Glauber Costa
On Tue, Mar 04, 2008 at 01:32:22PM -0600, Anthony Liguori wrote:
> Daniel P. Berrange wrote:
> >Removing based on pci device number is very un-pleasant, since its not
> >something
> >the user of the monitor cares about. Nor do they even know what the PCI
> >device number
> >assigned by 'pci_add' is.
> >
> >As with addition, I'd like separate commands for NIC vs Drive, and for the
> >removal
> >key to be based upon the same data used for addition. eg so one can remove
> >the
> >NIC based on its MAC address, or remove the drive based on the
> >(if,bus,unit,filename)
> >data items.
> >
> > nic_remove [vlan=n][,macaddr=addr][,model=type]
> > drive_remove [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]
> >
> >Though, perhaps still allow removal based on the PCI device ID as an
> >alternative
> >for those who happen to have that data available.
> >
>
> pci_remove is consistent with usb_del and things like stopcapture. The
> thing to add would be an "info pci" that let a user associate the slot
> number with higher level information about the device.
Its there already:
(qemu) info pci
Bus 0, device 0, function 0:
Host bridge: PCI device 8086:1237
Bus 0, device 1, function 0:
ISA bridge: PCI device 8086:7000
Bus 0, device 1, function 1:
IDE controller: PCI device 8086:7010
BAR4: I/O at 0xc000 [0xc00f].
Bus 0, device 1, function 3:
Bridge: PCI device 8086:7113
IRQ 9.
Bus 0, device 2, function 0:
VGA controller: PCI device 1013:00b8
BAR0: 32 bit memory at 0xf0000000 [0xf1ffffff].
BAR1: 32 bit memory at 0xf2000000 [0xf2000fff].
Bus 0, device 3, function 0:
Ethernet controller: PCI device 10ec:8139
IRQ 11.
BAR0: I/O at 0xc100 [0xc1ff].
BAR1: 32 bit memory at 0xf2001000 [0xf20010ff].
And block,network:
(qemu) info block
ide0-hd0: type=hd removable=0 file=/root/images/marcelo5.img ro=0 drv=raw
ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]
floppy0: type=floppy removable=1 locked=0 [not inserted]
sd0: type=floppy removable=1 locked=0 [not inserted]
scsi0-hd0: type=hd removable=0 file=/tmp/bigfile ro=0 drv=raw
scsi0-hd1: type=hd removable=0 file=/tmp/bigfile.2 ro=0 drv=raw
(qemu) info network
VLAN 0 devices:
tap: ifname=tap0 setup_script=qemu-ifup-tap0
rtl8139 pci macaddr=52:54:00:12:34:56
Perhaps reporting the <bus,slot> pair for PCI devices on block and
network info provides the necessary information that you need Dan?
Oh, and unit,bus,media for block too.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [patch 23/23] QEMU/KVM: device hot-remove
2008-03-04 20:00 ` Marcelo Tosatti
@ 2008-03-04 20:06 ` Daniel P. Berrange
2008-03-05 6:28 ` Avi Kivity
0 siblings, 1 reply; 39+ messages in thread
From: Daniel P. Berrange @ 2008-03-04 20:06 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm-devel, Avi Kivity, Glauber Costa
On Tue, Mar 04, 2008 at 05:00:09PM -0300, Marcelo Tosatti wrote:
> On Tue, Mar 04, 2008 at 01:32:22PM -0600, Anthony Liguori wrote:
> > Daniel P. Berrange wrote:
> > >
> > > nic_remove [vlan=n][,macaddr=addr][,model=type]
> > > drive_remove [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]
> > >
> > >Though, perhaps still allow removal based on the PCI device ID as an
> > >alternative
> > >for those who happen to have that data available.
> > >
> >
> > pci_remove is consistent with usb_del and things like stopcapture. The
> > thing to add would be an "info pci" that let a user associate the slot
> > number with higher level information about the device.
>
> Its there already:
>
> (qemu) info pci
> Bus 0, device 0, function 0:
> Host bridge: PCI device 8086:1237
> Bus 0, device 1, function 0:
> ISA bridge: PCI device 8086:7000
> Bus 0, device 1, function 1:
> IDE controller: PCI device 8086:7010
> BAR4: I/O at 0xc000 [0xc00f].
> Bus 0, device 1, function 3:
> Bridge: PCI device 8086:7113
> IRQ 9.
> Bus 0, device 2, function 0:
> VGA controller: PCI device 1013:00b8
> BAR0: 32 bit memory at 0xf0000000 [0xf1ffffff].
> BAR1: 32 bit memory at 0xf2000000 [0xf2000fff].
> Bus 0, device 3, function 0:
> Ethernet controller: PCI device 10ec:8139
> IRQ 11.
> BAR0: I/O at 0xc100 [0xc1ff].
> BAR1: 32 bit memory at 0xf2001000 [0xf20010ff].
>
> And block,network:
>
> (qemu) info block
> ide0-hd0: type=hd removable=0 file=/root/images/marcelo5.img ro=0 drv=raw
> ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]
> floppy0: type=floppy removable=1 locked=0 [not inserted]
> sd0: type=floppy removable=1 locked=0 [not inserted]
> scsi0-hd0: type=hd removable=0 file=/tmp/bigfile ro=0 drv=raw
> scsi0-hd1: type=hd removable=0 file=/tmp/bigfile.2 ro=0 drv=raw
>
> (qemu) info network
> VLAN 0 devices:
> tap: ifname=tap0 setup_script=qemu-ifup-tap0
> rtl8139 pci macaddr=52:54:00:12:34:56
This is utterly horrible for a human to parse & use if they're using the
QEMU monitor, let alone something that libvirt could parse. In fact this
doesn't let you map between the network device & pci device if there is
more than one device added because 'info pci' doesn't show the MAC address
info, and 'info network' does not show any PCI device number info - the
same for disks.
> Perhaps reporting the <bus,slot> pair for PCI devices on block and
> network info provides the necessary information that you need Dan?
> Oh, and unit,bus,media for block too.
Yes, getting PCI (bus,slot,func) triple reported against each line in the
'info block' and 'info network' data would at least let you reliably map
from NIC -> PCI devs.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch 23/23] QEMU/KVM: device hot-remove
2008-03-04 20:06 ` Daniel P. Berrange
@ 2008-03-05 6:28 ` Avi Kivity
0 siblings, 0 replies; 39+ messages in thread
From: Avi Kivity @ 2008-03-05 6:28 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: Marcelo Tosatti, kvm-devel, Glauber Costa
Daniel P. Berrange wrote:
>> (qemu) info block
>> ide0-hd0: type=hd removable=0 file=/root/images/marcelo5.img ro=0 drv=raw
>> ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]
>> floppy0: type=floppy removable=1 locked=0 [not inserted]
>> sd0: type=floppy removable=1 locked=0 [not inserted]
>> scsi0-hd0: type=hd removable=0 file=/tmp/bigfile ro=0 drv=raw
>> scsi0-hd1: type=hd removable=0 file=/tmp/bigfile.2 ro=0 drv=raw
>>
>> (qemu) info network
>> VLAN 0 devices:
>> tap: ifname=tap0 setup_script=qemu-ifup-tap0
>> rtl8139 pci macaddr=52:54:00:12:34:56
>>
>
> This is utterly horrible for a human to parse & use if they're using the
> QEMU monitor, let alone something that libvirt could parse. In fact this
> doesn't let you map between the network device & pci device if there is
> more than one device added because 'info pci' doesn't show the MAC address
> info, and 'info network' does not show any PCI device number info - the
> same for disks.
>
>
We need a machine friendly protocol for libvirt and other management
tools. Versioned commands (with some backward compatibility), command
discovery, and command/response tagging so you can associate an async
reply to the command that triggered it, and quoting so that strings with
spaces and other special chars are properly supported. But how the
information is presented is orthogonal to what information is presented.
btw, the qemu command line parses something fairly similar, I don't see
why libvirt should have problems with it. It wouldn't be fun to code,
but is doable.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch 23/23] QEMU/KVM: device hot-remove
2008-03-04 19:32 ` Anthony Liguori
2008-03-04 20:00 ` Marcelo Tosatti
@ 2008-03-05 5:46 ` Avi Kivity
1 sibling, 0 replies; 39+ messages in thread
From: Avi Kivity @ 2008-03-05 5:46 UTC (permalink / raw)
To: Anthony Liguori; +Cc: kvm-devel, Marcelo Tosatti, Glauber Costa
Anthony Liguori wrote:
> Daniel P. Berrange wrote:
>> Removing based on pci device number is very un-pleasant, since its
>> not something
>> the user of the monitor cares about. Nor do they even know what the
>> PCI device number
>> assigned by 'pci_add' is.
>>
>> As with addition, I'd like separate commands for NIC vs Drive, and
>> for the removal
>> key to be based upon the same data used for addition. eg so one can
>> remove the
>> NIC based on its MAC address, or remove the drive based on the
>> (if,bus,unit,filename)
>> data items.
>>
>> nic_remove [vlan=n][,macaddr=addr][,model=type]
>> drive_remove
>> [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]
>>
>> Though, perhaps still allow removal based on the PCI device ID as an
>> alternative
>> for those who happen to have that data available.
>>
>
> pci_remove is consistent with usb_del and things like stopcapture.
> The thing to add would be an "info pci" that let a user associate the
> slot number with higher level information about the device.
>
pci_add should return the slot information, which can later be used as
an identifier for pci_remove. It would also be nice to be able to
specify the slot in pci_add, though I hardly have a compelling use case
for that.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch 23/23] QEMU/KVM: device hot-remove
2008-03-04 18:34 ` [patch 23/23] QEMU/KVM: device hot-remove Marcelo Tosatti
2008-03-04 19:18 ` Daniel P. Berrange
@ 2008-03-05 6:47 ` Avi Kivity
1 sibling, 0 replies; 39+ messages in thread
From: Avi Kivity @ 2008-03-05 6:47 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm-devel, Glauber Costa
Marcelo Tosatti wrote:
> Add monitor command to hot-remove devices.
>
> Remove device data on _EJ0 notification.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> Index: kvm-userspace.hotplug/qemu/monitor.c
> ===================================================================
> --- kvm-userspace.hotplug.orig/qemu/monitor.c
> +++ kvm-userspace.hotplug/qemu/monitor.c
> @@ -1355,6 +1355,7 @@ static term_cmd_t term_cmds[] = {
> "value", "set maximum speed (in bytes) for migrations" },
> { "cpu_set", "is", do_cpu_set_nr, "cpu [online|offline]", "change cpu state" },
> { "pci_add", "ss", device_hot_add, "nic|drive [vlan=n][,macaddr=addr][,model=type] [[file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]]", "hotadd PCI device" },
> + { "pci_remove", "i", device_hot_remove, "slot number", "hot remove PCI device" },
> { NULL, NULL, },
>
Should be pci_del for consistency with usb_del.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
` (22 preceding siblings ...)
2008-03-04 18:34 ` [patch 23/23] QEMU/KVM: device hot-remove Marcelo Tosatti
@ 2008-03-05 6:00 ` Avi Kivity
23 siblings, 0 replies; 39+ messages in thread
From: Avi Kivity @ 2008-03-05 6:00 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm-devel, Glauber Costa
Marcelo Tosatti wrote:
> The following patchset adds ACPI PCI hotplug support for QEMU.
>
> It extends the number of slots with IRQ routing information from 6 to 32.
>
> The only PCI driver which the unregister method has been added is LSI SCSI, would
> like more comments to implement that for the remaining drivers.
>
>
Very nice patchset, looks minimally intrusive for such complex
functionality.
Please post the next iteration on qemu-devel to see if they have any
objections. Since this is a large patchset, I don't want to keep it
churning for too long, so if you prefer, you can rip out drive hotplug
and add it back later (see my comments to patch 14).
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 39+ messages in thread