From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNYe0-0005uZ-Um for qemu-devel@nongnu.org; Mon, 16 Feb 2015 22:16:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNYdw-0004U0-Kq for qemu-devel@nongnu.org; Mon, 16 Feb 2015 22:16:16 -0500 Received: from e8.ny.us.ibm.com ([32.97.182.138]:52724) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNYdw-0004Tv-Fa for qemu-devel@nongnu.org; Mon, 16 Feb 2015 22:16:12 -0500 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Feb 2015 22:16:12 -0500 Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 1E9D86E803F for ; Mon, 16 Feb 2015 22:08:01 -0500 (EST) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1H3G9lZ28377258 for ; Tue, 17 Feb 2015 03:16:09 GMT Received: from d01av02.pok.ibm.com (localhost [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t1H3G7gs024437 for ; Mon, 16 Feb 2015 22:16:08 -0500 From: Michael Roth Date: Mon, 16 Feb 2015 21:14:49 -0600 Message-Id: <1424142892-7275-8-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1424142892-7275-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1424142892-7275-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 07/10] qga: implement qmp_guest_set_memory_blocks() for Linux with sysfs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, zhanghailiang From: zhanghailiang We can change guest's online/offline state of memory blocks, by using command 'guest-set-memory-blocks'. Signed-off-by: zhanghailiang Signed-off-by: Michael Roth --- qga/commands-posix.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 6cd21b2..1c8080f 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2233,7 +2233,35 @@ GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp) GuestMemoryBlockResponseList * qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp) { - error_set(errp, QERR_UNSUPPORTED); + GuestMemoryBlockResponseList *head, **link; + Error *local_err = NULL; + + head = NULL; + link = &head; + + while (mem_blks != NULL) { + GuestMemoryBlockResponse *result; + GuestMemoryBlockResponseList *entry; + GuestMemoryBlock *current_mem_blk = mem_blks->value; + + result = g_malloc0(sizeof(*result)); + result->phys_index = current_mem_blk->phys_index; + transfer_memory_block(current_mem_blk, false, result, &local_err); + if (local_err) { /* should never happen */ + goto err; + } + entry = g_malloc0(sizeof *entry); + entry->value = result; + + *link = entry; + link = &entry->next; + mem_blks = mem_blks->next; + } + + return head; +err: + qapi_free_GuestMemoryBlockResponseList(head); + error_propagate(errp, local_err); return NULL; } -- 1.9.1