* [Qemu-devel] [PATCH v2 1/4] hw/arm/virt: separate versioned type-init code
2016-06-12 15:51 [Qemu-devel] [PATCH v2 0/4] create the mach-virt 2.7 machine type Andrew Jones
@ 2016-06-12 15:51 ` Andrew Jones
2016-06-12 15:51 ` [Qemu-devel] [PATCH v2 2/4] hw/arm/virt: introduce DEFINE_VIRT_MACHINE Andrew Jones
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andrew Jones @ 2016-06-12 15:51 UTC (permalink / raw)
To: qemu-devel, qemu-arm; +Cc: peter.maydell, alex.bennee, wei
Rename machvirt_info (which is specifically for 2.6 TypeInfo)
to machvirt_2_6_info, and separate the type registration of the
abstract machine type from the versioned type.
Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/virt.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 73113cfc4d9c9..57eb7fef251bd 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1387,6 +1387,12 @@ static const TypeInfo virt_machine_info = {
.class_init = virt_machine_class_init,
};
+static void machvirt_machine_init(void)
+{
+ type_register_static(&virt_machine_info);
+}
+type_init(machvirt_machine_init);
+
static void virt_2_6_instance_init(Object *obj)
{
VirtMachineState *vms = VIRT_MACHINE(obj);
@@ -1428,17 +1434,15 @@ static void virt_2_6_class_init(ObjectClass *oc, void *data)
mc->alias = "virt";
}
-static const TypeInfo machvirt_info = {
+static const TypeInfo machvirt_2_6_info = {
.name = MACHINE_TYPE_NAME("virt-2.6"),
.parent = TYPE_VIRT_MACHINE,
.instance_init = virt_2_6_instance_init,
.class_init = virt_2_6_class_init,
};
-static void machvirt_machine_init(void)
+static void machvirt_machine_2_6_init(void)
{
- type_register_static(&virt_machine_info);
- type_register_static(&machvirt_info);
+ type_register_static(&machvirt_2_6_info);
}
-
-type_init(machvirt_machine_init);
+type_init(machvirt_machine_2_6_init);
--
2.4.11
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v2 2/4] hw/arm/virt: introduce DEFINE_VIRT_MACHINE
2016-06-12 15:51 [Qemu-devel] [PATCH v2 0/4] create the mach-virt 2.7 machine type Andrew Jones
2016-06-12 15:51 ` [Qemu-devel] [PATCH v2 1/4] hw/arm/virt: separate versioned type-init code Andrew Jones
@ 2016-06-12 15:51 ` Andrew Jones
2016-06-12 15:51 ` [Qemu-devel] [PATCH v2 3/4] hw/arm/virt: introduce DEFINE_VIRT_MACHINE_AS_LATEST Andrew Jones
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andrew Jones @ 2016-06-12 15:51 UTC (permalink / raw)
To: qemu-devel, qemu-arm; +Cc: peter.maydell, alex.bennee, wei
Use DEFINE_VIRT_MACHINE to generate versioned machine type info.
Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/virt.c | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 57eb7fef251bd..054c31006aa2a 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -98,6 +98,28 @@ typedef struct {
#define VIRT_MACHINE_CLASS(klass) \
OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE)
+
+#define DEFINE_VIRT_MACHINE(major, minor) \
+ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
+ void *data) \
+ { \
+ MachineClass *mc = MACHINE_CLASS(oc); \
+ virt_machine_##major##_##minor##_options(mc); \
+ mc->desc = "QEMU " # major "." # minor " ARM Virtual Machine"; \
+ } \
+ static const TypeInfo machvirt_##major##_##minor##_info = { \
+ .name = MACHINE_TYPE_NAME("virt-" # major "." # minor), \
+ .parent = TYPE_VIRT_MACHINE, \
+ .instance_init = virt_##major##_##minor##_instance_init, \
+ .class_init = virt_##major##_##minor##_class_init, \
+ }; \
+ static void machvirt_machine_##major##_##minor##_init(void) \
+ { \
+ type_register_static(&machvirt_##major##_##minor##_info); \
+ } \
+ type_init(machvirt_machine_##major##_##minor##_init);
+
+
/* RAM limit in GB. Since VIRT_MEM starts at the 1GB mark, this means
* RAM can go up to the 256GB mark, leaving 256GB of the physical
* address space unallocated and free for future use between 256G and 512G.
@@ -1426,23 +1448,8 @@ static void virt_2_6_instance_init(Object *obj)
"Valid values are 2, 3 and host", NULL);
}
-static void virt_2_6_class_init(ObjectClass *oc, void *data)
+static void virt_machine_2_6_options(MachineClass *mc)
{
- MachineClass *mc = MACHINE_CLASS(oc);
-
- mc->desc = "QEMU 2.6 ARM Virtual Machine";
mc->alias = "virt";
}
-
-static const TypeInfo machvirt_2_6_info = {
- .name = MACHINE_TYPE_NAME("virt-2.6"),
- .parent = TYPE_VIRT_MACHINE,
- .instance_init = virt_2_6_instance_init,
- .class_init = virt_2_6_class_init,
-};
-
-static void machvirt_machine_2_6_init(void)
-{
- type_register_static(&machvirt_2_6_info);
-}
-type_init(machvirt_machine_2_6_init);
+DEFINE_VIRT_MACHINE(2, 6)
--
2.4.11
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v2 3/4] hw/arm/virt: introduce DEFINE_VIRT_MACHINE_AS_LATEST
2016-06-12 15:51 [Qemu-devel] [PATCH v2 0/4] create the mach-virt 2.7 machine type Andrew Jones
2016-06-12 15:51 ` [Qemu-devel] [PATCH v2 1/4] hw/arm/virt: separate versioned type-init code Andrew Jones
2016-06-12 15:51 ` [Qemu-devel] [PATCH v2 2/4] hw/arm/virt: introduce DEFINE_VIRT_MACHINE Andrew Jones
@ 2016-06-12 15:51 ` Andrew Jones
2016-06-12 15:51 ` [Qemu-devel] [PATCH v2 4/4] hw/arm/virt: create the 2.7 machine type Andrew Jones
2016-06-14 12:51 ` [Qemu-devel] [PATCH v2 0/4] create the mach-virt " Peter Maydell
4 siblings, 0 replies; 6+ messages in thread
From: Andrew Jones @ 2016-06-12 15:51 UTC (permalink / raw)
To: qemu-devel, qemu-arm; +Cc: peter.maydell, alex.bennee, wei
Create two variants of DEFINE_VIRT_MACHINE. One, just called
DEFINE_VIRT_MACHINE, that does not set properties that only
the latest machine type should have, and another that does.
This will hopefully reduce potential for errors when adding
new versions.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
hw/arm/virt.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 054c31006aa2a..df88eeb4d2ca0 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -99,13 +99,16 @@ typedef struct {
OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE)
-#define DEFINE_VIRT_MACHINE(major, minor) \
+#define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
void *data) \
{ \
MachineClass *mc = MACHINE_CLASS(oc); \
virt_machine_##major##_##minor##_options(mc); \
mc->desc = "QEMU " # major "." # minor " ARM Virtual Machine"; \
+ if (latest) { \
+ mc->alias = "virt"; \
+ } \
} \
static const TypeInfo machvirt_##major##_##minor##_info = { \
.name = MACHINE_TYPE_NAME("virt-" # major "." # minor), \
@@ -119,6 +122,11 @@ typedef struct {
} \
type_init(machvirt_machine_##major##_##minor##_init);
+#define DEFINE_VIRT_MACHINE_AS_LATEST(major, minor) \
+ DEFINE_VIRT_MACHINE_LATEST(major, minor, true)
+#define DEFINE_VIRT_MACHINE(major, minor) \
+ DEFINE_VIRT_MACHINE_LATEST(major, minor, false)
+
/* RAM limit in GB. Since VIRT_MEM starts at the 1GB mark, this means
* RAM can go up to the 256GB mark, leaving 256GB of the physical
@@ -1450,6 +1458,5 @@ static void virt_2_6_instance_init(Object *obj)
static void virt_machine_2_6_options(MachineClass *mc)
{
- mc->alias = "virt";
}
-DEFINE_VIRT_MACHINE(2, 6)
+DEFINE_VIRT_MACHINE_AS_LATEST(2, 6)
--
2.4.11
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v2 4/4] hw/arm/virt: create the 2.7 machine type
2016-06-12 15:51 [Qemu-devel] [PATCH v2 0/4] create the mach-virt 2.7 machine type Andrew Jones
` (2 preceding siblings ...)
2016-06-12 15:51 ` [Qemu-devel] [PATCH v2 3/4] hw/arm/virt: introduce DEFINE_VIRT_MACHINE_AS_LATEST Andrew Jones
@ 2016-06-12 15:51 ` Andrew Jones
2016-06-14 12:51 ` [Qemu-devel] [PATCH v2 0/4] create the mach-virt " Peter Maydell
4 siblings, 0 replies; 6+ messages in thread
From: Andrew Jones @ 2016-06-12 15:51 UTC (permalink / raw)
To: qemu-devel, qemu-arm; +Cc: peter.maydell, alex.bennee, wei
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
hw/arm/virt.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index df88eeb4d2ca0..d266ad7b943e3 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -42,6 +42,7 @@
#include "sysemu/sysemu.h"
#include "sysemu/kvm.h"
#include "hw/boards.h"
+#include "hw/compat.h"
#include "hw/loader.h"
#include "exec/address-spaces.h"
#include "qemu/bitops.h"
@@ -1423,7 +1424,7 @@ static void machvirt_machine_init(void)
}
type_init(machvirt_machine_init);
-static void virt_2_6_instance_init(Object *obj)
+static void virt_2_7_instance_init(Object *obj)
{
VirtMachineState *vms = VIRT_MACHINE(obj);
@@ -1456,7 +1457,22 @@ static void virt_2_6_instance_init(Object *obj)
"Valid values are 2, 3 and host", NULL);
}
+static void virt_machine_2_7_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(2, 7)
+
+#define VIRT_COMPAT_2_6 \
+ HW_COMPAT_2_6
+
+static void virt_2_6_instance_init(Object *obj)
+{
+ virt_2_7_instance_init(obj);
+}
+
static void virt_machine_2_6_options(MachineClass *mc)
{
+ virt_machine_2_7_options(mc);
+ SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_6);
}
-DEFINE_VIRT_MACHINE_AS_LATEST(2, 6)
+DEFINE_VIRT_MACHINE(2, 6)
--
2.4.11
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/4] create the mach-virt 2.7 machine type
2016-06-12 15:51 [Qemu-devel] [PATCH v2 0/4] create the mach-virt 2.7 machine type Andrew Jones
` (3 preceding siblings ...)
2016-06-12 15:51 ` [Qemu-devel] [PATCH v2 4/4] hw/arm/virt: create the 2.7 machine type Andrew Jones
@ 2016-06-14 12:51 ` Peter Maydell
4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2016-06-14 12:51 UTC (permalink / raw)
To: Andrew Jones; +Cc: QEMU Developers, qemu-arm, Alex Bennée, Wei Huang
On 12 June 2016 at 16:51, Andrew Jones <drjones@redhat.com> wrote:
> v2:
> - drop 'is_default' setting [Peter]
> - fix checkpatch warning [Peter]
> - add a couple R-b's
>
> This is the first new machine type mach-virt has received
> (2.6 being the first versioned machine type), so we need to
> do a bit more than the average "new machine type" patch.
> The first four patches prepare for easy-adding of machine
> types. The last patch adds the 2.7 type.
>
>
> Andrew Jones (4):
> hw/arm/virt: separate versioned type-init code
> hw/arm/virt: introduce DEFINE_VIRT_MACHINE
> hw/arm/virt: introduce DEFINE_VIRT_MACHINE_AS_LATEST
> hw/arm/virt: create the 2.7 machine type
>
> hw/arm/virt.c | 66 ++++++++++++++++++++++++++++++++++++++++++++---------------
> 1 file changed, 50 insertions(+), 16 deletions(-)
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread