Re: [PATCH v2 3/9] virDomainGetState public API implementation

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

 



On Tue, May 10, 2011 at 03:39:05PM +0200, Jiri Denemark wrote:
> ---
> Notes:
>     Version 2:
>     - rebased
>     - unsigned int flags
> 
>  src/libvirt.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 51 insertions(+), 0 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index abacf85..571eb97 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -3172,6 +3172,57 @@ error:
>  }
>  
>  /**
> + * virDomainGetState:
> + * @domain: a domain object
> + * @state: returned state of the domain (one of virDomainState)
> + * @reason: returned reason which led to @state (one of virDomain*Reason
> + * corresponding to the current state); it is allowed to be NULL
> + * @flags: additional flags, 0 for now.
> + *
> + * Extract domain state. Each state can be accompanied with a reason (if known)
> + * which led to the state.
> + *
> + * Returns 0 in case of success and -1 in case of failure.
> + */
> +int
> +virDomainGetState(virDomainPtr domain,
> +                  int *state,
> +                  int *reason,
> +                  unsigned int flags)
> +{
> +    virConnectPtr conn;
> +
> +    VIR_DOMAIN_DEBUG(domain, "state=%p, reason=%p", state, reason);
> +
> +    virResetLastError();
> +
> +    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
> +        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
> +        virDispatchError(NULL);
> +        return -1;
> +    }
> +    if (!state) {
> +        virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
> +        goto error;
> +    }
> +
> +    conn = domain->conn;
> +    if (conn->driver->domainGetState) {
> +        int ret;
> +        ret = conn->driver->domainGetState(domain, state, reason, flags);
> +        if (ret < 0)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    virDispatchError(domain->conn);
> +    return -1;
> +}

ACK

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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