From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2oGI-0006Es-KR for qemu-devel@nongnu.org; Sun, 21 Dec 2014 16:42:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y2oGA-0002bP-Ux for qemu-devel@nongnu.org; Sun, 21 Dec 2014 16:42:02 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]:54544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2oGA-0002bJ-ON for qemu-devel@nongnu.org; Sun, 21 Dec 2014 16:41:54 -0500 Received: from /spool/local by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 21 Dec 2014 14:41:53 -0700 Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id E870C19D8039 for ; Sun, 21 Dec 2014 14:30:28 -0700 (MST) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sBLLfoig40894594 for ; Sun, 21 Dec 2014 14:41:50 -0700 Received: from d03av01.boulder.ibm.com (localhost [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sBLLfnam032200 for ; Sun, 21 Dec 2014 14:41:49 -0700 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1417849159-6568-6-git-send-email-zhang.zhanghailiang@huawei.com> References: <1417849159-6568-1-git-send-email-zhang.zhanghailiang@huawei.com> <1417849159-6568-6-git-send-email-zhang.zhanghailiang@huawei.com> Message-ID: <20141221214144.15420.81128@loki> Date: Sun, 21 Dec 2014 15:41:44 -0600 Subject: Re: [Qemu-devel] [PATCH RFC for-2.3 5/6] qga: implement qmp_guest_get_memory_block_size() for Linux with sysfs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang , qemu-devel@nongnu.org Cc: peter.huangpeng@huawei.com Quoting zhanghailiang (2014-12-06 00:59:18) > The size of a memory block is architecture dependent, > For example, power uses 16MiB, ia64 uses 1GiB, x86 uses 128M. That's the minimum for Power, but the size can be set via device tree and can differ from one platform to the next. Should either clarify in the commit or maybe just drop the statement to avoid confusion. > It represents the logical unit upon which memory online/offline operation= s are > to be performed. > = > This function will return the value to host user. > = > Signed-off-by: zhanghailiang > --- > qga/commands-posix.c | 43 +++++++++++++++++++++++++++++++++++++------ > 1 file changed, 37 insertions(+), 6 deletions(-) > = > diff --git a/qga/commands-posix.c b/qga/commands-posix.c > index 1010e86..02c6b44 100644 > --- a/qga/commands-posix.c > +++ b/qga/commands-posix.c > @@ -2087,6 +2087,37 @@ int64_t qmp_guest_set_memory_blocks(GuestMemoryBlo= ckList *mem_blks, > return processed; > } > = > +int64_t qmp_guest_get_memory_block_size(Error **errp) > +{ > + Error *local_err =3D NULL; > + char *dirpath; > + int dirfd; > + char *buf; > + int64_t block_size; > + > + dirpath =3D g_strdup_printf("/sys/devices/system/memory/"); > + dirfd =3D open(dirpath, O_RDONLY | O_DIRECTORY); > + if (dirfd =3D=3D -1) { > + error_setg_errno(errp, errno, "open(\"%s\")", dirpath); > + g_free(dirpath); > + return -1; > + } > + g_free(dirpath); > + > + buf =3D g_malloc0(20); > + ga_read_sysfs_file(dirfd, "block_size_bytes", buf, 20, &local_err); > + if (local_err) { > + g_free(buf); > + error_propagate(errp, local_err); > + return -1; > + } > + > + block_size =3D strtol(buf, NULL, 16); /* the unit is bytes */ > + g_free(buf); > + > + return block_size; > +} > + > #else /* defined(__linux__) */ > = > void qmp_guest_suspend_disk(Error **errp) > @@ -2135,6 +2166,12 @@ int64_t qmp_guest_set_memory_blocks(GuestMemoryBlo= ckList *mem_blks, > return -1; > } > = > +int64_t qmp_guest_get_memory_block_size(Error **errp) > +{ > + error_set(errp, QERR_UNSUPPORTED); > + return -1; > +} > + > #endif > = > #if !defined(CONFIG_FSFREEZE) > @@ -2221,12 +2258,6 @@ GList *ga_command_blacklist_init(GList *blacklist) > return blacklist; > } > = > -int64_t qmp_guest_get_memory_block_size(Error **errp) > -{ > - error_set(errp, QERR_UNSUPPORTED); > - return -1; > -} > - Same as with above 2 patches, please squash into the initial stub patch > /* register init/cleanup routines for stateful command groups */ > void ga_command_state_init(GAState *s, GACommandState *cs) > { > -- = > 1.7.12.4