[libvirt-designer][PATCH 1/4] Load osinfo DB on init

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

 



as we need this DB later to find an OS or hypervisor and supported
devices.
---
 libvirt-designer/Makefile.am                 |    1 +
 libvirt-designer/libvirt-designer-domain.c   |    5 +++-
 libvirt-designer/libvirt-designer-internal.h |   30 ++++++++++++++++++++++++++
 libvirt-designer/libvirt-designer-main.c     |   17 +++++++++++++-
 4 files changed, 51 insertions(+), 2 deletions(-)
 create mode 100644 libvirt-designer/libvirt-designer-internal.h

diff --git a/libvirt-designer/Makefile.am b/libvirt-designer/Makefile.am
index cf40419..8f10c41 100644
--- a/libvirt-designer/Makefile.am
+++ b/libvirt-designer/Makefile.am
@@ -20,6 +20,7 @@ DESIGNER_GENERATED_FILES = \
 
 DESIGNER_HEADER_FILES = \
 			libvirt-designer.h \
+			libvirt-designer-internal.h \
 			libvirt-designer-main.h \
 			libvirt-designer-domain.h \
 			$(NULL)
diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c
index 9b4a7ed..a8cabde 100644
--- a/libvirt-designer/libvirt-designer-domain.c
+++ b/libvirt-designer/libvirt-designer-domain.c
@@ -17,13 +17,16 @@
  * 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: Daniel P. Berrange <berrange@xxxxxxxxxx>
+ * Authors:
+ *   Daniel P. Berrange <berrange@xxxxxxxxxx>
+ *   Michal Privoznik <mprivozn@xxxxxxxxxx>
  */
 
 #include <config.h>
 #include <sys/utsname.h>
 
 #include "libvirt-designer/libvirt-designer.h"
+#include "libvirt-designer/libvirt-designer-internal.h"
 
 #define GVIR_DESIGNER_DOMAIN_GET_PRIVATE(obj)                         \
         (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_DESIGNER_TYPE_DOMAIN, GVirDesignerDomainPrivate))
diff --git a/libvirt-designer/libvirt-designer-internal.h b/libvirt-designer/libvirt-designer-internal.h
new file mode 100644
index 0000000..bbef922
--- /dev/null
+++ b/libvirt-designer/libvirt-designer-internal.h
@@ -0,0 +1,30 @@
+/*
+ * libvirt-designer-internal.h: internal definitions just
+ *                              used by code from the library
+ *
+ * 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, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Michal Privoznik <mprivozn@xxxxxxxxxx>
+ */
+
+#ifndef __LIBVIRT_DESIGNER_INTERNAL_H__
+#define __LIBVIRT_DESIGNER_INTERNAL_H__
+
+extern OsinfoLoader *osinfo_loader;
+extern OsinfoDb *osinfo_db;
+
+#endif /* __LIBVIRT_DESIGNER_INTERNAL_H__ */
diff --git a/libvirt-designer/libvirt-designer-main.c b/libvirt-designer/libvirt-designer-main.c
index 60bf8f5..f2381a6 100644
--- a/libvirt-designer/libvirt-designer-main.c
+++ b/libvirt-designer/libvirt-designer-main.c
@@ -17,7 +17,9 @@
  * License along with this library; If not, see
  * <http://www.gnu.org/licenses/>.
  *
- * Author: Daniel P. Berrange <berrange@xxxxxxxxxx>
+ * Authors:
+ *   Daniel P. Berrange <berrange@xxxxxxxxxx>
+ *   Michal Privoznik <mprivozn@xxxxxxxxxx>
  */
 
 #include <config.h>
@@ -28,6 +30,9 @@
 #include <libvirt-designer/libvirt-designer.h>
 #include <libvirt-gconfig/libvirt-gconfig.h>
 
+OsinfoLoader *osinfo_loader = NULL;
+OsinfoDb *osinfo_db = NULL;
+
 /**
  * gvir_designer_init:
  * @argc: (inout): pointer to application's argc
@@ -80,5 +85,15 @@ gboolean gvir_designer_init_check(int *argc,
                           gvir_log_handler, NULL);
 #endif
 
+    /* Init libosinfo and load databases from default paths */
+    /* XXX maybe we want to let users tell a different path via
+     * env variable or argv */
+    osinfo_loader = osinfo_loader_new();
+    osinfo_loader_process_default_path(osinfo_loader, err);
+    if (err)
+        return FALSE;
+
+    osinfo_db = osinfo_loader_get_db(osinfo_loader);
+
     return TRUE;
 }
-- 
1.7.8.6

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