[lxc-devel] [lxd/master] VM optimization and fixes

stgraber on Github lxc-bot at linuxcontainers.org
Mon Feb 3 18:22:23 UTC 2020


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/20200203/ffde6435/attachment-0001.bin>
-------------- next part --------------
From cc8a972c13fee8a31779d85509bdf050dd185aab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 3 Feb 2020 12:49:01 +0100
Subject: [PATCH 1/5] lxd/vm: Use vhost_net
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/instance/drivers/driver_qemu_templates.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lxd/instance/drivers/driver_qemu_templates.go b/lxd/instance/drivers/driver_qemu_templates.go
index 6567a474b0..651d07b950 100644
--- a/lxd/instance/drivers/driver_qemu_templates.go
+++ b/lxd/instance/drivers/driver_qemu_templates.go
@@ -246,6 +246,7 @@ var qemuNetDevTapTun = template.Must(qemuDevTapCommon.New("qemuNetDevTapTun").Pa
 # Network card ("{{.devName}}" device)
 [netdev "lxd_{{.devName}}"]
 type = "tap"
+vhost = "on"
 ifname = "{{.ifName}}"
 script = "no"
 downscript = "no"
@@ -257,6 +258,7 @@ var qemuNetdevTapFD = template.Must(qemuDevTapCommon.New("qemuNetdevTapFD").Pars
 # Network card ("{{.devName}}" device)
 [netdev "lxd_{{.devName}}"]
 type = "tap"
+vhost = "on"
 fd = "{{.tapFD}}"
 {{ template "qemuDevTapCommon" . -}}
 `))

From ca3b9e093d9e3ed8785cd1ea248d5368de874c78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 3 Feb 2020 12:51:54 +0100
Subject: [PATCH 2/5] lxd/vm: Enable block discard
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/instance/drivers/driver_qemu_templates.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lxd/instance/drivers/driver_qemu_templates.go b/lxd/instance/drivers/driver_qemu_templates.go
index 651d07b950..2c0700c753 100644
--- a/lxd/instance/drivers/driver_qemu_templates.go
+++ b/lxd/instance/drivers/driver_qemu_templates.go
@@ -206,6 +206,7 @@ format = "raw"
 if = "none"
 cache = "{{.cacheMode}}"
 aio = "{{.aioMode}}"
+discard = "on"
 
 [device "dev-lxd_{{.devName}}"]
 driver = "scsi-hd"

From 4f81d3d51b537e51c7d90f15a6448864ac2db6ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 3 Feb 2020 13:17:19 +0100
Subject: [PATCH 3/5] shared/archive: Fix out of space logic
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6556

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 shared/archive_linux.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shared/archive_linux.go b/shared/archive_linux.go
index 7bd0ff4382..17a4b9c208 100644
--- a/shared/archive_linux.go
+++ b/shared/archive_linux.go
@@ -85,7 +85,7 @@ func Unpack(file string, path string, blockBackend bool, runningInUserns bool, t
 		}
 
 		// Check if we're running out of space
-		if int64(fs.Bfree) < int64(2*fs.Bsize) {
+		if int64(fs.Bfree) < 10 {
 			if blockBackend {
 				return fmt.Errorf("Unable to unpack image, run out of disk space (consider increasing your pool's volume.size)")
 			} else {

From 9a6e76b28f8dfc35a0441fbaf17658a6782310b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 3 Feb 2020 13:39:21 +0100
Subject: [PATCH 4/5] lxd/vm: Set Documentation in systemd units
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/instance/drivers/driver_qemu.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go
index 7929990120..ac2e3f8c60 100644
--- a/lxd/instance/drivers/driver_qemu.go
+++ b/lxd/instance/drivers/driver_qemu.go
@@ -1159,6 +1159,7 @@ func (vm *qemu) generateConfigShare() error {
 
 	lxdAgentServiceUnit := `[Unit]
 Description=LXD - agent
+Documentation=https://linuxcontainers.org/lxd
 ConditionPathExists=/dev/virtio-ports/org.linuxcontainers.lxd
 Requires=lxd-agent-9p.service
 After=lxd-agent-9p.service
@@ -1180,6 +1181,7 @@ WantedBy=multi-user.target
 
 	lxdConfigShareMountUnit := `[Unit]
 Description=LXD - agent - 9p mount
+Documentation=https://linuxcontainers.org/lxd
 ConditionPathExists=/dev/virtio-ports/org.linuxcontainers.lxd
 
 [Service]

From 662ac365c8fe9ec9045be3b47ee3805bff6440b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 3 Feb 2020 13:48:03 +0100
Subject: [PATCH 5/5] lxd/vm: Silence writeback warning for config drive
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/device/disk.go                  | 1 +
 lxd/instance/drivers/driver_qemu.go | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lxd/device/disk.go b/lxd/device/disk.go
index bc5404ecd0..6e33a5b4ff 100644
--- a/lxd/device/disk.go
+++ b/lxd/device/disk.go
@@ -384,6 +384,7 @@ func (d *disk) startVM() (*deviceConfig.RunConfig, error) {
 			{
 				DevPath: isoPath,
 				DevName: d.name,
+				FSType:  "iso9660",
 			},
 		}
 		return &runConf, nil
diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go
index ac2e3f8c60..4abb4ec4d6 100644
--- a/lxd/instance/drivers/driver_qemu.go
+++ b/lxd/instance/drivers/driver_qemu.go
@@ -1479,7 +1479,9 @@ func (vm *qemu) addDriveConfig(sb *strings.Builder, bootIndexes map[string]int,
 
 		// If FS is ZFS, avoid using direct I/O and use host page cache only.
 		if fsType == "zfs" {
-			logger.Warnf("Using writeback cache I/O with %s", driveConf.DevPath)
+			if driveConf.FSType != "iso9660" {
+				logger.Warnf("Using writeback cache I/O with %s", driveConf.DevPath)
+			}
 			aioMode = "threads"
 			cacheMode = "writeback" // Use host cache, with neither O_DSYNC nor O_DIRECT semantics.
 		}


More information about the lxc-devel mailing list