[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [PATCH v3 5/7] loader: add rom transaction API
From: |
Peter Maydell |
Subject: |
Re: [Qemu-arm] [PATCH v3 5/7] loader: add rom transaction API |
Date: |
Mon, 30 Jul 2018 18:57:13 +0100 |
On 25 July 2018 at 09:59, Stefan Hajnoczi <address@hidden> wrote:
> Image file loaders may add a series of roms. If an error occurs partway
> through loading there is no easy way to drop previously added roms.
>
> This patch adds a transaction mechanism that works like this:
>
> rom_transaction_begin();
> ...call rom_add_*()...
> rom_transaction_end(ok);
>
> If ok is false then roms added in this transaction are dropped.
>
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
> +void rom_transaction_end(bool commit)
> +{
> + Rom *rom;
> + Rom *tmp;
> +
> + QTAILQ_FOREACH_SAFE(rom, &roms, next, tmp) {
> + if (rom->committed) {
> + continue;
> + }
> + if (commit) {
> + rom->committed = true;
> + } else {
> + QTAILQ_REMOVE(&roms, rom, next);
> + g_free(rom->data);
> + g_free(rom->path);
> + g_free(rom->name);
> + g_free(rom->fw_dir);
> + g_free(rom->fw_file);
> + g_free(rom);
Is it worth having a rom_free() function so we can
share the "free all the pointers" code between this
and the error-exit codepath at the end of rom_add_file() ?
Either way
Reviewed-by: Peter Maydell <address@hidden>
thanks
-- PMM
- Re: [Qemu-arm] [PATCH v3 2/7] hw/arm: rename TYPE_ARMV7M to TYPE_ARM_M_PROFILE, (continued)
- [Qemu-arm] [PATCH v3 3/7] hw/arm: make bitbanded IO optional on ARM M Profile, Stefan Hajnoczi, 2018/07/25
- [Qemu-arm] [PATCH v3 4/7] target/arm: add "cortex-m0" CPU model, Stefan Hajnoczi, 2018/07/25
- [Qemu-arm] [PATCH v3 5/7] loader: add rom transaction API, Stefan Hajnoczi, 2018/07/25
- Re: [Qemu-arm] [PATCH v3 5/7] loader: add rom transaction API,
Peter Maydell <=
- [Qemu-arm] [PATCH v3 6/7] loader: Implement .hex file loader, Stefan Hajnoczi, 2018/07/25
- [Qemu-arm] [PATCH v3 7/7] Add QTest testcase for the Intel Hexadecimal, Stefan Hajnoczi, 2018/07/25
- Re: [Qemu-arm] [Qemu-devel] [PATCH v3 0/7] arm: add Cortex M0 CPU model and hex file loader, Stefan Hajnoczi, 2018/07/25