mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
* include/libxen.h src/libxen.c src/libxen_sym.version src/xensh.c:
changed entry points naming conventions based on feedback with Karel Zak Daniel
This commit is contained in:
parent
f113c5978e
commit
363bb8380f
@ -1,3 +1,9 @@
|
|||||||
|
Thu Dec 1 11:50:16 CET 2005 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* include/libxen.h src/libxen.c src/libxen_sym.version src/xensh.c:
|
||||||
|
changed entry points naming conventions based on feedback with
|
||||||
|
Karel Zak
|
||||||
|
|
||||||
Wed Nov 30 14:18:19 CET 2005 Daniel Veillard <veillard@redhat.com>
|
Wed Nov 30 14:18:19 CET 2005 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* src/Makefile.am src/hash.[ch]: added hash module based on libxml2
|
* src/Makefile.am src/hash.[ch]: added hash module based on libxml2
|
||||||
|
@ -60,38 +60,38 @@ typedef enum {
|
|||||||
/*
|
/*
|
||||||
* Connection and disconnections to the Hypervisor
|
* Connection and disconnections to the Hypervisor
|
||||||
*/
|
*/
|
||||||
xenConnectPtr xenOpenConnect (const char *name);
|
xenConnectPtr xenConnectOpen (const char *name);
|
||||||
int xenCloseConnect (xenConnectPtr conn);
|
int xenConnectClose (xenConnectPtr conn);
|
||||||
unsigned long xenGetVersion (xenConnectPtr conn);
|
unsigned long xenConnectGetVersion (xenConnectPtr conn);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Domain creation and destruction
|
* Domain creation and destruction
|
||||||
*/
|
*/
|
||||||
xenDomainPtr xenCreateLinuxDomain (xenConnectPtr conn,
|
xenDomainPtr xenDomainCreateLinux (xenConnectPtr conn,
|
||||||
const char *kernel_path,
|
const char *kernel_path,
|
||||||
const char *initrd_path,
|
const char *initrd_path,
|
||||||
const char *cmdline,
|
const char *cmdline,
|
||||||
unsigned long memory,
|
unsigned long memory,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
xenDomainPtr xenDomainByName (xenConnectPtr conn,
|
xenDomainPtr xenDomainLookupByName (xenConnectPtr conn,
|
||||||
const char *name);
|
const char *name);
|
||||||
xenDomainPtr xenDomainByID (xenConnectPtr conn,
|
xenDomainPtr xenDomainLookupByID (xenConnectPtr conn,
|
||||||
int id);
|
int id);
|
||||||
int xenDestroyDomain (xenDomainPtr domain);
|
int xenDomainDestroy (xenDomainPtr domain);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Domain suspend/resume
|
* Domain suspend/resume
|
||||||
*/
|
*/
|
||||||
int xenSuspendDomain (xenDomainPtr domain);
|
int xenDomainSuspend (xenDomainPtr domain);
|
||||||
int xenResumeDomain (xenDomainPtr domain);
|
int xenDomainResume (xenDomainPtr domain);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dynamic control of domains
|
* Dynamic control of domains
|
||||||
*/
|
*/
|
||||||
const char * xenGetName (xenDomainPtr domain);
|
const char * xenDomainGetName (xenDomainPtr domain);
|
||||||
unsigned int xenGetID (xenDomainPtr domain);
|
unsigned int xenDomainGetID (xenDomainPtr domain);
|
||||||
unsigned long xenGetMaxMemory (xenDomainPtr domain);
|
unsigned long xenDomainGetMaxMemory (xenDomainPtr domain);
|
||||||
int xenSetMaxMemory (xenDomainPtr domain,
|
int xenDomainSetMaxMemory (xenDomainPtr domain,
|
||||||
unsigned long memory);
|
unsigned long memory);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
58
src/libxen.c
58
src/libxen.c
@ -56,7 +56,7 @@ struct _xenDomain {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenGetConnect:
|
* xenConnectOpen:
|
||||||
* @name: optional argument currently unused, pass NULL
|
* @name: optional argument currently unused, pass NULL
|
||||||
*
|
*
|
||||||
* This function should be called first to get a connection to the
|
* This function should be called first to get a connection to the
|
||||||
@ -65,7 +65,7 @@ struct _xenDomain {
|
|||||||
* Returns a pointer to the hypervisor connection or NULL in case of error
|
* Returns a pointer to the hypervisor connection or NULL in case of error
|
||||||
*/
|
*/
|
||||||
xenConnectPtr
|
xenConnectPtr
|
||||||
xenOpenConnect(const char *name) {
|
xenConnectOpen(const char *name) {
|
||||||
xenConnectPtr ret;
|
xenConnectPtr ret;
|
||||||
int handle = -1;
|
int handle = -1;
|
||||||
struct xs_handle *xshandle = NULL;
|
struct xs_handle *xshandle = NULL;
|
||||||
@ -101,7 +101,7 @@ failed:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDestroyDomainName:
|
* xenDomainDestroyName:
|
||||||
* @domain: a domain object
|
* @domain: a domain object
|
||||||
*
|
*
|
||||||
* Destroy the domain object, this is just used by the domain hash callback.
|
* Destroy the domain object, this is just used by the domain hash callback.
|
||||||
@ -109,12 +109,12 @@ failed:
|
|||||||
* Returns 0 in case of success and -1 in case of failure.
|
* Returns 0 in case of success and -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xenDestroyDomainName(xenDomainPtr domain, const char *name ATTRIBUTE_UNUSED) {
|
xenDomainDestroyName(xenDomainPtr domain, const char *name ATTRIBUTE_UNUSED) {
|
||||||
return(xenDestroyDomain(domain));
|
return(xenDomainDestroy(domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenCloseConnect:
|
* xenConnectClose:
|
||||||
* @conn: pointer to the hypervisor connection
|
* @conn: pointer to the hypervisor connection
|
||||||
*
|
*
|
||||||
* This function closes the connection to the Hypervisor. This should
|
* This function closes the connection to the Hypervisor. This should
|
||||||
@ -125,11 +125,11 @@ xenDestroyDomainName(xenDomainPtr domain, const char *name ATTRIBUTE_UNUSED) {
|
|||||||
* Returns 0 in case of success or -1 in case of error.
|
* Returns 0 in case of success or -1 in case of error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xenCloseConnect(xenConnectPtr conn) {
|
xenConnectClose(xenConnectPtr conn) {
|
||||||
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC))
|
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC))
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
xenHashFree(conn->domains, (xenHashDeallocator) xenDestroyDomainName);
|
xenHashFree(conn->domains, (xenHashDeallocator) xenDomainDestroyName);
|
||||||
conn->magic = -1;
|
conn->magic = -1;
|
||||||
xs_daemon_close(conn->xshandle);
|
xs_daemon_close(conn->xshandle);
|
||||||
conn->xshandle = NULL;
|
conn->xshandle = NULL;
|
||||||
@ -140,7 +140,7 @@ xenCloseConnect(xenConnectPtr conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenGetVersion:
|
* xenConnectGetVersion:
|
||||||
* @conn: pointer to the hypervisor connection
|
* @conn: pointer to the hypervisor connection
|
||||||
*
|
*
|
||||||
* Get the version level of the Hypervisor running.
|
* Get the version level of the Hypervisor running.
|
||||||
@ -148,13 +148,13 @@ xenCloseConnect(xenConnectPtr conn) {
|
|||||||
* Returns -1 in case of error or major * 10,000 + minor * 100 + rev otherwise
|
* Returns -1 in case of error or major * 10,000 + minor * 100 + rev otherwise
|
||||||
*/
|
*/
|
||||||
unsigned long
|
unsigned long
|
||||||
xenGetVersion(xenConnectPtr conn) {
|
xenConnectGetVersion(xenConnectPtr conn) {
|
||||||
if (conn == NULL)
|
if (conn == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenCreateLinuxDomain:
|
* xenDomainCreateLinux:
|
||||||
* @conn: pointer to the hypervisor connection
|
* @conn: pointer to the hypervisor connection
|
||||||
* @kernel_path: the file path to the kernel image
|
* @kernel_path: the file path to the kernel image
|
||||||
* @initrd_path: an optional file path to an initrd
|
* @initrd_path: an optional file path to an initrd
|
||||||
@ -167,7 +167,7 @@ xenGetVersion(xenConnectPtr conn) {
|
|||||||
* Returns a new domain object or NULL in case of failure
|
* Returns a new domain object or NULL in case of failure
|
||||||
*/
|
*/
|
||||||
xenDomainPtr
|
xenDomainPtr
|
||||||
xenCreateLinuxDomain(xenConnectPtr conn, const char *kernel_path,
|
xenDomainCreateLinux(xenConnectPtr conn, const char *kernel_path,
|
||||||
const char *initrd_path, const char *cmdline,
|
const char *initrd_path, const char *cmdline,
|
||||||
unsigned long memory, unsigned int flags) {
|
unsigned long memory, unsigned int flags) {
|
||||||
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) ||
|
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) ||
|
||||||
@ -178,7 +178,7 @@ xenCreateLinuxDomain(xenConnectPtr conn, const char *kernel_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDomainByName:
|
* xenDomainLookupByName:
|
||||||
* @conn: pointer to the hypervisor connection
|
* @conn: pointer to the hypervisor connection
|
||||||
* @name: name for the domain
|
* @name: name for the domain
|
||||||
*
|
*
|
||||||
@ -187,7 +187,7 @@ xenCreateLinuxDomain(xenConnectPtr conn, const char *kernel_path,
|
|||||||
* Returns a new domain object or NULL in case of failure
|
* Returns a new domain object or NULL in case of failure
|
||||||
*/
|
*/
|
||||||
xenDomainPtr
|
xenDomainPtr
|
||||||
xenDomainByName(xenConnectPtr conn, const char *name) {
|
xenDomainLookupByName(xenConnectPtr conn, const char *name) {
|
||||||
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) || (name == NULL))
|
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) || (name == NULL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
TODO
|
TODO
|
||||||
@ -195,7 +195,7 @@ xenDomainByName(xenConnectPtr conn, const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDomainByID:
|
* xenDomainLookupByID:
|
||||||
* @conn: pointer to the hypervisor connection
|
* @conn: pointer to the hypervisor connection
|
||||||
* @id: the domain ID number
|
* @id: the domain ID number
|
||||||
*
|
*
|
||||||
@ -204,7 +204,7 @@ xenDomainByName(xenConnectPtr conn, const char *name) {
|
|||||||
* Returns a new domain object or NULL in case of failure
|
* Returns a new domain object or NULL in case of failure
|
||||||
*/
|
*/
|
||||||
xenDomainPtr
|
xenDomainPtr
|
||||||
xenDomainByID(xenConnectPtr conn, int id) {
|
xenDomainLookupByID(xenConnectPtr conn, int id) {
|
||||||
char *path;
|
char *path;
|
||||||
xenDomainPtr ret;
|
xenDomainPtr ret;
|
||||||
xc_dominfo_t info;
|
xc_dominfo_t info;
|
||||||
@ -236,7 +236,7 @@ xenDomainByID(xenConnectPtr conn, int id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDestroyDomain:
|
* xenDomainDestroy:
|
||||||
* @domain: a domain object
|
* @domain: a domain object
|
||||||
*
|
*
|
||||||
* Destroy the domain object. The running instance is shutdown if not down
|
* Destroy the domain object. The running instance is shutdown if not down
|
||||||
@ -245,7 +245,7 @@ xenDomainByID(xenConnectPtr conn, int id) {
|
|||||||
* Returns 0 in case of success and -1 in case of failure.
|
* Returns 0 in case of success and -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xenDestroyDomain(xenDomainPtr domain) {
|
xenDomainDestroy(xenDomainPtr domain) {
|
||||||
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
||||||
return(-1);
|
return(-1);
|
||||||
TODO
|
TODO
|
||||||
@ -253,7 +253,7 @@ xenDestroyDomain(xenDomainPtr domain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenSuspendDomain:
|
* xenDomainSuspend:
|
||||||
* @domain: a domain object
|
* @domain: a domain object
|
||||||
*
|
*
|
||||||
* Suspends an active domain, the process is frozen without further access
|
* Suspends an active domain, the process is frozen without further access
|
||||||
@ -264,7 +264,7 @@ xenDestroyDomain(xenDomainPtr domain) {
|
|||||||
* Returns 0 in case of success and -1 in case of failure.
|
* Returns 0 in case of success and -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xenSuspendDomain(xenDomainPtr domain) {
|
xenDomainSuspend(xenDomainPtr domain) {
|
||||||
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
||||||
return(-1);
|
return(-1);
|
||||||
TODO
|
TODO
|
||||||
@ -281,7 +281,7 @@ xenSuspendDomain(xenDomainPtr domain) {
|
|||||||
* Returns 0 in case of success and -1 in case of failure.
|
* Returns 0 in case of success and -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xenResumeDomain(xenDomainPtr domain) {
|
xenDomainResume(xenDomainPtr domain) {
|
||||||
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
||||||
return(-1);
|
return(-1);
|
||||||
TODO
|
TODO
|
||||||
@ -289,7 +289,7 @@ xenResumeDomain(xenDomainPtr domain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenGetName:
|
* xenDomainGetName:
|
||||||
* @domain: a domain object
|
* @domain: a domain object
|
||||||
*
|
*
|
||||||
* Get the public name for that domain
|
* Get the public name for that domain
|
||||||
@ -298,14 +298,14 @@ xenResumeDomain(xenDomainPtr domain) {
|
|||||||
* its lifetime will be the same as the domain object.
|
* its lifetime will be the same as the domain object.
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
xenGetName(xenDomainPtr domain) {
|
xenDomainGetName(xenDomainPtr domain) {
|
||||||
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
return(domain->name);
|
return(domain->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenGetID:
|
* xenDomainGetID:
|
||||||
* @domain: a domain object
|
* @domain: a domain object
|
||||||
*
|
*
|
||||||
* Get the hypervisor ID number for the domain
|
* Get the hypervisor ID number for the domain
|
||||||
@ -313,14 +313,14 @@ xenGetName(xenDomainPtr domain) {
|
|||||||
* Returns the domain ID number or (unsigned int) -1 in case of error
|
* Returns the domain ID number or (unsigned int) -1 in case of error
|
||||||
*/
|
*/
|
||||||
unsigned int
|
unsigned int
|
||||||
xenGetID(xenDomainPtr domain) {
|
xenDomainGetID(xenDomainPtr domain) {
|
||||||
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
||||||
return((unsigned int) -1);
|
return((unsigned int) -1);
|
||||||
return(domain->handle);
|
return(domain->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenGetMaxMemory:
|
* xenDomainGetMaxMemory:
|
||||||
* @domain: a domain object or NULL
|
* @domain: a domain object or NULL
|
||||||
*
|
*
|
||||||
* Retrieve the maximum amount of physical memory allocated to a
|
* Retrieve the maximum amount of physical memory allocated to a
|
||||||
@ -330,7 +330,7 @@ xenGetID(xenDomainPtr domain) {
|
|||||||
* Returns the memory size in kilobytes or 0 in case of error.
|
* Returns the memory size in kilobytes or 0 in case of error.
|
||||||
*/
|
*/
|
||||||
unsigned long
|
unsigned long
|
||||||
xenGetMaxMemory(xenDomainPtr domain) {
|
xenDomainGetMaxMemory(xenDomainPtr domain) {
|
||||||
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
||||||
return(0);
|
return(0);
|
||||||
TODO
|
TODO
|
||||||
@ -338,7 +338,7 @@ xenGetMaxMemory(xenDomainPtr domain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenSetMaxMemory:
|
* xenDomainSetMaxMemory:
|
||||||
* @domain: a domain object or NULL
|
* @domain: a domain object or NULL
|
||||||
* @memory: the memory size in kilobytes
|
* @memory: the memory size in kilobytes
|
||||||
*
|
*
|
||||||
@ -349,7 +349,7 @@ xenGetMaxMemory(xenDomainPtr domain) {
|
|||||||
* Returns 0 in case of success and -1 in case of failure.
|
* Returns 0 in case of success and -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xenSetMaxMemory(xenDomainPtr domain, unsigned long memory) {
|
xenDomainSetMaxMemory(xenDomainPtr domain, unsigned long memory) {
|
||||||
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC) ||
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC) ||
|
||||||
(memory < 4096))
|
(memory < 4096))
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
global:
|
global:
|
||||||
xenOpenConnect;
|
xenConnectOpen;
|
||||||
xenCloseConnect;
|
xenConnectClose;
|
||||||
xenGetVersion;
|
xenConnectGetVersion;
|
||||||
xenCreateLinuxDomain;
|
xenDomainCreateLinux;
|
||||||
xenDomainByName;
|
xenDomainLookupByName;
|
||||||
xenDomainByID;
|
xenDomainLookupByID;
|
||||||
xenDestroyDomain;
|
xenDomainDestroy;
|
||||||
xenSuspendDomain;
|
xenDomainSuspend;
|
||||||
xenResumeDomain;
|
xenDomainResume;
|
||||||
xenGetName;
|
xenDomainGetName;
|
||||||
xenGetID;
|
xenDomainGetID;
|
||||||
xenGetMaxMemory;
|
xenDomainGetMaxMemory;
|
||||||
xenSetMaxMemory;
|
xenDomainSetMaxMemory;
|
||||||
local: *;
|
local: *;
|
||||||
};
|
};
|
||||||
|
@ -18,23 +18,24 @@ xenDomainPtr dom0;
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
conn = xenOpenConnect(NULL);
|
conn = xenConnectOpen(NULL);
|
||||||
if (conn == NULL) {
|
if (conn == NULL) {
|
||||||
fprintf(stderr, "Failed to connect to the hypervisor\n");
|
fprintf(stderr, "Failed to connect to the hypervisor\n");
|
||||||
errcode = 1;
|
errcode = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
dom0 = xenDomainByID(conn, 0);
|
dom0 = xenDomainLookupByID(conn, 0);
|
||||||
if (dom0 == NULL) {
|
if (dom0 == NULL) {
|
||||||
fprintf(stderr, "Failed to get domain 0 informations\n");
|
fprintf(stderr, "Failed to get domain 0 informations\n");
|
||||||
errcode = 2;
|
errcode = 2;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
printf("Dom0: name %s, id %d\n", xenGetName(dom0), xenGetID(dom0));
|
printf("Dom0: name %s, id %d\n", xenDomainGetName(dom0),
|
||||||
|
xenDomainGetID(dom0));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (conn != NULL) {
|
if (conn != NULL) {
|
||||||
ret = xenCloseConnect(conn);
|
ret = xenConnectClose(conn);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
fprintf(stderr, "Failed to connect to the hypervisor\n");
|
fprintf(stderr, "Failed to connect to the hypervisor\n");
|
||||||
if (errcode == 0)
|
if (errcode == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user