[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V8 1/2] Add a new qmp command to start/stop repl
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH V8 1/2] Add a new qmp command to start/stop replication |
Date: |
Thu, 23 Feb 2017 09:31:46 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 02/23/2017 01:14 AM, Zhang Chen wrote:
> We can call this qmp command to start/stop replication outside of qemu.
> Like Xen colo need this function.
>
> Signed-off-by: Zhang Chen <address@hidden>
> Signed-off-by: Wen Congyang <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>
> Reviewed-by: Stefano Stabellini <address@hidden>
> Reviewed-by: zhanghailiang <address@hidden>
>
> ---
> @@ -104,6 +106,27 @@ void colo_do_failover(MigrationState *s)
> }
> }
>
> +void qmp_xen_set_replication(bool enable, bool primary,
> + bool has_failover, bool failover,
> + Error **errp)
> +{
> + ReplicationMode mode = primary ?
> + REPLICATION_MODE_PRIMARY :
> + REPLICATION_MODE_SECONDARY;
> +
> + if (has_failover && enable) {
> + error_setg(errp, "Parameter 'failover' is only for"
> + " stopping replication");
> + return;
> + }
> +
> + if (enable) {
> + replication_start_all(mode, errp);
> + } else {
> + replication_stop_all(failover, failover ? NULL : errp);
Technically, this is use of failover without first checking
has_failover; it would be safer if you inserted:
if (!has_failover) {
failover = NULL;
}
earlier in the function to be safe against any callers that don't go
through the QAPI-generated code. Fortunately, our QAPI generated code
guarantees that failover is NULL when has_failover is false, so my R-b
can stand as-is if there is no other reason for a respin.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature