Re: [PATCH 02/11] Introduce a virDomainOpenConsole API

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

 



On Tue, Nov 02, 2010 at 05:49:06PM +0000, Daniel P. Berrange wrote:
> To enable virsh console (or equivalent) to be used remotely
> it is necessary to provide remote access to the /dev/pts/XXX
> pseudo-TTY associated with the console/serial/parallel device
> in the guest. The virStream API provide a bi-directional I/O
> stream capability that can be used for this purpose. This
> patch thus introduces a virDomainOpenConsole API that uses
> the stream APIs.
> 
> * src/libvirt.c, src/libvirt_public.syms,
>   include/libvirt/libvirt.h.in, src/driver.h: Define the
>   new virDomainOpenConsole API
> * src/esx/esx_driver.c, src/lxc/lxc_driver.c,
>   src/opennebula/one_driver.c, src/openvz/openvz_driver.c,
>   src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
>   src/remote/remote_driver.c, src/test/test_driver.c,
>   src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
>   src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Stub
>   API entry point
> ---
>  include/libvirt/libvirt.h.in |    6 ++++
>  src/driver.h                 |    6 ++++
>  src/esx/esx_driver.c         |    1 +
>  src/libvirt.c                |   53 ++++++++++++++++++++++++++++++++++++++++++
>  src/libvirt_public.syms      |    5 ++++
>  src/lxc/lxc_driver.c         |    1 +
>  src/opennebula/one_driver.c  |    1 +
>  src/openvz/openvz_driver.c   |    1 +
>  src/phyp/phyp_driver.c       |    1 +
>  src/qemu/qemu_driver.c       |    1 +
>  src/remote/remote_driver.c   |    1 +
>  src/test/test_driver.c       |    1 +
>  src/uml/uml_driver.c         |    1 +
>  src/vbox/vbox_tmpl.c         |    1 +
>  src/xen/xen_driver.c         |    1 +
>  src/xenapi/xenapi_driver.c   |    1 +
>  16 files changed, 82 insertions(+), 0 deletions(-)
> 
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 81db3a2..cc82e5c 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -2400,6 +2400,12 @@ int                     virNWFilterGetUUIDString (virNWFilterPtr nwfilter,
>  char *                  virNWFilterGetXMLDesc    (virNWFilterPtr nwfilter,
>                                                    int flags);
>  
> +
> +int virDomainOpenConsole(virDomainPtr dom,
> +                         const char *devname,
> +                         virStreamPtr st,
> +                         unsigned int flags);
> +

  Okay, looks fine !


> +/**
> + * virDomainOpenConsole:
> + * @domain: a domain object

  should be @dom: to get API extraction right

> + * @devname: the console, serial or parallel port device alias, or NULL
> + * @st: a stream to associate with the console
> + * @flags: unused, pass 0
> + *
> + * This opens the backend associated with a console, serial or
> + * parallel port device on a guest, if the backend is supported.
> + * If the @devname is omitted, then the first console or serial
> + * device is opened. The console is associated with the passed
> + * in @st stream, which should have been opened in non-blocking
> + * mode for bi-directional I/O.
> + *
> + * returns 0 if the console was opened, -1 on error
> + */
> +int virDomainOpenConsole(virDomainPtr dom,
> +                         const char *devname,
> +                         virStreamPtr st,
> +                         unsigned int flags)
> +{
> +    virConnectPtr conn;
> +    DEBUG("dom=%p devname=%s, st=%p flags=%u", dom, NULLSTR(devname), st, flags);
> +
> +    virResetLastError();
> +
> +    if (!VIR_IS_DOMAIN(dom)) {
> +        virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
> +        virDispatchError(NULL);
> +        return -1;
> +    }
> +
> +    conn = dom->conn;
> +    if (conn->flags & VIR_CONNECT_RO) {
> +        virLibDomainError(dom, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
> +        goto error;
> +    }
> +
> +    if (conn->driver->domainOpenConsole) {
> +        int ret;
> +        ret = conn->driver->domainOpenConsole(dom, devname, st, flags);
> +        if (ret < 0)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    virDispatchError(conn);
> +    return -1;
> +}
> diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
> index a8091b1..4ef4c5a 100644
> --- a/src/libvirt_public.syms
> +++ b/src/libvirt_public.syms
> @@ -413,4 +413,9 @@ LIBVIRT_0.8.5 {
>          virDomainSetVcpusFlags;
>  } LIBVIRT_0.8.2;
>  
> +LIBVIRT_0.8.6 {
> +    global:
> +        virDomainOpenConsole;
> +} LIBVIRT_0.8.5;
> +

  ACK, but just fix that minor comment first

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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