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

[Xen-changelog] [xen stable-4.4] libxl: cdrom eject and insert: write to /libxl



commit 64282177f44fccf8fa9d8df7e1ab72d59a0fb0c8
Author:     Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
AuthorDate: Fri Apr 29 19:15:13 2016 +0100
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Mon Jun 6 16:14:00 2016 +0100

    libxl: cdrom eject and insert: write to /libxl
    
    Copy the new type and params values to /libxl, so that the information
    in /libxl is kept up to date.
    
    This is needed so that we can return this trustworthy information,
    rather than trusting the backend-writeable parts of xenstore.
    
    This is part of XSA-178.
    
    Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
    Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxl/libxl.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 19c3d90..2f043a7 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2496,7 +2496,8 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, 
libxl_device_disk *disk,
     int rc, dm_ver;
 
     libxl__device device;
-    const char * path;
+    const char *path, *libxl_path;
+    xs_transaction_t t = XBT_NULL;
     char * tmp;
 
     flexarray_t *insert = NULL;
@@ -2557,6 +2558,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, 
libxl_device_disk *disk,
     }
 
     path = libxl__device_backend_path(gc, &device);
+    libxl_path = libxl__device_libxl_path(gc, &device);
 
     /* Sanity check: make sure the backend exists before writing here */
     tmp = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/frontend", 
path));
@@ -2581,9 +2583,22 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, 
libxl_device_disk *disk,
     else
         flexarray_append_pair(insert, "params", "");
 
-    rc = libxl__xs_writev_atonce(gc, path,
-                        libxl__xs_kvs_of_flexarray(gc, insert, insert->count));
-    if (rc) goto out;
+    char **kvs = libxl__xs_kvs_of_flexarray(gc, insert, insert->count);
+
+    for (;;) {
+        rc = libxl__xs_transaction_start(gc, &t);
+        if (rc) goto out;
+
+        rc = libxl__xs_writev(gc, t, path, kvs);
+        if (rc) goto out;
+
+        rc = libxl__xs_writev(gc, t, libxl_path, kvs);
+        if (rc) goto out;
+
+        rc = libxl__xs_transaction_commit(gc, &t);
+        if (!rc) break;
+        if (rc<0) goto out;
+    }
 
     /* success, no actual async */
     libxl__ao_complete(egc, ao, 0);
@@ -2595,6 +2610,8 @@ out:
         libxl_device_disk_dispose(&disks[i]);
     free(disks);
 
+    libxl__xs_transaction_abort(gc, &t);
+
     if (rc) return AO_ABORT(rc);
     return AO_INPROGRESS;
 }
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.4

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.