[lxc-devel] [lxd/master] Device: Allows cloud-init config drive to be added to profiles used by VMs

tomponline on Github lxc-bot at linuxcontainers.org
Mon Jan 13 08:57:12 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 524 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200113/453d2210/attachment.bin>
-------------- next part --------------
From 2ca8a4beec9a8b1fd6effcde2d7919fe6ba724c5 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 13 Jan 2020 08:46:33 +0000
Subject: [PATCH] lxd/device/disk: Defer instance type check until start time
 for cloud-init config drive

Allows cloud-init config drive to be added to profiles used by VMs.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/device/disk.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lxd/device/disk.go b/lxd/device/disk.go
index d497553245..76dc6bcefc 100644
--- a/lxd/device/disk.go
+++ b/lxd/device/disk.go
@@ -83,8 +83,9 @@ func (d *disk) validateConfig() error {
 		"ceph.user_name":    shared.IsAny,
 	}
 
-	// VMs can have a special cloud-init config drive attached with no path.
-	if d.instance.Type() != instancetype.VM || d.config["source"] != diskSourceCloudInit {
+	// VMs can have a special cloud-init config drive attached with no path. Don't check instance type here
+	// to allow mixed instance type profiles to use this setting. We will check at device start for VM type.
+	if d.config["source"] != diskSourceCloudInit {
 		rules["path"] = shared.IsNotEmpty
 	}
 
@@ -190,6 +191,10 @@ func (d *disk) validateEnvironment() error {
 		return fmt.Errorf("shiftfs is required by disk entry but isn't supported on system")
 	}
 
+	if d.instance.Type() != instancetype.VM && d.config["source"] == diskSourceCloudInit {
+		return fmt.Errorf("disks with source=%s are only supported by virtual machines", diskSourceCloudInit)
+	}
+
 	return nil
 }
 


More information about the lxc-devel mailing list