Re: [PATCH v2 09/13] qemu: change qemuDomainTaint APIs to accept qemuDomainLogContextPtr

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

 




On 11/12/2015 12:19 PM, Daniel P. Berrange wrote:
> The qemuDomainTaint APIs currently expect to be passed a log file
> descriptor. Change them to instead use a qemuDomainLogContextPtr
> to hide the implementation details.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  src/qemu/qemu_domain.c  | 96 ++++++++++++++++++-------------------------------
>  src/qemu/qemu_domain.h  | 15 +++-----
>  src/qemu/qemu_driver.c  | 10 +++---
>  src/qemu/qemu_process.c |  4 +--
>  4 files changed, 47 insertions(+), 78 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index f3bb8d4..75f78fe 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -2107,9 +2107,10 @@ qemuDomainDefFormatLive(virQEMUDriverPtr driver,
>  void qemuDomainObjTaint(virQEMUDriverPtr driver,
>                          virDomainObjPtr obj,
>                          virDomainTaintFlags taint,
> -                        int logFD)
> +                        qemuDomainLogContextPtr logCtxt)
>  {
>      virErrorPtr orig_err = NULL;
> +    bool closeLog = false;
>  
>      if (virDomainObjTaint(obj, taint)) {
>          char uuidstr[VIR_UUID_STRING_BUFLEN];
> @@ -2125,11 +2126,23 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
>           * preserve original error, and clear any error that
>           * is raised */
>          orig_err = virSaveLastError();
> -        if (qemuDomainAppendLog(driver, obj, logFD,
> -                                "Domain id=%d is tainted: %s\n",
> -                                obj->def->id,
> -                                virDomainTaintTypeToString(taint)) < 0)
> +        if (logCtxt == NULL) {
> +            logCtxt = qemuDomainLogContextNew(driver, obj,
> +                                              QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH);
> +            if (!logCtxt) {
> +                VIR_WARN("Unable to open domainlog");

Coverity found - leaking orig_err


> +                return;
> +            }
> +            closeLog = true;
> +        }
> +
> +        if (qemuDomainLogContextWrite(logCtxt,
> +                                      "Domain id=%d is tainted: %s\n",
> +                                      obj->def->id,
> +                                      virDomainTaintTypeToString(taint)) < 0)
>              virResetLastError();
> +        if (closeLog)
> +            qemuDomainLogContextFree(logCtxt);
>          if (orig_err) {
>              virSetError(orig_err);
>              virFreeError(orig_err);
> @@ -2140,7 +2153,7 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
>  

[...]

ACK with the adjustment

John

--
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]