[PATCH libvirt-glib 4/5] Add APIs for setting virt type and appending devices

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Add gvir_config_domain_get_virt_type and
gvir_config_domain_virt_type_get_type

* libvirt-gconfig-domain.c, libvirt-gconfig-domain.h,
  libvirt-gconfig.h, libvirt-gconfig.sym: Add new APIs
---
 libvirt-gconfig/libvirt-gconfig-domain.c |   32 ++++++++++++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-domain.h |   10 +++++++++
 libvirt-gconfig/libvirt-gconfig.h        |    2 +-
 libvirt-gconfig/libvirt-gconfig.sym      |    2 +
 4 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index b54d12c..8fb1a2b 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -175,6 +175,23 @@ GVirConfigDomain *gvir_config_domain_new(void)
     return GVIR_CONFIG_DOMAIN(object);
 }
 
+
+void gvir_config_domain_set_virt_type(GVirConfigDomain *domain, GVirConfigDomainVirtType type)
+{
+    xmlNodePtr node;
+    const char *type_str;
+
+    g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_FILESYS(domain));
+
+    node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(domain));
+    g_return_if_fail(node != NULL);
+    type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DOMAIN_VIRT_TYPE,
+                                          type);
+    g_return_if_fail(type_str != NULL);
+    xmlNewProp(node, (xmlChar*)"type", (xmlChar*)type_str);
+}
+
+
 char *gvir_config_domain_get_name(GVirConfigDomain *domain)
 {
     return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(domain),
@@ -306,3 +323,18 @@ void gvir_config_domain_set_devices(GVirConfigDomain *domain,
     gvir_config_object_attach(GVIR_CONFIG_OBJECT(domain), devices_node);
     g_object_unref(G_OBJECT(devices_node));
 }
+
+void gvir_config_domain_add_device(GVirConfigDomain *domain,
+                                   GVirConfigDomainDevice *device)
+{
+    GVirConfigObject *devices_node;
+
+    g_return_if_fail(GVIR_IS_CONFIG_DOMAIN(domain));
+
+    devices_node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(domain),
+                                                "devices");
+
+    gvir_config_object_attach(devices_node, GVIR_CONFIG_OBJECT(device));
+    gvir_config_object_attach(GVIR_CONFIG_OBJECT(domain), devices_node);
+    g_object_unref(G_OBJECT(devices_node));
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h
index 08682aa..c97ff46 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain.h
@@ -59,12 +59,20 @@ struct _GVirConfigDomainClass
     gpointer padding[20];
 };
 
+typedef enum {
+    GVIR_CONFIG_DOMAIN_VIRT_XEN,
+    GVIR_CONFIG_DOMAIN_VIRT_QEMU,
+    GVIR_CONFIG_DOMAIN_VIRT_KVM,
+    GVIR_CONFIG_DOMAIN_VIRT_KQEMU,
+    GVIR_CONFIG_DOMAIN_VIRT_LXC,
+} GVirConfigDomainVirtType;
 
 GType gvir_config_domain_get_type(void);
 
 GVirConfigDomain *gvir_config_domain_new_from_xml(const gchar *xml, GError **error);
 GVirConfigDomain *gvir_config_domain_new(void);
 
+void gvir_config_domain_set_virt_type(GVirConfigDomain *domain, GVirConfigDomainVirtType type);
 char *gvir_config_domain_get_name(GVirConfigDomain *domain);
 void gvir_config_domain_set_name(GVirConfigDomain *domain, const char *name);
 guint64 gvir_config_domain_get_memory(GVirConfigDomain *domain);
@@ -81,6 +89,8 @@ void gvir_config_domain_set_os(GVirConfigDomain *domain,
                                GVirConfigDomainOs *os);
 void gvir_config_domain_set_devices(GVirConfigDomain *domain,
                                     GList *devices);
+void gvir_config_domain_add_device(GVirConfigDomain *domain,
+                                   GVirConfigDomainDevice *device);
 
 G_END_DECLS
 
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index ed7623c..8525065 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -29,7 +29,6 @@
 #include <libvirt-gconfig/libvirt-gconfig-main.h>
 #include <libvirt-gconfig/libvirt-gconfig-object.h>
 #include <libvirt-gconfig/libvirt-gconfig-capabilities.h>
-#include <libvirt-gconfig/libvirt-gconfig-domain.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-clock.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-device.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-disk.h>
@@ -43,6 +42,7 @@
 #include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-timer.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-video.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain.h>
 #include <libvirt-gconfig/libvirt-gconfig-enum-types.h>
 #include <libvirt-gconfig/libvirt-gconfig-helpers.h>
 #include <libvirt-gconfig/libvirt-gconfig-interface.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index e895cb0..9b74c35 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -21,6 +21,8 @@ LIBVIRT_GCONFIG_0.0.1 {
 	gvir_config_domain_set_os;
 	gvir_config_domain_get_vcpus;
 	gvir_config_domain_set_vcpus;
+	gvir_config_domain_get_virt_type;
+	gvir_config_domain_virt_type_get_type;
 
 	gvir_config_domain_clock_get_type;
 	gvir_config_domain_clock_offset_get_type;
-- 
1.7.6.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]