From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nwztc-0001Kh-Is for qemu-devel@nongnu.org; Wed, 31 Mar 2010 11:31:56 -0400 Received: from [140.186.70.92] (port=50407 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nwztb-0001H5-9h for qemu-devel@nongnu.org; Wed, 31 Mar 2010 11:31:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NwztZ-0004cL-Bj for qemu-devel@nongnu.org; Wed, 31 Mar 2010 11:31:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15157) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NwztZ-0004br-3t for qemu-devel@nongnu.org; Wed, 31 Mar 2010 11:31:53 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2VFVpHD021114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 31 Mar 2010 11:31:51 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] Re: [PATCH 2/2] Added monitor commands: 'keyboard_set' and 'info keybaord' References: <689f24e27d483de0e3201a9386c772dc241d4178.1270022701.git.shaharh@redhat.com> Date: Wed, 31 Mar 2010 17:31:49 +0200 In-Reply-To: (Juan Quintela's message of "Wed, 31 Mar 2010 12:20:28 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: Shahar Havivi , qemu-devel@nongnu.org Juan Quintela writes: > Shahar Havivi wrote: >> Two new monitor commands: adding ability to handle which keyboard qemu will >> use and to see which keyboard are currently available. > >> +int do_keyboard_set(Monitor *mon, const QDict *qdict, QObject **ret_data) >> +{ >> + QEMUPutKbdEntry *cursor; >> + int index = qdict_get_int(qdict, "index"); >> + int found = 0; > > found variable is not used. > >> + >> + if (QTAILQ_EMPTY(&kbd_handlers)) { >> + qerror_report(QERR_DEVICE_NOT_FOUND, "keyboard"); >> + return -1; >> + } >> + >> + QTAILQ_FOREACH(cursor, &kbd_handlers, node) { >> + if (cursor->index == index) { >> + QTAILQ_REMOVE(&kbd_handlers, cursor, node); >> + QTAILQ_INSERT_HEAD(&kbd_handlers, cursor, node); >> + found = 1; > > well it is set :) > >> + break; >> + } >> + } >> + >> + return 0; > > I guess you want to return one error if the index don't exist. > >> +} > > I still think that adding an "id" property as in markus proposal would > be neat. Otherwise I don't know how you are going to distinguish > between two keyboards with the same name. If I understand the patch correctly (only time for a quick skim today), the keyboard receives a numeric ID when it is created, and keyboard_set identifies it by that ID. Yes, a user-defined ID would be nicer, and consistent with how similar things work. But the numeric ID isn't *wrong*, as far as I can see.