Skip to contentSkip to conversation

usb/vmstate: add parent dev path

RFC PATCH In review Gerd Hoffmann 2 participants 3 messages Aug 26, 2011

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).

Obvious problem with that is that it breaks migration from and to older versions, thats why it is RfC. I don't see any way to fix the issue without breaking though. So the question is how to deal with that best?

Given that we plan to break the migration anyway for 1.0 one option would be to just wait a bit and merge this as part of the new migration protocol patch series.

Comments?

---
 hw/usb-bus.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
hw/usb-bus.c +14 -1
index c0bbc7c..477d57f 100644
@@ -342,7 +342,20 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
 static char *usb_get_dev_path(DeviceState *qdev)
 {
     USBDevice *dev = DO_UPCAST(USBDevice, qdev, 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
Quoted 7 lines · Gerd Hoffmann

... 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).

Obvious problem with that is that it breaks migration from and to older versions, thats why it is RfC. I don't see any way to fix the issue without breaking though. So the question is how to deal with that best?

How about keeping the original naming *only* for devices on the first USB controller. Since it was impossible to start a QEMU process with 2 USB controllers, migration compatibility does not matter for the naming of devices on the 2nd, 3rd, 4th.... controller.

Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#2 lore raw
Quoted 5 lines · Daniel P. Berrange
Quoted 4 lines · Gerd Hoffmann

... 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 7 lines
Quoted 3 lines

Obvious problem with that is that it breaks migration from and to older versions, thats why it is RfC. I don't see any way to fix the issue without breaking though. So the question is how to deal with that best?

How about keeping the original naming *only* for devices on the first USB controller. Since it was impossible to start a QEMU process with 2 USB controllers,

Now it is, and we have a release (0.15) in the wild which supports it.

Quoted 2 lines

migration compatibility does not matter for the naming of devices on the 2nd, 3rd, 4th.... controller.

That would still break users which use usb 2.0 with qemu 0.15 today.

cheers,
Gerd