diff mbox series

[v7,28/47] block/null: Implement bdrv_get_allocated_file_size

Message ID 20200625152215.941773-29-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series block: Deal with filters | expand

Commit Message

Max Reitz June 25, 2020, 3:21 p.m. UTC
It is trivial, so we might as well do it.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/null.c               | 7 +++++++
 tests/qemu-iotests/153.out | 2 +-
 tests/qemu-iotests/184.out | 6 ++++--
 3 files changed, 12 insertions(+), 3 deletions(-)

Comments

Andrey Shinkevich July 20, 2020, 3:10 p.m. UTC | #1
On 25.06.2020 18:21, Max Reitz wrote:
> It is trivial, so we might as well do it.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>   block/null.c               | 7 +++++++
>   tests/qemu-iotests/153.out | 2 +-
>   tests/qemu-iotests/184.out | 6 ++++--
>   3 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/block/null.c b/block/null.c
> index 15e1d56746..cc9b1d4ea7 100644
> --- a/block/null.c
> +++ b/block/null.c
> @@ -262,6 +262,11 @@ static void null_refresh_filename(BlockDriverState *bs)
>                bs->drv->format_name);
>   }
>   
> +static int64_t null_allocated_file_size(BlockDriverState *bs)
> +{
> +    return 0;
> +}
> +
>   static const char *const null_strong_runtime_opts[] = {
>       BLOCK_OPT_SIZE,
>       NULL_OPT_ZEROES,
> @@ -277,6 +282,7 @@ static BlockDriver bdrv_null_co = {
>       .bdrv_file_open         = null_file_open,
>       .bdrv_parse_filename    = null_co_parse_filename,
>       .bdrv_getlength         = null_getlength,
> +    .bdrv_get_allocated_file_size = null_allocated_file_size,
>   
>       .bdrv_co_preadv         = null_co_preadv,
>       .bdrv_co_pwritev        = null_co_pwritev,
> @@ -297,6 +303,7 @@ static BlockDriver bdrv_null_aio = {
>       .bdrv_file_open         = null_file_open,
>       .bdrv_parse_filename    = null_aio_parse_filename,
>       .bdrv_getlength         = null_getlength,
> +    .bdrv_get_allocated_file_size = null_allocated_file_size,
>   
>       .bdrv_aio_preadv        = null_aio_preadv,
>       .bdrv_aio_pwritev       = null_aio_pwritev,
> diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
> index b2a90caa6b..8659e6463b 100644
> --- a/tests/qemu-iotests/153.out
> +++ b/tests/qemu-iotests/153.out
> @@ -461,7 +461,7 @@ No conflict:
>   image: null-co://
>   file format: null-co
>   virtual size: 1 GiB (1073741824 bytes)
> -disk size: unavailable
> +disk size: 0 B
>   
>   Conflict:
>   qemu-img: --force-share/-U conflicts with image options
> diff --git a/tests/qemu-iotests/184.out b/tests/qemu-iotests/184.out
> index 3deb3cfb94..28b104da89 100644
> --- a/tests/qemu-iotests/184.out
> +++ b/tests/qemu-iotests/184.out
> @@ -29,7 +29,8 @@ Testing:
>               "image": {
>                   "virtual-size": 1073741824,
>                   "filename": "json:{\"throttle-group\": \"group0\", \"driver\": \"throttle\", \"file\": {\"driver\": \"null-co\"}}",
> -                "format": "throttle"
> +                "format": "throttle",
> +                "actual-size": SIZE


If we remove the _filter_generated_node_ids() in the current 
implementation of the test #184, we will get '"actual-size": 0'. It 
might be more informative when analyzing the output in 184.out.

Andrey


>               },
>               "iops_wr": 0,
>               "ro": false,
> @@ -56,7 +57,8 @@ Testing:
>               "image": {
>                   "virtual-size": 1073741824,
>                   "filename": "null-co://",
> -                "format": "null-co"
> +                "format": "null-co",
> +                "actual-size": SIZE
>               },
>               "iops_wr": 0,
>               "ro": false,


Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Max Reitz July 24, 2020, 8:58 a.m. UTC | #2
On 20.07.20 17:10, Andrey Shinkevich wrote:
> On 25.06.2020 18:21, Max Reitz wrote:
>> It is trivial, so we might as well do it.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>   block/null.c               | 7 +++++++
>>   tests/qemu-iotests/153.out | 2 +-
>>   tests/qemu-iotests/184.out | 6 ++++--
>>   3 files changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/block/null.c b/block/null.c
>> index 15e1d56746..cc9b1d4ea7 100644
>> --- a/block/null.c
>> +++ b/block/null.c
>> @@ -262,6 +262,11 @@ static void
>> null_refresh_filename(BlockDriverState *bs)
>>                bs->drv->format_name);
>>   }
>>   +static int64_t null_allocated_file_size(BlockDriverState *bs)
>> +{
>> +    return 0;
>> +}
>> +
>>   static const char *const null_strong_runtime_opts[] = {
>>       BLOCK_OPT_SIZE,
>>       NULL_OPT_ZEROES,
>> @@ -277,6 +282,7 @@ static BlockDriver bdrv_null_co = {
>>       .bdrv_file_open         = null_file_open,
>>       .bdrv_parse_filename    = null_co_parse_filename,
>>       .bdrv_getlength         = null_getlength,
>> +    .bdrv_get_allocated_file_size = null_allocated_file_size,
>>         .bdrv_co_preadv         = null_co_preadv,
>>       .bdrv_co_pwritev        = null_co_pwritev,
>> @@ -297,6 +303,7 @@ static BlockDriver bdrv_null_aio = {
>>       .bdrv_file_open         = null_file_open,
>>       .bdrv_parse_filename    = null_aio_parse_filename,
>>       .bdrv_getlength         = null_getlength,
>> +    .bdrv_get_allocated_file_size = null_allocated_file_size,
>>         .bdrv_aio_preadv        = null_aio_preadv,
>>       .bdrv_aio_pwritev       = null_aio_pwritev,
>> diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
>> index b2a90caa6b..8659e6463b 100644
>> --- a/tests/qemu-iotests/153.out
>> +++ b/tests/qemu-iotests/153.out
>> @@ -461,7 +461,7 @@ No conflict:
>>   image: null-co://
>>   file format: null-co
>>   virtual size: 1 GiB (1073741824 bytes)
>> -disk size: unavailable
>> +disk size: 0 B
>>     Conflict:
>>   qemu-img: --force-share/-U conflicts with image options
>> diff --git a/tests/qemu-iotests/184.out b/tests/qemu-iotests/184.out
>> index 3deb3cfb94..28b104da89 100644
>> --- a/tests/qemu-iotests/184.out
>> +++ b/tests/qemu-iotests/184.out
>> @@ -29,7 +29,8 @@ Testing:
>>               "image": {
>>                   "virtual-size": 1073741824,
>>                   "filename": "json:{\"throttle-group\": \"group0\",
>> \"driver\": \"throttle\", \"file\": {\"driver\": \"null-co\"}}",
>> -                "format": "throttle"
>> +                "format": "throttle",
>> +                "actual-size": SIZE
> 
> 
> If we remove the _filter_generated_node_ids() in the current
> implementation of the test #184, we will get '"actual-size": 0'. It
> might be more informative when analyzing the output in 184.out.

You mean _filter_actual_image_size?  Yeah, why not, it doesn’t seem
necessary here.

Max
Andrey Shinkevich July 24, 2020, 9:49 a.m. UTC | #3
On 24.07.2020 11:58, Max Reitz wrote:
> On 20.07.20 17:10, Andrey Shinkevich wrote:
>> On 25.06.2020 18:21, Max Reitz wrote:
>>> It is trivial, so we might as well do it.
>>>
>>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>>> ---
>>>    block/null.c               | 7 +++++++
>>>    tests/qemu-iotests/153.out | 2 +-
>>>    tests/qemu-iotests/184.out | 6 ++++--
>>>    3 files changed, 12 insertions(+), 3 deletions(-)
...
>>> diff --git a/tests/qemu-iotests/184.out b/tests/qemu-iotests/184.out
>>> index 3deb3cfb94..28b104da89 100644
>>> --- a/tests/qemu-iotests/184.out
>>> +++ b/tests/qemu-iotests/184.out
>>> @@ -29,7 +29,8 @@ Testing:
>>>                "image": {
>>>                    "virtual-size": 1073741824,
>>>                    "filename": "json:{\"throttle-group\": \"group0\",
>>> \"driver\": \"throttle\", \"file\": {\"driver\": \"null-co\"}}",
>>> -                "format": "throttle"
>>> +                "format": "throttle",
>>> +                "actual-size": SIZE
>>
>> If we remove the _filter_generated_node_ids() in the current
>> implementation of the test #184, we will get '"actual-size": 0'. It
>> might be more informative when analyzing the output in 184.out.
> You mean _filter_actual_image_size?  Yeah, why not, it doesn’t seem
> necessary here.
>
> Max
>

Yes Max, you are right, I ment the _filter_actual_image_size. It was my 
copy/paste mistake.

Andrey
diff mbox series

Patch

diff --git a/block/null.c b/block/null.c
index 15e1d56746..cc9b1d4ea7 100644
--- a/block/null.c
+++ b/block/null.c
@@ -262,6 +262,11 @@  static void null_refresh_filename(BlockDriverState *bs)
              bs->drv->format_name);
 }
 
+static int64_t null_allocated_file_size(BlockDriverState *bs)
+{
+    return 0;
+}
+
 static const char *const null_strong_runtime_opts[] = {
     BLOCK_OPT_SIZE,
     NULL_OPT_ZEROES,
@@ -277,6 +282,7 @@  static BlockDriver bdrv_null_co = {
     .bdrv_file_open         = null_file_open,
     .bdrv_parse_filename    = null_co_parse_filename,
     .bdrv_getlength         = null_getlength,
+    .bdrv_get_allocated_file_size = null_allocated_file_size,
 
     .bdrv_co_preadv         = null_co_preadv,
     .bdrv_co_pwritev        = null_co_pwritev,
@@ -297,6 +303,7 @@  static BlockDriver bdrv_null_aio = {
     .bdrv_file_open         = null_file_open,
     .bdrv_parse_filename    = null_aio_parse_filename,
     .bdrv_getlength         = null_getlength,
+    .bdrv_get_allocated_file_size = null_allocated_file_size,
 
     .bdrv_aio_preadv        = null_aio_preadv,
     .bdrv_aio_pwritev       = null_aio_pwritev,
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
index b2a90caa6b..8659e6463b 100644
--- a/tests/qemu-iotests/153.out
+++ b/tests/qemu-iotests/153.out
@@ -461,7 +461,7 @@  No conflict:
 image: null-co://
 file format: null-co
 virtual size: 1 GiB (1073741824 bytes)
-disk size: unavailable
+disk size: 0 B
 
 Conflict:
 qemu-img: --force-share/-U conflicts with image options
diff --git a/tests/qemu-iotests/184.out b/tests/qemu-iotests/184.out
index 3deb3cfb94..28b104da89 100644
--- a/tests/qemu-iotests/184.out
+++ b/tests/qemu-iotests/184.out
@@ -29,7 +29,8 @@  Testing:
             "image": {
                 "virtual-size": 1073741824,
                 "filename": "json:{\"throttle-group\": \"group0\", \"driver\": \"throttle\", \"file\": {\"driver\": \"null-co\"}}",
-                "format": "throttle"
+                "format": "throttle",
+                "actual-size": SIZE
             },
             "iops_wr": 0,
             "ro": false,
@@ -56,7 +57,8 @@  Testing:
             "image": {
                 "virtual-size": 1073741824,
                 "filename": "null-co://",
-                "format": "null-co"
+                "format": "null-co",
+                "actual-size": SIZE
             },
             "iops_wr": 0,
             "ro": false,