Skip to contentSkip to conversation

device-assignment: Register as un-migratable

PATCH Superseded Alex Williamson 3 participants 7 messages Nov 15, 2010 – Nov 16, 2010 KVM

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 device-assignment: Register as un-migratable

Use register_device_unmigratable() to declare ourselves as non-migratable.

---

 hw/device-assignment.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
hw/device-assignment.c +15 -0
index bde231d..cd93941 100644
@@ -1434,6 +1434,13 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
     dev->msix_table_page = NULL;
 }
 
+/* This should never get called, but we're required to create a save_state
+ * handler or else the no_migrate flag will never be checked. */
+static void assigned_save(QEMUFile* f, void *opaque)
+{
+    abort();
+}
+
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
@@ -1490,6 +1497,13 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
+
+    /* Assigned devices are not migratable, register a save
+     * state entry so that we can mark it unmigratable. */
+    register_savevm(&dev->dev.qdev, "pci-assign", 0, 0,
+                    assigned_save, NULL, dev);
+    register_device_unmigratable(&dev->dev.qdev, "pci-assign", dev);
+
     return 0;
 
 assigned_out:
@@ -1503,6 +1517,7 @@ static int assigned_exitfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
 
+    unregister_savevm(&dev->dev.qdev, "pci-assign", dev);
     QLIST_REMOVE(dev, next);
     deassign_device(dev);
     free_assigned_device(dev);
#1 lore raw
Quoted 28 lines · Alex Williamson

Use register_device_unmigratable() to declare ourselves as non-migratable.

---

 hw/device-assignment.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
hw/device-assignment.c +7 -0
index bde231d..cd93941 100644
@@ -1434,6 +1434,13 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
     dev->msix_table_page = NULL;
 }
 
+/* This should never get called, but we're required to create a save_state
+ * handler or else the no_migrate flag will never be checked. */
+static void assigned_save(QEMUFile* f, void *opaque)
+{
+    abort();
+}
+
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);

hw/device-assignment.c static int assigned_initfn(struct PCIDevice *pci_dev) · line 1506

Quoted 10 lines
hw/device-assignment.c +7 -0
@@ -1490,6 +1497,13 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
+
+    /* Assigned devices are not migratable, register a save
+     * state entry so that we can mark it unmigratable. */
+    register_savevm(&dev->dev.qdev, "pci-assign", 0, 0,
+                    assigned_save, NULL, dev);
+    register_device_unmigratable(&dev->dev.qdev, "pci-assign", dev);
+

Isn't this expressible via some VMStateDescription? If not, that should be changed first.

Jan

Quoted 12 lines
hw/device-assignment.c +1 -0
     return 0;
 
 assigned_out:
@@ -1503,6 +1517,7 @@ static int assigned_exitfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
 
+    unregister_savevm(&dev->dev.qdev, "pci-assign", dev);
     QLIST_REMOVE(dev, next);
     deassign_device(dev);
     free_assigned_device(dev);
#2 lore raw
Quoted 30 lines · Jan Kiszka
Quoted 29 lines · Alex Williamson

Use register_device_unmigratable() to declare ourselves as non-migratable.

---

 hw/device-assignment.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
hw/device-assignment.c +7 -0
index bde231d..cd93941 100644
@@ -1434,6 +1434,13 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
     dev->msix_table_page = NULL;
 }
 
+/* This should never get called, but we're required to create a save_state
+ * handler or else the no_migrate flag will never be checked. */
+static void assigned_save(QEMUFile* f, void *opaque)
+{
+    abort();
+}
+
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
@@ -1490,6 +1497,13 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
Quoted 12 lines

hw/device-assignment.c static int assigned_initfn(struct PCIDevice *pci_dev) · line 1506

Quoted 9 lines
hw/device-assignment.c +7 -0
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
+
+    /* Assigned devices are not migratable, register a save
+     * state entry so that we can mark it unmigratable. */
+    register_savevm(&dev->dev.qdev, "pci-assign", 0, 0,
+                    assigned_save, NULL, dev);
+    register_device_unmigratable(&dev->dev.qdev, "pci-assign", dev);
+

Isn't this expressible via some VMStateDescription? If not, that should be changed first.

Nope, save state handlers aren't allowed to fail. I tried to fix it:

http://lists.nongnu.org/archive/html/qemu-devel/2010-11/msg00417.html

(you can find more discussion in other branches of that subject) I've succumbed to not getting that series in, so now I'm just trying to use the code as it exists. Thanks,

Alex

#3 lore raw
Quoted 44 lines · Alex Williamson
Quoted 30 lines · Jan Kiszka
Quoted 29 lines · Alex Williamson

Use register_device_unmigratable() to declare ourselves as non-migratable.

---

 hw/device-assignment.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
hw/device-assignment.c +7 -0
index bde231d..cd93941 100644
@@ -1434,6 +1434,13 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
     dev->msix_table_page = NULL;
 }
 
+/* This should never get called, but we're required to create a save_state
+ * handler or else the no_migrate flag will never be checked. */
+static void assigned_save(QEMUFile* f, void *opaque)
+{
+    abort();
+}
+
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
@@ -1490,6 +1497,13 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
Quoted 12 lines

hw/device-assignment.c static int assigned_initfn(struct PCIDevice *pci_dev) · line 1506

Quoted 9 lines
hw/device-assignment.c +7 -0
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
+
+    /* Assigned devices are not migratable, register a save
+     * state entry so that we can mark it unmigratable. */
+    register_savevm(&dev->dev.qdev, "pci-assign", 0, 0,
+                    assigned_save, NULL, dev);
+    register_device_unmigratable(&dev->dev.qdev, "pci-assign", dev);
+

Isn't this expressible via some VMStateDescription? If not, that should be changed first.

Quoted 7 lines

Nope, save state handlers aren't allowed to fail. I tried to fix it:

http://lists.nongnu.org/archive/html/qemu-devel/2010-11/msg00417.html

(you can find more discussion in other branches of that subject) I've succumbed to not getting that series in, so now I'm just trying to use the code as it exists. Thanks,

Hmm, didn't get why you need that series for the purpose of no_migration declaration. My point is:

struct VMStateDescription {
    const char *name;
    int version_id;
    int minimum_version_id;
    int minimum_version_id_old;
    int no_migrate; /* or 'flags' */
    ...

so that you can specify an empty vmstate with that flag set, and you do not need to register/unregister things via to-be-deprecated service calls. Or am I missing some subtle detail?

Jan

#4 lore raw
Quoted 49 lines · Jan Kiszka
Quoted 48 lines · Alex Williamson
Quoted 30 lines · Jan Kiszka
Quoted 29 lines · Alex Williamson

Use register_device_unmigratable() to declare ourselves as non-migratable.

---

 hw/device-assignment.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
hw/device-assignment.c +7 -0
index bde231d..cd93941 100644
@@ -1434,6 +1434,13 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
     dev->msix_table_page = NULL;
 }
 
+/* This should never get called, but we're required to create a save_state
+ * handler or else the no_migrate flag will never be checked. */
+static void assigned_save(QEMUFile* f, void *opaque)
+{
+    abort();
+}
+
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
@@ -1490,6 +1497,13 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
Quoted 12 lines

hw/device-assignment.c static int assigned_initfn(struct PCIDevice *pci_dev) · line 1506

Quoted 9 lines
hw/device-assignment.c +7 -0
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
+
+    /* Assigned devices are not migratable, register a save
+     * state entry so that we can mark it unmigratable. */
+    register_savevm(&dev->dev.qdev, "pci-assign", 0, 0,
+                    assigned_save, NULL, dev);
+    register_device_unmigratable(&dev->dev.qdev, "pci-assign", dev);
+

Isn't this expressible via some VMStateDescription? If not, that should be changed first.

Nope, save state handlers aren't allowed to fail. I tried to fix it:

http://lists.nongnu.org/archive/html/qemu-devel/2010-11/msg00417.html

Quoted 7 lines
Quoted 3 lines

(you can find more discussion in other branches of that subject) I've succumbed to not getting that series in, so now I'm just trying to use the code as it exists. Thanks,

Hmm, didn't get why you need that series for the purpose of no_migration declaration.
My point is:

I was hoping you were going down the path I started, that we don't need to special case non-migratable devices if we just allow save to return an error.

Quoted 10 lines

My point is:

struct VMStateDescription {
    const char *name;
    int version_id;
    int minimum_version_id;
    int minimum_version_id_old;
    int no_migrate; /* or 'flags' */
    ...
Quoted 3 lines

so that you can specify an empty vmstate with that flag set, and you do not need to register/unregister things via to-be-deprecated service calls. Or am I missing some subtle detail?

We don't seem to be enforcing that new drivers should use vmsd vs the old style handling and there are some drivers that are currently too complicated for vmsd to handle, which means no_migrate has to be registered on the save state entry, not the vmsd. So I could create a dummy vmsd, then call register_device_unmigratable, to achieve roughly the same effect. Six of one, half dozen of the other... I can switch to a vmsd dummy save if it's preferred. Thanks,

Alex

#5 lore raw
Quoted 54 lines · Alex Williamson
Quoted 53 lines · Jan Kiszka
Quoted 51 lines · Alex Williamson
Quoted 30 lines · Jan Kiszka
Quoted 29 lines · Alex Williamson

Use register_device_unmigratable() to declare ourselves as non-migratable.

---

 hw/device-assignment.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
hw/device-assignment.c +7 -0
index bde231d..cd93941 100644
@@ -1434,6 +1434,13 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
     dev->msix_table_page = NULL;
 }
 
+/* This should never get called, but we're required to create a save_state
+ * handler or else the no_migrate flag will never be checked. */
+static void assigned_save(QEMUFile* f, void *opaque)
+{
+    abort();
+}
+
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
@@ -1490,6 +1497,13 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
Quoted 12 lines

hw/device-assignment.c static int assigned_initfn(struct PCIDevice *pci_dev) · line 1506

Quoted 9 lines
hw/device-assignment.c +7 -0
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
+
+    /* Assigned devices are not migratable, register a save
+     * state entry so that we can mark it unmigratable. */
+    register_savevm(&dev->dev.qdev, "pci-assign", 0, 0,
+                    assigned_save, NULL, dev);
+    register_device_unmigratable(&dev->dev.qdev, "pci-assign", dev);
+

Isn't this expressible via some VMStateDescription? If not, that should be changed first.

Nope, save state handlers aren't allowed to fail. I tried to fix it:

http://lists.nongnu.org/archive/html/qemu-devel/2010-11/msg00417.html

(you can find more discussion in other branches of that subject) I've succumbed to not getting that series in, so now I'm just trying to use the code as it exists. Thanks,

Quoted 7 lines
Quoted 3 lines

Hmm, didn't get why you need that series for the purpose of no_migration declaration.
My point is:

I was hoping you were going down the path I started, that we don't need to special case non-migratable devices if we just allow save to return an error.

Ah, of course. Still, vmstate is the way to go IMO.

Quoted 11 lines
Quoted 11 lines

My point is:

struct VMStateDescription {
    const char *name;
    int version_id;
    int minimum_version_id;
    int minimum_version_id_old;
    int no_migrate; /* or 'flags' */
    ...
Quoted 6 lines
Quoted 3 lines

so that you can specify an empty vmstate with that flag set, and you do not need to register/unregister things via to-be-deprecated service calls. Or am I missing some subtle detail?

We don't seem to be enforcing that new drivers should use vmsd vs the old style handling

Don't we? We are enforcing qdev but not vmstate? Sounds silly. I think new devices should all be expressible this way, no?

Quoted 6 lines

and there are some drivers that are currently too complicated for vmsd to handle, which means no_migrate has to be registered on the save state entry, not the vmsd. So I could create a dummy vmsd, then call register_device_unmigratable, to achieve roughly the same effect. Six of one, half dozen of the other... I can switch to a vmsd dummy save if it's preferred. Thanks,

IMHO, new designs should not use register_savevm anymore.

Jan

#6 lore raw
Quoted 59 lines · Jan Kiszka
Quoted 58 lines · Alex Williamson
Quoted 56 lines · Jan Kiszka
Quoted 44 lines · Alex Williamson
Quoted 30 lines · Jan Kiszka
Quoted 29 lines · Alex Williamson

Use register_device_unmigratable() to declare ourselves as non-migratable.

---

 hw/device-assignment.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
hw/device-assignment.c +7 -0
index bde231d..cd93941 100644
@@ -1434,6 +1434,13 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
     dev->msix_table_page = NULL;
 }
 
+/* This should never get called, but we're required to create a save_state
+ * handler or else the no_migrate flag will never be checked. */
+static void assigned_save(QEMUFile* f, void *opaque)
+{
+    abort();
+}
+
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
@@ -1490,6 +1497,13 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
Quoted 12 lines

hw/device-assignment.c static int assigned_initfn(struct PCIDevice *pci_dev) · line 1506

Quoted 9 lines
hw/device-assignment.c +7 -0
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
+
+    /* Assigned devices are not migratable, register a save
+     * state entry so that we can mark it unmigratable. */
+    register_savevm(&dev->dev.qdev, "pci-assign", 0, 0,
+                    assigned_save, NULL, dev);
+    register_device_unmigratable(&dev->dev.qdev, "pci-assign", dev);
+

Isn't this expressible via some VMStateDescription? If not, that should be changed first.

Quoted 7 lines

Nope, save state handlers aren't allowed to fail. I tried to fix it:

http://lists.nongnu.org/archive/html/qemu-devel/2010-11/msg00417.html

(you can find more discussion in other branches of that subject) I've succumbed to not getting that series in, so now I'm just trying to use the code as it exists. Thanks,

Hmm, didn't get why you need that series for the purpose of no_migration declaration.
My point is:

Quoted 5 lines
Quoted 3 lines

I was hoping you were going down the path I started, that we don't need to special case non-migratable devices if we just allow save to return an error.

Ah, of course. Still, vmstate is the way to go IMO.

Seconded.

If X can reasonably be done as a declaration (data), then it probably shouldn't be done as operation (code).

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

My point is:

struct VMStateDescription {
    const char *name;
    int version_id;
    int minimum_version_id;
    int minimum_version_id_old;
    int no_migrate; /* or 'flags' */
    ...

so that you can specify an empty vmstate with that flag set, and you do not need to register/unregister things via to-be-deprecated service calls. Or am I missing some subtle detail?

Quoted 5 lines
Quoted 2 lines

We don't seem to be enforcing that new drivers should use vmsd vs the old style handling

Don't we? We are enforcing qdev but not vmstate? Sounds silly. I think new devices should all be expressible this way, no?

We certainly should be enforcing that!

Quoted 10 lines
Quoted 6 lines

and there are some drivers that are currently too complicated for vmsd to handle, which means no_migrate has to be registered on the save state entry, not the vmsd. So I could create a dummy vmsd, then call register_device_unmigratable, to achieve roughly the same effect. Six of one, half dozen of the other... I can switch to a vmsd dummy save if it's preferred. Thanks,

IMHO, new designs should not use register_savevm anymore.

Jan