diff options
author | K. Y. Srinivasan <kys@microsoft.com> | 2012-02-02 19:56:50 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-02-09 11:32:44 -0500 |
commit | 2640335438ca4d7b139e114dae5f0d80e740e106 (patch) | |
tree | 0e254e2147dedefe04e385d0c97a9fbc15df2a23 /tools/hv | |
parent | eab6af71f0b83a7f62b9c48be5b2c0a82a86fad3 (diff) |
drivers: hv: kvp: Cleanup the kernel/user protocol
Now, cleanup the user/kernel KVP protocol by using the same structure
definition that is used for host/guest KVP protocol. This simplifies the code.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/hv')
-rw-r--r-- | tools/hv/hv_kvp_daemon.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index b75523cde2cd..4ebf70380582 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c | |||
@@ -302,7 +302,7 @@ int main(void) | |||
302 | struct pollfd pfd; | 302 | struct pollfd pfd; |
303 | struct nlmsghdr *incoming_msg; | 303 | struct nlmsghdr *incoming_msg; |
304 | struct cn_msg *incoming_cn_msg; | 304 | struct cn_msg *incoming_cn_msg; |
305 | struct hv_ku_msg *hv_msg; | 305 | struct hv_kvp_msg *hv_msg; |
306 | char *p; | 306 | char *p; |
307 | char *key_value; | 307 | char *key_value; |
308 | char *key_name; | 308 | char *key_name; |
@@ -340,9 +340,11 @@ int main(void) | |||
340 | message = (struct cn_msg *)kvp_send_buffer; | 340 | message = (struct cn_msg *)kvp_send_buffer; |
341 | message->id.idx = CN_KVP_IDX; | 341 | message->id.idx = CN_KVP_IDX; |
342 | message->id.val = CN_KVP_VAL; | 342 | message->id.val = CN_KVP_VAL; |
343 | message->seq = KVP_REGISTER; | 343 | |
344 | hv_msg = (struct hv_kvp_msg *)message->data; | ||
345 | hv_msg->kvp_hdr.operation = KVP_OP_REGISTER; | ||
344 | message->ack = 0; | 346 | message->ack = 0; |
345 | message->len = 0; | 347 | message->len = sizeof(struct hv_kvp_msg); |
346 | 348 | ||
347 | len = netlink_send(fd, message); | 349 | len = netlink_send(fd, message); |
348 | if (len < 0) { | 350 | if (len < 0) { |
@@ -368,14 +370,15 @@ int main(void) | |||
368 | 370 | ||
369 | incoming_msg = (struct nlmsghdr *)kvp_recv_buffer; | 371 | incoming_msg = (struct nlmsghdr *)kvp_recv_buffer; |
370 | incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg); | 372 | incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg); |
373 | hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data; | ||
371 | 374 | ||
372 | switch (incoming_cn_msg->seq) { | 375 | switch (hv_msg->kvp_hdr.operation) { |
373 | case KVP_REGISTER: | 376 | case KVP_OP_REGISTER: |
374 | /* | 377 | /* |
375 | * Driver is registering with us; stash away the version | 378 | * Driver is registering with us; stash away the version |
376 | * information. | 379 | * information. |
377 | */ | 380 | */ |
378 | p = (char *)incoming_cn_msg->data; | 381 | p = (char *)hv_msg->body.kvp_version; |
379 | lic_version = malloc(strlen(p) + 1); | 382 | lic_version = malloc(strlen(p) + 1); |
380 | if (lic_version) { | 383 | if (lic_version) { |
381 | strcpy(lic_version, p); | 384 | strcpy(lic_version, p); |
@@ -386,17 +389,15 @@ int main(void) | |||
386 | } | 389 | } |
387 | continue; | 390 | continue; |
388 | 391 | ||
389 | case KVP_KERNEL_GET: | ||
390 | break; | ||
391 | default: | 392 | default: |
392 | continue; | 393 | break; |
393 | } | 394 | } |
394 | 395 | ||
395 | hv_msg = (struct hv_ku_msg *)incoming_cn_msg->data; | 396 | hv_msg = (struct hv_kvp_msg *)incoming_cn_msg->data; |
396 | key_name = (char *)hv_msg->kvp_key; | 397 | key_name = (char *)hv_msg->body.kvp_enum_data.data.key; |
397 | key_value = (char *)hv_msg->kvp_value; | 398 | key_value = (char *)hv_msg->body.kvp_enum_data.data.value; |
398 | 399 | ||
399 | switch (hv_msg->kvp_index) { | 400 | switch (hv_msg->body.kvp_enum_data.index) { |
400 | case FullyQualifiedDomainName: | 401 | case FullyQualifiedDomainName: |
401 | kvp_get_domain_name(key_value, | 402 | kvp_get_domain_name(key_value, |
402 | HV_KVP_EXCHANGE_MAX_VALUE_SIZE); | 403 | HV_KVP_EXCHANGE_MAX_VALUE_SIZE); |
@@ -456,9 +457,8 @@ int main(void) | |||
456 | 457 | ||
457 | incoming_cn_msg->id.idx = CN_KVP_IDX; | 458 | incoming_cn_msg->id.idx = CN_KVP_IDX; |
458 | incoming_cn_msg->id.val = CN_KVP_VAL; | 459 | incoming_cn_msg->id.val = CN_KVP_VAL; |
459 | incoming_cn_msg->seq = KVP_USER_SET; | ||
460 | incoming_cn_msg->ack = 0; | 460 | incoming_cn_msg->ack = 0; |
461 | incoming_cn_msg->len = sizeof(struct hv_ku_msg); | 461 | incoming_cn_msg->len = sizeof(struct hv_kvp_msg); |
462 | 462 | ||
463 | len = netlink_send(fd, incoming_cn_msg); | 463 | len = netlink_send(fd, incoming_cn_msg); |
464 | if (len < 0) { | 464 | if (len < 0) { |