diff mbox

[v2,2/3] block/parallals: Do not update header or truncate image when INMIGRATE

Message ID e3abcb61ba8cdc2bb236368ab14a9037cbe7729b.1509368614.git.jcody@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Cody Oct. 30, 2017, 1:10 p.m. UTC
If we write or modify the image file while the QEMU run state is
INMIGRATE, then the BDRV_O_INACTIVE BDS flag is set.  This will cause
an assert, since the image is marked inactive.  Make sure we obey this
flag.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 block/parallels.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Stefan Hajnoczi Nov. 3, 2017, 11:05 a.m. UTC | #1
On Mon, Oct 30, 2017 at 02:10:27PM +0100, Jeff Cody wrote:
> If we write or modify the image file while the QEMU run state is
> INMIGRATE, then the BDRV_O_INACTIVE BDS flag is set.  This will cause
> an assert, since the image is marked inactive.  Make sure we obey this
> flag.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  block/parallels.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/block/parallels.c b/block/parallels.c
> index 2b6c6e5709..7b7a3efa1d 100644
> --- a/block/parallels.c
> +++ b/block/parallels.c
> @@ -708,7 +708,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
>          s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE;
>      }
>  
> -    if (flags & BDRV_O_RDWR) {
> +    if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_INACTIVE)) {
>          s->header->inuse = cpu_to_le32(HEADER_INUSE_MAGIC);
>          ret = parallels_update_header(bs);
>          if (ret < 0) {

Where do we ensure that HEADER_INUSE_MAGIC is set on the destination?
Denis V. Lunev Nov. 3, 2017, 11:08 a.m. UTC | #2
On 11/03/2017 02:05 PM, Stefan Hajnoczi wrote:
> On Mon, Oct 30, 2017 at 02:10:27PM +0100, Jeff Cody wrote:
>> If we write or modify the image file while the QEMU run state is
>> INMIGRATE, then the BDRV_O_INACTIVE BDS flag is set.  This will cause
>> an assert, since the image is marked inactive.  Make sure we obey this
>> flag.
>>
>> Signed-off-by: Jeff Cody <jcody@redhat.com>
>> ---
>>  block/parallels.c | 7 ++-----
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/block/parallels.c b/block/parallels.c
>> index 2b6c6e5709..7b7a3efa1d 100644
>> --- a/block/parallels.c
>> +++ b/block/parallels.c
>> @@ -708,7 +708,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
>>          s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE;
>>      }
>>  
>> -    if (flags & BDRV_O_RDWR) {
>> +    if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_INACTIVE)) {
>>          s->header->inuse = cpu_to_le32(HEADER_INUSE_MAGIC);
>>          ret = parallels_update_header(bs);
>>          if (ret < 0) {
> Where do we ensure that HEADER_INUSE_MAGIC is set on the destination?
good point. it should be set in invalidate_cache following QCOW2 scheme.
Thus we should add that callback with this patch.
Jeff Cody Nov. 6, 2017, 8:23 p.m. UTC | #3
On Fri, Nov 03, 2017 at 02:08:13PM +0300, Denis V. Lunev wrote:
> On 11/03/2017 02:05 PM, Stefan Hajnoczi wrote:
> > On Mon, Oct 30, 2017 at 02:10:27PM +0100, Jeff Cody wrote:
> >> If we write or modify the image file while the QEMU run state is
> >> INMIGRATE, then the BDRV_O_INACTIVE BDS flag is set.  This will cause
> >> an assert, since the image is marked inactive.  Make sure we obey this
> >> flag.
> >>
> >> Signed-off-by: Jeff Cody <jcody@redhat.com>
> >> ---
> >>  block/parallels.c | 7 ++-----
> >>  1 file changed, 2 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/block/parallels.c b/block/parallels.c
> >> index 2b6c6e5709..7b7a3efa1d 100644
> >> --- a/block/parallels.c
> >> +++ b/block/parallels.c
> >> @@ -708,7 +708,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
> >>          s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE;
> >>      }
> >>  
> >> -    if (flags & BDRV_O_RDWR) {
> >> +    if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_INACTIVE)) {
> >>          s->header->inuse = cpu_to_le32(HEADER_INUSE_MAGIC);
> >>          ret = parallels_update_header(bs);
> >>          if (ret < 0) {
> > Where do we ensure that HEADER_INUSE_MAGIC is set on the destination?
> good point. it should be set in invalidate_cache following QCOW2 scheme.
> Thus we should add that callback with this patch.
> 


Do we (intentionally) support migration with parallels?  I guess so, since
it doesn't have migration blockers.
Jeff Cody Nov. 7, 2017, 2:25 a.m. UTC | #4
On Mon, Nov 06, 2017 at 03:23:43PM -0500, Jeff Cody wrote:
> On Fri, Nov 03, 2017 at 02:08:13PM +0300, Denis V. Lunev wrote:
> > On 11/03/2017 02:05 PM, Stefan Hajnoczi wrote:
> > > On Mon, Oct 30, 2017 at 02:10:27PM +0100, Jeff Cody wrote:
> > >> If we write or modify the image file while the QEMU run state is
> > >> INMIGRATE, then the BDRV_O_INACTIVE BDS flag is set.  This will cause
> > >> an assert, since the image is marked inactive.  Make sure we obey this
> > >> flag.
> > >>
> > >> Signed-off-by: Jeff Cody <jcody@redhat.com>
> > >> ---
> > >>  block/parallels.c | 7 ++-----
> > >>  1 file changed, 2 insertions(+), 5 deletions(-)
> > >>
> > >> diff --git a/block/parallels.c b/block/parallels.c
> > >> index 2b6c6e5709..7b7a3efa1d 100644
> > >> --- a/block/parallels.c
> > >> +++ b/block/parallels.c
> > >> @@ -708,7 +708,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
> > >>          s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE;
> > >>      }
> > >>  
> > >> -    if (flags & BDRV_O_RDWR) {
> > >> +    if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_INACTIVE)) {
> > >>          s->header->inuse = cpu_to_le32(HEADER_INUSE_MAGIC);
> > >>          ret = parallels_update_header(bs);
> > >>          if (ret < 0) {
> > > Where do we ensure that HEADER_INUSE_MAGIC is set on the destination?
> > good point. it should be set in invalidate_cache following QCOW2 scheme.
> > Thus we should add that callback with this patch.
> > 
> 
> 
> Do we (intentionally) support migration with parallels?  I guess so, since
> it doesn't have migration blockers.

Hmm, I hit send prematurely...

Despite not having migration blockers, obviously nobody is using migration
with parallels; from v2.6.0 to now, attempting to do so causes QEMU to
assert due to the bug fixed in this patch.

Rather than implement .bdrv_invalidate_cache() in this series, I am going to
set a migration blocker in a separate patch (in this series), so that
migration is not supported.  Whenever .bdrv_invalidate_cache() is
implemented, then the blocker can be removed.

-Jeff
diff mbox

Patch

diff --git a/block/parallels.c b/block/parallels.c
index 2b6c6e5709..7b7a3efa1d 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -708,7 +708,7 @@  static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
         s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE;
     }
 
-    if (flags & BDRV_O_RDWR) {
+    if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_INACTIVE)) {
         s->header->inuse = cpu_to_le32(HEADER_INUSE_MAGIC);
         ret = parallels_update_header(bs);
         if (ret < 0) {
@@ -741,12 +741,9 @@  static void parallels_close(BlockDriverState *bs)
 {
     BDRVParallelsState *s = bs->opaque;
 
-    if (bs->open_flags & BDRV_O_RDWR) {
+    if ((bs->open_flags & BDRV_O_RDWR) && !(bs->open_flags & BDRV_O_INACTIVE)) {
         s->header->inuse = 0;
         parallels_update_header(bs);
-    }
-
-    if (bs->open_flags & BDRV_O_RDWR) {
         bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS,
                       PREALLOC_MODE_OFF, NULL);
     }