From patchwork Thu Jan 22 02:40:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 431658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B90CA14012E for ; Thu, 22 Jan 2015 13:43:06 +1100 (AEDT) Received: from localhost ([::1]:50958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YE7jd-0000qS-0E for incoming@patchwork.ozlabs.org; Wed, 21 Jan 2015 21:43:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YE7hc-0005sc-VX for qemu-devel@nongnu.org; Wed, 21 Jan 2015 21:41:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YE7hW-0004RE-Oh for qemu-devel@nongnu.org; Wed, 21 Jan 2015 21:41:00 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:61476) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YE7hV-0004PS-U0 for qemu-devel@nongnu.org; Wed, 21 Jan 2015 21:40:54 -0500 Received: from 172.24.2.119 (EHLO szxeml430-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CIH34611; Thu, 22 Jan 2015 10:40:43 +0800 (CST) Received: from localhost (10.177.22.69) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.158.1; Thu, 22 Jan 2015 10:40:33 +0800 From: zhanghailiang To: Date: Thu, 22 Jan 2015 10:40:02 +0800 Message-ID: <1421894406-12180-2-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 1.9.2.msysgit.0 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 X-Originating-IP: [10.177.22.69] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.64 Cc: hangaohuai@huawei.com, zhanghailiang , peter.huangpeng@huawei.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com, lersek@redhat.com Subject: [Qemu-devel] [PATCH v2 1/5] qga: introduce three guest memory block commmands with stubs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Introduce three new guest commands: guest-get-memory-blocks, guest-set-memory-blocks, guest-get-memory-block-size. With these three commands, we can support online/offline guest's memory block (logical memory hotplug/unplug) as required from host. Signed-off-by: zhanghailiang --- qga/commands-posix.c | 38 +++++++++++++++++ qga/commands-win32.c | 19 +++++++++ qga/qapi-schema.json | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index f6f3e3c..76dc07b 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1875,6 +1875,25 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp) return processed; } +GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return NULL; +} + +GuestMemoryBlockResponseList * +qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return NULL; +} + +int64_t qmp_guest_get_memory_block_size(Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return -1; +} + #else /* defined(__linux__) */ void qmp_guest_suspend_disk(Error **errp) @@ -1910,6 +1929,25 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp) return -1; } +GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return NULL; +} + +GuestMemoryBlockResponseList * +qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return NULL; +} + +int64_t qmp_guest_get_memory_block_size(Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return -1; +} + #endif #if !defined(CONFIG_FSFREEZE) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 3bcbeae..c596c0c 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -446,6 +446,25 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp) return -1; } +GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return NULL; +} + +GuestMemoryBlockResponseList * +qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return NULL; +} + +int64_t qmp_guest_get_memory_block_size(Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return -1; +} + /* add unsupported commands to the blacklist */ GList *ga_command_blacklist_init(GList *blacklist) { diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 376e79f..20ba2ad 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -738,3 +738,117 @@ ## { 'command': 'guest-get-fsinfo', 'returns': ['GuestFilesystemInfo'] } + +## +# @GuestMemoryBlock: +# +# @phys-index: Arbitrary guest-specific unique identifier of the MEMORY BLOCK. +# +# @online: Whether the MEMORY BLOCK is enabled in guest. +# +# @can-offline: #optional Whether offlining the MEMORY BLOCK is possible. +# This member is always filled in by the guest agent when the +# structure is returned, and always ignored on input (hence it +# can be omitted then). +# +# Since: 2.3 +## +{ 'type': 'GuestMemoryBlock', + 'data': {'phys-index': 'uint64', + 'online': 'bool', + '*can-offline': 'bool'} } + +## +# @guest-get-memory-blocks: +# +# Retrieve the list of the guest's memory blocks. +# +# This is a read-only operation. +# +# Returns: The list of all memory blocks the guest knows about. +# Each memory block is put on the list exactly once, but their order +# is unspecified. +# +# Since: 2.3 +## +{ 'command': 'guest-get-memory-blocks', + 'returns': ['GuestMemoryBlock'] } + +## +# @GuestMemoryBlockResponseType +# +# An enumeration of memory block operation result. +# +# @sucess: the operation of online/offline memory block is successful. +# @not-found: can't find the corresponding memoryXXX directory in sysfs. +# @operation-not-supported: for some old kernels, it does not support +# online or offline memory block. +# @operation-failed: the operation of online/offline memory block fails, +# because of some errors happen. +# +# Since: 2.3 +## +{ 'enum': 'GuestMemoryBlockResponseType', + 'data': ['success', 'not-found', 'operation-not-supported', + 'operation-failed'] } + +## +# @GuestMemoryBlockResponse: +# +# @phys-index: same with the 'phys-index' member of @GuestMemoryBlock. +# +# @response: the result of memory block operation. +# +# @error-code: #optional the error number. +# When memory block operation fails, we assign the value of +# 'errno' to this member, it indicates what goes wrong. +# When the operation succeeds, it will be omitted. +# +# Since: 2.3 +## +{ 'type': 'GuestMemoryBlockResponse', + 'data': { 'phys-index': 'uint64', + 'response': 'GuestMemoryBlockResponseType', + '*error-code': 'int' }} + +## +# @guest-set-memory-blocks: +# +# Attempt to reconfigure (currently: enable/disable) state of memory blocks +# inside the guest. +# +# The input list is processed node by node in order. In each node @phys-index +# is used to look up the guest MEMORY BLOCK, for which @online specifies the +# requested state. The set of distinct @phys-index's is only required to be a +# subset of the guest-supported identifiers. There's no restriction on list +# length or on repeating the same @phys-index (with possibly different @online +# field). +# Preferably the input list should describe a modified subset of +# @guest-get-memory-blocks' return value. +# +# Returns: The operation results, it is a list of @GuestMemoryBlockResponse, +# which is corresponding to the input list. +# +# Note: it will return NULL if the @mem-blks list was empty on input, +# or there is an error, and in this case, guest state will not be +# changed. +# +# Since: 2.3 +## +{ 'command': 'guest-set-memory-blocks', + 'data': {'mem-blks': ['GuestMemoryBlock'] }, + 'returns': ['GuestMemoryBlockResponse'] } + +## +# @guest-get-memory-block-size: +# +# Get the the size (in bytes) of a memory block in guest. +# It is the unit of memory block online/offline operation (also called Logical +# Memory Hotplug). +# +# Returns: memory block size in bytes. +# +# Since 2.3 +## +{ 'command': 'guest-get-memory-block-size', + 'returns': 'int' }