From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YE7hg-0005y2-Ft for qemu-devel@nongnu.org; Wed, 21 Jan 2015 21:41:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YE7hX-0004RP-4T for qemu-devel@nongnu.org; Wed, 21 Jan 2015 21:41:04 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:61500) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YE7hW-0004Pt-Ha for qemu-devel@nongnu.org; Wed, 21 Jan 2015 21:40:55 -0500 From: zhanghailiang Date: Thu, 22 Jan 2015 10:40:04 +0800 Message-ID: <1421894406-12180-4-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1421894406-12180-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1421894406-12180-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v2 3/5] 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: hangaohuai@huawei.com, zhanghailiang , peter.huangpeng@huawei.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com, lersek@redhat.com We can change guest's online/offline state of memory blocks, by using command 'guest-set-memory-blocks'. Signed-off-by: zhanghailiang --- 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 3f66489..4b41385 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2113,7 +2113,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.7.12.4