[libvirt-glib 16/37] Add GVirConfigDomain::vcpu

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

 



---
 libvirt-gconfig/libvirt-gconfig-domain.c   |   29 ++++++++++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-domain.h   |    3 ++
 libvirt-gconfig/libvirt-gconfig.sym        |    2 +
 libvirt-gconfig/tests/test-domain-create.c |    1 +
 4 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index f88ae69..41390bd 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -46,6 +46,7 @@ enum {
     PROP_0,
     PROP_NAME,
     PROP_MEMORY,
+    PROP_VCPU,
     PROP_FEATURES
 };
 
@@ -63,6 +64,9 @@ static void gvir_config_domain_get_property(GObject *object,
     case PROP_MEMORY:
         g_value_set_uint64(value, gvir_config_domain_get_memory(domain));
         break;
+    case PROP_VCPU:
+        g_value_set_uint64(value, gvir_config_domain_get_vcpus(domain));
+        break;
     case PROP_FEATURES:
         g_value_take_boxed(value, gvir_config_domain_get_features(domain));
         break;
@@ -86,6 +90,9 @@ static void gvir_config_domain_set_property(GObject *object,
     case PROP_MEMORY:
         gvir_config_domain_set_memory(domain, g_value_get_uint64(value));
         break;
+    case PROP_VCPU:
+        gvir_config_domain_set_vcpus(domain, g_value_get_uint64(value));
+        break;
     case PROP_FEATURES:
         gvir_config_domain_set_features(domain, g_value_get_boxed(value));
         break;
@@ -122,6 +129,15 @@ static void gvir_config_domain_class_init(GVirConfigDomainClass *klass)
                                                         G_PARAM_READWRITE |
                                                         G_PARAM_STATIC_STRINGS));
     g_object_class_install_property(object_class,
+                                    PROP_VCPU,
+                                    g_param_spec_uint64("vcpu",
+                                                        "Virtual CPUs",
+                                                        "Maximum Number of Guest Virtual CPUs",
+                                                        0, G_MAXUINT64,
+                                                        1,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_STATIC_STRINGS));
+    g_object_class_install_property(object_class,
                                     PROP_FEATURES,
                                     g_param_spec_boxed("features",
                                                         "Features",
@@ -192,6 +208,19 @@ void gvir_config_domain_set_memory(GVirConfigDomain *domain, guint64 memory)
     g_object_notify(G_OBJECT(domain), "memory");
 }
 
+guint64 gvir_config_domain_get_vcpus(GVirConfigDomain *domain)
+{
+    return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(domain),
+                                                      "vcpu");
+}
+
+void gvir_config_domain_set_vcpus(GVirConfigDomain *domain, guint64 vcpu_count)
+{
+    gvir_config_object_set_node_content_uint64(GVIR_CONFIG_OBJECT(domain),
+                                               "vcpu", vcpu_count);
+    g_object_notify(G_OBJECT(domain), "vcpu");
+}
+
 /**
  * gvir_config_domain_get_features:
  * Returns: (transfer full):
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h
index 37effe4..3ca6228 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain.h
@@ -66,6 +66,9 @@ 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);
 void gvir_config_domain_set_memory(GVirConfigDomain *domain, guint64 memory);
+guint64 gvir_config_domain_get_vcpus(GVirConfigDomain *domain);
+void gvir_config_domain_set_vcpus(GVirConfigDomain *domain,
+                                  guint64 vcpu_count);
 GStrv gvir_config_domain_get_features(GVirConfigDomain *domain);
 void gvir_config_domain_set_features(GVirConfigDomain *domain,
                                      const GStrv features);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 486b509..7660070 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -23,6 +23,8 @@ LIBVIRT_GOBJECT_0.0.1 {
 	gvir_config_domain_set_memory;
 	gvir_config_domain_get_name;
 	gvir_config_domain_set_name;
+	gvir_config_domain_get_vcpus;
+	gvir_config_domain_set_vcpus;
 
 	gvir_config_domain_snapshot_get_type;
 	gvir_config_domain_snapshot_new;
diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c
index 8abca00..af960a9 100644
--- a/libvirt-gconfig/tests/test-domain-create.c
+++ b/libvirt-gconfig/tests/test-domain-create.c
@@ -49,6 +49,7 @@ int main(void)
     g_free(name);
 
     gvir_config_domain_set_memory(domain, 1234);
+    gvir_config_domain_set_vcpus(domain, 3);
     g_assert(gvir_config_domain_get_memory(domain) == 1234);
 
     gvir_config_domain_set_features(domain, (const GStrv)features);
-- 
1.7.7

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