mirror of
https://git.yoctoproject.org/poky
synced 2026-09-29 07:36:20 +02:00
runqemu: simplify the checking for vm images
* So that we can add more image support easliy. * I think that wic should be vm images. (From OE-Core rev: 82d0014a0e1526ffa1ff7c8ea3903aeae31bada4) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
6716eb245d
commit
58bc8542de
@@ -75,6 +75,7 @@ KVM_ENABLED="no"
|
|||||||
KVM_ACTIVE="no"
|
KVM_ACTIVE="no"
|
||||||
VHOST_ENABLED="no"
|
VHOST_ENABLED="no"
|
||||||
VHOST_ACTIVE="no"
|
VHOST_ACTIVE="no"
|
||||||
|
IS_VM="false"
|
||||||
|
|
||||||
# Determine whether the file is a kernel or QEMU image, and set the
|
# Determine whether the file is a kernel or QEMU image, and set the
|
||||||
# appropriate variables
|
# appropriate variables
|
||||||
@@ -89,7 +90,7 @@ process_filename() {
|
|||||||
[ -z "$KERNEL" ] && KERNEL=$filename || \
|
[ -z "$KERNEL" ] && KERNEL=$filename || \
|
||||||
error "conflicting KERNEL args [$KERNEL] and [$filename]"
|
error "conflicting KERNEL args [$KERNEL] and [$filename]"
|
||||||
;;
|
;;
|
||||||
/ext[234]/|/jffs2/|/btrfs/|/wic/)
|
/ext[234]/|/jffs2/|/btrfs/)
|
||||||
# A file ending in a supportted fs type is a rootfs image
|
# A file ending in a supportted fs type is a rootfs image
|
||||||
if [ -z "$FSTYPE" -o "$FSTYPE" = "$EXT" ]; then
|
if [ -z "$FSTYPE" -o "$FSTYPE" = "$EXT" ]; then
|
||||||
FSTYPE=$EXT
|
FSTYPE=$EXT
|
||||||
@@ -98,10 +99,11 @@ process_filename() {
|
|||||||
error "conflicting FSTYPE types [$FSTYPE] and [$EXT]"
|
error "conflicting FSTYPE types [$FSTYPE] and [$EXT]"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
/hddimg/|/hdddirect/|/vmdk/)
|
/hddimg/|/hdddirect/|/vmdk/|/wic/)
|
||||||
FSTYPE=$EXT
|
FSTYPE=$EXT
|
||||||
VM=$filename
|
VM=$filename
|
||||||
ROOTFS=$filename
|
ROOTFS=$filename
|
||||||
|
IS_VM="true"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error "unknown file arg [$filename]"
|
error "unknown file arg [$filename]"
|
||||||
@@ -109,6 +111,13 @@ process_filename() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_fstype_conflicts() {
|
||||||
|
if [ -z "$FSTYPE" -o "$FSTYPE" = "$1" ]; then
|
||||||
|
FSTYPE=$1
|
||||||
|
else
|
||||||
|
error "conflicting FSTYPE types [$FSTYPE] and [$1]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
# Parse command line args without requiring specific ordering. It's a
|
# Parse command line args without requiring specific ordering. It's a
|
||||||
# bit more complex, but offers a great user experience.
|
# bit more complex, but offers a great user experience.
|
||||||
while true; do
|
while true; do
|
||||||
@@ -119,9 +128,12 @@ while true; do
|
|||||||
[ -z "$MACHINE" -o "$MACHINE" = "$arg" ] && MACHINE=$arg || \
|
[ -z "$MACHINE" -o "$MACHINE" = "$arg" ] && MACHINE=$arg || \
|
||||||
error "conflicting MACHINE types [$MACHINE] and [$arg]"
|
error "conflicting MACHINE types [$MACHINE] and [$arg]"
|
||||||
;;
|
;;
|
||||||
"ext2" | "ext3" | "ext4" | "jffs2" | "nfs" | "btrfs" | "hddimg" | "hdddirect" | "wic" | "vmdk")
|
"ext"[234] | "jffs2" | "nfs" | "btrfs")
|
||||||
[ -z "$FSTYPE" -o "$FSTYPE" = "$arg" ] && FSTYPE=$arg || \
|
check_fstype_conflicts $arg
|
||||||
error "conflicting FSTYPE types [$FSTYPE] and [$arg]"
|
;;
|
||||||
|
"hddimg" | "hdddirect" | "wic" | "vmdk")
|
||||||
|
check_fstype_conflicts $arg
|
||||||
|
IS_VM="true"
|
||||||
;;
|
;;
|
||||||
"ramfs")
|
"ramfs")
|
||||||
FSTYPE=cpio.gz
|
FSTYPE=cpio.gz
|
||||||
@@ -245,7 +257,7 @@ if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$MACHINE" ]; then
|
if [ -z "$MACHINE" ]; then
|
||||||
if [ "x$FSTYPE" = "xvmdk" ] || [ "x$FSTYPE" = "xhddimg" ] || [ "x$FSTYPE" = "xhdddirect" ] || [ "x$FSTYPE" = "xwic" ]; then
|
if [ "$IS_VM" = "true" ]; then
|
||||||
[ "x$FSTYPE" = "xwic" ] && filename=$ROOTFS || filename=$VM
|
[ "x$FSTYPE" = "xwic" ] && filename=$ROOTFS || filename=$VM
|
||||||
MACHINE=`basename $filename | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'`
|
MACHINE=`basename $filename | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'`
|
||||||
if [ -z "$MACHINE" ]; then
|
if [ -z "$MACHINE" ]; then
|
||||||
@@ -457,7 +469,7 @@ if [ -e "$ROOTFS" -a -z "$FSTYPE" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$KERNEL" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" -a "x$FSTYPE" != "xwic" ]; then
|
if [ -z "$KERNEL" -a "$IS_VM" = "false" ]; then \
|
||||||
setup_path_vars 1
|
setup_path_vars 1
|
||||||
eval kernel_file=\$${machine2}_DEFAULT_KERNEL
|
eval kernel_file=\$${machine2}_DEFAULT_KERNEL
|
||||||
KERNEL=$DEPLOY_DIR_IMAGE/$kernel_file
|
KERNEL=$DEPLOY_DIR_IMAGE/$kernel_file
|
||||||
@@ -483,7 +495,7 @@ fi
|
|||||||
if [ "$LAZY_ROOTFS" = "true" ]; then
|
if [ "$LAZY_ROOTFS" = "true" ]; then
|
||||||
setup_path_vars 1
|
setup_path_vars 1
|
||||||
echo "Assuming $ROOTFS really means $DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE"
|
echo "Assuming $ROOTFS really means $DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE"
|
||||||
if [ "$FSTYPE" = "hddimg" -o "x$FSTYPE" = "xhdddirect" ]; then
|
if [ "$IS_VM" = "true" ]; then
|
||||||
VM=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
|
VM=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
|
||||||
else
|
else
|
||||||
ROOTFS=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
|
ROOTFS=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE
|
||||||
@@ -498,7 +510,7 @@ if [ -z "$ROOTFS" ]; then
|
|||||||
|
|
||||||
if [ -z "$ROOTFS" ]; then
|
if [ -z "$ROOTFS" ]; then
|
||||||
error "Unable to determine default rootfs for MACHINE [$MACHINE]"
|
error "Unable to determine default rootfs for MACHINE [$MACHINE]"
|
||||||
elif [ "x$FSTYPE" = "xvmdk" -o "x$FSTYPE" = "xhddimg" -o "x$FSTYPE" = "xhdddirect" ]; then
|
elif [ "$IS_VM" = "true" ]; then
|
||||||
VM=$ROOTFS
|
VM=$ROOTFS
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -508,11 +520,11 @@ ROOTFS=`readlink -f $ROOTFS`
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Continuing with the following parameters:"
|
echo "Continuing with the following parameters:"
|
||||||
if [ "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" ]; then
|
if [ "$IS_VM" = "false" ]; then
|
||||||
echo "KERNEL: [$KERNEL]"
|
echo "KERNEL: [$KERNEL]"
|
||||||
echo "ROOTFS: [$ROOTFS]"
|
echo "ROOTFS: [$ROOTFS]"
|
||||||
else
|
else
|
||||||
echo "VMDK: [$VM]"
|
echo "VM: [$VM]"
|
||||||
fi
|
fi
|
||||||
echo "FSTYPE: [$FSTYPE]"
|
echo "FSTYPE: [$FSTYPE]"
|
||||||
|
|
||||||
|
|||||||
@@ -300,13 +300,13 @@ case "$MACHINE" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ ! -f "$KERNEL" -a "x$FSTYPE" != "xvmdk" -a "x$FSTYPE" != "xhddimg" -a "x$FSTYPE" != "xhdddirect" -a "x$FSTYPE" != "xwic" ]; then
|
if [ ! -f "$KERNEL" -a "$IS_VM" = "false" ]; then
|
||||||
echo "Error: Kernel image file $KERNEL doesn't exist"
|
echo "Error: Kernel image file $KERNEL doesn't exist"
|
||||||
cleanup
|
cleanup
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$FSTYPE" != "nfs" -a "$FSTYPE" != "vmdk" -a "$FSTYPE" != "hddimg" -a "$FSTYPE" != "hdddirect" -a ! -f "$ROOTFS" ]; then
|
if [ "$FSTYPE" != "nfs" -a "$IS_VM" = "false" -a ! -f "$ROOTFS" ]; then
|
||||||
echo "Error: Image file $ROOTFS doesn't exist"
|
echo "Error: Image file $ROOTFS doesn't exist"
|
||||||
cleanup
|
cleanup
|
||||||
return 1
|
return 1
|
||||||
@@ -428,7 +428,7 @@ if [ "$MACHINE" = "qemux86" ]; then
|
|||||||
KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
||||||
QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
|
QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
|
||||||
fi
|
fi
|
||||||
if [ "$FSTYPE" = "vmdk" -o "$FSTYPE" = "hddimg" -o "$FSTYPE" = "hdddirect" ]; then
|
if [ "$IS_VM" = "true" ]; then
|
||||||
QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
|
QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS"
|
||||||
fi
|
fi
|
||||||
# Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
|
# Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
|
||||||
@@ -464,7 +464,7 @@ if [ "$MACHINE" = "qemux86-64" ]; then
|
|||||||
KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY"
|
||||||
QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS"
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS"
|
||||||
fi
|
fi
|
||||||
if [ "$FSTYPE" = "vmdk" -o "$FSTYPE" = "hddimg" -o "$FSTYPE" = "hdddirect" ]; then
|
if [ "$IS_VM" = "true" ]; then
|
||||||
QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS"
|
QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS"
|
||||||
fi
|
fi
|
||||||
# Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
|
# Currently oprofile's event based interrupt mode doesn't work(Bug #828) in
|
||||||
@@ -721,7 +721,7 @@ fi
|
|||||||
|
|
||||||
echo "Running $QEMU..."
|
echo "Running $QEMU..."
|
||||||
# -no-reboot is a mandatory option - see bug #100
|
# -no-reboot is a mandatory option - see bug #100
|
||||||
if [ "$FSTYPE" = "vmdk" -o "$FSTYPE" = "hddimg" -o "$FSTYPE" = "hdddirect" ]; then
|
if [ "$IS_VM" = "true" ]; then
|
||||||
# Check root=/dev/sdX or root=/dev/vdX
|
# Check root=/dev/sdX or root=/dev/vdX
|
||||||
[ ! -e "$VM" ] && error "VM image is not found!"
|
[ ! -e "$VM" ] && error "VM image is not found!"
|
||||||
if grep -q 'root=/dev/sd' $VM; then
|
if grep -q 'root=/dev/sd' $VM; then
|
||||||
|
|||||||
Reference in New Issue
Block a user