On Fri, Mar 16, 2018 at 12:54:00PM +0100, Juan Quintela wrote: > Signed-off-by: Juan Quintela <quint...@redhat.com> > > -- > > Be network agnostic. > Add error checking for all values. > --- > migration/ram.c | 97 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 92 insertions(+), 5 deletions(-) >
> +static int multifd_recv_initial_packet(QIOChannel *c, Error **errp) > +{ > + MultiFDInit_t msg; > + int ret; > + > + ret = qio_channel_read_all(c, (char *)&msg, sizeof(msg), errp); > + if (ret != 0) { > + return -1; > + } > + > + be32_to_cpus(&msg.magic); > + be32_to_cpus(&msg.version); > + > + if (msg.magic != MULTIFD_MAGIC) { > + error_setg(errp, "multifd: recevied packet magic %d " s/recevied/received/ and in few places below too > + "expected %d", msg.magic, MULTIFD_MAGIC); > + return -1; > + } > + > + if (msg.version != MULTIFD_VERSION) { > + error_setg(errp, "multifd: recevied packet version %d " > + "expected %d", msg.version, MULTIFD_VERSION); > + return -1; > + } > + > + if (memcmp(msg.uuid, &qemu_uuid, sizeof(qemu_uuid))) { > + char *uuid = qemu_uuid_unparse_strdup(&qemu_uuid); > + error_setg(errp, "multifd: received uuid '%s' and expected " > + "uuid '%s' for channel %hhd", msg.uuid, uuid, msg.id); > + g_free(uuid); > + return -1; > + } > + > + if (msg.id > migrate_multifd_channels()) { > + error_setg(errp, "multifd: recevied channel version %d " > + "expected %d", msg.version, MULTIFD_VERSION); > + return -1; > + } > + > + return msg.id; > +} Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|