Lines 128-140
Link Here
|
128 |
{ |
128 |
{ |
129 |
int ret; |
129 |
int ret; |
130 |
|
130 |
|
131 |
if ((ret = write_msg(blkif->fds[WRITE], CTLMSG_PID, blkif, NULL)) |
131 |
if ((ret = write_msg(blkif->fds[BLKTAP_WRITE], CTLMSG_PID, blkif, NULL)) |
132 |
<= 0) { |
132 |
<= 0) { |
133 |
DPRINTF("Write_msg failed - CTLMSG_PID(%d)\n", ret); |
133 |
DPRINTF("Write_msg failed - CTLMSG_PID(%d)\n", ret); |
134 |
return -EINVAL; |
134 |
return -EINVAL; |
135 |
} |
135 |
} |
136 |
|
136 |
|
137 |
if ((ret = read_msg(blkif->fds[READ], CTLMSG_PID_RSP, blkif)) |
137 |
if ((ret = read_msg(blkif->fds[BLKTAP_READ], CTLMSG_PID_RSP, blkif)) |
138 |
<= 0) { |
138 |
<= 0) { |
139 |
DPRINTF("Read_msg failure - CTLMSG_PID(%d)\n", ret); |
139 |
DPRINTF("Read_msg failure - CTLMSG_PID(%d)\n", ret); |
140 |
return -EINVAL; |
140 |
return -EINVAL; |
Lines 576-583
Link Here
|
576 |
} |
576 |
} |
577 |
|
577 |
|
578 |
DPRINTF("Using tapdisk-ioemu connection\n"); |
578 |
DPRINTF("Using tapdisk-ioemu connection\n"); |
579 |
blkif->fds[READ] = dom0_readfd; |
579 |
blkif->fds[BLKTAP_READ] = dom0_readfd; |
580 |
blkif->fds[WRITE] = dom0_writefd; |
580 |
blkif->fds[BLKTAP_WRITE] = dom0_writefd; |
581 |
|
581 |
|
582 |
if (refresh_pid) { |
582 |
if (refresh_pid) { |
583 |
get_tapdisk_pid(blkif); |
583 |
get_tapdisk_pid(blkif); |
Lines 587-594
Link Here
|
587 |
} else if (access(rdctldev, R_OK | W_OK) == 0) { |
587 |
} else if (access(rdctldev, R_OK | W_OK) == 0) { |
588 |
/* Use existing pipe to the device model */ |
588 |
/* Use existing pipe to the device model */ |
589 |
DPRINTF("Using qemu-dm connection\n"); |
589 |
DPRINTF("Using qemu-dm connection\n"); |
590 |
blkif->fds[READ] = open_ctrl_socket(wrctldev); |
590 |
blkif->fds[BLKTAP_READ] = open_ctrl_socket(wrctldev); |
591 |
blkif->fds[WRITE] = open_ctrl_socket(rdctldev); |
591 |
blkif->fds[BLKTAP_WRITE] = open_ctrl_socket(rdctldev); |
592 |
} else { |
592 |
} else { |
593 |
/* No device model => try with tapdisk-ioemu */ |
593 |
/* No device model => try with tapdisk-ioemu */ |
594 |
DPRINTF("No device model\n"); |
594 |
DPRINTF("No device model\n"); |
Lines 598-604
Link Here
|
598 |
free(rdctldev); |
598 |
free(rdctldev); |
599 |
free(wrctldev); |
599 |
free(wrctldev); |
600 |
|
600 |
|
601 |
if (blkif->fds[READ] == -1 || blkif->fds[WRITE] == -1) |
601 |
if (blkif->fds[BLKTAP_READ] == -1 || blkif->fds[BLKTAP_WRITE] == -1) |
602 |
return -1; |
602 |
return -1; |
603 |
|
603 |
|
604 |
DPRINTF("Attached to qemu blktap pipes\n"); |
604 |
DPRINTF("Attached to qemu blktap pipes\n"); |
Lines 621-630
Link Here
|
621 |
"%s/tapctrlwrite%d", BLKTAP_CTRL_DIR, minor) == -1) |
621 |
"%s/tapctrlwrite%d", BLKTAP_CTRL_DIR, minor) == -1) |
622 |
goto fail; |
622 |
goto fail; |
623 |
|
623 |
|
624 |
blkif->fds[READ] = open_ctrl_socket(rdctldev); |
624 |
blkif->fds[BLKTAP_READ] = open_ctrl_socket(rdctldev); |
625 |
blkif->fds[WRITE] = open_ctrl_socket(wrctldev); |
625 |
blkif->fds[BLKTAP_WRITE] = open_ctrl_socket(wrctldev); |
626 |
|
626 |
|
627 |
if (blkif->fds[READ] == -1 || blkif->fds[WRITE] == -1) |
627 |
if (blkif->fds[BLKTAP_READ] == -1 || blkif->fds[BLKTAP_WRITE] == -1) |
628 |
goto fail; |
628 |
goto fail; |
629 |
|
629 |
|
630 |
/*launch the new process*/ |
630 |
/*launch the new process*/ |
Lines 683-690
Link Here
|
683 |
|
683 |
|
684 |
} else { |
684 |
} else { |
685 |
DPRINTF("Process exists!\n"); |
685 |
DPRINTF("Process exists!\n"); |
686 |
blkif->fds[READ] = exist->fds[READ]; |
686 |
blkif->fds[BLKTAP_READ] = exist->fds[BLKTAP_READ]; |
687 |
blkif->fds[WRITE] = exist->fds[WRITE]; |
687 |
blkif->fds[BLKTAP_WRITE] = exist->fds[BLKTAP_WRITE]; |
688 |
} |
688 |
} |
689 |
|
689 |
|
690 |
add_disktype(blkif, type); |
690 |
add_disktype(blkif, type); |
Lines 703-715
Link Here
|
703 |
|
703 |
|
704 |
/* Both of the following read and write calls will block up to |
704 |
/* Both of the following read and write calls will block up to |
705 |
* max_timeout val*/ |
705 |
* max_timeout val*/ |
706 |
if (write_msg(blkif->fds[WRITE], CTLMSG_PARAMS, blkif, ptr) |
706 |
if (write_msg(blkif->fds[BLKTAP_WRITE], CTLMSG_PARAMS, blkif, ptr) |
707 |
<= 0) { |
707 |
<= 0) { |
708 |
DPRINTF("Write_msg failed - CTLMSG_PARAMS\n"); |
708 |
DPRINTF("Write_msg failed - CTLMSG_PARAMS\n"); |
709 |
goto fail; |
709 |
goto fail; |
710 |
} |
710 |
} |
711 |
|
711 |
|
712 |
if (read_msg(blkif->fds[READ], CTLMSG_IMG, blkif) <= 0) { |
712 |
if (read_msg(blkif->fds[BLKTAP_READ], CTLMSG_IMG, blkif) <= 0) { |
713 |
DPRINTF("Read_msg failure - CTLMSG_IMG\n"); |
713 |
DPRINTF("Read_msg failure - CTLMSG_IMG\n"); |
714 |
goto fail; |
714 |
goto fail; |
715 |
} |
715 |
} |
Lines 725-736
Link Here
|
725 |
static int map_new_blktapctrl(blkif_t *blkif) |
725 |
static int map_new_blktapctrl(blkif_t *blkif) |
726 |
{ |
726 |
{ |
727 |
DPRINTF("Received a poll for a new devmap\n"); |
727 |
DPRINTF("Received a poll for a new devmap\n"); |
728 |
if (write_msg(blkif->fds[WRITE], CTLMSG_NEWDEV, blkif, NULL) <= 0) { |
728 |
if (write_msg(blkif->fds[BLKTAP_WRITE], CTLMSG_NEWDEV, blkif, NULL) <= 0) { |
729 |
DPRINTF("Write_msg failed - CTLMSG_NEWDEV\n"); |
729 |
DPRINTF("Write_msg failed - CTLMSG_NEWDEV\n"); |
730 |
return -EINVAL; |
730 |
return -EINVAL; |
731 |
} |
731 |
} |
732 |
|
732 |
|
733 |
if (read_msg(blkif->fds[READ], CTLMSG_NEWDEV_RSP, blkif) <= 0) { |
733 |
if (read_msg(blkif->fds[BLKTAP_READ], CTLMSG_NEWDEV_RSP, blkif) <= 0) { |
734 |
DPRINTF("Read_msg failed - CTLMSG_NEWDEV_RSP\n"); |
734 |
DPRINTF("Read_msg failed - CTLMSG_NEWDEV_RSP\n"); |
735 |
return -EINVAL; |
735 |
return -EINVAL; |
736 |
} |
736 |
} |
Lines 743-757
Link Here
|
743 |
{ |
743 |
{ |
744 |
DPRINTF("Unmapping vbd\n"); |
744 |
DPRINTF("Unmapping vbd\n"); |
745 |
|
745 |
|
746 |
if (write_msg(blkif->fds[WRITE], CTLMSG_CLOSE, blkif, NULL) <= 0) { |
746 |
if (write_msg(blkif->fds[BLKTAP_WRITE], CTLMSG_CLOSE, blkif, NULL) <= 0) { |
747 |
DPRINTF("Write_msg failed - CTLMSG_CLOSE\n"); |
747 |
DPRINTF("Write_msg failed - CTLMSG_CLOSE\n"); |
748 |
return -EINVAL; |
748 |
return -EINVAL; |
749 |
} |
749 |
} |
750 |
|
750 |
|
751 |
if (del_disktype(blkif)) { |
751 |
if (del_disktype(blkif)) { |
752 |
DPRINTF("Closing communication pipe to pid %d\n", blkif->tappid); |
752 |
DPRINTF("Closing communication pipe to pid %d\n", blkif->tappid); |
753 |
close(blkif->fds[WRITE]); |
753 |
close(blkif->fds[BLKTAP_WRITE]); |
754 |
close(blkif->fds[READ]); |
754 |
close(blkif->fds[BLKTAP_READ]); |
755 |
} |
755 |
} |
756 |
|
756 |
|
757 |
return 0; |
757 |
return 0; |