Re: [PATCH 3/7] add virAgentCommand()

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

 



On 08/15/2012 03:36 AM, MATSUDA Daiki wrote:
> diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
> index 013ed5a..60b83ef 100644
> --- a/include/libvirt/libvirt-qemu.h
> +++ b/include/libvirt/libvirt-qemu.h
> @@ -50,6 +50,9 @@ typedef enum {
>      VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT = 0,
>  } virDomainQemuAgentCommandTimeoutValues;
>  
> +char *virAgentCommand(virDomainPtr domain, const char *cmd,
> +                      int timeout, unsigned int flags);
> +

I wondered why this is type 'char *', when we can use 'int' as usual and
have '**result' (same as monitor command does).

> diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c
> index 78480bb..49dfc20 100644
> --- a/src/libvirt-qemu.c
> +++ b/src/libvirt-qemu.c
> @@ -185,3 +185,54 @@ error:
>      virDispatchError(conn);
>      return NULL;
>  }
> +
> +/**
> + * virAgentCommand:
> + * @domain: a domain object
> + * @cmd: the guest agent command string
> + * @timeout: timeout seconds
> + * @flags: execution flags
> + *
> + * Execute an arbitrary Guest Agent command.
> + *
> + * Issue @cmd to the guest agent running in @domain.
> + * If @result is NULL, then don't wait for a result (and @timeout

And then I noticed that there is no @result here, so maybe you wanted to
make it that way and didn't change something?

> + * must be 0).  Otherwise, wait for @timeout seconds for a
> + * @timeout must be -2, -1, 0 or positive.
> + * VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK(-2): meaning to block forever waiting for
> + * a result.
> + * VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT(-1): use default timeout value.
> + * VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT(0): does not wait.
> + * positive value: wait for @timeout seconds
> + *
> + * Returns strings if success, NULL in failure.
> + */
> +char *
> +virAgentCommand(virDomainPtr domain,
> +                const char *cmd,
> +                int timeout,
> +                unsigned int flags)
> +{
> +    virConnectPtr conn;
> +
> +    VIR_DEBUG("domain=%p, cmd=%s, timeout=%d, flags=%x",
> +              domain, cmd, timeout, flags);
> +
> +    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
> +        virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
> +        virDispatchError(NULL);
> +        return NULL;
> +    }
> +
> +    conn = domain->conn;
> +
> +    if (conn->driver->qemuAgentCommand) {
> +        return conn->driver->qemuAgentCommand(domain, cmd, timeout, flags);

Shouldn't this be allowed only for read-only connections?

> +    }
> +
> +    virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +    /* Copy to connection error object for back compatability */

s/compatability/compatibility/

> +    virDispatchError(domain->conn);

You have 'domain->conn' in 'conn' already.

Martin

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