[libvirt-designer 6/7] Add gvir_designer_domain_interface_{bridge, user} methods

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

 



These cover 2 additional types of libvirt interfaces: usermode/SLIRP
networking and bridge.
---
 libvirt-designer/libvirt-designer-domain.c | 70 +++++++++++++++++++++++++++++-
 libvirt-designer/libvirt-designer-domain.h |  5 +++
 libvirt-designer/libvirt-designer.sym      |  2 +
 3 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c
index 0321180..a060a81 100644
--- a/libvirt-designer/libvirt-designer-domain.c
+++ b/libvirt-designer/libvirt-designer-domain.c
@@ -54,7 +54,9 @@ G_DEFINE_TYPE(GVirDesignerDomain, gvir_designer_domain, G_TYPE_OBJECT);
 #define GVIR_DESIGNER_DOMAIN_ERROR gvir_designer_domain_error_quark()
 
 typedef enum {
+    GVIR_DESIGNER_DOMAIN_NIC_TYPE_BRIDGE,
     GVIR_DESIGNER_DOMAIN_NIC_TYPE_NETWORK,
+    GVIR_DESIGNER_DOMAIN_NIC_TYPE_USER,
     /* add new type here */
 } GVirDesignerDomainNICType;
 
@@ -1869,7 +1871,7 @@ cleanup:
 static GVirConfigDomainInterface *
 gvir_designer_domain_add_interface_full(GVirDesignerDomain *design,
                                         GVirDesignerDomainNICType type,
-                                        const char *network,
+                                        const char *source,
                                         GError **error)
 {
     GVirConfigDomainInterface *ret = NULL;
@@ -1878,10 +1880,18 @@ gvir_designer_domain_add_interface_full(GVirDesignerDomain *design,
     model = gvir_designer_domain_get_preferred_nic_model(design, error);
 
     switch (type) {
+    case GVIR_DESIGNER_DOMAIN_NIC_TYPE_BRIDGE:
+        ret = GVIR_CONFIG_DOMAIN_INTERFACE(gvir_config_domain_interface_bridge_new());
+        gvir_config_domain_interface_bridge_set_source(GVIR_CONFIG_DOMAIN_INTERFACE_BRIDGE(ret),
+                                                       source);
+        break;
     case GVIR_DESIGNER_DOMAIN_NIC_TYPE_NETWORK:
         ret = GVIR_CONFIG_DOMAIN_INTERFACE(gvir_config_domain_interface_network_new());
         gvir_config_domain_interface_network_set_source(GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK(ret),
-                                                        network);
+                                                        source);
+        break;
+    case GVIR_DESIGNER_DOMAIN_NIC_TYPE_USER:
+        ret = GVIR_CONFIG_DOMAIN_INTERFACE(gvir_config_domain_interface_user_new());
         break;
     default:
         g_set_error(error, GVIR_DESIGNER_DOMAIN_ERROR, 0,
@@ -1898,6 +1908,35 @@ cleanup:
     return ret;
 }
 
+/**
+ * gvir_designer_domain_add_interface_bridge:
+ * @design: (transfer none): the domain designer instance
+ * @bridge: (transfer none): bridge name
+ * @error: return location for a #GError, or NULL
+ *
+ * Add new network interface card into @design. The interface is
+ * of 'bridge' type and uses @bridge as the bridge device
+ *
+ * Returns: (transfer full): the pointer to the new interface.
+ */
+GVirConfigDomainInterface *
+gvir_designer_domain_add_interface_bridge(GVirDesignerDomain *design,
+                                          const char *bridge,
+                                          GError **error)
+{
+    g_return_val_if_fail(GVIR_DESIGNER_IS_DOMAIN(design), NULL);
+    g_return_val_if_fail(bridge != NULL, NULL);
+    g_return_val_if_fail(!error_is_set(error), NULL);
+
+    GVirConfigDomainInterface *ret = NULL;
+
+    ret = gvir_designer_domain_add_interface_full(design,
+                                                  GVIR_DESIGNER_DOMAIN_NIC_TYPE_BRIDGE,
+                                                  bridge,
+                                                  error);
+
+    return ret;
+}
 
 /**
  * gvir_designer_domain_add_interface_network:
@@ -1929,6 +1968,33 @@ gvir_designer_domain_add_interface_network(GVirDesignerDomain *design,
     return ret;
 }
 
+/**
+ * gvir_designer_domain_add_interface_user:
+ * @design: (transfer none): the domain designer instance
+ * @error: return location for a #GError, or NULL
+ *
+ * Add new network interface card into @design. The interface is
+ * of 'user' type.
+ *
+ * Returns: (transfer full): the pointer to the new interface.
+ */
+GVirConfigDomainInterface *
+gvir_designer_domain_add_interface_user(GVirDesignerDomain *design,
+                                        GError **error)
+{
+    g_return_val_if_fail(GVIR_DESIGNER_IS_DOMAIN(design), NULL);
+    g_return_val_if_fail(!error_is_set(error), NULL);
+
+    GVirConfigDomainInterface *ret = NULL;
+
+    ret = gvir_designer_domain_add_interface_full(design,
+                                                  GVIR_DESIGNER_DOMAIN_NIC_TYPE_USER,
+                                                  NULL,
+                                                  error);
+
+    return ret;
+}
+
 static GVirConfigDomainVideoModel
 gvir_designer_domain_video_model_str_to_enum(const char *model_str,
                                              GError **error)
diff --git a/libvirt-designer/libvirt-designer-domain.h b/libvirt-designer/libvirt-designer-domain.h
index 85dce97..41aae66 100644
--- a/libvirt-designer/libvirt-designer-domain.h
+++ b/libvirt-designer/libvirt-designer-domain.h
@@ -128,9 +128,14 @@ GVirConfigDomainDisk *gvir_designer_domain_add_floppy_device(GVirDesignerDomain
                                                              const char *devpath,
                                                              GError **error);
 
+GVirConfigDomainInterface *gvir_designer_domain_add_interface_bridge(GVirDesignerDomain *design,
+                                                                     const char *bridge,
+                                                                     GError **error);
 GVirConfigDomainInterface *gvir_designer_domain_add_interface_network(GVirDesignerDomain *design,
                                                                       const char *network,
                                                                       GError **error);
+GVirConfigDomainInterface *gvir_designer_domain_add_interface_user(GVirDesignerDomain *design,
+                                                                   GError **error);
 
 GVirConfigDomainGraphics *gvir_designer_domain_add_graphics(GVirDesignerDomain *design,
                                                             GVirDesignerDomainGraphics type,
diff --git a/libvirt-designer/libvirt-designer.sym b/libvirt-designer/libvirt-designer.sym
index 96bc656..d5a2e6e 100644
--- a/libvirt-designer/libvirt-designer.sym
+++ b/libvirt-designer/libvirt-designer.sym
@@ -21,7 +21,9 @@ LIBVIRT_DESIGNER_0.0.2 {
 	gvir_designer_domain_add_floppy_file;
 	gvir_designer_domain_add_floppy_device;
 	gvir_designer_domain_add_graphics;
+	gvir_designer_domain_add_interface_bridge;
 	gvir_designer_domain_add_interface_network;
+	gvir_designer_domain_add_interface_user;
 	gvir_designer_domain_add_smartcard;
 	gvir_designer_domain_add_sound;
 	gvir_designer_domain_add_usb_redir;
-- 
2.1.0

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