[libvirt] [PATCH v3 2/5] vz: add migration backbone code

Nikolay Shirokovskiy nshirokovskiy at parallels.com
Wed Aug 26 07:19:43 UTC 2015



On 25.08.2015 20:28, Dmitry Guryanov wrote:
> On 08/25/2015 07:18 PM, Daniel P. Berrange wrote:
>> On Tue, Aug 25, 2015 at 12:04:14PM +0300, nshirokovskiy at virtuozzo.com wrote:
>>> From: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
>>>
>>> This patch makes basic vz migration possible. For example by virsh:
>>>    virsh -c vz:///system migrate --direct $NAME $STUB vz+ssh://$DST/system
>>>
>>> $STUB could be anything as it is required virsh argument but it is not
>>> used in direct migration.
>>>
>>> Vz migration is implemented as direct migration. The reason is that vz sdk do
>>> all the job. Prepare phase function is used to pass session uuid from
>>> destination to source so we don't introduce new rpc call.
>> I'm trying to understand why you need $STUB as dummy data.
>>
>> IIRC, when doing direct migration, you should be providing a valid
>> URI for the first parameter, and not need the second uri.
> 
> virsh uses virDomainMigrateToURI3 function, and for some reason it differs
> destination URI for direct and peer-to-peer migrations. For p2p it uses
> pconnuri argument and for direct -VIR_MIGRATE_PARAM_URI <http://libvirt.org/html/libvirt-libvirt-domain.html#VIR_MIGRATE_PARAM_URI>  from typed params list.
> 
AFAIU in virDomainMigrateToURI3 function, dconnuri argument is treated as URI to destination libvirt daemon.
As direct migration doesn't need this kind of connection this argument is ignored.

However as suggested vz migration implementation uses connection to destination libvirtd daemon
to get destination hypervisor session uuid I should probably use dconnuri for for that purporse
not hypervisor URI. This is related what Dmitry mentioned in previous letters where there
was a confusion between hypervisor and remote access to daemon ports.

This would break a invariant mentioned in the documentation that direct migration 
does not use dconnuri. Probably it is not too bad too get away from this restriction.

> 
> 
>>> +
>>> +static int
>>> +vzDomainMigratePrepare3(virConnectPtr conn,
>>> +                        const char *cookiein ATTRIBUTE_UNUSED,
>>> +                        int cookieinlen ATTRIBUTE_UNUSED,
>>> +                        char **cookieout,
>>> +                        int *cookieoutlen,
>>> +                        const char *uri_in ATTRIBUTE_UNUSED,
>>> +                        char **uri_out ATTRIBUTE_UNUSED,
>>> +                        unsigned long flags,
>>> +                        const char *dname ATTRIBUTE_UNUSED,
>>> +                        unsigned long resource ATTRIBUTE_UNUSED,
>>> +                        const char *dom_xml ATTRIBUTE_UNUSED)
>>> +{
>>> +    vzConnPtr privconn = conn->privateData;
>>> +    int ret = -1;
>>> +
>>> +    virCheckFlags(0, -1);
>>> +
>>> +    if (!(*cookieout = vzFormatCookie(privconn->session_uuid)))
>>> +        goto cleanup;
>>> +    *cookieoutlen = strlen(*cookieout) + 1;
>>> +    ret = 0;
>>> +
>>> + cleanup:
>>> +    if (ret != 0) {
>>> +        VIR_FREE(*cookieout);
>>> +        *cookieoutlen = 0;
>>> +    }
>>> +
>>> +    return ret;
>>> +}
>>> +
>>> +static int
>>> +vzConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
>>> +{
>>> +    switch (feature) {
>>> +    case VIR_DRV_FEATURE_MIGRATION_V3:
>>> +    case VIR_DRV_FEATURE_MIGRATION_DIRECT:
>>> +        return 1;
>>> +    default:
>>> +        return 0;
>>> +    }
>>> +}
>>> +
>>> +static virURIPtr
>>> +vzMakeVzUri(const char *connuri_str)
>>> +{
>>> +    virURIPtr connuri = NULL;
>>> +    virURIPtr vzuri = NULL;
>>> +    int ret = -1;
>>> +
>>> +    if (!(connuri = virURIParse(connuri_str)))
>>> +        goto cleanup;
>>> +
>>> +    if (VIR_ALLOC(vzuri) < 0)
>>> +        goto cleanup;
>>> +    memset(vzuri, 0, sizeof(*vzuri));
>>> +
>>> +    if (VIR_STRDUP(vzuri->server, connuri->server) < 0)
>>> +        goto cleanup;
>>> +    vzuri->port = connuri->port;
>>> +    ret = 0;
>>> +
>>> + cleanup:
>>> +
>>> +    virURIFree(connuri);
>>> +    if (ret < 0) {
>>> +        virURIFree(vzuri);
>>> +        vzuri = NULL;
>>> +    }
>>> +
>>> +    return vzuri;
>>> +}
>>> +
>>> +#define VZ_MIGRATION_FLAGS (0)
>>> +
>>> +#define VZ_MIGRATION_PARAMETERS (NULL)
>>> +
>>> +static int
>>> +vzDomainMigratePerform3(virDomainPtr domain,
>>> +                        const char *xmlin ATTRIBUTE_UNUSED,
>>> +                        const char *cookiein ATTRIBUTE_UNUSED,
>>> +                        int cookieinlen ATTRIBUTE_UNUSED,
>>> +                        char **cookieout ATTRIBUTE_UNUSED,
>>> +                        int *cookieoutlen ATTRIBUTE_UNUSED,
>>> +                        const char *dconnuri ATTRIBUTE_UNUSED,
>>> +                        const char *uri,
>> I think you should be using 'dconnuri' rather than 'uri', so
>> then you would not need the $STUB dummy parameter.
>>
>>
>> Regards,
>> Daniel
> 




More information about the libvir-list mailing list