[libgovirt] Make sure a name is set for OvirtCdrom instances
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgovirt] Make sure a name is set for OvirtCdrom instances
- Date: Tue, 8 Oct 2013 17:05:11 +0000 (UTC)
commit f68dae626be0e2da426746d6b52401934dbe0c33
Author: Christophe Fergeau <cfergeau redhat com>
Date: Thu Aug 29 21:00:41 2013 +0200
Make sure a name is set for OvirtCdrom instances
With oVirt 3.2, the cdrom xml does not contain a name, but
OvirtCollection needs a name. As there can only be one CDROM device
per VM in that version, make up a name.
govirt/ovirt-cdrom.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/govirt/ovirt-cdrom.c b/govirt/ovirt-cdrom.c
index 664d452..de71477 100644
--- a/govirt/ovirt-cdrom.c
+++ b/govirt/ovirt-cdrom.c
@@ -91,6 +91,7 @@ static gboolean ovirt_cdrom_refresh_from_xml(OvirtCdrom *cdrom,
RestXmlNode *file_node;
const char *file;
const char *file_key = g_intern_string("file");
+ char *name;
file_node = g_hash_table_lookup(node->children, file_key);
if (file_node == NULL)
@@ -98,6 +99,20 @@ static gboolean ovirt_cdrom_refresh_from_xml(OvirtCdrom *cdrom,
file = rest_xml_node_get_attr(file_node, "id");
cdrom->priv->file = g_strdup(file);
+ g_object_get(G_OBJECT(cdrom), "name", &name, NULL);
+ if (name == NULL) {
+ /* Build up fake name as ovirt_collection_refresh_from_xml()
+ * expects it to be set (it uses it as a hash table key), but
+ * it's not set in oVirt XML as of 3.2. There can only be
+ * one cdrom node in an oVirt VM so this should be good
+ * enough for now
+ */
+ g_debug("Setting fake 'name' for cdrom resource");
+ g_object_set(G_OBJECT(cdrom), "name", "cdrom0", NULL);
+ } else {
+ g_free(name);
+ }
+
return TRUE;
}
@@ -137,7 +152,6 @@ static void ovirt_cdrom_class_init(OvirtCdromClass *klass)
"Name of the CD image",
NULL,
G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_property(object_class,
PROP_FILE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]