[lxc-devel] [lxd/master] Bits for LXD 2.2
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Sep 13 04:25:19 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160913/6f3377b2/attachment.bin>
-------------- next part --------------
From 80ebe62761c43b0a9d5baa10ab3a82097f596295 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 13 Sep 2016 00:11:46 -0400
Subject: [PATCH 1/2] Fix support for lzma alone file format
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #2360
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/images.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lxd/images.go b/lxd/images.go
index e4c1b8f..842a923 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -64,12 +64,14 @@ func detectCompression(fname string) ([]string, string, error) {
return []string{"-Jxf"}, ".tar.xz", nil
case (bytes.Equal(header[1:5], []byte{'7', 'z', 'X', 'Z'}) && header[0] != 0xFD):
return []string{"--lzma", "-xf"}, ".tar.lzma", nil
+ case bytes.Equal(header[0:3], []byte{0x5d, 0x00, 0x00}):
+ return []string{"--lzma", "-xf"}, ".tar.lzma", nil
case bytes.Equal(header[257:262], []byte{'u', 's', 't', 'a', 'r'}):
return []string{"-xf"}, ".tar", nil
case bytes.Equal(header[0:4], []byte{'h', 's', 'q', 's'}):
return []string{""}, ".squashfs", nil
default:
- return []string{""}, "", fmt.Errorf("Unsupported compression.")
+ return []string{""}, "", fmt.Errorf("Unsupported compression")
}
}
From dda806c6408289a9afbaaa2cca7133a4b4ae996a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 13 Sep 2016 00:24:34 -0400
Subject: [PATCH 2/2] Add storage.zfs_use_refquota
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #2354
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
doc/api-extensions.md | 10 +++++++++-
doc/configuration.md | 1 +
lxd/api_1.0.go | 1 +
lxd/daemon_config.go | 1 +
lxd/storage_zfs.go | 16 +++++++++++++---
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/doc/api-extensions.md b/doc/api-extensions.md
index 816fab7..b636818 100644
--- a/doc/api-extensions.md
+++ b/doc/api-extensions.md
@@ -81,10 +81,18 @@ This adds support for a compression\_algorithm property when creating an image (
Setting this property overrides the server default value (images.compression\_algorithm).
## directory\_manipulation
-
This allows for creating and listing directories via the LXD API, and exports
the file type via the X-LXD-type header, which can be either "file" or
"directory" right now.
## container\_cpu\_time
This adds support for retrieving cpu time for a running container.
+
+## storage\_zfs\_use\_refquota
+Introduces a new server property "storage.zfs\_use\_refquota" which instructs LXD
+to set the "refquota" property instead of "quota" when setting a size limit
+on a container. LXD will also then use "usedbydataset" in place of "used"
+when being queried about disk utilization.
+
+This effectively controls whether disk usage by snapshots should be
+considered as part of the container's disk space usage.
diff --git a/doc/configuration.md b/doc/configuration.md
index 7665f2c..d705a29 100644
--- a/doc/configuration.md
+++ b/doc/configuration.md
@@ -34,6 +34,7 @@ storage.lvm\_fstype | string | ext4 | -
storage.lvm\_volume\_size | string | 10GiB | - | Size of the logical volume
storage.zfs\_pool\_name | string | - | - | ZFS pool name
storage.zfs\_remove\_snapshots | boolean | false | storage\_zfs\_remove\_snapshots | Automatically remove any needed snapshot when attempting a container restore
+storage.zfs\_use\_refquota | boolean | false | storage\_zfs\_use\_refquota | Don't include snapshots as part of container quota (size property) or in reported disk usage
images.compression\_algorithm | string | gzip | - | Compression algorithm to use for new images (bzip2, gzip, lzma, xz or none)
images.remote\_cache\_expiry | integer | 10 | - | Number of days after which an unused cached remote image will be flushed
images.auto\_update\_interval | integer | 6 | - | Interval in hours at which to look for update to cached images (0 disables it)
diff --git a/lxd/api_1.0.go b/lxd/api_1.0.go
index 7e83267..933c06f 100644
--- a/lxd/api_1.0.go
+++ b/lxd/api_1.0.go
@@ -67,6 +67,7 @@ func api10Get(d *Daemon, r *http.Request) Response {
"image_compression_algorithm",
"directory_manipulation",
"container_cpu_time",
+ "storage_zfs_use_refquota",
},
"api_status": "stable",
diff --git a/lxd/daemon_config.go b/lxd/daemon_config.go
index 82d6726..473054c 100644
--- a/lxd/daemon_config.go
+++ b/lxd/daemon_config.go
@@ -185,6 +185,7 @@ func daemonConfigInit(db *sql.DB) error {
"storage.lvm_volume_size": &daemonConfigKey{valueType: "string", defaultValue: "10GiB"},
"storage.zfs_pool_name": &daemonConfigKey{valueType: "string", validator: storageZFSValidatePoolName, setter: daemonConfigSetStorage},
"storage.zfs_remove_snapshots": &daemonConfigKey{valueType: "bool"},
+ "storage.zfs_use_refquota": &daemonConfigKey{valueType: "bool"},
}
// Load the values from the DB
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index e755b1a..27ac0e1 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -418,10 +418,15 @@ func (s *storageZfs) ContainerSetQuota(container container, size int64) error {
fs := fmt.Sprintf("containers/%s", container.Name())
+ property := "quota"
+ if daemonConfig["storage.zfs_use_refquota"].GetBool() {
+ property = "refquota"
+ }
+
if size > 0 {
- err = s.zfsSet(fs, "quota", fmt.Sprintf("%d", size))
+ err = s.zfsSet(fs, property, fmt.Sprintf("%d", size))
} else {
- err = s.zfsSet(fs, "quota", "none")
+ err = s.zfsSet(fs, property, "none")
}
if err != nil {
@@ -436,7 +441,12 @@ func (s *storageZfs) ContainerGetUsage(container container) (int64, error) {
fs := fmt.Sprintf("containers/%s", container.Name())
- value, err := s.zfsGet(fs, "used")
+ property := "used"
+ if daemonConfig["storage.zfs_use_refquota"].GetBool() {
+ property = "usedbydataset"
+ }
+
+ value, err := s.zfsGet(fs, property)
if err != nil {
return -1, err
}
More information about the lxc-devel
mailing list