diff --git a/ap-common b/ap-common
index ed37811..0969ab3 100644
--- a/ap-common
+++ b/ap-common
@@ -70,6 +70,11 @@ fi
 : ${TREE_QEMU_UPSTREAM:=git://xenbits.xen.org/staging/qemu-upstream-${xenbranch#xen-}.git}
 : ${LOCALREV_QEMU_UPSTREAM:=daily-cron.$branch}
 
+: ${TREE_QEMU_MAINLINE:=git://git.qemu.org/qemu.git}
+: ${BASE_TREE_QEMU_MAINLINE:=git://xenbits.xen.org/osstest/qemu-mainline.git}
+: ${PUSH_TREE_QEMU_MAINLINE:=$XENBITS:/home/xen/git/osstest/qemu-mainline.git}
+: ${LOCALREV_QEMU_MAINLINE:=daily-cron.$branch}
+
 info_linux_tree () {
 	case $1 in
 
diff --git a/ap-fetch-version b/ap-fetch-version
index 7cc2d98..a4558ea 100755
--- a/ap-fetch-version
+++ b/ap-fetch-version
@@ -49,6 +49,10 @@ xen-4.*-testing)
 	repo_tree_rev_fetch_git xen \
 		$TREE_XEN staging-$branchcore $LOCALREV_XEN
 	;;
+qemu-mainline)
+	repo_tree_rev_fetch_git $branch \
+		$TREE_QEMU_MAINLINE master $LOCALREV_QEMU_UPSTREAM
+	;;
 qemu-upstream-*)
         repo_tree_rev_fetch_git $branch \
 		$TREE_QEMU_UPSTREAM master $LOCALREV_QEMU_UPSTREAM
diff --git a/ap-fetch-version-old b/ap-fetch-version-old
index 3879e09..f71626f 100755
--- a/ap-fetch-version-old
+++ b/ap-fetch-version-old
@@ -54,6 +54,10 @@ xen-4.*-testing)
 	repo_tree_rev_fetch_git xen \
 		$TREE_XEN stable-$branchcore $LOCALREV_XEN
 	;;
+qemu-mainline)
+        repo_tree_rev_fetch_git $branch \
+		$BASE_TREE_QEMU_MAINLINE xen-tested-master $LOCALREV_QEMU_MAINLINE
+        ;;
 qemu-upstream-*)
         repo_tree_rev_fetch_git $branch \
 		$BASE_TREE_QEMU_UPSTREAM master $LOCALREV_QEMU_UPSTREAM
diff --git a/ap-print-url b/ap-print-url
index b1af0b9..a21efce 100755
--- a/ap-print-url
+++ b/ap-print-url
@@ -34,6 +34,9 @@ case "$branch" in
 xen*)
         echo $TREE_XEN
 	;;
+qemu-mainline)
+        echo $TREE_QEMU_MAINLINE
+        ;;
 qemu-upstream-*)
         echo $TREE_QEMU_UPSTREAM
         ;;
diff --git a/ap-push b/ap-push
index 674559f..00e0d8b 100755
--- a/ap-push
+++ b/ap-push
@@ -30,6 +30,7 @@ select_xenbranch
 . ap-common
 
 TREE_LINUX=$PUSH_TREE_LINUX
+TREE_QEMU_MAINLINE=$PUSH_TREE_QEMU_MAINLINE
 TREE_QEMU_UPSTREAM=$XENBITS:/home/xen/git/qemu-upstream-${xenbranch#xen-}.git
 TREE_XEN=$PUSH_TREE_XEN
 TREE_LIBVIRT=$PUSH_TREE_LIBVIRT
@@ -57,6 +58,10 @@ xen-*-testing)
 	xenversion=${xenversion#xen-}
 	git push $TREE_XEN $revision:stable-$xenversion
 	;;
+qemu-mainline)
+	cd $repos/qemu-mainline
+	git push $TREE_QEMU_MAINLINE $revision:xen-tested-master
+	;;
 qemu-upstream-*)
 	cd $repos/$branch
         git push $TREE_QEMU_UPSTREAM $revision:master
diff --git a/cr-daily-branch b/cr-daily-branch
index 0cafe39..837cf7a 100755
--- a/cr-daily-branch
+++ b/cr-daily-branch
@@ -111,8 +111,7 @@ if [ "x$REVISION_QEMU_UPSTREAM" = x ]; then
         xen-3.*|xen-4.[01]-*)
         	;;
 	*)
-		REVISION_QEMU_UPSTREAM="`fetch_version \
-				qemu-upstream-${xenbranch#xen-}`"
+		REVISION_QEMU_UPSTREAM="`fetch_version $qemuubranch`"
 		;;
         esac
         export REVISION_QEMU_UPSTREAM
@@ -166,7 +165,7 @@ osstest)
 	fi
 	;;
 qemuu)
-	realtree=qemu-upstream-${xenbranch#xen-}
+	realtree=$qemuubranch
 	NEW_REVISION=$REVISION_QEMU_UPSTREAM
         ;;
 linuxfirmware)
diff --git a/cr-for-branches b/cr-for-branches
index 60611d1..bded06f 100755
--- a/cr-for-branches
+++ b/cr-for-branches
@@ -31,7 +31,7 @@ scriptoptions="$1"; shift
 LOGFILE=tmp/cr-for-branches.log
 export LOGFILE
 
-: ${BRANCHES:=osstest xen-4.0-testing xen-4.1-testing xen-4.2-testing xen-4.3-testing xen-4.4-testing xen-unstable qemu-upstream-unstable qemu-upstream-4.2-testing qemu-upstream-4.3-testing qemu-upstream-4.4-testing linux-3.10 linux-3.4 linux-arm-xen ${EXTRA_BRANCHES}}
+: ${BRANCHES:=osstest xen-4.0-testing xen-4.1-testing xen-4.2-testing xen-4.3-testing xen-4.4-testing xen-unstable qemu-mainline qemu-upstream-unstable qemu-upstream-4.2-testing qemu-upstream-4.3-testing qemu-upstream-4.4-testing linux-3.10 linux-3.4 linux-arm-xen ${EXTRA_BRANCHES}}
 export BRANCHES
 
 fetchwlem=$wlem
diff --git a/cri-common b/cri-common
index d82312c..d901383 100644
--- a/cri-common
+++ b/cri-common
@@ -43,6 +43,7 @@ repo_tree_rev_fetch_git () {
 select_xenbranch () {
 	case "$branch" in
 	xen*)			tree=xen;	xenbranch=$branch ;;
+	qemu-mainline)		tree=qemuu;	xenbranch=xen-unstable	qemuubranch=qemu-mainline;;
         qemu-upstream-*)    tree=qemuu; xenbranch=xen-${branch#qemu-upstream-};;
 	linux)			tree=linux;	xenbranch=xen-unstable ;;
 	linux-*)		tree=linux;	xenbranch=xen-unstable ;;
@@ -55,6 +56,9 @@ select_xenbranch () {
 	else
 		linuxbranch=''
 	fi
+	if [ x$qemuubranch = x ]; then
+		qemuubranch="qemu-upstream-${xenbranch#xen-}"
+	fi
 }
 
 select_branch () {
