aboutsummaryrefslogtreecommitdiff
path: root/bbot/machine.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-21 06:51:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-21 06:51:33 +0200
commitca35746ba41437b1ced31d689ec51203c960bfb4 (patch)
tree5cc520b29fe327d203f40bb571d65e6a8c8c4823 /bbot/machine.cxx
parent82e1c41385491d66d4717b17ca36601aedec28aa (diff)
Pass machine options instead of default QEMU/KVM network/disk setup
Diffstat (limited to 'bbot/machine.cxx')
-rw-r--r--bbot/machine.cxx52
1 files changed, 31 insertions, 21 deletions
diff --git a/bbot/machine.cxx b/bbot/machine.cxx
index 9459b25..976b79c 100644
--- a/bbot/machine.cxx
+++ b/bbot/machine.cxx
@@ -180,6 +180,36 @@ namespace bbot
else
ram += (ops.ram () - ram) / 2;
+ // If we have options, use that instead of the default network and
+ // disk configuration.
+ //
+ strings os;
+
+ if (mm.options)
+ os = mm.unquoted_options ();
+ else
+ {
+ auto add = [&os] (string o, string v)
+ {
+ os.push_back (move (o));
+ os.push_back (move (v));
+ };
+
+ // Network.
+ //
+ add ("-netdev", "tap,id=net0,script=no,ifname=" + tap);
+ add ("-device", "virtio-net-pci,netdev=net0,mac=" + mac);
+
+ // Disk.
+ //
+ add ("-drive", "if=none,id=disk0,file=disk.img,format=raw");
+ add ("-device", "virtio-blk-pci,scsi=off,drive=disk0");
+
+ //"-drive", "if=none,id=disk0,format=raw,file=disk.img"
+ //"-device", "virtio-scsi-pci,id=scsi"
+ //"-device", "scsi-hd,drive=disk0"
+ }
+
proc = run_io_start (
trace,
fdnull (),
@@ -189,30 +219,10 @@ namespace bbot
kvm,
"-boot", "c", // Boot from disk.
"-no-reboot", // Exit on VM reboot.
- //
- // Machine.
- //
"-m", to_string (ram / 1024) + "M",
"-cpu", "host",
"-smp", cpu,
- //
- // Network.
- //
- "-netdev", "tap,id=net0,script=no,ifname=" + tap,
- "-device", "virtio-net-pci,netdev=net0,mac=" + mac,
- //
- // Disk.
- //
- "-drive", "if=none,id=disk0,file=disk.img,format=raw",
- "-device", "virtio-blk-pci,scsi=off,drive=disk0",
-
- //"-device", "virtio-scsi-pci,id=scsi",
- //"-device", "scsi-hd,drive=disk0",
- //"-drive", "if=none,id=disk0,format=raw,file=disk.img",
-
- //
- // VNC & monitor.
- //
+ os,
"-vnc", "127.0.0.1:" + to_string (tc_num), // 5900 + tc_num
"-monitor", "unix:" + monitor.string () + ",server,nowait");
}