Skip to content

Commit

Permalink
Unload issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
varanasisaigithub committed Apr 15, 2014
1 parent d99b1d5 commit 24b57d4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
42 changes: 37 additions & 5 deletions utilities/hv_kvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/*-
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
Expand Down Expand Up @@ -81,6 +81,9 @@ __FBSDID("$FreeBSD$");
#include <sys/endian.h>
#include <sys/_null.h>

#include <sys/iconv.h>
#include <sys/signal.h>

#include <net/if_arp.h>

#include <dev/hyperv/include/hyperv.h>
Expand Down Expand Up @@ -120,6 +123,7 @@ static struct cdevsw hv_kvp_cdevsw =
static struct timeout_task delay_task;
static struct cdev *hv_kvp_dev;
static struct hv_kvp_msg *hv_kvp_dev_buf;
struct proc *daemon_task;

/*
* We maintain a global state, assuming only one transaction can be active
Expand Down Expand Up @@ -386,6 +390,27 @@ hv_kvp_convert_utf8_ipinfo_to_utf16(struct hv_kvp_msg *umsg,
struct hv_kvp_ip_msg *host_ip_msg)
{
int err_ip, err_subnet, err_gway, err_dns, err_adap;


/*{
void *handle;
const char *src;
char *dst;
size_t src_len, dst_len;
src = (char *)umsg->body.kvp_ip_val.ip_addr;
dst = (char *)host_ip_msg->kvp_ip_val.ip_addr;
src_len = (size_t)strlen((char *)umsg->body.kvp_ip_val.ip_addr);
dst_len = (size_t)MAX_IP_ADDR_SIZE;
iconv_open("UTF16LE", "UTF8", &handle);
iconv_conv(handle,
&src,
&src_len,
&dst,
&dst_len);
iconv_close(handle);
printf("%s\n",dst);
}*/

hv_kvp_convert8_to_16((uint16_t *)host_ip_msg->kvp_ip_val.ip_addr,
MAX_IP_ADDR_SIZE,
Expand Down Expand Up @@ -831,7 +856,7 @@ hv_kvp_dev_init(void)
0,
UID_ROOT,
GID_WHEEL,
0600,
0640,
"hv_kvp_dev");

if (error != 0)
Expand All @@ -852,21 +877,28 @@ static void
hv_kvp_dev_destroy(void)
{

if (daemon_task != NULL) {
PROC_LOCK(daemon_task);
kern_psignal(daemon_task, SIGKILL);
PROC_UNLOCK(daemon_task);
}

destroy_dev(hv_kvp_dev);
free(hv_kvp_dev_buf, M_HV_KVP_DEV_BUF);
return;
}


static int
hv_kvp_dev_open(struct cdev *dev __unused, int oflags __unused, int devtype __unused,
struct thread *td __unused)
hv_kvp_dev_open(struct cdev *dev, int oflags, int devtype,
struct thread *td)
{

uprintf("Opened device \"hv_kvp_device\" successfully.\n");
if (dev_accessed)
return (-EBUSY);

daemon_task = curproc;
dev_accessed = TRUE;
return (0);
}
Expand Down
8 changes: 7 additions & 1 deletion utilities/hv_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ hv_vmbus_service service_table[] = {
*/
uint8_t *receive_buffer[HV_MAX_UTIL_SERVICES];

static boolean_t destroyed_kvp = FALSE;

struct hv_ictimesync_data {
uint64_t parenttime;
uint64_t childtime;
Expand Down Expand Up @@ -428,6 +430,11 @@ hv_util_detach(device_t dev)
struct hv_vmbus_service* service;
size_t receive_buffer_offset;

if (!destroyed_kvp) {
hv_kvp_deinit();
destroyed_kvp = TRUE;
}

hv_dev = vmbus_get_devctx(dev);

hv_vmbus_channel_close(hv_dev->channel);
Expand All @@ -454,7 +461,6 @@ hv_util_modevent(module_t mod, int event, void *arg)
case MOD_LOAD:
break;
case MOD_UNLOAD:
hv_kvp_deinit();
break;
default:
break;
Expand Down

0 comments on commit 24b57d4

Please sign in to comment.