* [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup @ 2017-05-18 16:16 Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 1/9] migration: Create migration/xbzrle.h Juan Quintela ` (8 more replies) 0 siblings, 9 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx Hi Changes from v3 Only copyright notices: included the diff to make it easier to see: - channel.{c,h} -> goes to Daniel Berrange - qemu-file-channel.h -> same one than qemu-file-channel.c I hope this is ok now. Thanks, Juan. diff --git a/migration/channel.c b/migration/channel.c index fed8563..124857d 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -1,10 +1,10 @@ /* - * QEMU live migration + * QEMU live migration channel operations * - * Copyright IBM, Corp. 2008 + * Copyright Red Hat, Inc. 2016 * * Authors: - * Anthony Liguori <aliguori@us.ibm.com> + * Daniel P. Berrange <berrange@redhat.com> * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. diff --git a/migration/channel.h b/migration/channel.h index 618acb7..2e0a7e3 100644 --- a/migration/channel.h +++ b/migration/channel.h @@ -1,14 +1,16 @@ /* - * QEMU live migration channel functions + * QEMU live migration channel operations * - * Copyright IBM, Corp. 2008 + * Copyright Red Hat, Inc. 2016 * * Authors: - * Anthony Liguori <aliguori@us.ibm.com> + * Daniel P. Berrange <berrange@redhat.com> * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. */ #ifndef QEMU_MIGRATION_CHANNEL_H diff --git a/migration/qemu-file-channel.h b/migration/qemu-file-channel.h index d1bd5ff..0028a09 100644 --- a/migration/qemu-file-channel.h +++ b/migration/qemu-file-channel.h @@ -1,14 +1,25 @@ /* - * QEMU migration file channel operations + * QEMUFile backend for QIOChannel objects * - * Copyright IBM, Corp. 2008 + * Copyright (c) 2015-2016 Red Hat, Inc * - * Authors: - * Anthony Liguori <aliguori@us.ibm.com> + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #ifndef QEMU_FILE_CHANNEL_H [v3] - dropped movement of colo*h headers they are used in other palaces in patches outside the tree - Change the license of vmstate*c files to GPL v2+ Dave noted that I was using the wrong text - page_cache.c movement was already reviewd and it has no conflicts, moved to pull request. Please, review Thanks, Juan. [v3] Due to popular demand, and to make reviews easier, I just split the big cleanup series (41 patches) in small chunks. This chunk just include the easy patches: - create several include files foo.h for functcions exported from foo.c - split channel operations in channel.c - move colo headers to migration/ - split vmstate-types.c from vmstate.c (now it only contains the interpreter) - untangle qemu-file.h, vmstate.h and migration.h. Now none include the other fix all callers. - Remove uses of migration.h that are not needed Juan Quintela (9): migration: Create migration/xbzrle.h migration: Split migration/channel.c for channel operations migration: Export qemu-file-channel.c functions in its own file migration: Remove migration.h from colo.h migration: Move qjson.h to migration/ migration: Split vmstate-types.c from vmstate.c migration: Remove qemu-file.h from vmstate.h migration: Remove vmstate.h from migration.h migration: migration.h was not needed block/qed.c | 1 - hw/i386/pc_q35.c | 1 - hw/virtio/vhost-user.c | 1 - hw/virtio/vhost-vsock.c | 1 - hw/virtio/virtio.c | 1 - include/hw/hw.h | 1 + include/migration/colo.h | 1 - include/migration/migration.h | 13 +- include/migration/qemu-file.h | 4 - include/migration/vmstate.h | 3 - migration/Makefile.objs | 4 +- migration/block.c | 2 + migration/channel.c | 70 ++++ migration/channel.h | 27 ++ migration/colo-comm.c | 4 +- migration/colo.c | 3 + migration/exec.c | 1 + migration/fd.c | 1 + migration/migration.c | 52 +-- migration/postcopy-ram.c | 1 + migration/qemu-file-channel.c | 1 + migration/qemu-file-channel.h | 32 ++ migration/qjson.c | 2 +- {include/migration => migration}/qjson.h | 0 migration/ram.c | 3 + migration/rdma.c | 1 + migration/savevm.c | 1 + migration/socket.c | 1 + migration/tls.c | 1 + migration/vmstate-types.c | 661 +++++++++++++++++++++++++++++++ migration/vmstate.c | 656 +----------------------------- migration/xbzrle.c | 2 +- migration/xbzrle.h | 21 + monitor.c | 1 - tests/Makefile.include | 2 +- tests/test-vmstate.c | 2 + tests/test-xbzrle.c | 2 +- 37 files changed, 855 insertions(+), 726 deletions(-) create mode 100644 migration/channel.c create mode 100644 migration/channel.h create mode 100644 migration/qemu-file-channel.h rename {include/migration => migration}/qjson.h (100%) create mode 100644 migration/vmstate-types.c create mode 100644 migration/xbzrle.h -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 1/9] migration: Create migration/xbzrle.h 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela @ 2017-05-18 16:16 ` Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 2/9] migration: Split migration/channel.c for channel operations Juan Quintela ` (7 subsequent siblings) 8 siblings, 0 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> --- include/migration/migration.h | 4 ---- migration/ram.c | 1 + migration/xbzrle.c | 2 +- migration/xbzrle.h | 21 +++++++++++++++++++++ tests/test-xbzrle.c | 2 +- 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 migration/xbzrle.h diff --git a/include/migration/migration.h b/include/migration/migration.h index b80a6ed..7d1eef7 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -251,10 +251,6 @@ bool migrate_zero_blocks(void); bool migrate_auto_converge(void); -int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen, - uint8_t *dst, int dlen); -int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen); - int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); bool migrate_colo_enabled(void); diff --git a/migration/ram.c b/migration/ram.c index 59459ef..c14269f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -35,6 +35,7 @@ #include "qemu/bitmap.h" #include "qemu/timer.h" #include "qemu/main-loop.h" +#include "xbzrle.h" #include "migration/migration.h" #include "postcopy-ram.h" #include "exec/address-spaces.h" diff --git a/migration/xbzrle.c b/migration/xbzrle.c index c858339..1ba482d 100644 --- a/migration/xbzrle.c +++ b/migration/xbzrle.c @@ -12,7 +12,7 @@ */ #include "qemu/osdep.h" #include "qemu/cutils.h" -#include "include/migration/migration.h" +#include "xbzrle.h" /* page = zrun nzrun diff --git a/migration/xbzrle.h b/migration/xbzrle.h new file mode 100644 index 0000000..a0db507 --- /dev/null +++ b/migration/xbzrle.h @@ -0,0 +1,21 @@ +/* + * QEMU live migration + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Anthony Liguori <aliguori@us.ibm.com> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_MIGRATION_XBZRLE_H +#define QEMU_MIGRATION_XBZRLE_H + +int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen, + uint8_t *dst, int dlen); + +int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen); +#endif diff --git a/tests/test-xbzrle.c b/tests/test-xbzrle.c index 49f6419..f5e08de 100644 --- a/tests/test-xbzrle.c +++ b/tests/test-xbzrle.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/cutils.h" -#include "include/migration/migration.h" +#include "../migration/xbzrle.h" #define PAGE_SIZE 4096 -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 2/9] migration: Split migration/channel.c for channel operations 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 1/9] migration: Create migration/xbzrle.h Juan Quintela @ 2017-05-18 16:16 ` Juan Quintela 2017-05-18 16:40 ` Dr. David Alan Gilbert 2017-05-18 17:20 ` Dr. David Alan Gilbert 2017-05-18 16:16 ` [Qemu-devel] [PATCH 3/9] migration: Export qemu-file-channel.c functions in its own file Juan Quintela ` (6 subsequent siblings) 8 siblings, 2 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx Create an include for its exported functions. Signed-off-by: Juan Quintela <quintela@redhat.com> --- Add proper header --- include/migration/migration.h | 7 ----- migration/Makefile.objs | 2 +- migration/channel.c | 69 +++++++++++++++++++++++++++++++++++++++++++ migration/channel.h | 27 +++++++++++++++++ migration/exec.c | 1 + migration/fd.c | 1 + migration/migration.c | 50 ------------------------------- migration/socket.c | 1 + migration/tls.c | 1 + 9 files changed, 101 insertions(+), 58 deletions(-) create mode 100644 migration/channel.c create mode 100644 migration/channel.h diff --git a/include/migration/migration.h b/include/migration/migration.h index 7d1eef7..e831259 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -157,17 +157,10 @@ void migration_fd_process_incoming(QEMUFile *f); void qemu_start_incoming_migration(const char *uri, Error **errp); -void migration_channel_process_incoming(MigrationState *s, - QIOChannel *ioc); - void migration_tls_channel_process_incoming(MigrationState *s, QIOChannel *ioc, Error **errp); -void migration_channel_connect(MigrationState *s, - QIOChannel *ioc, - const char *hostname); - void migration_tls_channel_connect(MigrationState *s, QIOChannel *ioc, const char *hostname, diff --git a/migration/Makefile.objs b/migration/Makefile.objs index 00a3f4a..4e8ab0a 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -1,5 +1,5 @@ common-obj-y += migration.o socket.o fd.o exec.o -common-obj-y += tls.o +common-obj-y += tls.o channel.o common-obj-y += colo-comm.o colo.o colo-failover.o common-obj-y += vmstate.o page_cache.o common-obj-y += qemu-file.o diff --git a/migration/channel.c b/migration/channel.c new file mode 100644 index 0000000..f50267a --- /dev/null +++ b/migration/channel.c @@ -0,0 +1,69 @@ +/* + * QEMU live migration channel operations + * + * Copyright Red Hat, Inc. 2016 + * + * Authors: + * Daniel P. Berrange <berrange@redhat.com> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#include "qemu/osdep.h" +#include "channel.h" +#include "migration/migration.h" +#include "trace.h" +#include "qapi/error.h" +#include "io/channel-tls.h" + +void migration_channel_process_incoming(MigrationState *s, + QIOChannel *ioc) +{ + trace_migration_set_incoming_channel( + ioc, object_get_typename(OBJECT(ioc))); + + if (s->parameters.tls_creds && + *s->parameters.tls_creds && + !object_dynamic_cast(OBJECT(ioc), + TYPE_QIO_CHANNEL_TLS)) { + Error *local_err = NULL; + migration_tls_channel_process_incoming(s, ioc, &local_err); + if (local_err) { + error_report_err(local_err); + } + } else { + QEMUFile *f = qemu_fopen_channel_input(ioc); + migration_fd_process_incoming(f); + } +} + + +void migration_channel_connect(MigrationState *s, + QIOChannel *ioc, + const char *hostname) +{ + trace_migration_set_outgoing_channel( + ioc, object_get_typename(OBJECT(ioc)), hostname); + + if (s->parameters.tls_creds && + *s->parameters.tls_creds && + !object_dynamic_cast(OBJECT(ioc), + TYPE_QIO_CHANNEL_TLS)) { + Error *local_err = NULL; + migration_tls_channel_connect(s, ioc, hostname, &local_err); + if (local_err) { + migrate_fd_error(s, local_err); + error_free(local_err); + } + } else { + QEMUFile *f = qemu_fopen_channel_output(ioc); + + s->to_dst_file = f; + + migrate_fd_connect(s); + } +} diff --git a/migration/channel.h b/migration/channel.h new file mode 100644 index 0000000..2e0a7e3 --- /dev/null +++ b/migration/channel.h @@ -0,0 +1,27 @@ +/* + * QEMU live migration channel operations + * + * Copyright Red Hat, Inc. 2016 + * + * Authors: + * Daniel P. Berrange <berrange@redhat.com> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#ifndef QEMU_MIGRATION_CHANNEL_H +#define QEMU_MIGRATION_CHANNEL_H + +#include "io/channel.h" + +void migration_channel_process_incoming(MigrationState *s, + QIOChannel *ioc); + +void migration_channel_connect(MigrationState *s, + QIOChannel *ioc, + const char *hostname); +#endif diff --git a/migration/exec.c b/migration/exec.c index aba9089..57a9335 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "channel.h" #include "migration/migration.h" #include "io/channel-command.h" #include "trace.h" diff --git a/migration/fd.c b/migration/fd.c index 58cb51a..05e0a5c 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -17,6 +17,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "channel.h" #include "migration/migration.h" #include "monitor/monitor.h" #include "io/channel-util.h" diff --git a/migration/migration.c b/migration/migration.c index 2feeee8..217616d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -444,56 +444,6 @@ void migration_fd_process_incoming(QEMUFile *f) qemu_coroutine_enter(co); } - -void migration_channel_process_incoming(MigrationState *s, - QIOChannel *ioc) -{ - trace_migration_set_incoming_channel( - ioc, object_get_typename(OBJECT(ioc))); - - if (s->parameters.tls_creds && - *s->parameters.tls_creds && - !object_dynamic_cast(OBJECT(ioc), - TYPE_QIO_CHANNEL_TLS)) { - Error *local_err = NULL; - migration_tls_channel_process_incoming(s, ioc, &local_err); - if (local_err) { - error_report_err(local_err); - } - } else { - QEMUFile *f = qemu_fopen_channel_input(ioc); - migration_fd_process_incoming(f); - } -} - - -void migration_channel_connect(MigrationState *s, - QIOChannel *ioc, - const char *hostname) -{ - trace_migration_set_outgoing_channel( - ioc, object_get_typename(OBJECT(ioc)), hostname); - - if (s->parameters.tls_creds && - *s->parameters.tls_creds && - !object_dynamic_cast(OBJECT(ioc), - TYPE_QIO_CHANNEL_TLS)) { - Error *local_err = NULL; - migration_tls_channel_connect(s, ioc, hostname, &local_err); - if (local_err) { - migrate_fd_error(s, local_err); - error_free(local_err); - } - } else { - QEMUFile *f = qemu_fopen_channel_output(ioc); - - s->to_dst_file = f; - - migrate_fd_connect(s); - } -} - - /* * Send a message on the return channel back to the source * of the migration. diff --git a/migration/socket.c b/migration/socket.c index 1cfbe81..53f9d61 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -19,6 +19,7 @@ #include "qemu-common.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "channel.h" #include "migration/migration.h" #include "migration/qemu-file.h" #include "io/channel-socket.h" diff --git a/migration/tls.c b/migration/tls.c index a33ecb7..34ad121 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -19,6 +19,7 @@ */ #include "qemu/osdep.h" +#include "channel.h" #include "migration/migration.h" #include "io/channel-tls.h" #include "crypto/tlscreds.h" -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 2/9] migration: Split migration/channel.c for channel operations 2017-05-18 16:16 ` [Qemu-devel] [PATCH 2/9] migration: Split migration/channel.c for channel operations Juan Quintela @ 2017-05-18 16:40 ` Dr. David Alan Gilbert 2017-05-18 16:46 ` Daniel P. Berrange 2017-05-18 17:20 ` Dr. David Alan Gilbert 1 sibling, 1 reply; 17+ messages in thread From: Dr. David Alan Gilbert @ 2017-05-18 16:40 UTC (permalink / raw) To: Juan Quintela, berrange; +Cc: qemu-devel, lvivier, peterx * Juan Quintela (quintela@redhat.com) wrote: > Create an include for its exported functions. > > Signed-off-by: Juan Quintela <quintela@redhat.com> > > --- > Add proper header > --- > include/migration/migration.h | 7 ----- > migration/Makefile.objs | 2 +- > migration/channel.c | 69 +++++++++++++++++++++++++++++++++++++++++++ > migration/channel.h | 27 +++++++++++++++++ > migration/exec.c | 1 + > migration/fd.c | 1 + > migration/migration.c | 50 ------------------------------- > migration/socket.c | 1 + > migration/tls.c | 1 + > 9 files changed, 101 insertions(+), 58 deletions(-) > create mode 100644 migration/channel.c > create mode 100644 migration/channel.h > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index 7d1eef7..e831259 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -157,17 +157,10 @@ void migration_fd_process_incoming(QEMUFile *f); > > void qemu_start_incoming_migration(const char *uri, Error **errp); > > -void migration_channel_process_incoming(MigrationState *s, > - QIOChannel *ioc); > - > void migration_tls_channel_process_incoming(MigrationState *s, > QIOChannel *ioc, > Error **errp); > > -void migration_channel_connect(MigrationState *s, > - QIOChannel *ioc, > - const char *hostname); > - > void migration_tls_channel_connect(MigrationState *s, > QIOChannel *ioc, > const char *hostname, > diff --git a/migration/Makefile.objs b/migration/Makefile.objs > index 00a3f4a..4e8ab0a 100644 > --- a/migration/Makefile.objs > +++ b/migration/Makefile.objs > @@ -1,5 +1,5 @@ > common-obj-y += migration.o socket.o fd.o exec.o > -common-obj-y += tls.o > +common-obj-y += tls.o channel.o > common-obj-y += colo-comm.o colo.o colo-failover.o > common-obj-y += vmstate.o page_cache.o > common-obj-y += qemu-file.o > diff --git a/migration/channel.c b/migration/channel.c > new file mode 100644 > index 0000000..f50267a > --- /dev/null > +++ b/migration/channel.c > @@ -0,0 +1,69 @@ > +/* > + * QEMU live migration channel operations > + * > + * Copyright Red Hat, Inc. 2016 > + * > + * Authors: > + * Daniel P. Berrange <berrange@redhat.com> > + * > + * This work is licensed under the terms of the GNU GPL, version 2. See > + * the COPYING file in the top-level directory. > + * > + * Contributions after 2012-01-13 are licensed under the terms of the > + * GNU GPL, version 2 or (at your option) any later version. > + */ OK, better - but... isn't all this after 2012? Since it is I think you need the header that says it's v2 or later (e.g. the one on migration/page_cache.c ) But just get Dan to agree. Other than that I'm happy. Dave > +#include "qemu/osdep.h" > +#include "channel.h" > +#include "migration/migration.h" > +#include "trace.h" > +#include "qapi/error.h" > +#include "io/channel-tls.h" > + > +void migration_channel_process_incoming(MigrationState *s, > + QIOChannel *ioc) > +{ > + trace_migration_set_incoming_channel( > + ioc, object_get_typename(OBJECT(ioc))); > + > + if (s->parameters.tls_creds && > + *s->parameters.tls_creds && > + !object_dynamic_cast(OBJECT(ioc), > + TYPE_QIO_CHANNEL_TLS)) { > + Error *local_err = NULL; > + migration_tls_channel_process_incoming(s, ioc, &local_err); > + if (local_err) { > + error_report_err(local_err); > + } > + } else { > + QEMUFile *f = qemu_fopen_channel_input(ioc); > + migration_fd_process_incoming(f); > + } > +} > + > + > +void migration_channel_connect(MigrationState *s, > + QIOChannel *ioc, > + const char *hostname) > +{ > + trace_migration_set_outgoing_channel( > + ioc, object_get_typename(OBJECT(ioc)), hostname); > + > + if (s->parameters.tls_creds && > + *s->parameters.tls_creds && > + !object_dynamic_cast(OBJECT(ioc), > + TYPE_QIO_CHANNEL_TLS)) { > + Error *local_err = NULL; > + migration_tls_channel_connect(s, ioc, hostname, &local_err); > + if (local_err) { > + migrate_fd_error(s, local_err); > + error_free(local_err); > + } > + } else { > + QEMUFile *f = qemu_fopen_channel_output(ioc); > + > + s->to_dst_file = f; > + > + migrate_fd_connect(s); > + } > +} > diff --git a/migration/channel.h b/migration/channel.h > new file mode 100644 > index 0000000..2e0a7e3 > --- /dev/null > +++ b/migration/channel.h > @@ -0,0 +1,27 @@ > +/* > + * QEMU live migration channel operations > + * > + * Copyright Red Hat, Inc. 2016 > + * > + * Authors: > + * Daniel P. Berrange <berrange@redhat.com> > + * > + * This work is licensed under the terms of the GNU GPL, version 2. See > + * the COPYING file in the top-level directory. > + * > + * Contributions after 2012-01-13 are licensed under the terms of the > + * GNU GPL, version 2 or (at your option) any later version. > + */ > + > +#ifndef QEMU_MIGRATION_CHANNEL_H > +#define QEMU_MIGRATION_CHANNEL_H > + > +#include "io/channel.h" > + > +void migration_channel_process_incoming(MigrationState *s, > + QIOChannel *ioc); > + > +void migration_channel_connect(MigrationState *s, > + QIOChannel *ioc, > + const char *hostname); > +#endif > diff --git a/migration/exec.c b/migration/exec.c > index aba9089..57a9335 100644 > --- a/migration/exec.c > +++ b/migration/exec.c > @@ -20,6 +20,7 @@ > #include "qemu/osdep.h" > #include "qapi/error.h" > #include "qemu-common.h" > +#include "channel.h" > #include "migration/migration.h" > #include "io/channel-command.h" > #include "trace.h" > diff --git a/migration/fd.c b/migration/fd.c > index 58cb51a..05e0a5c 100644 > --- a/migration/fd.c > +++ b/migration/fd.c > @@ -17,6 +17,7 @@ > #include "qemu/osdep.h" > #include "qapi/error.h" > #include "qemu-common.h" > +#include "channel.h" > #include "migration/migration.h" > #include "monitor/monitor.h" > #include "io/channel-util.h" > diff --git a/migration/migration.c b/migration/migration.c > index 2feeee8..217616d 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -444,56 +444,6 @@ void migration_fd_process_incoming(QEMUFile *f) > qemu_coroutine_enter(co); > } > > - > -void migration_channel_process_incoming(MigrationState *s, > - QIOChannel *ioc) > -{ > - trace_migration_set_incoming_channel( > - ioc, object_get_typename(OBJECT(ioc))); > - > - if (s->parameters.tls_creds && > - *s->parameters.tls_creds && > - !object_dynamic_cast(OBJECT(ioc), > - TYPE_QIO_CHANNEL_TLS)) { > - Error *local_err = NULL; > - migration_tls_channel_process_incoming(s, ioc, &local_err); > - if (local_err) { > - error_report_err(local_err); > - } > - } else { > - QEMUFile *f = qemu_fopen_channel_input(ioc); > - migration_fd_process_incoming(f); > - } > -} > - > - > -void migration_channel_connect(MigrationState *s, > - QIOChannel *ioc, > - const char *hostname) > -{ > - trace_migration_set_outgoing_channel( > - ioc, object_get_typename(OBJECT(ioc)), hostname); > - > - if (s->parameters.tls_creds && > - *s->parameters.tls_creds && > - !object_dynamic_cast(OBJECT(ioc), > - TYPE_QIO_CHANNEL_TLS)) { > - Error *local_err = NULL; > - migration_tls_channel_connect(s, ioc, hostname, &local_err); > - if (local_err) { > - migrate_fd_error(s, local_err); > - error_free(local_err); > - } > - } else { > - QEMUFile *f = qemu_fopen_channel_output(ioc); > - > - s->to_dst_file = f; > - > - migrate_fd_connect(s); > - } > -} > - > - > /* > * Send a message on the return channel back to the source > * of the migration. > diff --git a/migration/socket.c b/migration/socket.c > index 1cfbe81..53f9d61 100644 > --- a/migration/socket.c > +++ b/migration/socket.c > @@ -19,6 +19,7 @@ > #include "qemu-common.h" > #include "qemu/error-report.h" > #include "qapi/error.h" > +#include "channel.h" > #include "migration/migration.h" > #include "migration/qemu-file.h" > #include "io/channel-socket.h" > diff --git a/migration/tls.c b/migration/tls.c > index a33ecb7..34ad121 100644 > --- a/migration/tls.c > +++ b/migration/tls.c > @@ -19,6 +19,7 @@ > */ > > #include "qemu/osdep.h" > +#include "channel.h" > #include "migration/migration.h" > #include "io/channel-tls.h" > #include "crypto/tlscreds.h" > -- > 2.9.3 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 2/9] migration: Split migration/channel.c for channel operations 2017-05-18 16:40 ` Dr. David Alan Gilbert @ 2017-05-18 16:46 ` Daniel P. Berrange 0 siblings, 0 replies; 17+ messages in thread From: Daniel P. Berrange @ 2017-05-18 16:46 UTC (permalink / raw) To: Dr. David Alan Gilbert; +Cc: Juan Quintela, qemu-devel, lvivier, peterx On Thu, May 18, 2017 at 05:40:54PM +0100, Dr. David Alan Gilbert wrote: > * Juan Quintela (quintela@redhat.com) wrote: > > Create an include for its exported functions. > > > > Signed-off-by: Juan Quintela <quintela@redhat.com> > > > > --- > > Add proper header > > --- > > include/migration/migration.h | 7 ----- > > migration/Makefile.objs | 2 +- > > migration/channel.c | 69 +++++++++++++++++++++++++++++++++++++++++++ > > migration/channel.h | 27 +++++++++++++++++ > > migration/exec.c | 1 + > > migration/fd.c | 1 + > > migration/migration.c | 50 ------------------------------- > > migration/socket.c | 1 + > > migration/tls.c | 1 + > > 9 files changed, 101 insertions(+), 58 deletions(-) > > create mode 100644 migration/channel.c > > create mode 100644 migration/channel.h > > > > diff --git a/include/migration/migration.h b/include/migration/migration.h > > index 7d1eef7..e831259 100644 > > --- a/include/migration/migration.h > > +++ b/include/migration/migration.h > > @@ -157,17 +157,10 @@ void migration_fd_process_incoming(QEMUFile *f); > > > > void qemu_start_incoming_migration(const char *uri, Error **errp); > > > > -void migration_channel_process_incoming(MigrationState *s, > > - QIOChannel *ioc); > > - > > void migration_tls_channel_process_incoming(MigrationState *s, > > QIOChannel *ioc, > > Error **errp); > > > > -void migration_channel_connect(MigrationState *s, > > - QIOChannel *ioc, > > - const char *hostname); > > - > > void migration_tls_channel_connect(MigrationState *s, > > QIOChannel *ioc, > > const char *hostname, > > diff --git a/migration/Makefile.objs b/migration/Makefile.objs > > index 00a3f4a..4e8ab0a 100644 > > --- a/migration/Makefile.objs > > +++ b/migration/Makefile.objs > > @@ -1,5 +1,5 @@ > > common-obj-y += migration.o socket.o fd.o exec.o > > -common-obj-y += tls.o > > +common-obj-y += tls.o channel.o > > common-obj-y += colo-comm.o colo.o colo-failover.o > > common-obj-y += vmstate.o page_cache.o > > common-obj-y += qemu-file.o > > diff --git a/migration/channel.c b/migration/channel.c > > new file mode 100644 > > index 0000000..f50267a > > --- /dev/null > > +++ b/migration/channel.c > > @@ -0,0 +1,69 @@ > > +/* > > + * QEMU live migration channel operations > > + * > > + * Copyright Red Hat, Inc. 2016 > > + * > > + * Authors: > > + * Daniel P. Berrange <berrange@redhat.com> > > + * > > + * This work is licensed under the terms of the GNU GPL, version 2. See > > + * the COPYING file in the top-level directory. > > + * > > + * Contributions after 2012-01-13 are licensed under the terms of the > > + * GNU GPL, version 2 or (at your option) any later version. > > + */ > > OK, better - but... isn't all this after 2012? > Since it is I think you need the header that says it's v2 or later > (e.g. the one on migration/page_cache.c ) Yes, all the code that has been copied into these new files post-dates that. So you can just mark the whole files (both .c and .h) as v2 or later. 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 :| ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 2/9] migration: Split migration/channel.c for channel operations 2017-05-18 16:16 ` [Qemu-devel] [PATCH 2/9] migration: Split migration/channel.c for channel operations Juan Quintela 2017-05-18 16:40 ` Dr. David Alan Gilbert @ 2017-05-18 17:20 ` Dr. David Alan Gilbert 1 sibling, 0 replies; 17+ messages in thread From: Dr. David Alan Gilbert @ 2017-05-18 17:20 UTC (permalink / raw) To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx * Juan Quintela (quintela@redhat.com) wrote: > Create an include for its exported functions. > > Signed-off-by: Juan Quintela <quintela@redhat.com> Other than needing to fix the GPLv2 to be GPLv2 or later, Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > --- > Add proper header > --- > include/migration/migration.h | 7 ----- > migration/Makefile.objs | 2 +- > migration/channel.c | 69 +++++++++++++++++++++++++++++++++++++++++++ > migration/channel.h | 27 +++++++++++++++++ > migration/exec.c | 1 + > migration/fd.c | 1 + > migration/migration.c | 50 ------------------------------- > migration/socket.c | 1 + > migration/tls.c | 1 + > 9 files changed, 101 insertions(+), 58 deletions(-) > create mode 100644 migration/channel.c > create mode 100644 migration/channel.h > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index 7d1eef7..e831259 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -157,17 +157,10 @@ void migration_fd_process_incoming(QEMUFile *f); > > void qemu_start_incoming_migration(const char *uri, Error **errp); > > -void migration_channel_process_incoming(MigrationState *s, > - QIOChannel *ioc); > - > void migration_tls_channel_process_incoming(MigrationState *s, > QIOChannel *ioc, > Error **errp); > > -void migration_channel_connect(MigrationState *s, > - QIOChannel *ioc, > - const char *hostname); > - > void migration_tls_channel_connect(MigrationState *s, > QIOChannel *ioc, > const char *hostname, > diff --git a/migration/Makefile.objs b/migration/Makefile.objs > index 00a3f4a..4e8ab0a 100644 > --- a/migration/Makefile.objs > +++ b/migration/Makefile.objs > @@ -1,5 +1,5 @@ > common-obj-y += migration.o socket.o fd.o exec.o > -common-obj-y += tls.o > +common-obj-y += tls.o channel.o > common-obj-y += colo-comm.o colo.o colo-failover.o > common-obj-y += vmstate.o page_cache.o > common-obj-y += qemu-file.o > diff --git a/migration/channel.c b/migration/channel.c > new file mode 100644 > index 0000000..f50267a > --- /dev/null > +++ b/migration/channel.c > @@ -0,0 +1,69 @@ > +/* > + * QEMU live migration channel operations > + * > + * Copyright Red Hat, Inc. 2016 > + * > + * Authors: > + * Daniel P. Berrange <berrange@redhat.com> > + * > + * This work is licensed under the terms of the GNU GPL, version 2. See > + * the COPYING file in the top-level directory. > + * > + * Contributions after 2012-01-13 are licensed under the terms of the > + * GNU GPL, version 2 or (at your option) any later version. > + */ > + > +#include "qemu/osdep.h" > +#include "channel.h" > +#include "migration/migration.h" > +#include "trace.h" > +#include "qapi/error.h" > +#include "io/channel-tls.h" > + > +void migration_channel_process_incoming(MigrationState *s, > + QIOChannel *ioc) > +{ > + trace_migration_set_incoming_channel( > + ioc, object_get_typename(OBJECT(ioc))); > + > + if (s->parameters.tls_creds && > + *s->parameters.tls_creds && > + !object_dynamic_cast(OBJECT(ioc), > + TYPE_QIO_CHANNEL_TLS)) { > + Error *local_err = NULL; > + migration_tls_channel_process_incoming(s, ioc, &local_err); > + if (local_err) { > + error_report_err(local_err); > + } > + } else { > + QEMUFile *f = qemu_fopen_channel_input(ioc); > + migration_fd_process_incoming(f); > + } > +} > + > + > +void migration_channel_connect(MigrationState *s, > + QIOChannel *ioc, > + const char *hostname) > +{ > + trace_migration_set_outgoing_channel( > + ioc, object_get_typename(OBJECT(ioc)), hostname); > + > + if (s->parameters.tls_creds && > + *s->parameters.tls_creds && > + !object_dynamic_cast(OBJECT(ioc), > + TYPE_QIO_CHANNEL_TLS)) { > + Error *local_err = NULL; > + migration_tls_channel_connect(s, ioc, hostname, &local_err); > + if (local_err) { > + migrate_fd_error(s, local_err); > + error_free(local_err); > + } > + } else { > + QEMUFile *f = qemu_fopen_channel_output(ioc); > + > + s->to_dst_file = f; > + > + migrate_fd_connect(s); > + } > +} > diff --git a/migration/channel.h b/migration/channel.h > new file mode 100644 > index 0000000..2e0a7e3 > --- /dev/null > +++ b/migration/channel.h > @@ -0,0 +1,27 @@ > +/* > + * QEMU live migration channel operations > + * > + * Copyright Red Hat, Inc. 2016 > + * > + * Authors: > + * Daniel P. Berrange <berrange@redhat.com> > + * > + * This work is licensed under the terms of the GNU GPL, version 2. See > + * the COPYING file in the top-level directory. > + * > + * Contributions after 2012-01-13 are licensed under the terms of the > + * GNU GPL, version 2 or (at your option) any later version. > + */ > + > +#ifndef QEMU_MIGRATION_CHANNEL_H > +#define QEMU_MIGRATION_CHANNEL_H > + > +#include "io/channel.h" > + > +void migration_channel_process_incoming(MigrationState *s, > + QIOChannel *ioc); > + > +void migration_channel_connect(MigrationState *s, > + QIOChannel *ioc, > + const char *hostname); > +#endif > diff --git a/migration/exec.c b/migration/exec.c > index aba9089..57a9335 100644 > --- a/migration/exec.c > +++ b/migration/exec.c > @@ -20,6 +20,7 @@ > #include "qemu/osdep.h" > #include "qapi/error.h" > #include "qemu-common.h" > +#include "channel.h" > #include "migration/migration.h" > #include "io/channel-command.h" > #include "trace.h" > diff --git a/migration/fd.c b/migration/fd.c > index 58cb51a..05e0a5c 100644 > --- a/migration/fd.c > +++ b/migration/fd.c > @@ -17,6 +17,7 @@ > #include "qemu/osdep.h" > #include "qapi/error.h" > #include "qemu-common.h" > +#include "channel.h" > #include "migration/migration.h" > #include "monitor/monitor.h" > #include "io/channel-util.h" > diff --git a/migration/migration.c b/migration/migration.c > index 2feeee8..217616d 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -444,56 +444,6 @@ void migration_fd_process_incoming(QEMUFile *f) > qemu_coroutine_enter(co); > } > > - > -void migration_channel_process_incoming(MigrationState *s, > - QIOChannel *ioc) > -{ > - trace_migration_set_incoming_channel( > - ioc, object_get_typename(OBJECT(ioc))); > - > - if (s->parameters.tls_creds && > - *s->parameters.tls_creds && > - !object_dynamic_cast(OBJECT(ioc), > - TYPE_QIO_CHANNEL_TLS)) { > - Error *local_err = NULL; > - migration_tls_channel_process_incoming(s, ioc, &local_err); > - if (local_err) { > - error_report_err(local_err); > - } > - } else { > - QEMUFile *f = qemu_fopen_channel_input(ioc); > - migration_fd_process_incoming(f); > - } > -} > - > - > -void migration_channel_connect(MigrationState *s, > - QIOChannel *ioc, > - const char *hostname) > -{ > - trace_migration_set_outgoing_channel( > - ioc, object_get_typename(OBJECT(ioc)), hostname); > - > - if (s->parameters.tls_creds && > - *s->parameters.tls_creds && > - !object_dynamic_cast(OBJECT(ioc), > - TYPE_QIO_CHANNEL_TLS)) { > - Error *local_err = NULL; > - migration_tls_channel_connect(s, ioc, hostname, &local_err); > - if (local_err) { > - migrate_fd_error(s, local_err); > - error_free(local_err); > - } > - } else { > - QEMUFile *f = qemu_fopen_channel_output(ioc); > - > - s->to_dst_file = f; > - > - migrate_fd_connect(s); > - } > -} > - > - > /* > * Send a message on the return channel back to the source > * of the migration. > diff --git a/migration/socket.c b/migration/socket.c > index 1cfbe81..53f9d61 100644 > --- a/migration/socket.c > +++ b/migration/socket.c > @@ -19,6 +19,7 @@ > #include "qemu-common.h" > #include "qemu/error-report.h" > #include "qapi/error.h" > +#include "channel.h" > #include "migration/migration.h" > #include "migration/qemu-file.h" > #include "io/channel-socket.h" > diff --git a/migration/tls.c b/migration/tls.c > index a33ecb7..34ad121 100644 > --- a/migration/tls.c > +++ b/migration/tls.c > @@ -19,6 +19,7 @@ > */ > > #include "qemu/osdep.h" > +#include "channel.h" > #include "migration/migration.h" > #include "io/channel-tls.h" > #include "crypto/tlscreds.h" > -- > 2.9.3 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK ^ permalink raw reply [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 3/9] migration: Export qemu-file-channel.c functions in its own file 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 1/9] migration: Create migration/xbzrle.h Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 2/9] migration: Split migration/channel.c for channel operations Juan Quintela @ 2017-05-18 16:16 ` Juan Quintela 2017-05-18 17:08 ` Dr. David Alan Gilbert 2017-05-19 2:47 ` Peter Xu 2017-05-18 16:16 ` [Qemu-devel] [PATCH 4/9] migration: Remove migration.h from colo.h Juan Quintela ` (5 subsequent siblings) 8 siblings, 2 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx Signed-off-by: Juan Quintela <quintela@redhat.com> --- include/migration/migration.h | 1 + include/migration/qemu-file.h | 4 ---- migration/channel.c | 1 + migration/colo.c | 1 + migration/migration.c | 1 + migration/qemu-file-channel.c | 1 + migration/qemu-file-channel.h | 32 ++++++++++++++++++++++++++++++++ migration/rdma.c | 1 + migration/savevm.c | 1 + tests/test-vmstate.c | 1 + 10 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 migration/qemu-file-channel.h diff --git a/include/migration/migration.h b/include/migration/migration.h index e831259..8280df1 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -19,6 +19,7 @@ #include "qemu/thread.h" #include "qemu/notify.h" #include "migration/vmstate.h" +#include "io/channel.h" #include "qapi-types.h" #include "exec/cpu-common.h" #include "qemu/coroutine_int.h" diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index 0cd648a..b5ac800 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -27,8 +27,6 @@ #include "qemu-common.h" #include "exec/cpu-common.h" -#include "io/channel.h" - /* Read a chunk of data from a file at the given position. The pos argument * can be ignored if the file is only be used for streaming. The number of @@ -119,8 +117,6 @@ typedef struct QEMUFileHooks { } QEMUFileHooks; QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops); -QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc); -QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc); void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks); int qemu_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f); diff --git a/migration/channel.c b/migration/channel.c index f50267a..124857d 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -16,6 +16,7 @@ #include "qemu/osdep.h" #include "channel.h" #include "migration/migration.h" +#include "qemu-file-channel.h" #include "trace.h" #include "qapi/error.h" #include "io/channel-tls.h" diff --git a/migration/colo.c b/migration/colo.c index dd38fed..9cd0250 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" +#include "qemu-file-channel.h" #include "migration/colo.h" #include "migration/block.h" #include "io/channel-buffer.h" diff --git a/migration/migration.c b/migration/migration.c index 217616d..2d9379c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -19,6 +19,7 @@ #include "qemu/main-loop.h" #include "migration/blocker.h" #include "migration/migration.h" +#include "qemu-file-channel.h" #include "migration/qemu-file.h" #include "sysemu/sysemu.h" #include "block/block.h" diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index 45c13f1..dc991c9 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -23,6 +23,7 @@ */ #include "qemu/osdep.h" +#include "qemu-file-channel.h" #include "migration/qemu-file.h" #include "io/channel-socket.h" #include "qemu/iov.h" diff --git a/migration/qemu-file-channel.h b/migration/qemu-file-channel.h new file mode 100644 index 0000000..0028a09 --- /dev/null +++ b/migration/qemu-file-channel.h @@ -0,0 +1,32 @@ +/* + * QEMUFile backend for QIOChannel objects + * + * Copyright (c) 2015-2016 Red Hat, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_FILE_CHANNEL_H +#define QEMU_FILE_CHANNEL_H + +#include "io/channel.h" + +QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc); +QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc); +#endif diff --git a/migration/rdma.c b/migration/rdma.c index 7eaaf96..166cd60 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -20,6 +20,7 @@ #include "migration/migration.h" #include "migration/qemu-file.h" #include "exec/cpu-common.h" +#include "qemu-file-channel.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/sockets.h" diff --git a/migration/savevm.c b/migration/savevm.c index a728414..8565103 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -36,6 +36,7 @@ #include "sysemu/sysemu.h" #include "qemu/timer.h" #include "migration/migration.h" +#include "qemu-file-channel.h" #include "postcopy-ram.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index f694a89..1c13570 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -27,6 +27,7 @@ #include "qemu-common.h" #include "migration/migration.h" #include "migration/vmstate.h" +#include "../migration/qemu-file-channel.h" #include "qemu/coroutine.h" #include "io/channel-file.h" -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 3/9] migration: Export qemu-file-channel.c functions in its own file 2017-05-18 16:16 ` [Qemu-devel] [PATCH 3/9] migration: Export qemu-file-channel.c functions in its own file Juan Quintela @ 2017-05-18 17:08 ` Dr. David Alan Gilbert 2017-05-19 2:47 ` Peter Xu 1 sibling, 0 replies; 17+ messages in thread From: Dr. David Alan Gilbert @ 2017-05-18 17:08 UTC (permalink / raw) To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx * Juan Quintela (quintela@redhat.com) wrote: > Signed-off-by: Juan Quintela <quintela@redhat.com> > --- > include/migration/migration.h | 1 + > include/migration/qemu-file.h | 4 ---- > migration/channel.c | 1 + > migration/colo.c | 1 + > migration/migration.c | 1 + > migration/qemu-file-channel.c | 1 + > migration/qemu-file-channel.h | 32 ++++++++++++++++++++++++++++++++ > migration/rdma.c | 1 + > migration/savevm.c | 1 + > tests/test-vmstate.c | 1 + > 10 files changed, 40 insertions(+), 4 deletions(-) > create mode 100644 migration/qemu-file-channel.h > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index e831259..8280df1 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -19,6 +19,7 @@ > #include "qemu/thread.h" > #include "qemu/notify.h" > #include "migration/vmstate.h" > +#include "io/channel.h" > #include "qapi-types.h" > #include "exec/cpu-common.h" > #include "qemu/coroutine_int.h" > diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h > index 0cd648a..b5ac800 100644 > --- a/include/migration/qemu-file.h > +++ b/include/migration/qemu-file.h > @@ -27,8 +27,6 @@ > > #include "qemu-common.h" > #include "exec/cpu-common.h" > -#include "io/channel.h" > - > > /* Read a chunk of data from a file at the given position. The pos argument > * can be ignored if the file is only be used for streaming. The number of > @@ -119,8 +117,6 @@ typedef struct QEMUFileHooks { > } QEMUFileHooks; > > QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops); > -QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc); > -QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc); > void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks); > int qemu_get_fd(QEMUFile *f); > int qemu_fclose(QEMUFile *f); > diff --git a/migration/channel.c b/migration/channel.c > index f50267a..124857d 100644 > --- a/migration/channel.c > +++ b/migration/channel.c > @@ -16,6 +16,7 @@ > #include "qemu/osdep.h" > #include "channel.h" > #include "migration/migration.h" > +#include "qemu-file-channel.h" > #include "trace.h" > #include "qapi/error.h" > #include "io/channel-tls.h" > diff --git a/migration/colo.c b/migration/colo.c > index dd38fed..9cd0250 100644 > --- a/migration/colo.c > +++ b/migration/colo.c > @@ -13,6 +13,7 @@ > #include "qemu/osdep.h" > #include "qemu/timer.h" > #include "sysemu/sysemu.h" > +#include "qemu-file-channel.h" > #include "migration/colo.h" > #include "migration/block.h" > #include "io/channel-buffer.h" > diff --git a/migration/migration.c b/migration/migration.c > index 217616d..2d9379c 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -19,6 +19,7 @@ > #include "qemu/main-loop.h" > #include "migration/blocker.h" > #include "migration/migration.h" > +#include "qemu-file-channel.h" > #include "migration/qemu-file.h" > #include "sysemu/sysemu.h" > #include "block/block.h" > diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c > index 45c13f1..dc991c9 100644 > --- a/migration/qemu-file-channel.c > +++ b/migration/qemu-file-channel.c > @@ -23,6 +23,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qemu-file-channel.h" > #include "migration/qemu-file.h" > #include "io/channel-socket.h" > #include "qemu/iov.h" > diff --git a/migration/qemu-file-channel.h b/migration/qemu-file-channel.h > new file mode 100644 > index 0000000..0028a09 > --- /dev/null > +++ b/migration/qemu-file-channel.h > @@ -0,0 +1,32 @@ > +/* > + * QEMUFile backend for QIOChannel objects > + * > + * Copyright (c) 2015-2016 Red Hat, Inc > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ OK, I think that is correct, and we can change it to something else later if we want, so: Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > +#ifndef QEMU_FILE_CHANNEL_H > +#define QEMU_FILE_CHANNEL_H > + > +#include "io/channel.h" > + > +QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc); > +QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc); > +#endif > diff --git a/migration/rdma.c b/migration/rdma.c > index 7eaaf96..166cd60 100644 > --- a/migration/rdma.c > +++ b/migration/rdma.c > @@ -20,6 +20,7 @@ > #include "migration/migration.h" > #include "migration/qemu-file.h" > #include "exec/cpu-common.h" > +#include "qemu-file-channel.h" > #include "qemu/error-report.h" > #include "qemu/main-loop.h" > #include "qemu/sockets.h" > diff --git a/migration/savevm.c b/migration/savevm.c > index a728414..8565103 100644 > --- a/migration/savevm.c > +++ b/migration/savevm.c > @@ -36,6 +36,7 @@ > #include "sysemu/sysemu.h" > #include "qemu/timer.h" > #include "migration/migration.h" > +#include "qemu-file-channel.h" > #include "postcopy-ram.h" > #include "qapi/qmp/qerror.h" > #include "qemu/error-report.h" > diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c > index f694a89..1c13570 100644 > --- a/tests/test-vmstate.c > +++ b/tests/test-vmstate.c > @@ -27,6 +27,7 @@ > #include "qemu-common.h" > #include "migration/migration.h" > #include "migration/vmstate.h" > +#include "../migration/qemu-file-channel.h" > #include "qemu/coroutine.h" > #include "io/channel-file.h" > > -- > 2.9.3 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 3/9] migration: Export qemu-file-channel.c functions in its own file 2017-05-18 16:16 ` [Qemu-devel] [PATCH 3/9] migration: Export qemu-file-channel.c functions in its own file Juan Quintela 2017-05-18 17:08 ` Dr. David Alan Gilbert @ 2017-05-19 2:47 ` Peter Xu 1 sibling, 0 replies; 17+ messages in thread From: Peter Xu @ 2017-05-19 2:47 UTC (permalink / raw) To: Juan Quintela; +Cc: qemu-devel, dgilbert, lvivier On Thu, May 18, 2017 at 06:16:49PM +0200, Juan Quintela wrote: > Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> -- Peter Xu ^ permalink raw reply [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 4/9] migration: Remove migration.h from colo.h 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela ` (2 preceding siblings ...) 2017-05-18 16:16 ` [Qemu-devel] [PATCH 3/9] migration: Export qemu-file-channel.c functions in its own file Juan Quintela @ 2017-05-18 16:16 ` Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 5/9] migration: Move qjson.h to migration/ Juan Quintela ` (4 subsequent siblings) 8 siblings, 0 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx migration.h is not included in any includes now. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> --- include/migration/colo.h | 1 - migration/colo-comm.c | 3 ++- migration/colo.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/migration/colo.h b/include/migration/colo.h index 2bbff9e..ba0bb6e 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -14,7 +14,6 @@ #define QEMU_COLO_H #include "qemu-common.h" -#include "migration/migration.h" #include "qemu/coroutine_int.h" #include "qemu/thread.h" #include "qemu/main-loop.h" diff --git a/migration/colo-comm.c b/migration/colo-comm.c index 20b60ec..3d91798 100644 --- a/migration/colo-comm.c +++ b/migration/colo-comm.c @@ -12,7 +12,8 @@ */ #include "qemu/osdep.h" -#include <migration/colo.h> +#include "migration/migration.h" +#include "migration/colo.h" #include "trace.h" typedef struct { diff --git a/migration/colo.c b/migration/colo.c index 9cd0250..73ebd64 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -14,6 +14,7 @@ #include "qemu/timer.h" #include "sysemu/sysemu.h" #include "qemu-file-channel.h" +#include "migration/migration.h" #include "migration/colo.h" #include "migration/block.h" #include "io/channel-buffer.h" -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 5/9] migration: Move qjson.h to migration/ 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela ` (3 preceding siblings ...) 2017-05-18 16:16 ` [Qemu-devel] [PATCH 4/9] migration: Remove migration.h from colo.h Juan Quintela @ 2017-05-18 16:16 ` Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 6/9] migration: Split vmstate-types.c from vmstate.c Juan Quintela ` (3 subsequent siblings) 8 siblings, 0 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx It is only used for migration code. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> --- migration/qjson.c | 2 +- {include/migration => migration}/qjson.h | 0 migration/vmstate.c | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename {include/migration => migration}/qjson.h (100%) diff --git a/migration/qjson.c b/migration/qjson.c index f345904..9d7f6eb 100644 --- a/migration/qjson.c +++ b/migration/qjson.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include "qapi/qmp/qstring.h" -#include "migration/qjson.h" +#include "qjson.h" struct QJSON { QString *str; diff --git a/include/migration/qjson.h b/migration/qjson.h similarity index 100% rename from include/migration/qjson.h rename to migration/qjson.h diff --git a/migration/vmstate.c b/migration/vmstate.c index 7b4a607..66c50ee 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -7,7 +7,7 @@ #include "qemu/error-report.h" #include "qemu/queue.h" #include "trace.h" -#include "migration/qjson.h" +#include "qjson.h" static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, QJSON *vmdesc); -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 6/9] migration: Split vmstate-types.c from vmstate.c 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela ` (4 preceding siblings ...) 2017-05-18 16:16 ` [Qemu-devel] [PATCH 5/9] migration: Move qjson.h to migration/ Juan Quintela @ 2017-05-18 16:16 ` Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 7/9] migration: Remove qemu-file.h from vmstate.h Juan Quintela ` (2 subsequent siblings) 8 siblings, 0 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx Now one just has the interperter, and the other has the basic types. Once there, add copyright boilerplate. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> -- Use GPL v2 or later. Detected by David. --- migration/Makefile.objs | 2 +- migration/vmstate-types.c | 661 ++++++++++++++++++++++++++++++++++++++++++++++ migration/vmstate.c | 654 +-------------------------------------------- tests/Makefile.include | 2 +- 4 files changed, 675 insertions(+), 644 deletions(-) create mode 100644 migration/vmstate-types.c diff --git a/migration/Makefile.objs b/migration/Makefile.objs index 4e8ab0a..3272415 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -1,7 +1,7 @@ common-obj-y += migration.o socket.o fd.o exec.o common-obj-y += tls.o channel.o common-obj-y += colo-comm.o colo.o colo-failover.o -common-obj-y += vmstate.o page_cache.o +common-obj-y += vmstate.o vmstate-types.o page_cache.o common-obj-y += qemu-file.o common-obj-y += qemu-file-channel.o common-obj-y += xbzrle.o postcopy-ram.o diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c new file mode 100644 index 0000000..cc95e47 --- /dev/null +++ b/migration/vmstate-types.c @@ -0,0 +1,661 @@ +/* + * VMStateInfo's for basic typse + * + * Copyright (c) 2009-2017 Red Hat Inc + * + * Authors: + * Juan Quintela <quintela@redhat.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "migration/migration.h" +#include "migration/qemu-file.h" +#include "migration/vmstate.h" +#include "qemu/error-report.h" +#include "qemu/queue.h" +#include "trace.h" + +/* bool */ + +static int get_bool(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + bool *v = pv; + *v = qemu_get_byte(f); + return 0; +} + +static int put_bool(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + bool *v = pv; + qemu_put_byte(f, *v); + return 0; +} + +const VMStateInfo vmstate_info_bool = { + .name = "bool", + .get = get_bool, + .put = put_bool, +}; + +/* 8 bit int */ + +static int get_int8(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + int8_t *v = pv; + qemu_get_s8s(f, v); + return 0; +} + +static int put_int8(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + int8_t *v = pv; + qemu_put_s8s(f, v); + return 0; +} + +const VMStateInfo vmstate_info_int8 = { + .name = "int8", + .get = get_int8, + .put = put_int8, +}; + +/* 16 bit int */ + +static int get_int16(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + int16_t *v = pv; + qemu_get_sbe16s(f, v); + return 0; +} + +static int put_int16(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + int16_t *v = pv; + qemu_put_sbe16s(f, v); + return 0; +} + +const VMStateInfo vmstate_info_int16 = { + .name = "int16", + .get = get_int16, + .put = put_int16, +}; + +/* 32 bit int */ + +static int get_int32(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + int32_t *v = pv; + qemu_get_sbe32s(f, v); + return 0; +} + +static int put_int32(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + int32_t *v = pv; + qemu_put_sbe32s(f, v); + return 0; +} + +const VMStateInfo vmstate_info_int32 = { + .name = "int32", + .get = get_int32, + .put = put_int32, +}; + +/* 32 bit int. See that the received value is the same than the one + in the field */ + +static int get_int32_equal(QEMUFile *f, void *pv, size_t size, + VMStateField *field) +{ + int32_t *v = pv; + int32_t v2; + qemu_get_sbe32s(f, &v2); + + if (*v == v2) { + return 0; + } + error_report("%" PRIx32 " != %" PRIx32, *v, v2); + return -EINVAL; +} + +const VMStateInfo vmstate_info_int32_equal = { + .name = "int32 equal", + .get = get_int32_equal, + .put = put_int32, +}; + +/* 32 bit int. Check that the received value is non-negative + * and less than or equal to the one in the field. + */ + +static int get_int32_le(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + int32_t *cur = pv; + int32_t loaded; + qemu_get_sbe32s(f, &loaded); + + if (loaded >= 0 && loaded <= *cur) { + *cur = loaded; + return 0; + } + error_report("Invalid value %" PRId32 + " expecting positive value <= %" PRId32, + loaded, *cur); + return -EINVAL; +} + +const VMStateInfo vmstate_info_int32_le = { + .name = "int32 le", + .get = get_int32_le, + .put = put_int32, +}; + +/* 64 bit int */ + +static int get_int64(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + int64_t *v = pv; + qemu_get_sbe64s(f, v); + return 0; +} + +static int put_int64(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + int64_t *v = pv; + qemu_put_sbe64s(f, v); + return 0; +} + +const VMStateInfo vmstate_info_int64 = { + .name = "int64", + .get = get_int64, + .put = put_int64, +}; + +/* 8 bit unsigned int */ + +static int get_uint8(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + uint8_t *v = pv; + qemu_get_8s(f, v); + return 0; +} + +static int put_uint8(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + uint8_t *v = pv; + qemu_put_8s(f, v); + return 0; +} + +const VMStateInfo vmstate_info_uint8 = { + .name = "uint8", + .get = get_uint8, + .put = put_uint8, +}; + +/* 16 bit unsigned int */ + +static int get_uint16(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + uint16_t *v = pv; + qemu_get_be16s(f, v); + return 0; +} + +static int put_uint16(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + uint16_t *v = pv; + qemu_put_be16s(f, v); + return 0; +} + +const VMStateInfo vmstate_info_uint16 = { + .name = "uint16", + .get = get_uint16, + .put = put_uint16, +}; + +/* 32 bit unsigned int */ + +static int get_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + uint32_t *v = pv; + qemu_get_be32s(f, v); + return 0; +} + +static int put_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + uint32_t *v = pv; + qemu_put_be32s(f, v); + return 0; +} + +const VMStateInfo vmstate_info_uint32 = { + .name = "uint32", + .get = get_uint32, + .put = put_uint32, +}; + +/* 32 bit uint. See that the received value is the same than the one + in the field */ + +static int get_uint32_equal(QEMUFile *f, void *pv, size_t size, + VMStateField *field) +{ + uint32_t *v = pv; + uint32_t v2; + qemu_get_be32s(f, &v2); + + if (*v == v2) { + return 0; + } + error_report("%" PRIx32 " != %" PRIx32, *v, v2); + return -EINVAL; +} + +const VMStateInfo vmstate_info_uint32_equal = { + .name = "uint32 equal", + .get = get_uint32_equal, + .put = put_uint32, +}; + +/* 64 bit unsigned int */ + +static int get_uint64(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + uint64_t *v = pv; + qemu_get_be64s(f, v); + return 0; +} + +static int put_uint64(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + uint64_t *v = pv; + qemu_put_be64s(f, v); + return 0; +} + +const VMStateInfo vmstate_info_uint64 = { + .name = "uint64", + .get = get_uint64, + .put = put_uint64, +}; + +static int get_nullptr(QEMUFile *f, void *pv, size_t size, VMStateField *field) + +{ + if (qemu_get_byte(f) == VMS_NULLPTR_MARKER) { + return 0; + } + error_report("vmstate: get_nullptr expected VMS_NULLPTR_MARKER"); + return -EINVAL; +} + +static int put_nullptr(QEMUFile *f, void *pv, size_t size, + VMStateField *field, QJSON *vmdesc) + +{ + if (pv == NULL) { + qemu_put_byte(f, VMS_NULLPTR_MARKER); + return 0; + } + error_report("vmstate: put_nullptr must be called with pv == NULL"); + return -EINVAL; +} + +const VMStateInfo vmstate_info_nullptr = { + .name = "uint64", + .get = get_nullptr, + .put = put_nullptr, +}; + +/* 64 bit unsigned int. See that the received value is the same than the one + in the field */ + +static int get_uint64_equal(QEMUFile *f, void *pv, size_t size, + VMStateField *field) +{ + uint64_t *v = pv; + uint64_t v2; + qemu_get_be64s(f, &v2); + + if (*v == v2) { + return 0; + } + error_report("%" PRIx64 " != %" PRIx64, *v, v2); + return -EINVAL; +} + +const VMStateInfo vmstate_info_uint64_equal = { + .name = "int64 equal", + .get = get_uint64_equal, + .put = put_uint64, +}; + +/* 8 bit int. See that the received value is the same than the one + in the field */ + +static int get_uint8_equal(QEMUFile *f, void *pv, size_t size, + VMStateField *field) +{ + uint8_t *v = pv; + uint8_t v2; + qemu_get_8s(f, &v2); + + if (*v == v2) { + return 0; + } + error_report("%x != %x", *v, v2); + return -EINVAL; +} + +const VMStateInfo vmstate_info_uint8_equal = { + .name = "uint8 equal", + .get = get_uint8_equal, + .put = put_uint8, +}; + +/* 16 bit unsigned int int. See that the received value is the same than the one + in the field */ + +static int get_uint16_equal(QEMUFile *f, void *pv, size_t size, + VMStateField *field) +{ + uint16_t *v = pv; + uint16_t v2; + qemu_get_be16s(f, &v2); + + if (*v == v2) { + return 0; + } + error_report("%x != %x", *v, v2); + return -EINVAL; +} + +const VMStateInfo vmstate_info_uint16_equal = { + .name = "uint16 equal", + .get = get_uint16_equal, + .put = put_uint16, +}; + +/* floating point */ + +static int get_float64(QEMUFile *f, void *pv, size_t size, + VMStateField *field) +{ + float64 *v = pv; + + *v = make_float64(qemu_get_be64(f)); + return 0; +} + +static int put_float64(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + uint64_t *v = pv; + + qemu_put_be64(f, float64_val(*v)); + return 0; +} + +const VMStateInfo vmstate_info_float64 = { + .name = "float64", + .get = get_float64, + .put = put_float64, +}; + +/* CPU_DoubleU type */ + +static int get_cpudouble(QEMUFile *f, void *pv, size_t size, + VMStateField *field) +{ + CPU_DoubleU *v = pv; + qemu_get_be32s(f, &v->l.upper); + qemu_get_be32s(f, &v->l.lower); + return 0; +} + +static int put_cpudouble(QEMUFile *f, void *pv, size_t size, + VMStateField *field, QJSON *vmdesc) +{ + CPU_DoubleU *v = pv; + qemu_put_be32s(f, &v->l.upper); + qemu_put_be32s(f, &v->l.lower); + return 0; +} + +const VMStateInfo vmstate_info_cpudouble = { + .name = "CPU_Double_U", + .get = get_cpudouble, + .put = put_cpudouble, +}; + +/* uint8_t buffers */ + +static int get_buffer(QEMUFile *f, void *pv, size_t size, + VMStateField *field) +{ + uint8_t *v = pv; + qemu_get_buffer(f, v, size); + return 0; +} + +static int put_buffer(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + uint8_t *v = pv; + qemu_put_buffer(f, v, size); + return 0; +} + +const VMStateInfo vmstate_info_buffer = { + .name = "buffer", + .get = get_buffer, + .put = put_buffer, +}; + +/* unused buffers: space that was used for some fields that are + not useful anymore */ + +static int get_unused_buffer(QEMUFile *f, void *pv, size_t size, + VMStateField *field) +{ + uint8_t buf[1024]; + int block_len; + + while (size > 0) { + block_len = MIN(sizeof(buf), size); + size -= block_len; + qemu_get_buffer(f, buf, block_len); + } + return 0; +} + +static int put_unused_buffer(QEMUFile *f, void *pv, size_t size, + VMStateField *field, QJSON *vmdesc) +{ + static const uint8_t buf[1024]; + int block_len; + + while (size > 0) { + block_len = MIN(sizeof(buf), size); + size -= block_len; + qemu_put_buffer(f, buf, block_len); + } + + return 0; +} + +const VMStateInfo vmstate_info_unused_buffer = { + .name = "unused_buffer", + .get = get_unused_buffer, + .put = put_unused_buffer, +}; + +/* vmstate_info_tmp, see VMSTATE_WITH_TMP, the idea is that we allocate + * a temporary buffer and the pre_load/pre_save methods in the child vmsd + * copy stuff from the parent into the child and do calculations to fill + * in fields that don't really exist in the parent but need to be in the + * stream. + */ +static int get_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + int ret; + const VMStateDescription *vmsd = field->vmsd; + int version_id = field->version_id; + void *tmp = g_malloc(size); + + /* Writes the parent field which is at the start of the tmp */ + *(void **)tmp = pv; + ret = vmstate_load_state(f, vmsd, tmp, version_id); + g_free(tmp); + return ret; +} + +static int put_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + const VMStateDescription *vmsd = field->vmsd; + void *tmp = g_malloc(size); + + /* Writes the parent field which is at the start of the tmp */ + *(void **)tmp = pv; + vmstate_save_state(f, vmsd, tmp, vmdesc); + g_free(tmp); + + return 0; +} + +const VMStateInfo vmstate_info_tmp = { + .name = "tmp", + .get = get_tmp, + .put = put_tmp, +}; + +/* bitmaps (as defined by bitmap.h). Note that size here is the size + * of the bitmap in bits. The on-the-wire format of a bitmap is 64 + * bit words with the bits in big endian order. The in-memory format + * is an array of 'unsigned long', which may be either 32 or 64 bits. + */ +/* This is the number of 64 bit words sent over the wire */ +#define BITS_TO_U64S(nr) DIV_ROUND_UP(nr, 64) +static int get_bitmap(QEMUFile *f, void *pv, size_t size, VMStateField *field) +{ + unsigned long *bmp = pv; + int i, idx = 0; + for (i = 0; i < BITS_TO_U64S(size); i++) { + uint64_t w = qemu_get_be64(f); + bmp[idx++] = w; + if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) { + bmp[idx++] = w >> 32; + } + } + return 0; +} + +static int put_bitmap(QEMUFile *f, void *pv, size_t size, VMStateField *field, + QJSON *vmdesc) +{ + unsigned long *bmp = pv; + int i, idx = 0; + for (i = 0; i < BITS_TO_U64S(size); i++) { + uint64_t w = bmp[idx++]; + if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) { + w |= ((uint64_t)bmp[idx++]) << 32; + } + qemu_put_be64(f, w); + } + + return 0; +} + +const VMStateInfo vmstate_info_bitmap = { + .name = "bitmap", + .get = get_bitmap, + .put = put_bitmap, +}; + +/* get for QTAILQ + * meta data about the QTAILQ is encoded in a VMStateField structure + */ +static int get_qtailq(QEMUFile *f, void *pv, size_t unused_size, + VMStateField *field) +{ + int ret = 0; + const VMStateDescription *vmsd = field->vmsd; + /* size of a QTAILQ element */ + size_t size = field->size; + /* offset of the QTAILQ entry in a QTAILQ element */ + size_t entry_offset = field->start; + int version_id = field->version_id; + void *elm; + + trace_get_qtailq(vmsd->name, version_id); + if (version_id > vmsd->version_id) { + error_report("%s %s", vmsd->name, "too new"); + trace_get_qtailq_end(vmsd->name, "too new", -EINVAL); + + return -EINVAL; + } + if (version_id < vmsd->minimum_version_id) { + error_report("%s %s", vmsd->name, "too old"); + trace_get_qtailq_end(vmsd->name, "too old", -EINVAL); + return -EINVAL; + } + + while (qemu_get_byte(f)) { + elm = g_malloc(size); + ret = vmstate_load_state(f, vmsd, elm, version_id); + if (ret) { + return ret; + } + QTAILQ_RAW_INSERT_TAIL(pv, elm, entry_offset); + } + + trace_get_qtailq_end(vmsd->name, "end", ret); + return ret; +} + +/* put for QTAILQ */ +static int put_qtailq(QEMUFile *f, void *pv, size_t unused_size, + VMStateField *field, QJSON *vmdesc) +{ + const VMStateDescription *vmsd = field->vmsd; + /* offset of the QTAILQ entry in a QTAILQ element*/ + size_t entry_offset = field->start; + void *elm; + + trace_put_qtailq(vmsd->name, vmsd->version_id); + + QTAILQ_RAW_FOREACH(elm, pv, entry_offset) { + qemu_put_byte(f, true); + vmstate_save_state(f, vmsd, elm, vmdesc); + } + qemu_put_byte(f, false); + + trace_put_qtailq_end(vmsd->name, "end"); + + return 0; +} +const VMStateInfo vmstate_info_qtailq = { + .name = "qtailq", + .get = get_qtailq, + .put = put_qtailq, +}; diff --git a/migration/vmstate.c b/migration/vmstate.c index 66c50ee..ff54531 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -1,3 +1,15 @@ +/* + * VMState interpreter + * + * Copyright (c) 2009-2017 Red Hat Inc + * + * Authors: + * Juan Quintela <quintela@redhat.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + #include "qemu/osdep.h" #include "qemu-common.h" #include "migration/migration.h" @@ -5,7 +17,6 @@ #include "migration/vmstate.h" #include "qemu/bitops.h" #include "qemu/error-report.h" -#include "qemu/queue.h" #include "trace.h" #include "qjson.h" @@ -475,644 +486,3 @@ static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, json_end_array(vmdesc); } } - -/* bool */ - -static int get_bool(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - bool *v = pv; - *v = qemu_get_byte(f); - return 0; -} - -static int put_bool(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - bool *v = pv; - qemu_put_byte(f, *v); - return 0; -} - -const VMStateInfo vmstate_info_bool = { - .name = "bool", - .get = get_bool, - .put = put_bool, -}; - -/* 8 bit int */ - -static int get_int8(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - int8_t *v = pv; - qemu_get_s8s(f, v); - return 0; -} - -static int put_int8(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - int8_t *v = pv; - qemu_put_s8s(f, v); - return 0; -} - -const VMStateInfo vmstate_info_int8 = { - .name = "int8", - .get = get_int8, - .put = put_int8, -}; - -/* 16 bit int */ - -static int get_int16(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - int16_t *v = pv; - qemu_get_sbe16s(f, v); - return 0; -} - -static int put_int16(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - int16_t *v = pv; - qemu_put_sbe16s(f, v); - return 0; -} - -const VMStateInfo vmstate_info_int16 = { - .name = "int16", - .get = get_int16, - .put = put_int16, -}; - -/* 32 bit int */ - -static int get_int32(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - int32_t *v = pv; - qemu_get_sbe32s(f, v); - return 0; -} - -static int put_int32(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - int32_t *v = pv; - qemu_put_sbe32s(f, v); - return 0; -} - -const VMStateInfo vmstate_info_int32 = { - .name = "int32", - .get = get_int32, - .put = put_int32, -}; - -/* 32 bit int. See that the received value is the same than the one - in the field */ - -static int get_int32_equal(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - int32_t *v = pv; - int32_t v2; - qemu_get_sbe32s(f, &v2); - - if (*v == v2) { - return 0; - } - error_report("%" PRIx32 " != %" PRIx32, *v, v2); - return -EINVAL; -} - -const VMStateInfo vmstate_info_int32_equal = { - .name = "int32 equal", - .get = get_int32_equal, - .put = put_int32, -}; - -/* 32 bit int. Check that the received value is non-negative - * and less than or equal to the one in the field. - */ - -static int get_int32_le(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - int32_t *cur = pv; - int32_t loaded; - qemu_get_sbe32s(f, &loaded); - - if (loaded >= 0 && loaded <= *cur) { - *cur = loaded; - return 0; - } - error_report("Invalid value %" PRId32 - " expecting positive value <= %" PRId32, - loaded, *cur); - return -EINVAL; -} - -const VMStateInfo vmstate_info_int32_le = { - .name = "int32 le", - .get = get_int32_le, - .put = put_int32, -}; - -/* 64 bit int */ - -static int get_int64(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - int64_t *v = pv; - qemu_get_sbe64s(f, v); - return 0; -} - -static int put_int64(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - int64_t *v = pv; - qemu_put_sbe64s(f, v); - return 0; -} - -const VMStateInfo vmstate_info_int64 = { - .name = "int64", - .get = get_int64, - .put = put_int64, -}; - -/* 8 bit unsigned int */ - -static int get_uint8(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - uint8_t *v = pv; - qemu_get_8s(f, v); - return 0; -} - -static int put_uint8(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - uint8_t *v = pv; - qemu_put_8s(f, v); - return 0; -} - -const VMStateInfo vmstate_info_uint8 = { - .name = "uint8", - .get = get_uint8, - .put = put_uint8, -}; - -/* 16 bit unsigned int */ - -static int get_uint16(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - uint16_t *v = pv; - qemu_get_be16s(f, v); - return 0; -} - -static int put_uint16(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - uint16_t *v = pv; - qemu_put_be16s(f, v); - return 0; -} - -const VMStateInfo vmstate_info_uint16 = { - .name = "uint16", - .get = get_uint16, - .put = put_uint16, -}; - -/* 32 bit unsigned int */ - -static int get_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - uint32_t *v = pv; - qemu_get_be32s(f, v); - return 0; -} - -static int put_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - uint32_t *v = pv; - qemu_put_be32s(f, v); - return 0; -} - -const VMStateInfo vmstate_info_uint32 = { - .name = "uint32", - .get = get_uint32, - .put = put_uint32, -}; - -/* 32 bit uint. See that the received value is the same than the one - in the field */ - -static int get_uint32_equal(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - uint32_t *v = pv; - uint32_t v2; - qemu_get_be32s(f, &v2); - - if (*v == v2) { - return 0; - } - error_report("%" PRIx32 " != %" PRIx32, *v, v2); - return -EINVAL; -} - -const VMStateInfo vmstate_info_uint32_equal = { - .name = "uint32 equal", - .get = get_uint32_equal, - .put = put_uint32, -}; - -/* 64 bit unsigned int */ - -static int get_uint64(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - uint64_t *v = pv; - qemu_get_be64s(f, v); - return 0; -} - -static int put_uint64(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - uint64_t *v = pv; - qemu_put_be64s(f, v); - return 0; -} - -const VMStateInfo vmstate_info_uint64 = { - .name = "uint64", - .get = get_uint64, - .put = put_uint64, -}; - -static int get_nullptr(QEMUFile *f, void *pv, size_t size, VMStateField *field) - -{ - if (qemu_get_byte(f) == VMS_NULLPTR_MARKER) { - return 0; - } - error_report("vmstate: get_nullptr expected VMS_NULLPTR_MARKER"); - return -EINVAL; -} - -static int put_nullptr(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) - -{ - if (pv == NULL) { - qemu_put_byte(f, VMS_NULLPTR_MARKER); - return 0; - } - error_report("vmstate: put_nullptr must be called with pv == NULL"); - return -EINVAL; -} - -const VMStateInfo vmstate_info_nullptr = { - .name = "uint64", - .get = get_nullptr, - .put = put_nullptr, -}; - -/* 64 bit unsigned int. See that the received value is the same than the one - in the field */ - -static int get_uint64_equal(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - uint64_t *v = pv; - uint64_t v2; - qemu_get_be64s(f, &v2); - - if (*v == v2) { - return 0; - } - error_report("%" PRIx64 " != %" PRIx64, *v, v2); - return -EINVAL; -} - -const VMStateInfo vmstate_info_uint64_equal = { - .name = "int64 equal", - .get = get_uint64_equal, - .put = put_uint64, -}; - -/* 8 bit int. See that the received value is the same than the one - in the field */ - -static int get_uint8_equal(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - uint8_t *v = pv; - uint8_t v2; - qemu_get_8s(f, &v2); - - if (*v == v2) { - return 0; - } - error_report("%x != %x", *v, v2); - return -EINVAL; -} - -const VMStateInfo vmstate_info_uint8_equal = { - .name = "uint8 equal", - .get = get_uint8_equal, - .put = put_uint8, -}; - -/* 16 bit unsigned int int. See that the received value is the same than the one - in the field */ - -static int get_uint16_equal(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - uint16_t *v = pv; - uint16_t v2; - qemu_get_be16s(f, &v2); - - if (*v == v2) { - return 0; - } - error_report("%x != %x", *v, v2); - return -EINVAL; -} - -const VMStateInfo vmstate_info_uint16_equal = { - .name = "uint16 equal", - .get = get_uint16_equal, - .put = put_uint16, -}; - -/* floating point */ - -static int get_float64(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - float64 *v = pv; - - *v = make_float64(qemu_get_be64(f)); - return 0; -} - -static int put_float64(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - uint64_t *v = pv; - - qemu_put_be64(f, float64_val(*v)); - return 0; -} - -const VMStateInfo vmstate_info_float64 = { - .name = "float64", - .get = get_float64, - .put = put_float64, -}; - -/* CPU_DoubleU type */ - -static int get_cpudouble(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - CPU_DoubleU *v = pv; - qemu_get_be32s(f, &v->l.upper); - qemu_get_be32s(f, &v->l.lower); - return 0; -} - -static int put_cpudouble(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) -{ - CPU_DoubleU *v = pv; - qemu_put_be32s(f, &v->l.upper); - qemu_put_be32s(f, &v->l.lower); - return 0; -} - -const VMStateInfo vmstate_info_cpudouble = { - .name = "CPU_Double_U", - .get = get_cpudouble, - .put = put_cpudouble, -}; - -/* uint8_t buffers */ - -static int get_buffer(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - uint8_t *v = pv; - qemu_get_buffer(f, v, size); - return 0; -} - -static int put_buffer(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - uint8_t *v = pv; - qemu_put_buffer(f, v, size); - return 0; -} - -const VMStateInfo vmstate_info_buffer = { - .name = "buffer", - .get = get_buffer, - .put = put_buffer, -}; - -/* unused buffers: space that was used for some fields that are - not useful anymore */ - -static int get_unused_buffer(QEMUFile *f, void *pv, size_t size, - VMStateField *field) -{ - uint8_t buf[1024]; - int block_len; - - while (size > 0) { - block_len = MIN(sizeof(buf), size); - size -= block_len; - qemu_get_buffer(f, buf, block_len); - } - return 0; -} - -static int put_unused_buffer(QEMUFile *f, void *pv, size_t size, - VMStateField *field, QJSON *vmdesc) -{ - static const uint8_t buf[1024]; - int block_len; - - while (size > 0) { - block_len = MIN(sizeof(buf), size); - size -= block_len; - qemu_put_buffer(f, buf, block_len); - } - - return 0; -} - -const VMStateInfo vmstate_info_unused_buffer = { - .name = "unused_buffer", - .get = get_unused_buffer, - .put = put_unused_buffer, -}; - -/* vmstate_info_tmp, see VMSTATE_WITH_TMP, the idea is that we allocate - * a temporary buffer and the pre_load/pre_save methods in the child vmsd - * copy stuff from the parent into the child and do calculations to fill - * in fields that don't really exist in the parent but need to be in the - * stream. - */ -static int get_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - int ret; - const VMStateDescription *vmsd = field->vmsd; - int version_id = field->version_id; - void *tmp = g_malloc(size); - - /* Writes the parent field which is at the start of the tmp */ - *(void **)tmp = pv; - ret = vmstate_load_state(f, vmsd, tmp, version_id); - g_free(tmp); - return ret; -} - -static int put_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - const VMStateDescription *vmsd = field->vmsd; - void *tmp = g_malloc(size); - - /* Writes the parent field which is at the start of the tmp */ - *(void **)tmp = pv; - vmstate_save_state(f, vmsd, tmp, vmdesc); - g_free(tmp); - - return 0; -} - -const VMStateInfo vmstate_info_tmp = { - .name = "tmp", - .get = get_tmp, - .put = put_tmp, -}; - -/* bitmaps (as defined by bitmap.h). Note that size here is the size - * of the bitmap in bits. The on-the-wire format of a bitmap is 64 - * bit words with the bits in big endian order. The in-memory format - * is an array of 'unsigned long', which may be either 32 or 64 bits. - */ -/* This is the number of 64 bit words sent over the wire */ -#define BITS_TO_U64S(nr) DIV_ROUND_UP(nr, 64) -static int get_bitmap(QEMUFile *f, void *pv, size_t size, VMStateField *field) -{ - unsigned long *bmp = pv; - int i, idx = 0; - for (i = 0; i < BITS_TO_U64S(size); i++) { - uint64_t w = qemu_get_be64(f); - bmp[idx++] = w; - if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) { - bmp[idx++] = w >> 32; - } - } - return 0; -} - -static int put_bitmap(QEMUFile *f, void *pv, size_t size, VMStateField *field, - QJSON *vmdesc) -{ - unsigned long *bmp = pv; - int i, idx = 0; - for (i = 0; i < BITS_TO_U64S(size); i++) { - uint64_t w = bmp[idx++]; - if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) { - w |= ((uint64_t)bmp[idx++]) << 32; - } - qemu_put_be64(f, w); - } - - return 0; -} - -const VMStateInfo vmstate_info_bitmap = { - .name = "bitmap", - .get = get_bitmap, - .put = put_bitmap, -}; - -/* get for QTAILQ - * meta data about the QTAILQ is encoded in a VMStateField structure - */ -static int get_qtailq(QEMUFile *f, void *pv, size_t unused_size, - VMStateField *field) -{ - int ret = 0; - const VMStateDescription *vmsd = field->vmsd; - /* size of a QTAILQ element */ - size_t size = field->size; - /* offset of the QTAILQ entry in a QTAILQ element */ - size_t entry_offset = field->start; - int version_id = field->version_id; - void *elm; - - trace_get_qtailq(vmsd->name, version_id); - if (version_id > vmsd->version_id) { - error_report("%s %s", vmsd->name, "too new"); - trace_get_qtailq_end(vmsd->name, "too new", -EINVAL); - - return -EINVAL; - } - if (version_id < vmsd->minimum_version_id) { - error_report("%s %s", vmsd->name, "too old"); - trace_get_qtailq_end(vmsd->name, "too old", -EINVAL); - return -EINVAL; - } - - while (qemu_get_byte(f)) { - elm = g_malloc(size); - ret = vmstate_load_state(f, vmsd, elm, version_id); - if (ret) { - return ret; - } - QTAILQ_RAW_INSERT_TAIL(pv, elm, entry_offset); - } - - trace_get_qtailq_end(vmsd->name, "end", ret); - return ret; -} - -/* put for QTAILQ */ -static int put_qtailq(QEMUFile *f, void *pv, size_t unused_size, - VMStateField *field, QJSON *vmdesc) -{ - const VMStateDescription *vmsd = field->vmsd; - /* offset of the QTAILQ entry in a QTAILQ element*/ - size_t entry_offset = field->start; - void *elm; - - trace_put_qtailq(vmsd->name, vmsd->version_id); - - QTAILQ_RAW_FOREACH(elm, pv, entry_offset) { - qemu_put_byte(f, true); - vmstate_save_state(f, vmsd, elm, vmdesc); - } - qemu_put_byte(f, false); - - trace_put_qtailq_end(vmsd->name, "end"); - - return 0; -} -const VMStateInfo vmstate_info_qtailq = { - .name = "qtailq", - .get = get_qtailq, - .put = put_qtailq, -}; diff --git a/tests/Makefile.include b/tests/Makefile.include index 4277597..7589383 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -574,7 +574,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ hw/core/reset.o \ $(test-qapi-obj-y) tests/test-vmstate$(EXESUF): tests/test-vmstate.o \ - migration/vmstate.o migration/qemu-file.o \ + migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \ migration/qemu-file-channel.o migration/qjson.o \ $(test-io-obj-y) tests/test-timed-average$(EXESUF): tests/test-timed-average.o $(test-util-obj-y) -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 7/9] migration: Remove qemu-file.h from vmstate.h 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela ` (5 preceding siblings ...) 2017-05-18 16:16 ` [Qemu-devel] [PATCH 6/9] migration: Split vmstate-types.c from vmstate.c Juan Quintela @ 2017-05-18 16:16 ` Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 8/9] migration: Remove vmstate.h from migration.h Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 9/9] migration: migration.h was not needed Juan Quintela 8 siblings, 0 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> -- minor rearangements due to the rebase --- include/hw/hw.h | 1 + include/migration/vmstate.h | 3 --- migration/block.c | 1 + migration/colo.c | 1 + migration/postcopy-ram.c | 1 + migration/ram.c | 1 + tests/test-vmstate.c | 1 + 7 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/hw/hw.h b/include/hw/hw.h index e22d4ce..af9eae1 100644 --- a/include/hw/hw.h +++ b/include/hw/hw.h @@ -11,6 +11,7 @@ #include "exec/memory.h" #include "hw/irq.h" #include "migration/vmstate.h" +#include "migration/qemu-file.h" #include "qemu/module.h" #include "sysemu/reset.h" diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index dacb052..f97411d 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -27,9 +27,6 @@ #ifndef QEMU_VMSTATE_H #define QEMU_VMSTATE_H -#ifndef CONFIG_USER_ONLY -#include "migration/qemu-file.h" -#endif #include "migration/qjson.h" typedef void SaveStateHandler(QEMUFile *f, void *opaque); diff --git a/migration/block.c b/migration/block.c index 5d22926..5baf46d 100644 --- a/migration/block.c +++ b/migration/block.c @@ -26,6 +26,7 @@ #include "migration/block.h" #include "migration/migration.h" #include "sysemu/blockdev.h" +#include "migration/qemu-file.h" #include "sysemu/block-backend.h" #define BLOCK_SIZE (1 << 20) diff --git a/migration/colo.c b/migration/colo.c index 73ebd64..929b31c 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -15,6 +15,7 @@ #include "sysemu/sysemu.h" #include "qemu-file-channel.h" #include "migration/migration.h" +#include "migration/qemu-file.h" #include "migration/colo.h" #include "migration/block.h" #include "io/channel-buffer.h" diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 63b8501..0e2a996 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -20,6 +20,7 @@ #include "qemu-common.h" #include "migration/migration.h" +#include "migration/qemu-file.h" #include "postcopy-ram.h" #include "sysemu/sysemu.h" #include "sysemu/balloon.h" diff --git a/migration/ram.c b/migration/ram.c index c14269f..8ce8c07 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -37,6 +37,7 @@ #include "qemu/main-loop.h" #include "xbzrle.h" #include "migration/migration.h" +#include "migration/qemu-file.h" #include "postcopy-ram.h" #include "exec/address-spaces.h" #include "migration/page_cache.h" diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index 1c13570..25389bc 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -27,6 +27,7 @@ #include "qemu-common.h" #include "migration/migration.h" #include "migration/vmstate.h" +#include "migration/qemu-file.h" #include "../migration/qemu-file-channel.h" #include "qemu/coroutine.h" #include "io/channel-file.h" -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 8/9] migration: Remove vmstate.h from migration.h 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela ` (6 preceding siblings ...) 2017-05-18 16:16 ` [Qemu-devel] [PATCH 7/9] migration: Remove qemu-file.h from vmstate.h Juan Quintela @ 2017-05-18 16:16 ` Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 9/9] migration: migration.h was not needed Juan Quintela 8 siblings, 0 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- Minor rearrangements due to rebase --- include/migration/migration.h | 1 - migration/block.c | 1 + migration/colo-comm.c | 1 + migration/migration.c | 1 + migration/ram.c | 1 + 5 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 8280df1..0e807b6 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -18,7 +18,6 @@ #include "qemu-common.h" #include "qemu/thread.h" #include "qemu/notify.h" -#include "migration/vmstate.h" #include "io/channel.h" #include "qapi-types.h" #include "exec/cpu-common.h" diff --git a/migration/block.c b/migration/block.c index 5baf46d..13f90d3 100644 --- a/migration/block.c +++ b/migration/block.c @@ -27,6 +27,7 @@ #include "migration/migration.h" #include "sysemu/blockdev.h" #include "migration/qemu-file.h" +#include "migration/vmstate.h" #include "sysemu/block-backend.h" #define BLOCK_SIZE (1 << 20) diff --git a/migration/colo-comm.c b/migration/colo-comm.c index 3d91798..8bfdf68 100644 --- a/migration/colo-comm.c +++ b/migration/colo-comm.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "migration/migration.h" #include "migration/colo.h" +#include "migration/vmstate.h" #include "trace.h" typedef struct { diff --git a/migration/migration.c b/migration/migration.c index 2d9379c..9fe474b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -21,6 +21,7 @@ #include "migration/migration.h" #include "qemu-file-channel.h" #include "migration/qemu-file.h" +#include "migration/vmstate.h" #include "sysemu/sysemu.h" #include "block/block.h" #include "qapi/qmp/qerror.h" diff --git a/migration/ram.c b/migration/ram.c index 8ce8c07..c07a9c0 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -38,6 +38,7 @@ #include "xbzrle.h" #include "migration/migration.h" #include "migration/qemu-file.h" +#include "migration/vmstate.h" #include "postcopy-ram.h" #include "exec/address-spaces.h" #include "migration/page_cache.h" -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 9/9] migration: migration.h was not needed 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela ` (7 preceding siblings ...) 2017-05-18 16:16 ` [Qemu-devel] [PATCH 8/9] migration: Remove vmstate.h from migration.h Juan Quintela @ 2017-05-18 16:16 ` Juan Quintela 8 siblings, 0 replies; 17+ messages in thread From: Juan Quintela @ 2017-05-18 16:16 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx This files don't use any function from migration.h, so drop it. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> --- block/qed.c | 1 - hw/i386/pc_q35.c | 1 - hw/virtio/vhost-user.c | 1 - hw/virtio/vhost-vsock.c | 1 - hw/virtio/virtio.c | 1 - monitor.c | 1 - 6 files changed, 6 deletions(-) diff --git a/block/qed.c b/block/qed.c index fd76817..8d899fd 100644 --- a/block/qed.c +++ b/block/qed.c @@ -19,7 +19,6 @@ #include "trace.h" #include "qed.h" #include "qapi/qmp/qerror.h" -#include "migration/migration.h" #include "sysemu/block-backend.h" static const AIOCBInfo qed_aiocb_info = { diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index f243203..1523ef3 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -46,7 +46,6 @@ #include "hw/ide/ahci.h" #include "hw/usb.h" #include "qemu/error-report.h" -#include "migration/migration.h" #include "sysemu/numa.h" /* ICH9 AHCI has 6 ports */ diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 32a95a8..b87a176 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -17,7 +17,6 @@ #include "sysemu/kvm.h" #include "qemu/error-report.h" #include "qemu/sockets.h" -#include "migration/migration.h" #include <sys/ioctl.h> #include <sys/socket.h> diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index b481562..49e0022 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -17,7 +17,6 @@ #include "qapi/error.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" -#include "migration/migration.h" #include "qemu/error-report.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 890b4d7..f99d99f 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -21,7 +21,6 @@ #include "hw/virtio/virtio.h" #include "qemu/atomic.h" #include "hw/virtio/virtio-bus.h" -#include "migration/migration.h" #include "hw/virtio/virtio-access.h" #include "sysemu/dma.h" diff --git a/monitor.c b/monitor.c index afbacfe..baa73c9 100644 --- a/monitor.c +++ b/monitor.c @@ -49,7 +49,6 @@ #include "disas/disas.h" #include "sysemu/balloon.h" #include "qemu/timer.h" -#include "migration/migration.h" #include "sysemu/hw_accel.h" #include "qemu/acl.h" #include "sysemu/tpm.h" -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH v4 0/9] Migration mini-cleanup @ 2017-05-17 15:47 Juan Quintela 2017-05-17 15:47 ` [Qemu-devel] [PATCH 5/9] migration: Move qjson.h to migration/ Juan Quintela 0 siblings, 1 reply; 17+ messages in thread From: Juan Quintela @ 2017-05-17 15:47 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx Hi Changes from v3 - dropped movement of colo*h headers they are used in other palaces in patches outside the tree - Change the license of vmstate*c files to GPL v2+ Dave noted that I was using the wrong text - page_cache.c movement was already reviewd and it has no conflicts, moved to pull request. Please, review Thanks, Juan. [v3] Due to popular demand, and to make reviews easier, I just split the big cleanup series (41 patches) in small chunks. This chunk just include the easy patches: - create several include files foo.h for functcions exported from foo.c - split channel operations in channel.c - move colo headers to migration/ - split vmstate-types.c from vmstate.c (now it only contains the interpreter) - untangle qemu-file.h, vmstate.h and migration.h. Now none include the other fix all callers. - Remove uses of migration.h that are not needed Juan Quintela (9): migration: Create migration/xbzrle.h migration: Split migration/channel.c for channel operations migration: Export qemu-file-channel.c functions in its own file migration: Remove migration.h from colo.h migration: Move qjson.h to migration/ migration: Split vmstate-types.c from vmstate.c migration: Remove qemu-file.h from vmstate.h migration: Remove vmstate.h from migration.h migration: migration.h was not needed block/qed.c | 1 - hw/i386/pc_q35.c | 1 - hw/virtio/vhost-user.c | 1 - hw/virtio/vhost-vsock.c | 1 - hw/virtio/virtio.c | 1 - include/hw/hw.h | 1 + include/migration/colo.h | 1 - include/migration/migration.h | 13 +- include/migration/qemu-file.h | 4 - include/migration/vmstate.h | 3 - migration/Makefile.objs | 4 +- migration/block.c | 2 + migration/channel.c | 70 ++++ migration/channel.h | 25 ++ migration/colo-comm.c | 4 +- migration/colo.c | 3 + migration/exec.c | 1 + migration/fd.c | 1 + migration/migration.c | 52 +-- migration/postcopy-ram.c | 1 + migration/qemu-file-channel.c | 1 + migration/qemu-file-channel.h | 21 + migration/qjson.c | 2 +- {include/migration => migration}/qjson.h | 0 migration/ram.c | 3 + migration/rdma.c | 1 + migration/savevm.c | 1 + migration/socket.c | 1 + migration/tls.c | 1 + migration/vmstate-types.c | 661 +++++++++++++++++++++++++++++++ migration/vmstate.c | 656 +----------------------------- migration/xbzrle.c | 2 +- migration/xbzrle.h | 21 + monitor.c | 1 - tests/Makefile.include | 2 +- tests/test-vmstate.c | 2 + tests/test-xbzrle.c | 2 +- 37 files changed, 842 insertions(+), 726 deletions(-) create mode 100644 migration/channel.c create mode 100644 migration/channel.h create mode 100644 migration/qemu-file-channel.h rename {include/migration => migration}/qjson.h (100%) create mode 100644 migration/vmstate-types.c create mode 100644 migration/xbzrle.h -- 2.9.3 ^ permalink raw reply [flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 5/9] migration: Move qjson.h to migration/ 2017-05-17 15:47 [Qemu-devel] [PATCH v4 0/9] Migration mini-cleanup Juan Quintela @ 2017-05-17 15:47 ` Juan Quintela 2017-05-17 16:05 ` Dr. David Alan Gilbert 0 siblings, 1 reply; 17+ messages in thread From: Juan Quintela @ 2017-05-17 15:47 UTC (permalink / raw) To: qemu-devel; +Cc: dgilbert, lvivier, peterx It is only used for migration code. Signed-off-by: Juan Quintela <quintela@redhat.com> --- migration/qjson.c | 2 +- {include/migration => migration}/qjson.h | 0 migration/vmstate.c | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename {include/migration => migration}/qjson.h (100%) diff --git a/migration/qjson.c b/migration/qjson.c index f345904..9d7f6eb 100644 --- a/migration/qjson.c +++ b/migration/qjson.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include "qapi/qmp/qstring.h" -#include "migration/qjson.h" +#include "qjson.h" struct QJSON { QString *str; diff --git a/include/migration/qjson.h b/migration/qjson.h similarity index 100% rename from include/migration/qjson.h rename to migration/qjson.h diff --git a/migration/vmstate.c b/migration/vmstate.c index 7b4a607..66c50ee 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -7,7 +7,7 @@ #include "qemu/error-report.h" #include "qemu/queue.h" #include "trace.h" -#include "migration/qjson.h" +#include "qjson.h" static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, QJSON *vmdesc); -- 2.9.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [Qemu-devel] [PATCH 5/9] migration: Move qjson.h to migration/ 2017-05-17 15:47 ` [Qemu-devel] [PATCH 5/9] migration: Move qjson.h to migration/ Juan Quintela @ 2017-05-17 16:05 ` Dr. David Alan Gilbert 0 siblings, 0 replies; 17+ messages in thread From: Dr. David Alan Gilbert @ 2017-05-17 16:05 UTC (permalink / raw) To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx * Juan Quintela (quintela@redhat.com) wrote: > It is only used for migration code. > > Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > --- > migration/qjson.c | 2 +- > {include/migration => migration}/qjson.h | 0 > migration/vmstate.c | 2 +- > 3 files changed, 2 insertions(+), 2 deletions(-) > rename {include/migration => migration}/qjson.h (100%) > > diff --git a/migration/qjson.c b/migration/qjson.c > index f345904..9d7f6eb 100644 > --- a/migration/qjson.c > +++ b/migration/qjson.c > @@ -25,7 +25,7 @@ > > #include "qemu/osdep.h" > #include "qapi/qmp/qstring.h" > -#include "migration/qjson.h" > +#include "qjson.h" > > struct QJSON { > QString *str; > diff --git a/include/migration/qjson.h b/migration/qjson.h > similarity index 100% > rename from include/migration/qjson.h > rename to migration/qjson.h > diff --git a/migration/vmstate.c b/migration/vmstate.c > index 7b4a607..66c50ee 100644 > --- a/migration/vmstate.c > +++ b/migration/vmstate.c > @@ -7,7 +7,7 @@ > #include "qemu/error-report.h" > #include "qemu/queue.h" > #include "trace.h" > -#include "migration/qjson.h" > +#include "qjson.h" > > static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, > void *opaque, QJSON *vmdesc); > -- > 2.9.3 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2017-05-19 2:47 UTC | newest] Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-05-18 16:16 [Qemu-devel] [PATCH v5 0/9] Migration mini-cleanup Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 1/9] migration: Create migration/xbzrle.h Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 2/9] migration: Split migration/channel.c for channel operations Juan Quintela 2017-05-18 16:40 ` Dr. David Alan Gilbert 2017-05-18 16:46 ` Daniel P. Berrange 2017-05-18 17:20 ` Dr. David Alan Gilbert 2017-05-18 16:16 ` [Qemu-devel] [PATCH 3/9] migration: Export qemu-file-channel.c functions in its own file Juan Quintela 2017-05-18 17:08 ` Dr. David Alan Gilbert 2017-05-19 2:47 ` Peter Xu 2017-05-18 16:16 ` [Qemu-devel] [PATCH 4/9] migration: Remove migration.h from colo.h Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 5/9] migration: Move qjson.h to migration/ Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 6/9] migration: Split vmstate-types.c from vmstate.c Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 7/9] migration: Remove qemu-file.h from vmstate.h Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 8/9] migration: Remove vmstate.h from migration.h Juan Quintela 2017-05-18 16:16 ` [Qemu-devel] [PATCH 9/9] migration: migration.h was not needed Juan Quintela -- strict thread matches above, loose matches on Subject: below -- 2017-05-17 15:47 [Qemu-devel] [PATCH v4 0/9] Migration mini-cleanup Juan Quintela 2017-05-17 15:47 ` [Qemu-devel] [PATCH 5/9] migration: Move qjson.h to migration/ Juan Quintela 2017-05-17 16:05 ` Dr. David Alan Gilbert
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.