Skip to contentSkip to conversation

Remove hardcoded xen-platform device initialization (v2)

PATCH In review Paul Durrant 2 participants 9 messages Jun 17, 2013 – Jun 18, 2013

lore
Share & tools
lore
#0 lore raw

cover Remove hardcoded xen-platform device initialization (v2)

Because of concerns over backwards compatibility and a suggestion that xenfv should be retired in favour of using the pc machine type I have re- worked my original patch into 2 patches:

[PATCH 1/2] Allow use of pc machine type (accel=xen) for Xen HVM [PATCH 2/2] Move hardcoded initialization of xen-platform device.

Application of both these patches allows alternative pc machine types to be used with the accel=xen option, but preserves the hardcoded creation of the xen-platform device only for machine type xenfv.

#1 lore raw

PATCH 1/2 Allow use of pc machine type (accel=xen) for Xen HVM domains.

Xen HVM domains normally spawn QEMU with a dedicated xenfv machine type. The initialization code for this machine type can easily be pulled into the generic pc initialization code and guarded with a test for whether the xen accelerator options is specified, which is more consistent with the way other accelerators are used.

---
 hw/i386/pc_piix.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +4 -3
index d618570..6d3f161 100644
@@ -91,6 +91,10 @@ static void pc_init1(MemoryRegion *system_memory,
     DeviceState *icc_bridge;
     FWCfgState *fw_cfg = NULL;
 
+    if (xen_hvm_init() != 0) {
+        hw_error("xen hardware virtual machine initialisation failed");
+    }
+
     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
@@ -320,9 +324,6 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 {
-    if (xen_hvm_init() != 0) {
-        hw_error("xen hardware virtual machine initialisation failed");
-    }
     pc_init_pci(args);
 }
 #endif
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 1/2 Allow use of pc machine type (accel=xen) for Xen HVM domains.

In reply to Paul Durrant

Xen HVM domains normally spawn QEMU with a dedicated xenfv machine type. The initialization code for this machine type can easily be pulled into the generic pc initialization code and guarded with a test for whether the xen accelerator options is specified, which is more consistent with the way other accelerators are used.

---
 hw/i386/pc_piix.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +4 -3
index d618570..6d3f161 100644
@@ -91,6 +91,10 @@ static void pc_init1(MemoryRegion *system_memory,
     DeviceState *icc_bridge;
     FWCfgState *fw_cfg = NULL;
 
+    if (xen_hvm_init() != 0) {
+        hw_error("xen hardware virtual machine initialisation failed");
+    }
+
     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
@@ -320,9 +324,6 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 {
-    if (xen_hvm_init() != 0) {
-        hw_error("xen hardware virtual machine initialisation failed");
-    }
     pc_init_pci(args);
 }
 #endif
Signature · 1 line
1.7.10.4
#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] Allow use of pc machine type (accel=xen) for Xen HVM domains.

Quoted 16 lines · On Mon, 17 Jun 2013 13:36:36 +0100 Paul Durrant <[email protected]> wrote:

Xen HVM domains normally spawn QEMU with a dedicated xenfv machine type. The initialization code for this machine type can easily be pulled into the generic pc initialization code and guarded with a test for whether the xen accelerator options is specified, which is more consistent with the way other accelerators are used.

---
 hw/i386/pc_piix.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +0 -0
index d618570..6d3f161 100644

hw/i386/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 97

Quoted 7 lines
hw/i386/pc_piix.c +4 -0
@@ -91,6 +91,10 @@ static void pc_init1(MemoryRegion *system_memory,
     DeviceState *icc_bridge;
     FWCfgState *fw_cfg = NULL;
 
+    if (xen_hvm_init() != 0) {
+        hw_error("xen hardware virtual machine initialisation failed");
+    }
+

would it work if starting QEMU without xen?

Quoted 17 lines
hw/i386/pc_piix.c +0 -3
     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
@@ -320,9 +324,6 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 {
-    if (xen_hvm_init() != 0) {
-        hw_error("xen hardware virtual machine initialisation failed");
-    }
     pc_init_pci(args);
 }
 #endif
Signature · 1 line
1.7.10.4
Signature · 2 lines
Regards,
  Igor
#4 lore raw

Re: [Qemu-devel] [PATCH 1/2] Allow use of pc machine type (accel=xen) for Xen HVM domains.

In reply to Paul Durrant
Quoted 16 lines · On Mon, 17 Jun 2013 13:36:36 +0100 Paul Durrant <[email protected]> wrote:

Xen HVM domains normally spawn QEMU with a dedicated xenfv machine type. The initialization code for this machine type can easily be pulled into the generic pc initialization code and guarded with a test for whether the xen accelerator options is specified, which is more consistent with the way other accelerators are used.

---
 hw/i386/pc_piix.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +0 -0
index d618570..6d3f161 100644

hw/i386/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 97

Quoted 7 lines
hw/i386/pc_piix.c +4 -0
@@ -91,6 +91,10 @@ static void pc_init1(MemoryRegion *system_memory,
     DeviceState *icc_bridge;
     FWCfgState *fw_cfg = NULL;
 
+    if (xen_hvm_init() != 0) {
+        hw_error("xen hardware virtual machine initialisation failed");
+    }
+

would it work if starting QEMU without xen?

Quoted 17 lines
hw/i386/pc_piix.c +0 -3
     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
@@ -320,9 +324,6 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 {
-    if (xen_hvm_init() != 0) {
-        hw_error("xen hardware virtual machine initialisation failed");
-    }
     pc_init_pci(args);
 }
 #endif
Signature · 1 line
1.7.10.4
Signature · 2 lines
Regards,
  Igor
#5 lore raw

Re: [Qemu-devel] [PATCH 1/2] Allow use of pc machine type (accel=xen) for Xen HVM domains.

Quoted 29 lines

-----Original Message-----
From: Igor Mammedov [mailto:[email protected]]
Sent: 18 June 2013 10:44
To: Paul Durrant
Cc: [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH 1/2] Allow use of pc machine type (accel=xen) for Xen HVM domains.

Quoted 1 line · On Mon, 17 Jun 2013 13:36:36 +0100 Paul Durrant <[email protected]> wrote:

Xen HVM domains normally spawn QEMU with a dedicated xenfv machine

type. The

hw/i386/pc_piix.c static void pc_init1(MemoryRegion

Quoted 15 lines

initialization code for this machine type can easily be pulled into the generic pc initialization code and guarded with a test for whether the xen accelerator options is specified, which is more consistent with the way other accelerators are used.

---
 hw/i386/pc_piix.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +0 -0
index d618570..6d3f161 100644
@@ -91,6 +91,10 @@ static void pc_init1(MemoryRegion

*system_memory,

Quoted 9 lines

hw/i386/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 97

Quoted 7 lines
hw/i386/pc_piix.c +4 -0
     DeviceState *icc_bridge;
     FWCfgState *fw_cfg = NULL;
 
+    if (xen_hvm_init() != 0) {
+        hw_error("xen hardware virtual machine initialisation failed");
+    }
+

would it work if starting QEMU without xen?

Yikes, there's supposed to be a xen_enabled() test there too! Must have got lost when I re-based my patches. I'll fix and re-post.

Paul

Quoted 22 lines
Quoted 14 lines
hw/i386/pc_piix.c +0 -4
     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
@@ -320,9 +324,6 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 {
-    if (xen_hvm_init() != 0) {
-        hw_error("xen hardware virtual machine initialisation failed");
-    }
     pc_init_pci(args);
 }
 #endif
--
Quoted 3 lines

1.7.10.4

--
Regards,
Igor

#6 lore raw

Re: [Qemu-devel] [PATCH 1/2] Allow use of pc machine type (accel=xen) for Xen HVM domains.

In reply to Igor Mammedov
Quoted 29 lines

-----Original Message-----
From: Igor Mammedov [mailto:[email protected]]
Sent: 18 June 2013 10:44
To: Paul Durrant
Cc: [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH 1/2] Allow use of pc machine type (accel=xen) for Xen HVM domains.

Quoted 1 line · On Mon, 17 Jun 2013 13:36:36 +0100 Paul Durrant <[email protected]> wrote:

Xen HVM domains normally spawn QEMU with a dedicated xenfv machine

type. The

hw/i386/pc_piix.c static void pc_init1(MemoryRegion

Quoted 15 lines

initialization code for this machine type can easily be pulled into the generic pc initialization code and guarded with a test for whether the xen accelerator options is specified, which is more consistent with the way other accelerators are used.

---
 hw/i386/pc_piix.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +0 -0
index d618570..6d3f161 100644
@@ -91,6 +91,10 @@ static void pc_init1(MemoryRegion

*system_memory,

Quoted 9 lines

hw/i386/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 97

Quoted 7 lines
hw/i386/pc_piix.c +4 -0
     DeviceState *icc_bridge;
     FWCfgState *fw_cfg = NULL;
 
+    if (xen_hvm_init() != 0) {
+        hw_error("xen hardware virtual machine initialisation failed");
+    }
+

would it work if starting QEMU without xen?

Yikes, there's supposed to be a xen_enabled() test there too! Must have got lost when I re-based my patches. I'll fix and re-post.

Paul

Quoted 22 lines
Quoted 14 lines
hw/i386/pc_piix.c +0 -4
     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
     object_property_add_child(qdev_get_machine(), "icc-bridge",
                               OBJECT(icc_bridge), NULL);
@@ -320,9 +324,6 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 {
-    if (xen_hvm_init() != 0) {
-        hw_error("xen hardware virtual machine initialisation failed");
-    }
     pc_init_pci(args);
 }
 #endif
--
Quoted 3 lines

1.7.10.4

--
Regards,
Igor

#7 lore raw

PATCH 2/2 Move hardcoded initialization of xen-platform device.

In reply to Paul Durrant

Creation of the xen-platform device is currently hardcoded into machine type pc's initialization code, guarded by a test for the whether the xen accelerator is enabled. This patch moves the creation of xen-platform into the initialization code of the xenfv machine type. This maintains backwards compatibility for that machine type but allows more flexibility if another machine type is used with Xen HVM domains.

---
 hw/i386/pc_piix.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +6 -3
index 6d3f161..38d98af 100644
@@ -178,9 +178,6 @@ static void pc_init1(MemoryRegion *system_memory,
     pc_register_ferr_irq(gsi[13]);
 
     pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
-    if (xen_enabled()) {
-        pci_create_simple(pci_bus, -1, "xen-platform");
-    }
 
     /* init basic PC hardware */
     pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled());
@@ -324,7 +321,13 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 {
+    PCIBus *bus;
+
     pc_init_pci(args);
+
+    bus = pci_find_root_bus(0);
+    if (bus != NULL)
+        pci_create_simple(bus, -1, "xen-platform");
 }
 #endif
 
Signature · 1 line
1.7.10.4
#8 lore raw

PATCH 2/2 Move hardcoded initialization of xen-platform device.

In reply to Paul Durrant

Creation of the xen-platform device is currently hardcoded into machine type pc's initialization code, guarded by a test for the whether the xen accelerator is enabled. This patch moves the creation of xen-platform into the initialization code of the xenfv machine type. This maintains backwards compatibility for that machine type but allows more flexibility if another machine type is used with Xen HVM domains.

---
 hw/i386/pc_piix.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
hw/i386/pc_piix.c +6 -3
index 6d3f161..38d98af 100644
@@ -178,9 +178,6 @@ static void pc_init1(MemoryRegion *system_memory,
     pc_register_ferr_irq(gsi[13]);
 
     pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
-    if (xen_enabled()) {
-        pci_create_simple(pci_bus, -1, "xen-platform");
-    }
 
     /* init basic PC hardware */
     pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled());
@@ -324,7 +321,13 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 {
+    PCIBus *bus;
+
     pc_init_pci(args);
+
+    bus = pci_find_root_bus(0);
+    if (bus != NULL)
+        pci_create_simple(bus, -1, "xen-platform");
 }
 #endif
 
Signature · 1 line
1.7.10.4