Patchwork [3/3] UHCI: Substate section for migration of remote wakeup feature

login
register
mail settings
Submitter Marcelo Tosatti
Date Dec. 1, 2010, 4:47 p.m.
Message ID <20101201164743.090538903@redhat.com>
Download mbox | patch
Permalink /patch/73847/
State New
Headers show

Comments

Marcelo Tosatti - Dec. 1, 2010, 4:47 p.m.
Use a subsection to migrate remote wakeup feature only when used by the guest. 

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Gerd Hoffmann - Dec. 1, 2010, 5:16 p.m.
On 12/01/10 17:47, Marcelo Tosatti wrote:
> Use a subsection to migrate remote wakeup feature only when used by the guest.

Yea, right, this must be saved.  But certainly not by the UHCI adapter, 
it belongs into the usb devices.  Some of them don't save state at all 
today, which makes it a bit tricky to do this in a way that migration to 
older versions keeps working at least as long as remote wakeup isn't 
used ...

Juan, any idea?

cheers,
   Gerd
Juan Quintela - Dec. 1, 2010, 7:14 p.m.
Gerd Hoffmann <kraxel@redhat.com> wrote:
> On 12/01/10 17:47, Marcelo Tosatti wrote:
>> Use a subsection to migrate remote wakeup feature only when used by the guest.
>
> Yea, right, this must be saved.  But certainly not by the UHCI
> adapter, it belongs into the usb devices.  Some of them don't save
> state at all today, which makes it a bit tricky to do this in a way
> that migration to older versions keeps working at least as long as
> remote wakeup isn't used ...
>
> Juan, any idea?

Second thought.

Only to add sections for all devices that don't have one.  But the
problem is that we have optional subsections, not optional subsections
(it is not a way to not send a section because no value there).

Later, Juan.
Marcelo Tosatti - Dec. 1, 2010, 8:56 p.m.
On Wed, Dec 01, 2010 at 08:14:22PM +0100, Juan Quintela wrote:
> Gerd Hoffmann <kraxel@redhat.com> wrote:
> > On 12/01/10 17:47, Marcelo Tosatti wrote:
> >> Use a subsection to migrate remote wakeup feature only when used by the guest.
> >
> > Yea, right, this must be saved.  But certainly not by the UHCI
> > adapter, it belongs into the usb devices.  Some of them don't save
> > state at all today, which makes it a bit tricky to do this in a way
> > that migration to older versions keeps working at least as long as
> > remote wakeup isn't used ...
> >
> > Juan, any idea?
> 
> Second thought.
> 
> Only to add sections for all devices that don't have one.  But the
> problem is that we have optional subsections, not optional subsections
> (it is not a way to not send a section because no value there).
> 
> Later, Juan.

Which breaks migration for older versions. Which lowers the
applicability of s/r.

Yes, remote_wakeup does not belong to UHCI, but i dont see another
solution. Or break migration upstream and use the hack for vendors.

Patch

Index: qemu-kvm/hw/usb-uhci.c
===================================================================
--- qemu-kvm.orig/hw/usb-uhci.c
+++ qemu-kvm/hw/usb-uhci.c
@@ -363,6 +363,39 @@  static void uhci_pre_save(void *opaque)
     uhci_async_cancel_all(s);
 }
 
+static bool uhci_port_wakeup_state_needed(void *opaque)
+{
+    UHCIPort *port = opaque;
+
+    if (port->port.dev) {
+        return port->port.dev->remote_wakeup;
+    }
+
+    return false;
+}
+
+static int uhci_port_wakeup_post_load(void *opaque, int version_id)
+{
+    UHCIPort *port = opaque;
+
+    if (port->port.dev) {
+        port->port.dev->remote_wakeup = 1;
+    }
+
+    return 0;
+}
+
+const VMStateDescription vmstate_uhci_wakeup_state = {
+    .name = "uhci port/wakeup",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .post_load = uhci_port_wakeup_post_load,
+    .fields      = (VMStateField []) {
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const VMStateDescription vmstate_uhci_port = {
     .name = "uhci port",
     .version_id = 1,
@@ -371,6 +404,14 @@  static const VMStateDescription vmstate_
     .fields      = (VMStateField []) {
         VMSTATE_UINT16(ctrl, UHCIPort),
         VMSTATE_END_OF_LIST()
+    },
+    .subsections = (VMStateSubsection []) {
+        {
+            .vmsd = &vmstate_uhci_wakeup_state,
+            .needed = uhci_port_wakeup_state_needed,
+        }, {
+            /* empty */
+        }
     }
 };