* [Qemu-devel] [PATCHv3] migration: catch unknown flags in ram_load
@ 2014-06-10 8:04 Peter Lieven
2014-06-10 8:45 ` Amit Shah
0 siblings, 1 reply; 5+ messages in thread
From: Peter Lieven @ 2014-06-10 8:04 UTC (permalink / raw)
To: qemu-devel, --cc=dgilbert
Cc: quintela, Peter Lieven, qemu-stable, amit.shah, pbonzini
if a saved vm has unknown flags in the memory data qemu
currently simply ignores this flag and continues which
yields in an unpredictable result.
this patch catches all unknown flags and
aborts the loading of the vm.
CC: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
---
v2->v3: - reworked last case in the if statement
- added an error_report in case of an unknown flag [David]
v1->v2: rework loop from do ... while to while [Juan]
arch_init.c | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 9f1a174..93a1191 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -1041,17 +1041,15 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
{
ram_addr_t addr;
int flags, ret = 0;
- int error;
static uint64_t seq_iter;
seq_iter++;
if (version_id != 4) {
ret = -EINVAL;
- goto done;
}
- do {
+ while (!ret) {
addr = qemu_get_be64(f);
flags = addr & ~TARGET_PAGE_MASK;
@@ -1079,7 +1077,6 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
" in != " RAM_ADDR_FMT, id, length,
block->length);
ret = -EINVAL;
- goto done;
}
break;
}
@@ -1089,21 +1086,21 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
error_report("Unknown ramblock \"%s\", cannot "
"accept migration", id);
ret = -EINVAL;
- goto done;
+ }
+ if (ret) {
+ break;
}
total_ram_bytes -= length;
}
- }
-
- if (flags & RAM_SAVE_FLAG_COMPRESS) {
+ } else if (flags & RAM_SAVE_FLAG_COMPRESS) {
void *host;
uint8_t ch;
host = host_from_stream_offset(f, addr, flags);
if (!host) {
ret = -EINVAL;
- goto done;
+ break;
}
ch = qemu_get_byte(f);
@@ -1114,7 +1111,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
host = host_from_stream_offset(f, addr, flags);
if (!host) {
ret = -EINVAL;
- goto done;
+ break;
}
qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
@@ -1122,24 +1119,23 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
void *host = host_from_stream_offset(f, addr, flags);
if (!host) {
ret = -EINVAL;
- goto done;
+ break;
}
if (load_xbzrle(f, addr, host) < 0) {
ret = -EINVAL;
- goto done;
+ break;
}
} else if (flags & RAM_SAVE_FLAG_HOOK) {
ram_control_load_hook(f, flags);
+ } else if (!(flags & RAM_SAVE_FLAG_EOS)) {
+ error_report("Unknown migration flags: %#x", flags);
+ ret = -EINVAL;
+ break;
}
- error = qemu_file_get_error(f);
- if (error) {
- ret = error;
- goto done;
- }
- } while (!(flags & RAM_SAVE_FLAG_EOS));
+ ret = qemu_file_get_error(f);
+ }
-done:
DPRINTF("Completed load of VM with exit code %d seq iteration "
"%" PRIu64 "\n", ret, seq_iter);
return ret;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCHv3] migration: catch unknown flags in ram_load
2014-06-10 8:04 [Qemu-devel] [PATCHv3] migration: catch unknown flags in ram_load Peter Lieven
@ 2014-06-10 8:45 ` Amit Shah
2014-06-10 8:47 ` Peter Lieven
0 siblings, 1 reply; 5+ messages in thread
From: Amit Shah @ 2014-06-10 8:45 UTC (permalink / raw)
To: Peter Lieven; +Cc: quintela, qemu-stable, qemu-devel, pbonzini, dgilbert
On (Tue) 10 Jun 2014 [10:04:23], Peter Lieven wrote:
> if a saved vm has unknown flags in the memory data qemu
> currently simply ignores this flag and continues which
> yields in an unpredictable result.
>
> this patch catches all unknown flags and
> aborts the loading of the vm.
>
> CC: qemu-stable@nongnu.org
> Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
> ---
> v2->v3: - reworked last case in the if statement
> - added an error_report in case of an unknown flag [David]
Thanks. Would be nice to get an error_report() for the other error
conditions, too. It's not fun to learn migration has failed, w/o any
clue of why or where.
Amit
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCHv3] migration: catch unknown flags in ram_load
2014-06-10 8:45 ` Amit Shah
@ 2014-06-10 8:47 ` Peter Lieven
2014-06-10 9:03 ` Amit Shah
2014-06-10 9:30 ` Juan Quintela
0 siblings, 2 replies; 5+ messages in thread
From: Peter Lieven @ 2014-06-10 8:47 UTC (permalink / raw)
To: Amit Shah; +Cc: quintela, qemu-stable, qemu-devel, pbonzini, dgilbert
On 10.06.2014 10:45, Amit Shah wrote:
> On (Tue) 10 Jun 2014 [10:04:23], Peter Lieven wrote:
>> if a saved vm has unknown flags in the memory data qemu
>> currently simply ignores this flag and continues which
>> yields in an unpredictable result.
>>
>> this patch catches all unknown flags and
>> aborts the loading of the vm.
>>
>> CC: qemu-stable@nongnu.org
>> Signed-off-by: Peter Lieven <pl@kamp.de>
> Reviewed-by: Amit Shah <amit.shah@redhat.com>
>
>> ---
>> v2->v3: - reworked last case in the if statement
>> - added an error_report in case of an unknown flag [David]
> Thanks. Would be nice to get an error_report() for the other error
> conditions, too. It's not fun to learn migration has failed, w/o any
> clue of why or where.
Ok, will send v4.
Peter
>
> Amit
--
Mit freundlichen Grüßen
Peter Lieven
...........................................................
KAMP Netzwerkdienste GmbH
Vestische Str. 89-91 | 46117 Oberhausen
Tel: +49 (0) 208.89 402-50 | Fax: +49 (0) 208.89 402-40
pl@kamp.de | http://www.kamp.de
Geschäftsführer: Heiner Lante | Michael Lante
Amtsgericht Duisburg | HRB Nr. 12154
USt-Id-Nr.: DE 120607556
...........................................................
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCHv3] migration: catch unknown flags in ram_load
2014-06-10 8:47 ` Peter Lieven
@ 2014-06-10 9:03 ` Amit Shah
2014-06-10 9:30 ` Juan Quintela
1 sibling, 0 replies; 5+ messages in thread
From: Amit Shah @ 2014-06-10 9:03 UTC (permalink / raw)
To: Peter Lieven; +Cc: quintela, qemu-stable, qemu-devel, pbonzini, dgilbert
On (Tue) 10 Jun 2014 [10:47:56], Peter Lieven wrote:
> On 10.06.2014 10:45, Amit Shah wrote:
> >On (Tue) 10 Jun 2014 [10:04:23], Peter Lieven wrote:
> >>if a saved vm has unknown flags in the memory data qemu
> >>currently simply ignores this flag and continues which
> >>yields in an unpredictable result.
> >>
> >>this patch catches all unknown flags and
> >>aborts the loading of the vm.
> >>
> >>CC: qemu-stable@nongnu.org
> >>Signed-off-by: Peter Lieven <pl@kamp.de>
> >Reviewed-by: Amit Shah <amit.shah@redhat.com>
> >
> >>---
> >>v2->v3: - reworked last case in the if statement
> >> - added an error_report in case of an unknown flag [David]
> >Thanks. Would be nice to get an error_report() for the other error
> >conditions, too. It's not fun to learn migration has failed, w/o any
> >clue of why or where.
>
> Ok, will send v4.
Thank you!
Amit
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCHv3] migration: catch unknown flags in ram_load
2014-06-10 8:47 ` Peter Lieven
2014-06-10 9:03 ` Amit Shah
@ 2014-06-10 9:30 ` Juan Quintela
1 sibling, 0 replies; 5+ messages in thread
From: Juan Quintela @ 2014-06-10 9:30 UTC (permalink / raw)
To: Peter Lieven; +Cc: qemu-stable, qemu-devel, Amit Shah, pbonzini, dgilbert
Peter Lieven <pl@kamp.de> wrote:
> On 10.06.2014 10:45, Amit Shah wrote:
>> On (Tue) 10 Jun 2014 [10:04:23], Peter Lieven wrote:
>>> if a saved vm has unknown flags in the memory data qemu
>>> currently simply ignores this flag and continues which
>>> yields in an unpredictable result.
>>>
>>> this patch catches all unknown flags and
>>> aborts the loading of the vm.
>>>
>>> CC: qemu-stable@nongnu.org
>>> Signed-off-by: Peter Lieven <pl@kamp.de>
>> Reviewed-by: Amit Shah <amit.shah@redhat.com>
>>
>>> ---
>>> v2->v3: - reworked last case in the if statement
>>> - added an error_report in case of an unknown flag [David]
>> Thanks. Would be nice to get an error_report() for the other error
>> conditions, too. It's not fun to learn migration has failed, w/o any
>> clue of why or where.
>
> Ok, will send v4.
>
> Peter
Thanks very much.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-10 9:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-10 8:04 [Qemu-devel] [PATCHv3] migration: catch unknown flags in ram_load Peter Lieven
2014-06-10 8:45 ` Amit Shah
2014-06-10 8:47 ` Peter Lieven
2014-06-10 9:03 ` Amit Shah
2014-06-10 9:30 ` Juan Quintela
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).