Skip to contentSkip to conversation

Versioning ARM virt machine types

PATCH Applied Wei Huang 3 participants 7 messages Mar 11, 2016 – Jun 7, 2016

lore
Share & tools
lore

Wei Huang

author
#0 lore raw

cover Versioning ARM virt machine types

We start to see more features been added to ARM virtual machine models. For the purpose of backward compatibility (e.g. migration), it is time to consider versioning machine types for ARM VMs. As a beginning step, this patchset defines an abstract machine type for ARM VMs. The current "virt" machine is re-written based on this new abstract type accordingly. These patches have been verified by booting existing VMs.

RFC->V1:
* Rename the machine type to "virt-2.6", matching the imminent QEMU version
* Remove mc->is_default (Peter's comment)

Thanks,
-Wei

Wei Huang (2):
arm: virt: Add an abstract ARM virt machine type
arm: virt: Move machine class init code to the abstract machine type

 hw/arm/virt.c | 57 ++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 19 deletions(-)
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 2/2 arm: virt: Move machine class init code to the abstract machine type

This patch moves the common class initialization code from "virt-2.6" to the new abstract class. An empty property is added to "virt-2.6" machine. In the meanwhile, related funtions are renamed to "virt_2_6_*" for consistency.

---
 hw/arm/virt.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)
hw/arm/virt.c +20 -14
index be9bbfb..8c3ac0d 100644
@@ -1347,6 +1347,18 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp)
 
 static void virt_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->init = machvirt_init;
+    /* Start max_cpus at the maximum QEMU supports. We'll further restrict
+     * it later in machvirt_init, where we have more information about the
+     * configuration of the particular instance.
+     */
+    mc->max_cpus = MAX_CPUMASK_BITS;
+    mc->has_dynamic_sysbus = true;
+    mc->block_default_type = IF_VIRTIO;
+    mc->no_cdrom = 1;
+    mc->pci_allow_0_address = true;
 }
 
 static const TypeInfo virt_machine_info = {
@@ -1358,7 +1370,7 @@ static const TypeInfo virt_machine_info = {
     .class_init    = virt_machine_class_init,
 };
 
-static void virt_instance_init(Object *obj)
+static void virt_2_6_instance_init(Object *obj)
 {
     VirtMachineState *vms = VIRT_MACHINE(obj);
 
@@ -1391,29 +1403,23 @@ static void virt_instance_init(Object *obj)
                                     "Valid values are 2, 3 and host", NULL);
 }
 
-static void virt_class_init(ObjectClass *oc, void *data)
+static void virt_2_6_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
+    static GlobalProperty compat_props[] = {
+        { /* end of list */ }
+    };
 
     mc->desc = "QEMU 2.6 ARM Virtual Machine";
     mc->alias = "virt";
-    mc->init = machvirt_init;
-    /* Start max_cpus at the maximum QEMU supports. We'll further restrict
-     * it later in machvirt_init, where we have more information about the
-     * configuration of the particular instance.
-     */
-    mc->max_cpus = MAX_CPUMASK_BITS;
-    mc->has_dynamic_sysbus = true;
-    mc->block_default_type = IF_VIRTIO;
-    mc->no_cdrom = 1;
-    mc->pci_allow_0_address = true;
+    mc->compat_props = compat_props;
 }
 
 static const TypeInfo machvirt_info = {
     .name = MACHINE_TYPE_NAME("virt-2.6"),
     .parent = TYPE_VIRT_MACHINE,
-    .instance_init = virt_instance_init,
-    .class_init = virt_class_init,
+    .instance_init = virt_2_6_instance_init,
+    .class_init = virt_2_6_class_init,
 };
 
 static void machvirt_machine_init(void)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/2 arm: virt: Add an abstract ARM virt machine type

In reply to Wei Huang

In preparation for future ARM virt machine types, this patch creates an abstract type for all ARM machines. The current machine type in QEMU (i.e. "virt") is renamed to "virt-2.6", whose naming scheme is similar to other architectures. For the purpose of backward compatibility, "virt" is converted to an alias, pointing to "virt-2.6". With this patch, "qemu -M ?" lists the following virtual machine types along with others:

virt QEMU 2.6 ARM Virtual Machine (alias of virt-2.6)
virt-2.6 QEMU 2.6 ARM Virtual Machine

---
 hw/arm/virt.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
hw/arm/virt.c +18 -5
index 8c6c996..be9bbfb 100644
@@ -1345,6 +1345,19 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp)
     }
 }
 
