[libvirt] [libvirt-glib 1/3] Fix GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_GUESTFWD name

It was called GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_GUESTFWD, which in turn confused glib-mkenums, leading to a wrong value being generated in the XML when trying to use this enumeration. --- libvirt-gconfig/libvirt-gconfig-domain-channel.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-channel.h b/libvirt-gconfig/libvirt-gconfig-domain-channel.h index a8a3020..5141d11 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-channel.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-channel.h @@ -57,7 +57,7 @@ struct _GVirConfigDomainChannelClass }; typedef enum { - GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_GUESTFWD, + GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_GUESTFWD, GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_VIRTIO, } GVirConfigDomainChannelTargetType; -- 1.7.7.6

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

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@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@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@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Mon, Mar 12, 2012 at 5:56 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
Ping for this patch and for 3/3 ?
./test-domain-create gives: <channel type="spicevmc"> <target type="channel-target-virtio"/> </channel> Where we expect this: <channel type='spicevmc'> <target type='virtio' name='com.redhat.spice.0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel>
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@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@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@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Marc-André Lureau

Hey, On Tue, Mar 13, 2012 at 01:22:09AM +0100, Marc-André Lureau wrote:
On Mon, Mar 12, 2012 at 5:56 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
Ping for this patch and for 3/3 ?
./test-domain-create gives:
<channel type="spicevmc"> <target type="channel-target-virtio"/> </channel>
Where we expect this:
<channel type='spicevmc'> <target type='virtio' name='com.redhat.spice.0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel>
The "address" element is optional, see http://libvirt.org/formatdomain.html#elementCharChannel "The optional address element can tie the channel to a particular type='virtio-serial' controller." It seems libvirt will still do the right thing if it's omitted: http://libvirt.org/formatdomain.html#elementsAddress I tend to only add API in libvirt-gconfig when there's a need for it, but I can look into adding API to set the address element if you think that's needed now. Similarly, the "name" attribute is optional, and defaults to 'com.redhat.spice.0'. It can be set with vir_config_domain_channel_set_target_name While looking at this, I've found that I need to squash this in this patch: diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h index 6b2ab20..8bbe634 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h @@ -62,9 +62,6 @@ 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__ */ Christophe
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@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@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@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Marc-André Lureau

On Tue, Mar 13, 2012 at 4:15 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
<target type="channel-target-virtio"/>
That's what I was mainly looking at, and I wish the test would cover a more complex and needed case, just to be sure. -- Marc-André Lureau

On Tue, Mar 13, 2012 at 04:18:21PM +0100, Marc-André Lureau wrote:
On Tue, Mar 13, 2012 at 4:15 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
<target type="channel-target-virtio"/>
That's what I was mainly looking at, and I wish the test would cover a more complex and needed case, just to be sure.
Yes, that XML does look a bit wrong. 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 :|

On Tue, Mar 13, 2012 at 04:18:21PM +0100, Marc-André Lureau wrote:
On Tue, Mar 13, 2012 at 4:15 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
<target type="channel-target-virtio"/>
That's what I was mainly looking at, and I wish the test would cover a more complex and needed case, just to be sure.
Ah, this is fixed by the first patch in the series, I hadn't noticed it. Christophe

On Tue, Mar 13, 2012 at 04:31:56PM +0100, Christophe Fergeau wrote:
On Tue, Mar 13, 2012 at 04:18:21PM +0100, Marc-André Lureau wrote:
On Tue, Mar 13, 2012 at 4:15 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
<target type="channel-target-virtio"/>
That's what I was mainly looking at, and I wish the test would cover a more complex and needed case, just to be sure.
Ah, this is fixed by the first patch in the series, I hadn't noticed it.
I've now pushed this first patch to master since it had been ack'ed by Zeeshan already. Christophe

