From: Laszlo Ersek <lersek@redhat.com>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>,
"Gabriel L. Somlo" <somlo@cmu.edu>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
kraxel@redhat.com, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] fw cfg files cross-version migration races
Date: Tue, 02 Jun 2015 09:04:23 +0200 [thread overview]
Message-ID: <556D5577.1020002@redhat.com> (raw)
In-Reply-To: <20150601203126.GK2120@HEDWIG.INI.CMU.EDU>
(resending, with Paolo's address corrected)
On 06/01/15 22:31, Gabriel L. Somlo wrote:
> On Mon, Jun 01, 2015 at 02:00:22PM -0400, Gabriel L. Somlo wrote:
>> On Mon, Jun 01, 2015 at 05:44:47PM +0200, Michael S. Tsirkin wrote:
>>>>> Shouldn't we migrate the fw cfg data that the source host generates
>>>>> originally, rather than trying to play games make sure the way it
>>>>> is re-generated on dest doesn't change.
>>>>
>>>> Right now, in hw/nvram/fw_cfg.c, we have:
>>>>
>>>> struct FWCfgState {
>>>> /*< private >*/
>>>> SysBusDevice parent_obj;
>>>> /*< public >*/
>>>>
>>>> FWCfgEntry entries[2][FW_CFG_MAX_ENTRY];
>>>> FWCfgFiles *files;
>>>> uint16_t cur_entry;
>>>> uint32_t cur_offset;
>>>> Notifier machine_ready;
>>>> };
>>>>
>>>> and, later:
>>>>
>>>> static const VMStateDescription vmstate_fw_cfg = {
>>>> .name = "fw_cfg",
>>>> .version_id = 2,
>>>> .minimum_version_id = 1,
>>>> .fields = (VMStateField[]) {
>>>> VMSTATE_UINT16(cur_entry, FWCfgState),
>>>> VMSTATE_UINT16_HACK(cur_offset, FWCfgState, is_version_1),
>>>> VMSTATE_UINT32_V(cur_offset, FWCfgState, 2),
>>>> VMSTATE_END_OF_LIST()
>>>> }
>>>> };
>>>>
>>>> Would this be as simple as adding a VMSTATE_ARRAY* for 'entries'
>>>> and something like a VMSTATE_VBUFFER_ALLOC_UINT32 for 'files', which
>>>> is dynamically allocated the first time a fwcfg "file" is inserted ?
>>>>
>>>> The one catch is that the value of the "files" pointer is itself a
>>>> fw_cfg entry (FW_CFG_FILE_DIR), so that would need to be "patched"
>>>> on the destination side...
>>>>
>>>> I do like the idea of simply migrating the full content of the fw_cfg
>>>> device though, seems like the safest solution.
>>>>
>>>> Thanks much,
>>>> --Gabriel
>>>
>>> OK but you need to do a bunch of work on load, e.g. some fw cfg
>>> entries trigger callbacks on access, etc.
>>
>> Oh, you mean here:
>>
>> typedef struct FWCfgEntry {
>> uint32_t len;
>> uint8_t *data;
>> void *callback_opaque;
>> FWCfgReadCallback read_callback;
>> } FWCfgEntry;
>>
>> ... I can't just assume that 'read_callback' is a valid function
>> pointer in the context of the destination host ?
>>
>> Ouch, that could get painful really really quickly :)
>
> Actually, it's much worse than that. A lot of the data items stored in
> fw_cfg are just pointers to somewhere in the qemu process address
> space, and I have no confidence that these pointers are guaranteed to
> make sense in the address space of the *destination* qemu process...
>
> I guess the only reason this isn't a problem is that nobody currently
> attempts to access fw_cfg after a migration ? :)
I thought once fw_cfg was rebased to an (anonymous?) RAMBlock footing,
migration became a non-issue. But, admittedly, I haven't thought much
about it.
Laszlo
next prev parent reply other threads:[~2015-06-02 7:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-01 14:10 [Qemu-devel] fw cfg files cross-version migration races Michael S. Tsirkin
2015-06-01 14:13 ` Daniel P. Berrange
2015-06-01 15:32 ` Gabriel L. Somlo
2015-06-01 15:44 ` Michael S. Tsirkin
2015-06-01 18:00 ` Gabriel L. Somlo
2015-06-01 20:31 ` Gabriel L. Somlo
2015-06-02 7:04 ` Laszlo Ersek [this message]
2015-06-02 7:11 ` Gerd Hoffmann
2015-06-03 8:31 ` Paolo Bonzini
2015-06-03 16:03 ` Michael S. Tsirkin
2015-06-05 16:05 ` Gabriel L. Somlo
2015-06-08 7:21 ` Gerd Hoffmann
2015-06-08 9:43 ` Michael S. Tsirkin
2015-06-08 11:19 ` Gerd Hoffmann
2015-06-08 11:44 ` Paolo Bonzini
2015-06-08 12:23 ` Gabriel L. Somlo
2015-06-08 12:28 ` Paolo Bonzini
2015-06-08 12:33 ` Gerd Hoffmann
2015-06-08 13:32 ` Gabriel L. Somlo
2015-06-08 15:53 ` Michael S. Tsirkin
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=556D5577.1020002@redhat.com \
--to=lersek@redhat.com \
--cc=gsomlo@gmail.com \
--cc=kraxel@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=somlo@cmu.edu \
/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.