Re: [libvirt PATCH 4/5] qemu: implement qemuDomainGraphicsReload

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

 



On 2/29/24 16:23, Ján Tomko wrote:
> From: Zheng Yan <yanzheng759@xxxxxxxxxx>
> 
> The 'display-reload' QMP command had been introduced from QEMU 6.0.0:
> 
> https://gitlab.com/qemu-project/qemu/-/commit/9cc07651655ee86eca41059f5ead8c4e5607c734
> 
> Currently it only supports reloading TLS certificates for VNC.
> 
> https://issues.redhat.com/browse/RHEL-16333
> 
> Signed-off-by: Zheng Yan <yanzheng759@xxxxxxxxxx>
> Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c       | 54 ++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_monitor.c      | 10 +++++++
>  src/qemu/qemu_monitor.h      |  5 ++++
>  src/qemu/qemu_monitor_json.c | 23 +++++++++++++++
>  src/qemu/qemu_monitor_json.h |  4 +++
>  5 files changed, 96 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 448e6b1591..22e9f743cb 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -19932,6 +19932,59 @@ qemuDomainFDAssociate(virDomainPtr domain,
>      return ret;
>  }
>  
> +static int
> +qemuDomainGraphicsReload(virDomainPtr domain,
> +                         unsigned int type,
> +                         unsigned int flags)
> +{
> +    int ret = -1;
> +    virDomainObj *vm = NULL;
> +    qemuDomainObjPrivate *priv;
> +
> +    if (!(vm = qemuDomainObjFromDomain(domain)))
> +        return -1;
> +
> +    if (virDomainGraphicsReloadEnsureACL(domain->conn, vm->def))
> +        goto cleanup;
> +
> +    virCheckFlagsGoto(0, cleanup);

Checking flags is way faster than looking up domain. Please swap these
two. That's how we do that in majority of other APIs (if not all).

> +
> +    if (type == VIR_DOMAIN_GRAPHICS_RELOAD_TYPE_ANY) {
> +        size_t i;
> +        for (i = 0; i < vm->def->ngraphics; i++) {

I'd put an empty line before this ^^^ for() so that declaration and code
blocks are visually separated.

> +            if (vm->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC)
> +                break;
> +        }
> +        if (i == vm->def->ngraphics) {
> +            ret = 0;
> +            goto cleanup;
> +        }
> +    }
> +
> +    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
> +        goto cleanup;
> +
> +     if (!virDomainObjIsActive(vm)) {

Alignment.

> +        virReportError(VIR_ERR_OPERATION_INVALID,
> +                       "%s", _("domain is not running"));
> +        goto endjob;
> +    }
> +
> +    priv = vm->privateData;
> +
> +    qemuDomainObjEnterMonitor(vm);
> +
> +    ret = qemuMonitorDisplayReload(priv->mon, "vnc", true);
> +
> +    qemuDomainObjExitMonitor(vm);
> +
> + endjob:
> +    virDomainObjEndJob(vm);
> +
> + cleanup:
> +    virDomainObjEndAPI(&vm);
> +    return ret;
> +}

Michal
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




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

  Powered by Linux