mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
Merge pull request #2264 from tych0/support-tap-qemu
support tap devices in qemu backend
This commit is contained in:
commit
3219daa674
@ -35,6 +35,7 @@ type QemuConfig struct {
|
|||||||
QemuBinPath string
|
QemuBinPath string
|
||||||
QemuImgPath string
|
QemuImgPath string
|
||||||
PublishedPorts []string
|
PublishedPorts []string
|
||||||
|
TapDevice string
|
||||||
}
|
}
|
||||||
|
|
||||||
func haveKVM() bool {
|
func haveKVM() bool {
|
||||||
@ -96,6 +97,7 @@ func runQemu(args []string) {
|
|||||||
|
|
||||||
publishFlags := multipleFlag{}
|
publishFlags := multipleFlag{}
|
||||||
flags.Var(&publishFlags, "publish", "Publish a vm's port(s) to the host (default [])")
|
flags.Var(&publishFlags, "publish", "Publish a vm's port(s) to the host (default [])")
|
||||||
|
tapDevice := flags.String("tap-device", "", "Tap device to use as eth0 (optional)")
|
||||||
|
|
||||||
if err := flags.Parse(args); err != nil {
|
if err := flags.Parse(args); err != nil {
|
||||||
log.Fatal("Unable to parse args")
|
log.Fatal("Unable to parse args")
|
||||||
@ -215,6 +217,7 @@ func runQemu(args []string) {
|
|||||||
KVM: *enableKVM,
|
KVM: *enableKVM,
|
||||||
Containerized: *qemuContainerized,
|
Containerized: *qemuContainerized,
|
||||||
PublishedPorts: publishFlags,
|
PublishedPorts: publishFlags,
|
||||||
|
TapDevice: *tapDevice,
|
||||||
}
|
}
|
||||||
|
|
||||||
config = discoverBackend(config)
|
config = discoverBackend(config)
|
||||||
@ -447,6 +450,12 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
|||||||
qemuArgs = append(qemuArgs, "-net", "nic")
|
qemuArgs = append(qemuArgs, "-net", "nic")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.TapDevice != "" {
|
||||||
|
qemuArgs = append(qemuArgs, "-net", "nic,model=virtio")
|
||||||
|
tapArg := fmt.Sprintf("tap,ifname=%s,script=no,downscript=no", config.TapDevice)
|
||||||
|
qemuArgs = append(qemuArgs, "-net", tapArg)
|
||||||
|
}
|
||||||
|
|
||||||
if config.GUI != true {
|
if config.GUI != true {
|
||||||
qemuArgs = append(qemuArgs, "-nographic")
|
qemuArgs = append(qemuArgs, "-nographic")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user