Received: from eggs.gnu.org ([140.186.70.92]:52148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QLtFA-0004QB-5c for qemu-devel@nongnu.org; Mon, 16 May 2011 04:33:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QLtF7-0004UM-Us for qemu-devel@nongnu.org; Mon, 16 May 2011 04:33:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30573) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QLtF7-0004UB-LT for qemu-devel@nongnu.org; Mon, 16 May 2011 04:33:33 -0400 From: Markus Armbruster References: <4DCD60AF.5090107@codemonkey.ws> Date: Mon, 16 May 2011 10:33:28 +0200 In-Reply-To: <4DCD60AF.5090107@codemonkey.ws> (Anthony Liguori's message of "Fri, 13 May 2011 11:47:43 -0500") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] Should new USB devices such as usb-ccid support legacy -usbdevice? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Alon Levy , qemu-devel@nongnu.org, Gerd Hoffmann Anthony Liguori writes: > On 05/13/2011 11:36 AM, Markus Armbruster wrote: >> When Gerd qdevified USB, he kept legacy -usbdevice working (commit >> 0958b4cc...). What about new USB devices? Should they get a legacy >> syntax, too? >> >> The only existing new device is usb-ccid, and it got one in commit >> 36707144. > > What keeps -usbdevice from being a light wrapper to -device such that > no future code is needed for this? What would that buy us? Inhowfar is -usbdevice any lighter than -device? > I know some of the names are different but presumably we could use a > map for existing ones and pass through names for newer ones. Here's what an USB device needs to do for -usbdevice: * For -usbdevice NAME (no parameters), set USBDeviceInfo member usbdevice_name to NAME. * For -usbdevice NAME:PARAMS, additionally set USBDeviceInfo member usbdevice_init() to a function that parses PARAMS and creates the device. Legacy PARAMs use various ad hoc syntax, and that's why we have a callback here. For new devices, we could require regular syntax, and then a common callback would do. The common NAME=VALUE,... syntax is the obvious choice, where the NAMEs are property names. But then -usbdevice is *exactly* like -device, except you the "usb" goes in a different place: "-usbdevice ccid" vs. "-device usb-ccid". And except that -usbdevice is crippled for some devices. For instance, usb-ccid doesn't support parameters with -usbdevice, even though it has a qdev property.