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

[Libvir] [PATCH] Remove XenStore transactions



XenStore transactions aren't actually needed for our current uses of XenStore. Moreover, the type of transactions changed recently from an opaque pointer to an integer type. This breaks the build for newer changesets. The change also introduced an XBT_NULL type but instead of using that (which would break older builds), we can just pass 0.

Regards,

Anthony Liguori
# HG changeset patch
# User Anthony Liguori <anthony codemonkey ws>
# Node ID 9fe0c1f3379e06054ff66a572daad59bbfac3292
# Parent  c028398d53b98baf08eb97192d599fbd311e3dd1
Remove transactions as the type has changed recently breaking the build and
more importantly they aren't actually needed here.

diff -r c028398d53b9 -r 9fe0c1f3379e src/libvir.c
--- a/src/libvir.c	Thu Jan 26 18:11:32 2006 +0000
+++ b/src/libvir.c	Thu Jan 26 17:27:36 2006 -0500
@@ -307,7 +307,6 @@
  */
 int
 virConnectListDomains(virConnectPtr conn, int *ids, int maxids) {
-    struct xs_transaction_handle* t = NULL;
     int ret = -1;
     unsigned int num, i;
     long id;
@@ -330,11 +329,7 @@
 	goto done;
     }
     if (conn->xshandle != NULL) {
-	t = xs_transaction_start(conn->xshandle);
-	if (t == NULL)
-	    goto done;
-
-	idlist = xs_directory(conn->xshandle, t, "/local/domain", &num);
+	idlist = xs_directory(conn->xshandle, 0, "/local/domain", &num);
 	if (idlist == NULL)
 	    goto done;
 
@@ -351,8 +346,6 @@
     }
 
 done:
-    if ((t != NULL) && (conn->xshandle != NULL))
-	xs_transaction_end(conn->xshandle, t, 0);
     if (idlist != NULL)
         free(idlist);
 
