Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 157918 Details for
Bug 243872
fence_xvmd doesn't reboot VM
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Allows hvm rebooting
fence-xvm-hvm-fix.patch (text/plain), 9.55 KB, created by
Lon Hohberger
on 2007-06-26 17:15:12 UTC
(
hide
)
Description:
Allows hvm rebooting
Filename:
MIME Type:
Creator:
Lon Hohberger
Created:
2007-06-26 17:15:12 UTC
Size:
9.55 KB
patch
obsolete
>Index: Makefile >=================================================================== >RCS file: /cvs/cluster/cluster/fence/agents/xvm/Makefile,v >retrieving revision 1.3.2.2 >diff -u -p -r1.3.2.2 Makefile >--- Makefile 13 Nov 2006 20:50:34 -0000 1.3.2.2 >+++ Makefile 26 Jun 2007 17:04:30 -0000 >@@ -18,19 +18,20 @@ TARGETS=fence_xvm fence_xvmd > fence_xvm_SOURCE = fence_xvm.c mcast.c ip_lookup.c simple_auth.c tcp.c \ > options.c debug.c > fence_xvmd_SOURCE= fence_xvmd.c mcast.c simple_auth.c tcp.c virt.c \ >- options.c options-ccs.c vm_states.c debug.c >+ options.c options-ccs.c vm_states.c debug.c \ >+ xml.c > > > INCLUDE=-I${top_srcdir}/include -I${top_srcdir}/config \ > -I/usr/include/openais -I/usr/include/libvirt \ > -I/usr/include/nss3 -I/usr/include/nspr4 \ >- -I../../../cman/lib -I../../../ccs/lib >+ -I../../../cman/lib -I../../../ccs/lib -I/usr/include/libxml2 > > CFLAGS+=-DFENCE_RELEASE_NAME=\"${RELEASE}\" \ > -Wall -Werror -Wstrict-prototypes -Wshadow -ggdb -D_GNU_SOURCE > > LIBS+=-L../../../cman/lib -L../../../ccs/lib -L${libdir}/openais \ >- -L../../../dlm/lib -lnss3 >+ -L../../../dlm/lib -lnss3 -lxml2 > > all: ${TARGETS} > >Index: fence_xvmd.c >=================================================================== >RCS file: /cvs/cluster/cluster/fence/agents/xvm/fence_xvmd.c,v >retrieving revision 1.4.2.4 >diff -u -p -r1.4.2.4 fence_xvmd.c >--- fence_xvmd.c 10 Jan 2007 20:25:58 -0000 1.4.2.4 >+++ fence_xvmd.c 26 Jun 2007 17:04:30 -0000 >@@ -55,6 +55,9 @@ > > static int running = 1; > >+ >+int cleanup_xml(char *xmldesc, char **ret, size_t *retsz); >+ > int > connect_tcp(fence_req_t *req, fence_auth_type_t auth, > void *key, size_t key_len) >@@ -165,48 +168,6 @@ get_domain(fence_req_t *req, virConnectP > } > > >-/* >- Nuke the OS block if this domain was booted using a bootloader. >- XXX We probably should use libxml2 to do this, but this is very fast >- */ >-void >-cleanup_xmldesc(char *xmldesc) >-{ >- char *start = NULL; >- char *end = NULL; >- >-#define STARTBOOTTAG "<bootloader>" >-#define ENDBOOTTAG "</bootloader>" >-#define STARTOSTAG "<os>" >-#define ENDOSTAG "</os>" >- >- /* Part 1: Check for a boot loader */ >- start = strcasestr(xmldesc, STARTBOOTTAG); >- if (start) { >- start += strlen(STARTBOOTTAG); >- end = strcasestr(start, ENDBOOTTAG); >- if (end == start) { >- /* Empty bootloader tag -> return */ >- return; >- } >- } >- >- /* Part 2: Nuke the <os> tag */ >- start = strcasestr(xmldesc, STARTOSTAG); >- if (!start) >- return; >- end = strcasestr(start, ENDOSTAG); >- if (!end) >- return; >- end += strlen(ENDOSTAG); >- >- dprintf(3, "Clearing %d bytes starting @ %p\n", (int)(end-start), >- start); >- >- memset(start, ' ', end-start); >-} >- >- > static inline int > wait_domain(fence_req_t *req, virConnectPtr vp, int timeout) > { >@@ -262,7 +223,8 @@ do_fence_request_tcp(fence_req_t *req, f > int fd, ret = -1; > virDomainPtr vdp; > char response = 1; >- char *domain_desc; >+ char *domain_desc, *domain_desc_sanitized; >+ size_t sz; > > if (!(vdp = get_domain(req, vp))) { > dprintf(2, "Could not find domain: %s\n", req->domain); >@@ -305,7 +267,14 @@ do_fence_request_tcp(fence_req_t *req, f > if (domain_desc) { > dprintf(3, "[[ XML Domain Info ]]\n"); > dprintf(3, "%s\n[[ XML END ]]\n", domain_desc); >- cleanup_xmldesc(domain_desc); >+ >+ sz = 0; >+ if (cleanup_xml(domain_desc, >+ &domain_desc_sanitized, &sz) == 0) { >+ free(domain_desc); >+ domain_desc = domain_desc_sanitized; >+ } >+ > dprintf(3, "[[ XML Domain Info (modified) ]]\n"); > dprintf(3, "%s\n[[ XML END ]]\n", domain_desc); > } else { >@@ -431,7 +400,7 @@ get_domain_state_ckpt(void *hp, unsigned > > if (!hp || !domain || !state || !strlen((char *)domain)) > return -1; >- if (!strcmp("Domain-0", (char *)domain)) >+ if (!strcmp(DOMAIN0NAME, (char *)domain)) > return -1; > > return ckpt_read(hp, (char *)domain, state, sizeof(*state)); >@@ -735,8 +704,10 @@ main(int argc, char **argv) > if (args.auth != AUTH_NONE || args.hash != HASH_NONE) { > key_len = read_key_file(args.key_file, key, sizeof(key)); > if (key_len < 0) { >- printf("Could not read key file\n"); >- return 1; >+ printf("Could not read %s; operating without " >+ "authentication\n", args.key_file); >+ args.auth = AUTH_NONE; >+ args.hash = HASH_NONE; > } > } > >Index: xml.c >=================================================================== >RCS file: xml.c >diff -N xml.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ xml.c 26 Jun 2007 17:04:30 -0000 >@@ -0,0 +1,306 @@ >+#include <libxml/xmlmemory.h> >+#include <libxml/parser.h> >+#include <string.h> >+#include <fcntl.h> >+#include <errno.h> >+#include <stdio.h> >+#include <stdlib.h> >+#include <unistd.h> >+#include <ctype.h> >+ >+ >+xmlNodePtr >+get_os_node(xmlDocPtr doc) >+{ >+ xmlNodePtr node; >+ >+ /* Flip the property of the graphics port if it exists */ >+ node = xmlDocGetRootElement(doc); >+ node = node->children; >+ >+ while (node) { >+ if (!xmlStrcmp(node->name, (xmlChar *)"os")) >+ break; >+ node = node->next; >+ } >+ >+ return node; >+} >+ >+ >+int >+flip_graphics_port(xmlDocPtr doc) >+{ >+ xmlNodePtr node, curr; >+ >+ /* Flip the property of the graphics port if it exists */ >+ node = xmlDocGetRootElement(doc); >+ node = node->children; >+ >+ while (node) { >+ if (!xmlStrcmp(node->name, (xmlChar *)"devices")) >+ break; >+ node = node->next; >+ } >+ >+ node = node->children; >+ curr = node; >+ while (curr) { >+ if (!xmlStrcmp(curr->name, (xmlChar *)"graphics")) >+ break; >+ curr = curr->next; >+ } >+ >+ if (xmlGetProp(curr, (xmlChar *)"port")) { >+ printf("Zapping the port spec\n"); >+ xmlSetProp(curr, (xmlChar *)"port", (xmlChar *)"-1"); >+ } >+ >+ return 0; >+} >+ >+ >+int >+cleanup_xml_doc(xmlDocPtr doc) >+{ >+ xmlNodePtr os_node, curr; >+ int type = 0; >+ char *val; >+ >+ curr = xmlDocGetRootElement(doc); >+ if (xmlStrcmp(curr->name, (xmlChar *)"domain")) { >+ printf("Invalid XML\n"); >+ return -1; >+ } >+ >+ flip_graphics_port(doc); >+ >+ os_node = get_os_node(doc); >+ >+ curr = os_node->children; >+ while (curr) { >+ if (!xmlStrcmp(curr->name, (xmlChar *)"type")) >+ break; >+ curr = curr->next; >+ } >+ if (!curr) { >+ printf("Unable to determine the domain type\n"); >+ return -1; >+ } >+ >+ val = (char *)xmlNodeGetContent(curr); >+ while (isspace(*val)) val++; >+ >+ if (!strcasecmp(val, "hvm")) { >+ type = 1; >+ printf("Virtual machine is HVM\n"); >+ } else if (!strcasecmp(val, "linux")) { >+ type = 2; >+ printf("Virtual machine is Linux\n"); >+ } >+ >+ /* Node is still pointing to the <os> block */ >+ if (type == 2) { >+ printf("Unlinkiking %s block\n", (char *)os_node->name); >+ xmlUnlinkNode(os_node); >+ xmlFreeNode(os_node); >+ } >+ >+ return 0; >+} >+ >+ >+int >+xtree_readfile(const char *filename, xmlDocPtr *xtreep) >+{ >+ xmlNodePtr cur; >+ >+ xmlKeepBlanksDefault(0); >+ xmlIndentTreeOutput = 1; >+ >+ *xtreep = xmlParseFile(filename); >+ >+ if (!*xtreep) >+ return -1; >+ >+ if (!((cur = xmlDocGetRootElement(*xtreep)))) { >+ xmlFreeDoc(*xtreep); >+ *xtreep = NULL; >+ return -1; >+ } >+ >+ return 0; >+} >+ >+ >+int >+xtree_readbuffer(const char *buffer, size_t size, xmlDocPtr *xtreep) >+{ >+ xmlNodePtr cur; >+ >+ xmlKeepBlanksDefault(0); >+ xmlIndentTreeOutput = 1; >+ >+ *xtreep = xmlParseMemory(buffer, size); >+ >+ if (!*xtreep) { >+ printf("parse failure %p %d\n", buffer, (int)size); >+ return -1; >+ } >+ >+ if (!((cur = xmlDocGetRootElement(*xtreep)))) { >+ printf("root element failure\n"); >+ xmlFreeDoc(*xtreep); >+ *xtreep = NULL; >+ return -1; >+ } >+ >+ return 0; >+} >+ >+ >+int >+xtree_writefile(const char *filename, xmlDocPtr xtree) >+{ >+ char tmpfn[1024]; >+ int fd, tmpfd; >+ xmlChar *buffer; >+ struct flock flock; >+ int n, remain, written, size = 0; >+ >+ snprintf(tmpfn, sizeof(tmpfn), "%s.XXXXXX", filename); >+ tmpfd = mkstemp(tmpfn); >+ if (tmpfd == -1) >+ return -1; >+ >+ memset(&flock, 0, sizeof(flock)); >+ flock.l_type = F_WRLCK; >+ >+ fd = open(filename, O_WRONLY | O_CREAT | O_SYNC); >+ if (fd == -1) { >+ n = errno; >+ close(tmpfd); >+ unlink(tmpfn); >+ errno = n; >+ return -1; >+ } >+ >+ while (fcntl(fd, F_SETLKW, &flock) == -1) { >+ if (errno == EINTR) >+ continue; >+ n = errno; >+ close(fd); >+ close(tmpfd); >+ unlink(tmpfn); >+ errno = n; >+ return -1; >+ } >+ >+ xmlDocDumpFormatMemory(xtree, (xmlChar **)&buffer, (int *)&size, 1); >+ >+ written = 0; >+ remain = size; >+ while (remain) { >+ n = write(tmpfd, buffer + written, remain); >+ >+ if (n == -1) { >+ if (errno == EINTR) >+ continue; >+ >+ free(buffer); >+ n = errno; >+ close(fd); >+ close(tmpfd); >+ unlink(tmpfn); >+ errno = n; >+ return -1; >+ } >+ >+ written += n; >+ remain -= n; >+ } >+ >+ xmlFree(buffer); >+ if (rename(tmpfn, filename) == -1) { >+ n = errno; >+ close(fd); >+ close(tmpfd); >+ unlink(tmpfn); >+ errno = n; >+ return -1; >+ } >+ >+ close(fd); >+ fsync(tmpfd); >+ close(tmpfd); >+ return 0; >+} >+ >+ >+int >+xtree_writebuffer(xmlDocPtr xtree, char **buffer, size_t *size) >+{ >+ *size = 0; >+ xmlDocDumpFormatMemory(xtree, (xmlChar **)buffer, (int *)size, 1); >+ return 0; >+} >+ >+ >+int >+cleanup_xml(char *desc, char **ret, size_t *retsz) >+{ >+ xmlDocPtr xtree; >+ int rv; >+ >+ *ret = NULL; >+ if (xtree_readbuffer(desc, strlen(desc), &xtree) < 0) { >+ xmlCleanupParser(); >+ return -1; >+ } >+ >+ rv = cleanup_xml_doc(xtree); >+ if (xtree_writebuffer(xtree, ret, retsz) < 0) >+ rv = -1; >+ >+ if (*ret && rv < 0) >+ free(*ret); >+ xmlFreeDoc(xtree); >+ xmlCleanupParser(); >+ return rv; >+} >+ >+ >+#ifdef STANDALONE >+int >+main(int argc, char **argv) >+{ >+ char *file = NULL; >+ char *buf; >+ size_t sz; >+ int opt; >+ xmlDocPtr xtree; >+ >+ while ((opt = getopt(argc, argv, "f:")) != EOF) { >+ switch(opt) { >+ case 'f': >+ file = optarg; >+ break; >+ } >+ } >+ >+ if (!file) { >+ printf("No file specified\n"); >+ return 1; >+ } >+ >+ if (xtree_readfile(file, &xtree) < 0) >+ return -1; >+ >+ cleanup_xml(xtree); >+ >+ xtree_writebuffer(xtree, &buf, &sz); >+ write(1, buf, sz); >+ >+ return 0; >+} >+#endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 243872
:
157757
| 157918