On Tue, Mar 13, 2012 at 04:15:59PM +0100, Christophe Fergeau wrote:
Hey,
On Tue, Mar 13, 2012 at 01:22:09AM +0100, Marc-André Lureau wrote:
On Mon, Mar 12, 2012 at 5:56 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
Ping for this patch and for 3/3 ?
./test-domain-create gives:
<channel type="spicevmc"> <target type="channel-target-virtio"/> </channel>
Where we expect this:
<channel type='spicevmc'> <target type='virtio' name='com.redhat.spice.0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel>
The "address" element is optional, see http://libvirt.org/formatdomain.html#elementCharChannel "The optional address element can tie the channel to a particular type='virtio-serial' controller." It seems libvirt will still do the right thing if it's omitted: http://libvirt.org/formatdomain.html#elementsAddress I tend to only add API in libvirt-gconfig when there's a need for it, but I can look into adding API to set the address element if you think that's needed now.
Yes, there is no need to specify an <address> element really. Just let libvirt do its thing. 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 :|

So it looks ok to me, but On Tue, Mar 13, 2012 at 4:15 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
I tend to only add API in libvirt-gconfig when there's a need for it, but I can look into adding API to set the address element if you think that's needed now.
How do you verify new_from_xml()? Am I missing something? -- Marc-André Lureau

On Tue, Mar 13, 2012 at 05:01:14PM +0100, Marc-André Lureau wrote:
How do you verify new_from_xml()? Am I missing something?
This is just copy and paste, and keeping all files consistent. I don't think we have any user of these methods, except the top level ones, and I'm not sure it's really useful to be able to generate config objects from xml fragments. So basically it's boilerplate for now and not really useful. Maybe I should kill all these funcs some day... Christophe

On Tue, Mar 13, 2012 at 06:37:04PM +0100, Christophe Fergeau wrote:
On Tue, Mar 13, 2012 at 05:01:14PM +0100, Marc-André Lureau wrote:
How do you verify new_from_xml()? Am I missing something?
This is just copy and paste, and keeping all files consistent. I don't think we have any user of these methods, except the top level ones, and I'm not sure it's really useful to be able to generate config objects from xml fragments. So basically it's boilerplate for now and not really useful. Maybe I should kill all these funcs some day...
It might be useful when you get into the realm of hotplug, since the virDomain{Attach,Update,Detach}Device APIs use XML fragments for just the invididual devices. Regards, 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 :|

This is used to add the SPICE USB redirection channel. Even if the libvirt doc doesn't document it with the other devices deriving from GVirConfigDomainChardev, I think it makes sense to have this class derivers from GVirConfigDomainChardev too since it needs a GVirConfigDomainChardevSource, and it's documented as using a character device for redirection. --- libvirt-gconfig/Makefile.am | 2 + libvirt-gconfig/libvirt-gconfig-domain-redirdev.c | 82 +++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-redirdev.h | 73 ++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 6 ++ libvirt-gconfig/tests/test-domain-create.c | 14 ++++ 6 files changed, 178 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-redirdev.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-redirdev.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index d9e87b5..181ec57 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -35,6 +35,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-memballoon.h \ libvirt-gconfig-domain-os.h \ libvirt-gconfig-domain-parallel.h \ + libvirt-gconfig-domain-redirdev.h \ libvirt-gconfig-domain-seclabel.h \ libvirt-gconfig-domain-serial.h \ libvirt-gconfig-domain-snapshot.h \ @@ -87,6 +88,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-memballoon.c \ libvirt-gconfig-domain-os.c \ libvirt-gconfig-domain-parallel.c \ + libvirt-gconfig-domain-redirdev.c \ libvirt-gconfig-domain-seclabel.c \ libvirt-gconfig-domain-serial.c \ libvirt-gconfig-domain-snapshot.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c new file mode 100644 index 0000000..30c370a --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c @@ -0,0 +1,82 @@ +/* + * libvirt-gconfig-domain-redirdev.c: libvirt domain redirdev 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@redhat.com> + */ + +#include <config.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_REDIRDEV_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, GVirConfigDomainRedirdevPrivate)) + +struct _GVirConfigDomainRedirdevPrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainRedirdev, gvir_config_domain_redirdev, GVIR_CONFIG_TYPE_DOMAIN_CHARDEV); + + +static void gvir_config_domain_redirdev_class_init(GVirConfigDomainRedirdevClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainRedirdevPrivate)); +} + + +static void gvir_config_domain_redirdev_init(GVirConfigDomainRedirdev *redirdev) +{ + g_debug("Init GVirConfigDomainRedirdev=%p", redirdev); + + redirdev->priv = GVIR_CONFIG_DOMAIN_REDIRDEV_GET_PRIVATE(redirdev); +} + + +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, + "redirdev", NULL); + return GVIR_CONFIG_DOMAIN_REDIRDEV(object); +} + +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, + "redirdev", NULL, xml, error); + return GVIR_CONFIG_DOMAIN_REDIRDEV(object); +} + +void gvir_config_domain_redirdev_set_bus(GVirConfigDomainRedirdev *redirdev, + GVirConfigDomainRedirdevBus bus) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_REDIRDEV(redirdev)); + + gvir_config_object_set_attribute_with_type(GVIR_CONFIG_OBJECT(redirdev), + "bus", + GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV_BUS, + bus, + NULL); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-redirdev.h b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.h new file mode 100644 index 0000000..99585bb --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.h @@ -0,0 +1,73 @@ +/* + * libvirt-gconfig-domain-redirdev.h: libvirt domain redirdev 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@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_REDIRDEV_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_REDIRDEV_H__ + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV (gvir_config_domain_redirdev_get_type ()) +#define GVIR_CONFIG_DOMAIN_REDIRDEV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, GVirConfigDomainRedirdev)) +#define GVIR_CONFIG_DOMAIN_REDIRDEV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, GVirConfigDomainRedirdevClass)) +#define GVIR_CONFIG_IS_DOMAIN_REDIRDEV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV)) +#define GVIR_CONFIG_IS_DOMAIN_REDIRDEV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV)) +#define GVIR_CONFIG_DOMAIN_REDIRDEV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, GVirConfigDomainRedirdevClass)) + +typedef struct _GVirConfigDomainRedirdev GVirConfigDomainRedirdev; +typedef struct _GVirConfigDomainRedirdevPrivate GVirConfigDomainRedirdevPrivate; +typedef struct _GVirConfigDomainRedirdevClass GVirConfigDomainRedirdevClass; + +struct _GVirConfigDomainRedirdev +{ + GVirConfigDomainChardev parent; + + GVirConfigDomainRedirdevPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainRedirdevClass +{ + GVirConfigDomainChardevClass parent_class; + + gpointer padding[20]; +}; + +typedef enum { + GVIR_CONFIG_DOMAIN_REDIRDEV_BUS_USB +} GVirConfigDomainRedirdevBus; + +GType gvir_config_domain_redirdev_get_type(void); + +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new(void); +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new_from_xml(const gchar *xml, + GError **error); +void gvir_config_domain_redirdev_set_bus(GVirConfigDomainRedirdev *redirdev, + GVirConfigDomainRedirdevBus bus); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_REDIRDEV_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index b1eede2..2fcc4ba 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -52,6 +52,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-memballoon.h> #include <libvirt-gconfig/libvirt-gconfig-domain-os.h> #include <libvirt-gconfig/libvirt-gconfig-domain-parallel.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-redirdev.h> #include <libvirt-gconfig/libvirt-gconfig-domain-seclabel.h> #include <libvirt-gconfig/libvirt-gconfig-domain-serial.h> #include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index ffde0bc..717c3c9 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -197,6 +197,12 @@ LIBVIRT_GCONFIG_0.0.4 { gvir_config_domain_parallel_new; gvir_config_domain_parallel_new_from_xml; + gvir_config_domain_redirdev_get_type; + gvir_config_domain_redirdev_bus_get_type; + gvir_config_domain_redirdev_new; + gvir_config_domain_redirdev_new_from_xml; + gvir_config_domain_redirdev_set_bus; + gvir_config_domain_seclabel_get_type; gvir_config_domain_seclabel_type_get_type; gvir_config_domain_seclabel_new; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index b24d133..fd936e6 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -194,6 +194,20 @@ int main(int argc, char **argv) g_object_unref(G_OBJECT(spicevmc)); devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(channel)); + /* spice usb redirection */ + GVirConfigDomainRedirdev *redirdev; + + redirdev = gvir_config_domain_redirdev_new(); + gvir_config_domain_redirdev_set_bus(redirdev, + GVIR_CONFIG_DOMAIN_REDIRDEV_BUS_USB); + 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(redirdev), + GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE(spicevmc)); + g_object_unref(G_OBJECT(spicevmc)); + devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(redirdev)); + gvir_config_domain_set_devices(domain, devices); g_list_foreach(devices, (GFunc)g_object_unref, NULL); -- 1.7.7.6

