Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 347664
Collapse All | Expand All

(-)xen-4.0.1.orig/tools/blktap/lib/blktaplib.h (-2 / +2 lines)
Lines 195-202 Link Here
195
	pid_t     pid;
195
	pid_t     pid;
196
} msg_pid_t;
196
} msg_pid_t;
197
197
198
#define READ 0
198
#define BLKTAP_READ 0
199
#define WRITE 1
199
#define BLKTAP_WRITE 1
200
200
201
/*Control Messages between manager and tapdev*/
201
/*Control Messages between manager and tapdev*/
202
#define CTLMSG_PARAMS      1
202
#define CTLMSG_PARAMS      1
(-)xen-4.0.1.orig/tools/blktap/drivers/blktapctrl.c (-19 / +19 lines)
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;
(-)xen-4.0.1.orig/tools/blktap/drivers/tapdisk.c (-20 / +20 lines)
Lines 138-147 Link Here
138
		if (ptr->tap_fd) {
138
		if (ptr->tap_fd) {
139
			FD_SET(ptr->tap_fd, readfds);
139
			FD_SET(ptr->tap_fd, readfds);
140
			td_for_each_disk(ptr->s, dd) {
140
			td_for_each_disk(ptr->s, dd) {
141
				if (dd->io_fd[READ]) 
141
				if (dd->io_fd[BLKTAP_READ]) 
142
					FD_SET(dd->io_fd[READ], readfds);
142
					FD_SET(dd->io_fd[BLKTAP_READ], readfds);
143
				maxfds = (dd->io_fd[READ] > maxfds ? 
143
				maxfds = (dd->io_fd[BLKTAP_READ] > maxfds ? 
144
					  dd->io_fd[READ] : maxfds);
144
					  dd->io_fd[BLKTAP_READ] : maxfds);
145
			}
145
			}
146
			maxfds = (ptr->tap_fd > maxfds ? ptr->tap_fd : maxfds);
146
			maxfds = (ptr->tap_fd > maxfds ? ptr->tap_fd : maxfds);
147
		}
147
		}
Lines 380-386 Link Here
380
	struct td_state *s = NULL;
380
	struct td_state *s = NULL;
381
	fd_list_entry_t *entry;
381
	fd_list_entry_t *entry;
382
382
383
	length = read(fds[READ], buf, MSG_SIZE);
383
	length = read(fds[BLKTAP_READ], buf, MSG_SIZE);
384
384
385
	if (length > 0 && length >= sizeof(msg_hdr_t)) 
385
	if (length > 0 && length >= sizeof(msg_hdr_t)) 
386
	{
386
	{
Lines 435-441 Link Here
435
				msg->type = CTLMSG_IMG_FAIL;
435
				msg->type = CTLMSG_IMG_FAIL;
436
				msg->len = msglen;
436
				msg->len = msglen;
437
			}
437
			}
438
			len = write(fds[WRITE], buf, msglen);
438
			len = write(fds[BLKTAP_WRITE], buf, msglen);
439
			free(path);
439
			free(path);
440
			return 1;
440
			return 1;
441
			
441
			
Lines 457-463 Link Here
457
				              : CTLMSG_NEWDEV_FAIL);
457
				              : CTLMSG_NEWDEV_FAIL);
458
			msg->len = msglen;
458
			msg->len = msglen;
459
459
460
			len = write(fds[WRITE], buf, msglen);
460
			len = write(fds[BLKTAP_WRITE], buf, msglen);
461
			return 1;
461
			return 1;
462
462
463
		case CTLMSG_CLOSE:
463
		case CTLMSG_CLOSE:
Lines 479-485 Link Here
479
			process = getpid();
479
			process = getpid();
480
			msg_pid->pid = process;
480
			msg_pid->pid = process;
481
481
482
			len = write(fds[WRITE], buf, msglen);
482
			len = write(fds[BLKTAP_WRITE], buf, msglen);
483
			return 1;
483
			return 1;
484
484
485
		default:
485
		default:
Lines 782-793 Link Here
782
	signal (SIGINT, sig_handler);
782
	signal (SIGINT, sig_handler);
783
783
784
	/*Open the control channel*/
784
	/*Open the control channel*/
785
	fds[READ]  = open(argv[1],O_RDWR|O_NONBLOCK);
785
	fds[BLKTAP_READ]  = open(argv[1],O_RDWR|O_NONBLOCK);
786
	fds[WRITE] = open(argv[2],O_RDWR|O_NONBLOCK);
786
	fds[BLKTAP_WRITE] = open(argv[2],O_RDWR|O_NONBLOCK);
787
787
788
	if ( (fds[READ] < 0) || (fds[WRITE] < 0) ) 
788
	if ( (fds[BLKTAP_READ] < 0) || (fds[BLKTAP_WRITE] < 0) ) 
789
	{
789
	{
790
		DPRINTF("FD open failed [%d,%d]\n", fds[READ], fds[WRITE]);
790
		DPRINTF("FD open failed [%d,%d]\n", fds[BLKTAP_READ], fds[BLKTAP_WRITE]);
791
		exit(-1);
791
		exit(-1);
792
	}
792
	}
793
793
Lines 803-810 Link Here
803
        {
803
        {
804
		ret = 0;
804
		ret = 0;
805
		FD_ZERO(&readfds);
805
		FD_ZERO(&readfds);
806
		FD_SET(fds[READ], &readfds);
806
		FD_SET(fds[BLKTAP_READ], &readfds);
807
		maxfds = fds[READ];
807
		maxfds = fds[BLKTAP_READ];
808
808
809
		/*Set all tap fds*/
809
		/*Set all tap fds*/
810
		LOCAL_FD_SET(&readfds);
810
		LOCAL_FD_SET(&readfds);
Lines 822-831 Link Here
822
				tapdev_info_t *info = ptr->s->ring_info;
822
				tapdev_info_t *info = ptr->s->ring_info;
823
823
824
				td_for_each_disk(ptr->s, dd) {
824
				td_for_each_disk(ptr->s, dd) {
825
					if (dd->io_fd[READ] &&
825
					if (dd->io_fd[BLKTAP_READ] &&
826
					    FD_ISSET(dd->io_fd[READ], 
826
					    FD_ISSET(dd->io_fd[BLKTAP_READ], 
827
						     &readfds)) {
827
						     &readfds)) {
828
						io_done(dd, READ);
828
						io_done(dd, BLKTAP_READ);
829
						progress_made = 1;
829
						progress_made = 1;
830
					}
830
					}
831
				}
831
				}
Lines 851-863 Link Here
851
				ptr = ptr->next;
851
				ptr = ptr->next;
852
			}
852
			}
853
853
854
			if (FD_ISSET(fds[READ], &readfds))
854
			if (FD_ISSET(fds[BLKTAP_READ], &readfds))
855
				read_msg(buf);
855
				read_msg(buf);
856
		}
856
		}
857
	}
857
	}
858
	free(buf);
858
	free(buf);
859
	close(fds[READ]);
859
	close(fds[BLKTAP_READ]);
860
	close(fds[WRITE]);
860
	close(fds[BLKTAP_WRITE]);
861
861
862
	ptr = fd_start;
862
	ptr = fd_start;
863
	while (ptr != NULL) {
863
	while (ptr != NULL) {

Return to bug 347664