diff mbox

migration: new sections and backward compatibility.

Message ID 4E15C569.8030304@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann July 7, 2011, 2:40 p.m. UTC
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 <kraxel@redhat.com>
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 mbox

Patch

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",