ack On Tue, Mar 6, 2012 at 5:38 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
This is used to add the SPICE USB redirection channel. Even if the libvirt doc doesn't document it with the other devices deriving from GVirConfigDomainChardev, I think it makes sense to have this class derivers from GVirConfigDomainChardev too since it needs a GVirConfigDomainChardevSource, and it's documented as using a character device for redirection. --- libvirt-gconfig/Makefile.am | 2 + libvirt-gconfig/libvirt-gconfig-domain-redirdev.c | 82 +++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-redirdev.h | 73 ++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 6 ++ libvirt-gconfig/tests/test-domain-create.c | 14 ++++ 6 files changed, 178 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-redirdev.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-redirdev.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index d9e87b5..181ec57 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -35,6 +35,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-memballoon.h \ libvirt-gconfig-domain-os.h \ libvirt-gconfig-domain-parallel.h \ + libvirt-gconfig-domain-redirdev.h \ libvirt-gconfig-domain-seclabel.h \ libvirt-gconfig-domain-serial.h \ libvirt-gconfig-domain-snapshot.h \ @@ -87,6 +88,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-memballoon.c \ libvirt-gconfig-domain-os.c \ libvirt-gconfig-domain-parallel.c \ + libvirt-gconfig-domain-redirdev.c \ libvirt-gconfig-domain-seclabel.c \ libvirt-gconfig-domain-serial.c \ libvirt-gconfig-domain-snapshot.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c new file mode 100644 index 0000000..30c370a --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c @@ -0,0 +1,82 @@ +/* + * libvirt-gconfig-domain-redirdev.c: libvirt domain redirdev 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@redhat.com> + */ + +#include <config.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_REDIRDEV_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, GVirConfigDomainRedirdevPrivate)) + +struct _GVirConfigDomainRedirdevPrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainRedirdev, gvir_config_domain_redirdev, GVIR_CONFIG_TYPE_DOMAIN_CHARDEV); + + +static void gvir_config_domain_redirdev_class_init(GVirConfigDomainRedirdevClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainRedirdevPrivate)); +} + + +static void gvir_config_domain_redirdev_init(GVirConfigDomainRedirdev *redirdev) +{ + g_debug("Init GVirConfigDomainRedirdev=%p", redirdev); + + redirdev->priv = GVIR_CONFIG_DOMAIN_REDIRDEV_GET_PRIVATE(redirdev); +} + + +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, + "redirdev", NULL); + return GVIR_CONFIG_DOMAIN_REDIRDEV(object); +} + +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, + "redirdev", NULL, xml, error); + return GVIR_CONFIG_DOMAIN_REDIRDEV(object); +} + +void gvir_config_domain_redirdev_set_bus(GVirConfigDomainRedirdev *redirdev, + GVirConfigDomainRedirdevBus bus) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_REDIRDEV(redirdev)); + + gvir_config_object_set_attribute_with_type(GVIR_CONFIG_OBJECT(redirdev), + "bus", + GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV_BUS, + bus, + NULL); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-redirdev.h b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.h new file mode 100644 index 0000000..99585bb --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.h @@ -0,0 +1,73 @@ +/* + * libvirt-gconfig-domain-redirdev.h: libvirt domain redirdev 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@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_REDIRDEV_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_REDIRDEV_H__ + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV (gvir_config_domain_redirdev_get_type ()) +#define GVIR_CONFIG_DOMAIN_REDIRDEV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, GVirConfigDomainRedirdev)) +#define GVIR_CONFIG_DOMAIN_REDIRDEV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, GVirConfigDomainRedirdevClass)) +#define GVIR_CONFIG_IS_DOMAIN_REDIRDEV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV)) +#define GVIR_CONFIG_IS_DOMAIN_REDIRDEV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV)) +#define GVIR_CONFIG_DOMAIN_REDIRDEV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, GVirConfigDomainRedirdevClass)) + +typedef struct _GVirConfigDomainRedirdev GVirConfigDomainRedirdev; +typedef struct _GVirConfigDomainRedirdevPrivate GVirConfigDomainRedirdevPrivate; +typedef struct _GVirConfigDomainRedirdevClass GVirConfigDomainRedirdevClass; + +struct _GVirConfigDomainRedirdev +{ + GVirConfigDomainChardev parent; + + GVirConfigDomainRedirdevPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainRedirdevClass +{ + GVirConfigDomainChardevClass parent_class; + + gpointer padding[20]; +}; + +typedef enum { + GVIR_CONFIG_DOMAIN_REDIRDEV_BUS_USB +} GVirConfigDomainRedirdevBus; + +GType gvir_config_domain_redirdev_get_type(void); + +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new(void); +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new_from_xml(const gchar *xml, + GError **error); +void gvir_config_domain_redirdev_set_bus(GVirConfigDomainRedirdev *redirdev, + GVirConfigDomainRedirdevBus bus); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_REDIRDEV_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index b1eede2..2fcc4ba 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -52,6 +52,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-memballoon.h> #include <libvirt-gconfig/libvirt-gconfig-domain-os.h> #include <libvirt-gconfig/libvirt-gconfig-domain-parallel.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-redirdev.h> #include <libvirt-gconfig/libvirt-gconfig-domain-seclabel.h> #include <libvirt-gconfig/libvirt-gconfig-domain-serial.h> #include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index ffde0bc..717c3c9 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -197,6 +197,12 @@ LIBVIRT_GCONFIG_0.0.4 { gvir_config_domain_parallel_new; gvir_config_domain_parallel_new_from_xml;
+ gvir_config_domain_redirdev_get_type; + gvir_config_domain_redirdev_bus_get_type; + gvir_config_domain_redirdev_new; + gvir_config_domain_redirdev_new_from_xml; + gvir_config_domain_redirdev_set_bus; + gvir_config_domain_seclabel_get_type; gvir_config_domain_seclabel_type_get_type; gvir_config_domain_seclabel_new; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index b24d133..fd936e6 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -194,6 +194,20 @@ int main(int argc, char **argv) g_object_unref(G_OBJECT(spicevmc)); devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(channel));
+ /* spice usb redirection */ + GVirConfigDomainRedirdev *redirdev; + + redirdev = gvir_config_domain_redirdev_new(); + gvir_config_domain_redirdev_set_bus(redirdev, + GVIR_CONFIG_DOMAIN_REDIRDEV_BUS_USB); + 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(redirdev), + GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE(spicevmc)); + g_object_unref(G_OBJECT(spicevmc)); + devices = g_list_append(devices, GVIR_CONFIG_DOMAIN_DEVICE(redirdev)); +
gvir_config_domain_set_devices(domain, devices); g_list_foreach(devices, (GFunc)g_object_unref, NULL); -- 1.7.7.6
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Marc-André Lureau

On Tue, Mar 6, 2012 at 6:38 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
It was called GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_GUESTFWD, which in turn confused glib-mkenums, leading to a wrong value being generated in the XML when trying to use this enumeration.
ACK! -- Regards, Zeeshan Ali (Khattak) FSF member#5124
participants (4)
-
Christophe Fergeau
-
Daniel P. Berrange
-
Marc-André Lureau
-
Zeeshan Ali (Khattak)