diff mbox

vl.c: use 'break' instead of 'continue' in configure_accelerator()

Message ID 53337BEB.90305@gmail.com
State New
Headers show

Commit Message

Chen Gang March 27, 2014, 1:16 a.m. UTC
At present, each 'opt_name' of 'accel_list' is uniq with each other, so
'buf' can only match one 'opt_name'.

When drop into the matching code block, can 'break' outside related
'for' looping after finish processing it (just like the other 'break'
within the matching block).

After print "... not support for this target", it can avoid to print
"... accelerator does not exist".


Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 vl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marcel Apfelbaum March 27, 2014, 7:55 a.m. UTC | #1
On Thu, 2014-03-27 at 09:16 +0800, Chen Gang wrote:
> At present, each 'opt_name' of 'accel_list' is uniq with each other, so
> 'buf' can only match one 'opt_name'.
> 
> When drop into the matching code block, can 'break' outside related
> 'for' looping after finish processing it (just like the other 'break'
> within the matching block).
> 
> After print "... not support for this target", it can avoid to print
> "... accelerator does not exist".
Hi,
Thanks for the patch!

I would re-write
1. The commit subject to:
   Fix wrong warning on configure_accelerator
2. The commit message to:
   No need to continue to iterate over the accelerators list
   after a match is found, even if it is not supported.

> 
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
>  vl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/vl.c b/vl.c
> index 842e897..b4f98fa 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2709,7 +2709,7 @@ static int configure_accelerator(QEMUMachine *machine)
>                  if (!accel_list[i].available()) {
>                      printf("%s not supported for this target\n",
>                             accel_list[i].name);
> -                    continue;
> +                    break;
Seems like the right thing to do.

Thanks,
Marcel

>                  }
>                  *(accel_list[i].allowed) = true;
>                  ret = accel_list[i].init(machine);
Markus Armbruster March 27, 2014, 8:59 a.m. UTC | #2
Chen Gang <gang.chen.5i5j@gmail.com> writes:

> At present, each 'opt_name' of 'accel_list' is uniq with each other, so
> 'buf' can only match one 'opt_name'.
>
> When drop into the matching code block, can 'break' outside related
> 'for' looping after finish processing it (just like the other 'break'
> within the matching block).
>
> After print "... not support for this target", it can avoid to print
> "... accelerator does not exist".
>
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
>  vl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/vl.c b/vl.c
> index 842e897..b4f98fa 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2709,7 +2709,7 @@ static int configure_accelerator(QEMUMachine *machine)
>                  if (!accel_list[i].available()) {
>                      printf("%s not supported for this target\n",
>                             accel_list[i].name);
> -                    continue;
> +                    break;
>                  }
>                  *(accel_list[i].allowed) = true;
>                  ret = accel_list[i].init(machine);

Works, because the opt_name in accel_list[] are distinct, as you
explained in your commit message.

Apropos commit message.  You first explain what you do, and only then
state the problem you're trying to solve.  That's backwards.  Start with
the problem.  Only then explain your solution, if it needs explaining.
This one, I think, doesn't.

Suggested commit message:

    vl: Report accelerator not supported for target more nicely

    When you ask for an accelerator not supported for your target, you
    get a bogus "accelerator does not exist" message:

        $ qemu-system-arm -machine none,accel=kvm
        KVM not supported for this target
        "kvm" accelerator does not exist.
        No accelerator found!

    Suppress it.
Chen Gang March 27, 2014, 9:54 a.m. UTC | #3
On 03/27/2014 03:55 PM, Marcel Apfelbaum wrote:
> On Thu, 2014-03-27 at 09:16 +0800, Chen Gang wrote:
>> At present, each 'opt_name' of 'accel_list' is uniq with each other, so
>> 'buf' can only match one 'opt_name'.
>>
>> When drop into the matching code block, can 'break' outside related
>> 'for' looping after finish processing it (just like the other 'break'
>> within the matching block).
>>
>> After print "... not support for this target", it can avoid to print
>> "... accelerator does not exist".
> Hi,
> Thanks for the patch!
> 
> I would re-write
> 1. The commit subject to:
>    Fix wrong warning on configure_accelerator
> 2. The commit message to:
>    No need to continue to iterate over the accelerators list
>    after a match is found, even if it is not supported.
> 

