From patchwork Thu Feb 2 22:31:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Fehlig X-Patchwork-Id: 9553301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CEA4160453 for ; Thu, 2 Feb 2017 22:33:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7E9E28480 for ; Thu, 2 Feb 2017 22:33:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCC8628499; Thu, 2 Feb 2017 22:33:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 16BA128497 for ; Thu, 2 Feb 2017 22:33:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZPue-0007Q8-10; Thu, 02 Feb 2017 22:31:32 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZPuc-0007Pd-Ov for xen-devel@lists.xen.org; Thu, 02 Feb 2017 22:31:30 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 51/EF-01719-243B3985; Thu, 02 Feb 2017 22:31:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRWlGSWpSXmKPExsXS6fgrUNdx8+Q Ig4+/lS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozfi5YxFrwUqrjU8521gfEsfxcjF4eQwHZG iamzNzN3MXJysAkoS7zsvMUKYosISEksurcALM4sYC3xrXUlUJyDQxjI/nykDiTMIqAq8ebrd CYQm1fARKJr6U4WEFtCQE7i5eufYK2cAqYSD1+dBrOFgGoeXfjCNoGRawEjwypGjeLUorLUIl 0jA72kosz0jJLcxMwcXUMDU73c1OLixPTUnMSkYr3k/NxNjEAv1jMwMO5gbJztd4hRkoNJSZT 358LJEUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeEM2AeUEi1LTUyvSMnOA4QSTluDgURLhjQNJ 8xYXJOYWZ6ZDpE4xKkqJ8/KBJARAEhmleXBtsBC+xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDU UmYd+1GoCk8mXklcNNfAS1mAlr88/EkkMUliQgpqQZG/b1zT3A+kt4aUnfyPVfMl8vKKyx3BJ yI+XeRO1T01mHJW6VHt/9gdnCVPb38yv+E1HXnBXV+sqmF6j3M45z0d8Psd82l8+927uEpYut tST3U9f/kq6WVZ7XTGMWTDGYo5bix73veevCH1OqUE6vLFipI18YaWtlZHq1lqtiqsz/dsSNo 6Uk5JZbijERDLeai4kQAFohdz1wCAAA= X-Env-Sender: jfehlig@suse.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1486074687!67157527!1 X-Originating-IP: [137.65.250.81] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30233 invoked from network); 2 Feb 2017 22:31:29 -0000 Received: from smtp2.provo.novell.com (HELO smtp2.provo.novell.com) (137.65.250.81) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Feb 2017 22:31:29 -0000 Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Thu, 02 Feb 2017 15:31:24 -0700 From: Jim Fehlig To: libvir-list@redhat.com Date: Thu, 2 Feb 2017 15:31:13 -0700 Message-Id: <20170202223114.5793-2-jfehlig@suse.com> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20170202223114.5793-1-jfehlig@suse.com> References: <20170202223114.5793-1-jfehlig@suse.com> Cc: Jim Fehlig , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH 1/2] libxl: fix reporting of maximum memory X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The libxl driver reports different values of maximum memory depending on state of a domain. If inactive, maximum memory value is reported correctly. When active, maximum memory is derived from max_pages value returned by the XEN_SYSCTL_getdomaininfolist sysctl operation. But max_pages can be changed by toolstacks and does not necessarily represent the maximum memory a domain can use during its active lifetime. A better location for determining a domain's maximum memory is the /local/domain//memory/static-max node in xenstore. This value is set from the libxl_domain_build_info.max_memkb field when creating the domain. Currently it cannot be changed nor can its value be exceeded by a balloon operation. From libvirt's perspective, always reporting maximum memory with virDomainDefGetMemoryTotal() will produce the same results as reading the static-max node in xenstore. Signed-off-by: Jim Fehlig --- As an alternative, libvirt could call libxl_retrieve_domain_configuration and use the max_memkb field embedded in the libxl_domain_config object. src/libxl/libxl_driver.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 3a69720..921cc93 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1640,10 +1640,10 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0) goto cleanup; + info->maxMem = virDomainDefGetMemoryTotal(vm->def); if (!virDomainObjIsActive(vm)) { info->cpuTime = 0; info->memory = vm->def->mem.cur_balloon; - info->maxMem = virDomainDefGetMemoryTotal(vm->def); } else { libxl_dominfo_init(&d_info); @@ -1655,7 +1655,6 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) } info->cpuTime = d_info.cpu_time; info->memory = d_info.current_memkb; - info->maxMem = d_info.max_memkb; libxl_dominfo_dispose(&d_info); } @@ -5172,7 +5171,7 @@ libxlDomainMemoryStats(virDomainPtr dom, goto endjob; } mem = d_info.current_memkb; - maxmem = d_info.max_memkb; + maxmem = virDomainDefGetMemoryTotal(vm->def); LIBXL_SET_MEMSTAT(VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON, mem); LIBXL_SET_MEMSTAT(VIR_DOMAIN_MEMORY_STAT_AVAILABLE, maxmem);