The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6694

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Defer instance type check until start time for cloud-init config disk drive.

As currently instance type is always container when running profile validation.

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
From 2ca8a4beec9a8b1fd6effcde2d7919fe6ba724c5 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@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.parr...@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
 }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to