*/
int
virConnectListDomains(virConnectPtr conn, int *ids, int maxids) {
- struct xs_transaction_handle* t = NULL;
int ret = -1;
unsigned int num, i;
long id;
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;
}
done:
- if ((t != NULL) && (conn->xshandle != NULL))
- xs_transaction_end(conn->xshandle, t, 0);
if (idlist != NULL)
free(idlist);
*/
int
virConnectNumOfDomains(virConnectPtr conn) {
- struct xs_transaction_handle* t;
int ret = -1;
unsigned int num;
char **idlist = NULL;
}
} 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);
*/
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);
}
/**
*/
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))
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);
}
static int
virDomainDoStoreWrite(virDomainPtr domain, const char *path,
const char *value) {
- struct xs_transaction_handle* t;
char s[256];
int ret = -1;
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);
}
char *
virDomainGetVM(virDomainPtr domain)
{
- struct xs_transaction_handle* t;
char *vm;
char query[200];
unsigned int len;
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);
}
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;
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, 0, &s[0], &len);
- ret = xs_read(domain->conn->xshandle, t, &s[0], &len);
-
-done:
- if (t != NULL)
- xs_transaction_end(domain->conn->xshandle, t, 0);
return(ret);
}
*/
virDomainPtr
virDomainLookupByName(virConnectPtr conn, const char *name) {
- struct xs_transaction_handle* t = NULL;
virDomainPtr ret = NULL;
unsigned int num, i, len;
long id = -1;
/* 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;
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);
done:
if (xenddomain != NULL)
free(xenddomain);
- if (t != NULL)
- xs_transaction_end(conn->xshandle, t, 0);
if (idlist != NULL)
free(idlist);
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);
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);
}
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);
}
/**
*/
static int
virDomainGetXMLDevices(virDomainPtr domain, virBufferPtr buf) {
- struct xs_transaction_handle* t;
int ret = -1;
unsigned int num, i;
long id;
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;
}
done:
- if (t != NULL)
- xs_transaction_end(conn->xshandle, t, 0);
if (list != NULL)
free(list);
*/
static int
virDomainGetXMLInterfaces(virDomainPtr domain, virBufferPtr buf) {
- struct xs_transaction_handle* t;
int ret = -1;
unsigned int num, i;
long id;
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;
}
done:
- if (t != NULL)
- xs_transaction_end(conn->xshandle, t, 0);
if (list != NULL)
free(list);