From patchwork Thu Jul 7 14:40:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 103685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DC5911007D1 for ; Fri, 8 Jul 2011 02:01:00 +1000 (EST) Received: from localhost ([::1]:57576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qer0c-0001qy-0S for incoming@patchwork.ozlabs.org; Thu, 07 Jul 2011 12:00:58 -0400 Received: from eggs.gnu.org ([140.186.70.92]:40908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qepl6-0006bg-Rr for qemu-devel@nongnu.org; Thu, 07 Jul 2011 10:40:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qepl5-0006bY-97 for qemu-devel@nongnu.org; Thu, 07 Jul 2011 10:40:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qepl4-0006bK-QT for qemu-devel@nongnu.org; Thu, 07 Jul 2011 10:40:51 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p67Eem6R016761 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Jul 2011 10:40:48 -0400 Received: from rincewind.home.kraxel.org (vpn1-7-130.ams2.redhat.com [10.36.7.130]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p67Eehf2025343; Thu, 7 Jul 2011 10:40:44 -0400 Message-ID: <4E15C569.8030304@redhat.com> Date: Thu, 07 Jul 2011 16:40:41 +0200 From: Gerd Hoffmann User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Red Hat/3.1.11-2.el6_1 Thunderbird/3.1.11 MIME-Version: 1.0 To: Markus Armbruster References: <4E148776.4000805@redhat.com> <4E1497C6.4060505@codemonkey.ws> In-Reply-To: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: jes sorensen , "qemu-devel@nongnu.org" , Juan Quintela Subject: Re: [Qemu-devel] migration: new sections and backward compatibility. 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 Hi, > Not so fast :) > > I agree that throwing away unrecognized migration data is unsafe, and > should not be done. Now let me present my little problem. > > I'm working on making migration preserve "tray status": open/closed, > locked/unlocked. > > For ide-cd, I can stick a subsection "ide_drive/tray_state" into section > "ide_drive". Needed only if the tray is open or locked. This gives > users a chance to migrate to older versions, and is perfectly safe. > > scsi-cd doesn't have a section, yet. What now? Experimental patch for usb attached (actually two, the first is pure code motion though so the second with the actual changes becomes more readable). That makes migration support switchable using a property, so we can use compatibility properties to disable sending the section to an older version. That requires usb-hid.c call vmstate_register manually. Not that nice. We could move the needed() callback from VMStateSubsection to VMStateDescription, so it is possible to send complete sections conditionally. Comments? cheers, Gerd From adf3fd9f870c5ce5566223e1edfb033c81bd01e4 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 7 Jul 2011 15:49:54 +0200 Subject: [PATCH 1/2] move code --- hw/usb-hid.c | 86 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 43 insertions(+), 43 deletions(-) diff --git a/hw/usb-hid.c b/hw/usb-hid.c index d711b5c..f30c96b 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -854,49 +854,6 @@ static void usb_hid_handle_destroy(USBDevice *dev) } } -static int usb_hid_initfn(USBDevice *dev, int kind) -{ - USBHIDState *s = DO_UPCAST(USBHIDState, dev, dev); - - usb_desc_init(dev); - s->kind = kind; - - if (s->kind == USB_MOUSE) { - s->ptr.eh_entry = qemu_add_mouse_event_handler(usb_pointer_event, s, - 0, "QEMU USB Mouse"); - } else if (s->kind == USB_TABLET) { - s->ptr.eh_entry = qemu_add_mouse_event_handler(usb_pointer_event, s, - 1, "QEMU USB Tablet"); - } - - /* Force poll routine to be run and grab input the first time. */ - s->changed = 1; - return 0; -} - -static int usb_tablet_initfn(USBDevice *dev) -{ - return usb_hid_initfn(dev, USB_TABLET); -} - -static int usb_mouse_initfn(USBDevice *dev) -{ - return usb_hid_initfn(dev, USB_MOUSE); -} - -static int usb_keyboard_initfn(USBDevice *dev) -{ - return usb_hid_initfn(dev, USB_KEYBOARD); -} - -void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *)) -{ - USBHIDState *s = (USBHIDState *)dev; - - s->datain_opaque = opaque; - s->datain = datain; -} - static int usb_hid_post_load(void *opaque, int version_id) { USBHIDState *s = opaque; @@ -956,6 +913,49 @@ static const VMStateDescription vmstate_usb_kbd = { } }; +static int usb_hid_initfn(USBDevice *dev, int kind) +{ + USBHIDState *s = DO_UPCAST(USBHIDState, dev, dev); + + usb_desc_init(dev); + s->kind = kind; + + if (s->kind == USB_MOUSE) { + s->ptr.eh_entry = qemu_add_mouse_event_handler(usb_pointer_event, s, + 0, "QEMU USB Mouse"); + } else if (s->kind == USB_TABLET) { + s->ptr.eh_entry = qemu_add_mouse_event_handler(usb_pointer_event, s, + 1, "QEMU USB Tablet"); + } + + /* Force poll routine to be run and grab input the first time. */ + s->changed = 1; + return 0; +} + +static int usb_tablet_initfn(USBDevice *dev) +{ + return usb_hid_initfn(dev, USB_TABLET); +} + +static int usb_mouse_initfn(USBDevice *dev) +{ + return usb_hid_initfn(dev, USB_MOUSE); +} + +static int usb_keyboard_initfn(USBDevice *dev) +{ + return usb_hid_initfn(dev, USB_KEYBOARD); +} + +void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *)) +{ + USBHIDState *s = (USBHIDState *)dev; + + s->datain_opaque = opaque; + s->datain = datain; +} + static struct USBDeviceInfo hid_info[] = { { .product_desc = "QEMU USB Tablet",