iscsi: add error handling for qmp_query_uuid
PATCH 1/1 iscsi: add error handling for qmp_query_uuid
We can't assume that qmp_query_uuid() always returns available value.
--- block/iscsi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
block/iscsi.c +5 -2
@@ -1059,6 +1059,7 @@ static char *parse_initiator_name(const char *target)const char *name;char *iscsi_name;UuidInfo *uuid_info; +Error *errp =NULL ; list =qemu_find_opts ("iscsi" );if (list) {
@@ -1074,8 +1075,10 @@ static char *parse_initiator_name(const char *target) } } - uuid_info =qmp_query_uuid (NULL ); -if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { + uuid_info =qmp_query_uuid (&errp); +if (error_is_set (&errp)) { + name =qemu_get_vm_name (); + }else if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { name =qemu_get_vm_name (); }else { name = uuid_info->UUID;
Signature · 1 line
1.8.3.1
PATCH v2 1/1 iscsi: add error handling for qmp_query_uuid
We can't assume that qmp_query_uuid() always returns available value.
---
v2: free errp if it's set
--- block/iscsi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
block/iscsi.c +6 -2
@@ -1059,6 +1059,7 @@ static char *parse_initiator_name(const char *target)const char *name;char *iscsi_name;UuidInfo *uuid_info; +Error *errp =NULL ; list =qemu_find_opts ("iscsi" );if (list) {
@@ -1074,8 +1075,11 @@ static char *parse_initiator_name(const char *target) } } - uuid_info =qmp_query_uuid (NULL ); -if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { + uuid_info =qmp_query_uuid (&errp); +if (error_is_set (&errp)) { + name =qemu_get_vm_name (); +error_free (errp); + }else if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { name =qemu_get_vm_name (); }else { name = uuid_info->UUID;
Signature · 1 line
1.8.3.1
Quoted 14 lines · Amos Kong
We can't assume that
qmp_query_uuid()always returns available value.Signed-off-by Amos Kong <[email protected]>---
v2: free errp if it's set--- block/iscsi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)block/iscsi.c +0
-0
block/iscsi.c static char *parse_initiator_name(const char *target) · line 1062
Quoted 4 lines
block/iscsi.c +1
-0@@ -1059,6 +1059,7 @@ static char *parse_initiator_name(const char *target)const char *name;char *iscsi_name;UuidInfo *uuid_info; +Error *errp =NULL ;
I think we usually call this "local_err" or something similar.
block/iscsi.c static char *parse_initiator_name(const char *target) · line 1080
Quoted 12 lines
block/iscsi.c +3
-2list =qemu_find_opts ("iscsi" );if (list) {@@ -1074,8 +1075,11 @@ static char *parse_initiator_name(const char *target) } } - uuid_info =qmp_query_uuid (NULL ); -if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { + uuid_info =qmp_query_uuid (&errp); +if (error_is_set (&errp)) { + name =qemu_get_vm_name ();
I wonder if such an error should make parse_initiator_name() fail (which is currently not possible), or maybe succeed with qemu_get_vm_name() but print the UUID error message as a "warning" (could be pointless though).
block/iscsi.c static char *parse_initiator_name(const char *target) · line 1085
Quoted 6 lines
block/iscsi.c +2
-0+error_free (errp); + }else if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { name =qemu_get_vm_name (); }else { name = uuid_info->UUID;
Quoted 8 lines · Amos Kong
We can't assume that
qmp_query_uuid()always returns available value.Signed-off-by Amos Kong <[email protected]>---
v2: free errp if it's set--- block/iscsi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
I guess this will go through Paolo's SCSI tree.
Il 05/11/2013 14:17, Stefan Hajnoczi ha scritto:
Quoted 10 lines · Amos Kong
Quoted 8 lines
We can't assume that
qmp_query_uuid()always returns available value.Signed-off-by Amos Kong <[email protected]>---
v2: free errp if it's set--- block/iscsi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Quoted 3 lines
Reviewed-by Stefan Hajnoczi <[email protected]>I guess this will go through Paolo's SCSI tree.
Actually I'm not sure this is necessary, but if people want it, it will. :)
Paolo
Il 05/11/2013 01:08, Amos Kong ha scritto:
Quoted 23 lines
We can't assume that
qmp_query_uuid()always returns available value.Signed-off-by Amos Kong <[email protected]>--- block/iscsi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)block/iscsi.c +1
-0@@ -1059,6 +1059,7 @@ static char *parse_initiator_name(const char *target)const char *name;char *iscsi_name;UuidInfo *uuid_info; +Error *errp =NULL ; list =qemu_find_opts ("iscsi" );if (list) {@@ -1074,8 +1075,10 @@ static char *parse_initiator_name(const char *target) } }
block/iscsi.c static char *parse_initiator_name(const char *target) · line 1084
Quoted 10 lines
block/iscsi.c +4
-2- uuid_info =qmp_query_uuid (NULL ); -if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { + uuid_info =qmp_query_uuid (&errp); +if (error_is_set (&errp)) { + name =qemu_get_vm_name (); + }else if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { name =qemu_get_vm_name (); }else { name = uuid_info->UUID;
Does this fix an actual bug? qmp_query_uuid will never fail, it just has an Error* argument to comply with the requirements of the code generator.
Paolo
Quoted 24 lines · Paolo Bonzini
Il 05/11/2013 01:08, Amos Kong ha scritto:
Quoted 23 lines
We can't assume that
qmp_query_uuid()always returns available value.Signed-off-by Amos Kong <[email protected]>--- block/iscsi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)block/iscsi.c +1
-0@@ -1059,6 +1059,7 @@ static char *parse_initiator_name(const char *target)const char *name;char *iscsi_name;UuidInfo *uuid_info; +Error *errp =NULL ; list =qemu_find_opts ("iscsi" );if (list) {@@ -1074,8 +1075,10 @@ static char *parse_initiator_name(const char *target) } }
Quoted 12 lines
block/iscsi.c static char *parse_initiator_name(const char *target) · line 1084
Quoted 10 lines
block/iscsi.c +4
-2- uuid_info =qmp_query_uuid (NULL ); -if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { + uuid_info =qmp_query_uuid (&errp); +if (error_is_set (&errp)) { + name =qemu_get_vm_name (); + }else if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { name =qemu_get_vm_name (); }else { name = uuid_info->UUID;Does this fix an actual bug?
No a bug fixing.
Quoted 3 lines
qmp_query_uuidwill never fail, it just
has an Error* argument to comply with the requirements of the code generator.
Yes, this patch isn't necessary for current qmp_query_uuid() We can ignore this patch.
Quoted 1 line
Paolo
Signature · 1 line
Amos.