Patchwork [v6,2/5] qerror: add five qerror strings

login
register
mail settings
Submitter Amos Kong
Date April 17, 2012, 2:54 p.m.
Message ID <20120417145411.22756.29708.stgit@dhcp-8-167.nay.redhat.com>
Download mbox | patch
Permalink /patch/153221/
State New
Headers show

Comments

Amos Kong - April 17, 2012, 2:54 p.m.
Add five new qerror strings, they are about socket:
  QERR_SOCKET_CONNECT_IN_PROGRESS
  QERR_SOCKET_CONNECT_FAILED
  QERR_SOCKET_LISTEN_FAILED
  QERR_SOCKET_BIND_FAILED
  QERR_SOCKET_CREATE_FAILED

Signed-off-by: Amos Kong <akong@redhat.com>
---
 qerror.c |   20 ++++++++++++++++++++
 qerror.h |   15 +++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)
Michael Roth - April 18, 2012, 1:44 a.m.
On Tue, Apr 17, 2012 at 10:54:11PM +0800, Amos Kong wrote:
> Add five new qerror strings, they are about socket:
>   QERR_SOCKET_CONNECT_IN_PROGRESS
>   QERR_SOCKET_CONNECT_FAILED
>   QERR_SOCKET_LISTEN_FAILED
>   QERR_SOCKET_BIND_FAILED
>   QERR_SOCKET_CREATE_FAILED
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  qerror.c |   20 ++++++++++++++++++++
>  qerror.h |   15 +++++++++++++++
>  2 files changed, 35 insertions(+), 0 deletions(-)
> 
> diff --git a/qerror.c b/qerror.c
> index 96fbe71..7afe1ac 100644
> --- a/qerror.c
> +++ b/qerror.c
> @@ -304,6 +304,26 @@ static const QErrorStringTable qerror_table[] = {
>          .error_fmt = QERR_VNC_SERVER_FAILED,
>          .desc      = "Could not start VNC server on %(target)",
>      },
> +    {
> +        .error_fmt = QERR_SOCKET_CONNECT_IN_PROGRESS,
> +        .desc      = "Connection cannot be completed immediately",
> +    },
> +    {
> +        .error_fmt = QERR_SOCKET_CONNECT_FAILED,
> +        .desc      = "Fail to connect socket",

"Failed to connect to socket"

> +    },
> +    {
> +        .error_fmt = QERR_SOCKET_LISTEN_FAILED,
> +        .desc      = "Fail to listen socket",

"Failed to set socket to listening mode"

> +    },
> +    {
> +        .error_fmt = QERR_SOCKET_BIND_FAILED,
> +        .desc      = "Fail to bind socket",

"Failed to bind socket"

> +    },
> +    {
> +        .error_fmt = QERR_SOCKET_CREATE_FAILED,
> +        .desc      = "Fail to create socket",

"Failed to create socket"

> +    },
>      {}
>  };
> 
> diff --git a/qerror.h b/qerror.h
> index 5c23c1f..4cbba48 100644
> --- a/qerror.h
> +++ b/qerror.h
> @@ -248,4 +248,19 @@ QError *qobject_to_qerror(const QObject *obj);
>  #define QERR_VNC_SERVER_FAILED \
>      "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
> 
> +#define QERR_SOCKET_CONNECT_IN_PROGRESS \
> +    "{ 'class': 'SockConnectInprogress', 'data': {} }"
> +
> +#define QERR_SOCKET_CONNECT_FAILED \
> +    "{ 'class': 'SockConnectFailed', 'data': {} }"
> +
> +#define QERR_SOCKET_LISTEN_FAILED \
> +    "{ 'class': 'SockListenFailed', 'data': {} }"
> +
> +#define QERR_SOCKET_BIND_FAILED \
> +    "{ 'class': 'SockBindFailed', 'data': {} }"
> +
> +#define QERR_SOCKET_CREATE_FAILED \
> +    "{ 'class': 'SockCreateFailed', 'data': {} }"
> +
>  #endif /* QERROR_H */
> 
>
Orit Wasserman - April 18, 2012, 6:51 a.m.
On 04/17/2012 05:54 PM, Amos Kong wrote:
> Add five new qerror strings, they are about socket:
>   QERR_SOCKET_CONNECT_IN_PROGRESS
>   QERR_SOCKET_CONNECT_FAILED
>   QERR_SOCKET_LISTEN_FAILED
>   QERR_SOCKET_BIND_FAILED
>   QERR_SOCKET_CREATE_FAILED
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  qerror.c |   20 ++++++++++++++++++++
>  qerror.h |   15 +++++++++++++++
>  2 files changed, 35 insertions(+), 0 deletions(-)
> 
> diff --git a/qerror.c b/qerror.c
> index 96fbe71..7afe1ac 100644
> --- a/qerror.c
> +++ b/qerror.c
> @@ -304,6 +304,26 @@ static const QErrorStringTable qerror_table[] = {
>          .error_fmt = QERR_VNC_SERVER_FAILED,
>          .desc      = "Could not start VNC server on %(target)",
>      },
> +    {
> +        .error_fmt = QERR_SOCKET_CONNECT_IN_PROGRESS,
> +        .desc      = "Connection cannot be completed immediately",
> +    },
> +    {
> +        .error_fmt = QERR_SOCKET_CONNECT_FAILED,
> +        .desc      = "Fail to connect socket",
> +    },
> +    {
> +        .error_fmt = QERR_SOCKET_LISTEN_FAILED,
> +        .desc      = "Fail to listen socket",
> +    },
> +    {
> +        .error_fmt = QERR_SOCKET_BIND_FAILED,
> +        .desc      = "Fail to bind socket",
> +    },
> +    {
> +        .error_fmt = QERR_SOCKET_CREATE_FAILED,
> +        .desc      = "Fail to create socket",
> +    },
>      {}
>  };
>  
> diff --git a/qerror.h b/qerror.h
> index 5c23c1f..4cbba48 100644
> --- a/qerror.h
> +++ b/qerror.h
> @@ -248,4 +248,19 @@ QError *qobject_to_qerror(const QObject *obj);
>  #define QERR_VNC_SERVER_FAILED \
>      "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
>  
> +#define QERR_SOCKET_CONNECT_IN_PROGRESS \
> +    "{ 'class': 'SockConnectInprogress', 'data': {} }"
> +
> +#define QERR_SOCKET_CONNECT_FAILED \
> +    "{ 'class': 'SockConnectFailed', 'data': {} }"
> +
> +#define QERR_SOCKET_LISTEN_FAILED \
> +    "{ 'class': 'SockListenFailed', 'data': {} }"
> +
> +#define QERR_SOCKET_BIND_FAILED \
> +    "{ 'class': 'SockBindFailed', 'data': {} }"
> +
> +#define QERR_SOCKET_CREATE_FAILED \
> +    "{ 'class': 'SockCreateFailed', 'data': {} }"

