summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/run-qemu-ota27
1 files changed, 25 insertions, 2 deletions
diff --git a/scripts/run-qemu-ota b/scripts/run-qemu-ota
index 181558c..7f84d08 100755
--- a/scripts/run-qemu-ota
+++ b/scripts/run-qemu-ota
@@ -75,6 +75,7 @@ class QemuCommand(object):
75 self.gui = not args.no_gui 75 self.gui = not args.no_gui
76 self.gdb = args.gdb 76 self.gdb = args.gdb
77 self.pcap = args.pcap 77 self.pcap = args.pcap
78 self.overlay = args.overlay
78 79
79 def command_line(self): 80 def command_line(self):
80 netuser = 'user,hostfwd=tcp:0.0.0.0:%d-:22,restrict=off' % self.ssh_port 81 netuser = 'user,hostfwd=tcp:0.0.0.0:%d-:22,restrict=off' % self.ssh_port
@@ -82,8 +83,11 @@ class QemuCommand(object):
82 netuser += ',hostfwd=tcp:0.0.0.0:2159-:2159' 83 netuser += ',hostfwd=tcp:0.0.0.0:2159-:2159'
83 cmdline = [ 84 cmdline = [
84 "qemu-system-x86_64", 85 "qemu-system-x86_64",
85 "-bios", self.bios, 86 "-bios", self.bios
86 "-drive", "file=%s,if=ide,format=raw,snapshot=on" % self.image, 87 ]
88 if not self.overlay:
89 cmdline += ["-drive", "file=%s,if=ide,format=raw,snapshot=on" % self.image]
90 cmdline += [
87 "-serial", "tcp:127.0.0.1:%d,server,nowait" % self.serial_port, 91 "-serial", "tcp:127.0.0.1:%d,server,nowait" % self.serial_port,
88 "-m", "1G", 92 "-m", "1G",
89 "-usb", 93 "-usb",
@@ -103,6 +107,16 @@ class QemuCommand(object):
103 cmdline.append('-enable-kvm') 107 cmdline.append('-enable-kvm')
104 else: 108 else:
105 cmdline += ['-cpu', 'Haswell'] 109 cmdline += ['-cpu', 'Haswell']
110 if self.overlay:
111 cmdline.append(self.overlay)
112 return cmdline
113
114 def img_command_line(self):
115 cmdline = [
116 "qemu-img", "create",
117 "-o", "backing_file=%s" % self.image,
118 "-f", "qcow2",
119 self.overlay]
106 return cmdline 120 return cmdline
107 121
108 122
@@ -121,6 +135,7 @@ def main():
121 parser.add_argument('--no-gui', help='Disable GUI', action='store_true') 135 parser.add_argument('--no-gui', help='Disable GUI', action='store_true')
122 parser.add_argument('--gdb', help='Export gdbserver port 2159 from the image', action='store_true') 136 parser.add_argument('--gdb', help='Export gdbserver port 2159 from the image', action='store_true')
123 parser.add_argument('--pcap', default=None, help='Dump all network traffic') 137 parser.add_argument('--pcap', default=None, help='Dump all network traffic')
138 parser.add_argument('-o', '--overlay', type=str, metavar='file.cow', help='Use an overlay storage image file. Will be created if it does not exist. This option lets you have a persistent image without modifying the underlying image file, permitting multiple different persistent machines.')
124 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true') 139 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true')
125 args = parser.parse_args() 140 args = parser.parse_args()
126 try: 141 try:
@@ -136,6 +151,14 @@ def main():
136 print(" nc localhost %d" % qemu_command.serial_port) 151 print(" nc localhost %d" % qemu_command.serial_port)
137 152
138 cmdline = qemu_command.command_line() 153 cmdline = qemu_command.command_line()
154 if args.overlay and not exists(args.overlay):
155 print("Image file %s does not yet exist, creating." % args.overlay)
156 img_cmdline = qemu_command.img_command_line()
157 if args.dry_run:
158 print(" ".join(img_cmdline))
159 else:
160 Popen(img_cmdline)
161
139 if args.dry_run: 162 if args.dry_run:
140 print(" ".join(cmdline)) 163 print(" ".join(cmdline))
141 else: 164 else: