mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
Removed obsolete / unused code
This commit is contained in:
parent
4f2fcbd905
commit
ed02290129
@ -1,3 +1,8 @@
|
|||||||
|
Thu Feb 8 12:59:14 EST 2007 Daniel Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* src/xml.c, src/xend_internal.c, src/xend_internal.h: Remove
|
||||||
|
obsolete / unused code.
|
||||||
|
|
||||||
Wed Feb 7 11:30:14 EST 2007 Daniel Berrange <berrange@redhat.com>
|
Wed Feb 7 11:30:14 EST 2007 Daniel Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
* autobuild.sh, src/Makefile.am: Added a control file for
|
* autobuild.sh, src/Makefile.am: Added a control file for
|
||||||
|
@ -742,51 +742,6 @@ sexpr_u64(struct sexpr *sexpr, const char *name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
sexpr_strlen(struct sexpr *sexpr, const char *path)
|
|
||||||
{
|
|
||||||
const char *r = sexpr_node(sexpr, path);
|
|
||||||
|
|
||||||
return r ? (strlen(r) + 1) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
sexpr_strcpy(char **ptr, struct sexpr *node, const char *path)
|
|
||||||
{
|
|
||||||
const char *ret = sexpr_node(node, path);
|
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
strcpy(*ptr, ret);
|
|
||||||
ret = *ptr;
|
|
||||||
*ptr += (strlen(ret) + 1);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sexpr_node_system:
|
|
||||||
* @sexpr: an S-Expression
|
|
||||||
* @name: the name for the value
|
|
||||||
*
|
|
||||||
* convenience function to lookup a value describing the kind of system
|
|
||||||
* from the S-Expression
|
|
||||||
*
|
|
||||||
* Returns the value found or 0 if not found (but may not be an error)
|
|
||||||
*/
|
|
||||||
static enum xend_node_system
|
|
||||||
sexpr_node_system(struct sexpr *node, const char *path)
|
|
||||||
{
|
|
||||||
const char *syst = sexpr_node(node, path);
|
|
||||||
|
|
||||||
if (syst) {
|
|
||||||
if (strcmp(syst, "Linux") == 0) {
|
|
||||||
return XEND_SYSTEM_LINUX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return XEND_DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sexpr_uuid:
|
* sexpr_uuid:
|
||||||
@ -940,48 +895,6 @@ xend_wait_for_devices(virConnectPtr xend, const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xend_rename:
|
|
||||||
* @xend: pointer to the Xem Daemon block
|
|
||||||
* @old: old name for the domain
|
|
||||||
* @new: new name for the domain
|
|
||||||
*
|
|
||||||
* Rename the domain
|
|
||||||
*
|
|
||||||
* Returns 0 in case of success, -1 (with errno) in case of error.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xend_rename(virConnectPtr xend, const char *old, const char *new)
|
|
||||||
{
|
|
||||||
if ((xend == NULL) || (old == NULL) || (new == NULL)) {
|
|
||||||
/* this should be caught at the interface but ... */
|
|
||||||
virXendError(xend, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
return xend_op(xend, old, "op", "rename", "name", new, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xend_sysrq:
|
|
||||||
* @xend: pointer to the Xem Daemon block
|
|
||||||
* @name: name for the domain
|
|
||||||
* @key: the SysReq key
|
|
||||||
*
|
|
||||||
* Send a SysReq key which is used to debug Linux kernels running in the domain
|
|
||||||
*
|
|
||||||
* Returns 0 in case of success, -1 (with errno) in case of error.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xend_sysrq(virConnectPtr xend, const char *name, const char *key)
|
|
||||||
{
|
|
||||||
if ((xend == NULL) || (name == NULL) || (key == NULL)) {
|
|
||||||
/* this should be caught at the interface but ... */
|
|
||||||
virXendError(xend, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
return xend_op(xend, name, "op", "sysrq", "key", key, NULL);
|
|
||||||
}
|
|
||||||
#endif /* PROXY */
|
#endif /* PROXY */
|
||||||
|
|
||||||
|
|
||||||
@ -1186,91 +1099,6 @@ error:
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* xend_get_node:
|
|
||||||
* @xend: A xend instance
|
|
||||||
*
|
|
||||||
* This method returns information about the physical host
|
|
||||||
* machine running Xen.
|
|
||||||
*
|
|
||||||
* Returns node info on success; NULL (with errno) on error
|
|
||||||
*/
|
|
||||||
struct xend_node *
|
|
||||||
xend_get_node(virConnectPtr xend)
|
|
||||||
{
|
|
||||||
struct sexpr *root;
|
|
||||||
struct xend_node *node = NULL;
|
|
||||||
size_t size;
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
root = sexpr_get(xend, "/xend/node/");
|
|
||||||
if (root == NULL)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
size = sizeof(struct xend_node);
|
|
||||||
size += sexpr_strlen(root, "node/host");
|
|
||||||
size += sexpr_strlen(root, "node/release");
|
|
||||||
size += sexpr_strlen(root, "node/version");
|
|
||||||
size += sexpr_strlen(root, "node/machine");
|
|
||||||
size += sexpr_strlen(root, "node/hw_caps");
|
|
||||||
size += sexpr_strlen(root, "node/xen_caps");
|
|
||||||
size += sexpr_strlen(root, "node/platform_params");
|
|
||||||
size += sexpr_strlen(root, "node/xen_changeset");
|
|
||||||
size += sexpr_strlen(root, "node/cc_compiler");
|
|
||||||
size += sexpr_strlen(root, "node/cc_compile_by");
|
|
||||||
size += sexpr_strlen(root, "node/cc_compile_domain");
|
|
||||||
size += sexpr_strlen(root, "node/cc_compile_date");
|
|
||||||
|
|
||||||
ptr = malloc(size);
|
|
||||||
if (ptr == NULL)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
node = (struct xend_node *) ptr;
|
|
||||||
ptr += sizeof(struct xend_node);
|
|
||||||
|
|
||||||
node->system = sexpr_node_system(root, "node/system");
|
|
||||||
node->host = sexpr_strcpy(&ptr, root, "node/host");
|
|
||||||
node->release = sexpr_strcpy(&ptr, root, "node/release");
|
|
||||||
node->version = sexpr_strcpy(&ptr, root, "node/version");
|
|
||||||
node->machine = sexpr_strcpy(&ptr, root, "node/machine");
|
|
||||||
node->nr_cpus = sexpr_int(root, "node/nr_cpus");
|
|
||||||
node->nr_nodes = sexpr_int(root, "node/nr_nodes");
|
|
||||||
node->sockets_per_node = sexpr_int(root, "node/sockets_per_node");
|
|
||||||
node->cores_per_socket = sexpr_int(root, "node/cores_per_socket");
|
|
||||||
node->threads_per_core = sexpr_int(root, "node/threads_per_core");
|
|
||||||
node->cpu_mhz = sexpr_int(root, "node/cpu_mhz");
|
|
||||||
node->hw_caps = sexpr_strcpy(&ptr, root, "node/hw_caps");
|
|
||||||
node->total_memory = sexpr_u64(root, "node/total_memory") << 12;
|
|
||||||
node->free_memory = sexpr_u64(root, "node/free_memory") << 12;
|
|
||||||
node->xen_major = sexpr_int(root, "node/xen_major");
|
|
||||||
node->xen_minor = sexpr_int(root, "node/xen_minor");
|
|
||||||
{
|
|
||||||
const char *tmp;
|
|
||||||
|
|
||||||
tmp = sexpr_node(root, "node/xen_extra");
|
|
||||||
if (tmp) {
|
|
||||||
if (*tmp == '.')
|
|
||||||
tmp++;
|
|
||||||
node->xen_extra = atoi(tmp);
|
|
||||||
} else {
|
|
||||||
node->xen_extra = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node->xen_caps = sexpr_strcpy(&ptr, root, "node/xen_caps");
|
|
||||||
node->platform_params =
|
|
||||||
sexpr_strcpy(&ptr, root, "node/platform_params");
|
|
||||||
node->xen_changeset = sexpr_strcpy(&ptr, root, "node/xen_changeset");
|
|
||||||
node->cc_compiler = sexpr_strcpy(&ptr, root, "node/cc_compiler");
|
|
||||||
node->cc_compile_by = sexpr_strcpy(&ptr, root, "node/cc_compile_by");
|
|
||||||
node->cc_compile_domain =
|
|
||||||
sexpr_strcpy(&ptr, root, "node/cc_compile_domain");
|
|
||||||
node->cc_compile_date =
|
|
||||||
sexpr_strcpy(&ptr, root, "node/cc_compile_date");
|
|
||||||
|
|
||||||
error:
|
|
||||||
sexpr_free(root);
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xend_detect_config_version(virConnectPtr conn) {
|
xend_detect_config_version(virConnectPtr conn) {
|
||||||
|
@ -24,425 +24,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
Use the default setting as determined by Xend.
|
|
||||||
*/
|
|
||||||
#define XEND_DEFAULT 0
|
|
||||||
|
|
||||||
/**
|
|
||||||
This structure represents a virtual block device.
|
|
||||||
*/
|
|
||||||
struct xend_device_vbd {
|
|
||||||
|
|
||||||
/**
|
|
||||||
The domain ID of the backend.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
int backend;
|
|
||||||
|
|
||||||
/**
|
|
||||||
A URI representing the device. This is typically in the form
|
|
||||||
file:/path/to/image or phy:/dev/device
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
const char *uname;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The name (or number) of the device to expose to the frontend.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
const char *dev;
|
|
||||||
|
|
||||||
/**
|
|
||||||
A flag specifying the permissions to expose the device with.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
virDeviceMode mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
This structure represents a range of PIO to enable for a guest.
|
|
||||||
*/
|
|
||||||
struct xend_device_ioport {
|
|
||||||
|
|
||||||
/**
|
|
||||||
The beginning address of an ioport range to enable.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
uint16_t from;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The ending address of an ioport range to enable.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
uint16_t to;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
This structure represents a virtual network interface configuration.
|
|
||||||
*/
|
|
||||||
struct xend_device_vif {
|
|
||||||
|
|
||||||
/**
|
|
||||||
A string representing the domain that will serve as the backend for
|
|
||||||
this device.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
int backend;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The name of the bridge device to pass to the network script.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
const char *bridge;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The ip address to configure the virtal network device with.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
const char *ip;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The mac address to use for the virtual network device.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
uint8_t mac[6];
|
|
||||||
|
|
||||||
/**
|
|
||||||
The path to the network script that is to be used for initializing
|
|
||||||
the network device.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
const char *script;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The name of the vif. The primary use for this is to allow the user
|
|
||||||
to operate on vifs by name.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
const char *vifname;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct xend_domain_live {
|
|
||||||
|
|
||||||
/**
|
|
||||||
true is domain is currently scheduled.
|
|
||||||
*/
|
|
||||||
bool running;
|
|
||||||
|
|
||||||
/**
|
|
||||||
true is domain has crashed.
|
|
||||||
*/
|
|
||||||
bool crashed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
true if domain has been shutdown.
|
|
||||||
*/
|
|
||||||
bool poweroff;
|
|
||||||
|
|
||||||
/**
|
|
||||||
true if domain has requested a reboot.
|
|
||||||
*/
|
|
||||||
bool reboot;
|
|
||||||
|
|
||||||
/**
|
|
||||||
true if domain has requested a suspend.
|
|
||||||
*/
|
|
||||||
bool suspend;
|
|
||||||
|
|
||||||
/**
|
|
||||||
true if domain is blocked on IO
|
|
||||||
*/
|
|
||||||
bool blocked;
|
|
||||||
|
|
||||||
/**
|
|
||||||
true if domain has been destroyed but resources are not
|
|
||||||
fully deallocated.
|
|
||||||
*/
|
|
||||||
bool dying;
|
|
||||||
|
|
||||||
/**
|
|
||||||
true if domain is paused.
|
|
||||||
*/
|
|
||||||
bool paused;
|
|
||||||
|
|
||||||
/**
|
|
||||||
the amount of time the domain has been running (in seconds)
|
|
||||||
*/
|
|
||||||
double cpu_time;
|
|
||||||
|
|
||||||
/**
|
|
||||||
the wall clock time since the domain was created (in seconds)
|
|
||||||
*/
|
|
||||||
double up_time;
|
|
||||||
|
|
||||||
/**
|
|
||||||
the time (in seconds since epoch) the domain was created
|
|
||||||
*/
|
|
||||||
double start_time;
|
|
||||||
|
|
||||||
/**
|
|
||||||
the number of enabled VCPUs
|
|
||||||
*/
|
|
||||||
int online_vcpus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
the total number of available VCPUs
|
|
||||||
*/
|
|
||||||
int vcpu_avail;
|
|
||||||
|
|
||||||
/**
|
|
||||||
the domain id number
|
|
||||||
*/
|
|
||||||
int id;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
This structure represents the configuration of a domain. It's primary
|
|
||||||
purpose (currently) is for domain creation.
|
|
||||||
*/
|
|
||||||
struct xend_domain {
|
|
||||||
|
|
||||||
/**
|
|
||||||
The name of the domain.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
const char *name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The amount of memory to assign to the domain before creation.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
uint64_t memory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The maximum amount of memory that can be given to the domain
|
|
||||||
while it's running. Please note that a domain can increase its
|
|
||||||
memory on its own while running up to this value.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
uint64_t max_memory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The uuid to use to identify the domain. This is compatible with
|
|
||||||
libuuid's uuid_t and should be able to be used interchangably.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
unsigned char *uuid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The ssidref to assign to the domain.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
int ssidref;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The action to perform when the domain powers off.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
virDomainRestart on_poweroff;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The action to perform when the domain reboots.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
virDomainRestart on_reboot;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The action to perform when the domain crashes.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
virDomainRestart on_crash;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The number of VCPUs to assign to the domain.
|
|
||||||
|
|
||||||
Required.
|
|
||||||
*/
|
|
||||||
int vcpus;
|
|
||||||
|
|
||||||
/* FIXME cpus */
|
|
||||||
|
|
||||||
virDomainKernel image;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The number of VBDs pointed to be vbds.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
size_t n_vbds;
|
|
||||||
struct xend_device_vbd *vbds;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The number of IO port ranges pointed to by ioports.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
size_t n_ioports;
|
|
||||||
struct xend_device_ioport *ioports;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The number of VIFs pointed to be vifs.
|
|
||||||
|
|
||||||
Optional.
|
|
||||||
*/
|
|
||||||
size_t n_vifs;
|
|
||||||
struct xend_device_vif *vifs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
A pointer to run-time information about the domain.
|
|
||||||
|
|
||||||
Only set by xen_get_domain().
|
|
||||||
*/
|
|
||||||
struct xend_domain_live *live;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum xend_node_system {
|
|
||||||
XEND_SYSTEM_LINUX = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct xend_node {
|
|
||||||
|
|
||||||
/**
|
|
||||||
An enumeration value specifying the host system.
|
|
||||||
*/
|
|
||||||
enum xend_node_system system;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The DNS host name.
|
|
||||||
*/
|
|
||||||
const char *host;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The dom0 kernel release string.
|
|
||||||
*/
|
|
||||||
const char *release;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The result of uname -v.
|
|
||||||
*/
|
|
||||||
const char *version;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The machine type.
|
|
||||||
*/
|
|
||||||
const char *machine;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The number of physical cpus.
|
|
||||||
*/
|
|
||||||
int nr_cpus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The number of NUMA nodes.
|
|
||||||
*/
|
|
||||||
int nr_nodes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The number of sockets per NUMA node.
|
|
||||||
*/
|
|
||||||
int sockets_per_node;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The number of cores per NUMA socket.
|
|
||||||
*/
|
|
||||||
int cores_per_socket;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The number of hyperthreads per core.
|
|
||||||
*/
|
|
||||||
int threads_per_core;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The clock rating (in megahertz) of each core.
|
|
||||||
*/
|
|
||||||
int cpu_mhz;
|
|
||||||
|
|
||||||
/**
|
|
||||||
I honestly don't know what this is.
|
|
||||||
*/
|
|
||||||
const char *hw_caps;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The total memory (in bytes).
|
|
||||||
*/
|
|
||||||
uint64_t total_memory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The free memory (in bytes).
|
|
||||||
*/
|
|
||||||
uint64_t free_memory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The Xen major version number.
|
|
||||||
*/
|
|
||||||
int xen_major;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The Xen minor version number.
|
|
||||||
*/
|
|
||||||
int xen_minor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The Xen extra version number.
|
|
||||||
*/
|
|
||||||
int xen_extra;
|
|
||||||
|
|
||||||
/**
|
|
||||||
A string descirbing the Xen platform.
|
|
||||||
*/
|
|
||||||
const char *xen_caps;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Dunno.
|
|
||||||
*/
|
|
||||||
const char *platform_params;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The build changeset.
|
|
||||||
*/
|
|
||||||
const char *xen_changeset;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The compiler version.
|
|
||||||
*/
|
|
||||||
const char *cc_compiler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The user that compiled this binary.
|
|
||||||
*/
|
|
||||||
const char *cc_compile_by;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The system this binary was built on.
|
|
||||||
*/
|
|
||||||
const char *cc_compile_domain;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The date that this binary was built on.
|
|
||||||
*/
|
|
||||||
const char *cc_compile_date;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Setup the connection to a xend instance via TCP
|
* \brief Setup the connection to a xend instance via TCP
|
||||||
@ -486,28 +67,6 @@ int xenDaemonOpen_unix(virConnectPtr xend, const char *path);
|
|||||||
*/
|
*/
|
||||||
int xend_wait_for_devices(virConnectPtr xend, const char *name);
|
int xend_wait_for_devices(virConnectPtr xend, const char *name);
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Rename a domain
|
|
||||||
* \param xend A xend instance
|
|
||||||
* \param oldname The domain's name
|
|
||||||
* \param name The new name
|
|
||||||
* \return 0 for success; -1 (with errno) on error
|
|
||||||
*
|
|
||||||
* This method allows a domain to have its name changed after creation.
|
|
||||||
*/
|
|
||||||
int xend_rename(virConnectPtr xend, const char *oldname,
|
|
||||||
const char *name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Sends a SYSRQ to a domain
|
|
||||||
* \param xend A xend instance
|
|
||||||
* \param name The domain's name
|
|
||||||
* \param key The key that was held during the SYSRQ
|
|
||||||
* \return 0 for success; -1 (with errno) on error
|
|
||||||
*
|
|
||||||
* This method simulates the pressing of a SYSRQ sequence.
|
|
||||||
*/
|
|
||||||
int xend_sysrq(virConnectPtr xend, const char *name, const char *key);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Create a new domain
|
* \brief Create a new domain
|
||||||
|
360
src/xml.c
360
src/xml.c
@ -209,366 +209,6 @@ virBufferStrcat(virBufferPtr buf, ...)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This block of function are now implemented by a xend poll in
|
|
||||||
* xend_internal.c instead of querying the Xen store, code is kept
|
|
||||||
* for reference of in case Xend may not be available in the future ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virDomainGetXMLDevice:
|
|
||||||
* @domain: a domain object
|
|
||||||
* @sub: the xenstore subsection 'vbd', 'vif', ...
|
|
||||||
* @dev: the xenstrore internal device number
|
|
||||||
* @name: the value's name
|
|
||||||
*
|
|
||||||
* Extract one information the device used by the domain from xensttore
|
|
||||||
*
|
|
||||||
* Returns the new string or NULL in case of error
|
|
||||||
*/
|
|
||||||
static char *
|
|
||||||
virDomainGetXMLDeviceInfo(virDomainPtr domain, const char *sub,
|
|
||||||
long dev, const char *name)
|
|
||||||
{
|
|
||||||
char s[256];
|
|
||||||
unsigned int len = 0;
|
|
||||||
|
|
||||||
snprintf(s, 255, "/local/domain/0/backend/%s/%d/%ld/%s",
|
|
||||||
sub, domain->id, dev, name);
|
|
||||||
s[255] = 0;
|
|
||||||
|
|
||||||
return xs_read(domain->conn->xshandle, 0, &s[0], &len);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virDomainGetXMLDevice:
|
|
||||||
* @domain: a domain object
|
|
||||||
* @buf: the output buffer object
|
|
||||||
* @dev: the xenstrore internal device number
|
|
||||||
*
|
|
||||||
* Extract and dump in the buffer information on the device used by the domain
|
|
||||||
*
|
|
||||||
* Returns 0 in case of success, -1 in case of failure
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
virDomainGetXMLDevice(virDomainPtr domain, virBufferPtr buf, long dev)
|
|
||||||
{
|
|
||||||
char *type, *val;
|
|
||||||
|
|
||||||
type = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "type");
|
|
||||||
if (type == NULL)
|
|
||||||
return (-1);
|
|
||||||
if (!strcmp(type, "file")) {
|
|
||||||
virBufferVSprintf(buf, " <disk type='file'>\n");
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "params");
|
|
||||||
if (val != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <source file='%s'/>\n", val);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "dev");
|
|
||||||
if (val != NULL) {
|
|
||||||
char *tmp = val;
|
|
||||||
if (!strncmp(tmp, "ioemu:", 6))
|
|
||||||
tmp += 6;
|
|
||||||
virBufferVSprintf(buf, " <target dev='%s'/>\n", tmp);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "read-only");
|
|
||||||
if (val != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <readonly/>\n", val);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
virBufferAdd(buf, " </disk>\n", 12);
|
|
||||||
} else if (!strcmp(type, "phy")) {
|
|
||||||
virBufferVSprintf(buf, " <disk type='device'>\n");
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "params");
|
|
||||||
if (val != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <source device='%s'/>\n", val);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "dev");
|
|
||||||
if (val != NULL) {
|
|
||||||
char *tmp = val;
|
|
||||||
if (!strncmp(tmp, "ioemu:", 6))
|
|
||||||
tmp += 6;
|
|
||||||
virBufferVSprintf(buf, " <target dev='%s'/>\n", tmp);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "read-only");
|
|
||||||
if (val != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <readonly/>\n", val);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
virBufferAdd(buf, " </disk>\n", 12);
|
|
||||||
} else {
|
|
||||||
TODO fprintf(stderr, "Don't know how to handle device type %s\n",
|
|
||||||
type);
|
|
||||||
}
|
|
||||||
free(type);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virDomainGetXMLDevices:
|
|
||||||
* @domain: a domain object
|
|
||||||
* @buf: the output buffer object
|
|
||||||
*
|
|
||||||
* Extract the devices used by the domain and dumps then in the buffer
|
|
||||||
*
|
|
||||||
* Returns 0 in case of success, -1 in case of failure
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
virDomainGetXMLDevices(virDomainPtr domain, virBufferPtr buf)
|
|
||||||
{
|
|
||||||
int ret = -1;
|
|
||||||
unsigned int num, i;
|
|
||||||
long id;
|
|
||||||
char **list = NULL, *endptr;
|
|
||||||
char backend[200];
|
|
||||||
virConnectPtr conn;
|
|
||||||
|
|
||||||
if (!VIR_IS_CONNECTED_DOMAIN(domain))
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
conn = domain->conn;
|
|
||||||
|
|
||||||
snprintf(backend, 199, "/local/domain/0/backend/vbd/%d",
|
|
||||||
virDomainGetID(domain));
|
|
||||||
backend[199] = 0;
|
|
||||||
list = xs_directory(conn->xshandle, 0, backend, &num);
|
|
||||||
ret = 0;
|
|
||||||
if (list == NULL)
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
|
||||||
id = strtol(list[i], &endptr, 10);
|
|
||||||
if ((endptr == list[i]) || (*endptr != 0)) {
|
|
||||||
ret = -1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
virDomainGetXMLDevice(domain, buf, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
|
||||||
if (list != NULL)
|
|
||||||
free(list);
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virDomainGetXMLInterface:
|
|
||||||
* @domain: a domain object
|
|
||||||
* @buf: the output buffer object
|
|
||||||
* @dev: the xenstrore internal device number
|
|
||||||
*
|
|
||||||
* Extract and dump in the buffer information on the interface used by
|
|
||||||
* the domain
|
|
||||||
*
|
|
||||||
* Returns 0 in case of success, -1 in case of failure
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
virDomainGetXMLInterface(virDomainPtr domain, virBufferPtr buf, long dev)
|
|
||||||
{
|
|
||||||
char *type, *val;
|
|
||||||
|
|
||||||
type = virDomainGetXMLDeviceInfo(domain, "vif", dev, "bridge");
|
|
||||||
if (type == NULL) {
|
|
||||||
virBufferVSprintf(buf, " <interface type='default'>\n");
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vif", dev, "mac");
|
|
||||||
if (val != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <mac address='%s'/>\n", val);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vif", dev, "script");
|
|
||||||
if (val != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <script path='%s'/>\n", val);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
virBufferAdd(buf, " </interface>\n", 17);
|
|
||||||
} else {
|
|
||||||
virBufferVSprintf(buf, " <interface type='bridge'>\n");
|
|
||||||
virBufferVSprintf(buf, " <source bridge='%s'/>\n", type);
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vif", dev, "mac");
|
|
||||||
if (val != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <mac address='%s'/>\n", val);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
val = virDomainGetXMLDeviceInfo(domain, "vif", dev, "script");
|
|
||||||
if (val != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <script path='%s'/>\n", val);
|
|
||||||
free(val);
|
|
||||||
}
|
|
||||||
virBufferAdd(buf, " </interface>\n", 17);
|
|
||||||
}
|
|
||||||
free(type);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virDomainGetXMLInterfaces:
|
|
||||||
* @domain: a domain object
|
|
||||||
* @buf: the output buffer object
|
|
||||||
*
|
|
||||||
* Extract the interfaces used by the domain and dumps then in the buffer
|
|
||||||
*
|
|
||||||
* Returns 0 in case of success, -1 in case of failure
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
virDomainGetXMLInterfaces(virDomainPtr domain, virBufferPtr buf)
|
|
||||||
{
|
|
||||||
int ret = -1;
|
|
||||||
unsigned int num, i;
|
|
||||||
long id;
|
|
||||||
char **list = NULL, *endptr;
|
|
||||||
char backend[200];
|
|
||||||
virConnectPtr conn;
|
|
||||||
|
|
||||||
if (!VIR_IS_CONNECTED_DOMAIN(domain))
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
conn = domain->conn;
|
|
||||||
|
|
||||||
snprintf(backend, 199, "/local/domain/0/backend/vif/%d",
|
|
||||||
virDomainGetID(domain));
|
|
||||||
backend[199] = 0;
|
|
||||||
list = xs_directory(conn->xshandle, 0, backend, &num);
|
|
||||||
ret = 0;
|
|
||||||
if (list == NULL)
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
|
||||||
id = strtol(list[i], &endptr, 10);
|
|
||||||
if ((endptr == list[i]) || (*endptr != 0)) {
|
|
||||||
ret = -1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
virDomainGetXMLInterface(domain, buf, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
|
||||||
if (list != NULL)
|
|
||||||
free(list);
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virDomainGetXMLBoot:
|
|
||||||
* @domain: a domain object
|
|
||||||
* @buf: the output buffer object
|
|
||||||
*
|
|
||||||
* Extract the boot information used to start that domain
|
|
||||||
*
|
|
||||||
* Returns 0 in case of success, -1 in case of failure
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
virDomainGetXMLBoot(virDomainPtr domain, virBufferPtr buf)
|
|
||||||
{
|
|
||||||
char *vm, *str;
|
|
||||||
|
|
||||||
if (!VIR_IS_DOMAIN(domain))
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
vm = virDomainGetVM(domain);
|
|
||||||
if (vm == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
virBufferAdd(buf, " <os>\n", 7);
|
|
||||||
str = virDomainGetVMInfo(domain, vm, "image/ostype");
|
|
||||||
if (str != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <type>%s</type>\n", str);
|
|
||||||
free(str);
|
|
||||||
}
|
|
||||||
str = virDomainGetVMInfo(domain, vm, "image/kernel");
|
|
||||||
if (str != NULL) {
|
|
||||||
virBufferVSprintf(buf, " <kernel>%s</kernel>\n", str);
|
|
||||||
free(str);
|
|
||||||
}
|
|
||||||
str = virDomainGetVMInfo(domain, vm, "image/ramdisk");
|
|
||||||
if (str != NULL) {
|
|
||||||
if (str[0] != 0)
|
|
||||||
virBufferVSprintf(buf, " <initrd>%s</initrd>\n", str);
|
|
||||||
free(str);
|
|
||||||
}
|
|
||||||
str = virDomainGetVMInfo(domain, vm, "image/cmdline");
|
|
||||||
if (str != NULL) {
|
|
||||||
if (str[0] != 0)
|
|
||||||
virBufferVSprintf(buf, " <cmdline>%s</cmdline>\n", str);
|
|
||||||
free(str);
|
|
||||||
}
|
|
||||||
virBufferAdd(buf, " </os>\n", 8);
|
|
||||||
|
|
||||||
free(vm);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* virDomainGetXMLDesc:
|
|
||||||
* @domain: a domain object
|
|
||||||
* @flags: and OR'ed set of extraction flags, not used yet
|
|
||||||
*
|
|
||||||
* Provide an XML description of the domain. NOTE: this API is subject
|
|
||||||
* to changes.
|
|
||||||
*
|
|
||||||
* Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of error.
|
|
||||||
* the caller must free() the returned value.
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
|
||||||
{
|
|
||||||
char *ret = NULL;
|
|
||||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
|
||||||
virBuffer buf;
|
|
||||||
virDomainInfo info;
|
|
||||||
|
|
||||||
if (!VIR_IS_DOMAIN(domain))
|
|
||||||
return (NULL);
|
|
||||||
if (flags != 0)
|
|
||||||
return (NULL);
|
|
||||||
if (virDomainGetInfo(domain, &info) < 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
ret = malloc(1000);
|
|
||||||
if (ret == NULL)
|
|
||||||
return (NULL);
|
|
||||||
buf.content = ret;
|
|
||||||
buf.size = 1000;
|
|
||||||
buf.use = 0;
|
|
||||||
|
|
||||||
virBufferVSprintf(&buf, "<domain type='xen' id='%d'>\n",
|
|
||||||
virDomainGetID(domain));
|
|
||||||
virBufferVSprintf(&buf, " <name>%s</name>\n",
|
|
||||||
virDomainGetName(domain));
|
|
||||||
if (virDomainGetUUID(domain, &uuid[0]) == 0) {
|
|
||||||
virBufferVSprintf(&buf,
|
|
||||||
" <uuid>%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x</uuid>\n",
|
|
||||||
uuid[0], uuid[1], uuid[2], uuid[3],
|
|
||||||
uuid[4], uuid[5], uuid[6], uuid[7],
|
|
||||||
uuid[8], uuid[9], uuid[10], uuid[11],
|
|
||||||
uuid[12], uuid[13], uuid[14], uuid[15]);
|
|
||||||
}
|
|
||||||
virDomainGetXMLBoot(domain, &buf);
|
|
||||||
virBufferVSprintf(&buf, " <memory>%lu</memory>\n", info.maxMem);
|
|
||||||
virBufferVSprintf(&buf, " <vcpu>%d</vcpu>\n", (int) info.nrVirtCpu);
|
|
||||||
virBufferAdd(&buf, " <devices>\n", 12);
|
|
||||||
virDomainGetXMLDevices(domain, &buf);
|
|
||||||
virDomainGetXMLInterfaces(domain, &buf);
|
|
||||||
virBufferAdd(&buf, " </devices>\n", 13);
|
|
||||||
virBufferAdd(&buf, "</domain>\n", 10);
|
|
||||||
|
|
||||||
buf.content[buf.use] = 0;
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* 0 - UNUSED */
|
|
||||||
|
|
||||||
#ifndef PROXY
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user