From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Md Haris Iqbal <haris.phnx@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-devel [RFC] [WIP] v1] Keeping the Destination side alive incase of network failure (Migration recover from network failure)
Date: Wed, 1 Jun 2016 18:07:01 +0100 [thread overview]
Message-ID: <20160601170700.GC2310@work-vm> (raw)
In-Reply-To: <1464721993-15682-1-git-send-email-haris.phnx@gmail.com>
* Md Haris Iqbal (haris.phnx@gmail.com) wrote:
> ---
> include/migration/migration.h | 3 +++
> migration/migration.c | 12 ++++++++++++
> migration/savevm.c | 25 +++++++++++++++++--------
> 3 files changed, 32 insertions(+), 8 deletions(-)
>
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index ac2c12c..73832ac 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -326,6 +326,9 @@ void flush_page_queue(MigrationState *ms);
> int ram_save_queue_pages(MigrationState *ms, const char *rbname,
> ram_addr_t start, ram_addr_t len);
>
> +// New added function for postcopy migration recovery in case of failure
Note the comment style is always /* not //
> +void qemu_postcopy_migration_recovery(QEMUFile **f,MigrationIncomingState* mis);
> +
> PostcopyState postcopy_state_get(void);
> /* Set the state and return the old state */
> PostcopyState postcopy_state_set(PostcopyState new_state);
> diff --git a/migration/migration.c b/migration/migration.c
> index 991313a..4301972 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -1797,6 +1797,18 @@ void migrate_fd_connect(MigrationState *s)
> s->migration_thread_running = true;
> }
>
> +void qemu_postcopy_migration_recovery(QEMUFile **f,
> + MigrationIncomingState* mis)
> +{
> + migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
> + MIGRATION_STATUS_POSTCOPY_RECOVERING);
> + /* Code for network recovery to be added here */
> + while(1) {
> + fprintf(stderr, "Not letting it fail\n");
> + sleep(2);
> + }
> +}
> +
> PostcopyState postcopy_state_get(void)
> {
> return atomic_mb_read(&incoming_postcopy_state);
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 16ba443..03467da 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1832,7 +1832,8 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
> static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
> {
> uint8_t section_type;
> - int ret;
> + PostcopyState ps;
> + int32_t ret;
Again match up the 'ret' type.
> while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
>
> @@ -1841,21 +1842,16 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
> case QEMU_VM_SECTION_START:
> case QEMU_VM_SECTION_FULL:
> ret = qemu_loadvm_section_start_full(f, mis);
> - if (ret < 0) {
> - return ret;
> - }
> break;
> case QEMU_VM_SECTION_PART:
> case QEMU_VM_SECTION_END:
> ret = qemu_loadvm_section_part_end(f, mis);
> - if (ret < 0) {
> - return ret;
> - }
> break;
> case QEMU_VM_COMMAND:
> ret = loadvm_process_command(f);
> trace_qemu_loadvm_state_section_command(ret);
> - if ((ret < 0) || (ret & LOADVM_QUIT)) {
> + if (ret & LOADVM_QUIT) {
> + fprintf(stderr, "LOADVM_QUIT\n");
> return ret;
> }
> break;
> @@ -1863,6 +1859,19 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
> error_report("Unknown savevm section type %d", section_type);
> return -EINVAL;
> }
> +
> + if (ret < 0) {
> + fprintf(stderr, "Failure\n");
> +
> + ps = postcopy_state_get();
> + ret = qemu_file_get_error(f);
> + fprintf(stderr, "Error %s %d\n", strerror(-ret), -ret);
> +
> + if(ret != -EIO && ps == POSTCOPY_INCOMING_RUNNING)
> + qemu_postcopy_migration_recovery(&f, mis);
Qemu's if style always puts {'s in even for one line if.
ps == POSTCOPY_INCOMING_RUNNING is a reasonable test; I wonder if we should
also combine it with the run-state; if the destination was started with -S
and got to RUNNING but libvirt hadn't actually told it to run yet, then I think
it's still safe to fail to migration right up to the point the destination
is started running.
Dave
> + else
> + return ret;
> + }
> }
>
> return 0;
> --
> 2.7.4
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
prev parent reply other threads:[~2016-06-01 17:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 19:13 [Qemu-devel] [Qemu-devel [RFC] [WIP] v1] Keeping the Destination side alive incase of network failure (Migration recover from network failure) Md Haris Iqbal
2016-06-01 17:07 ` Dr. David Alan Gilbert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160601170700.GC2310@work-vm \
--to=dgilbert@redhat.com \
--cc=haris.phnx@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).