From ed02290129e909e1ff00e39eff4d9bfd6f6b9c58 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 8 Feb 2007 19:10:25 +0000 Subject: [PATCH] Removed obsolete / unused code --- ChangeLog | 5 + src/xend_internal.c | 172 ----------------- src/xend_internal.h | 441 -------------------------------------------- src/xml.c | 360 ------------------------------------ 4 files changed, 5 insertions(+), 973 deletions(-) diff --git a/ChangeLog b/ChangeLog index ca9c1180ba..c73e17961f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Feb 8 12:59:14 EST 2007 Daniel Berrange + + * 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 * autobuild.sh, src/Makefile.am: Added a control file for diff --git a/src/xend_internal.c b/src/xend_internal.c index de818bb467..71056a9188 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -742,51 +742,6 @@ sexpr_u64(struct sexpr *sexpr, const char *name) 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: @@ -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 */ @@ -1186,91 +1099,6 @@ error: 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 xend_detect_config_version(virConnectPtr conn) { diff --git a/src/xend_internal.h b/src/xend_internal.h index 95daf9087d..796d885feb 100644 --- a/src/xend_internal.h +++ b/src/xend_internal.h @@ -24,425 +24,6 @@ extern "C" { #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 @@ -486,28 +67,6 @@ int xenDaemonOpen_unix(virConnectPtr xend, const char *path); */ 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 diff --git a/src/xml.c b/src/xml.c index 15f4938993..b89a420efc 100644 --- a/src/xml.c +++ b/src/xml.c @@ -209,366 +209,6 @@ virBufferStrcat(virBufferPtr buf, ...) 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, " \n"); - val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "params"); - if (val != NULL) { - virBufferVSprintf(buf, " \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, " \n", tmp); - free(val); - } - val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "read-only"); - if (val != NULL) { - virBufferVSprintf(buf, " \n", val); - free(val); - } - virBufferAdd(buf, " \n", 12); - } else if (!strcmp(type, "phy")) { - virBufferVSprintf(buf, " \n"); - val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "params"); - if (val != NULL) { - virBufferVSprintf(buf, " \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, " \n", tmp); - free(val); - } - val = virDomainGetXMLDeviceInfo(domain, "vbd", dev, "read-only"); - if (val != NULL) { - virBufferVSprintf(buf, " \n", val); - free(val); - } - virBufferAdd(buf, " \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, " \n"); - val = virDomainGetXMLDeviceInfo(domain, "vif", dev, "mac"); - if (val != NULL) { - virBufferVSprintf(buf, " \n", val); - free(val); - } - val = virDomainGetXMLDeviceInfo(domain, "vif", dev, "script"); - if (val != NULL) { - virBufferVSprintf(buf, "