OK, thank you for your work (re-write it before commit it).

Next I will/should notice about it.  :-)

>>
>>
>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>> ---
>>  vl.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/vl.c b/vl.c
>> index 842e897..b4f98fa 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2709,7 +2709,7 @@ static int configure_accelerator(QEMUMachine *machine)
>>                  if (!accel_list[i].available()) {
>>                      printf("%s not supported for this target\n",
>>                             accel_list[i].name);
>> -                    continue;
>> +                    break;
> Seems like the right thing to do.
> 
> Thanks,
> Marcel
> 
>>                  }
>>                  *(accel_list[i].allowed) = true;
>>                  ret = accel_list[i].init(machine);
> 
> 
>
Chen Gang March 27, 2014, 10:01 a.m. UTC | #4
On 03/27/2014 04:59 PM, Markus Armbruster wrote:
> Chen Gang <gang.chen.5i5j@gmail.com> writes:
> 
>> At present, each 'opt_name' of 'accel_list' is uniq with each other, so
>> 'buf' can only match one 'opt_name'.
>>
>> When drop into the matching code block, can 'break' outside related
>> 'for' looping after finish processing it (just like the other 'break'
>> within the matching block).
>>
>> After print "... not support for this target", it can avoid to print
>> "... accelerator does not exist".
>>
>>
>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>> ---
>>  vl.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/vl.c b/vl.c
>> index 842e897..b4f98fa 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -2709,7 +2709,7 @@ static int configure_accelerator(QEMUMachine *machine)
>>                  if (!accel_list[i].available()) {
>>                      printf("%s not supported for this target\n",
>>                             accel_list[i].name);
>> -                    continue;
>> +                    break;
>>                  }
>>                  *(accel_list[i].allowed) = true;
>>                  ret = accel_list[i].init(machine);
> 
> Works, because the opt_name in accel_list[] are distinct, as you
> explained in your commit message.
> 
> Apropos commit message.  You first explain what you do, and only then
> state the problem you're trying to solve.  That's backwards.  Start with
> the problem.  Only then explain your solution, if it needs explaining.
> This one, I think, doesn't.
> 
> Suggested commit message:
> 
>     vl: Report accelerator not supported for target more nicely
> 
>     When you ask for an accelerator not supported for your target, you
>     get a bogus "accelerator does not exist" message:
> 
>         $ qemu-system-arm -machine none,accel=kvm
>         KVM not supported for this target
>         "kvm" accelerator does not exist.
>         No accelerator found!
> 
>     Suppress it.
> 

Thank you for your details, that sounds reasonable to me.

Next, I will/should notice start with the issue, and then explain the
solution.


Thanks.
Chen Gang March 30, 2014, 2:44 p.m. UTC | #5
Hello Maintainers:

If it is necessary to send patch v2 by me, please let me know, I
will/should send.


Thanks.

