Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ISC2
virtu
scripts
Commits
d2d399e4
Verified
Commit
d2d399e4
authored
1 year ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
WIP: vm_run, TODO clipboard
parents
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vm_run.sh
+79
-0
79 additions, 0 deletions
vm_run.sh
with
79 additions
and
0 deletions
vm_run.sh
0 → 100755
+
79
−
0
View file @
d2d399e4
#!/bin/bash
print_usage
()
{
echo
"Usage: ./vm_run.sh -d disk -i iso"
echo
"disk the disk to use (qcow file)"
echo
"iso the CD/DVD-ROM image to use (iso file)"
echo
""
echo
"At least one image must be specified"
}
if
[
$#
-eq
0
]
;
then
print_usage
exit
1
fi
DISK_OPT
=
false
ISO_OPT
=
false
DISK_PATH
=
""
ISO_PATH
=
""
# flags -d and -i require arguments, -h doesn't
OPTSTRING
=
":d:i:h"
while
getopts
$OPTSTRING
flag
;
do
case
$flag
in
h
)
print_usage
exit
0
;;
d
)
DISK_OPT
=
true
DISK_PATH
=
$OPTARG
;;
i
)
ISO_OPT
=
true
ISO_PATH
=
$OPTARG
;;
:
)
echo
"Option -
${
OPTARG
}
requires an argument."
exit
2
;;
?
)
echo
"Invalid option: -
${
OPTARG
}
."
exit
3
;;
esac
done
MEM_COUNT
=
"4G"
CPU_COUNT
=
"2"
NET_PV
=
"-nic user,model=virtio-net-pci"
GPU_PV
=
"-vga virtio"
QEMU_GA
=
"-device virtio-serial
\
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
\
-chardev socket,path=/tmp/qga.sock,server=on,wait=off,id=qga0"
SPICE_GA
=
"-device virtio-serial-pci
\
-chardev qemu-vdagent,id=ch1,name=vdagent,clipboard=on
\
-device virtserialport,chardev=ch1,id=ch1,name=com.redhat.spice.0 "
if
$DISK_OPT
;
then
qemu-system-x86_64
-m
$MEM_COUNT
-smp
cpus
=
$CPU_COUNT
-enable-kvm
$NET_PV
\
$GPU_PV
$DISK_PATH
$QEMU_GA
$SPICE_GA
fi
if
$ISO_OPT
;
then
qemu-system-x86_64
-cdrom
$ISO_PATH
-m
$MEM_COUNT
-smp
cpus
=
$CPU_COUNT
\
-enable-kvm
$NET_PV
$GPU_PV
$QEMU_GA
$SPICE_GA
fi
if
$DISK_OPT
&&
$ISO_OPT
;
then
qemu-system-x86_64
-boot
=
d
-cdrom
$ISO_PATH
-m
$MEM_COUNT
-smp
\
cpus
=
$CPU_COUNT
-enable-kvm
$NET_PV
$GPU_PV
\
-drive
file
=
$DISK_PATH
,index
=
0,media
=
disk,format
=
qcow2,if
=
virtio
\
$QEMU_GA
$SPICE_GA
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment