diff options
author | zhanghailiang <zhang.zhanghailiang@huawei.com> | 2015-01-22 10:40:04 +0800 |
---|---|---|
committer | Michael Roth <mdroth@linux.vnet.ibm.com> | 2015-02-17 16:16:40 -0600 |
commit | 32ca7927c7d66371abafb4cabfab9438a5905784 (patch) | |
tree | 142d7994e71011f4fba1e6d7e73a8c1a02b5f576 /qga | |
parent | bd240fca42d5f072fb758a71720d9de9990ac553 (diff) |
qga: implement qmp_guest_set_memory_blocks() for Linux with sysfs
We can change guest's online/offline state of memory blocks, by using
command 'guest-set-memory-blocks'.
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qga')
-rw-r--r-- | qga/commands-posix.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 5d4101dc79..0fd5d959d2 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2232,7 +2232,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; } |