qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: xiecl.fnst@cn.fujitsu.com, lizhijian@cn.fujitsu.com,
	quintela@redhat.com, armbru@redhat.com, yunhong.jiang@intel.com,
	eddie.dong@intel.com, peter.huangpeng@huawei.com,
	qemu-devel@nongnu.org, arei.gonglei@huawei.com,
	stefanha@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
	amit.shah@redhat.com, zhangchen.fnst@cn.fujitsu.com,
	hongyang.yang@easystack.cn
Subject: Re: [Qemu-devel] [PATCH COLO-Frame v14 24/40] COLO: Process shutdown command for VM in COLO state
Date: Tue, 16 Feb 2016 14:17:09 +0800	[thread overview]
Message-ID: <56C2BEE5.5030603@huawei.com> (raw)
In-Reply-To: <20160212150924.GD2411@work-vm>

On 2016/2/12 23:09, Dr. David Alan Gilbert wrote:
> * zhanghailiang (zhang.zhanghailiang@huawei.com) wrote:
>> If VM is in COLO FT state, we should do some extra work before normal shutdown
>> process. SVM will ignore the shutdown command if this command is issued directly
>> to it, PVM will send the shutdown command to SVM if it gets this command.
>>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>
> although one question below.
>

Thanks!

> Dave
>
>> ---
>> v14:
>> - Remove 'colo_shutdown' variable, use colo_shutdown_request directly
>> v13:
>> - Move COLO shutdown related codes to colo.c file (Dave's suggestion)
>> ---
>>   include/migration/colo.h |  2 ++
>>   include/sysemu/sysemu.h  |  3 +++
>>   migration/colo.c         | 42 ++++++++++++++++++++++++++++++++++++++++--
>>   qapi-schema.json         |  4 +++-
>>   stubs/migration-colo.c   |  5 +++++
>>   vl.c                     | 19 ++++++++++++++++---
>>   6 files changed, 69 insertions(+), 6 deletions(-)
>>
>> diff --git a/include/migration/colo.h b/include/migration/colo.h
>> index e32eef4..919b135 100644
>> --- a/include/migration/colo.h
>> +++ b/include/migration/colo.h
>> @@ -35,4 +35,6 @@ COLOMode get_colo_mode(void);
>>
>>   /* failover */
>>   void colo_do_failover(MigrationState *s);
>> +
>> +bool colo_shutdown(void);
>>   #endif
>> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
>> index 3bb8897..91eeda3 100644
>> --- a/include/sysemu/sysemu.h
>> +++ b/include/sysemu/sysemu.h
>> @@ -52,6 +52,8 @@ typedef enum WakeupReason {
>>       QEMU_WAKEUP_REASON_OTHER,
>>   } WakeupReason;
>>
>> +extern int colo_shutdown_requested;
>> +
>>   void qemu_system_reset_request(void);
>>   void qemu_system_suspend_request(void);
>>   void qemu_register_suspend_notifier(Notifier *notifier);
>> @@ -59,6 +61,7 @@ void qemu_system_wakeup_request(WakeupReason reason);
>>   void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
>>   void qemu_register_wakeup_notifier(Notifier *notifier);
>>   void qemu_system_shutdown_request(void);
>> +void qemu_system_shutdown_request_core(void);
>>   void qemu_system_powerdown_request(void);
>>   void qemu_register_powerdown_notifier(Notifier *notifier);
>>   void qemu_system_debug_request(void);
>> diff --git a/migration/colo.c b/migration/colo.c
>> index 515d561..92be985 100644
>> --- a/migration/colo.c
>> +++ b/migration/colo.c
>> @@ -330,6 +330,18 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
>>           goto out;
>>       }
>>
>> +    if (colo_shutdown_requested) {
>> +        colo_put_cmd(s->to_dst_file, COLO_MESSAGE_GUEST_SHUTDOWN, &local_err);
>> +        if (local_err) {
>> +            goto out;
>> +        }
>
> I wonder what actually happens in this case? Does it eventually shutdown?
>

No, the qemu will not exit from the main loop,
it seems that, we should ignore the error here, and go on the shutdown process.
I will fix it in next version.

>> +        qemu_fflush(s->to_dst_file);
>> +        colo_shutdown_requested = 0;
>> +        qemu_system_shutdown_request_core();
>> +        /* Fix me: Just let the colo thread exit ? */
>> +        qemu_thread_exit(0);
>> +    }
>> +
>>       ret = 0;
>>       /* Resume primary guest */
>>       qemu_mutex_lock_iothread();
>> @@ -390,8 +402,9 @@ static void colo_process_checkpoint(MigrationState *s)
>>           }
>>
>>           current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
>> -        if (current_time - checkpoint_time <
>> -            s->parameters[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY]) {
>> +        if ((current_time - checkpoint_time <
>> +            s->parameters[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY]) &&
>> +            !colo_shutdown_requested) {
>>               int64_t delay_ms;
>>
>>               delay_ms = s->parameters[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY] -
>> @@ -465,6 +478,15 @@ static void colo_wait_handle_cmd(QEMUFile *f, int *checkpoint_request,
>>       case COLO_MESSAGE_CHECKPOINT_REQUEST:
>>           *checkpoint_request = 1;
>>           break;
>> +    case COLO_MESSAGE_GUEST_SHUTDOWN:
>> +        qemu_mutex_lock_iothread();
>> +        vm_stop_force_state(RUN_STATE_COLO);
>> +        qemu_system_shutdown_request_core();
>> +        qemu_mutex_unlock_iothread();
>> +        /* the main thread will exit and terminate the whole
>> +        * process, do we need some cleanup?
>> +        */
>> +        qemu_thread_exit(0);
>>       default:
>>           *checkpoint_request = 0;
>>           error_setg(errp, "Got unknown COLO command: %d", cmd);
>> @@ -636,3 +658,19 @@ out:
>>
>>       return NULL;
>>   }
>> +
>> +bool colo_shutdown(void)
>> +{
>> +    /*
>> +    * if in colo mode, we need do some significant work before respond
>> +    * to the shutdown request.
>> +    */
>> +    if (migration_incoming_in_colo_state()) {
>> +        return true; /* primary's responsibility */
>> +    }
>> +    if (migration_in_colo_state()) {
>> +        colo_shutdown_requested = 1;
>> +        return true;
>> +    }
>> +    return false;
>> +}
>> diff --git a/qapi-schema.json b/qapi-schema.json
>> index 7fec696..4d8ba04 100644
>> --- a/qapi-schema.json
>> +++ b/qapi-schema.json
>> @@ -752,12 +752,14 @@
>>   #
>>   # @vmstate-loaded: VM's state has been loaded by SVM.
>>   #
>> +# @guest-shutdown: shutdown require from PVM to SVM
>> +#
>>   # Since: 2.6
>>   ##
>>   { 'enum': 'COLOMessage',
>>     'data': [ 'checkpoint-ready', 'checkpoint-request', 'checkpoint-reply',
>>               'vmstate-send', 'vmstate-size', 'vmstate-received',
>> -            'vmstate-loaded' ] }
>> +            'vmstate-loaded', 'guest-shutdown' ] }
>>
>>   ##
>>   # @COLOMode
>> diff --git a/stubs/migration-colo.c b/stubs/migration-colo.c
>> index a6cd6e5..1996cd9 100644
>> --- a/stubs/migration-colo.c
>> +++ b/stubs/migration-colo.c
>> @@ -43,3 +43,8 @@ void qmp_x_colo_lost_heartbeat(Error **errp)
>>                        " with --enable-colo option in order to support"
>>                        " COLO feature");
>>   }
>> +
>> +bool colo_shutdown(void)
>> +{
>> +    return false;
>> +}
>> diff --git a/vl.c b/vl.c
>> index f16fe2d..90da8d1 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -1631,6 +1631,8 @@ static NotifierList wakeup_notifiers =
>>       NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
>>   static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
>>
>> +int colo_shutdown_requested;
>> +
>>   int qemu_shutdown_requested_get(void)
>>   {
>>       return shutdown_requested;
>> @@ -1762,7 +1764,10 @@ void qemu_system_guest_panicked(void)
>>   void qemu_system_reset_request(void)
>>   {
>>       if (no_reboot) {
>> -        shutdown_requested = 1;
>> +        qemu_system_shutdown_request();
>> +        if (!shutdown_requested) {/* colo handle it ? */
>> +            return;
>> +        }
>>       } else {
>>           reset_requested = 1;
>>       }
>> @@ -1835,14 +1840,22 @@ void qemu_system_killed(int signal, pid_t pid)
>>       qemu_notify_event();
>>   }
>>
>> -void qemu_system_shutdown_request(void)
>> +void qemu_system_shutdown_request_core(void)
>>   {
>> -    trace_qemu_system_shutdown_request();
>>       replay_shutdown_request();
>>       shutdown_requested = 1;
>>       qemu_notify_event();
>>   }
>>
>> +void qemu_system_shutdown_request(void)
>> +{
>> +    trace_qemu_system_shutdown_request();
>> +    if (colo_shutdown()) {
>> +        return;
>> +    }
>> +    qemu_system_shutdown_request_core();
>> +}
>> +
>>   static void qemu_system_powerdown(void)
>>   {
>>       qapi_event_send_powerdown(&error_abort);
>> --
>> 1.8.3.1
>>
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
> .
>

  reply	other threads:[~2016-02-16  6:18 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-06  9:28 [Qemu-devel] [PATCH COLO-Frame v14 00/40] COarse-grain LOck-stepping(COLO) Virtual Machines for Non-stop Service (FT) zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 01/40] configure: Add parameter for configure to enable/disable COLO support zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 02/40] migration: Introduce capability 'x-colo' to migration zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 03/40] COLO: migrate colo related info to secondary node zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 04/40] migration: Integrate COLO checkpoint process into migration zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 05/40] migration: Integrate COLO checkpoint process into loadvm zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 06/40] COLO/migration: Create a new communication path from destination to source zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 07/40] COLO: Implement colo checkpoint protocol zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 08/40] COLO: Add a new RunState RUN_STATE_COLO zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 09/40] QEMUSizedBuffer: Introduce two help functions for qsb zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 10/40] COLO: Save PVM state to secondary side when do checkpoint zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 11/40] COLO: Load PVM's dirty pages into SVM's RAM cache temporarily zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 12/40] ram/COLO: Record the dirty pages that SVM received zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 13/40] COLO: Load VMState into qsb before restore it zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 14/40] COLO: Flush PVM's cached RAM into SVM's memory zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 15/40] COLO: Add checkpoint-delay parameter for migrate-set-parameters zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 16/40] COLO: synchronize PVM's state to SVM periodically zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 17/40] COLO failover: Introduce a new command to trigger a failover zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 18/40] COLO failover: Introduce state to record failover process zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 19/40] COLO: Implement failover work for Primary VM zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 20/40] COLO: Implement failover work for Secondary VM zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 21/40] qmp event: Add COLO_EXIT event to notify users while exited from COLO zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 22/40] COLO failover: Shutdown related socket fd when do failover zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 23/40] COLO failover: Don't do failover during loading VM's state zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 24/40] COLO: Process shutdown command for VM in COLO state zhanghailiang
