mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 01:59:07 +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
|
PublishedPorts []string
|
||||||
NetdevConfig string
|
NetdevConfig string
|
||||||
UUID uuid.UUID
|
UUID uuid.UUID
|
||||||
|
USB bool
|
||||||
|
Devices []string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -180,6 +182,11 @@ 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 [])")
|
||||||
|
|
||||||
|
// 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 {
|
if err := flags.Parse(args); err != nil {
|
||||||
log.Fatal("Unable to parse args")
|
log.Fatal("Unable to parse args")
|
||||||
}
|
}
|
||||||
@ -332,6 +339,8 @@ func runQemu(args []string) {
|
|||||||
PublishedPorts: publishFlags,
|
PublishedPorts: publishFlags,
|
||||||
NetdevConfig: netdevConfig,
|
NetdevConfig: netdevConfig,
|
||||||
UUID: vmUUID,
|
UUID: vmUUID,
|
||||||
|
USB: *usbEnabled,
|
||||||
|
Devices: deviceFlags,
|
||||||
}
|
}
|
||||||
|
|
||||||
config = discoverBackend(config)
|
config = discoverBackend(config)
|
||||||
@ -663,6 +672,13 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
|||||||
qemuArgs = append(qemuArgs, "-nographic")
|
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
|
return config, qemuArgs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user