On Thu, Jan 12, 2012 at 07:07:22PM +0000, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
---
libvirt-gconfig/libvirt-gconfig-domain-channel.c | 23 ++++++++++++++++++++++
libvirt-gconfig/libvirt-gconfig-domain-channel.h | 11 ++++++++++
libvirt-gconfig/libvirt-gconfig-domain-console.c | 12 +++++++++++
libvirt-gconfig/libvirt-gconfig-domain-console.h | 12 +++++++++++
libvirt-gconfig/libvirt-gconfig-object-private.h | 5 ++++
libvirt-gconfig/libvirt-gconfig-object.c | 15 ++++++++++++++
libvirt-gconfig/libvirt-gconfig.sym | 5 ++++
7 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-channel.c
b/libvirt-gconfig/libvirt-gconfig-domain-channel.c
index 02f8fe7..a4f9527 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-channel.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-channel.c
@@ -23,6 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_CHANNEL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_CHANNEL,
GVirConfigDomainChannelPrivate))
@@ -68,3 +69,25 @@ GVirConfigDomainChannel *gvir_config_domain_channel_new_from_xml(const
gchar *xm
return NULL;
return GVIR_CONFIG_DOMAIN_CHANNEL(object);
}
+
+
+void gvir_config_domain_channel_set_target_type(GVirConfigDomainChannel *channel,
+ GVirConfigDomainChannelTargetType type)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CHANNEL(channel));
+
+ gvir_config_object_add_child_with_attribute_enum(GVIR_CONFIG_OBJECT(channel),
+ "target",
"type",
+
GVIR_CONFIG_TYPE_DOMAIN_CHANNEL_TARGET_TYPE,
+ type);
+}
+
+
+void gvir_config_domain_channel_set_target_name(GVirConfigDomainChannel *channel,
+ const gchar *name)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CHANNEL(channel));
+
+ gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(channel),
+ "target", "name",
name);
+}
_set_target_type and _set_target_name create a different <target> node when
they are called, this is probably not what we want.
Apart from this issue, the patch looks good to me.
Christophe
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-channel.h
b/libvirt-gconfig/libvirt-gconfig-domain-channel.h
index 0e48bcf..a8a3020 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-channel.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-channel.h
@@ -56,12 +56,23 @@ struct _GVirConfigDomainChannelClass
gpointer padding[20];
};
+typedef enum {
+ GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_GUESTFWD,
+ GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_VIRTIO,
+} GVirConfigDomainChannelTargetType;
+
GType gvir_config_domain_channel_get_type(void);
GVirConfigDomainChannel *gvir_config_domain_channel_new(void);
GVirConfigDomainChannel *gvir_config_domain_channel_new_from_xml(const gchar *xml,
GError **error);
+void gvir_config_domain_channel_set_target_type(GVirConfigDomainChannel *channel,
+ GVirConfigDomainChannelTargetType
type);
+void gvir_config_domain_channel_set_target_name(GVirConfigDomainChannel *channel,
+ const gchar *name);
+
+
G_END_DECLS
#endif /* __LIBVIRT_GCONFIG_DOMAIN_CHANNEL_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-console.c
b/libvirt-gconfig/libvirt-gconfig-domain-console.c
index 03ee1a7..db97322 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-console.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-console.c
@@ -23,6 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_CONSOLE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_CONSOLE,
GVirConfigDomainConsolePrivate))
@@ -68,3 +69,14 @@ GVirConfigDomainConsole *gvir_config_domain_console_new_from_xml(const
gchar *xm
return NULL;
return GVIR_CONFIG_DOMAIN_CONSOLE(object);
}
+
+void gvir_config_domain_console_set_target_type(GVirConfigDomainConsole *console,
+ GVirConfigDomainConsoleTargetType type)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CONSOLE(console));
+
+ gvir_config_object_add_child_with_attribute_enum(GVIR_CONFIG_OBJECT(console),
+ "target",
"type",
+
GVIR_CONFIG_TYPE_DOMAIN_CONSOLE_TARGET_TYPE,
+ type);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-console.h
b/libvirt-gconfig/libvirt-gconfig-domain-console.h
index 00e142a..1c735e9 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-console.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-console.h
@@ -57,11 +57,23 @@ struct _GVirConfigDomainConsoleClass
};
+typedef enum {
+ GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_XEN,
+ GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_SERIAL,
+ GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_UML,
+ GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_VIRTIO,
+ GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_LXC,
+ GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_OPENVZ,
+} GVirConfigDomainConsoleTargetType;
+
GType gvir_config_domain_console_get_type(void);
GVirConfigDomainConsole *gvir_config_domain_console_new(void);
GVirConfigDomainConsole *gvir_config_domain_console_new_from_xml(const gchar *xml,
GError **error);
+void gvir_config_domain_console_set_target_type(GVirConfigDomainConsole *console,
+ GVirConfigDomainConsoleTargetType
type);
+
G_END_DECLS
#endif /* __LIBVIRT_GCONFIG_DOMAIN_CONSOLE_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h
b/libvirt-gconfig/libvirt-gconfig-object-private.h
index 0c0c44f..6d01e26 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -59,6 +59,11 @@ void gvir_config_object_add_child_with_attribute(GVirConfigObject
*object,
const char *child_name,
const char *attr_name,
const char *attr_value);
+void gvir_config_object_add_child_with_attribute_enum(GVirConfigObject *object,
+ const char *child_name,
+ const char *attr_name,
+ GType attr_type,
+ unsigned int attr_value);
GVirConfigObject *gvir_config_object_replace_child(GVirConfigObject *object,
const char *child_name);
void gvir_config_object_replace_child_with_attribute(GVirConfigObject *object,
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c
b/libvirt-gconfig/libvirt-gconfig-object.c
index a3b7109..5645490 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -419,6 +419,21 @@ gvir_config_object_add_child_with_attribute(GVirConfigObject
*object,
g_object_unref(G_OBJECT(child));
}
+
+void gvir_config_object_add_child_with_attribute_enum(GVirConfigObject *object,
+ const char *child_name,
+ const char *attr_name,
+ GType attr_type,
+ unsigned int attr_value)
+{
+ GVirConfigObject *child;
+
+ child = gvir_config_object_add_child(object, child_name);
+ gvir_config_object_set_attribute_with_type(child, attr_name, attr_type, attr_value,
NULL);
+ g_object_unref(G_OBJECT(child));
+}
+
+
G_GNUC_INTERNAL GVirConfigObject *
gvir_config_object_replace_child(GVirConfigObject *object,
const char *child_name)
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 7cf3c3d..1c11729 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -33,6 +33,9 @@ LIBVIRT_GCONFIG_0.0.3 {
gvir_config_domain_channel_get_type;
gvir_config_domain_channel_new;
gvir_config_domain_channel_new_from_xml;
+ gvir_config_domain_channel_set_target_type;
+ gvir_config_domain_channel_set_target_name;
+ gvir_config_domain_channel_target_type_get_type;
gvir_config_domain_chardev_get_type;
gvir_config_domain_chardev_set_source;
@@ -55,6 +58,8 @@ LIBVIRT_GCONFIG_0.0.3 {
gvir_config_domain_console_get_type;
gvir_config_domain_console_new;
gvir_config_domain_console_new_from_xml;
+ gvir_config_domain_console_set_target_type;
+ gvir_config_domain_console_target_type_get_type;
gvir_config_domain_device_get_type;
--
1.7.7.5
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list