On 03/27/2014 06:01 PM, Chen Gang wrote:
> 
> 
> On 03/27/2014 04:59 PM, Markus Armbruster wrote:
>> Chen Gang <gang.chen.5i5j@gmail.com> writes:
>>
>>> At present, each 'opt_name' of 'accel_list' is uniq with each other, so
>>> 'buf' can only match one 'opt_name'.
>>>
>>> When drop into the matching code block, can 'break' outside related
>>> 'for' looping after finish processing it (just like the other 'break'
>>> within the matching block).
>>>
>>> After print "... not support for this target", it can avoid to print
>>> "... accelerator does not exist".
>>>
>>>
>>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>>> ---
>>>  vl.c |    2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/vl.c b/vl.c
>>> index 842e897..b4f98fa 100644
>>> --- a/vl.c
>>> +++ b/vl.c
>>> @@ -2709,7 +2709,7 @@ static int configure_accelerator(QEMUMachine *machine)
>>>                  if (!accel_list[i].available()) {
>>>                      printf("%s not supported for this target\n",
>>>                             accel_list[i].name);
>>> -                    continue;
>>> +                    break;
>>>                  }
>>>                  *(accel_list[i].allowed) = true;
>>>                  ret = accel_list[i].init(machine);
>>
>> Works, because the opt_name in accel_list[] are distinct, as you
>> explained in your commit message.
>>
>> Apropos commit message.  You first explain what you do, and only then
>> state the problem you're trying to solve.  That's backwards.  Start with
>> the problem.  Only then explain your solution, if it needs explaining.
>> This one, I think, doesn't.
>>
>> Suggested commit message:
>>
>>     vl: Report accelerator not supported for target more nicely
>>
>>     When you ask for an accelerator not supported for your target, you
>>     get a bogus "accelerator does not exist" message:
>>
>>         $ qemu-system-arm -machine none,accel=kvm
>>         KVM not supported for this target
>>         "kvm" accelerator does not exist.
>>         No accelerator found!
>>
>>     Suppress it.
>>
> 
> Thank you for your details, that sounds reasonable to me.
> 
> Next, I will/should notice start with the issue, and then explain the
> solution.
> 
> 
> Thanks.
>
Markus Armbruster March 31, 2014, 12:38 p.m. UTC | #6
Chen Gang <gang.chen.5i5j@gmail.com> writes:

> Hello Maintainers:
>
> If it is necessary to send patch v2 by me, please let me know, I
> will/should send.

Not a maintainer, but if you send a v2 with an improved commit message,
I'll R-by it, which can only help getting it merged.
Chen Gang March 31, 2014, 12:53 p.m. UTC | #7
On 03/31/2014 08:38 PM, Markus Armbruster wrote:
> Chen Gang <gang.chen.5i5j@gmail.com> writes:
> 
>> Hello Maintainers:
>>
>> If it is necessary to send patch v2 by me, please let me know, I
>> will/should send.
> 
> Not a maintainer, but if you send a v2 with an improved commit message,
> I'll R-by it, which can only help getting it merged.
> 

I guess your meaning is "not quite necessary" (for me, minor useful
patches almost like spam). So if sending patch v2 is really required,
please let me know, thanks.

At present, I am just trying to know about Qemu by reading code (start
from 'vl.c' and continue), if I can find related issue, I will try to
fix it and send the related patch for it.


Welcome any additional suggestions and completions for what I am doing.

Thanks.
Peter Maydell March 31, 2014, 1:01 p.m. UTC | #8
On 31 March 2014 13:53, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
> On 03/31/2014 08:38 PM, Markus Armbruster wrote:
>> Chen Gang <gang.chen.5i5j@gmail.com> writes:
>>
>>> Hello Maintainers:
>>>
>>> If it is necessary to send patch v2 by me, please let me know, I
>>> will/should send.
>>
>> Not a maintainer, but if you send a v2 with an improved commit message,
>> I'll R-by it, which can only help getting it merged.
>>
>
> I guess your meaning is "not quite necessary" (for me, minor useful
> patches almost like spam). So if sending patch v2 is really required,
> please let me know, thanks.

Basically, asking a maintainer to make changes to a patch
as they apply it is asking them to do extra work beyond
what they would normally do. Sometimes people will agree
to do this, but in general it's better just to send a fixed
version of the patch yourself.

(I've cc'd qemu-trivial since that's probably the best tree
to take this patch.)

