top = kmalloc(sizeof(struct top_half_data), GFP_KERNEL);
if (IS_ERR(top)) {
- printk("Palacios Error: could not allocate space for top half data\n");
+ ERROR("Palacios Error: could not allocate space for top half data\n");
return -EFAULT;
}
memset(top, 0, sizeof(struct top_half_data));
- printk("Palacios: Loading ELF data...\n");
+ INFO("Palacios: Loading ELF data...\n");
if (copy_from_user(&top_arg, (void __user *)arg, sizeof(struct top_half_data))) {
- printk("palacios: error copying ELF from userspace\n");
+ ERROR("palacios: error copying ELF from userspace\n");
return -EFAULT;
}
if (top_arg.is_exec_hooked) {
strcpy(top->bin_file, top_arg.bin_file);
top->is_exec_hooked = 1;
- printk("top->bin_file is %s\n", top->bin_file);
+ DEBUG("top->bin_file is %s\n", top->bin_file);
}
- printk("Palacios: Allocating %lu B of kernel memory for ELF binary data...\n", top->elf_size);
+ DEBUG("Palacios: Allocating %lu B of kernel memory for ELF binary data...\n", top->elf_size);
top->elf_data = kmalloc(top->elf_size, GFP_KERNEL);
if (IS_ERR(top->elf_data)) {
- printk("Palacios Error: could not allocate space for binary image\n");
+ ERROR("Palacios Error: could not allocate space for binary image\n");
return -EFAULT;
}
memset(top->elf_data, 0, top->elf_size);
- printk("Palacios: Copying ELF image into kernel module...\n");
+ INFO("Palacios: Copying ELF image into kernel module...\n");
if (copy_from_user(top->elf_data, (void __user *)top_arg.elf_data, top->elf_size)) {
- printk("Palacios: Error loading elf data\n");
+ ERROR("Palacios: Error loading elf data\n");
return -EFAULT;
}
if (register_top(top) < 0)
return -1;
- printk("Palacios: setting up inject code...\n");
+ INFO("Palacios: setting up inject code...\n");
if (v3_insert_code_inject(guest->v3_ctx, top->elf_data, top->elf_size,
top->bin_file, top->is_dyn, top->is_exec_hooked, top->func_offset) < 0) {
- printk("Palacios Error: error setting up inject code\n");
+ ERROR("Palacios Error: error setting up inject code\n");
return -1;
}
- printk("Palacios: injection registration complete\n");
+ INFO("Palacios: injection registration complete\n");
return 0;
}
if (size < sizeof(struct cons_msg)) {
- printk("Invalid Read operation size: %lu\n", size);
+ ERROR("Invalid Read operation size: %lu\n", size);
return -EFAULT;
}
msg = dequeue(cons->queue);
if (msg == NULL) {
- printk("ERROR: Null console message\n");
+ ERROR("ERROR: Null console message\n");
return -EFAULT;
}
if (copy_to_user(buf, msg, size)) {
- printk("Read Fault\n");
+ ERROR("Read Fault\n");
return -EFAULT;
}
wake_up_interruptible(&(cons->intr_queue));
}
- // printk("Read from console\n");
+ // DEBUG("Read from console\n");
return size;
}
for (i = 0; i < size; i++) {
if (copy_from_user(&(event.scan_code), buf + i, 1)) {
- printk("Console Write fault\n");
+ ERROR("Console Write fault\n");
return -EFAULT;
}
unsigned long flags;
int entries = 0;
- // printk("Console=%p (guest=%s)\n", cons, cons->guest->name);
+ // DEBUG("Console=%p (guest=%s)\n", cons, cons->guest->name);
poll_wait(filp, &(cons->intr_queue), poll_tb);
spin_unlock_irqrestore(&(cons->queue->lock), flags);
if (entries > 0) {
- // printk("Returning from POLL\n");
+ // DEBUG("Returning from POLL\n");
return mask;
}
struct cons_msg * msg = NULL;
unsigned long flags;
- printk("Releasing the Console File desc\n");
+ DEBUG("Releasing the Console File desc\n");
spin_lock_irqsave(&(cons->queue->lock), flags);
cons->connected = 0;
int acquired = 0;
if (cons->open == 0) {
- printk("Attempted to connect to unopened console\n");
+ ERROR("Attempted to connect to unopened console\n");
return -1;
}
spin_unlock_irqrestore(&(cons->lock), flags);
if (acquired == 0) {
- printk("Console already connected\n");
+ ERROR("Console already connected\n");
return -1;
}
cons_fd = anon_inode_getfd("v3-cons", &cons_fops, cons, O_RDWR);
if (cons_fd < 0) {
- printk("Error creating console inode\n");
+ ERROR("Error creating console inode\n");
return cons_fd;
}
v3_deliver_console_event(guest->v3_ctx, NULL);
- printk("Console connected\n");
+ INFO("Console connected\n");
return cons_fd;
}
struct v3_guest * guest = (struct v3_guest *)private_data;
struct palacios_console * cons = kmalloc(sizeof(struct palacios_console), GFP_KERNEL);
- printk("Guest initialized virtual console (Guest=%s)\n", guest->name);
+ INFO("Guest initialized virtual console (Guest=%s)\n", guest->name);
if (guest == NULL) {
- printk("ERROR: Cannot open a console on a NULL guest\n");
+ ERROR("ERROR: Cannot open a console on a NULL guest\n");
return NULL;
}
if (cons->open == 1) {
- printk("Console already open\n");
+ ERROR("Console already open\n");
return NULL;
}
}
static int post_msg(struct palacios_console * cons, struct cons_msg * msg) {
- // printk("Posting Console message\n");
+ // DEBUG("Posting Console message\n");
while (enqueue(cons->queue, msg) == -1) {
wake_up_interruptible(&(cons->intr_queue));
struct env_data * env;
int i;
- printk("Palacios: Loading environment data...\n");
+ INFO("Palacios: Loading environment data...\n");
if (copy_from_user(&env_arg, (void __user *)arg, sizeof(struct env_data))) {
- printk("palacios: error copying environment data from userspace\n");
+ ERROR("palacios: error copying environment data from userspace\n");
return -EFAULT;
}
env = kmalloc(sizeof(struct env_data), GFP_KERNEL);
if (IS_ERR(env)) {
- printk("Palacios Error: could not allocate space for environment data\n");
+ ERROR("Palacios Error: could not allocate space for environment data\n");
return -EFAULT;
}
env->num_strings = env_arg.num_strings;
strcpy(env->bin_name, env_arg.bin_name);
- printk("Binary hooked on: %s\n", env->bin_name);
+ DEBUG("Binary hooked on: %s\n", env->bin_name);
- //printk("Palacios: Allocating space for %u env var string ptrs...\n", env->num_strings);
+ //DEBUG("Palacios: Allocating space for %u env var string ptrs...\n", env->num_strings);
env->strings = kmalloc(env->num_strings*sizeof(char*), GFP_KERNEL);
if (IS_ERR(env->strings)) {
- printk("Palacios Error: could not allocate space for env var strings\n");
+ ERROR("Palacios Error: could not allocate space for env var strings\n");
return -EFAULT;
}
memset(env->strings, 0, env->num_strings*sizeof(char*));
- //printk("Palacios: copying env var string pointers\n");
+ //INFO("Palacios: copying env var string pointers\n");
if (copy_from_user(env->strings, (void __user *)env_arg.strings, env->num_strings*sizeof(char*))) {
- printk("Palacios: Error copying string pointers\n");
+ ERROR("Palacios: Error copying string pointers\n");
return -EFAULT;
}
for (i = 0; i < env->num_strings; i++) {
char * tmp = kmalloc(MAX_STRING_LEN, GFP_KERNEL);
if (IS_ERR(tmp)) {
- printk("Palacios Error: could not allocate space for env var string #%d\n", i);
+ ERROR("Palacios Error: could not allocate space for env var string #%d\n", i);
return -EFAULT;
}
if (copy_from_user(tmp, (void __user *)env->strings[i], MAX_STRING_LEN)) {
- printk("Palacios: Error copying string #%d\n", i);
+ ERROR("Palacios: Error copying string #%d\n", i);
return -EFAULT;
}
env->strings[i] = tmp;
}
- printk("Palacios: registering environment data...\n");
+ INFO("Palacios: registering environment data...\n");
if (register_env(env) < 0)
return -1;
- printk("Palacios: passing data off to palacios...\n");
+ DEBUG("Palacios: passing data off to palacios...\n");
if (v3_insert_env_inject(guest->v3_ctx, env->strings, env->num_strings, env->bin_name) < 0) {
- printk("Palacios: Error passing off environment data\n");
+ ERROR("Palacios: Error passing off environment data\n");
return -1;
}
- printk("Palacios: environment injection registration complete\n");
+ INFO("Palacios: environment injection registration complete\n");
return 0;
}
(*tmp_iter != '\0')) {
if ( (!isprint(*tmp_iter))) {
- printk("Invalid character in path name (%d)\n", *tmp_iter);
+ ERROR("Invalid character in path name (%d)\n", *tmp_iter);
return -1;
} else {
tmp_iter++;
// Ignore empty directories
if ((tmp_iter - dirname_ptr) > 1) {
if (palacios_file_mkdir(tmp_str, perms, 0) != 0) {
- printk("Could not create directory (%s)\n", tmp_str);
+ ERROR("Could not create directory (%s)\n", tmp_str);
return -1;
}
}
#endif
if (ret != 0) {
- printk("%s:%d - Error: kern_path_parent() returned error for (%s)\n", __FILE__, __LINE__,
+ ERROR("%s:%d - Error: kern_path_parent() returned error for (%s)\n", __FILE__, __LINE__,
pathname);
return -1;
}
vm_state = get_vm_ext_data(guest, "FILE_INTERFACE");
if (vm_state == NULL) {
- printk("ERROR: Could not locate vm file state for extension FILE_INTERFACE\n");
+ ERROR("ERROR: Could not locate vm file state for extension FILE_INTERFACE\n");
return NULL;
}
}
pfile->filp = filp_open(path, pfile->mode, 0);
if (IS_ERR(pfile->filp)) {
- printk("Cannot open file: %s\n", path);
+ ERROR("Cannot open file: %s\n", path);
return NULL;
}
ret = vfs_getattr(filp->f_path.mnt, filp->f_path.dentry, &s);
if (ret != 0) {
- printk("Failed to fstat file\n");
+ ERROR("Failed to fstat file\n");
return -1;
}
set_fs(old_fs);
if (ret <= 0) {
- printk("sys_read of %p for %lld bytes at offset %llu failed (ret=%ld)\n", filp, length, offset, ret);
+ ERROR("sys_read of %p for %lld bytes at offset %llu failed (ret=%ld)\n", filp, length, offset, ret);
}
return ret;
if (ret <= 0) {
- printk("sys_write for %llu bytes at offset %llu failed (ret=%ld)\n", length, offset, ret);
+ ERROR("sys_write for %llu bytes at offset %llu failed (ret=%ld)\n", length, offset, ret);
}
return ret;
static int file_deinit( void ) {
if (!list_empty(&(global_files))) {
- printk("Error removing module with open files\n");
+ ERROR("Error removing module with open files\n");
}
return 0;
gc = get_vm_ext_data(guest, "GRAPHICS_CONSOLE_INTERFACE");
if (gc == NULL) {
- printk("palacios: Could not locate graphics console data for extension GRAPHICS_CONSOLE_INTERFACE\n");
+ ERROR("palacios: Could not locate graphics console data for extension GRAPHICS_CONSOLE_INTERFACE\n");
return 0;
}
if (gc->data != NULL) {
- printk("palacios: framebuffer already allocated - returning it\n");
+ DEBUG("palacios: framebuffer already allocated - returning it\n");
*actual_spec = gc->spec;
gc->cons_refcount++;
mem = desired_spec->width * desired_spec->height * desired_spec->bytes_per_pixel;
- printk("palacios: allocating %u bytes for %u by %u by %u buffer\n",
+ DEBUG("palacios: allocating %u bytes for %u by %u by %u buffer\n",
mem, desired_spec->width, desired_spec->height, desired_spec->bytes_per_pixel);
gc->data = vmalloc(mem);
if (!(gc->data)) {
- printk("palacios: unable to allocate memory for frame buffer\n");
+ ERROR("palacios: unable to allocate memory for frame buffer\n");
return 0;
}
gc->cons_refcount++;
gc->data_refcount++;
- printk("palacios: allocated frame buffer\n");
+ INFO("palacios: allocated frame buffer\n");
return gc;
}
gc->data_refcount--;
if (gc->data_refcount < gc->cons_refcount) {
- printk("palacios: error! data refcount is less than console refcount for graphics console\n");
+ ERROR("palacios: error! data refcount is less than console refcount for graphics console\n");
}
if (gc->cons_refcount > 0) {
return;
} else {
if (gc->cons_refcount < 0) {
- printk("palacios: error! refcount for graphics console is negative on close!\n");
+ ERROR("palacios: error! refcount for graphics console is negative on close!\n");
}
if (gc->data_refcount > 0) {
- printk("palacios: error! refcount for graphics console data is positive on close - LEAKING MEMORY\n");
+ ERROR("palacios: error! refcount for graphics console data is positive on close - LEAKING MEMORY\n");
return;
}
if (gc->data) {
struct palacios_graphics_console *gc = (struct palacios_graphics_console *) cons;
if (gc->data_refcount<=0) {
- printk("palacios: error! data refcount is <= 0 in get_data_read\n");
+ ERROR("palacios: error! data refcount is <= 0 in get_data_read\n");
}
gc->data_refcount++;
gc->data_refcount--;
if (gc->data_refcount<=0) {
- printk("palacios: error! data refcount is <= zero in release_data_read\n");
+ ERROR("palacios: error! data refcount is <= zero in release_data_read\n");
}
}
gc->render_data = priv_data;
gc->render_request = render_request;
- printk("palacios: installed rendering callback function for graphics console\n");
+ INFO("palacios: installed rendering callback function for graphics console\n");
return 0;
gc->update_data = priv_data;
gc->update_inquire = update_inquire;
- printk("palacios: installed update inquiry callback function for graphics console\n");
+ INFO("palacios: installed update inquiry callback function for graphics console\n");
return 0;
e.status = 0;
e.scan_code = scancode;
- //printk("palacios: start key delivery\n");
+ //DEBUG("palacios: start key delivery\n");
v3_deliver_keyboard_event(guest->v3_ctx, &e);
- //printk("palacios: end key delivery\n");
+ //DEBUG("palacios: end key delivery\n");
return 0;
}
if (copy_from_user(&q, (void __user *) arg, sizeof(struct v3_fb_query_response))) {
- printk("palacios: copy from user in getting query in fb\n");
+ ERROR("palacios: copy from user in getting query in fb\n");
return -EFAULT;
}
switch (q.request_type) {
case V3_FB_SPEC:
- //printk("palacios: request for db spec from Userland\n");
+ //INFO("palacios: request for db spec from Userland\n");
// returns only the spec for the FB
q.spec = cons->spec;
break;
case V3_FB_UPDATE:
- //printk("palacios: test for fb updatei from Userland\n");
+ //DEBUG("palacios: test for fb updatei from Userland\n");
// returns whether an update is available for the region
if (cons->update_inquire) {
q.updated = cons->update_inquire(cons,cons->update_data);
} else {
q.updated = 1;
}
- //printk("palacios: update=%d\n",q.updated);
+ //DEBUG("palacios: update=%d\n",q.updated);
// request a render, since a FB_DATA will probably soon come
cons->change_request = 1;
case V3_FB_DATA_BOX: {
// Not curently implemented
- printk("palacios: request for data in bounding box unsupported currently\n");
+ ERROR("palacios: request for data in bounding box unsupported currently\n");
return -EFAULT;
}
break;
case V3_FB_DATA_ALL: {
- //printk("palacios: got FrameBuffer Request from Userland\n");
+ //DEBUG("palacios: got FrameBuffer Request from Userland\n");
// First let's sanity check to see if they are requesting the same
// spec that we have
if (memcmp(&(q.spec),&(cons->spec),sizeof(struct v3_frame_buffer_spec))) {
- printk("palacios: request for data with non-matching fb spec \n");
+ ERROR("palacios: request for data with non-matching fb spec \n");
return -EFAULT;
}
// Now we will force a render if we can
if (cons->render_request) {
- //printk("palacios: making rendering request\n");
+ //DEBUG("palacios: making rendering request\n");
cons->render_request(cons,cons->render_data);
}
// Now let's indicate an update is in the pointer and copy across the data
if (copy_to_user(q.data,cons->data,cons->spec.width*cons->spec.height*cons->spec.bytes_per_pixel)) {
- printk("palacios: unable to copy fb content to user\n");
+ ERROR("palacios: unable to copy fb content to user\n");
return -EFAULT;
}
- //printk("palacios: FrameBuffer copy out done\n");
+ //DEBUG("palacios: FrameBuffer copy out done\n");
q.updated = 1;
// Now we don't need to request a render
cons->change_request = 0;
// now we'll copy back any changes we made to the query/response structure
if (copy_to_user((void __user *) arg, (void*)&q, sizeof(struct v3_fb_query_response))) {
- printk("palacios: unable to copy fb response to user\n");
+ ERROR("palacios: unable to copy fb response to user\n");
return -EFAULT;
}
if (copy_from_user(&inp, (void __user *) arg, sizeof(struct v3_fb_input))) {
- printk("palacios: copy from user in getting input in fb\n");
+ ERROR("palacios: copy from user in getting input in fb\n");
return -EFAULT;
}
- //printk("palacios: input from Userland\n");
+ //DEBUG("palacios: input from Userland\n");
if ((inp.data_type == V3_FB_KEY) || (inp.data_type == V3_FB_BOTH)) {
rc = palacios_graphics_console_key(guest, cons, inp.scan_code);
- //printk("palacios: key delivered to palacios\n");
+ //DEBUG("palacios: key delivered to palacios\n");
}
if ((inp.data_type == V3_FB_MOUSE) || (inp.data_type == V3_FB_BOTH)) {
rc |= palacios_graphics_console_mouse(guest, cons, inp.mouse_data[0],
inp.mouse_data[1], inp.mouse_data[2]);
- //printk("palacios: mouse delivered to palacios\n");
+ //DEBUG("palacios: mouse delivered to palacios\n");
}
if (rc) {
struct palacios_graphics_console * graphics_cons = kmalloc(sizeof(struct palacios_graphics_console), GFP_KERNEL);
if (!graphics_cons) {
- printk("palacios: filed to do guest_init for graphics console\n");
+ ERROR("palacios: filed to do guest_init for graphics console\n");
return -1;
}
#define SHALLOW_DEBUG 0
#if DEEP_DEBUG
-#define DEEP_DEBUG_PRINT(fmt, args...) printk((fmt), ##args)
+#define DEEP_DEBUG_PRINT(fmt, args...) DEBUG((fmt), ##args)
#else
#define DEEP_DEBUG_PRINT(fmt, args...)
#endif
#if SHALLOW_DEBUG
-#define SHALLOW_DEBUG_PRINT(fmt, args...) printk((fmt), ##args)
+#define SHALLOW_DEBUG_PRINT(fmt, args...) INFO((fmt), ##args)
#else
#define SHALLOW_DEBUG_PRINT(fmt, args...)
#endif
-
-#define ERROR(fmt, args...) printk((fmt), ##args)
-#define INFO(fmt, args...) printk((fmt), ##args)
+// Moved to palacios.h
+//define ERROR(fmt, args...)
+//define INFO(fmt, args...)
struct palacios_host_device_user {
spinlock_t lock;
if (copy_from_user(url, argp, MAX_URL)) {
- printk("copy from user error getting url for host device connect...\n");
+ ERROR("copy from user error getting url for host device connect...\n");
return -EFAULT;
}
host_dev = get_vm_ext_data(guest, "HOST_DEVICE_INTERFACE");
if (host_dev == NULL) {
- printk("Error locating vm host data for HOST_DEVICE_INTERFACE\n");
+ ERROR("Error locating vm host data for HOST_DEVICE_INTERFACE\n");
return 0;
}
unsigned int hcall_id,
struct guest_accessors *acc,
void *priv_data) {
- printk("palacios: host_hypercall_nop dummy handler invoked\n");
- printk(" rip=%p\n rsp=%p\n rbp=%p\n rflags=%p\n",
+ DEBUG("palacios: host_hypercall_nop dummy handler invoked\n");
+ DEBUG(" rip=%p\n rsp=%p\n rbp=%p\n rflags=%p\n",
(void*)(acc->get_rip(core)),
(void*)(acc->get_rsp(core)),
(void*)(acc->get_rbp(core)),
(void*)(acc->get_rflags(core)));
- printk(" rax=%p\n rbx=%p\n rcx=%p\n rdx=%p\n rsi=%p\n rdi=%p\n",
+ DEBUG(" rax=%p\n rbx=%p\n rcx=%p\n rdx=%p\n rsi=%p\n rdi=%p\n",
(void*)(acc->get_rax(core)),
(void*)(acc->get_rbx(core)),
(void*)(acc->get_rcx(core)),
(void*)(acc->get_rdx(core)),
(void*)(acc->get_rsi(core)),
(void*)(acc->get_rdi(core)));
- printk(" r8=%p\n r9=%p\n r10=%p\n r11=%p\n r12=%p\n r13=%p\n r14=%p\n r15=%p\n",
+ DEBUG(" r8=%p\n r9=%p\n r10=%p\n r11=%p\n r12=%p\n r13=%p\n r14=%p\n r15=%p\n",
(void*)(acc->get_r8(core)),
(void*)(acc->get_r9(core)),
(void*)(acc->get_r10(core)),
(void*)(acc->get_r13(core)),
(void*)(acc->get_r14(core)),
(void*)(acc->get_r15(core)));
- printk(" cr0=%p\n cr2=%p\n cr3=%p\n cr4=%p\n cr8=%p\n efer=%p\n",
+ DEBUG(" cr0=%p\n cr2=%p\n cr3=%p\n cr4=%p\n cr8=%p\n efer=%p\n",
(void*)(acc->get_cr0(core)),
(void*)(acc->get_cr2(core)),
(void*)(acc->get_cr3(core)),
void *func;
if (copy_from_user(&hdata,(void __user *) arg, sizeof(struct hcall_data))) {
- printk("palacios: copy from user in getting input for hypercall add\n");
+ ERROR("palacios: copy from user in getting input for hypercall add\n");
return -EFAULT;
}
if (0==strcmp(hdata.fn,"")) {
- printk("palacios: no hypercall function supplied, using default\n");
+ WARNING("palacios: no hypercall function supplied, using default\n");
func = (void*) host_hypercall_nop;
} else {
func = __symbol_get(hdata.fn);
}
if (func == NULL) {
- printk("palacios: cannot find function '%s' for hypercall addition - perhaps your module hasn't been loaded yet?\n",hdata.fn);
+ ERROR("palacios: cannot find function '%s' for hypercall addition - perhaps your module hasn't been loaded yet?\n",hdata.fn);
return -EFAULT;
}
hdata.hcall_nr,
func,
NULL)) {
- printk("palacios: cannot register hypercall 0x%x for function %s (%p)\n",
+ ERROR("palacios: cannot register hypercall 0x%x for function %s (%p)\n",
hdata.hcall_nr, hdata.fn, func);
return -EFAULT;
}
- printk("palacios: hypercall %d (0x%x) registered for function %s (%p)\n",
+ INFO("palacios: hypercall %d (0x%x) registered for function %s (%p)\n",
hdata.hcall_nr,hdata.hcall_nr,hdata.fn,func);
return 0;
}
struct hcall_data hdata;
if (copy_from_user(&hdata,(void __user *) arg, sizeof(struct hcall_data))) {
- printk("palacios: copy from user in getting input for hypercall remove\n");
+ ERROR("palacios: copy from user in getting input for hypercall remove\n");
return -EFAULT;
}
if (v3_unregister_host_hypercall(guest->v3_ctx,
hdata.hcall_nr)) {
- printk("palacios: cannot unregister hypercall 0x%x\n", hdata.hcall_nr);
+ ERROR("palacios: cannot unregister hypercall 0x%x\n", hdata.hcall_nr);
return -EFAULT;
}
- printk("palacios: hypercall %d (0x%x) unregistered\n",
+ INFO("palacios: hypercall %d (0x%x) unregistered\n",
hdata.hcall_nr,hdata.hcall_nr);
return 0;
{
if (strncasecmp(url,"mem:",4)) {
- printk("palacios: illegitimate attempt to open memory stream \"%s\"\n",url);
+ WARNING("palacios: illegitimate attempt to open memory stream \"%s\"\n",url);
return 0;
}
mykey = kmalloc(strlen(url+4)+1,GFP_KERNEL);
if (!mykey) {
- printk("palacios: cannot allocate space for new in-memory keyed stream %s\n",url);
+ ERROR("palacios: cannot allocate space for new in-memory keyed stream %s\n",url);
return 0;
}
if (!mks) {
kfree(mykey);
- printk("palacios: cannot allocate in-memory keyed stream %s\n",url);
+ ERROR("palacios: cannot allocate in-memory keyed stream %s\n",url);
return 0;
}
if (!mks->ht) {
kfree(mks);
kfree(mykey);
- printk("palacios: cannot allocate in-memory keyed stream %s\n",url);
+ ERROR("palacios: cannot allocate in-memory keyed stream %s\n",url);
return 0;
}
palacios_free_htable(mks->ht,1,1);
kfree(mks);
kfree(mykey);
- printk("palacios: cannot insert in-memory keyed stream %s\n",url);
+ ERROR("palacios: cannot insert in-memory keyed stream %s\n",url);
return 0;
}
mks->stype=STREAM_MEM;
break;
default:
- printk("palacios: unsupported open type in open_stream_mem\n");
+ ERROR("palacios: unsupported open type in open_stream_mem\n");
break;
}
char *mykey = kmalloc(strlen(key)+1,GFP_KERNEL);
if (!mykey) {
- printk("palacios: cannot allocate copy of key for key %s\n",key);
+ ERROR("palacios: cannot allocate copy of key for key %s\n",key);
return 0;
}
if (!m) {
kfree(mykey);
- printk("palacios: cannot allocate mem keyed stream for key %s\n",key);
+ ERROR("palacios: cannot allocate mem keyed stream for key %s\n",key);
return 0;
}
if (!palacios_htable_insert(s,(addr_t)mykey,(addr_t)m)) {
destroy_mem_stream(m);
kfree(mykey);
- printk("palacios: cannot insert mem keyed stream for key %s\n",key);
+ ERROR("palacios: cannot insert mem keyed stream for key %s\n",key);
return 0;
}
}
mykey=kmalloc(strlen(key)+1,GFP_KERNEL);
if (!mykey) {
- printk("palacios: cannot allocate key spce for preallocte for key %s\n",key);
+ ERROR("palacios: cannot allocate key space for preallocte for key %s\n",key);
return;
}
m = create_mem_stream_internal(size);
if (!m) {
- printk("palacios: cannot preallocate mem keyed stream for key %s\n",key);
+ ERROR("palacios: cannot preallocate mem keyed stream for key %s\n",key);
return;
}
if (!palacios_htable_insert(s,(addr_t)mykey,(addr_t)m)) {
- printk("palacios: cannot insert preallocated mem keyed stream for key %s\n",key);
+ ERROR("palacios: cannot insert preallocated mem keyed stream for key %s\n",key);
destroy_mem_stream(m);
return;
}
} else {
if (m->data_max < size) {
if (expand_mem_stream(m,size)) {
- printk("palacios: cannot expand key for preallocation for key %s\n",key);
+ ERROR("palacios: cannot expand key for preallocation for key %s\n",key);
return;
}
}
writelen=write_mem_stream(m,buf,mylen);
if (writelen!=mylen) {
- printk("palacios: failed to write all data for key\n");
+ ERROR("palacios: failed to write all data for key\n");
return -1;
} else {
return (sint64_t)writelen;
readlen=read_mem_stream(m,buf,mylen);
if (readlen!=mylen) {
- printk("palacios: failed to read all data for key\n");
+ ERROR("palacios: failed to read all data for key\n");
return -1;
} else {
return (sint64_t)readlen;
struct nameidata nd;
if (strncasecmp(url,"file:",5)) {
- printk("palacios: illegitimate attempt to open file stream \"%s\"\n",url);
+ WARNING("palacios: illegitimate attempt to open file stream \"%s\"\n",url);
return 0;
}
fks = kmalloc(sizeof(struct file_keyed_stream),GFP_KERNEL);
if (!fks) {
- printk("palacios: cannot allocate space for file stream\n");
+ ERROR("palacios: cannot allocate space for file stream\n");
return 0;
}
fks->path = (char*)kmalloc(strlen(url+5)+1,GFP_KERNEL);
if (!(fks->path)) {
- printk("palacios: cannot allocate space for file stream\n");
+ ERROR("palacios: cannot allocate space for file stream\n");
kfree(fks);
return 0;
}
if (ot==V3_KS_RD_ONLY || ot==V3_KS_WR_ONLY) {
// we are not being asked to create it
- printk("palacios: attempt to open %s, which does not exist\n",fks->path);
+ ERROR("palacios: attempt to open %s, which does not exist\n",fks->path);
goto fail_out;
} else {
// Find its parent
if (path_lookup(fks->path,LOOKUP_PARENT|LOOKUP_FOLLOW,&nd)) {
- printk("palacios: attempt to create %s failed because its parent cannot be looked up\n",fks->path);
+ ERROR("palacios: attempt to create %s failed because its parent cannot be looked up\n",fks->path);
goto fail_out;
}
// Can we write to the parent?
if (inode_permission(nd.path.dentry->d_inode, MAY_WRITE | MAY_EXEC)) {
- printk("palacios: attempt to open %s, which has the wrong permissions for directory creation\n",fks->path);
+ ERROR("palacios: attempt to open %s, which has the wrong permissions for directory creation\n",fks->path);
goto fail_out;
}
de = lookup_create(&nd,1);
if (IS_ERR(de)) {
- printk("palacios: cannot allocate dentry\n");
+ ERROR("palacios: cannot allocate dentry\n");
goto fail_out;
}
mutex_unlock(&(nd.path.dentry->d_inode->i_mutex));
if (err) {
- printk("palacios: attempt to create %s failed because mkdir failed\n",fks->path);
+ ERROR("palacios: attempt to create %s failed because mkdir failed\n",fks->path);
goto fail_out;
}
// and the directory exists, so we must check the permissions
if (inode_permission(nd.path.dentry->d_inode, MAY_EXEC | (ot==V3_KS_RD_ONLY ? MAY_READ : MAY_WRITE))) {
- printk("palacios: attempt to open %s, which has the wrong permissions\n",fks->path);
+ ERROR("palacios: attempt to open %s, which has the wrong permissions\n",fks->path);
goto fail_out;
} else {
return (v3_keyed_stream_t) fks;
// file:/home/foo + "regext" => "/home/foo/regext"
path = (char *) kmalloc(strlen(fks->path)+strlen(key)+2,GFP_KERNEL);
if (!path) {
- printk("palacios: cannot allocate file keyed stream for key %s\n",key);
+ ERROR("palacios: cannot allocate file keyed stream for key %s\n",key);
return 0;
}
strcpy(path,fks->path);
fs = (struct file_stream *) kmalloc(sizeof(struct file_stream *),GFP_KERNEL);
if (!fs) {
- printk("palacios: cannot allocate file keyed stream for key %s\n",key);
+ ERROR("palacios: cannot allocate file keyed stream for key %s\n",key);
kfree(path);
return 0;
}
fs->f = filp_open(path,O_RDWR|O_CREAT,0600);
if (IS_ERR(fs->f)) {
- printk("palacios: cannot open relevent file \"%s\" for stream \"file:%s\" and key \"%s\"\n",path,fks->path,key);
+ ERROR("palacios: cannot open relevent file \"%s\" for stream \"file:%s\" and key \"%s\"\n",path,fks->path,key);
kfree(fs);
kfree(path);
return 0;
{
if (s->waiting) {
- printk("palacios: user keyed stream request attempted while one is already in progress on %s\n",s->url);
+ ERROR("palacios: user keyed stream request attempted while one is already in progress on %s\n",s->url);
return -1;
}
{
if (!(s->waiting)) {
- printk("palacios: user keyed stream response while no request is in progress on %s\n",s->url);
+ ERROR("palacios: user keyed stream response while no request is in progress on %s\n",s->url);
return -1;
}
if (copy_to_user((void * __user) argp, &size, sizeof(uint64_t))) {
spin_unlock_irqrestore(&(s->lock), flags);
- printk("palacios: palacios user key size request failed to copy data\n");
+ ERROR("palacios: palacios user key size request failed to copy data\n");
return -EFAULT;
}
if (!(s->waiting)) {
spin_unlock_irqrestore(&(s->lock), flags);
- printk("palacios: palacios user key pull request when not waiting\n");
+ ERROR("palacios: palacios user key pull request when not waiting\n");
return 0;
}
if (copy_to_user((void __user *) argp, s->op, size)) {
spin_unlock_irqrestore(&(s->lock), flags);
- printk("palacios: palacios user key pull request failed to copy data\n");
+ ERROR("palacios: palacios user key pull request failed to copy data\n");
return -EFAULT;
}
if (!(s->waiting)) {
spin_unlock_irqrestore(&(s->lock), flags);
- printk("palacios: palacios user key push response when not waiting\n");
+ ERROR("palacios: palacios user key push response when not waiting\n");
return 0;
}
if (copy_from_user(&size, (void __user *) argp, sizeof(uint64_t))) {
- printk("palacios: palacios user key push response failed to copy size\n");
+ ERROR("palacios: palacios user key push response failed to copy size\n");
spin_unlock_irqrestore(&(s->lock), flags);
return -EFAULT;
}
if (resize_op(&(s->op),size-sizeof(struct palacios_user_keyed_stream_op))) {
- printk("palacios: unable to resize op in user key push response\n");
+ ERROR("palacios: unable to resize op in user key push response\n");
spin_unlock_irqrestore(&(s->lock), flags);
return -EFAULT;
}
break;
default:
- printk("palacios: unknown ioctl in user keyed stream\n");
+ ERROR("palacios: unknown ioctl in user keyed stream\n");
return -EFAULT;
struct user_keyed_stream *s;
if (!user_streams) {
- printk("palacios: no user space keyed streams!\n");
+ ERROR("palacios: no user space keyed streams!\n");
return -1;
}
// get the url
if (copy_from_user(&len,(void __user *)arg,sizeof(len))) {
- printk("palacios: cannot copy url len from user\n");
+ ERROR("palacios: cannot copy url len from user\n");
return -1;
}
url = kmalloc(len,GFP_KERNEL);
if (!url) {
- printk("palacios: cannot allocate url for user keyed stream\n");
+ ERROR("palacios: cannot allocate url for user keyed stream\n");
return -1;
}
if (copy_from_user(url,((void __user *)arg)+sizeof(len),len)) {
- printk("palacios: cannot copy url from user\n");
+ ERROR("palacios: cannot copy url from user\n");
return -1;
}
url[len-1]=0;
spin_lock_irqsave(&(user_streams->lock), flags);
list_for_each_entry(s, &(user_streams->streams), node) {
if (!strncasecmp(url, s->url, len)) {
- printk("palacios: user keyed stream connection with url \"%s\" already exists\n", url);
+ ERROR("palacios: user keyed stream connection with url \"%s\" already exists\n", url);
kfree(url);
return -1;
}
s = kmalloc(sizeof(struct user_keyed_stream), GFP_KERNEL);
if (!s) {
- printk("palacios: cannot allocate new user keyed stream for %s\n",url);
+ ERROR("palacios: cannot allocate new user keyed stream for %s\n",url);
kfree(url);
return -1;
}
fd = anon_inode_getfd("v3-kstream", &user_keyed_stream_fops, s, 0);
if (fd < 0) {
- printk("palacios: cannot allocate file descriptor for new user keyed stream for %s\n",url);
+ ERROR("palacios: cannot allocate file descriptor for new user keyed stream for %s\n",url);
kfree(s);
kfree(url);
return -1;
struct user_keyed_stream *s;
if (!user_streams) {
- printk("palacios: no user space keyed streams available\n");
+ ERROR("palacios: no user space keyed streams available\n");
return NULL;
}
s = keyed_stream_user_find(url);
if (!s) {
- printk("palacios: cannot open user stream %s as it does not exist yet\n",url);
+ ERROR("palacios: cannot open user stream %s as it does not exist yet\n",url);
return NULL;
}
if (s->waiting) {
spin_unlock_irqrestore(&(s->lock), flags);
- printk("palacios: cannot open user stream %s as it is already in waiting state\n",url);
+ ERROR("palacios: cannot open user stream %s as it is already in waiting state\n",url);
return NULL;
}
if (resize_op(&(s->op),len)) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: cannot resize op in opening key %s on user keyed stream %s\n",key,s->url);
+ ERROR("palacios: cannot resize op in opening key %s on user keyed stream %s\n",key,s->url);
return NULL;
}
// enter with it locked
if (do_request_to_response(s,&flags)) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: request/response handling failed\n");
+ ERROR("palacios: request/response handling failed\n");
return NULL;
}
// return with it locked
if (resize_op(&(s->op),len)) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: cannot resize op in closing key 0x%p on user keyed stream %s\n",key,s->url);
+ ERROR("palacios: cannot resize op in closing key 0x%p on user keyed stream %s\n",key,s->url);
return;
}
// enter with it locked
if (do_request_to_response(s,&flags)) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: request/response handling failed\n");
+ ERROR("palacios: request/response handling failed\n");
return;
}
// return with it locked
if (s->otype != V3_KS_RD_ONLY) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: attempt to read key from stream that is not in read state on %s\n",s->url);
+ ERROR("palacios: attempt to read key from stream that is not in read state on %s\n",s->url);
}
if (resize_op(&(s->op),len)) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: cannot resize op in reading key 0x%p on user keyed stream %s\n",key,s->url);
+ ERROR("palacios: cannot resize op in reading key 0x%p on user keyed stream %s\n",key,s->url);
return -1;
}
// enter with it locked
if (do_request_to_response(s,&flags)) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: request/response handling failed\n");
+ ERROR("palacios: request/response handling failed\n");
return -1;
}
// return with it locked
if (s->otype != V3_KS_WR_ONLY) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: attempt to write key on stream that is not in write state on %s\n",s->url);
+ ERROR("palacios: attempt to write key on stream that is not in write state on %s\n",s->url);
}
if (resize_op(&(s->op),len)) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: cannot resize op in reading key 0x%p on user keyed stream %s\n",key,s->url);
+ ERROR("palacios: cannot resize op in reading key 0x%p on user keyed stream %s\n",key,s->url);
return -1;
}
// enter with it locked
if (do_request_to_response(s,&flags)) {
spin_unlock_irqrestore(&(s->lock),flags);
- printk("palacios: request/response handling failed\n");
+ ERROR("palacios: request/response handling failed\n");
return -1;
}
// return with it locked
} else if (!strncasecmp(url,"user:",5)) {
return open_stream_user(url,ot);
} else {
- printk("palacios: unsupported type in attempt to open keyed stream \"%s\"\n",url);
+ ERROR("palacios: unsupported type in attempt to open keyed stream \"%s\"\n",url);
return 0;
}
}
return close_stream_user(stream);
break;
default:
- printk("palacios: unknown stream type %d in close\n",gks->stype);
+ ERROR("palacios: unknown stream type %d in close\n",gks->stype);
break;
}
}
return preallocate_hint_key_user(stream,key,size);
break;
default:
- printk("palacios: unknown stream type %d in preallocate_hint_key\n",gks->stype);
+ ERROR("palacios: unknown stream type %d in preallocate_hint_key\n",gks->stype);
break;
}
return;
return open_key_user(stream,key);
break;
default:
- printk("palacios: unknown stream type %d in open_key\n",gks->stype);
+ ERROR("palacios: unknown stream type %d in open_key\n",gks->stype);
break;
}
return 0;
return close_key_user(stream,key);
break;
default:
- printk("palacios: unknown stream type %d in close_key\n",gks->stype);
+ ERROR("palacios: unknown stream type %d in close_key\n",gks->stype);
break;
}
// nothing to do
return write_key_user(stream,key,buf,len);
break;
default:
- printk("palacios: unknown stream type %d in write_key\n",gks->stype);
+ ERROR("palacios: unknown stream type %d in write_key\n",gks->stype);
return -1;
break;
}
return read_key_user(stream,key,buf,len);
break;
default:
- printk("palacios: unknown stream type %d in read_key\n",gks->stype);
+ ERROR("palacios: unknown stream type %d in read_key\n",gks->stype);
return -1;
break;
}
mem_streams = palacios_create_htable(DEF_NUM_STREAMS,hash_func,hash_comp);
if (!mem_streams) {
- printk("palacios: failed to allocated stream pool for in-memory streams\n");
+ ERROR("palacios: failed to allocated stream pool for in-memory streams\n");
return -1;
}
user_streams = kmalloc(sizeof(struct user_keyed_streams),GFP_KERNEL);
if (!user_streams) {
- printk("palacios: failed to allocated list for user streams\n");
+ ERROR("palacios: failed to allocated list for user streams\n");
return -1;
}
kfree(user_streams);
- printk("Deinit of Palacios Keyed Streams likely leaked memory\n");
+ WARNING("Deinit of Palacios Keyed Streams likely leaked memory\n");
return 0;
}
err = sock_create(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL), &(iface->raw_sock));
if (err < 0) {
- printk(KERN_WARNING "Could not create a PF_PACKET Socket, err %d\n", err);
+ WARNING("Could not create a PF_PACKET Socket, err %d\n", err);
return -1;
}
net_dev = dev_get_by_name(&init_net, eth_dev);
if(net_dev == NULL) {
- printk(KERN_WARNING "Palacios Packet: Unable to get index for device %s\n", eth_dev);
+ WARNING("Palacios Packet: Unable to get index for device %s\n", eth_dev);
sock_release(iface->raw_sock);
return -1;
}
sizeof(sock_addr));
if (err < 0){
- printk(KERN_WARNING "Error binding raw packet to device %s, %d\n", eth_dev, err);
+ WARNING("Error binding raw packet to device %s, %d\n", eth_dev, err);
sock_release(iface->raw_sock);
return -1;
}
- printk(KERN_INFO "Bind a palacios raw packet interface to device %s, device index %d\n",
+ INFO("Bind a palacios raw packet interface to device %s, device index %d\n",
eth_dev, net_dev->ifindex);
return 0;
pkt = (unsigned char *)kmalloc(ETHERNET_PACKET_LEN, GFP_KERNEL);
- printk("Palacios Raw Packet Bridge: Staring receiving on ethernet device %s\n",
+ INFO("Palacios Raw Packet Bridge: Staring receiving on ethernet device %s\n",
iface->eth_dev);
while (!kthread_should_stop()) {
size = recv_pkt(iface->raw_sock, pkt, ETHERNET_PACKET_LEN);
if (size < 0) {
- printk(KERN_WARNING "Palacios raw packet receive error, Server terminated\n");
+ WARNING("Palacios raw packet receive error, Server terminated\n");
break;
}
memcpy(iface->eth_dev, eth_dev, V3_ETHINT_NAMELEN);
if(init_socket(iface, eth_dev) !=0) {
- printk("packet: fails to initiate raw socket\n");
+ WARNING("packet: fails to initiate raw socket\n");
return -1;
}
if(iface == NULL){
iface = (struct raw_interface *)kmalloc(sizeof(struct raw_interface), GFP_KERNEL);
if (!iface) {
- printk("Palacios Packet Interface: Fails to allocate interface\n");
+ WARNING("Palacios Packet Interface: Fails to allocate interface\n");
return -1;
}
if(init_raw_interface(iface, host_nic) != 0) {
- printk("Palacios Packet Interface: Fails to initiate an raw interface on device %s\n", host_nic);
+ WARNING("Palacios Packet Interface: Fails to initiate an raw interface on device %s\n", host_nic);
kfree(iface);
return -1;
}
(addr_t)packet->dev_mac,
(addr_t)packet);
- printk(KERN_INFO "Packet: Add Receiver MAC to ethernet device %s: %2x:%2x:%2x:%2x:%2x:%2x\n",
+ INFO("Packet: Add Receiver MAC to ethernet device %s: %2x:%2x:%2x:%2x:%2x:%2x\n",
iface->eth_dev,
packet->dev_mac[0], packet->dev_mac[1],
packet->dev_mac[2], packet->dev_mac[3],
if(iface->inited == 0 ||
iface->raw_sock == NULL){
- printk("Palacios Packet Interface: Send fails due to inapproriate interface\n");
+ WARNING("Palacios Packet Interface: Send fails due to inapproriate interface\n");
return -1;
}
vm_state = get_vm_ext_data(guest, "SOCKET_INTERFACE");
if (vm_state == NULL) {
- printk("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
+ ERROR("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
return NULL;
}
}
vm_state = get_vm_ext_data(guest, "SOCKET_INTERFACE");
if (vm_state == NULL) {
- printk("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
+ ERROR("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
return NULL;
}
}
vm_state = get_vm_ext_data(sock->guest, "SOCKET_INTERFACE");
if (vm_state == NULL) {
- printk("ERROR: Could not locate vm socket state for extension SOCKET_INTERFACE\n");
+ ERROR("Could not locate vm socket state for extension SOCKET_INTERFACE\n");
return NULL;
}
}
static int socket_deinit( void ) {
if (!list_empty(&(global_sockets))) {
- printk("Error removing module with open sockets\n");
+ ERROR("Error removing module with open sockets\n");
}
return 0;
vm_state = get_vm_ext_data(guest, "STREAM_INTERFACE");
if (vm_state == NULL) {
- printk("ERROR: Could not locate vm stream state for extension STREAM_INTERFACE\n");
+ ERROR("ERROR: Could not locate vm stream state for extension STREAM_INTERFACE\n");
return NULL;
}
}
if (copy_to_user(buf + bytes_read, tmp_buf, tmp_read)) {
- printk("Read Fault\n");
+ ERROR("Read Fault\n");
return -EFAULT;
}
kern_buf = kmalloc(size, GFP_KERNEL);
if (copy_from_user(kern_buf, buf, size)) {
- printk("Stream Write Failed\n");
+ ERROR("Stream Write Failed\n");
return -EFAULT;
};
vm_state = get_vm_ext_data(guest, "STREAM_INTERFACE");
if (vm_state == NULL) {
- printk("ERROR: Could not locate vm stream state for extension STREAM_INTERFACE\n");
+ ERROR("ERROR: Could not locate vm stream state for extension STREAM_INTERFACE\n");
return NULL;
}
}
if (find_stream_by_name(guest, name) != NULL) {
- printk("Stream already exists\n");
+ ERROR("Stream already exists\n");
return NULL;
}
static int stream_deinit( void ) {
if (!list_empty(&(global_streams))) {
- printk("Error removing module with open streams\n");
- printk("TODO: free old streams... \n");
+ ERROR("Error removing module with open streams\n");
+ DEBUG("TODO: free old streams... \n");
}
return 0;
if (copy_from_user(name, argp, STREAM_NAME_LEN)) {
- printk("%s(%d): copy from user error...\n", __FILE__, __LINE__);
+ ERROR("%s(%d): copy from user error...\n", __FILE__, __LINE__);
return -EFAULT;
}
stream = find_stream_by_name(guest, name);
if (stream == NULL) {
- printk("Could not find stream (%s)\n", name);
+ ERROR("Could not find stream (%s)\n", name);
return -EFAULT;
}
if (ret == -1) {
- printk("Stream (%s) already connected\n", name);
+ ERROR("Stream (%s) already connected\n", name);
return -EFAULT;
}
stream_fd = anon_inode_getfd("v3-stream", &stream_fops, stream, O_RDWR);
if (stream_fd < 0) {
- printk("Error creating stream inode for (%s)\n", name);
+ ERROR("Error creating stream inode for (%s)\n", name);
return stream_fd;
}
- printk("Stream (%s) connected\n", name);
+ INFO("Stream (%s) connected\n", name);
return stream_fd;
}
static int guest_stream_deinit(struct v3_guest * guest, void * vm_data) {
struct vm_global_streams * state = vm_data;
if (!list_empty(&(state->open_streams))) {
- printk("Error shutting down VM with open streams\n");
+ ERROR("Error shutting down VM with open streams\n");
}
return 0;
int ret;
if (copy_from_user(&syscall_cmd, (void __user *)arg, sizeof(struct v3_syscall_cmd))) {
- printk("Palacios: error copying syscall command from userspace\n");
+ ERROR("palacios: error copying syscall command from userspace\n");
return -EFAULT;
}
case SYSCALL_OFF: {
ret = v3_syscall_off(guest->v3_ctx, syscall_cmd.syscall_nr);
if (ret < 0) {
- printk("Palacios: error deactivating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
+ ERROR("palacios: error deactivating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
}
break;
}
case SYSCALL_ON: {
ret = v3_syscall_on(guest->v3_ctx, syscall_cmd.syscall_nr);
if (ret < 0) {
- printk("Palacios: error activating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
+ ERROR("palacios: error activating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
}
break;
}
case SYSCALL_STAT: {
ret = v3_syscall_stat(guest->v3_ctx, syscall_cmd.syscall_nr);
if (ret == SYSCALL_OFF)
- printk("Palacios: exiting for syscall #%d is OFF\n", syscall_cmd.syscall_nr);
+ INFO("palacios: exiting for syscall #%d is OFF\n", syscall_cmd.syscall_nr);
else if (ret == SYSCALL_ON)
- printk("Palacios: exiting for syscall #%d is ON\n", syscall_cmd.syscall_nr);
+ INFO("palacios: exiting for syscall #%d is ON\n", syscall_cmd.syscall_nr);
else
- printk("Palacios: error stating syscall nr: %d\n", syscall_cmd.syscall_nr);
+ INFO("palacios: error stating syscall nr: %d\n", syscall_cmd.syscall_nr);
break;
}
default:
- printk("Palacios: error - invalid syscall command\n");
+ ERROR("palacios: error - invalid syscall command\n");
return -1;
}
if (root == NULL) {
- printk("No inspection root found\n");
+ ERROR("No inspection root found\n");
return -1;
}
guest_dir = debugfs_create_dir(guest->name, v3_dir);
if (IS_ERR(guest_dir)) {
- printk("Error Creating inspector tree for VM \"%s\"\n", guest->name);
+ ERROR("Error Creating inspector tree for VM \"%s\"\n", guest->name);
return -1;
}
v3_dir = debugfs_create_dir("v3vee", NULL);
if (IS_ERR(v3_dir)) {
- printk("Error creating v3vee debugfs directory\n");
+ ERROR("Error creating v3vee debugfs directory\n");
return -1;
}
continue;
}
- printk("Registering Linux Extension (%s)\n", ext_impl->name);
+ INFO("Registering Linux Extension (%s)\n", ext_impl->name);
ext = kmalloc(sizeof(struct vm_ext), GFP_KERNEL);
if (!ext) {
- printk("Error allocating VM extension (%s)\n", ext_impl->name);
+ WARNING("Error allocating VM extension (%s)\n", ext_impl->name);
return -1;
}
if (ext->impl->guest_deinit) {
ext->impl->guest_deinit(guest, ext->vm_data);
} else {
- printk("WARNING: Extension %s, does not have a guest deinit function\n", ext->impl->name);
+ WARNING("WARNING: Extension %s, does not have a guest deinit function\n", ext->impl->name);
}
list_del(&(ext->node));
while (tmp_ext != __stop__lnx_exts[0]) {
- printk("tmp_ext=%p\n", tmp_ext);
+ DEBUG("tmp_ext=%p\n", tmp_ext);
if (tmp_ext->init != NULL) {
- printk("Registering Linux Extension (%s)\n", tmp_ext->name);
+ INFO("Registering Linux Extension (%s)\n", tmp_ext->name);
tmp_ext->init();
}
int i = 0;
while (tmp_ext != __stop__lnx_exts[0]) {
- printk("Cleaning up Linux Extension (%s)\n", tmp_ext->name);
+ INFO("Cleaning up Linux Extension (%s)\n", tmp_ext->name);
if (tmp_ext->deinit != NULL) {
tmp_ext->deinit();
} else {
- printk("WARNING: Extension %s does not have a global deinit function\n", tmp_ext->name);
+ WARNING("WARNING: Extension %s does not have a global deinit function\n", tmp_ext->name);
}
tmp_ext = __start__lnx_exts[++i];
static long v3_dev_ioctl(struct file * filp,
unsigned int ioctl, unsigned long arg) {
void __user * argp = (void __user *)arg;
- printk("V3 IOCTL %d\n", ioctl);
+ DEBUG("V3 IOCTL %d\n", ioctl);
switch (ioctl) {
struct v3_guest * guest = kmalloc(sizeof(struct v3_guest), GFP_KERNEL);
if (IS_ERR(guest)) {
- printk("Palacios: Error allocating Kernel guest_image\n");
+ ERROR("Palacios: Error allocating Kernel guest_image\n");
return -EFAULT;
}
memset(guest, 0, sizeof(struct v3_guest));
- printk("Palacios: Creating V3 Guest...\n");
+ INFO("Palacios: Creating V3 Guest...\n");
vm_minor = register_vm(guest);
if (vm_minor == -1) {
- printk("Palacios Error: Too many VMs are currently running\n");
+ ERROR("Palacios Error: Too many VMs are currently running\n");
return -EFAULT;
}
guest->vm_dev = MKDEV(v3_major_num, vm_minor);
if (copy_from_user(&user_image, argp, sizeof(struct v3_guest_img))) {
- printk("Palacios Error: copy from user error getting guest image...\n");
+ ERROR("Palacios Error: copy from user error getting guest image...\n");
return -EFAULT;
}
guest->img_size = user_image.size;
- printk("Palacios: Allocating kernel memory for guest image (%llu bytes)\n", user_image.size);
+ DEBUG("Palacios: Allocating kernel memory for guest image (%llu bytes)\n", user_image.size);
guest->img = vmalloc(guest->img_size);
if (IS_ERR(guest->img)) {
- printk("Palacios Error: Could not allocate space for guest image\n");
+ ERROR("Palacios Error: Could not allocate space for guest image\n");
return -EFAULT;
}
if (copy_from_user(guest->img, user_image.guest_data, guest->img_size)) {
- printk("Palacios: Error loading guest data\n");
+ ERROR("Palacios: Error loading guest data\n");
return -EFAULT;
}
INIT_LIST_HEAD(&(guest->exts));
if (create_palacios_vm(guest) == -1) {
- printk("Palacios: Error creating guest\n");
+ ERROR("Palacios: Error creating guest\n");
return -EFAULT;
}
unsigned long vm_idx = arg;
struct v3_guest * guest = guest_map[vm_idx];
- printk("Freeing VM (%s) (%p)\n", guest->name, guest);
+ INFO("Freeing VM (%s) (%p)\n", guest->name, guest);
free_palacios_vm(guest);
guest_map[vm_idx] = NULL;
memset(&mem, 0, sizeof(struct v3_mem_region));
if (copy_from_user(&mem, argp, sizeof(struct v3_mem_region))) {
- printk("copy from user error getting mem_region...\n");
+ ERROR("copy from user error getting mem_region...\n");
return -EFAULT;
}
- printk("Adding %llu pages to Palacios memory\n", mem.num_pages);
+ DEBUG("Adding %llu pages to Palacios memory\n", mem.num_pages);
if (add_palacios_memory(mem.base_addr, mem.num_pages) == -1) {
- printk("Error adding memory to Palacios\n");
+ ERROR("Error adding memory to Palacios\n");
return -EFAULT;
}
}
default:
- printk("\tUnhandled\n");
+ ERROR("\tUnhandled\n");
return -EINVAL;
}
v3_class = class_create(THIS_MODULE, "vms");
if (IS_ERR(v3_class)) {
- printk("Failed to register V3 VM device class\n");
+ ERROR("Failed to register V3 VM device class\n");
return PTR_ERR(v3_class);
}
- printk("intializing V3 Control device\n");
+ INFO("intializing V3 Control device\n");
ret = alloc_chrdev_region(&dev, 0, MAX_VMS + 1, "v3vee");
if (ret < 0) {
- printk("Error registering device region for V3 devices\n");
+ ERROR("Error registering device region for V3 devices\n");
goto failure2;
}
dev = MKDEV(v3_major_num, MAX_VMS + 1);
- printk("Creating V3 Control device: Major %d, Minor %d\n", v3_major_num, MINOR(dev));
+ DEBUG("Creating V3 Control device: Major %d, Minor %d\n", v3_major_num, MINOR(dev));
cdev_init(&ctrl_dev, &v3_ctrl_fops);
ctrl_dev.owner = THIS_MODULE;
ctrl_dev.ops = &v3_ctrl_fops;
device_create(v3_class, NULL, dev, NULL, "v3vee");
if (ret != 0) {
- printk("Error adding v3 control device\n");
+ ERROR("Error adding v3 control device\n");
goto failure1;
}
dev_t dev = MKDEV(v3_major_num, MAX_VMS + 1);
- printk("Removing V3 Control device\n");
+ INFO("Removing V3 Control device\n");
palacios_vmm_exit();
- printk("Palacios Mallocs = %d, Frees = %d\n", mallocs, frees);
- printk("Palacios Page Allocs = %d, Page Frees = %d\n", pg_allocs, pg_frees);
+ DEBUG("Palacios Mallocs = %d, Frees = %d\n", mallocs, frees);
+ DEBUG("Palacios Page Allocs = %d, Page Frees = %d\n", pg_allocs, pg_frees);
unregister_chrdev_region(MKDEV(v3_major_num, 0), MAX_VMS + 1);
palacios_deinit_mm();
- printk("Palacios Module Mallocs = %d, Frees = %d\n", mod_allocs, mod_frees);
+ DEBUG("Palacios Module Mallocs = %d, Frees = %d\n", mod_allocs, mod_frees);
}
#include <linux/mm.h>
//static struct list_head pools;
+#include "palacios.h"
struct mempool {
uintptr_t base_addr;
int i = 0;
int start = 0;
- printk("Allocating %llu pages (align=%lu)\n",
+ DEBUG("Allocating %llu pages (align=%lu)\n",
num_pages, (unsigned long)alignment);
if (pool.bitmap == NULL) {
- printk("ERROR: Attempting to allocate from non initialized memory\n");
+ ERROR("ERROR: Attempting to allocate from non initialized memory\n");
return 0;
}
start = ((alignment - (pool.base_addr % alignment)) >> 12);
}
- printk("\t Start idx %d (base_addr=%p)\n", start, (void *)(u64)pool.base_addr);
+ ERROR("\t Start idx %d (base_addr=%p)\n", start, (void *)(u64)pool.base_addr);
for (i = start; i < (pool.num_pages - num_pages); i += step) {
if (get_page_bit(i) == 0) {
}
}
- /* printk("PALACIOS BAD: LARGE PAGE ALLOCATION FAILED\n"); */
+ /* ERROR("PALACIOS BAD: LARGE PAGE ALLOCATION FAILED\n"); */
return 0;
}
WARN(!pgs, "Could not allocate pages\n");
- /* if (!pgs) { printk("PALACIOS BAD: SMALL PAGE ALLOCATION FAILED\n"); } */
+ /* if (!pgs) { ERROR("PALACIOS BAD: SMALL PAGE ALLOCATION FAILED\n"); } */
- /* printk("%llu pages (order=%d) aquired from alloc_pages\n",
+ /* DEBUG("%llu pages (order=%d) aquired from alloc_pages\n",
num_pages, order); */
addr = page_to_pfn(pgs) << PAGE_SHIFT;
} else {
- //printk("Allocating %llu pages from bitmap allocator\n", num_pages);
+ //DEBUG("Allocating %llu pages from bitmap allocator\n", num_pages);
//addr = pool.base_addr;
addr = alloc_contig_pgs(num_pages, alignment);
}
- //printk("Returning from alloc addr=%p, vaddr=%p\n", (void *)addr, __va(addr));
+ //DEBUG("Returning from alloc addr=%p, vaddr=%p\n", (void *)addr, __va(addr));
return addr;
}
void free_palacios_pgs(uintptr_t pg_addr, int num_pages) {
- //printk("Freeing Memory page %p\n", (void *)pg_addr);
+ //DEBUG("Freeing Memory page %p\n", (void *)pg_addr);
if ((pg_addr >= pool.base_addr) &&
(pg_addr < pool.base_addr + (4096 * pool.num_pages))) {
int i = 0;
if ((pg_idx + num_pages) > pool.num_pages) {
- printk("Freeing memory bounds exceeded\n");
+ ERROR("Freeing memory bounds exceeded\n");
return;
}
int bitmap_size = (num_pages / 8) + ((num_pages % 8) > 0);
if (pool.num_pages != 0) {
- printk("ERROR: Memory has already been added\n");
+ ERROR("ERROR: Memory has already been added\n");
return -1;
}
- printk("Managing %dMB of memory starting at %llu (%lluMB)\n",
+ DEBUG("Managing %dMB of memory starting at %llu (%lluMB)\n",
(unsigned int)(num_pages * 4096) / (1024 * 1024),
(unsigned long long)base_addr,
(unsigned long long)(base_addr / (1024 * 1024)));
pool.bitmap = kmalloc(bitmap_size, GFP_KERNEL);
if (IS_ERR(pool.bitmap)) {
- printk("Error allocating Palacios MM bitmap\n");
+ WARNING("Error allocating Palacios MM bitmap\n");
return -1;
}
struct lnx_thread_arg * thread_info = (struct lnx_thread_arg *)arg;
int ret = 0;
/*
- printk("Daemonizing new Palacios thread (name=%s)\n", thread_info->name);
+ INFO("Daemonizing new Palacios thread (name=%s)\n", thread_info->name);
daemonize(thread_info->name);
allow_signal(SIGKILL);
thread = kthread_create( lnx_thread_target, thread_info, thread_name );
if (IS_ERR(thread)) {
- printk("Palacios error creating thread: %s\n", thread_name);
+ WARNING("Palacios error creating thread: %s\n", thread_name);
return NULL;
}
void * thread_ptr) {
struct task_struct * thread = (struct task_struct *)thread_ptr;
- printk("Moving thread (%p) to cpu %d\n", thread, new_cpu_id);
+ INFO("Moving thread (%p) to cpu %d\n", thread, new_cpu_id);
if (thread == NULL) {
thread = current;
static int
palacios_hook_interrupt(struct v3_vm_info * vm,
unsigned int vector ) {
- printk("hooking vector %d\n", vector);
+ INFO("hooking vector %d\n", vector);
if (irq_to_guest_map[vector]) {
- printk(KERN_WARNING
+ WARNING(
"%s: Interrupt vector %u is already hooked.\n",
__func__, vector);
return -1;
}
- printk(KERN_DEBUG
+ DEBUG(
"%s: Hooking interrupt vector %u to vm %p.\n",
__func__, vector, vm);
int flag = 0;
int error;
- printk("hooking vector: %d\n", vector);
+ DEBUG("hooking vector: %d\n", vector);
if (vector == 32) {
flag = IRQF_TIMER;
&device_id);
if (error) {
- printk("error code for request_irq is %d\n", error);
+ ERROR("error code for request_irq is %d\n", error);
panic("request vector %d failed",vector);
}
}
)
{
ack_APIC_irq();
- printk("Pretending to ack interrupt, vector=%d\n",vector);
+ DEBUG("Pretending to ack interrupt, vector=%d\n",vector);
return 0;
}
static unsigned int
palacios_get_cpu_khz(void)
{
- printk("cpu_khz is %u\n",cpu_khz);
+ INFO("cpu_khz is %u\n",cpu_khz);
if (cpu_khz == 0) {
- printk("faking cpu_khz to 1000000\n");
+ INFO("faking cpu_khz to 1000000\n");
return 1000000;
} else {
return cpu_khz;
for (i = 0; i < cpu_list_len; i++) {
if (cpu_list[i] >= num_cpus) {
- printk("CPU (%d) exceeds number of available CPUs. Ignoring...\n", cpu_list[i]);
+ WARNING("CPU (%d) exceeds number of available CPUs. Ignoring...\n", cpu_list[i]);
continue;
}
memset(irq_to_guest_map, 0, sizeof(struct v3_vm_info *) * 256);
- printk("palacios_init starting - calling init_v3\n");
+ INFO("palacios_init starting - calling init_v3\n");
Init_V3(&palacios_os_hooks, cpu_mask, num_cpus);
#include <vnet/vnet.h>
#include <vnet/vnet_hashtable.h>
#include "palacios-vnet.h"
+#include "palacios.h"
#define VNET_SERVER_PORT 9000
vnet_brg_s.num_links --;
spin_unlock_irqrestore(&(vnet_brg_s.lock), flags);
- printk("VNET Bridge: Link deleted, ip 0x%x, port: %d, idx: %d\n",
+ INFO("VNET Bridge: Link deleted, ip 0x%x, port: %d, idx: %d\n",
link->dst_ip,
link->dst_port,
link->idx);
break;
default:
- printk("Unsupported VNET Server Protocol\n");
+ WARNING("Unsupported VNET Server Protocol\n");
return -1;
}
if ((err = sock_create(AF_INET, SOCK_DGRAM, protocol, &link->sock)) < 0) {
- printk("Could not create socket for VNET Link, error %d\n", err);
+ WARNING("Could not create socket for VNET Link, error %d\n", err);
return -1;
}
link->sock_addr.sin_port = htons(link->dst_port);
if ((err = link->sock->ops->connect(link->sock, (struct sockaddr *)&(link->sock_addr), sizeof(struct sockaddr), 0) < 0)) {
- printk("Could not connect to remote VNET Server, error %d\n", err);
+ WARNING("Could not connect to remote VNET Server, error %d\n", err);
return -1;
}
vnet_htable_insert(vnet_brg_s.ip2link, (addr_t)&(link->dst_ip), (addr_t)link);
spin_unlock_irqrestore(&(vnet_brg_s.lock), flags);
- printk("VNET Bridge: Link created, ip 0x%x, port: %d, idx: %d, link: %p, protocol: %s\n",
+ INFO("VNET Bridge: Link created, ip 0x%x, port: %d, idx: %d, link: %p, protocol: %s\n",
link->dst_ip,
link->dst_port,
link->idx,
idx = _create_link(new_link);
if (idx < 0) {
- printk("Could not create link\n");
+ WARNING("Could not create link\n");
kfree(new_link);
return -1;
}
pkt.data = buf;
if(net_debug >= 2){
- printk("VNET Lnx Bridge: send pkt to VNET core (size: %d, src_id: %d, src_type: %d)\n",
+ DEBUG("VNET Lnx Bridge: send pkt to VNET core (size: %d, src_id: %d, src_type: %d)\n",
pkt.size, pkt.src_id, pkt.src_type);
if(net_debug >= 4){
print_hex_dump(NULL, "pkt_data: ", 0, 20, 20, pkt.data, pkt.size, 0);
struct vnet_link * link;
if(net_debug >= 2){
- printk("VNET Lnx Host Bridge: packet received from VNET Core ... pkt size: %d, link: %d\n",
+ DEBUG("VNET Lnx Host Bridge: packet received from VNET Core ... pkt size: %d, link: %d\n",
pkt->size,
pkt->dst_id);
if(net_debug >= 4){
break;
default:
- printk("VNET Server: Invalid Link Protocol\n");
+ WARNING("VNET Server: Invalid Link Protocol\n");
vnet_brg_s.stats.pkt_drop_vmm ++;
}
link->stats.tx_bytes += pkt->size;
link->stats.tx_pkts ++;
} else {
- printk("VNET Bridge Linux Host: wrong dst link, idx: %d, discards the packet\n", pkt->dst_id);
+ INFO("VNET Bridge Linux Host: wrong dst link, idx: %d, discards the packet\n", pkt->dst_id);
vnet_brg_s.stats.pkt_drop_vmm ++;
}
break;
default:
- printk("Unsupported VNET Server Protocol\n");
+ WARNING("Unsupported VNET Server Protocol\n");
return -1;
}
if ((err = sock_create(AF_INET, SOCK_DGRAM, protocol, &vnet_brg_s.serv_sock)) < 0) {
- printk("Could not create VNET server socket, error: %d\n", err);
+ WARNING("Could not create VNET server socket, error: %d\n", err);
return -1;
}
vnet_brg_s.serv_addr.sin_port = htons(VNET_SERVER_PORT);
if ((err = vnet_brg_s.serv_sock->ops->bind(vnet_brg_s.serv_sock, (struct sockaddr *)&(vnet_brg_s.serv_addr), sizeof(struct sockaddr))) < 0) {
- printk("Could not bind VNET server socket to port %d, error: %d\n", VNET_SERVER_PORT, err);
+ WARNING("Could not bind VNET server socket to port %d, error: %d\n", VNET_SERVER_PORT, err);
return -1;
}
- printk("VNET server bind to port: %d\n", VNET_SERVER_PORT);
+ INFO("VNET server bind to port: %d\n", VNET_SERVER_PORT);
if(vnet_brg_s.serv_proto == TCP){
if((err = vnet_brg_s.serv_sock->ops->listen(vnet_brg_s.serv_sock, 32)) < 0){
- printk("VNET Server error listening on port %d, error %d\n", VNET_SERVER_PORT, err);
+ WARNING("VNET Server error listening on port %d, error %d\n", VNET_SERVER_PORT, err);
return -1;
}
}
struct vnet_link * link = NULL;
int len;
- printk("Palacios VNET Bridge: UDP receiving server ..... \n");
+ INFO("Palacios VNET Bridge: UDP receiving server ..... \n");
pkt = kmalloc(MAX_PACKET_LEN, GFP_KERNEL);
while (!kthread_should_stop()) {
len = _udp_recv(vnet_brg_s.serv_sock, &pkt_addr, pkt, MAX_PACKET_LEN);
if(len < 0) {
- printk("Receive error: Could not get packet, error %d\n", len);
+ WARNING("Receive error: Could not get packet, error %d\n", len);
continue;
}
link = _link_by_ip(pkt_addr.sin_addr.s_addr);
if (link == NULL){
- printk("VNET Server: No VNET Link match the src IP\n");
+ WARNING("VNET Server: No VNET Link match the src IP\n");
vnet_brg_s.stats.pkt_drop_phy ++;
continue;
}
//use select to receive pkt from physical network
//or create new kthread to handle each connection?
}else {
- printk ("VNET Server: Unsupported Protocol\n");
+ WARNING ("VNET Server: Unsupported Protocol\n");
return -1;
}
vnet_brg_s.ip2link = vnet_create_htable(10, hash_fn, hash_eq);
if(vnet_brg_s.ip2link == NULL){
- printk("Failure to initiate VNET link hashtable\n");
+ WARNING("Failure to initiate VNET link hashtable\n");
return -1;
}
if(init_vnet_serv() < 0){
- printk("Failure to initiate VNET server\n");
+ WARNING("Failure to initiate VNET server\n");
return -1;
}
bridge_ops.poll = NULL;
if( v3_vnet_add_bridge(NULL, &bridge_ops, HOST_LNX_BRIDGE, NULL) < 0){
- printk("VNET LNX Bridge: Fails to register bridge to VNET core");
+ WARNING("VNET LNX Bridge: Fails to register bridge to VNET core");
}
- printk("VNET Linux Bridge initiated\n");
+ INFO("VNET Linux Bridge initiated\n");
return 0;
}
#include <vnet/vnet.h>
#include <vnet/vnet_hashtable.h>
#include "palacios-vnet.h"
+#include "palacios.h"
#define VNET_SERVER_PORT 9000
static int parse_mac_str(char * str, uint8_t * qual, uint8_t * mac) {
char * token;
- printk("Parsing MAC (%s)\n", str);
+ INFO("Parsing MAC (%s)\n", str);
*qual = MAC_NOSET;
if(strnicmp("any", str, strlen(str)) == 0){
if (strnicmp("not", token, strlen("not")) == 0) {
*qual = MAC_NOT;
} else {
- printk("Invalid MAC String token (%s)\n", token);
+ WARNING("Invalid MAC String token (%s)\n", token);
return -1;
}
}
for (i = 0; i < 6; i++) {
token = strsep(&str, ":");
if (!token) {
- printk("Invalid MAC String token (%s)\n", token);
+ WARNING("Invalid MAC String token (%s)\n", token);
return -1;
}
mac[i] = simple_strtol(token, &token, 16);
}
- printk("MAC: %2x:%2x:%2x:%2x:%2x:%2x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ DEBUG("MAC: %2x:%2x:%2x:%2x:%2x:%2x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}else {
- printk("Invalid MAC String token (%s)\n", token);
+ WARNING("Invalid MAC String token (%s)\n", token);
return -1;
}
for (i = 0; i < ETH_ALEN; i++) {
hex = strsep(&str, ":");
if (!hex) {
- printk("Invalid MAC String token (%s)\n", str);
+ WARNING("Invalid MAC String token (%s)\n", str);
return -1;
}
mac[i] = simple_strtol(hex, &hex, 16);
if (!token) {
return -1;
}
- printk("dst type =(%s)\n", token);
+ INFO("dst type =(%s)\n", token);
if (strnicmp("interface", token, strlen("interface")) == 0) {
route->dst_type = LINK_INTERFACE;
} else if (strnicmp("edge", token, strlen("edge")) == 0) {
route->dst_type = LINK_EDGE;
} else {
- printk("Invalid Destination Link Type (%s)\n", token);
+ WARNING("Invalid Destination Link Type (%s)\n", token);
return -1;
}
if (!token) {
return -1;
}
- printk("dst ID=(%s)\n", token);
+ DEBUG("dst ID=(%s)\n", token);
// Figure out link here
if (route->dst_type == LINK_EDGE) {
// Figure out Link Here
if (in4_pton(token, strlen(token), (uint8_t *)&(link_ip), '\0', NULL) != 1) {
- printk("Invalid Dst IP address (%s)\n", token);
+ WARNING("Invalid Dst IP address (%s)\n", token);
return -EFAULT;
}
if (link != NULL){
route->dst_id = link->idx;
}else{
- printk("can not find dst link %s\n", token);
+ WARNING("can not find dst link %s\n", token);
return -1;
}
- printk("link_ip = %d, link_id = %d\n", link_ip, link->idx);
+ INFO("link_ip = %d, link_id = %d\n", link_ip, link->idx);
} else if (route->dst_type == LINK_INTERFACE) {
uint8_t mac[ETH_ALEN];
if(str2mac(token, mac) == -1){
- printk("wrong MAC format (%s)\n", token);
+ WARNING("wrong MAC format (%s)\n", token);
return -1;
}
route->dst_id = v3_vnet_find_dev(mac);
if (route->dst_id == -1){
- printk("can not find dst device %s\n", token);
+ WARNING("can not find dst device %s\n", token);
return -1;
}
} else {
- printk("Unsupported dst link type\n");
+ WARNING("Unsupported dst link type\n");
return -1;
}
// src LINK
token = strsep(&str, " ");
- printk("SRC type = %s\n", token);
+ INFO("SRC type = %s\n", token);
if (!token) {
return -1;
} else if (strnicmp("any", token, strlen("any")) == 0) {
route->src_type = LINK_ANY;
} else {
- printk("Invalid Src link type (%s)\n", token);
+ WARNING("Invalid Src link type (%s)\n", token);
return -1;
}
// Figure out Link Here
if (in4_pton(token, strlen(token), (uint8_t *)&(src_ip), '\0', NULL) != 1) {
- printk("Invalid SRC IP address (%s)\n", token);
+ WARNING("Invalid SRC IP address (%s)\n", token);
return -EFAULT;
}
if (link != NULL){
route->src_id = link->idx;
}else{
- printk("can not find src link %s\n", token);
+ WARNING("can not find src link %s\n", token);
return -1;
}
} else if(route->src_type == LINK_INTERFACE){
uint8_t mac[ETH_ALEN];
if(str2mac(token, mac) == -1){
- printk("wrong MAC format (%s)\n", token);
+ WARNING("wrong MAC format (%s)\n", token);
return -1;
}
route->src_id = v3_vnet_find_dev(mac);
if (route->src_id == -1){
- printk("can not find dst device %s\n", token);
+ WARNING("can not find dst device %s\n", token);
return -1;
}
} else {
- printk("Invalid link type\n");
+ WARNING("Invalid link type\n");
return -1;
}
vnet_ctrl_s.num_routes ++;
spin_unlock_irqrestore(&(vnet_ctrl_s.lock), flags);
- printk("VNET Control: One route added to VNET core\n");
+ INFO("VNET Control: One route added to VNET core\n");
return 0;
}
vnet_ctrl_s.num_routes --;
spin_unlock_irqrestore(&(vnet_ctrl_s.lock), flags);
- printk("VNET Control: Route %d deleted from VNET\n", route->idx);
+ INFO("VNET Control: Route %d deleted from VNET\n", route->idx);
kfree(route);
route = NULL;
}
route_buf[size] = '\0';
- printk("Route written: %s\n", route_buf);
+ INFO("Route written: %s\n", route_buf);
while ((buf_iter = strsep(&line_str, "\r\n"))) {
idx_str = strsep(&buf_iter, " ");
if (!idx_str) {
- printk("Missing route idx in DEL Route command\n");
+ WARNING("Missing route idx in DEL Route command\n");
return -EFAULT;
}
d_idx = simple_strtoul(idx_str, &idx_str, 10);
- printk("VNET: deleting route %d\n", d_idx);
+ INFO("VNET: deleting route %d\n", d_idx);
list_for_each_entry(route, &(vnet_ctrl_s.route_list), node) {
if (route->idx == d_idx) {
}
}
} else {
- printk("Invalid Route command string\n");
+ WARNING("Invalid Route command string\n");
}
}
}
while ((link_iter = strsep(&line_str, "\r\n"))) {
- printk("Link written: %s\n", link_buf);
+ DEBUG("Link written: %s\n", link_buf);
token = strsep(&link_iter, " ");
ip_str = strsep(&link_iter, " ");
if ((!ip_str) || (!link_iter)) {
- printk("Missing fields in ADD Link command\n");
+ WARNING("Missing fields in ADD Link command\n");
return -EFAULT;
}
if (in4_pton(ip_str, strlen(ip_str), (uint8_t *)&(d_ip), '\0', NULL) != 1) {
- printk("Invalid Dst IP address (%s)\n", ip_str);
+ WARNING("Invalid Dst IP address (%s)\n", ip_str);
return -EFAULT;
}
link_idx = vnet_brg_add_link(d_ip, d_port, d_proto);
if(link_idx < 0){
- printk("VNET Control: Failed to create link\n");
+ WARNING("VNET Control: Failed to create link\n");
return -EFAULT;
}
idx_str = strsep(&link_iter, " ");
if (!idx_str) {
- printk("Missing link idx in DEL Link command\n");
+ WARNING("Missing link idx in DEL Link command\n");
return -EFAULT;
}
vnet_brg_delete_link(d_idx);
- printk("VNET Control: One link deleted\n");
+ DEBUG("VNET Control: One link deleted\n");
} else {
- printk("Invalid Link command string\n");
+ WARNING("Invalid Link command string\n");
}
}
in_iter = strsep(&line_str, "\r\n");
level = simple_strtol(in_iter, &in_iter, 10);
- printk("VNET Control: Set VNET Debug level to %d\n", level);
+ DEBUG("VNET Control: Set VNET Debug level to %d\n", level);
if(level >= 0){
net_debug = level;
init_proc_files();
- printk("VNET Linux control module initiated\n");
+ NOTICE("VNET Linux control module initiated\n");
return 0;
}
vnet_bridge_init();
vnet_ctrl_init();
- printk("V3 VNET Inited\n");
+ INFO("V3 VNET Inited\n");
return 0;
}
vnet_bridge_deinit();
vnet_ctrl_deinit();
- printk("V3 VNET Deinited\n");
+ INFO("V3 VNET Deinited\n");
return 0;
}
struct vm_ctrl * ctrl = kmalloc(sizeof(struct vm_ctrl), GFP_KERNEL);
if (ctrl == NULL) {
- printk("Error: Could not allocate vm ctrl %d\n", cmd);
+ WARNING("Error: Could not allocate vm ctrl %d\n", cmd);
return -1;
}
ctrl->priv_data = priv_data;
if (__insert_ctrl(guest, ctrl) != NULL) {
- printk("Could not insert guest ctrl %d\n", cmd);
+ WARNING("Could not insert guest ctrl %d\n", cmd);
kfree(ctrl);
return -1;
}
struct v3_guest * guest = filp->private_data;
- printk("V3 IOCTL %d\n", ioctl);
+ INFO("V3 IOCTL %d\n", ioctl);
switch (ioctl) {
case V3_VM_LAUNCH: {
- printk("palacios: launching vm\n");
+ NOTICE("palacios: launching vm\n");
if (v3_start_vm(guest->v3_ctx, (0x1 << num_online_cpus()) - 1) < 0) {
- printk("palacios: launch of vm failed\n");
+ WARNING("palacios: launch of vm failed\n");
return -1;
}
break;
}
case V3_VM_STOP: {
- printk("Stopping VM (%s) (%p)\n", guest->name, guest);
+ NOTICE("Stopping VM (%s) (%p)\n", guest->name, guest);
if (irqs_disabled()) {
- printk("WHAT!!?? IRQs are disabled??\n");
+ ERROR("WHAT!!?? IRQs are disabled??\n");
break;
}
break;
}
case V3_VM_PAUSE: {
- printk("Pausing VM (%s)\n", guest->name);
+ NOTICE("Pausing VM (%s)\n", guest->name);
v3_pause_vm(guest->v3_ctx);
break;
}
case V3_VM_CONTINUE: {
- printk("Continuing VM (%s)\n", guest->name);
+ NOTICE("Continuing VM (%s)\n", guest->name);
v3_continue_vm(guest->v3_ctx);
break;
}
case V3_VM_SIMULATE: {
- printk("Simulating VM (%s) for %lu msecs\n", guest->name, arg);
+ NOTICE("Simulating VM (%s) for %lu msecs\n", guest->name, arg);
v3_simulate_vm(guest->v3_ctx, arg);
break;
}
memset(&chkpt, 0, sizeof(struct v3_chkpt_info));
if (copy_from_user(&chkpt, argp, sizeof(struct v3_chkpt_info))) {
- printk("Copy from user error getting checkpoint info\n");
+ WARNING("Copy from user error getting checkpoint info\n");
return -EFAULT;
}
- printk("Saving Guest to %s:%s\n", chkpt.store, chkpt.url);
+ NOTICE("Saving Guest to %s:%s\n", chkpt.store, chkpt.url);
if (v3_save_vm(guest->v3_ctx, chkpt.store, chkpt.url) == -1) {
- printk("Error checkpointing VM state\n");
+ WARNING("Error checkpointing VM state\n");
return -EFAULT;
}
memset(&chkpt, 0, sizeof(struct v3_chkpt_info));
if (copy_from_user(&chkpt, argp, sizeof(struct v3_chkpt_info))) {
- printk("Copy from user error getting checkpoint info\n");
+ WARNING("Copy from user error getting checkpoint info\n");
return -EFAULT;
}
- printk("Loading Guest to %s:%s\n", chkpt.store, chkpt.url);
+ NOTICE("Loading Guest to %s:%s\n", chkpt.store, chkpt.url);
if (v3_load_vm(guest->v3_ctx, chkpt.store, chkpt.url) == -1) {
- printk("Error Loading VM state\n");
+ WARNING("Error Loading VM state\n");
return -EFAULT;
}
memset(&cmd, 0, sizeof(struct v3_core_move_cmd));
if (copy_from_user(&cmd, argp, sizeof(struct v3_core_move_cmd))) {
- printk("copy from user error getting migrate command...\n");
+ WARNING("copy from user error getting migrate command...\n");
return -EFAULT;
}
- printk("moving guest %s vcore %d to CPU %d\n", guest->name, cmd.vcore_id, cmd.pcore_id);
+ INFO("moving guest %s vcore %d to CPU %d\n", guest->name, cmd.vcore_id, cmd.pcore_id);
v3_move_vm_core(guest->v3_ctx, cmd.vcore_id, cmd.pcore_id);
}
- printk("\tUnhandled ctrl cmd: %d\n", ioctl);
+ WARNING("\tUnhandled ctrl cmd: %d\n", ioctl);
return -EINVAL;
}
}
guest->v3_ctx = v3_create_vm(guest->img, (void *)guest, guest->name);
if (guest->v3_ctx == NULL) {
- printk("palacios: failed to create vm\n");
+ WARNING("palacios: failed to create vm\n");
return -1;
}
- printk("Creating VM device: Major %d, Minor %d\n", MAJOR(guest->vm_dev), MINOR(guest->vm_dev));
+ NOTICE("Creating VM device: Major %d, Minor %d\n", MAJOR(guest->vm_dev), MINOR(guest->vm_dev));
cdev_init(&(guest->cdev), &v3_vm_fops);
guest->cdev.ops = &v3_vm_fops;
- printk("Adding VM device\n");
+ INFO("Adding VM device\n");
err = cdev_add(&(guest->cdev), guest->vm_dev, 1);
if (err) {
- printk("Fails to add cdev\n");
+ WARNING("Fails to add cdev\n");
v3_free_vm(guest->v3_ctx);
return -1;
}
if (device_create(v3_class, NULL, guest->vm_dev, guest, "v3-vm%d", MINOR(guest->vm_dev)) == NULL){
- printk("Fails to create device\n");
+ WARNING("Fails to create device\n");
cdev_del(&(guest->cdev));
v3_free_vm(guest->v3_ctx);
return -1;
}
- printk("palacios: vm created at /dev/v3-vm%d\n", MINOR(guest->vm_dev));
+ NOTICE("palacios: vm created at /dev/v3-vm%d\n", MINOR(guest->vm_dev));
return 0;
}