qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v2 for-2.10 4/4] block: Add some bdrv_truncate()


From: Max Reitz
Subject: Re: [Qemu-block] [PATCH v2 for-2.10 4/4] block: Add some bdrv_truncate() error messages
Date: Tue, 28 Mar 2017 21:35:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 23.03.2017 19:03, Kevin Wolf wrote:
> Am 08.03.2017 um 20:15 hat Max Reitz geschrieben:
>> Add missing error messages for the drivers I am comfortable to do this
>> in.
>>
>> Since one of these changes touches a mis-indented block in
>> block/file-posix.c, this patch fixes that coding style issue along the
>> way.
>>
>> Signed-off-by: Max Reitz <address@hidden>
> 
>> diff --git a/block/qcow2.c b/block/qcow2.c
>> index 17585fbb89..53b0bd61a7 100644
>> --- a/block/qcow2.c
>> +++ b/block/qcow2.c
>> @@ -2550,6 +2550,7 @@ static int qcow2_truncate(BlockDriverState *bs, 
>> int64_t offset, Error **errp)
>>      new_l1_size = size_to_l1(s, offset);
>>      ret = qcow2_grow_l1_table(bs, new_l1_size, true);
>>      if (ret < 0) {
>> +        error_setg(errp, "Failed to grow the L1 table");
> 
> Let's not throw away error codes, error_setg_errno() is your friend.

:-)

Will do. Not sure why I haven't.

Max

>>          return ret;
>>      }
>>  
>> @@ -2558,6 +2559,7 @@ static int qcow2_truncate(BlockDriverState *bs, 
>> int64_t offset, Error **errp)
>>      ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size),
>>                             &offset, sizeof(uint64_t));
>>      if (ret < 0) {
>> +        error_setg(errp, "Failed to update the image size");
> 
> Here, too.
> 
>>          return ret;
>>      }
>>  
>> diff --git a/block/qed.c b/block/qed.c
>> index fa2aeee471..eb346d645b 100644
>> --- a/block/qed.c
>> +++ b/block/qed.c
>> @@ -1526,11 +1526,12 @@ static int bdrv_qed_truncate(BlockDriverState *bs, 
>> int64_t offset, Error **errp)
>>  
>>      if (!qed_is_image_size_valid(offset, s->header.cluster_size,
>>                                   s->header.table_size)) {
>> +        error_setg(errp, "Invalid image size specified");
>>          return -EINVAL;
>>      }
>>  
>> -    /* Shrinking is currently not supported */
>>      if ((uint64_t)offset < s->header.image_size) {
>> +        error_setg(errp, "Shrinking images is currently not supported");
>>          return -ENOTSUP;
>>      }
>>  
>> @@ -1539,6 +1540,7 @@ static int bdrv_qed_truncate(BlockDriverState *bs, 
>> int64_t offset, Error **errp)
>>      ret = qed_write_header_sync(s);
>>      if (ret < 0) {
>>          s->header.image_size = old_image_size;
>> +        error_setg(errp, "Failed to update the image size");
> 
> As well as here.
> 
>>      }
>>      return ret;
>>  }
> 
> Kevin
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]