Re: [PATCH 2/2] qemu: adding domainGetHostname support for QEMU.

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

 



On Fri, Aug 17, 2018 at 23:25:19 -0300, Julio Faracco wrote:
> This commit add the support to use the function qemuAgentGetHostname() for
> obtain the domain hostname using QEMU-GA command.
> 
> Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c | 41 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index d4a2379e48..9a6614fbc2 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -19309,6 +19309,46 @@ qemuConnectGetCPUModelNames(virConnectPtr conn,
>      return virCPUGetModels(arch, models);
>  }
>  
> +static char *
> +qemuDomainGetHostname(virDomainPtr dom,
> +                      unsigned int flags)
> +{
> +    int rv = -1;
> +    virQEMUDriverPtr driver = dom->conn->privateData;
> +    virDomainObjPtr vm = NULL;
> +    qemuAgentPtr agent;
> +    char *hostname = NULL;
> +
> +    virCheckFlags(0, hostname);

Please return NULL directly.

> +
> +    if (!(vm = qemuDomObjFromDomain(dom)))
> +        return NULL;
> +
> +    if (virDomainGetTimeEnsureACL(dom->conn, vm->def) < 0)

ACL checking functions are per-API, so this should use virDomainGetHostnameACL.

I presume it's a copy-paste error.

This is the wrong ACL checking function. 

> +        goto cleanup;
> +
> +    if (qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_QUERY) < 0)
> +        goto cleanup;
> +
> +    if (virDomainObjCheckActive(vm) < 0)
> +        goto endjob;
> +
> +    if (!qemuDomainAgentAvailable(vm, true))
> +        goto endjob;
> +
> +    agent = qemuDomainObjEnterAgent(vm);
> +    rv = qemuAgentGetHostname(agent, &hostname);

rv is unused. Either make sure it's used somehow or use the
'ignore_value()' wrapper instead.

> +    qemuDomainObjExitAgent(vm, agent);
> +
> + endjob:
> +    qemuDomainObjEndAgentJob(vm);
> +
> + cleanup:
> +    virDomainObjEndAPI(&vm);
> +    return hostname;
> +}
> +
> +
>  static int
>  qemuDomainGetTime(virDomainPtr dom,
>                    long long *seconds,
> @@ -21787,6 +21827,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
>      .connectGetCPUModelNames = qemuConnectGetCPUModelNames, /* 1.1.3 */
>      .domainFSFreeze = qemuDomainFSFreeze, /* 1.2.5 */
>      .domainFSThaw = qemuDomainFSThaw, /* 1.2.5 */
> +    .domainGetHostname = qemuDomainGetHostname, /* 4.6.0 */
>      .domainGetTime = qemuDomainGetTime, /* 1.2.5 */
>      .domainSetTime = qemuDomainSetTime, /* 1.2.5 */
>      .nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
> -- 
> 2.17.1
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: PGP signature

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

  Powered by Linux