From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5yXS-0000YK-N0 for qemu-devel@nongnu.org; Wed, 03 May 2017 13:58:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5yXR-0001Wk-W6 for qemu-devel@nongnu.org; Wed, 03 May 2017 13:58:10 -0400 Date: Wed, 3 May 2017 14:58:02 -0300 From: Eduardo Habkost Message-ID: <20170503175802.GU3482@thinpad.lan.raisama.net> References: <1493816238-33120-1-git-send-email-imammedo@redhat.com> <1493816238-33120-24-git-send-email-imammedo@redhat.com> <20170503163543.GR3482@thinpad.lan.raisama.net> <5f71cfda-2a73-77e3-0bf7-85e2aed53811@redhat.com> <20170503173841.GT3482@thinpad.lan.raisama.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170503173841.GT3482@thinpad.lan.raisama.net> Subject: Re: [Qemu-devel] [PATCH v2 23/24] numa: add '-numa cpu, ...' option for property based node mapping List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Igor Mammedov , qemu-devel@nongnu.org, Peter Maydell , Andrew Jones , David Gibson , Paolo Bonzini , Shannon Zhao , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Michael Roth On Wed, May 03, 2017 at 02:38:41PM -0300, Eduardo Habkost wrote: > On Wed, May 03, 2017 at 11:39:10AM -0500, Eric Blake wrote: > > On 05/03/2017 11:35 AM, Eduardo Habkost wrote: > > > > >> + > > >> + memset(&cpu, 0, sizeof(cpu)); > > >> + cpu.has_node_id = object->u.cpu.has_node_id; > > >> + cpu.node_id = object->u.cpu.node_id; > > >> + cpu.has_socket_id = object->u.cpu.has_socket_id; > > >> + cpu.socket_id = object->u.cpu.socket_id; > > >> + cpu.has_core_id = object->u.cpu.has_core_id; > > >> + cpu.core_id = object->u.cpu.core_id; > > >> + cpu.has_thread_id = object->u.cpu.has_thread_id; > > >> + cpu.thread_id = object->u.cpu.thread_id; > > > > > > We don't have a way to avoid copying each field individually? > > > Some visitor trick, maybe? > > > > > > Eric, Markus, Michael, do you have any suggestions? > > > > Markus just added QAPI_CLONE_MEMBERS(), which sounds like what you want: > > > > https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg04867.html > > Not sure if it would work in this case. Note that cpu and > object->u.cpu have different types. 'cpu' is CpuInstanceProps, > but object->u.cpu is NodeCpuOptions. > > NodeCpuOptions has { 'base': 'CpuInstanceProps' }, and > CpuInstanceProps field declarations are duplicated in struct > NodeCpuOptions. Do you know why struct inheritance is implemented > by duplicating the fields of the base struct instead of embedding > the base struct? Nevermind, I just found out that QAPI generates a qapi_NumaCpuOptions_base() upcast helper. So this can be solved with no data copying at all: machine_set_cpu_numa_nodes(ms, qapi_NumaCpuOptions_base(&object->u.cpu), &err); -- Eduardo