+static void virt_machine_class_init(ObjectClass *oc, void *data)
+{
+}
+
+static const TypeInfo virt_machine_info = {
+    .name          = TYPE_VIRT_MACHINE,
+    .parent        = TYPE_MACHINE,
+    .abstract      = true,
+    .instance_size = sizeof(VirtMachineState),
+    .class_size    = sizeof(VirtMachineClass),
+    .class_init    = virt_machine_class_init,
+};
+
 static void virt_instance_init(Object *obj)
 {
     VirtMachineState *vms = VIRT_MACHINE(obj);
@@ -1382,7 +1395,8 @@ static void virt_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->desc = "ARM Virtual Machine",
+    mc->desc = "QEMU 2.6 ARM Virtual Machine";
+    mc->alias = "virt";
     mc->init = machvirt_init;
     /* Start max_cpus at the maximum QEMU supports. We'll further restrict
      * it later in machvirt_init, where we have more information about the
@@ -1396,16 +1410,15 @@ static void virt_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo machvirt_info = {
-    .name = TYPE_VIRT_MACHINE,
-    .parent = TYPE_MACHINE,
-    .instance_size = sizeof(VirtMachineState),
+    .name = MACHINE_TYPE_NAME("virt-2.6"),
+    .parent = TYPE_VIRT_MACHINE,
     .instance_init = virt_instance_init,
-    .class_size = sizeof(VirtMachineClass),
     .class_init = virt_class_init,
 };
 
 static void machvirt_machine_init(void)
 {
+    type_register_static(&virt_machine_info);
     type_register_static(&machvirt_info);
 }
 
Signature · 1 line
1.8.3.1
#3 lore raw
In reply to Wei Huang
Quoted 10 lines · Wei Huang

We start to see more features been added to ARM virtual machine models. For the purpose of backward compatibility (e.g. migration), it is time to consider versioning machine types for ARM VMs. As a beginning step, this patchset defines an abstract machine type for ARM VMs. The current "virt" machine is re-written based on this new abstract type accordingly. These patches have been verified by booting existing VMs.

RFC->V1:
* Rename the machine type to "virt-2.6", matching the imminent QEMU version
* Remove mc->is_default (Peter's comment)

Applied to target-arm.next, thanks.

-- PMM

#4 lore raw
In reply to Wei Huang
Quoted 10 lines · Wei Huang

We start to see more features been added to ARM virtual machine models. For the purpose of backward compatibility (e.g. migration), it is time to consider versioning machine types for ARM VMs. As a beginning step, this patchset defines an abstract machine type for ARM VMs. The current "virt" machine is re-written based on this new abstract type accordingly. These patches have been verified by booting existing VMs.

RFC->V1:
* Rename the machine type to "virt-2.6", matching the imminent QEMU version
* Remove mc->is_default (Peter's comment)

So is there a plan to provide a virt-2.7 for the next release?

thanks
-- PMM

#5 lore raw
Quoted 8 lines · Peter Maydell
Quoted 7 lines · Wei Huang

We start to see more features been added to ARM virtual machine models. For the purpose of backward compatibility (e.g. migration), it is time to consider versioning machine types for ARM VMs. As a beginning step, this patchset defines an abstract machine type for ARM VMs. The current "virt" machine is re-written based on this new abstract type accordingly. These patches have been verified by booting existing VMs.

Quoted 5 lines
Quoted 3 lines

RFC->V1:
* Rename the machine type to "virt-2.6", matching the imminent QEMU version
* Remove mc->is_default (Peter's comment)

So is there a plan to provide a virt-2.7 for the next release?

Yup. I was planning to send it as part of a small "hw/arm/virt: add cpu-map" series I pretty much have ready, but didn't finish and send yet because I got distracted working on the larger plan (among other things). The motivation (larger plan) for cpu-map is full cpu-topology configuration, but working on that has led to an smp parameter rework RFC (hoping to send this week...) Wei or I can just send the virt-2.7 patch now though to get it done sooner than later.

Thanks,
drew

author
#6 lore raw
Quoted 15 lines · Andrew Jones
Quoted 8 lines · Peter Maydell
Quoted 7 lines · Wei Huang

We start to see more features been added to ARM virtual machine models. For the purpose of backward compatibility (e.g. migration), it is time to consider versioning machine types for ARM VMs. As a beginning step, this patchset defines an abstract machine type for ARM VMs. The current "virt" machine is re-written based on this new abstract type accordingly. These patches have been verified by booting existing VMs.

Quoted 5 lines
Quoted 3 lines

RFC->V1:
* Rename the machine type to "virt-2.6", matching the imminent QEMU version
* Remove mc->is_default (Peter's comment)

So is there a plan to provide a virt-2.7 for the next release?

Quoted 7 lines

Yup. I was planning to send it as part of a small "hw/arm/virt: add cpu-map" series I pretty much have ready, but didn't finish and send yet because I got distracted working on the larger plan (among other things). The motivation (larger plan) for cpu-map is full cpu-topology configuration, but working on that has led to an smp parameter rework RFC (hoping to send this week...) Wei or I can just send the virt-2.7 patch now though to get it done sooner than later.

It makes sense to go with Drew's patches, so he doesn't need to re-base his existing current implementation.

Quoted 4 lines

Thanks,
drew