[lxc-devel] [lxd/master] lxd/instance/qemu/vm/qemu: Implements deviceAdd and deviceRemove
tomponline on Github
lxc-bot at linuxcontainers.org
Thu Dec 12 15:26:35 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 433 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191212/7623c379/attachment.bin>
-------------- next part --------------
From 04c776b5d5a1cf76ca903c92a1cedeec112ac1a9 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 12 Dec 2019 15:25:25 +0000
Subject: [PATCH] lxd/instance/qemu/vm/qemu: Implements deviceAdd and
deviceRemove
Ensures dnsmasq host entries are created with generated MAC address.
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/instance/qemu/vm_qemu.go | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/lxd/instance/qemu/vm_qemu.go b/lxd/instance/qemu/vm_qemu.go
index f0c18f58ff..ac106c323c 100644
--- a/lxd/instance/qemu/vm_qemu.go
+++ b/lxd/instance/qemu/vm_qemu.go
@@ -2199,11 +2199,30 @@ func (vm *Qemu) Delete() error {
}
func (vm *Qemu) deviceAdd(deviceName string, rawConfig deviceConfig.Device) error {
- return nil
+ d, _, err := vm.deviceLoad(deviceName, rawConfig)
+ if err != nil {
+ return err
+ }
+
+ return d.Add()
}
func (vm *Qemu) deviceRemove(deviceName string, rawConfig deviceConfig.Device) error {
- return nil
+ d, _, err := vm.deviceLoad(deviceName, rawConfig)
+
+ // If deviceLoad fails with unsupported device type then return.
+ if err == device.ErrUnsupportedDevType {
+ return err
+ }
+
+ // If deviceLoad fails for any other reason then just log the error and proceed, as in the
+ // scenario that a new version of LXD has additional validation restrictions than older
+ // versions we still need to allow previously valid devices to be stopped.
+ if err != nil {
+ logger.Errorf("Device remove validation failed for '%s': %v", deviceName, err)
+ }
+
+ return d.Remove()
}
// Export publishes the instance.
More information about the lxc-devel
mailing list