[libgovirt] cdrom: Allow empty filename when serializing to XML



commit bdb788fcced810b45d7c02882c80114477576a46
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Mon Sep 22 14:11:07 2014 +0200

    cdrom: Allow empty filename when serializing to XML
    
    Removing a CDROM image from a VM is achieved by updating the current VM
    file to be "". The code currently forbid NULL filenames in update
    requests, this commit removes this limitation so that it's possible to
    remove a CD image from a VM through libgovirt.

 govirt/ovirt-cdrom.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/govirt/ovirt-cdrom.c b/govirt/ovirt-cdrom.c
index 020159c..d852403 100644
--- a/govirt/ovirt-cdrom.c
+++ b/govirt/ovirt-cdrom.c
@@ -151,13 +151,16 @@ static gboolean ovirt_cdrom_init_from_xml(OvirtResource *resource,
 static char *ovirt_cdrom_to_xml(OvirtResource *resource)
 {
     OvirtCdrom *cdrom;
+    const char *file;
 
     g_return_val_if_fail(OVIRT_IS_CDROM(resource), NULL);
     cdrom = OVIRT_CDROM(resource);
-    g_return_val_if_fail(cdrom->priv->file != NULL, NULL);
+    file = cdrom->priv->file;
+    if (file == NULL) {
+        file = "";
+    }
 
-    return g_strdup_printf("<cdrom>\n\t<file id=\"%s\"/>\n</cdrom>",
-                           cdrom->priv->file);
+    return g_strdup_printf("<cdrom>\n\t<file id=\"%s\"/>\n</cdrom>", file);
 }
 
 


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