[lxc-devel] [lxd/master] VM: Device check improvements
tomponline on Github
lxc-bot at linuxcontainers.org
Thu Jan 30 14:42:28 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/20200130/ab60a9a8/attachment.bin>
-------------- next part --------------
From bf2277b88ed2a2fd34b3ac02d9a0098429bf3cae Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 30 Jan 2020 14:41:25 +0000
Subject: [PATCH 1/2] lxd/device/disk: Adds a check for mkisofs tool for qemu
config drive
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/device/disk.go | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lxd/device/disk.go b/lxd/device/disk.go
index f2b4eb00c6..2399d70fe4 100644
--- a/lxd/device/disk.go
+++ b/lxd/device/disk.go
@@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"
+ "os/exec"
"path/filepath"
"strconv"
"strings"
@@ -1169,8 +1170,14 @@ func (d *disk) getParentBlocks(path string) ([]string, error) {
func (d *disk) generateVMConfigDrive() (string, error) {
scratchDir := filepath.Join(d.inst.DevicesPath(), deviceNameEncode(d.name))
+ // Check we have the mkisofs tool available.
+ mkisofsPath, err := exec.LookPath("mkisofs")
+ if err != nil {
+ return "", err
+ }
+
// Create config drive dir.
- err := os.MkdirAll(scratchDir, 0100)
+ err = os.MkdirAll(scratchDir, 0100)
if err != nil {
return "", err
}
@@ -1215,7 +1222,7 @@ local-hostname: %s
// templates on first boot. The vendor-data template then modifies the system so that the
// config drive is mounted and the agent is started on subsequent boots.
isoPath := filepath.Join(d.inst.Path(), "config.iso")
- _, err = shared.RunCommand("mkisofs", "-R", "-V", "cidata", "-o", isoPath, scratchDir)
+ _, err = shared.RunCommand(mkisofsPath, "-R", "-V", "cidata", "-o", isoPath, scratchDir)
if err != nil {
return "", err
}
From 0f06439089bc68df5a7f44113fbba4896e79d25b Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 30 Jan 2020 14:41:48 +0000
Subject: [PATCH 2/2] lxd/device/nic/sriov: Loads vfio-pci module
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/device/nic_sriov.go | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lxd/device/nic_sriov.go b/lxd/device/nic_sriov.go
index 9269604381..dd208708f1 100644
--- a/lxd/device/nic_sriov.go
+++ b/lxd/device/nic_sriov.go
@@ -10,9 +10,12 @@ import (
"strconv"
"strings"
+ "github.com/pkg/errors"
+
deviceConfig "github.com/lxc/lxd/lxd/device/config"
"github.com/lxc/lxd/lxd/instance/instancetype"
"github.com/lxc/lxd/lxd/revert"
+ "github.com/lxc/lxd/lxd/util"
"github.com/lxc/lxd/shared"
)
@@ -72,6 +75,14 @@ func (d *nicSRIOV) Start() (*deviceConfig.RunConfig, error) {
saveData := make(map[string]string)
+ // If VM, then try and load the vfio-pci module first.
+ if d.inst.Type() == instancetype.VM {
+ err = util.LoadModule("vfio-pci")
+ if err != nil {
+ return nil, errors.Wrapf(err, "Error loading %q module", "vfio-pci")
+ }
+ }
+
reservedDevices, err := instanceGetReservedDevices(d.state, d.config)
if err != nil {
return nil, err
More information about the lxc-devel
mailing list