mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 01:06:27 +00:00
Merge pull request #3235 from kkroo/qemu_usb
Add qemu USB device pass through
This commit is contained in:
commit
9d1838d812
@ -47,6 +47,8 @@ type QemuConfig struct {
|
||||
PublishedPorts []string
|
||||
NetdevConfig string
|
||||
UUID uuid.UUID
|
||||
USB bool
|
||||
Devices []string
|
||||
}
|
||||
|
||||
const (
|
||||
@ -180,6 +182,11 @@ func runQemu(args []string) {
|
||||
publishFlags := multipleFlag{}
|
||||
flags.Var(&publishFlags, "publish", "Publish a vm's port(s) to the host (default [])")
|
||||
|
||||
// USB devices
|
||||
usbEnabled := flags.Bool("usb", false, "Enable USB controller")
|
||||
deviceFlags := multipleFlag{}
|
||||
flags.Var(&deviceFlags, "device", "Add USB host device(s). Format driver[,prop=value][,...] -- add device, like -device on the qemu command line.")
|
||||
|
||||
if err := flags.Parse(args); err != nil {
|
||||
log.Fatal("Unable to parse args")
|
||||
}
|
||||
@ -332,6 +339,8 @@ func runQemu(args []string) {
|
||||
PublishedPorts: publishFlags,
|
||||
NetdevConfig: netdevConfig,
|
||||
UUID: vmUUID,
|
||||
USB: *usbEnabled,
|
||||
Devices: deviceFlags,
|
||||
}
|
||||
|
||||
config = discoverBackend(config)
|
||||
@ -663,6 +672,13 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
||||
qemuArgs = append(qemuArgs, "-nographic")
|
||||
}
|
||||
|
||||
if config.USB == true {
|
||||
qemuArgs = append(qemuArgs, "-usb")
|
||||
}
|
||||
for _, d := range config.Devices {
|
||||
qemuArgs = append(qemuArgs, "-device", d)
|
||||
}
|
||||
|
||||
return config, qemuArgs
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user