Skip to contentSkip to conversation

block: simple changes

PATCH In review Denis V. Lunev 3 participants 9 messages Apr 5, 2017 – Apr 13, 2017

lore
Share & tools
lore
#0 lore raw

cover block: simple changes

First patch here is one we have agreed on during the initial discussion about truncate() in parallels format driver, another one is simple coding style change spotted by my student.

Denis V. Lunev (1):
block: assert no image modification under BDRV_O_INACTIVE

Klim Kireev (1):
block: fix obvious coding style mitakes in block_int.h

 block.c                   | 2 ++
 include/block/block_int.h | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 block: fix obvious coding style mitakes in block_int.h

From: Klim Kireev <[email protected]>

---
 include/block/block_int.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/block/block_int.h +3 -3
index 59400bd..bf18c5f 100644
@@ -252,7 +252,7 @@ struct BlockDriver {
      * Returns 0 for completed check, -errno for internal errors.
      * The check results are stored in result.
      */
-    int (*bdrv_check)(BlockDriverState* bs, BdrvCheckResult *result,
+    int (*bdrv_check)(BlockDriverState *bs, BdrvCheckResult *result,
         BdrvCheckMode fix);
 
     int (*bdrv_amend_options)(BlockDriverState *bs, QemuOpts *opts,
@@ -454,13 +454,13 @@ struct BdrvChildRole {
     /* Returns a name that is supposedly more useful for human users than the
      * node name for identifying the node in question (in particular, a BB
      * name), or NULL if the parent can't provide a better name. */
-    const char* (*get_name)(BdrvChild *child);
+    const char *(*get_name)(BdrvChild *child);
 
     /* Returns a malloced string that describes the parent of the child for a
      * human reader. This could be a node-name, BlockBackend name, qdev ID or
      * QOM path of the device owning the BlockBackend, job type and ID etc. The
      * caller is responsible for freeing the memory. */
-    char* (*get_parent_desc)(BdrvChild *child);
+    char *(*get_parent_desc)(BdrvChild *child);
 
     /*
      * If this pair of functions is implemented, the parent doesn't issue new
Signature · 1 line
2.7.4
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] block: fix obvious coding style mitakes in block_int.h

Quoted 1 line · Denis V. Lunev

From: Klim Kireev <[email protected]>

s/mitakes/mistakes/ in the subject

A blank commit message body doesn't help - the subject says what was changed but not why (for example, output of checkpatch.pl without the patch applied); and details may help in grepping past history when looking for the change or even to justify that the change is not just churn.

Quoted 9 lines
---
 include/block/block_int.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

At any rate, all of the changes (the fact that we prefer binding the pointer operator * to the name on the right rather than the type on the left) look sane.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] block: fix obvious coding style mitakes in block_int.h

Quoted 20 lines · Eric Blake
Quoted 1 line · Denis V. Lunev

From: Klim Kireev <[email protected]>

s/mitakes/mistakes/ in the subject

A blank commit message body doesn't help - the subject says what was changed but not why (for example, output of checkpatch.pl without the patch applied); and details may help in grepping past history when looking for the change or even to justify that the change is not just churn.

Quoted 9 lines
---
 include/block/block_int.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 3 lines

At any rate, all of the changes (the fact that we prefer binding the pointer operator * to the name on the right rather than the type on the left) look sane.

I know someone who disagrees but that someone also knows that I will support and accept this kind of patches gladly. O:-)

Max

Quoted 1 line
#4 lore raw

PATCH 2/2 block: assert no image modification under BDRV_O_INACTIVE

In reply to Denis V. Lunev

As long as BDRV_O_INACTIVE is set, the image file is only opened so we have a file descriptor for it. We're definitely not supposed to modify the image, it's still owned by the migration source.

This commit is an addition to 09e0c771 but the assert() is added to bdrv_truncate().

---
 block.c | 2 ++
 1 file changed, 2 insertions(+)
block.c +2 -0
index 927ba89..9273741 100644
@@ -3279,6 +3279,8 @@ int bdrv_truncate(BdrvChild *child, int64_t offset)
     if (bs->read_only)
         return -EACCES;
 
+    assert(!(bs->open_flags & BDRV_O_INACTIVE));
+
     ret = drv->bdrv_truncate(bs, offset);
     if (ret == 0) {
         ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);
Signature · 1 line
2.7.4
Reviewed-by on v1 2/2
#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] block: assert no image modification under BDRV_O_INACTIVE

Quoted 7 lines · Denis V. Lunev

As long as BDRV_O_INACTIVE is set, the image file is only opened so we have a file descriptor for it. We're definitely not supposed to modify the image, it's still owned by the migration source.

This commit is an addition to 09e0c771 but the assert() is added to bdrv_truncate().

Quoted 6 lines
---
 block.c | 2 ++
 1 file changed, 2 insertions(+)

I don't feel comfortable adding an assert this late in the 2.9 phase, but think it makes perfect sense as a 2.10 addition.

Quoted 15 lines
block.c +2 -0
index 927ba89..9273741 100644
@@ -3279,6 +3279,8 @@ int bdrv_truncate(BdrvChild *child, int64_t offset)
     if (bs->read_only)
         return -EACCES;
 
+    assert(!(bs->open_flags & BDRV_O_INACTIVE));
+
     ret = drv->bdrv_truncate(bs, offset);
     if (ret == 0) {
         ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#6 lore raw

Re: [Qemu-devel] [PATCH 2/2] block: assert no image modification under BDRV_O_INACTIVE

Quoted 14 lines · Eric Blake
Quoted 7 lines · Denis V. Lunev

As long as BDRV_O_INACTIVE is set, the image file is only opened so we have a file descriptor for it. We're definitely not supposed to modify the image, it's still owned by the migration source.

This commit is an addition to 09e0c771 but the assert() is added to bdrv_truncate().

Quoted 6 lines
---
 block.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 4 lines

I don't feel comfortable adding an assert this late in the 2.9 phase, but think it makes perfect sense as a 2.10 addition.

no-no, this is for 2.10 for sure. No way for 2.9. I have stated that in cover letter :(
Sorry for inconvenience.

Den

#7 lore raw

Re: [Qemu-devel] [PATCH 2/2] block: assert no image modification under BDRV_O_INACTIVE

In reply to Denis V. Lunev
Quoted 7 lines · Denis V. Lunev

As long as BDRV_O_INACTIVE is set, the image file is only opened so we have a file descriptor for it. We're definitely not supposed to modify the image, it's still owned by the migration source.

This commit is an addition to 09e0c771 but the assert() is added to bdrv_truncate().

Quoted 6 lines
---
 block.c | 2 ++
 1 file changed, 2 insertions(+)

Thanks to the new op blockers I'm not sure this is really necessary anymore (that assertion should cover this, once it's reinstated, that is...), but it won't hurt, I guess.

Max

#8 lore raw
In reply to Denis V. Lunev
Quoted 11 lines · Denis V. Lunev

First patch here is one we have agreed on during the initial discussion about truncate() in parallels format driver, another one is simple coding style change spotted by my student.

Denis V. Lunev (1):
block: assert no image modification under BDRV_O_INACTIVE

Quoted 6 lines

Klim Kireev (1):
block: fix obvious coding style mitakes in block_int.h

 block.c                   | 2 ++
 include/block/block_int.h | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

Thanks, fixed the subject of the first patch and applied to my block-next branch:

https://github.com/XanClic/qemu/commits/block-next

Max