thanks
-- PMM
Chen Gang March 31, 2014, 1:12 p.m. UTC | #9
On 03/31/2014 09:01 PM, Peter Maydell wrote:
> On 31 March 2014 13:53, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
>> On 03/31/2014 08:38 PM, Markus Armbruster wrote:
>>> Chen Gang <gang.chen.5i5j@gmail.com> writes:
>>>
>>>> Hello Maintainers:
>>>>
>>>> If it is necessary to send patch v2 by me, please let me know, I
>>>> will/should send.
>>>
>>> Not a maintainer, but if you send a v2 with an improved commit message,
>>> I'll R-by it, which can only help getting it merged.
>>>
>>
>> I guess your meaning is "not quite necessary" (for me, minor useful
>> patches almost like spam). So if sending patch v2 is really required,
>> please let me know, thanks.
> 
> Basically, asking a maintainer to make changes to a patch
> as they apply it is asking them to do extra work beyond
> what they would normally do. Sometimes people will agree
> to do this, but in general it's better just to send a fixed
> version of the patch yourself.
> 
> (I've cc'd qemu-trivial since that's probably the best tree
> to take this patch.)
> 

OK, thanks. And excuse me, my English is not quite well, I guess, I
misunderstood the original replier's meaning. I will/should send patch
v2 for it within this week (2014-04-06).

Next, when I send trivial patches, I will/should cc to qemu-trivial. I
guess, most of my future patches will be trivial patches (and for me,
trivial != minor).


Thanks.
Peter Maydell March 31, 2014, 1:16 p.m. UTC | #10
On 31 March 2014 14:12, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
> Next, when I send trivial patches, I will/should cc to qemu-trivial. I
> guess, most of my future patches will be trivial patches (and for me,
> trivial != minor).

We describe on the wiki what we mean by 'trivial':
http://wiki.qemu.org/Contribute/TrivialPatches

thanks
-- PMM
Chen Gang March 31, 2014, 1:26 p.m. UTC | #11
On 03/31/2014 09:16 PM, Peter Maydell wrote:
> On 31 March 2014 14:12, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
>> Next, when I send trivial patches, I will/should cc to qemu-trivial. I
>> guess, most of my future patches will be trivial patches (and for me,
>> trivial != minor).
> 
> We describe on the wiki what we mean by 'trivial':
> http://wiki.qemu.org/Contribute/TrivialPatches
> 

Thank you for your information.

Next, when I send trivial patches, I will only send to qemu-trivial (not
send/cc to qemu-devel again), that will be more efficient.  :-)


Thanks.
Peter Maydell March 31, 2014, 1:33 p.m. UTC | #12
On 31 March 2014 14:26, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
> Next, when I send trivial patches, I will only send to qemu-trivial (not
> send/cc to qemu-devel again), that will be more efficient.  :-)

No, please always send to qemu-devel; just also cc qemu-trivial
(or the relevant subsystem maintainers as listed in MAINTAINERS)
if appropriate. Not everybody subscribes to qemu-trivial.

thanks
-- PMM
Chen Gang March 31, 2014, 11:50 p.m. UTC | #13
On 03/31/2014 09:33 PM, Peter Maydell wrote:
> On 31 March 2014 14:26, Chen Gang <gang.chen.5i5j@gmail.com> wrote:
>> Next, when I send trivial patches, I will only send to qemu-trivial (not
>> send/cc to qemu-devel again), that will be more efficient.  :-)
> 
> No, please always send to qemu-devel; just also cc qemu-trivial
> (or the relevant subsystem maintainers as listed in MAINTAINERS)
> if appropriate. Not everybody subscribes to qemu-trivial.
> 

OK, thanks.

And when send trivial patch, I will/should always mark it as "[PATCH
trivial]" to let another members know about it easily, and always cc to
qemu-trivial.


Thanks.
diff mbox

Patch

diff --git a/vl.c b/vl.c
index 842e897..b4f98fa 100644
--- a/vl.c
+++ b/vl.c
@@ -2709,7 +2709,7 @@  static int configure_accelerator(QEMUMachine *machine)
                 if (!accel_list[i].available()) {
                     printf("%s not supported for this target\n",
                            accel_list[i].name);
-                    continue;
+                    break;
                 }
                 *(accel_list[i].allowed) = true;
                 ret = accel_list[i].init(machine);