aboutsummaryrefslogtreecommitdiff
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
parent82e1c41385491d66d4717b17ca36601aedec28aa (diff)
Pass machine options instead of default QEMU/KVM network/disk setup
-rw-r--r--bbot/machine-manifest2
-rw-r--r--bbot/machine-manifest.cxx2
-rw-r--r--bbot/machine.cxx52
3 files changed, 33 insertions, 23 deletions
diff --git a/bbot/machine-manifest b/bbot/machine-manifest
index ec14c3f..ba27071 100644
--- a/bbot/machine-manifest
+++ b/bbot/machine-manifest
@@ -38,7 +38,7 @@ namespace bbot
optional<strings> options; // Note: could be quoted.
strings
- unquoted_options (); // Return empty if absent.
+ unquoted_options () const; // Return empty if absent.
machine_manifest (std::string i,
std::string n,
diff --git a/bbot/machine-manifest.cxx b/bbot/machine-manifest.cxx
index debdbcc..acb9d27 100644
--- a/bbot/machine-manifest.cxx
+++ b/bbot/machine-manifest.cxx
@@ -213,7 +213,7 @@ namespace bbot
}
strings machine_manifest::
- unquoted_options ()
+ unquoted_options () const
{
return options
? string_parser::unquote (*options)
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");
}