[libvirt] [libvirt-glib 2/3] Add LibvirtGConfigDomainChardevSourceSpiceVmc

Christophe Fergeau cfergeau at redhat.com
Mon Mar 12 16:56:44 UTC 2012


Ping for this patch and for 3/3 ?

Christophe

On Tue, Mar 06, 2012 at 05:38:33PM +0100, Christophe Fergeau wrote:
> This is needed to be able to add the SPICE agent channels
> ---
>  libvirt-gconfig/Makefile.am                        |    2 +
>  ...ibvirt-gconfig-domain-chardev-source-spicevmc.c |   80 ++++++++++++++++++++
>  ...ibvirt-gconfig-domain-chardev-source-spicevmc.h |   70 +++++++++++++++++
>  libvirt-gconfig/libvirt-gconfig.h                  |    1 +
>  libvirt-gconfig/libvirt-gconfig.sym                |    4 +
>  libvirt-gconfig/tests/test-domain-create.c         |   14 ++++
>  6 files changed, 171 insertions(+), 0 deletions(-)
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h
> 
> diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
> index 03a5507..d9e87b5 100644
> --- a/libvirt-gconfig/Makefile.am
> +++ b/libvirt-gconfig/Makefile.am
> @@ -17,6 +17,7 @@ GCONFIG_HEADER_FILES = \
>  			libvirt-gconfig-domain-chardev.h \
>  			libvirt-gconfig-domain-chardev-source.h \
>  			libvirt-gconfig-domain-chardev-source-pty.h \
> +			libvirt-gconfig-domain-chardev-source-spicevmc.h \
>  			libvirt-gconfig-domain-clock.h \
>  			libvirt-gconfig-domain-console.h \
>  			libvirt-gconfig-domain-device.h \
> @@ -68,6 +69,7 @@ GCONFIG_SOURCE_FILES = \
>  			libvirt-gconfig-domain-chardev.c \
>  			libvirt-gconfig-domain-chardev-source.c \
>  			libvirt-gconfig-domain-chardev-source-pty.c \
> +			libvirt-gconfig-domain-chardev-source-spicevmc.c \
>  			libvirt-gconfig-domain-clock.c \
>  			libvirt-gconfig-domain-console.c \
>  			libvirt-gconfig-domain-device.c \
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c
> new file mode 100644
> index 0000000..22eabf5
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c
> @@ -0,0 +1,80 @@
> +/*
> + * libvirt-gconfig-domain-chardev-source-spicevmc.c: libvirt domain chardev spicevmc configuration
> + *
> + * Copyright (C) 2012 Red Hat, Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
> + *
> + * Author: Christophe Fergeau <cfergeau at redhat.com>
> + */
> +
> +#include <config.h>
> +
> +#include "libvirt-gconfig/libvirt-gconfig.h"
> +#include "libvirt-gconfig/libvirt-gconfig-private.h"
> +
> +#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_GET_PRIVATE(obj)                         \
> +        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC, GVirConfigDomainChardevSourceSpiceVmcPrivate))
> +
> +struct _GVirConfigDomainChardevSourceSpiceVmcPrivate
> +{
> +    gboolean unused;
> +};
> +
> +G_DEFINE_TYPE(GVirConfigDomainChardevSourceSpiceVmc, gvir_config_domain_chardev_source_spicevmc, GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE);
> +
> +
> +static void gvir_config_domain_chardev_source_spicevmc_class_init(GVirConfigDomainChardevSourceSpiceVmcClass *klass)
> +{
> +    g_type_class_add_private(klass, sizeof(GVirConfigDomainChardevSourceSpiceVmcPrivate));
> +}
> +
> +
> +static void gvir_config_domain_chardev_source_spicevmc_init(GVirConfigDomainChardevSourceSpiceVmc *source)
> +{
> +    g_debug("Init GVirConfigDomainChardevSourceSpiceVmc=%p", source);
> +
> +    source->priv = GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_GET_PRIVATE(source);
> +}
> +
> +
> +GVirConfigDomainChardevSourceSpiceVmc *gvir_config_domain_chardev_source_spicevmc_new(void)
> +{
> +    GVirConfigObject *object;
> +
> +    /* the name of the root node is just a placeholder, it will be
> +     * overwritten when the GVirConfigDomainChardevSourceSpiceVmc is attached to a
> +     * GVirConfigDomainChardevSourceSpiceVmc
> +     */
> +    object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC, "dummy", NULL);
> +    gvir_config_object_set_attribute(object, "type", "spicevmc", NULL);
> +    return GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC(object);
> +}
> +
> +
> +GVirConfigDomainChardevSourceSpiceVmc *gvir_config_domain_chardev_source_spicevmc_new_from_xml(const gchar *xml,
> +                                                                              GError **error)
> +{
> +    GVirConfigObject *object;
> +
> +    /* the name of the root node is just a placeholder, it will be
> +     * overwritten when the GVirConfigDomainChardevSourceSpiceVmc is attached to a
> +     * GVirConfigDomainChardevSourceSpiceVmc
> +     */
> +    object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC,
> +                                             "dummy", NULL, xml, error);
> +    gvir_config_object_set_attribute(object, "type", "spicevmc", NULL);
> +    return GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC(object);
> +}
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h
> new file mode 100644
> index 0000000..6b2ab20
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h
> @@ -0,0 +1,70 @@
> +/*
> + * libvirt-gconfig-domain-chardev-source-spicevmc.h: libvirt domain chardev spicevmc configuration
> + *
> + * Copyright (C) 2012 Red Hat, Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
> + *
> + * Author: Christophe Fergeau <cfergeau at redhat.com>
> + */
> +
> +#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD)
> +#error "Only <libvirt-gconfig/libvirt-gconfig.h> can be included directly."
> +#endif
> +
> +#ifndef __LIBVIRT_GCONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_H__
> +#define __LIBVIRT_GCONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_H__
> +
> +G_BEGIN_DECLS
> +
> +#define GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC            (gvir_config_domain_chardev_source_spicevmc_get_type ())
> +#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC, GVirConfigDomainChardevSourceSpiceVmc))
> +#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC, GVirConfigDomainChardevSourceSpiceVmcClass))
> +#define GVIR_CONFIG_IS_DOMAIN_CHARDEV_SOURCE_SPICE_VMC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC))
> +#define GVIR_CONFIG_IS_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC))
> +#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC, GVirConfigDomainChardevSourceSpiceVmcClass))
> +
> +typedef struct _GVirConfigDomainChardevSourceSpiceVmc GVirConfigDomainChardevSourceSpiceVmc;
> +typedef struct _GVirConfigDomainChardevSourceSpiceVmcPrivate GVirConfigDomainChardevSourceSpiceVmcPrivate;
> +typedef struct _GVirConfigDomainChardevSourceSpiceVmcClass GVirConfigDomainChardevSourceSpiceVmcClass;
> +
> +struct _GVirConfigDomainChardevSourceSpiceVmc
> +{
> +    GVirConfigDomainChardevSource parent;
> +
> +    GVirConfigDomainChardevSourceSpiceVmcPrivate *priv;
> +
> +    /* Do not add fields to this struct */
> +};
> +
> +struct _GVirConfigDomainChardevSourceSpiceVmcClass
> +{
> +    GVirConfigDomainChardevSourceClass parent_class;
> +
> +    gpointer padding[20];
> +};
> +
> +
> +GType gvir_config_domain_chardev_source_spicevmc_get_type(void);
> +
> +GVirConfigDomainChardevSourceSpiceVmc *gvir_config_domain_chardev_source_spicevmc_new(void);
> +GVirConfigDomainChardevSourceSpiceVmc *gvir_config_domain_chardev_source_spicevmc_new_from_xml(const gchar *xml,
> +                                                                              GError **error);
> +void gvir_config_domain_source_spicevmc_set_path(GVirConfigDomainChardevSourceSpiceVmc *spicevmc,
> +                                                 const char *path);
> +
> +G_END_DECLS
> +
> +#endif /* __LIBVIRT_GCONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_H__ */
> diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
> index cb28e23..b1eede2 100644
> --- a/libvirt-gconfig/libvirt-gconfig.h
> +++ b/libvirt-gconfig/libvirt-gconfig.h
> @@ -33,6 +33,7 @@
>  #include <libvirt-gconfig/libvirt-gconfig-domain-chardev.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-chardev-source.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.h>
> +#include <libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-channel.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-clock.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-console.h>
> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
> index 1329c17..ffde0bc 100644
> --- a/libvirt-gconfig/libvirt-gconfig.sym
> +++ b/libvirt-gconfig/libvirt-gconfig.sym
> @@ -51,6 +51,10 @@ LIBVIRT_GCONFIG_0.0.4 {
>  	gvir_config_domain_chardev_source_pty_new_from_xml;
>  	gvir_config_domain_source_pty_set_path;
>  
> +	gvir_config_domain_chardev_source_spicevmc_get_type;
> +	gvir_config_domain_chardev_source_spicevmc_new;
> +	gvir_config_domain_chardev_source_spicevmc_new_from_xml;
> +
>  	gvir_config_domain_clock_get_type;
>  	gvir_config_domain_clock_offset_get_type;
>  	gvir_config_domain_clock_new;
> diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c
> index a92413d..b24d133 100644
> --- a/libvirt-gconfig/tests/test-domain-create.c
> +++ b/libvirt-gconfig/tests/test-domain-create.c
> @@ -181,6 +181,20 @@ int main(int argc, char **argv)
>      g_object_unref(G_OBJECT(pty));
>      devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(console));
>  
> +    /* spice agent channel */
> +    GVirConfigDomainChannel *channel;
> +    GVirConfigDomainChardevSourceSpiceVmc *spicevmc;
> +
> +    channel = gvir_config_domain_channel_new();
> +    gvir_config_domain_channel_set_target_type(channel,
> +                                               GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_VIRTIO);
> +    spicevmc = gvir_config_domain_chardev_source_spicevmc_new();
> +    gvir_config_domain_chardev_set_source(GVIR_CONFIG_DOMAIN_CHARDEV(channel),
> +                                          GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE(spicevmc));
> +    g_object_unref(G_OBJECT(spicevmc));
> +    devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(channel));
> +
> +
>      gvir_config_domain_set_devices(domain, devices);
>      g_list_foreach(devices, (GFunc)g_object_unref, NULL);
>      g_list_free(devices);
> -- 
> 1.7.7.6
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120312/10df80e9/attachment-0001.sig>


More information about the libvir-list mailing list