From: Alex Williamson <alex.williamson@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: linux-pci@vger.kernel.org, kvm@vger.kernel.org,
jan.kiszka@siemens.com, jbarnes@virtuousgeek.org
Subject: Re: [PATCH 2/2] KVM: Use pci_store/load_saved_state() around VM device usage
Date: Wed, 20 Apr 2011 09:13:16 -0600 [thread overview]
Message-ID: <1303312396.3110.142.camel@x201> (raw)
In-Reply-To: <4DAE8915.8020804@redhat.com>
On Wed, 2011-04-20 at 10:19 +0300, Avi Kivity wrote:
> On 04/18/2011 10:43 PM, Alex Williamson wrote:
> > On Sun, 2011-04-17 at 12:25 +0300, Avi Kivity wrote:
> > > On 04/15/2011 10:54 PM, Alex Williamson wrote:
> > > > Store the device saved state so that we can reload the device back
> > > > to the original state when it's unassigned. This has the benefit
> > > > that the state survives across pci_reset_function() calls via
> > > > the PCI sysfs reset interface while the VM is using the device.
> > >
> > > > @@ -516,7 +518,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
> > > >
> > > > pci_reset_function(dev);
> > > > pci_save_state(dev);
> > > > -
> > > > + match->pci_saved_state = pci_store_saved_state(dev);
> > > > match->assigned_dev_id = assigned_dev->assigned_dev_id;
> > >
> > > Error check?
> > >
> > > It might be better to give up the opacity of the data structure and make
> > > pci_saved_state the full struct, not a pointer.
> >
> > pci_store_saved_state() returns NULL on error, which is correctly
> > handled if we pass NULL to pci_load_saved_state() or a pointer to NULL
> > to pci_load_and_free_saved_state().
>
> But we silently swallow an error, this isn't good.
>
> > This is also why I changed the
> > __pci_reset_function() back to a normal pci_reset_function(), so we're
> > never left with an uninitialized device like we are now.
> >
> > We could be more verbose or return an error here, but we've gone for a
> > long time not even doing this save/restore across VM usage, so I don't
> > think it's worthy of preventing the device attachment if it fails.
>
> At least a log?
Ok, I'm not sure what corrective action a user would take or what they
should expect not to work, but I guess a KERN_DEBUG printk is
reasonable.
> Note avoiding the pointer would have removed the problem altogether.
Returning a struct on store? We lose any kind of opacity that way since
the caller needs to know about the struct then. I thought the pointer
makes it clear the caller shouldn't be touching the contents, but if you
think it's a better way to go, I can try it. Thanks,
Alex
next prev parent reply other threads:[~2011-04-20 15:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-15 19:54 [PATCH 0/2] Store and load PCI device saved state across function resets Alex Williamson
2011-04-15 19:54 ` [PATCH 1/2] PCI: Add interfaces to store and load the device saved state Alex Williamson
2011-04-17 9:23 ` Avi Kivity
2011-04-18 19:44 ` Alex Williamson
2011-04-15 19:54 ` [PATCH 2/2] KVM: Use pci_store/load_saved_state() around VM device usage Alex Williamson
2011-04-15 20:03 ` Jan Kiszka
2011-04-15 20:13 ` Alex Williamson
2011-04-15 20:28 ` Jan Kiszka
2011-04-17 9:25 ` Avi Kivity
2011-04-18 19:43 ` Alex Williamson
2011-04-20 7:19 ` Avi Kivity
2011-04-20 15:13 ` Alex Williamson [this message]
2011-04-20 15:27 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1303312396.3110.142.camel@x201 \
--to=alex.williamson@redhat.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=jbarnes@virtuousgeek.org \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.