Skip to content
Newer
Older
100644 375 lines (336 sloc) 12.7 KB
f0a1948 @dmitrii changed volume state machine on NC; cosmetic changes
dmitrii authored Aug 2, 2011
1 // -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
2 // vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
3
054a11a @gholms Update GPL+BSD file headers
gholms authored Jul 17, 2012
4 /*************************************************************************
5 * Copyright 2009-2012 Eucalyptus Systems, Inc.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see http://www.gnu.org/licenses/.
18 *
19 * Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
20 * CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
21 * additional information or have any questions.
22 *
23 * This file may incorporate work covered under the following copyright
24 * and permission notice:
25 *
26 * Software License Agreement (BSD License)
27 *
28 * Copyright (c) 2008, Regents of the University of California
29 * All rights reserved.
30 *
31 * Redistribution and use of this software in source and binary forms,
32 * with or without modification, are permitted provided that the
33 * following conditions are met:
34 *
35 * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 *
38 * Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer
40 * in the documentation and/or other materials provided with the
41 * distribution.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
46 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
47 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
48 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
49 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
51 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
53 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
54 * POSSIBILITY OF SUCH DAMAGE. USERS OF THIS SOFTWARE ACKNOWLEDGE
55 * THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE LICENSED MATERIAL,
56 * COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS SOFTWARE,
57 * AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
58 * IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA,
59 * SANTA BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY,
60 * WHICH IN THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION,
61 * REPLACEMENT OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO
62 * IDENTIFIED, OR WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT
63 * NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
64 ************************************************************************/
48052e3 added license header to source files (not clc/)
root authored Aug 26, 2009
65
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
66 #include <stdio.h>
67 #include <stdlib.h>
6a32280 removed the dangerous run() function (no type checking on args);
Dmitrii Zagorodnov authored Feb 24, 2009
68 #define __USE_GNU /* strnlen */
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
69 #include <string.h> /* strlen, strcpy */
70 #include <time.h>
71 #include <sys/types.h> /* fork */
72 #include <sys/wait.h> /* waitpid */
73 #include <unistd.h>
74 #include <assert.h>
75 #include <errno.h>
76 #include <pthread.h>
77 #include <signal.h> /* SIGINT */
f982b11 newest NC code
root authored Jun 7, 2010
78 #include <sys/stat.h>
79 #include <fcntl.h>
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
80
81 #include "ipc.h"
82 #include "misc.h"
3375b80 merged 'node' from 'main-dev' - everything compiles
Dmitrii Zagorodnov dmitrii@eucalyptus.com authored Apr 27, 2011
83 #include "handlers.h"
84 #include "eucalyptus.h"
85 #include "euca_auth.h"
86 #include "backing.h"
f0a1948 @dmitrii changed volume state machine on NC; cosmetic changes
dmitrii authored Aug 2, 2011
87 #include "xml.h"
e34c72a wrap libvirt calls in hypervisor semaphore
Daniel Nurmi authored Sep 20, 2011
88 #include "diskutil.h"
1b706c6 @sangmin fix RT 4828
sangmin authored Nov 28, 2011
89 #include "iscsi.h"
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
90
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
91 /* coming from handlers.c */
fbb2dab changed xen_sem to hyp_sem (since both xen and kvm uses it).
graziano authored Aug 21, 2009
92 extern sem * hyp_sem;
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
93 extern sem * inst_sem;
94 extern bunchOfInstances * global_instances;
d745164 fix to attach vol on reboot (iscsi).
neil authored Mar 8, 2011
95 extern struct nc_state_t nc_state;
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
96
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
97 #define HYPERVISOR_URI "qemu:///system"
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
98
bc054d2 remove hidden dist target in makefile (it never worked anyway)
graziano authored Aug 18, 2009
99 static int doInitialize (struct nc_state_t *nc)
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
100 {
c480a3c Let's remove getResources since it breaks the logical functions mappi…
graziano authored Aug 24, 2009
101 char *s = NULL;
102
889542a .blobstore rewriting bug fix; more thorough disk stats; corrected all…
root authored Dec 2, 2011
103 // set up paths of Eucalyptus commands NC relies on
e78c81f more MAX_PATH changes
root authored Mar 23, 2010
104 snprintf (nc->get_info_cmd_path, MAX_PATH, EUCALYPTUS_GET_KVM_INFO, nc->home, nc->home);
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
105 strcpy(nc->uri, HYPERVISOR_URI);
106 nc->convert_to_disk = 1;
ae38c6e @dmitrii first try at generating volume attachment XML via XSLT, with correct …
dmitrii authored Nov 29, 2011
107 nc->capability = HYPERVISOR_HARDWARE; // TODO: indicate virtio support?
d8afdd2 moved to a single hypervisor connection for KVM code, too
Dmitrii Zagorodnov authored Jan 30, 2009
108
2a2ab54 I had the init sequence wrong: reorganized it.
graziano authored Aug 21, 2009
109 s = system_output (nc->get_info_cmd_path);
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
110 #define GET_VALUE(name,var) \
2a2ab54 I had the init sequence wrong: reorganized it.
graziano authored Aug 22, 2009
111 if (get_value (s, name, &var)) { \
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
112 logprintfl (EUCAFATAL, "did not find %s in output from %s\n", name, nc->get_info_cmd_path); \
5a8ed2c Check for more memory leaks on error code paths.
graziano authored Oct 10, 2009
113 if (s) free (s); \
2a2ab54 I had the init sequence wrong: reorganized it.
graziano authored Aug 22, 2009
114 return ERROR_FATAL; \
115 }
116
b178324 let's uniform everything to long long for resources.
graziano authored Aug 24, 2009
117 GET_VALUE("nr_cores", nc->cores_max);
c480a3c Let's remove getResources since it breaks the logical functions mappi…
graziano authored Aug 24, 2009
118 GET_VALUE("total_memory", nc->mem_max);
a28fa20 Plugged more leaks on error paths.
graziano obertelli authored Oct 11, 2009
119 if (s) free(s);
120
889542a .blobstore rewriting bug fix; more thorough disk stats; corrected all…
root authored Dec 3, 2011
121 // we leave 256M to the host
c480a3c Let's remove getResources since it breaks the logical functions mappi…
graziano authored Aug 24, 2009
122 nc->mem_max -= 256;
123
2a2ab54 I had the init sequence wrong: reorganized it.
graziano authored Aug 22, 2009
124 return OK;
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
125 }
126
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 27, 2009
127 /* thread that does the actual reboot */
128 static void * rebooting_thread (void *arg)
129 {
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
130 virConnectPtr *conn;
d745164 fix to attach vol on reboot (iscsi).
neil authored Mar 8, 2011
131 ncInstance * instance = (ncInstance *)arg;
2567318 tentative fix to kvm iSCSI attach on reboot.
neil authored Mar 7, 2011
132 struct stat statbuf;
133 int rc = 0;
3375b80 merged 'node' from 'main-dev' - everything compiles
Dmitrii Zagorodnov dmitrii@eucalyptus.com authored Apr 28, 2011
134
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
135 logprintfl (EUCADEBUG, "[%s] spawning rebooting thread\n", instance->instanceId);
3375b80 merged 'node' from 'main-dev' - everything compiles
Dmitrii Zagorodnov dmitrii@eucalyptus.com authored Apr 28, 2011
136 char * xml = file2str (instance->libvirtFilePath);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
137 if (xml == NULL) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
138 logprintfl (EUCAERROR, "[%s] cannot obtain XML file %s\n", instance->instanceId, instance->libvirtFilePath);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
139 return NULL;
140 }
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
141
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
142 conn = check_hypervisor_conn();
143 if (! conn) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
144 logprintfl (EUCAERROR, "[%s] cannot restart instance %s, abandoning it\n", instance->instanceId, instance->instanceId);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
145 change_state (instance, SHUTOFF);
146 free (xml);
147 return NULL;
148 }
e34c72a wrap libvirt calls in hypervisor semaphore
Daniel Nurmi authored Sep 20, 2011
149
150 sem_p (hyp_sem);
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
151 virDomainPtr dom = virDomainLookupByName(*conn, instance->instanceId);
e34c72a wrap libvirt calls in hypervisor semaphore
Daniel Nurmi authored Sep 20, 2011
152 sem_v (hyp_sem);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
153 if (dom == NULL) {
154 free (xml);
155 return NULL;
156 }
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
157
fbb2dab changed xen_sem to hyp_sem (since both xen and kvm uses it).
graziano authored Aug 22, 2009
158 sem_p (hyp_sem);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
159 // for KVM, must stop and restart the instance
28d06d2 trivial: added a comment
Dmitrii Zagorodnov authored Jan 27, 2009
160 int error = virDomainDestroy (dom); // TODO: change to Shutdown? TODO: is this synchronous?
1381710 libDomainShutdown -> Destroy for now, until we figure out Reboot with…
Dmitrii Zagorodnov authored Jan 27, 2009
161 virDomainFree(dom);
d9ab9bb more libvirt hypervisor locks
Daniel Nurmi authored Sep 28, 2011
162 sem_v (hyp_sem);
163
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
164 if (error) {
165 free (xml);
166 return NULL;
167 }
168
169 // domain is now shut down, create a new one with the same XML
fbb2dab changed xen_sem to hyp_sem (since both xen and kvm uses it).
graziano authored Aug 22, 2009
170 sem_p (hyp_sem);
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
171 dom = virDomainCreateLinux (*conn, xml, 0);
fbb2dab changed xen_sem to hyp_sem (since both xen and kvm uses it).
graziano authored Aug 22, 2009
172 sem_v (hyp_sem);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
173 free (xml);
274947d fixes LP: 586542
Neil authored Jun 27, 2010
174
1b706c6 @sangmin fix RT 4828
sangmin authored Nov 29, 2011
175 char *remoteDevStr=NULL;
f0a1948 @dmitrii changed volume state machine on NC; cosmetic changes
dmitrii authored Aug 2, 2011
176 // re-attach each volume previously attached
177 for (int i=0; i < EUCA_MAX_VOLUMES; ++i) {
178 ncVolume * volume = &instance->volumes[i];
179 if (strcmp (volume->stateName, VOL_STATE_ATTACHED) &&
180 strcmp (volume->stateName, VOL_STATE_ATTACHING))
181 continue; // skip the entry unless attached or attaching
182
274947d fixes LP: 586542
Neil authored Jun 28, 2010
183 char attach_xml[1024];
13c5ba1 @dmitrii merged from eee
dmitrii authored Nov 30, 2011
184 int rc;
1b706c6 @sangmin fix RT 4828
sangmin authored Nov 29, 2011
185 // get credentials, decrypt them
186 remoteDevStr = get_iscsi_target (volume->remoteDev);
187 if (!remoteDevStr || !strstr(remoteDevStr, "/dev")) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
188 logprintfl(EUCAERROR, "[%s] Reattach-volume: failed to get local name of host iscsi device\n", instance->instanceId);
13c5ba1 @dmitrii merged from eee
dmitrii authored Nov 30, 2011
189 rc = 1;
190 } else {
191 rc = gen_libvirt_attach_xml (volume->volumeId,
ae38c6e @dmitrii first try at generating volume attachment XML via XSLT, with correct …
dmitrii authored Nov 29, 2011
192 instance,
f0a1948 @dmitrii changed volume state machine on NC; cosmetic changes
dmitrii authored Aug 2, 2011
193 volume->localDevReal,
1b706c6 @sangmin fix RT 4828
sangmin authored Nov 29, 2011
194 remoteDevStr,
f0a1948 @dmitrii changed volume state machine on NC; cosmetic changes
dmitrii authored Aug 2, 2011
195 attach_xml,
196 sizeof(attach_xml));
1b706c6 @sangmin fix RT 4828
sangmin authored Nov 29, 2011
197 }
198
13c5ba1 @dmitrii merged from eee
dmitrii authored Nov 30, 2011
199 if (remoteDevStr)
200 free (remoteDevStr);
1b706c6 @sangmin fix RT 4828
sangmin authored Nov 29, 2011
201
f0a1948 @dmitrii changed volume state machine on NC; cosmetic changes
dmitrii authored Aug 2, 2011
202 if (!rc) {
203 int err;
2567318 tentative fix to kvm iSCSI attach on reboot.
neil authored Mar 8, 2011
204 sem_p (hyp_sem);
205 err = virDomainAttachDevice (dom, attach_xml);
206 sem_v (hyp_sem);
207 if (err) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
208 logprintfl (EUCAERROR, "[%s] virDomainAttachDevice() failed (err=%d) XML=%s\n", instance->instanceId, err, attach_xml);
2567318 tentative fix to kvm iSCSI attach on reboot.
neil authored Mar 8, 2011
209 } else {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
210 logprintfl (EUCAINFO, "[%s] reattached '%s' to '%s' in domain\n", instance->instanceId, volume->remoteDev, volume->localDevReal);
2567318 tentative fix to kvm iSCSI attach on reboot.
neil authored Mar 8, 2011
211 }
f0a1948 @dmitrii changed volume state machine on NC; cosmetic changes
dmitrii authored Aug 2, 2011
212 }
274947d fixes LP: 586542
Neil authored Jun 28, 2010
213 }
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
214 if (dom==NULL) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
215 logprintfl (EUCAERROR, "[%s] Failed to restart instance\n", instance->instanceId);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
216 change_state (instance, SHUTOFF);
217 return NULL;
218 }
219
d9ab9bb more libvirt hypervisor locks
Daniel Nurmi authored Sep 28, 2011
220 sem_p (hyp_sem);
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
221 virDomainFree(dom);
d9ab9bb more libvirt hypervisor locks
Daniel Nurmi authored Sep 28, 2011
222 sem_v (hyp_sem);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
223 return NULL;
224 }
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
225
bc054d2 remove hidden dist target in makefile (it never worked anyway)
graziano authored Aug 19, 2009
226 static int
227 doRebootInstance( struct nc_state_t *nc,
228 ncMetadata *meta,
229 char *instanceId)
230 {
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
231 sem_p (inst_sem);
232 ncInstance *instance = find_instance (&global_instances, instanceId);
233 sem_v (inst_sem);
234 if ( instance == NULL ) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
235 logprintfl (EUCAERROR, "[%s] cannot find instance\n", instanceId);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
236 return ERROR;
237 }
238
239 pthread_t tcb;
240 // since shutdown/restart may take a while, we do them in a thread
d745164 fix to attach vol on reboot (iscsi).
neil authored Mar 8, 2011
241 if ( pthread_create (&tcb, NULL, rebooting_thread, (void *)instance) ) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
242 logprintfl (EUCAERROR, "[%s] failed to spawn a reboot thread\n", instanceId);
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
243 return ERROR_FATAL;
244 }
1430841 ensure that created threads are detached/cleaned up upon thread exit …
root authored Apr 20, 2010
245 if (pthread_detach(tcb)) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
246 logprintfl (EUCAERROR, "[%s] failed to detach the rebooting thread\n", instanceId);
1430841 ensure that created threads are detached/cleaned up upon thread exit …
root authored Apr 20, 2010
247 return ERROR_FATAL;
248 }
86d0182 moved KVM rebooting into a separate thread to avoid timeouts
Dmitrii Zagorodnov authored Jan 28, 2009
249
250 return OK;
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
251 }
252
bc054d2 remove hidden dist target in makefile (it never worked anyway)
graziano authored Aug 19, 2009
253 static int
254 doGetConsoleOutput( struct nc_state_t *nc,
255 ncMetadata *meta,
256 char *instanceId,
257 char **consoleOutput) {
6e8bb65 some null check cleanup
root authored May 9, 2010
258
259 char *console_output=NULL, *console_append=NULL, *console_main=NULL;
2deb69c fix up serviceInfo workaround, metadata re-direct workaround, and fix…
root authored Mar 2, 2011
260 char console_file[MAX_PATH], userId[48];
6e8bb65 some null check cleanup
root authored May 9, 2010
261 int rc, fd, ret, readsize;
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
262 struct stat statbuf;
2deb69c fix up serviceInfo workaround, metadata re-direct workaround, and fix…
root authored Mar 3, 2011
263 ncInstance *instance=NULL;
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
264
265 *consoleOutput = NULL;
a84061a read last 64k of console output in NC
root authored Apr 23, 2010
266 readsize = 64 * 1024;
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
267
2deb69c fix up serviceInfo workaround, metadata re-direct workaround, and fix…
root authored Mar 3, 2011
268 // find the instance record
269 sem_p (inst_sem);
270 instance = find_instance(&global_instances, instanceId);
271 if (instance) {
3375b80 merged 'node' from 'main-dev' - everything compiles
Dmitrii Zagorodnov dmitrii@eucalyptus.com authored Apr 28, 2011
272 snprintf(console_file, 1024, "%s/console.append.log", instance->instancePath);
273 snprintf(userId, 48, "%s", instance->userId);
2deb69c fix up serviceInfo workaround, metadata re-direct workaround, and fix…
root authored Mar 3, 2011
274 }
275 sem_v (inst_sem);
3375b80 merged 'node' from 'main-dev' - everything compiles
Dmitrii Zagorodnov dmitrii@eucalyptus.com authored Apr 28, 2011
276
2deb69c fix up serviceInfo workaround, metadata re-direct workaround, and fix…
root authored Mar 3, 2011
277 if (!instance) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
278 logprintfl(EUCAERROR, "[%s] cannot locate instance\n", instanceId);
2deb69c fix up serviceInfo workaround, metadata re-direct workaround, and fix…
root authored Mar 3, 2011
279 return(1);
280 }
281
ccdb7a4 fixing get-console-output on RHEL 6 + KVM
root authored Apr 1, 2012
282 // read from console.append.log if it exists into dynamically allocated 4K console_append buffer
6e8bb65 some null check cleanup
root authored May 9, 2010
283 rc = stat(console_file, &statbuf);
284 if (rc >= 0) {
ccdb7a4 fixing get-console-output on RHEL 6 + KVM
root authored Apr 1, 2012
285 if (diskutil_ch (console_file, nc->admin_user_id, nc->admin_user_id, 0) != OK) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
286 logprintfl (EUCAERROR, "[%s] failed to change ownership of %s\n", instanceId, console_file);
ccdb7a4 fixing get-console-output on RHEL 6 + KVM
root authored Apr 1, 2012
287 return (1);
288 }
6e8bb65 some null check cleanup
root authored May 9, 2010
289 fd = open(console_file, O_RDONLY);
290 if (fd >= 0) {
291 console_append = malloc(4096);
292 if (console_append) {
293 bzero(console_append, 4096);
294 rc = read(fd, console_append, (4096)-1);
295 close(fd);
296 }
297 }
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
298 }
299
3375b80 merged 'node' from 'main-dev' - everything compiles
Dmitrii Zagorodnov dmitrii@eucalyptus.com authored Apr 28, 2011
300 sem_p (inst_sem);
301 snprintf(console_file, MAX_PATH, "%s/console.log", instance->instancePath);
302 sem_v (inst_sem);
6e8bb65 some null check cleanup
root authored May 9, 2010
303
ccdb7a4 fixing get-console-output on RHEL 6 + KVM
root authored Apr 1, 2012
304 // read the last 64K from console.log or the whole file, if smaller, into dynamically allocated 64K console_main buffer
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
305 rc = stat(console_file, &statbuf);
6e8bb65 some null check cleanup
root authored May 9, 2010
306 if (rc >= 0) {
ccdb7a4 fixing get-console-output on RHEL 6 + KVM
root authored Apr 1, 2012
307 if (diskutil_ch (console_file, nc->admin_user_id, nc->admin_user_id, 0) != OK) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
308 logprintfl (EUCAERROR, "[%s] failed to change ownership of %s\n", instanceId, console_file);
ccdb7a4 fixing get-console-output on RHEL 6 + KVM
root authored Apr 1, 2012
309 if (console_append)
310 free(console_append);
311 return (1);
312 }
6e8bb65 some null check cleanup
root authored May 9, 2010
313 fd = open(console_file, O_RDONLY);
314 if (fd >= 0) {
315 rc = lseek(fd, (off_t)(-1 * readsize), SEEK_END);
316 if (rc < 0) {
317 rc = lseek(fd, (off_t)0, SEEK_SET);
318 if (rc < 0) {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
319 logprintfl(EUCAERROR, "[%s] cannot seek to beginning of file\n", instanceId);
6e8bb65 some null check cleanup
root authored May 9, 2010
320 if (console_append) free(console_append);
321 return(1);
322 }
323 }
324 console_main = malloc(readsize);
325 if (console_main) {
326 bzero(console_main, readsize);
327 rc = read(fd, console_main, (readsize)-1);
328 close(fd);
329 }
330 } else {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
331 logprintfl(EUCAERROR, "[%s] cannot open '%s' read-only\n", instanceId, console_file);
6e8bb65 some null check cleanup
root authored May 9, 2010
332 }
333 } else {
2bbac1d @gelinasc Fixes EUCA-2208
gelinasc authored Oct 5, 2012
334 logprintfl(EUCAERROR, "[%s] cannot stat console_output file '%s'\n", instanceId, console_file);
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
335 }
336
ccdb7a4 fixing get-console-output on RHEL 6 + KVM
root authored Apr 1, 2012
337 // concatenate console_append with console_main, base64-encode this, and put into dynamically allocated buffer consoleOutput
6e8bb65 some null check cleanup
root authored May 9, 2010
338 ret = 1;
339 console_output = malloc( (readsize) + 4096 );
340 if (console_output) {
341 bzero(console_output, (readsize) + 4096 );
342 if (console_append) {
343 strncat(console_output, console_append, 4096);
a84061a read last 64k of console output in NC
root authored Apr 23, 2010
344 }
6e8bb65 some null check cleanup
root authored May 9, 2010
345 if (console_main) {
346 strncat(console_output, console_main, readsize);
347 }
348 *consoleOutput = base64_enc((unsigned char *)console_output, strlen(console_output));
349 ret = 0;
a84061a read last 64k of console output in NC
root authored Apr 23, 2010
350 }
6e8bb65 some null check cleanup
root authored May 9, 2010
351
352 if (console_append) free(console_append);
353 if (console_main) free(console_main);
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
354 if (console_output) free(console_output);
6e8bb65 some null check cleanup
root authored May 9, 2010
355
356 return(ret);
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
357 }
358
359 struct handlers kvm_libvirt_handlers = {
360 .name = "kvm",
361 .doInitialize = doInitialize,
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
362 .doDescribeInstances = NULL,
c7dd988 @dmitrii more vbr-related adjustments; moved runInstance handler to _default
dmitrii authored Sep 14, 2010
363 .doRunInstance = NULL,
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
364 .doTerminateInstance = NULL,
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
365 .doRebootInstance = doRebootInstance,
366 .doGetConsoleOutput = doGetConsoleOutput,
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
367 .doDescribeResource = NULL,
368 .doStartNetwork = NULL,
2fb6e8e add ncAssignAddress to recover public IPs past restart
root authored Dec 7, 2010
369 .doAssignAddress = NULL,
53fc754 removed dummy handler (it was outdated).
graziano authored Aug 14, 2009
370 .doPowerDown = NULL,
f0a1948 @dmitrii changed volume state machine on NC; cosmetic changes
dmitrii authored Aug 2, 2011
371 .doAttachVolume = NULL,
e418678 @dmitrii sensor stub on the NC coded, but not tested
dmitrii authored Aug 3, 2012
372 .doDetachVolume = NULL,
373 .doDescribeSensors = NULL
0f37b51 added KVM support (driver)
root authored Jan 19, 2009
374 };
Something went wrong with that request. Please try again.