2016-02-12 15:09   ` Dr. David Alan Gilbert
2016-02-16  6:17     ` Hailiang Zhang [this message]
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 25/40] COLO: Update the global runstate after going into colo state zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 26/40] savevm: Introduce two helper functions for save/find loadvm_handlers entry zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 27/40] migration/savevm: Add new helpers to process the different stages of loadvm zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 28/40] migration/savevm: Export two helper functions for savevm process zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 29/40] COLO: Separate the process of saving/loading ram and device state zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 30/40] COLO: Split qemu_savevm_state_begin out of checkpoint process zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 31/40] net/filter: Add a 'status' property for filter object zhanghailiang
2016-02-18  3:00   ` Jason Wang
2016-02-18  3:27     ` Hailiang Zhang
2016-02-23  8:34       ` Jason Wang
2016-02-23  9:37         ` Hailiang Zhang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 32/40] net/filter: Introduce a helper to add a filter to the netdev zhanghailiang
2016-02-18  3:19   ` Jason Wang
2016-02-18  3:30     ` Hailiang Zhang
2016-02-23  8:36       ` Jason Wang
2016-02-23 11:39         ` Hailiang Zhang
2016-02-23 11:50           ` Hailiang Zhang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 33/40] filter-buffer: Accept zero interval zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 34/40] net: Add notifier/callback for netdev init zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 35/40] COLO/filter: add each netdev a buffer filter zhanghailiang
2016-02-18  3:23   ` Jason Wang
2016-02-18  4:07     ` Hailiang Zhang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 36/40] net/filter: Add a helper to traverse all the filters zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 37/40] COLO: enable buffer filters for PVM zhanghailiang
2016-02-18  3:31   ` Jason Wang
2016-02-18  3:46     ` Hailiang Zhang
2016-02-18  7:30       ` Hailiang Zhang
2016-02-23  8:38         ` Jason Wang
2016-02-23  9:10           ` Hailiang Zhang
2016-02-23  8:37       ` Jason Wang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 38/40] filter-buffer: make filter_buffer_flush() public zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 39/40] COLO: flush buffered packets in checkpoint process or exit COLO zhanghailiang
2016-02-06  9:28 ` [Qemu-devel] [PATCH COLO-Frame v14 40/40] COLO: Add block replication into colo process zhanghailiang

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=56C2BEE5.5030603@huawei.com \
    --to=zhang.zhanghailiang@huawei.com \
    --cc=amit.shah@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eddie.dong@intel.com \
    --cc=hongyang.yang@easystack.cn \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=xiecl.fnst@cn.fujitsu.com \
    --cc=yunhong.jiang@intel.com \
    --cc=zhangchen.fnst@cn.fujitsu.com \
    /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).