For the FAILED error we will probably need more data , how about adding a string 
that can contain the strerror string ?

Orit
> +
>  #endif /* QERROR_H */
>
Paolo Bonzini - April 18, 2012, 11:25 a.m.
Il 18/04/2012 08:51, Orit Wasserman ha scritto:
> On 04/17/2012 05:54 PM, Amos Kong wrote:
>> Add five new qerror strings, they are about socket:
>>   QERR_SOCKET_CONNECT_IN_PROGRESS
>>   QERR_SOCKET_CONNECT_FAILED
>>   QERR_SOCKET_LISTEN_FAILED
>>   QERR_SOCKET_BIND_FAILED
>>   QERR_SOCKET_CREATE_FAILED
>>
>> Signed-off-by: Amos Kong <akong@redhat.com>
>> ---
>>  qerror.c |   20 ++++++++++++++++++++
>>  qerror.h |   15 +++++++++++++++
>>  2 files changed, 35 insertions(+), 0 deletions(-)
>>
>> diff --git a/qerror.c b/qerror.c
>> index 96fbe71..7afe1ac 100644
>> --- a/qerror.c
>> +++ b/qerror.c
>> @@ -304,6 +304,26 @@ static const QErrorStringTable qerror_table[] = {
>>          .error_fmt = QERR_VNC_SERVER_FAILED,
>>          .desc      = "Could not start VNC server on %(target)",
>>      },
>> +    {
>> +        .error_fmt = QERR_SOCKET_CONNECT_IN_PROGRESS,
>> +        .desc      = "Connection cannot be completed immediately",
>> +    },
>> +    {
>> +        .error_fmt = QERR_SOCKET_CONNECT_FAILED,
>> +        .desc      = "Fail to connect socket",
>> +    },
>> +    {
>> +        .error_fmt = QERR_SOCKET_LISTEN_FAILED,
>> +        .desc      = "Fail to listen socket",
>> +    },
>> +    {
>> +        .error_fmt = QERR_SOCKET_BIND_FAILED,
>> +        .desc      = "Fail to bind socket",
>> +    },
>> +    {
>> +        .error_fmt = QERR_SOCKET_CREATE_FAILED,
>> +        .desc      = "Fail to create socket",
>> +    },
>>      {}
>>  };
>>  
>> diff --git a/qerror.h b/qerror.h
>> index 5c23c1f..4cbba48 100644
>> --- a/qerror.h
>> +++ b/qerror.h
>> @@ -248,4 +248,19 @@ QError *qobject_to_qerror(const QObject *obj);
>>  #define QERR_VNC_SERVER_FAILED \
>>      "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
>>  
>> +#define QERR_SOCKET_CONNECT_IN_PROGRESS \
>> +    "{ 'class': 'SockConnectInprogress', 'data': {} }"
>> +
>> +#define QERR_SOCKET_CONNECT_FAILED \
>> +    "{ 'class': 'SockConnectFailed', 'data': {} }"
>> +
>> +#define QERR_SOCKET_LISTEN_FAILED \
>> +    "{ 'class': 'SockListenFailed', 'data': {} }"
>> +
>> +#define QERR_SOCKET_BIND_FAILED \
>> +    "{ 'class': 'SockBindFailed', 'data': {} }"
>> +
>> +#define QERR_SOCKET_CREATE_FAILED \
>> +    "{ 'class': 'SockCreateFailed', 'data': {} }"
> 
> For the FAILED error we will probably need more data , how about adding a string 
> that can contain the strerror string ?

