]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
* src/xend_internal.c: applied patch from Hugh Brock to allow
authorDaniel Veillard <veillard@redhat.com>
Mon, 10 Sep 2007 11:47:17 +0000 (11:47 +0000)
committerDaniel Veillard <veillard@redhat.com>
Mon, 10 Sep 2007 11:47:17 +0000 (11:47 +0000)
  CD Rom device reload by reusing virDomainAttachDevice() with
  a new definition
Daniel

ChangeLog
src/xend_internal.c

index 51153341bea9dbcd8c1679e9694024bc4230a908..3aa8676ece126108819e2de10492d3f4bd9c5b33 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Sep 10 13:46:05 CEST 2007 Daniel Veillard <veillard@redhat.com>
+
+       * src/xend_internal.c: applied patch from Hugh Brock to allow
+         CD Rom device reload by reusing virDomainAttachDevice() with
+         a new definition
+
 Mon Sep 10 11:35:06 CEST 2007 Daniel Veillard <veillard@redhat.com>
 
        * include/libvirt/libvirt.h include/libvirt/libvirt.h.in
index 0bd42a700f6516db68e0604d320b716de8ea5430..64557fcb75d40e09d915d0865a400df0ce44b91d 100644 (file)
@@ -3087,6 +3087,7 @@ xenDaemonAttachDevice(virDomainPtr domain, char *xml)
     char *sexpr, *conf, *str;
     int hvm = 0, ret;
     xenUnifiedPrivatePtr priv;
+    char class[8], ref[80];
 
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
         virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
@@ -3116,8 +3117,16 @@ xenDaemonAttachDevice(virDomainPtr domain, char *xml)
         *(conf + strlen(conf) -1) = 0; /* suppress final ) */
     }
     else conf = sexpr;
-    ret = xend_op(domain->conn, domain->name, "op", "device_create",
-        "config", conf, NULL);
+    if (virDomainXMLDevID(domain, xml, class, ref)) {
+        /* device doesn't exist, define it */
+        ret = xend_op(domain->conn, domain->name, "op", "device_create",
+                      "config", conf, NULL);
+    } 
+    else {
+        /* device exists, attempt to modify it */
+        ret = xend_op(domain->conn, domain->name, "op", "device_configure", 
+                      "config", conf, "dev", ref, NULL);
+    }
     free(sexpr);
     return ret;
 }