@@ -369,7 +362,6 @@
  */
 int
 virConnectNumOfDomains(virConnectPtr conn) {
-    struct xs_transaction_handle* t;
     int ret = -1;
     unsigned int num;
     char **idlist = NULL;
@@ -391,14 +383,10 @@
 	}
 	
     } else if (conn->xshandle != NULL) {
-	t = xs_transaction_start(conn->xshandle);
-	if (t) {
-	    idlist = xs_directory(conn->xshandle, t, "/local/domain", &num);
-	    if (idlist) {
-		free(idlist);
-		ret = num;
-	    }
-	    xs_transaction_end(conn->xshandle, t, 0);
+        idlist = xs_directory(conn->xshandle, 0, "/local/domain", &num);
+	if (idlist) {
+	    free(idlist);
+	    ret = num;
 	}
     }
     return(ret);
@@ -445,23 +433,11 @@
  */
 static char **
 virConnectDoStoreList(virConnectPtr conn, const char *path, unsigned int *nb) {
-    struct xs_transaction_handle* t;
-    char **ret = NULL;
-
     if ((conn == NULL) || (conn->xshandle == NULL) || (path == NULL) ||
         (nb == NULL))
         return(NULL);
 
-    t = xs_transaction_start(conn->xshandle);
-    if (t == NULL)
-        goto done;
-
-    ret = xs_directory(conn->xshandle, t, path, nb);
-
-done:
-    if (t != NULL)
-	xs_transaction_end(conn->xshandle, t, 0);
-    return(ret);
+    return xs_directory(conn->xshandle, 0, path, nb);
 }
 
 /**
@@ -475,9 +451,7 @@
  */
 static char *
 virDomainDoStoreQuery(virDomainPtr domain, const char *path) {
-    struct xs_transaction_handle* t;
     char s[256];
-    char *ret = NULL;
     unsigned int len = 0;
     
     if (!VIR_IS_CONNECTED_DOMAIN(domain))
@@ -488,16 +462,7 @@
     snprintf(s, 255, "/local/domain/%d/%s", domain->handle, path);
     s[255] = 0;
 
-    t = xs_transaction_start(domain->conn->xshandle);
-    if (t == NULL)
-        goto done;
-
-    ret = xs_read(domain->conn->xshandle, t, &s[0], &len);
-
-done:
-    if (t != NULL)
-	xs_transaction_end(domain->conn->xshandle, t, 0);
-    return(ret);
+    return xs_read(domain->conn->xshandle, 0, &s[0], &len);
 }
 
 
@@ -514,7 +479,6 @@
 static int
 virDomainDoStoreWrite(virDomainPtr domain, const char *path,
                       const char *value) {
-    struct xs_transaction_handle* t;
     char s[256];
 
     int ret = -1;
@@ -529,16 +493,9 @@
     snprintf(s, 255, "/local/domain/%d/%s", domain->handle, path);
     s[255] = 0;
 
-    t = xs_transaction_start(domain->conn->xshandle);
-    if (t == NULL)
-        goto done;
-
-    if (xs_write(domain->conn->xshandle, t, &s[0], value, strlen(value)))
+    if (xs_write(domain->conn->xshandle, 0, &s[0], value, strlen(value)))
         ret = 0;
 
-done:
-    if (t != NULL)
-	xs_transaction_end(domain->conn->xshandle, t, 0);
     return(ret);
 }
 
@@ -553,7 +510,6 @@
 char *
 virDomainGetVM(virDomainPtr domain)
 {
-    struct xs_transaction_handle* t;
     char *vm;
     char query[200];
     unsigned int len;
@@ -563,18 +519,11 @@
     if (domain->conn->xshandle == NULL)
         return(NULL);
     
-    t = xs_transaction_start(domain->conn->xshandle);
-    if (t == NULL)
-        return(NULL);
-
     snprintf(query, 199, "/local/domain/%d/vm", 
              virDomainGetID(domain));
     query[199] = 0;
 
-    vm = xs_read(domain->conn->xshandle, t, &query[0], &len);
-
-    if (t != NULL)
-	xs_transaction_end(domain->conn->xshandle, t, 0);
+    vm = xs_read(domain->conn->xshandle, 0, &query[0], &len);
 
     return(vm);
 }
@@ -593,7 +542,6 @@
 char *
 virDomainGetVMInfo(virDomainPtr domain, const char *vm, 
                    const char *name) {
-    struct xs_transaction_handle* t;
     char s[256];
     char *ret = NULL;
     unsigned int len = 0;
@@ -606,15 +554,8 @@
     snprintf(s, 255, "%s/%s", vm, name);
     s[255] = 0;
 
-    t = xs_transaction_start(domain->conn->xshandle);
-    if (t == NULL)
-        goto done;
-
-    ret = xs_read(domain->conn->xshandle, t, &s[0], &len);
-
-done:
-    if (t != NULL)
-	xs_transaction_end(domain->conn->xshandle, t, 0);
+    ret = xs_read(domain->conn->xshandle, 0, &s[0], &len);
+
     return(ret);
 }
 
@@ -696,7 +637,6 @@
  */
 virDomainPtr
 virDomainLookupByName(virConnectPtr conn, const char *name) {
-    struct xs_transaction_handle* t = NULL;
     virDomainPtr ret = NULL;
     unsigned int num, i, len;
     long id = -1;
@@ -722,11 +662,7 @@
 
     /* then though the XenStore */
     if (conn->xshandle != NULL) {
-        t = xs_transaction_start(conn->xshandle);
-        if (t == NULL)
-            goto done;
-
-        idlist = xs_directory(conn->xshandle, t, "/local/domain", &num);
+        idlist = xs_directory(conn->xshandle, 0, "/local/domain", &num);
         if (idlist == NULL)
             goto done;
 
@@ -739,7 +675,7 @@
 	         continue;
              snprintf(prop, 199, "/local/domain/%s/name", idlist[i]);
 	     prop[199] = 0;
-	     tmp = xs_read(conn->xshandle, t, prop, &len);
+	     tmp = xs_read(conn->xshandle, 0, prop, &len);
 	     if (tmp != NULL) {
 	         found = !strcmp(name, tmp);
 	         free(tmp);
@@ -768,8 +704,6 @@
 done:
     if (xenddomain != NULL)
 	free(xenddomain);
-    if (t != NULL)
-	xs_transaction_end(conn->xshandle, t, 0);
     if (idlist != NULL)
         free(idlist);
 
@@ -1121,7 +1055,6 @@
 virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) {
     int ret;
     char s[256], v[30];
-    struct xs_transaction_handle* t;
     
     if (!VIR_IS_CONNECTED_DOMAIN(domain))
 	return(-1);
@@ -1146,12 +1079,8 @@
     snprintf(v, 29, "%lu", memory);
     v[30] = 0;
 
-    t = xs_transaction_start(domain->conn->xshandle);
-    if (t == NULL)
-        return(0);
-
-    xs_write(domain->conn->xshandle, t, &s[0], &v[0], strlen(v));
-    xs_transaction_end(domain->conn->xshandle, t, 0);
+    if (!xs_write(domain->conn->xshandle, 0, &s[0], &v[0], strlen(v)))
+        ret = -1;
 
     return(ret);
 }
diff -r c028398d53b9 -r 9fe0c1f3379e src/xml.c
--- a/src/xml.c	Thu Jan 26 18:11:32 2006 +0000
+++ b/src/xml.c	Thu Jan 26 17:27:36 2006 -0500
@@ -146,25 +146,14 @@
 static char *
 virDomainGetXMLDeviceInfo(virDomainPtr domain, const char *sub, 
                           long dev, const char *name) {
-    struct xs_transaction_handle* t;
     char s[256];
-    char *ret = NULL;
     unsigned int len = 0;
 
     snprintf(s, 255, "/local/domain/0/backend/%s/%d/%ld/%s",
              sub, domain->handle, dev, name);
     s[255] = 0;
 
-    t = xs_transaction_start(domain->conn->xshandle);
-    if (t == NULL)
-        goto done;
-
-    ret = xs_read(domain->conn->xshandle, t, &s[0], &len);
-
-done:
-    if (t != NULL)
-	xs_transaction_end(domain->conn->xshandle, t, 0);
-    return(ret);
+    return xs_read(domain->conn->xshandle, 0, &s[0], &len);
 }
 
 /**
@@ -240,7 +229,6 @@
  */
 static int
 virDomainGetXMLDevices(virDomainPtr domain, virBufferPtr buf) {
-    struct xs_transaction_handle* t;
     int ret = -1;
     unsigned int num, i;
     long id;
@@ -253,14 +241,10 @@
     
     conn = domain->conn;
 
-    t = xs_transaction_start(conn->xshandle);
-    if (t == NULL)
-        goto done;
-
     snprintf(backend, 199, "/local/domain/0/backend/vbd/%d", 
              virDomainGetID(domain));
     backend[199] = 0;
-    list = xs_directory(conn->xshandle, t, backend, &num);
+    list = xs_directory(conn->xshandle, 0, backend, &num);
     ret = 0;
     if (list == NULL)
         goto done;
@@ -275,8 +259,6 @@
     }
 
 done:
-    if (t != NULL)
-	xs_transaction_end(conn->xshandle, t, 0);
     if (list != NULL)
         free(list);
 
@@ -343,7 +325,6 @@
  */
 static int
 virDomainGetXMLInterfaces(virDomainPtr domain, virBufferPtr buf) {
-    struct xs_transaction_handle* t;
     int ret = -1;
     unsigned int num, i;
     long id;
@@ -356,14 +337,10 @@
     
     conn = domain->conn;
 
-    t = xs_transaction_start(conn->xshandle);
-    if (t == NULL)
-        goto done;
-
     snprintf(backend, 199, "/local/domain/0/backend/vif/%d", 
              virDomainGetID(domain));
     backend[199] = 0;
-    list = xs_directory(conn->xshandle, t, backend, &num);
+    list = xs_directory(conn->xshandle, 0, backend, &num);
     ret = 0;
     if (list == NULL)
         goto done;
@@ -378,8 +355,6 @@
     }
 
 done:
-    if (t != NULL)
-	xs_transaction_end(conn->xshandle, t, 0);
     if (list != NULL)
         free(list);
 

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