diff mbox

[6/8] machine: query phandle-start machine property rather than qemu opts

Message ID 1423064635-19045-7-git-send-email-marcel@redhat.com
State New
Headers show

Commit Message

Marcel Apfelbaum Feb. 4, 2015, 3:43 p.m. UTC
Fixes a QEMU crash when passing phandle_start parameter in command line.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
---
 device_tree.c       | 5 ++---
 hw/core/machine.c   | 5 +++++
 include/hw/boards.h | 1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

Comments

Marcel Apfelbaum March 11, 2015, 2:32 p.m. UTC | #1
On 02/04/2015 05:43 PM, Marcel Apfelbaum wrote:
> Fixes a QEMU crash when passing phandle_start parameter in command line.
>
> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Please amend commit message:

Commit e79d5a6 ("machine: remove qemu_machine_opts global list")
removed the global option  descriptions and moved them to MachineState's QOM properties.

Query phandle-start by accephandle-startssing machine properties through designated wrappers.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>


> ---
>   device_tree.c       | 5 ++---
>   hw/core/machine.c   | 5 +++++
>   include/hw/boards.h | 1 +
>   3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/device_tree.c b/device_tree.c
> index 4cb1cd5..3d119ef 100644
> --- a/device_tree.c
> +++ b/device_tree.c
> @@ -24,7 +24,7 @@
>   #include "sysemu/device_tree.h"
>   #include "sysemu/sysemu.h"
>   #include "hw/loader.h"
> -#include "qemu/option.h"
> +#include "hw/boards.h"
>   #include "qemu/config-file.h"
>
>   #include <libfdt.h>
> @@ -245,8 +245,7 @@ uint32_t qemu_fdt_alloc_phandle(void *fdt)
>        * which phandle id to start allocting phandles.
>        */
>       if (!phandle) {
> -        phandle = qemu_opt_get_number(qemu_get_machine_opts(),
> -                                      "phandle_start", 0);
> +        phandle = machine_phandle_start(current_machine);
>       }
>
>       if (!phandle) {
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 0ad5b12..5ad2409 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -420,6 +420,11 @@ int machine_kvm_shadow_mem(MachineState *machine)
>       return machine->kvm_shadow_mem;
>   }
>
> +int machine_phandle_start(MachineState *machine)
> +{
> +    return machine->phandle_start;
> +}
> +
>   static const TypeInfo machine_info = {
>       .name = TYPE_MACHINE,
>       .parent = TYPE_OBJECT,
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 4be3cd1..1f21bdf 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -70,6 +70,7 @@ bool machine_iommu(MachineState *machine);
>   bool machine_kernel_irqchip_allowed(MachineState *machine);
>   bool machine_kernel_irqchip_required(MachineState *machine);
>   int machine_kvm_shadow_mem(MachineState *machine);
> +int machine_phandle_start(MachineState *machine);
>
>   /**
>    * MachineClass:
>
Marcel Apfelbaum March 11, 2015, 2:34 p.m. UTC | #2
On 03/11/2015 04:32 PM, Marcel Apfelbaum wrote:
> On 02/04/2015 05:43 PM, Marcel Apfelbaum wrote:
>> Fixes a QEMU crash when passing phandle_start parameter in command line.
>>
>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
> Please amend commit message:
>
> Commit e79d5a6 ("machine: remove qemu_machine_opts global list")
> removed the global option  descriptions and moved them to MachineState's QOM properties.
>
> Query phandle-start by accephandle-startssing machine properties through designated wrappers.
>
> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>
Sorry for the typo:

Commit e79d5a6 ("machine: remove qemu_machine_opts global list")
removed the global option  descriptions and moved them to MachineState's QOM properties.

Query phandle-start by accessing machine properties through designated wrappers.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>


>
>> ---
>>   device_tree.c       | 5 ++---
>>   hw/core/machine.c   | 5 +++++
>>   include/hw/boards.h | 1 +
>>   3 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/device_tree.c b/device_tree.c
>> index 4cb1cd5..3d119ef 100644
>> --- a/device_tree.c
>> +++ b/device_tree.c
>> @@ -24,7 +24,7 @@
>>   #include "sysemu/device_tree.h"
>>   #include "sysemu/sysemu.h"
>>   #include "hw/loader.h"
>> -#include "qemu/option.h"
>> +#include "hw/boards.h"
>>   #include "qemu/config-file.h"
>>
>>   #include <libfdt.h>
>> @@ -245,8 +245,7 @@ uint32_t qemu_fdt_alloc_phandle(void *fdt)
>>        * which phandle id to start allocting phandles.
>>        */
>>       if (!phandle) {
>> -        phandle = qemu_opt_get_number(qemu_get_machine_opts(),
>> -                                      "phandle_start", 0);
>> +        phandle = machine_phandle_start(current_machine);
>>       }
>>
>>       if (!phandle) {
>> diff --git a/hw/core/machine.c b/hw/core/machine.c
>> index 0ad5b12..5ad2409 100644
>> --- a/hw/core/machine.c
>> +++ b/hw/core/machine.c
>> @@ -420,6 +420,11 @@ int machine_kvm_shadow_mem(MachineState *machine)
>>       return machine->kvm_shadow_mem;
>>   }
>>
>> +int machine_phandle_start(MachineState *machine)
>> +{
>> +    return machine->phandle_start;
>> +}
>> +
>>   static const TypeInfo machine_info = {
>>       .name = TYPE_MACHINE,
>>       .parent = TYPE_OBJECT,
>> diff --git a/include/hw/boards.h b/include/hw/boards.h
>> index 4be3cd1..1f21bdf 100644
>> --- a/include/hw/boards.h
>> +++ b/include/hw/boards.h
>> @@ -70,6 +70,7 @@ bool machine_iommu(MachineState *machine);
>>   bool machine_kernel_irqchip_allowed(MachineState *machine);
>>   bool machine_kernel_irqchip_required(MachineState *machine);
>>   int machine_kvm_shadow_mem(MachineState *machine);
>> +int machine_phandle_start(MachineState *machine);
>>
>>   /**
>>    * MachineClass:
>>
>
Michael S. Tsirkin March 11, 2015, 2:39 p.m. UTC | #3
On Wed, Mar 11, 2015 at 04:32:39PM +0200, Marcel Apfelbaum wrote:
> On 02/04/2015 05:43 PM, Marcel Apfelbaum wrote:
> >Fixes a QEMU crash when passing phandle_start parameter in command line.
> >
> >Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
> Please amend commit message:
> 
> Commit e79d5a6 ("machine: remove qemu_machine_opts global list")
> removed the global option  descriptions and moved them to MachineState's QOM properties.
> 
> Query phandle-start by accephandle-startssing machine properties through designated wrappers.

What does this mean?

> 
> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>


I don't think this makes it clearer.
Maybe just given an example on how to reproduce the crash?

> 
> >---
> >  device_tree.c       | 5 ++---
> >  hw/core/machine.c   | 5 +++++
> >  include/hw/boards.h | 1 +
> >  3 files changed, 8 insertions(+), 3 deletions(-)
> >
> >diff --git a/device_tree.c b/device_tree.c
> >index 4cb1cd5..3d119ef 100644
> >--- a/device_tree.c
> >+++ b/device_tree.c
> >@@ -24,7 +24,7 @@
> >  #include "sysemu/device_tree.h"
> >  #include "sysemu/sysemu.h"
> >  #include "hw/loader.h"
> >-#include "qemu/option.h"
> >+#include "hw/boards.h"
> >  #include "qemu/config-file.h"
> >
> >  #include <libfdt.h>
> >@@ -245,8 +245,7 @@ uint32_t qemu_fdt_alloc_phandle(void *fdt)
> >       * which phandle id to start allocting phandles.
> >       */
> >      if (!phandle) {
> >-        phandle = qemu_opt_get_number(qemu_get_machine_opts(),
> >-                                      "phandle_start", 0);
> >+        phandle = machine_phandle_start(current_machine);
> >      }
> >
> >      if (!phandle) {
> >diff --git a/hw/core/machine.c b/hw/core/machine.c
> >index 0ad5b12..5ad2409 100644
> >--- a/hw/core/machine.c
> >+++ b/hw/core/machine.c
> >@@ -420,6 +420,11 @@ int machine_kvm_shadow_mem(MachineState *machine)
> >      return machine->kvm_shadow_mem;
> >  }
> >
> >+int machine_phandle_start(MachineState *machine)
> >+{
> >+    return machine->phandle_start;
> >+}
> >+
> >  static const TypeInfo machine_info = {
> >      .name = TYPE_MACHINE,
> >      .parent = TYPE_OBJECT,
> >diff --git a/include/hw/boards.h b/include/hw/boards.h
> >index 4be3cd1..1f21bdf 100644
> >--- a/include/hw/boards.h
> >+++ b/include/hw/boards.h
> >@@ -70,6 +70,7 @@ bool machine_iommu(MachineState *machine);
> >  bool machine_kernel_irqchip_allowed(MachineState *machine);
> >  bool machine_kernel_irqchip_required(MachineState *machine);
> >  int machine_kvm_shadow_mem(MachineState *machine);
> >+int machine_phandle_start(MachineState *machine);
> >
> >  /**
> >   * MachineClass:
> >
Marcel Apfelbaum March 11, 2015, 2:48 p.m. UTC | #4
On 03/11/2015 04:39 PM, Michael S. Tsirkin wrote:
> On Wed, Mar 11, 2015 at 04:32:39PM +0200, Marcel Apfelbaum wrote:
>> On 02/04/2015 05:43 PM, Marcel Apfelbaum wrote:
>>> Fixes a QEMU crash when passing phandle_start parameter in command line.
>>>
>>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>> Please amend commit message:
>>
>> Commit e79d5a6 ("machine: remove qemu_machine_opts global list")
>> removed the global option  descriptions and moved them to MachineState's QOM properties.
>>
>> Query phandle-start by accephandle-startssing machine properties through designated wrappers.
>
> What does this mean?
Please look at the fixed mail (sent a few seconds later)

Thanks,
Marcel

>
>>
>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>
>
> I don't think this makes it clearer.
> Maybe just given an example on how to reproduce the crash?
>
>>
>>> ---
>>>   device_tree.c       | 5 ++---
>>>   hw/core/machine.c   | 5 +++++
>>>   include/hw/boards.h | 1 +
>>>   3 files changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/device_tree.c b/device_tree.c
>>> index 4cb1cd5..3d119ef 100644
>>> --- a/device_tree.c
>>> +++ b/device_tree.c
>>> @@ -24,7 +24,7 @@
>>>   #include "sysemu/device_tree.h"
>>>   #include "sysemu/sysemu.h"
>>>   #include "hw/loader.h"
>>> -#include "qemu/option.h"
>>> +#include "hw/boards.h"
>>>   #include "qemu/config-file.h"
>>>
>>>   #include <libfdt.h>
>>> @@ -245,8 +245,7 @@ uint32_t qemu_fdt_alloc_phandle(void *fdt)
>>>        * which phandle id to start allocting phandles.
>>>        */
>>>       if (!phandle) {
>>> -        phandle = qemu_opt_get_number(qemu_get_machine_opts(),
>>> -                                      "phandle_start", 0);
>>> +        phandle = machine_phandle_start(current_machine);
>>>       }
>>>
>>>       if (!phandle) {
>>> diff --git a/hw/core/machine.c b/hw/core/machine.c
>>> index 0ad5b12..5ad2409 100644
>>> --- a/hw/core/machine.c
>>> +++ b/hw/core/machine.c
>>> @@ -420,6 +420,11 @@ int machine_kvm_shadow_mem(MachineState *machine)
>>>       return machine->kvm_shadow_mem;
>>>   }
>>>
>>> +int machine_phandle_start(MachineState *machine)
>>> +{
>>> +    return machine->phandle_start;
>>> +}
>>> +
>>>   static const TypeInfo machine_info = {
>>>       .name = TYPE_MACHINE,
>>>       .parent = TYPE_OBJECT,
>>> diff --git a/include/hw/boards.h b/include/hw/boards.h
>>> index 4be3cd1..1f21bdf 100644
>>> --- a/include/hw/boards.h
>>> +++ b/include/hw/boards.h
>>> @@ -70,6 +70,7 @@ bool machine_iommu(MachineState *machine);
>>>   bool machine_kernel_irqchip_allowed(MachineState *machine);
>>>   bool machine_kernel_irqchip_required(MachineState *machine);
>>>   int machine_kvm_shadow_mem(MachineState *machine);
>>> +int machine_phandle_start(MachineState *machine);
>>>
>>>   /**
>>>    * MachineClass:
>>>
diff mbox

Patch

diff --git a/device_tree.c b/device_tree.c
index 4cb1cd5..3d119ef 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -24,7 +24,7 @@ 
 #include "sysemu/device_tree.h"
 #include "sysemu/sysemu.h"
 #include "hw/loader.h"
-#include "qemu/option.h"
+#include "hw/boards.h"
 #include "qemu/config-file.h"
 
 #include <libfdt.h>
@@ -245,8 +245,7 @@  uint32_t qemu_fdt_alloc_phandle(void *fdt)
      * which phandle id to start allocting phandles.
      */
     if (!phandle) {
-        phandle = qemu_opt_get_number(qemu_get_machine_opts(),
-                                      "phandle_start", 0);
+        phandle = machine_phandle_start(current_machine);
     }
 
     if (!phandle) {
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 0ad5b12..5ad2409 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -420,6 +420,11 @@  int machine_kvm_shadow_mem(MachineState *machine)
     return machine->kvm_shadow_mem;
 }
 
+int machine_phandle_start(MachineState *machine)
+{
+    return machine->phandle_start;
+}
+
 static const TypeInfo machine_info = {
     .name = TYPE_MACHINE,
     .parent = TYPE_OBJECT,
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 4be3cd1..1f21bdf 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -70,6 +70,7 @@  bool machine_iommu(MachineState *machine);
 bool machine_kernel_irqchip_allowed(MachineState *machine);
 bool machine_kernel_irqchip_required(MachineState *machine);
 int machine_kvm_shadow_mem(MachineState *machine);
+int machine_phandle_start(MachineState *machine);
 
 /**
  * MachineClass: