public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] device-assignment: Register as un-migratable
@ 2010-11-15 23:06 Alex Williamson
  2010-11-15 23:11 ` Jan Kiszka
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Williamson @ 2010-11-15 23:06 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, mst, jan.kiszka

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

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 v2: Use dummy vmsd instead of dummy save_state

 hw/device-assignment.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index bde231d..154bb1a 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1434,6 +1434,10 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
     dev->msix_table_page = NULL;
 }
 
+static const VMStateDescription vmstate_assigned_device = {
+    .name = "pci-assign"
+};
+
 static int assigned_initfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
@@ -1490,6 +1494,11 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
+
+    /* Register a vmsd so that we can mark it unmigratable. */
+    vmstate_register(&dev->dev.qdev, 0, &vmstate_assigned_device, dev);
+    register_device_unmigratable(&dev->dev.qdev, "pci-assign", dev);
+
     return 0;
 
 assigned_out:
@@ -1503,6 +1512,7 @@ static int assigned_exitfn(struct PCIDevice *pci_dev)
 {
     AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
 
+    vmstate_unregister(&dev->dev.qdev, &vmstate_assigned_device, dev);
     QLIST_REMOVE(dev, next);
     deassign_device(dev);
     free_assigned_device(dev);


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] device-assignment: Register as un-migratable
  2010-11-15 23:06 [PATCH v2] device-assignment: Register as un-migratable Alex Williamson
@ 2010-11-15 23:11 ` Jan Kiszka
  2010-11-15 23:24   ` Alex Williamson
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2010-11-15 23:11 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, mst

[-- Attachment #1: Type: text/plain, Size: 1786 bytes --]

Am 16.11.2010 00:06, Alex Williamson wrote:
> Use register_device_unmigratable() to declare ourselves as
> non-migratable.
> 
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
> 
>  v2: Use dummy vmsd instead of dummy save_state
> 
>  hw/device-assignment.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> index bde231d..154bb1a 100644
> --- a/hw/device-assignment.c
> +++ b/hw/device-assignment.c
> @@ -1434,6 +1434,10 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
>      dev->msix_table_page = NULL;
>  }
>  
> +static const VMStateDescription vmstate_assigned_device = {
> +    .name = "pci-assign"
> +};
> +
>  static int assigned_initfn(struct PCIDevice *pci_dev)
>  {
>      AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
> @@ -1490,6 +1494,11 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
>  
>      assigned_dev_load_option_rom(dev);
>      QLIST_INSERT_HEAD(&devs, dev, next);
> +
> +    /* Register a vmsd so that we can mark it unmigratable. */
> +    vmstate_register(&dev->dev.qdev, 0, &vmstate_assigned_device, dev);

Almost: You can register this vmstate description via assign_info
(.qdev.vmsd = ....).

Jan

> +    register_device_unmigratable(&dev->dev.qdev, "pci-assign", dev);
> +
>      return 0;
>  
>  assigned_out:
> @@ -1503,6 +1512,7 @@ static int assigned_exitfn(struct PCIDevice *pci_dev)
>  {
>      AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
>  
> +    vmstate_unregister(&dev->dev.qdev, &vmstate_assigned_device, dev);
>      QLIST_REMOVE(dev, next);
>      deassign_device(dev);
>      free_assigned_device(dev);
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] device-assignment: Register as un-migratable
  2010-11-15 23:11 ` Jan Kiszka
@ 2010-11-15 23:24   ` Alex Williamson
  2010-11-15 23:45     ` Jan Kiszka
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Williamson @ 2010-11-15 23:24 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: kvm, mst

