Skip to content

Commit

Permalink
incusd/instance/qemu: Support LXD virtual machines
Browse files Browse the repository at this point in the history
This adds support for the LXD virtio-serial device and agent symlink
to allow existing virtual machines to function properly when imported
into Incus.

Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Aug 30, 2023
1 parent b6a4bbe commit 43d7a73
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions incusd/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -2454,6 +2454,11 @@ func (d *qemu) generateConfigShare() error {
} else {
d.logger.Debug("Skipping incus-agent install as unchanged", logger.Ctx{"srcPath": agentSrcPath, "installPath": agentInstallPath})
}

err = os.Symlink("incus-agent", filepath.Join(configDrivePath, "lxd-agent"))
if err != nil && !os.IsExist(err) {
return err
}
}

agentCert, agentKey, clientCert, _, err := d.generateAgentCert()
Expand Down
5 changes: 5 additions & 0 deletions incusd/instance/drivers/driver_qemu_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ func TestQemuConfigTemplates(t *testing.T) {
chardev = "qemu_serial-chardev"
bus = "dev-qemu_serial.0"
[device "qemu_serial_legacy"]
driver = "virtserialport"
name = "org.linuxcontainers.lxd"
bus = "dev-qemu_serial.0"
# Spice agent
[chardev "qemu_spice-chardev"]
backend = "spicevmc"
Expand Down
7 changes: 7 additions & 0 deletions incusd/instance/drivers/driver_qemu_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ func qemuSerial(opts *qemuSerialOpts) []cfgSection {
{key: "chardev", value: opts.charDevName},
{key: "bus", value: "dev-qemu_serial.0"},
},
}, {
name: `device "qemu_serial_legacy"`,
entries: []cfgEntry{
{key: "driver", value: "virtserialport"},
{key: "name", value: "org.linuxcontainers.lxd"},
{key: "bus", value: "dev-qemu_serial.0"},
},
}, {
name: `chardev "qemu_spice-chardev"`,
comment: "Spice agent",
Expand Down

0 comments on commit 43d7a73

Please sign in to comment.