Re: [PATCHv4 3/3] qemu: Implement virDomain{Get,Set}Time

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

 



On 05/07/2014 10:19 AM, Michal Privoznik wrote:
> One caveat though, qemu-ga is expecting time and returning time
> in nanoseconds. With all the buffering and propagation delay, the
> time is already wrong once it gets to the qemu-ga, but there's
> nothing we can do about it.
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/qemu/qemu_agent.c  |  99 ++++++++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_agent.h  |   8 ++++
>  src/qemu/qemu_driver.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 216 insertions(+)

Jan

> 
> diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
> index 4082331..80a820e 100644
> --- a/src/qemu/qemu_agent.c
> +++ b/src/qemu/qemu_agent.c
> @@ -1646,3 +1646,102 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus,
>  
>      return 0;
>  }
> +
> +
> +int
> +qemuAgentGetTime(qemuAgentPtr mon,
> +                 long long *seconds,
> +                 unsigned int *nseconds)
> +{
> +    int ret = -1;
> +    unsigned long long json_time;
> +    virJSONValuePtr cmd;
> +    virJSONValuePtr reply = NULL;
> +
> +    cmd = qemuAgentMakeCommand("guest-get-time",
> +                               NULL);
> +    if (!cmd)
> +        return ret;
> +
> +    if (qemuAgentCommand(mon, cmd, &reply, true,
> +                         VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
> +        goto cleanup;
> +

> +    if (!reply || qemuAgentCheckError(cmd, reply) < 0)
> +        goto cleanup;
> +

Here too.

> +    if (virJSONValueObjectGetNumberUlong(reply, "return", &json_time) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("malformed return value"));
> +        goto cleanup;
> +    }
> +

...

> +
> +
> +/**
> + * qemuAgentSetTime:
> + * @setTime: time to set
> + * @sync: let guest agent to read domain's RTC (@setTime is ignored)
> + */
> +int
> +qemuAgentSetTime(qemuAgentPtr mon,
> +                long long seconds,
> +                unsigned int nseconds,
> +                bool sync)
> +{
> +    int ret = -1;
> +    virJSONValuePtr cmd;
> +    virJSONValuePtr reply = NULL;
> +

...

> +
> +    if (!cmd)
> +        return ret;
> +
> +    if (qemuAgentCommand(mon, cmd, &reply, true,
> +                         VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
> +        goto cleanup;
> +

> +    if (!reply || qemuAgentCheckError(cmd, reply) < 0)
> +        goto cleanup;

This should be checked by qemuAgentCommand already.

> +
> +    ret = 0;
> + cleanup:
> +    virJSONValueFree(cmd);
> +    virJSONValueFree(reply);
> +    return ret;
> +}

> @@ -16717,6 +16824,8 @@ static virDriver qemuDriver = {
>      .domainMigrateFinish3Params = qemuDomainMigrateFinish3Params, /* 1.1.0 */
>      .domainMigrateConfirm3Params = qemuDomainMigrateConfirm3Params, /* 1.1.0 */
>      .connectGetCPUModelNames = qemuConnectGetCPUModelNames, /* 1.1.3 */
> +    .domainGetTime = qemuDomainGetTime, /* 1.2.4 */
> +    .domainSetTime = qemuDomainSetTime, /* 1.2.4 */

1.2.5

>  };
>  
>  
> 

Attachment: signature.asc
Description: OpenPGP digital 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]