This was nack-ed in the past, and the numeric errno values are not
portable.  However, as a follow up we could add a QAPI-specific enum
(QEMU_ERRNO_EACCES, QEMU_ERRNO_ECONNREFUSED, etc.) and convert errno
values to it.
Amos Kong - April 18, 2012, 11:48 a.m.
On 18/04/12 19:25, Paolo Bonzini wrote:
> Il 18/04/2012 08:51, Orit Wasserman ha scritto:
>> On 04/17/2012 05:54 PM, Amos Kong wrote:
>>> Add five new qerror strings, they are about socket:
>>>    QERR_SOCKET_CONNECT_IN_PROGRESS
>>>    QERR_SOCKET_CONNECT_FAILED
>>>    QERR_SOCKET_LISTEN_FAILED
>>>    QERR_SOCKET_BIND_FAILED
>>>    QERR_SOCKET_CREATE_FAILED
>>>
>>> Signed-off-by: Amos Kong<akong@redhat.com>
>>> ---
>>>   qerror.c |   20 ++++++++++++++++++++
>>>   qerror.h |   15 +++++++++++++++
>>>   2 files changed, 35 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/qerror.c b/qerror.c
>>> index 96fbe71..7afe1ac 100644
>>> --- a/qerror.c
>>> +++ b/qerror.c
>>> @@ -304,6 +304,26 @@ static const QErrorStringTable qerror_table[] = {
>>>           .error_fmt = QERR_VNC_SERVER_FAILED,
>>>           .desc      = "Could not start VNC server on %(target)",
>>>       },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_CONNECT_IN_PROGRESS,
>>> +        .desc      = "Connection cannot be completed immediately",
>>> +    },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_CONNECT_FAILED,
>>> +        .desc      = "Fail to connect socket",
>>> +    },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_LISTEN_FAILED,
>>> +        .desc      = "Fail to listen socket",
>>> +    },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_BIND_FAILED,
>>> +        .desc      = "Fail to bind socket",
>>> +    },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_CREATE_FAILED,
>>> +        .desc      = "Fail to create socket",
>>> +    },
>>>       {}
>>>   };
>>>
>>> diff --git a/qerror.h b/qerror.h
>>> index 5c23c1f..4cbba48 100644
>>> --- a/qerror.h
>>> +++ b/qerror.h
>>> @@ -248,4 +248,19 @@ QError *qobject_to_qerror(const QObject *obj);
>>>   #define QERR_VNC_SERVER_FAILED \
>>>       "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
>>>
>>> +#define QERR_SOCKET_CONNECT_IN_PROGRESS \
>>> +    "{ 'class': 'SockConnectInprogress', 'data': {} }"
>>> +
>>> +#define QERR_SOCKET_CONNECT_FAILED \
>>> +    "{ 'class': 'SockConnectFailed', 'data': {} }"
>>> +
>>> +#define QERR_SOCKET_LISTEN_FAILED \
>>> +    "{ 'class': 'SockListenFailed', 'data': {} }"
>>> +
>>> +#define QERR_SOCKET_BIND_FAILED \
>>> +    "{ 'class': 'SockBindFailed', 'data': {} }"
>>> +
>>> +#define QERR_SOCKET_CREATE_FAILED \
>>> +    "{ 'class': 'SockCreateFailed', 'data': {} }"
>>
>> For the FAILED error we will probably need more data , how about adding a string
>> that can contain the strerror string ?

