Skip to contentSkip to conversation

usb/vmstate: add parent dev path

RFC PATCH In review Gerd Hoffmann 2 participants 2 messages Mar 13, 2012

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 usb/vmstate: add parent dev path

... to make vmstate id string truely unique with multiple host controllers, i.e. move from "1/usb-ptr" to "0000:00:01.3/1/usb-ptr" (usb tabled connected to piix3 uhci).

This is needed in case you have multiple USB busses in a virtual machine to make sure the section names are unique. Obviously this will break migration. I'm sitting on the patch for a while already, with the plan to sneak it in when we have a migration flag day anyway for the planned new & shiny migration format.

It doesn't look like this is going to happen anytime soon. I'd like to have this fixed in the 1.1 release. Suggestions how to go forward?

cheers,
Gerd

---
 hw/usb/bus.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
hw/usb/bus.c +14 -1
index d3f8358..0ffb89e 100644
@@ -460,7 +460,20 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
 static char *usb_get_dev_path(DeviceState *qdev)
 {
     USBDevice *dev = USB_DEVICE(qdev);
-    return g_strdup(dev->port->path);
+    DeviceState *hcd = qdev->parent_bus->parent;
+    char *id = NULL;
+
+    if (hcd && hcd->parent_bus && hcd->parent_bus->info->get_dev_path) {
+        id = hcd->parent_bus->info->get_dev_path(hcd);
+    }
+    if (id) {
+        int len = strlen(id)+strlen(dev->port->path)+2;
+        char *ret = g_malloc(len);
+        snprintf(ret, len, "%s/%s", id, dev->port->path);
+        return ret;
+    } else {
+        return g_strdup(dev->port->path);
+    }
 }
 
 static char *usb_get_fw_dev_path(DeviceState *qdev)
Signature · 1 line
1.7.1
#1 lore raw

Il 13/03/2012 13:34, Gerd Hoffmann ha scritto:

Quoted 4 lines

... to make vmstate id string truely unique with multiple host controllers, i.e. move from "1/usb-ptr" to "0000:00:01.3/1/usb-ptr" (usb tabled connected to piix3 uhci).

Quoted 8 lines

This is needed in case you have multiple USB busses in a virtual machine to make sure the section names are unique. Obviously this will break migration. I'm sitting on the patch for a while already, with the plan to sneak it in when we have a migration flag day anyway for the planned new & shiny migration format.

It doesn't look like this is going to happen anytime soon. I'd like to have this fixed in the 1.1 release. Suggestions how to go forward?

Add a property to the hcd devices, and set it to false for compatibility machines?

That is

- if (id) {
+ if (id && qdev_get_bit(hcd, "full-device-path")) {

BTW, your recently added serial.wakeup property uses a uint32... any chance you could change it to a bit so that -global isa-serial.wakeup=on works (nicer than =1 imho)?

Paolo