From 239f17cd66b8e9480373274f2a9784b61fc49b47 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 22 Apr 2017 14:49:37 +0200 Subject: =?UTF-8?q?Add=20support=20for=20ifname=3D=3F=20and=20mac=3D=3F=20?= =?UTF-8?q?in=20kvm=20options?= --- bbot/machine.cxx | 22 ++++++++++++++++++++++ doc/manual.cli | 6 +++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/bbot/machine.cxx b/bbot/machine.cxx index de394b6..0bd2e86 100644 --- a/bbot/machine.cxx +++ b/bbot/machine.cxx @@ -205,7 +205,29 @@ namespace bbot strings os; if (mm.options) + { os = mm.unquoted_options (); + + // Pre-process ifname=? and mac=?. + // + auto sub = [] (string& o, const char* s, const string& r) + { + size_t p (o.find (s)); + + if (p != string::npos) + { + p = o.find ('?', p + 1); + assert (p != string::npos); + o.replace (p, 1, r); + } + }; + + for (string& o: os) + { + sub (o, "ifname=?", tap); + sub (o, "mac=?", mac); + } + } else { auto add = [&os] (string o, string v) diff --git a/doc/manual.cli b/doc/manual.cli index a851008..f26f350 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -244,9 +244,9 @@ the header values must appear before any non-header values. For \c{kvm} machines, if this value is present, then it replaces the default network and disk configuration when starting the QEMU/KVM - hypervisor. - -|| + hypervisor The options are pre-processed by replacing the question + mark in \c{ifname=?} and \c{mac=?} strings with the network interface + and MAC address, respectively.|| \h#arch-task-manifest|Task Manifest| -- cgit v1.1