From nobody Sun Nov 9 23:46:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1494856988993671.6953569028597; Mon, 15 May 2017 07:03:08 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CCD7D3D974; Mon, 15 May 2017 14:03:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A03181821E; Mon, 15 May 2017 14:03:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 26F6F5ED63; Mon, 15 May 2017 14:03:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4FE33b4027529 for ; Mon, 15 May 2017 10:03:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id E3DA37ED92; Mon, 15 May 2017 14:03:03 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC51E7EBE3 for ; Mon, 15 May 2017 14:03:01 +0000 (UTC) Received: from relay.sw.ru (mailhub.sw.ru [195.214.232.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95B8A80C02 for ; Mon, 15 May 2017 14:02:58 +0000 (UTC) Received: from dim-vz7.qa.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4FE2urn025581 for ; Mon, 15 May 2017 17:02:56 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CCD7D3D974 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CCD7D3D974 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 95B8A80C02 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=nshirokovskiy@virtuozzo.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 95B8A80C02 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Mon, 15 May 2017 17:02:37 +0300 Message-Id: <1494856957-926069-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Greylist: Delayed for 72:25:15 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 15 May 2017 14:03:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 15 May 2017 14:03:00 +0000 (UTC) for IP:'195.214.232.25' DOMAIN:'mailhub.sw.ru' HELO:'relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: 0.799 (BAYES_50, SPF_PASS) 195.214.232.25 mailhub.sw.ru 195.214.232.25 mailhub.sw.ru X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] vz: support virDomainGetBlockInfo in driver X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 15 May 2017 14:03:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Actually physical size is not available in vz sdk right now so let's set it to allocation as an estimation in non sparse case. --- src/vz/vz_driver.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/vz/vz_sdk.c | 23 +++++++++++++++++++++++ src/vz/vz_sdk.h | 1 + 3 files changed, 74 insertions(+) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 9a429f4..7b32558 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -4005,6 +4005,55 @@ vzDomainBlockResize(virDomainPtr domain, return ret; } =20 +static int +vzDomainGetBlockInfo(virDomainPtr domain, + const char *path, + virDomainBlockInfoPtr info, + unsigned int flags) +{ + virDomainObjPtr dom; + virDomainDiskDefPtr disk; + long long allocation; + bool job =3D false; + int ret =3D -1; + + virCheckFlags(0, -1); + + if (!(dom =3D vzDomObjFromDomainRef(domain))) + return -1; + + if (virDomainGetBlockInfoEnsureACL(domain->conn, dom->def) < 0) + goto cleanup; + + if (vzDomainObjBeginJob(dom) < 0) + goto cleanup; + job =3D true; + + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + + if (!(disk =3D virDomainDiskByName(dom->def, path, false))) { + virReportError(VIR_ERR_INVALID_ARG, + _("invalid path %s not assigned to domain"), path); + goto cleanup; + } + + if ((allocation =3D prlsdkGetDiskAllocation(dom, disk)) < 0) + goto cleanup; + + info->capacity =3D disk->src->capacity; + info->allocation =3D allocation; + info->physical =3D allocation; + + ret =3D 0; + + cleanup: + if (job) + vzDomainObjEndJob(dom); + virDomainObjEndAPI(&dom); + return ret; +} + static virHypervisorDriver vzHypervisorDriver =3D { .name =3D "vz", .connectOpen =3D vzConnectOpen, /* 0.10.0 */ @@ -4106,6 +4155,7 @@ static virHypervisorDriver vzHypervisorDriver =3D { .domainAbortJob =3D vzDomainAbortJob, /* 3.1.0 */ .domainReset =3D vzDomainReset, /* 3.1.0 */ .domainBlockResize =3D vzDomainBlockResize, /* 3.3.0 */ + .domainGetBlockInfo =3D vzDomainGetBlockInfo, /* 3.4.0 */ }; =20 static virConnectDriver vzConnectDriver =3D { diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 4d2c6b0..b8f561c 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4962,3 +4962,26 @@ int prlsdkResizeImage(virDomainObjPtr dom, virDomain= DiskDefPtr disk, PrlHandle_Free(prldisk); return ret; } + +long long prlsdkGetDiskAllocation(virDomainObjPtr dom, + virDomainDiskDefPtr disk) +{ + vzDomObjPtr privdom =3D dom->privateData; + PRL_HANDLE job; + PRL_HANDLE prldisk; + PRL_UINT32 size; + PRL_RESULT pret; + + job =3D PrlVm_RefreshConfig(privdom->sdkdom); + if (waitDomainJob(job, dom)) + return -1; + + prldisk =3D prlsdkGetDisk(privdom->sdkdom, disk); + if (prldisk =3D=3D PRL_INVALID_HANDLE) + return -1; + + pret =3D PrlVmDevHd_GetSizeOnDisk(prldisk, &size); + prlsdkCheckRetExit(pret, -1); + + return ((unsigned long long)size) << 20; +} diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h index 0a77431..6b73067 100644 --- a/src/vz/vz_sdk.h +++ b/src/vz/vz_sdk.h @@ -91,3 +91,4 @@ PRL_HANDLE prlsdkSdkDomainLookupByName(vzDriverPtr driver, const char *name); int prlsdkCancelJob(virDomainObjPtr dom); int prlsdkResizeImage(virDomainObjPtr dom, virDomainDiskDefPtr disk, unsig= ned long long newsize); +long long prlsdkGetDiskAllocation(virDomainObjPtr dom, virDomainDiskDefPtr= disk); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list