From: Jack Lange Date: Mon, 13 Jun 2011 20:58:26 +0000 (-0500) Subject: removed BKL acquisition from daemonization of kernel threads in linux module X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=c1c2c17d6e7655447a16345089b1da7fa5819b6c removed BKL acquisition from daemonization of kernel threads in linux module In linux 2.6.39, the BKL has been completely removed so the lock_kernel calls no longer exist. Also lock_kernel was not considered necessary, so removing it should be fine on earlier kernels. --- diff --git a/linux_module/Makefile b/linux_module/Makefile index bedce06..1a48a04 100644 --- a/linux_module/Makefile +++ b/linux_module/Makefile @@ -33,20 +33,13 @@ v3vee-$(V3_CONFIG_VNET) += palacios-vnet.o \ palacios-vnet-brg.o - - - v3vee-objs := $(v3vee-y) ../libv3vee.a - obj-m := v3vee.o - all: $(MAKE) -C $(V3_CONFIG_LINUX_KERN) M=$(PWD) modules - - clean: $(MAKE) -C $(V3_CONFIG_LINUX_KERN) M=$(PWD) clean diff --git a/linux_module/palacios-packet.c b/linux_module/palacios-packet.c index d51c7e7..667f548 100644 --- a/linux_module/palacios-packet.c +++ b/linux_module/palacios-packet.c @@ -66,35 +66,38 @@ static int palacios_packet_add_recver(const char * mac, } static int palacios_packet_del_recver(const char * mac, - struct v3_vm_info * vm){ + struct v3_vm_info * vm){ return 0; } -static int init_raw_socket (const char * eth_dev){ +static int init_raw_socket(const char * eth_dev){ int err; struct sockaddr_ll sock_addr; struct ifreq if_req; int dev_idx; err = sock_create(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL), &(packet_state.raw_sock)); + if (err < 0) { printk(KERN_WARNING "Could not create a PF_PACKET Socket, err %d\n", err); return -1; } - if(eth_dev == NULL){ + if (eth_dev == NULL){ eth_dev = "eth0"; /* default "eth0" */ } memset(&if_req, 0, sizeof(if_req)); strncpy(if_req.ifr_name, eth_dev, IFNAMSIZ); //sizeof(if_req.ifr_name)); + err = packet_state.raw_sock->ops->ioctl(packet_state.raw_sock, SIOCGIFINDEX, (long)&if_req); - if(err < 0){ - printk(KERN_WARNING "Palacios Packet: Unable to get index for device %s, error %d\n", if_req.ifr_name, err); + + if (err < 0){ + printk(KERN_WARNING "Palacios Packet: Unable to get index for device %s, error %d\n", + if_req.ifr_name, err); dev_idx = 2; /* match ALL 2:"eth0" */ - } - else{ + } else { dev_idx = if_req.ifr_ifindex; } @@ -105,7 +108,10 @@ static int init_raw_socket (const char * eth_dev){ sock_addr.sll_protocol = htons(ETH_P_ALL); sock_addr.sll_ifindex = dev_idx; - err = packet_state.raw_sock->ops->bind(packet_state.raw_sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)); + err = packet_state.raw_sock->ops->bind(packet_state.raw_sock, + (struct sockaddr *)&sock_addr, + sizeof(sock_addr)); + if (err < 0){ printk(KERN_WARNING "Error binding raw packet to device %s, %d\n", eth_dev, err); return -1; @@ -208,6 +214,7 @@ static int packet_server(void * arg) { while (!kthread_should_stop()) { size = recv_pkt(pkt, ETHERNET_PACKET_LEN); + if (size < 0) { printk(KERN_WARNING "Palacios raw packet receive error, Server terminated\n"); break; @@ -223,7 +230,8 @@ static int packet_server(void * arg) { vm = (struct v3_vm_info *)v3_htable_search(packet_state.mac_vm_cache, (addr_t)pkt); - if(vm != NULL){ + + if (vm != NULL){ printk("Find destinated VM 0x%p\n", vm); send_raw_packet_to_palacios(pkt, size, vm); } @@ -237,10 +245,10 @@ static int packet_init( void ) { const char * eth_dev = NULL; - if(packet_state.inited == 0){ + if (packet_state.inited == 0){ packet_state.inited = 1; - if(init_raw_socket(eth_dev) == -1){ + if (init_raw_socket(eth_dev) == -1){ printk("Error to initiate palacios packet interface\n"); return -1; } @@ -253,7 +261,7 @@ static int packet_init( void ) { } - // REGISTER GLOBAL CONTROL to add devices... + // REGISTER GLOBAL CONTROL to add interfaces... return 0; } diff --git a/linux_module/palacios-vm.c b/linux_module/palacios-vm.c index 04b338a..e98be0c 100644 --- a/linux_module/palacios-vm.c +++ b/linux_module/palacios-vm.c @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -189,10 +188,10 @@ int start_palacios_vm(void * arg) { struct v3_guest * guest = (struct v3_guest *)arg; int err; - lock_kernel(); + daemonize(guest->name); // allow_signal(SIGKILL); - unlock_kernel(); + init_vm_extensions(guest); diff --git a/linux_module/palacios-vnet.h b/linux_module/palacios-vnet.h index 56ac9f1..6acf6c9 100644 --- a/linux_module/palacios-vnet.h +++ b/linux_module/palacios-vnet.h @@ -8,8 +8,6 @@ #include -int palacios_vnet_init(void); -void palacios_vnet_deinit(void); typedef enum {UDP, TCP, RAW, NONE} vnet_brg_proto_t; @@ -26,6 +24,8 @@ void vnet_brg_delete_link(uint32_t idx); uint32_t vnet_brg_add_link(uint32_t ip, uint16_t port, vnet_brg_proto_t proto); int vnet_brg_link_stats(uint32_t link_idx, struct nic_statistics * stats); int vnet_brg_stats(struct vnet_brg_stats * stats); + + int vnet_bridge_init(void); void vnet_bridge_deinit(void); diff --git a/linux_module/palacios.c b/linux_module/palacios.c index fc64360..b59f2fb 100644 --- a/linux_module/palacios.c +++ b/linux_module/palacios.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -158,11 +157,9 @@ static int lnx_thread_target(void * arg) { struct lnx_thread_arg * thread_info = (struct lnx_thread_arg *)arg; /* - lock_kernel(); printk("Daemonizing new Palacios thread (name=%s)\n", thread_info->name); daemonize(thread_info->name); - unlock_kernel(); allow_signal(SIGKILL); */