Re: [PATCH 1/2] driver config: Introduce virFirmware object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/18/2016 10:38 AM, Jim Fehlig wrote:
> The virQEMUDriverConfig object contains lists of
> loader:nvram pairs to advertise firmwares supported by
> by the driver, and qemu_conf.c contains code to populate
> the lists, all of which is useful for other drivers too.
>
> To avoid code duplication, introduce a virFirmware object
> to encapsulate firmware details and switch the qemu driver
> to use it.
>
> Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
> ---
>  po/POTFILES.in               |   1 +
>  src/Makefile.am              |   1 +
>  src/libvirt_private.syms     |   6 ++
>  src/qemu/qemu_capabilities.c |  22 +++----
>  src/qemu/qemu_capabilities.h |   5 +-
>  src/qemu/qemu_conf.c         | 127 ++++++----------------------------------
>  src/qemu/qemu_conf.h         |   7 +--
>  src/qemu/qemu_driver.c       |   2 +-
>  src/qemu/qemu_process.c      |   6 +-
>  src/util/virfirmware.c       | 135 +++++++++++++++++++++++++++++++++++++++++++
>  src/util/virfirmware.h       |  51 ++++++++++++++++
>  tests/domaincapstest.c       |   3 +-
>  12 files changed, 235 insertions(+), 131 deletions(-)
[...]
> diff --git a/src/util/virfirmware.c b/src/util/virfirmware.c
> new file mode 100644
> index 0000000..e0eb6b9
> --- /dev/null
> +++ b/src/util/virfirmware.c
> @@ -0,0 +1,135 @@
> +/*
> + * virfirmware.c: Definition of firmware object and supporting functions
> + *
> + * Copyright (C) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library.  If not, see
> + * <http://www.gnu.org/licenses/>.
> + *
> + * Author: Jim Fehlig <jfehlig@xxxxxxxx>
> + */
> +
> +#include <config.h>
> +
> +#include "viralloc.h"
> +#include "virerror.h"
> +#include "virfirmware.h"
> +#include "virlog.h"
> +#include "virstring.h"
> +
> +#define VIR_FROM_THIS VIR_FROM_NONE
> +
> +VIR_LOG_INIT("util.firmware");
> +
> +
> +static void
> +virFirmwareFree(virFirmwarePtr firmware)
> +{
> +    if (!firmware)
> +        return;
> +
> +    VIR_FREE(firmware->name);
> +    VIR_FREE(firmware->nvram);
> +    VIR_FREE(firmware);
> +}
> +
> +
> +void
> +virFirmwareFreeList(virFirmwarePtr *firmwares, size_t nfirmwares)
> +{
> +    size_t i;
> +
> +    for (i = 0; i < nfirmwares; i++)
> +        virFirmwareFree(firmwares[i]);
> +}

'firmwares' should be freed after the items are freed. I've squashed the below
diff into my branch.

Regards,
Jim


diff --git a/src/util/virfirmware.c b/src/util/virfirmware.c
index e0eb6b9..6b20c06 100644
--- a/src/util/virfirmware.c
+++ b/src/util/virfirmware.c
@@ -52,6 +52,8 @@ virFirmwareFreeList(virFirmwarePtr *firmwares, size_t nfirmwares)
 
     for (i = 0; i < nfirmwares; i++)
         virFirmwareFree(firmwares[i]);
+
+    VIR_FREE(firmwares);
 }
 
 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]