[libvirt] [PATCH 1/3] vz: implement connectGetType and connectGetMaxVcpus API calls

Maxim Nestratov mnestratov at virtuozzo.com
Mon Oct 19 16:20:40 UTC 2015



14.10.2015 18:28, Dmitry Guryanov пишет:
> On 10/14/2015 12:50 PM, Maxim Nestratov wrote:
>> From: Maxim Nestratov <mnestratov at virtuozzo.com>
>>
>> As a connection type we report 'vz'.
>> And because we have no limitation for maximal number of vcpus in 
>> containers
>> we report as maximum 1028 just for the sake of common sence.
>>
>> Signed-off-by: Maxim Nestratov <mnestratov at virtuozzo.com>
>> ---
>>   src/vz/vz_driver.c |   19 +++++++++++++++++++
>>   1 files changed, 19 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
>> index 15dc70f..3cd6096 100644
>> --- a/src/vz/vz_driver.c
>> +++ b/src/vz/vz_driver.c
>> @@ -1337,12 +1337,31 @@ vzDomainMemoryStats(virDomainPtr domain,
>>       return ret;
>>   }
>>   +static int vzConnectGetMaxVcpus(virConnectPtr conn ATTRIBUTE_UNUSED,
>> +                                const char *type)
>> +{
>> +    /* As far as we have no limitation for containers
>> +     * we report maximum */
> What about VMs?
>> +    if (type == NULL || STRCASEEQ(type, "vz"))
> What about parallels virt type?
>
>> +        return 1028;
>> +
> Why not 1024?

The only reason is that this number is used in openVZ driver. I failed 
to find out why it was chosen back then. I guess it was NR_CPUS 
configured for openVZ kernel.

>
>> +    virReportError(VIR_ERR_INVALID_ARG,
>> +                   _("unknown type '%s'"), type);
>> +    return -1;
>> +}
>> +
>> +static const char *vzConnectGetType(virConnectPtr conn 
>> ATTRIBUTE_UNUSED) {
>> +    return "vz";
>> +}
>> +
>
> Is this function really needed? virConnectGetType returns driver name 
> if it's not
> implemented in the driver, exactly what are you doing.
>
> const char *
> virConnectGetType(virConnectPtr conn)
> {
>     const char *ret;
>     VIR_DEBUG("conn=%p", conn);
>
>     virResetLastError();
>
>     virCheckConnectReturn(conn, NULL);
>
>     if (conn->driver->connectGetType) {
>         ret = conn->driver->connectGetType(conn);
>         if (ret) return ret;
>     }
>     return conn->driver->name;
> }
>
>>   static virHypervisorDriver vzDriver = {
>>       .name = "vz",
>>       .connectOpen = vzConnectOpen,            /* 0.10.0 */
>>       .connectClose = vzConnectClose,          /* 0.10.0 */
>>       .connectGetVersion = vzConnectGetVersion,   /* 0.10.0 */
>>       .connectGetHostname = vzConnectGetHostname,      /* 0.10.0 */
>> +    .connectGetType = vzConnectGetType,        /* 1.2.21 */
>> +    .connectGetMaxVcpus = vzConnectGetMaxVcpus, /* 1.2.21 */
>>       .nodeGetInfo = vzNodeGetInfo,      /* 0.10.0 */
>>       .connectGetCapabilities = vzConnectGetCapabilities, /* 0.10.0 */
>>       .connectBaselineCPU = vzConnectBaselineCPU, /* 1.2.6 */
>




More information about the libvir-list mailing list