On Tue, 2010-11-16 at 00:11 +0100, Jan Kiszka wrote:
> Am 16.11.2010 00:06, Alex Williamson wrote:
> > Use register_device_unmigratable() to declare ourselves as
> > non-migratable.
> > 
> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> > ---
> > 
> >  v2: Use dummy vmsd instead of dummy save_state
> > 
> >  hw/device-assignment.c |   10 ++++++++++
> >  1 files changed, 10 insertions(+), 0 deletions(-)
> > 
> > diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> > index bde231d..154bb1a 100644
> > --- a/hw/device-assignment.c
> > +++ b/hw/device-assignment.c
> > @@ -1434,6 +1434,10 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
> >      dev->msix_table_page = NULL;
> >  }
> >  
> > +static const VMStateDescription vmstate_assigned_device = {
> > +    .name = "pci-assign"
> > +};
> > +
> >  static int assigned_initfn(struct PCIDevice *pci_dev)
> >  {
> >      AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
> > @@ -1490,6 +1494,11 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
> >  
> >      assigned_dev_load_option_rom(dev);
> >      QLIST_INSERT_HEAD(&devs, dev, next);
> > +
> > +    /* Register a vmsd so that we can mark it unmigratable. */
> > +    vmstate_register(&dev->dev.qdev, 0, &vmstate_assigned_device, dev);
> 
> Almost: You can register this vmstate description via assign_info
> (.qdev.vmsd = ....).

Only if you have some other suggestion on where to call
register_device_unmigratable rather than init.  qdev_init looks like
this:

int qdev_init(DeviceState *dev)
{
    int rc;

    assert(dev->state == DEV_STATE_CREATED);
    rc = dev->info->init(dev, dev->info);
    if (rc < 0) {
        qdev_free(dev);
        return rc;
    }
    qemu_register_reset(qdev_reset, dev);
    if (dev->info->vmsd) {
        vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev,
                                       dev->instance_id_alias,
                                       dev->alias_required_for_version);
    }
    dev->state = DEV_STATE_INITIALIZED;
    return 0;
}

So the save state entry hasn't been inserted yet for me to attach the
no_migrate flag to from init :(

Alex


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] device-assignment: Register as un-migratable
  2010-11-15 23:24   ` Alex Williamson
@ 2010-11-15 23:45     ` Jan Kiszka
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2010-11-15 23:45 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, mst

[-- Attachment #1: Type: text/plain, Size: 2710 bytes --]

Am 16.11.2010 00:24, Alex Williamson wrote:
> On Tue, 2010-11-16 at 00:11 +0100, Jan Kiszka wrote:
>> Am 16.11.2010 00:06, Alex Williamson wrote:
>>> Use register_device_unmigratable() to declare ourselves as
>>> non-migratable.
>>>
>>> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
>>> ---
>>>
>>>  v2: Use dummy vmsd instead of dummy save_state
>>>
>>>  hw/device-assignment.c |   10 ++++++++++
>>>  1 files changed, 10 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
>>> index bde231d..154bb1a 100644
>>> --- a/hw/device-assignment.c
>>> +++ b/hw/device-assignment.c
>>> @@ -1434,6 +1434,10 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
>>>      dev->msix_table_page = NULL;
>>>  }
>>>  
>>> +static const VMStateDescription vmstate_assigned_device = {
>>> +    .name = "pci-assign"
>>> +};
>>> +
>>>  static int assigned_initfn(struct PCIDevice *pci_dev)
>>>  {
>>>      AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
>>> @@ -1490,6 +1494,11 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
>>>  
>>>      assigned_dev_load_option_rom(dev);
>>>      QLIST_INSERT_HEAD(&devs, dev, next);
>>> +
>>> +    /* Register a vmsd so that we can mark it unmigratable. */
>>> +    vmstate_register(&dev->dev.qdev, 0, &vmstate_assigned_device, dev);
>>
>> Almost: You can register this vmstate description via assign_info
>> (.qdev.vmsd = ....).
> 
> Only if you have some other suggestion on where to call
> register_device_unmigratable rather than init.  qdev_init looks like
> this:
> 
> int qdev_init(DeviceState *dev)
> {
>     int rc;
> 
>     assert(dev->state == DEV_STATE_CREATED);
>     rc = dev->info->init(dev, dev->info);
>     if (rc < 0) {
>         qdev_free(dev);
>         return rc;
>     }
>     qemu_register_reset(qdev_reset, dev);
>     if (dev->info->vmsd) {
>         vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev,
>                                        dev->instance_id_alias,
>                                        dev->alias_required_for_version);
>     }
>     dev->state = DEV_STATE_INITIALIZED;
>     return 0;
> }
> 
> So the save state entry hasn't been inserted yet for me to attach the
> no_migrate flag to from init :(

I see. I think that's a sign register_device_unmigratable should be
obsoleted as well by introducing no_migrate to vmstate (one day, vmsd ==
NULL could replace this flag).

BTW, ivshmem could resolve its need for dynamic no_migrate by
introducing two device types: one that is migratable (ivshmem-master)
and one that isn't (normal peer devices).

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-15 23:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-15 23:06 [PATCH v2] device-assignment: Register as un-migratable Alex Williamson
2010-11-15 23:11 ` Jan Kiszka
2010-11-15 23:24   ` Alex Williamson
2010-11-15 23:45     ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox