[PATCH v2] conf: virDomainMemoryDefValidate: Improve error message

Liu Yiding posted 1 patch 1 year, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20220628035335.238442-1-liuyd.fnst@fujitsu.com
src/conf/domain_validate.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH v2] conf: virDomainMemoryDefValidate: Improve error message
Posted by Liu Yiding 1 year, 10 months ago
An explicit limit would be more user friendly. Add the limit to error message.

Before this commit:
```
error: requested size must be smaller than or equal to @size
```

Now:
```
error: requested size must be smaller than or equal to @size (8388608KiB)
```

Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
---
 src/conf/domain_validate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 33b6f47159..28b0481d4e 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -2194,8 +2194,9 @@ virDomainMemoryDefValidate(const virDomainMemoryDef *mem,
 
     case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
         if (mem->requestedsize > mem->size) {
-            virReportError(VIR_ERR_XML_DETAIL, "%s",
-                           _("requested size must be smaller than or equal to @size"));
+            virReportError(VIR_ERR_XML_DETAIL,
+                           _("requested size must be smaller than or equal to @size (%lluKiB)"),
+                           mem->size);
             return -1;
         }
 
-- 
2.34.1
Re: [PATCH v2] conf: virDomainMemoryDefValidate: Improve error message
Posted by Michal Prívozník 1 year, 10 months ago
On 6/28/22 05:53, Liu Yiding wrote:
> An explicit limit would be more user friendly. Add the limit to error message.
> 
> Before this commit:
> ```
> error: requested size must be smaller than or equal to @size
> ```
> 
> Now:
> ```
> error: requested size must be smaller than or equal to @size (8388608KiB)
> ```
> 
> Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
> ---
>  src/conf/domain_validate.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 

Yup, this looks perfect. Thanks!

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

and pushed. Congratulations on your first libvirt contribution!

Michal
Re: [PATCH v2] conf: virDomainMemoryDefValidate: Improve error message
Posted by liuyd.fnst@fujitsu.com 1 year, 10 months ago
Thanks, Michal :)

On 6/28/22 18:35, Michal Prívozník wrote:
> On 6/28/22 05:53, Liu Yiding wrote:
>> An explicit limit would be more user friendly. Add the limit to error message.
>>
>> Before this commit:
>> ```
>> error: requested size must be smaller than or equal to @size
>> ```
>>
>> Now:
>> ```
>> error: requested size must be smaller than or equal to @size (8388608KiB)
>> ```
>>
>> Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
>> ---
>>   src/conf/domain_validate.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
> 
> Yup, this looks perfect. Thanks!
> 
> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
> 
> and pushed. Congratulations on your first libvirt contribution!
> 
> Michal
>