We should provide monitor users more meaningful error note,
and output the strerror string to qemu stderr.
so I think current patch is ok.


> This was nack-ed in the past, and the numeric errno values are not
> portable.  However, as a follow up we could add a QAPI-specific enum
> (QEMU_ERRNO_EACCES, QEMU_ERRNO_ECONNREFUSED, etc.) and convert errno
> values to it.
Orit Wasserman - April 18, 2012, 11:56 a.m.
On 04/18/2012 02:25 PM, Paolo Bonzini wrote:
> Il 18/04/2012 08:51, Orit Wasserman ha scritto:
>> On 04/17/2012 05:54 PM, Amos Kong wrote:
>>> Add five new qerror strings, they are about socket:
>>>   QERR_SOCKET_CONNECT_IN_PROGRESS
>>>   QERR_SOCKET_CONNECT_FAILED
>>>   QERR_SOCKET_LISTEN_FAILED
>>>   QERR_SOCKET_BIND_FAILED
>>>   QERR_SOCKET_CREATE_FAILED
>>>
>>> Signed-off-by: Amos Kong <akong@redhat.com>
>>> ---
>>>  qerror.c |   20 ++++++++++++++++++++
>>>  qerror.h |   15 +++++++++++++++
>>>  2 files changed, 35 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/qerror.c b/qerror.c
>>> index 96fbe71..7afe1ac 100644
>>> --- a/qerror.c
>>> +++ b/qerror.c
>>> @@ -304,6 +304,26 @@ static const QErrorStringTable qerror_table[] = {
>>>          .error_fmt = QERR_VNC_SERVER_FAILED,
>>>          .desc      = "Could not start VNC server on %(target)",
>>>      },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_CONNECT_IN_PROGRESS,
>>> +        .desc      = "Connection cannot be completed immediately",
>>> +    },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_CONNECT_FAILED,
>>> +        .desc      = "Fail to connect socket",
>>> +    },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_LISTEN_FAILED,
>>> +        .desc      = "Fail to listen socket",
>>> +    },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_BIND_FAILED,
>>> +        .desc      = "Fail to bind socket",
>>> +    },
>>> +    {
>>> +        .error_fmt = QERR_SOCKET_CREATE_FAILED,
>>> +        .desc      = "Fail to create socket",
>>> +    },
>>>      {}
>>>  };
>>>  
>>> diff --git a/qerror.h b/qerror.h
>>> index 5c23c1f..4cbba48 100644
>>> --- a/qerror.h
>>> +++ b/qerror.h
>>> @@ -248,4 +248,19 @@ QError *qobject_to_qerror(const QObject *obj);
>>>  #define QERR_VNC_SERVER_FAILED \
>>>      "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
>>>  
>>> +#define QERR_SOCKET_CONNECT_IN_PROGRESS \
>>> +    "{ 'class': 'SockConnectInprogress', 'data': {} }"
>>> +
>>> +#define QERR_SOCKET_CONNECT_FAILED \
>>> +    "{ 'class': 'SockConnectFailed', 'data': {} }"
>>> +
>>> +#define QERR_SOCKET_LISTEN_FAILED \
>>> +    "{ 'class': 'SockListenFailed', 'data': {} }"
>>> +
>>> +#define QERR_SOCKET_BIND_FAILED \
>>> +    "{ 'class': 'SockBindFailed', 'data': {} }"
>>> +
>>> +#define QERR_SOCKET_CREATE_FAILED \
>>> +    "{ 'class': 'SockCreateFailed', 'data': {} }"
>>
>> For the FAILED error we will probably need more data , how about adding a string 
>> that can contain the strerror string ?
> 
> This was nack-ed in the past, and the numeric errno values are not
> portable.  However, as a follow up we could add a QAPI-specific enum
> (QEMU_ERRNO_EACCES, QEMU_ERRNO_ECONNREFUSED, etc.) and convert errno
> values to it.
> 

I agree, it can be handled later. Migration error messages are very cryptic and we need to make them
more user friendly in general.

Patch

diff --git a/qerror.c b/qerror.c
index 96fbe71..7afe1ac 100644
--- a/qerror.c
+++ b/qerror.c
@@ -304,6 +304,26 @@  static const QErrorStringTable qerror_table[] = {
         .error_fmt = QERR_VNC_SERVER_FAILED,
         .desc      = "Could not start VNC server on %(target)",
     },
+    {
+        .error_fmt = QERR_SOCKET_CONNECT_IN_PROGRESS,
+        .desc      = "Connection cannot be completed immediately",
+    },
+    {
+        .error_fmt = QERR_SOCKET_CONNECT_FAILED,
+        .desc      = "Fail to connect socket",
+    },
+    {
+        .error_fmt = QERR_SOCKET_LISTEN_FAILED,
+        .desc      = "Fail to listen socket",
+    },
+    {
+        .error_fmt = QERR_SOCKET_BIND_FAILED,
+        .desc      = "Fail to bind socket",
+    },
+    {
+        .error_fmt = QERR_SOCKET_CREATE_FAILED,
+        .desc      = "Fail to create socket",
+    },
     {}
 };
 
diff --git a/qerror.h b/qerror.h
index 5c23c1f..4cbba48 100644
--- a/qerror.h
+++ b/qerror.h
@@ -248,4 +248,19 @@  QError *qobject_to_qerror(const QObject *obj);
 #define QERR_VNC_SERVER_FAILED \
     "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
 
+#define QERR_SOCKET_CONNECT_IN_PROGRESS \
+    "{ 'class': 'SockConnectInprogress', 'data': {} }"
+
+#define QERR_SOCKET_CONNECT_FAILED \
+    "{ 'class': 'SockConnectFailed', 'data': {} }"
+
+#define QERR_SOCKET_LISTEN_FAILED \
+    "{ 'class': 'SockListenFailed', 'data': {} }"
+
+#define QERR_SOCKET_BIND_FAILED \
+    "{ 'class': 'SockBindFailed', 'data': {} }"
+
+#define QERR_SOCKET_CREATE_FAILED \
+    "{ 'class': 'SockCreateFailed', 'data': {} }"
+
 #endif /* QERROR_H */