[lxc-devel] [lxd/master] #7868: `proxy` device support for VMs (NAT-only)
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8240 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) === Allows `proxy` devices to attach to VMs, and runs the necessary startup hooks for the proxy device to work. CC: @grant-he @benhartcheatham From d1c9b0e1afe1b5b7868b8918cc769c8740eab3c5 Mon Sep 17 00:00:00 2001 From: JLRDRAGON92000 Date: Fri, 4 Dec 2020 22:58:58 -0600 Subject: [PATCH 1/3] lxd/device: allow adding proxy device to VM instances Signed-off-by: Jared Rankin --- lxd/device/proxy.go | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lxd/device/proxy.go b/lxd/device/proxy.go index d169a4671e..c114c0230f 100644 --- a/lxd/device/proxy.go +++ b/lxd/device/proxy.go @@ -48,7 +48,7 @@ type proxyProcInfo struct { // validateConfig checks the supplied config for correctness. func (d *proxy) validateConfig(instConf instance.ConfigReader) error { - if !instanceSupported(instConf.Type(), instancetype.Container) { + if !instanceSupported(instConf.Type(), instancetype.Container, instancetype.VM) { return ErrUnsupportedDevType } @@ -85,6 +85,10 @@ func (d *proxy) validateConfig(instConf instance.ConfigReader) error { return err } + if instConf.Type() == instancetype.VM && !shared.IsTrue(d.config["nat"]) { + return fmt.Errorf("Only NAT mode is supported for proxies on VM instances") + } + listenAddr, err := ProxyParseAddr(d.config["listen"]) if err != nil { return err From 3d0fad9d218f6a188ef1a7fa25536e4fdfae100e Mon Sep 17 00:00:00 2001 From: JLRDRAGON92000 Date: Fri, 4 Dec 2020 23:00:01 -0600 Subject: [PATCH 2/3] lxd/instance/drivers: run device post-start hooks in QEMU driver Signed-off-by: Jared Rankin --- lxd/instance/drivers/driver_qemu.go | 15 +++ 1 file changed, 15 insertions(+) diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go index e243634547..ef1b42f657 100644 --- a/lxd/instance/drivers/driver_qemu.go +++ b/lxd/instance/drivers/driver_qemu.go @@ -794,6 +794,7 @@ func (vm *qemu) Start(stateful bool) error { } devConfs := make([]*deviceConfig.RunConfig, 0, len(vm.expandedDevices)) + postStartHooks := []func() error{} // Setup devices in sorted order, this ensures that device mounts are added in path order. for _, d := range vm.expandedDevices.Sorted() { @@ -817,6 +818,11 @@ func (vm *qemu) Start(stateful bool) error { } }) + // Add post-start hooks + if len(runConf.PostHooks) > 0 { + postStartHooks = append(postStartHooks, runConf.PostHooks...) + } + devConfs = append(devConfs, runConf) } @@ -1071,6 +1077,15 @@ func (vm *qemu) Start(stateful bool) error { return err } + // Run any post-start hooks. + err = vm.runHooks(postStartHooks) + if err != nil { + op.Done(err) + // Shut down the VM if hooks fail. + vm.Stop(false) + return err + } + // Database updates err = vm.state.Cluster.Transaction(func(tx *db.ClusterTx) error { // Record current state From 4cf11b2ad0224d859825f858be7e9fb8f3850d5b Mon Sep 17 00:00:00 2001 From: JLRDRAGON92000 Date: Thu, 10 Dec 2020 15:57:44 -0600 Subject: [PATCH 3/3] doc: update `proxy` doc to reflect VM support Signed-off-by: Jared Rankin --- doc/instances.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/instances.md b/doc/instances.md index dece79586a..9ef66151b9 100644 --- a/doc/instances.md +++ b/doc/instances.md @@ -766,7 +766,7 @@ mode| int | 0660 | no| Mode of the device in ### Type: proxy -Supported instance types: container +Supported instance types: container (`nat` and non-`nat` modes), VM (`nat` mode only) Proxy devices allow forwarding network connections between host and instance. This makes it possible to forward traffic hitting one of the host's ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [lxd/master] Allow `user.*` keys everywhere we store configuration
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8202 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) === Issue #7870 -- this allows configuration keys starting with `user.*` in server config (`lxc config`). In a cluster, `user.*` keys are replicated across the cluster. From dae4f4083e8cdd97a8d3b264ed507058367d1467 Mon Sep 17 00:00:00 2001 From: JLRDRAGON92000 Date: Mon, 30 Nov 2020 18:18:30 -0600 Subject: [PATCH] lxd/config: allowed user.* keys in server/cluster config Signed-off-by: Jared Rankin --- lxd/config/map.go | 51 +-- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/lxd/config/map.go b/lxd/config/map.go index a4e949269b..dce73165e0 100644 --- a/lxd/config/map.go +++ b/lxd/config/map.go @@ -5,6 +5,7 @@ import ( "reflect" "sort" "strconv" + "strings" "github.com/lxc/lxd/shared" ) @@ -95,14 +96,21 @@ func (m *Map) Change(changes map[string]interface{}) (map[string]string, error) func (m *Map) Dump() map[string]interface{} { values := map[string]interface{}{} - for name, key := range m.schema { - value := m.GetRaw(name) - if value != key.Default { - if key.Hidden { - values[name] = true - } else { - values[name] = value + for name, value := range m.values { + key, ok := m.schema[name] + if ok { + // Schema key + value := m.GetRaw(name) + if value != key.Default { + if key.Hidden { + values[name] = true + } else { + values[name] = value + } } + } else if strings.HasPrefix(name, "user.") { + // User key, just include it as is + values[name] = value } } @@ -111,17 +119,21 @@ func (m *Map) Dump() map[string]interface{} { // GetRaw returns the value of the given key, which must be of type String. func (m *Map) GetRaw(name string) string { - key := m.schema.mustGetKey(name) value, ok := m.values[name] - if !ok { - value = key.Default + if !strings.HasPrefix(name, "user.") { + key := m.schema.mustGetKey(name) + if !ok { + value = key.Default + } } return value } // GetString returns the value of the given key, which must be of type String. func (m *Map) GetString(name string) string { - m.schema.assertKeyType(name, String) + if !strings.HasPrefix(name, "user.") { + m.schema.assertKeyType(name, String) + } return m.GetRaw(name) } @@ -182,6 +194,23 @@ func (m *Map) update(values map[string]string) ([]string, error) { // effectively revert it to the default. Return a boolean indicating whether // the value has changed, and error if something went wrong. func (m *Map) set(name string, value string, initial bool) (bool, error) { + // Bypass schema for user.* keys + if strings.HasPrefix(name, "user.") { + current, ok := m.values[name] + if ok && value == current { + // Value is unchanged + return false, nil + } + + if value == "" { + delete(m.values, name) + } else { + m.values[name] = value + } + + return true, nil + } + key, ok := m.schema[name] if !ok { return false, fmt.Errorf("unknown key") ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel