Skip to contentSkip to conversation

migration: equation is more proper than and to check LOADVM_QUIT

PATCH In review Wei Yang 3 participants 4 messages Jul 18, 2019 – Aug 7, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 migration: equation is more proper than and to check LOADVM_QUIT

LOADVM_QUIT allows a command to quit all layers of nested loadvm loops, while current return value check is not that proper even it works now.

Current return value check "ret & LOADVM_QUIT" would return true if bit[0] is 1. This would be true when ret is -1 which is used to indicate an error of handling a command.

Since there is only one place return LOADVM_QUIT and no other combination of return value, use "ret == LOADVM_QUIT" would be more proper.

---
 migration/savevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/savevm.c +1 -1
index 1a9b1f411e..25fe7ea05a 100644
@@ -2429,7 +2429,7 @@ retry:
         case QEMU_VM_COMMAND:
             ret = loadvm_process_command(f);
             trace_qemu_loadvm_state_section_command(ret);
-            if ((ret < 0) || (ret & LOADVM_QUIT)) {
+            if ((ret < 0) || (ret == LOADVM_QUIT)) {
                 goto out;
             }
             break;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · * Wei Yang ([email protected]) wrote:

LOADVM_QUIT allows a command to quit all layers of nested loadvm loops, while current return value check is not that proper even it works now.

Current return value check "ret & LOADVM_QUIT" would return true if bit[0] is 1. This would be true when ret is -1 which is used to indicate an error of handling a command.

Since there is only one place return LOADVM_QUIT and no other combination of return value, use "ret == LOADVM_QUIT" would be more proper.

Yes, when I first wrote this it was more complex with a few flags, and they all got removed.

Quoted 1 line
Quoted 20 lines
---
 migration/savevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/savevm.c +1 -1
index 1a9b1f411e..25fe7ea05a 100644
@@ -2429,7 +2429,7 @@ retry:
         case QEMU_VM_COMMAND:
             ret = loadvm_process_command(f);
             trace_qemu_loadvm_state_section_command(ret);
-            if ((ret < 0) || (ret & LOADVM_QUIT)) {
+            if ((ret < 0) || (ret == LOADVM_QUIT)) {
                 goto out;
             }
             break;
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#2 lore raw
Quoted 8 lines · Dr. David Alan Gilbert
Quoted 7 lines · * Wei Yang ([email protected]) wrote:

LOADVM_QUIT allows a command to quit all layers of nested loadvm loops, while current return value check is not that proper even it works now.

Current return value check "ret & LOADVM_QUIT" would return true if bit[0] is 1. This would be true when ret is -1 which is used to indicate an error of handling a command.

Quoted 7 lines
Quoted 3 lines

Since there is only one place return LOADVM_QUIT and no other combination of return value, use "ret == LOADVM_QUIT" would be more proper.

Yes, when I first wrote this it was more complex with a few flags, and they all got removed.

Ah, life is much easier now :-)

Quoted 26 lines
Quoted 1 line
Quoted 20 lines
---
 migration/savevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/savevm.c +1 -1
index 1a9b1f411e..25fe7ea05a 100644
@@ -2429,7 +2429,7 @@ retry:
         case QEMU_VM_COMMAND:
             ret = loadvm_process_command(f);
             trace_qemu_loadvm_state_section_command(ret);
-            if ((ret < 0) || (ret & LOADVM_QUIT)) {
+            if ((ret < 0) || (ret == LOADVM_QUIT)) {
                 goto out;
             }
             break;
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

Signature · 2 lines
Wei Yang
Help you, Help me
#3 lore raw
In reply to Wei Yang
Quoted 7 lines · * Wei Yang ([email protected]) wrote:

LOADVM_QUIT allows a command to quit all layers of nested loadvm loops, while current return value check is not that proper even it works now.

Current return value check "ret & LOADVM_QUIT" would return true if bit[0] is 1. This would be true when ret is -1 which is used to indicate an error of handling a command.

Quoted 5 lines

Since there is only one place return LOADVM_QUIT and no other combination of return value, use "ret == LOADVM_QUIT" would be more proper.

Queued

Quoted 21 lines
---
 migration/savevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/savevm.c +1 -1
index 1a9b1f411e..25fe7ea05a 100644
@@ -2429,7 +2429,7 @@ retry:
         case QEMU_VM_COMMAND:
             ret = loadvm_process_command(f);
             trace_qemu_loadvm_state_section_command(ret);
-            if ((ret < 0) || (ret & LOADVM_QUIT)) {
+            if ((ret < 0) || (ret == LOADVM_QUIT)) {
                 goto out;
             }
             break;
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK