[lxc-devel] [lxc/master] network: use __instantiate_ns_common() in instantiate_ns_phys() too
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/3419 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) === Fixes: https://lists.linuxcontainers.org/pipermail/lxc-users/2020-May/015245.html Signed-off-by: Christian Brauner From 9d0406c79dd19a76b0974910855f4a1d6e87b70e Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 19 May 2020 09:09:24 +0200 Subject: [PATCH] network: use __instantiate_ns_common() in instantiate_ns_phys() too Fixes: https://lists.linuxcontainers.org/pipermail/lxc-users/2020-May/015245.html Signed-off-by: Christian Brauner --- src/lxc/network.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/lxc/network.c b/src/lxc/network.c index 5845a5c13f..da09141dd6 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -860,7 +860,7 @@ static instantiate_cb netdev_conf[LXC_NET_MAXCONFTYPE + 1] = { [LXC_NET_NONE]= instantiate_none, }; -static int __instantiate_common(struct lxc_netdev *netdev) +static int __instantiate_ns_common(struct lxc_netdev *netdev) { char current_ifname[IFNAMSIZ]; @@ -905,33 +905,27 @@ static int __instantiate_common(struct lxc_netdev *netdev) static int instantiate_ns_veth(struct lxc_netdev *netdev) { - return __instantiate_common(netdev); + return __instantiate_ns_common(netdev); } static int instantiate_ns_macvlan(struct lxc_netdev *netdev) { - return __instantiate_common(netdev); + return __instantiate_ns_common(netdev); } static int instantiate_ns_ipvlan(struct lxc_netdev *netdev) { - return __instantiate_common(netdev); + return __instantiate_ns_common(netdev); } static int instantiate_ns_vlan(struct lxc_netdev *netdev) { - return __instantiate_common(netdev); + return __instantiate_ns_common(netdev); } static int instantiate_ns_phys(struct lxc_netdev *netdev) { - netdev->ifindex = if_nametoindex(netdev->name); - if (!netdev->ifindex) - return log_error_errno(-1, errno, - "Failed to retrieve ifindex for network device with name %s", - netdev->name); - - return 0; + return __instantiate_ns_common(netdev); } static int instantiate_ns_empty(struct lxc_netdev *netdev) ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [lxd/master] Storage: Restore dir project quotas on import
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7384 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) === Fixes https://github.com/lxc/lxd/issues/7365 From aebc3dbbd7f4f5fbd39827ce61b9b577f31f5989 Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Tue, 19 May 2020 08:54:35 +0100 Subject: [PATCH 1/5] lxd/storage/quota/projectquota: Fixes leaking file handles in quota_set_path and quota_get_path Signed-off-by: Thomas Parrott --- lxd/storage/quota/projectquota.go | 6 ++ 1 file changed, 6 insertions(+) diff --git a/lxd/storage/quota/projectquota.go b/lxd/storage/quota/projectquota.go index c1b6b1ad1b..578b6db57d 100644 --- a/lxd/storage/quota/projectquota.go +++ b/lxd/storage/quota/projectquota.go @@ -22,6 +22,7 @@ import ( #include #include #include +#include #ifndef FS_XFLAG_PROJINHERIT struct fsxattr { @@ -120,6 +121,7 @@ int quota_set_path(char *path, uint32_t id) { ret = ioctl(fd, FS_IOC_FSGETXATTR, &attr); if (ret < 0) { + close(fd); return -1; } @@ -128,9 +130,11 @@ int quota_set_path(char *path, uint32_t id) { ret = ioctl(fd, FS_IOC_FSSETXATTR, &attr); if (ret < 0) { + close(fd); return -1; } + close(fd); return 0; } @@ -145,9 +149,11 @@ int32_t quota_get_path(char *path) { ret = ioctl(fd, FS_IOC_FSGETXATTR, &attr); if (ret < 0) { + close(fd); return -1; } + close(fd); return attr.fsx_projid; } From 6f5a4f43cd8218aab04e4d1c715f871394fdcc83 Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Tue, 19 May 2020 08:56:50 +0100 Subject: [PATCH 2/5] lxd/storage/quota/projectquota: Adds inherit argument to quota_set_path Allows disabling FS_XFLAG_PROJINHERIT flag on FS_IOC_FSSETXATTR so project can be set on non-directories. Signed-off-by: Thomas Parrott --- lxd/storage/quota/projectquota.go | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lxd/storage/quota/projectquota.go b/lxd/storage/quota/projectquota.go index 578b6db57d..a934db687d 100644 --- a/lxd/storage/quota/projectquota.go +++ b/lxd/storage/quota/projectquota.go @@ -22,6 +22,7 @@ import ( #include #include #include +#include #include #ifndef FS_XFLAG_PROJINHERIT @@ -110,7 +111,7 @@ int quota_set(char *dev_path, uint32_t id, uint64_t hard_bytes) { return 0; } -int quota_set_path(char *path, uint32_t id) { +int quota_set_path(char *path, uint32_t id, bool inherit) { struct fsxattr attr; int fd; int ret; @@ -125,7 +126,10 @@ int quota_set_path(char *path, uint32_t id) { return -1; } - attr.fsx_xflags |= FS_XFLAG_PROJINHERIT; + if (inherit) { + attr.fsx_xflags |= FS_XFLAG_PROJINHERIT; + } + attr.fsx_projid = id; ret = ioctl(fd, FS_IOC_FSSETXATTR, &attr); From 0ee371669945f42f150f4f9b639d0084da004b3a Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Tue, 19 May 2020 09:12:18 +0100 Subject: [PATCH 3/5] lxd/storage/quota/projectquota: Updates SetProject to recursively set project and support non-directory files Signed-off-by: Thomas Parrott --- lxd/storage/quota/projectquota.go | 41 +-- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/lxd/storage/quota/projectquota.go b/lxd/storage/quota/projectquota.go index a934db687d..134ae259e0 100644 --- a/lxd/storage/quota/projectquota.go +++ b/lxd/storage/quota/projectquota.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "os" + "path/filepath" "strings" "unsafe" @@ -232,17 +233,41 @@ func GetProject(path string) (uint32, error) { return uint32(id), nil } -// SetProject sets the project quota ID for the given path +// SetProject recursively sets the project quota ID (and project inherit flag on directories) for the given path. func SetProject(path string, id uint32) error { - // Call ioctl through CGo - cPath := C.CString(path) - defer C.free(unsafe.Pointer(cPath)) + err := filepath.Walk(path, func(filePath string, info os.FileInfo, err error) error { + if err != nil { + return err + } - if C.quota_set_path(cPath, C.uint32_t(id)) != 0 { - return fmt.Errorf("Failed to set project id '%d' on '%s'", id, path) - } + inherit := false - return nil + if info.IsDir() { + inherit = true // Only can set FS_XFLAG_PROJINHERIT on directories. + } + + // Call ioctl through CGo. + cPath := C.CString(filePath) + defer C.free(unsafe.Pointer
[lxc-devel] [lxc/lxc] 9d0406: network: use __instantiate_ns_common() in instanti...
Branch: refs/heads/master Home: https://github.com/lxc/lxc Commit: 9d0406c79dd19a76b0974910855f4a1d6e87b70e https://github.com/lxc/lxc/commit/9d0406c79dd19a76b0974910855f4a1d6e87b70e Author: Christian Brauner Date: 2020-05-19 (Tue, 19 May 2020) Changed paths: M src/lxc/network.c Log Message: --- network: use __instantiate_ns_common() in instantiate_ns_phys() too Fixes: https://lists.linuxcontainers.org/pipermail/lxc-users/2020-May/015245.html Signed-off-by: Christian Brauner Commit: 2b5d8a439c913d8f69f3fb44e1bf3a6cfdd86a4f https://github.com/lxc/lxc/commit/2b5d8a439c913d8f69f3fb44e1bf3a6cfdd86a4f Author: Christian Brauner Date: 2020-05-19 (Tue, 19 May 2020) Changed paths: M src/lxc/network.c Log Message: --- Merge pull request #3419 from brauner/2020-05-19/network_phys_fixes network: use __instantiate_ns_common() in instantiate_ns_phys() too Compare: https://github.com/lxc/lxc/compare/b23d806cb2a5...2b5d8a439c91 ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [distrobuilder/master] Fix checksum check
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/332 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) === From 4a449714dae975dc49ebe1db2c34b76c15a047d4 Mon Sep 17 00:00:00 2001 From: Thomas Hipp Date: Tue, 19 May 2020 11:38:00 +0200 Subject: [PATCH 1/2] shared: Handle multiple checksums Gentoo provides multiple hashes (BLAKE2B and SHA512) for the same file. Instead of failing on the first mismatch, we need to check all checksums. Signed-off-by: Thomas Hipp --- shared/net.go | 27 ++- shared/util.go | 23 ++- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/shared/net.go b/shared/net.go index 408425e..8ac9081 100644 --- a/shared/net.go +++ b/shared/net.go @@ -20,6 +20,7 @@ import ( func DownloadHash(def DefinitionImage, file, checksum string, hashFunc hash.Hash) (string, error) { var ( client http.Client + hashes []string hash string errerror ) @@ -40,7 +41,7 @@ func DownloadHash(def DefinitionImage, file, checksum string, hashFunc hash.Hash hashLen = hashFunc.Size() * 2 } - hash, err = downloadChecksum(targetDir, checksum, file, hashFunc, hashLen) + hashes, err = downloadChecksum(targetDir, checksum, file, hashFunc, hashLen) if err != nil { return "", errors.Wrap(err, "Error while downloading checksum") } @@ -67,8 +68,16 @@ func DownloadHash(def DefinitionImage, file, checksum string, hashFunc hash.Hash } result := fmt.Sprintf("%x", hashFunc.Sum(nil)) - if result != hash { - return "", fmt.Errorf("Hash mismatch for %s: %s != %s", imagePath, result, hash) + + for _, h := range hashes { + if result == h { + hash = h + break + } + } + + if hash == "" { + return "", fmt.Errorf("Hash mismatch for %s: %s != %v", imagePath, result, hashes) } } @@ -103,7 +112,7 @@ func DownloadHash(def DefinitionImage, file, checksum string, hashFunc hash.Hash // downloadChecksum downloads or opens URL, and matches fname against the // checksums inside of the downloaded or opened file. -func downloadChecksum(targetDir string, URL string, fname string, hashFunc hash.Hash, hashLen int) (string, error) { +func downloadChecksum(targetDir string, URL string, fname string, hashFunc hash.Hash, hashLen int) ([]string, error) { var ( client http.Client tempFile *os.File @@ -115,29 +124,29 @@ func downloadChecksum(targetDir string, URL string, fname string, hashFunc hash. if err == nil && !fi.IsDir() { tempFile, err = os.Open(filepath.Join(targetDir, URL)) if err != nil { - return "", err + return nil, err } defer os.Remove(tempFile.Name()) } else { tempFile, err = ioutil.TempFile(targetDir, "hash.") if err != nil { - return "", err + return nil, err } defer os.Remove(tempFile.Name()) _, err = lxd.DownloadFileHash(&client, "", nil, nil, "", URL, "", hashFunc, tempFile) // ignore hash mismatch if err != nil && !strings.HasPrefix(err.Error(), "Hash mismatch") { - return "", err + return nil, err } } tempFile.Seek(0, 0) checksum := getChecksum(filepath.Base(fname), hashLen, tempFile) - if checksum != "" { + if checksum != nil { return checksum, nil } - return "", fmt.Errorf("Could not find checksum") + return nil, fmt.Errorf("Could not find checksum") } diff --git a/shared/util.go b/shared/util.go index 2b66c9f..abaf4d0 100644 --- a/shared/util.go +++ b/shared/util.go @@ -368,10 +368,11 @@ func GetTargetDir(def DefinitionImage) string { return targetDir } -func getChecksum(fname string, hashLen int, r io.Reader) string { +func getChecksum(fname string, hashLen int, r io.Reader) []string { scanner := bufio.NewScanner(r) var matches []string + var result []string for scanner.Scan() { if !strings.Contains(scanner.Text(), fname) { @@ -395,19 +396,27 @@ func getChecksum(fname
[lxc-devel] [lxd/master] Database logic cleanup part 2
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7386 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) === From 72b248177ce376d598037f99a485b0bfab919fd8 Mon Sep 17 00:00:00 2001 From: Free Ekanayaka Date: Mon, 11 May 2020 11:19:21 +0100 Subject: [PATCH 1/8] lxd/db: Change UpdateCertificate to RenameCertificate (only renaming supported) Signed-off-by: Free Ekanayaka --- lxd/certificates.go | 2 +- lxd/db/certificates.go| 9 + lxd/db/certificates.mapper.go | 22 ++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lxd/certificates.go b/lxd/certificates.go index fa817c1ee2..917f5d1178 100644 --- a/lxd/certificates.go +++ b/lxd/certificates.go @@ -322,7 +322,7 @@ func doCertificateUpdate(d *Daemon, fingerprint string, req api.CertificatePut) return response.BadRequest(fmt.Errorf("Unknown request type %s", req.Type)) } - err := d.cluster.UpdateCertificate(fingerprint, req.Name, 1) + err := d.cluster.RenameCertificate(fingerprint, req.Name) if err != nil { return response.SmartError(err) } diff --git a/lxd/db/certificates.go b/lxd/db/certificates.go index cfefaa773e..5176ceb29c 100644 --- a/lxd/db/certificates.go +++ b/lxd/db/certificates.go @@ -12,6 +12,7 @@ package db //go:generate mapper stmt -p db -e certificate id //go:generate mapper stmt -p db -e certificate create struct=Certificate //go:generate mapper stmt -p db -e certificate delete +//go:generate mapper stmt -p db -e certificate rename // //go:generate mapper method -p db -e certificate List //go:generate mapper method -p db -e certificate Get @@ -19,6 +20,7 @@ package db //go:generate mapper method -p db -e certificate Exists struct=Certificate //go:generate mapper method -p db -e certificate Create struct=Certificate //go:generate mapper method -p db -e certificate Delete +//go:generate mapper method -p db -e certificate Rename // Certificate is here to pass the certificates content // from the database around @@ -66,11 +68,10 @@ func (c *Cluster) DeleteCertificate(fingerprint string) error { return err } -// UpdateCertificate updates the certificate with the given fingerprint. -func (c *Cluster) UpdateCertificate(fingerprint string, certName string, certType int) error { +// RenameCertificate updates a certificate's name. +func (c *Cluster) RenameCertificate(fingerprint string, name string) error { err := c.Transaction(func(tx *ClusterTx) error { - _, err := tx.tx.Exec("UPDATE certificates SET name=?, type=? WHERE fingerprint=?", certName, certType, fingerprint) - return err + return c.RenameCertificate(fingerprint, name) }) return err } diff --git a/lxd/db/certificates.mapper.go b/lxd/db/certificates.mapper.go index 4f6e718358..c682094754 100644 --- a/lxd/db/certificates.mapper.go +++ b/lxd/db/certificates.mapper.go @@ -41,6 +41,10 @@ var certificateDelete = cluster.RegisterStmt(` DELETE FROM certificates WHERE fingerprint = ? `) +var certificateRename = cluster.RegisterStmt(` +UPDATE certificates SET name = ? WHERE fingerprint = ? +`) + // GetCertificates returns all available certificates. func (c *ClusterTx) GetCertificates(filter CertificateFilter) ([]Certificate, error) { // Result slice. @@ -203,3 +207,21 @@ func (c *ClusterTx) DeleteCertificate(fingerprint string) error { return nil } + +// RenameCertificate renames the certificate matching the given key parameters. +func (c *ClusterTx) RenameCertificate(fingerprint string, to string) error { + stmt := c.stmt(certificateRename) + result, err := stmt.Exec(to, fingerprint) + if err != nil { + return errors.Wrap(err, "Rename certificate") + } + + n, err := result.RowsAffected() + if err != nil { + return errors.Wrap(err, "Fetch affected rows") + } + if n != 1 { + return fmt.Errorf("Query affected %d rows instead of 1", n) + } + return nil +} From 1bb5dde03ee8174197bdea33dfe6446cb66e0f7e Mon Sep 17 00:00:00 2001 From: Free Ekanayaka Date: Mon, 11 May 2020 11:23:28 +0100 Subject: [PATCH 2/8] lxd/db: Rename containers.go to instances.go Signed-off-by: Free Ekanayaka --- lxd/db/{containers.go => instances.go} | 0 lxd/db/{containers_export_test.go => instances_export_test.go} | 0 lxd/db/{containers_test.go => instances_test.go} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename lxd/db/{containers.go => instances.go} (100%) rename lxd/db/{containers_export_test.go => instances_export_test.go} (100%) rename lxd/db/{containers_test.go => instances_test.go} (100%) diff --git a/lxd/db/containers.go
[lxc-devel] [lxd/master] firewall: Fixes proxy nat rule dynamic family when using nftables
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7389 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) === Signed-off-by: Thomas Parrott From 0a46bae0680a047f92ffc7e2ea055f8fb7aa7aeb Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Tue, 19 May 2020 17:37:05 +0100 Subject: [PATCH] lxd/firewall/drivers/driver/nftables/templates: Fixes proxy nat rule dynamic family Signed-off-by: Thomas Parrott --- lxd/firewall/drivers/drivers_nftables_templates.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxd/firewall/drivers/drivers_nftables_templates.go b/lxd/firewall/drivers/drivers_nftables_templates.go index 31551e4bcd..bd768d3572 100644 --- a/lxd/firewall/drivers/drivers_nftables_templates.go +++ b/lxd/firewall/drivers/drivers_nftables_templates.go @@ -71,7 +71,7 @@ chain out{{.chainSeparator}}{{.deviceLabel}} { chain pstrt{{.chainSeparator}}{{.deviceLabel}} { type nat hook postrouting priority 100; policy accept; {{- range .rules}} - {{.family}} saddr {{.connectHost}} ip daddr {{.connectHost}} {{.connType}} dport {{.connectPort}} masquerade + {{.family}} saddr {{.connectHost}} {{.family}} daddr {{.connectHost}} {{.connType}} dport {{.connectPort}} masquerade {{- end}} } `)) ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [lxd/master] Mips cast
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7390 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) === Hi guys, This PR fixes the remaining issues preventing LXD building on mips - build and run tested on amd64 also. Relevant: https://github.com/docker/docker-ce/commit/25d244c1db47dec23879b0928c366e34d5756a89 Although it builds, there are still some issues when remapping containers, so as-is this does not quite work From 041174437c3cfbee3855da10633f142ae0f0b2ae Mon Sep 17 00:00:00 2001 From: Joe Holden Date: Tue, 19 May 2020 18:11:38 + Subject: [PATCH 1/4] shared/util_linux.go: cast Rdev uint64 for mips Signed-off-by: Joe Holden --- shared/util_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/util_linux.go b/shared/util_linux.go index 47d35a0e30..b37792f7e9 100644 --- a/shared/util_linux.go +++ b/shared/util_linux.go @@ -30,8 +30,8 @@ func GetFileStat(p string) (uid int, gid int, major uint32, minor uint32, inode inode = uint64(stat.Ino) nlink = int(stat.Nlink) if stat.Mode&unix.S_IFBLK != 0 || stat.Mode&unix.S_IFCHR != 0 { - major = unix.Major(stat.Rdev) - minor = unix.Minor(stat.Rdev) + major = unix.Major(uint64(stat.Rdev)) + minor = unix.Minor(uint64(stat.Rdev)) } return From e17b282282d9a4e411efb2648c6fbce961e0d892 Mon Sep 17 00:00:00 2001 From: Joe Holden Date: Tue, 19 May 2020 18:17:40 + Subject: [PATCH 2/4] lxd/storage/quota/projectquota.go: cast Rdev uint64 for mips Signed-off-by: Joe Holden --- lxd/storage/quota/projectquota.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lxd/storage/quota/projectquota.go b/lxd/storage/quota/projectquota.go index c1b6b1ad1b..8db4b988c6 100644 --- a/lxd/storage/quota/projectquota.go +++ b/lxd/storage/quota/projectquota.go @@ -164,8 +164,8 @@ func devForPath(path string) (string, error) { return "", err } - devMajor := unix.Major(stat.Dev) - devMinor := unix.Minor(stat.Dev) + devMajor := unix.Major(uint64(stat.Dev)) + devMinor := unix.Minor(uint64(stat.Dev)) // Parse mountinfo for it mountinfo, err := os.Open("/proc/self/mountinfo") From 43b913776738a7f8d5e8033718259d079f086dea Mon Sep 17 00:00:00 2001 From: Joe Holden Date: Tue, 19 May 2020 18:26:49 + Subject: [PATCH 3/4] lxd/device/device_utils_unix.go: cast Rdev uint64 for mips Signed-off-by: Joe Holden --- lxd/device/device_utils_unix.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lxd/device/device_utils_unix.go b/lxd/device/device_utils_unix.go index 810e77dc99..dcde09495c 100644 --- a/lxd/device/device_utils_unix.go +++ b/lxd/device/device_utils_unix.go @@ -41,8 +41,8 @@ func unixDeviceAttributes(path string) (string, uint32, uint32, error) { } // Return the device information - major := unix.Major(stat.Rdev) - minor := unix.Minor(stat.Rdev) + major := unix.Major(uint64(stat.Rdev)) + minor := unix.Minor(uint64(stat.Rdev)) return dType, major, minor, nil } From 95d213e414aa945070072df2c6836fa99849e37c Mon Sep 17 00:00:00 2001 From: Joe Holden Date: Tue, 19 May 2020 18:27:53 + Subject: [PATCH 4/4] lxd/device/gpu.go: cast Rdev uint64 for mips Signed-off-by: Joe Holden --- lxd/device/gpu.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lxd/device/gpu.go b/lxd/device/gpu.go index 9bb4c39c71..3c111b9cac 100644 --- a/lxd/device/gpu.go +++ b/lxd/device/gpu.go @@ -263,8 +263,8 @@ func (d *gpu) getNvidiaNonCardDevices() ([]nvidiaNonCardDevice, error) { tmpNividiaGpu := nvidiaNonCardDevice{ path: nvidiaPath, - major: unix.Major(stat.Rdev), - minor: unix.Minor(stat.Rdev), + major: unix.Major(uint64(stat.Rdev)), + minor: unix.Minor(uint64(stat.Rdev)), } nvidiaDevices = append(nvidiaDevices, tmpNividiaGpu) ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [lxd/master] Make lxd-agent static
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7391 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) === From 7f4ad6aef20938900567faf1e504a9348d1852b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Tue, 19 May 2020 17:12:28 -0400 Subject: [PATCH 1/2] shared: Reimplement GetPollRevents without cgo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- shared/netutils/network_linux.go | 202 --- shared/netutils/network_linux_cgo.go | 210 shared/util_linux.go | 208 shared/util_linux_cgo.go | 231 --- 4 files changed, 418 insertions(+), 433 deletions(-) create mode 100644 shared/netutils/network_linux_cgo.go diff --git a/shared/netutils/network_linux.go b/shared/netutils/network_linux.go index 2f31ef70e6..c006e7f388 100644 --- a/shared/netutils/network_linux.go +++ b/shared/netutils/network_linux.go @@ -1,177 +1,16 @@ // +build linux -// +build cgo package netutils import ( - "fmt" "io" - "net" - "os" - "strings" - "unsafe" "github.com/gorilla/websocket" "github.com/lxc/lxd/shared" - "github.com/lxc/lxd/shared/api" "github.com/lxc/lxd/shared/logger" ) -/* -#include "unixfd.h" -#include "netns_getifaddrs.c" -*/ -import "C" - -// NetnsGetifaddrs returns a map of InstanceStateNetwork for a particular process. -func NetnsGetifaddrs(initPID int32) (map[string]api.InstanceStateNetwork, error) { - var netnsidAware C.bool - var ifaddrs *C.struct_netns_ifaddrs - var netnsID C.__s32 - - if initPID > 0 { - f, err := os.Open(fmt.Sprintf("/proc/%d/ns/net", initPID)) - if err != nil { - return nil, err - } - defer f.Close() - - netnsID = C.netns_get_nsid(C.__s32(f.Fd())) - if netnsID < 0 { - return nil, fmt.Errorf("Failed to retrieve network namespace id") - } - } else { - netnsID = -1 - } - - ret := C.netns_getifaddrs(&ifaddrs, netnsID, &netnsidAware) - if ret < 0 { - return nil, fmt.Errorf("Failed to retrieve network interfaces and addresses") - } - defer C.netns_freeifaddrs(ifaddrs) - - if netnsID >= 0 && !netnsidAware { - return nil, fmt.Errorf("Netlink requests are not fully network namespace id aware") - } - - // We're using the interface name as key here but we should really - // switch to the ifindex at some point to handle ip aliasing correctly. - networks := map[string]api.InstanceStateNetwork{} - - for addr := ifaddrs; addr != nil; addr = addr.ifa_next { - var address [C.INET6_ADDRSTRLEN]C.char - addNetwork, networkExists := networks[C.GoString(addr.ifa_name)] - if !networkExists { - addNetwork = api.InstanceStateNetwork{ - Addresses: []api.InstanceStateNetworkAddress{}, - Counters: api.InstanceStateNetworkCounters{}, - } - } - - // Interface flags - netState := "down" - netType := "unknown" - - if (addr.ifa_flags & C.IFF_BROADCAST) > 0 { - netType = "broadcast" - } - - if (addr.ifa_flags & C.IFF_LOOPBACK) > 0 { - netType = "loopback" - } - - if (addr.ifa_flags & C.IFF_POINTOPOINT) > 0 { - netType = "point-to-point" - } - - if (addr.ifa_flags & C.IFF_UP) > 0 { - netState = "up" - } - addNetwork.State = netState - addNetwork.Type = netType - addNetwork.Mtu = int(addr.ifa_mtu) - - if initPID != 0 && int(addr.ifa_ifindex_peer) > 0 { - hostInterface, err := net.InterfaceByIndex(int(addr.ifa_ifindex_peer)) - if err == nil { - addNetwork.HostName = hostInterface.Name - } - } - - // Addresses - if addr.ifa_addr != nil && (addr.ifa_addr.sa_family == C.AF_INET || addr.ifa_addr.sa_family == C.AF_INET6) { - family := "inet" - if addr.ifa_addr.sa_family == C.AF_INET6 { - family = "inet6" - } - - addrPtr := C.get_addr_ptr(addr.ifa_addr) -
[lxc-devel] [lxd/master] lxd/api: Don't strip double slashes
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7392 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) === Closes #7344 Signed-off-by: Stéphane Graber From e2dcbb6786f80643c8267d3897abaf2c4e9b77dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Tue, 19 May 2020 19:41:44 -0400 Subject: [PATCH] lxd/api: Don't strip double slashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #7344 Signed-off-by: Stéphane Graber --- lxd/api.go | 1 + 1 file changed, 1 insertion(+) diff --git a/lxd/api.go b/lxd/api.go index 70438ca6a5..0b95fe729a 100644 --- a/lxd/api.go +++ b/lxd/api.go @@ -20,6 +20,7 @@ func restServer(d *Daemon) *http.Server { /* Setup the web server */ mux := mux.NewRouter() mux.StrictSlash(false) + mux.SkipClean(true) mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [distrobuilder/master] shared/net: Fix checksum check regression
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/334 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) === From 63b7a886b031b61880b5bb0bc4ba538c4e1782da Mon Sep 17 00:00:00 2001 From: Thomas Hipp Date: Wed, 20 May 2020 08:47:03 +0200 Subject: [PATCH] shared/net: Fix checksum check regression Signed-off-by: Thomas Hipp --- shared/net.go | 31 ++- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/shared/net.go b/shared/net.go index 8ac9081..2c8be8e 100644 --- a/shared/net.go +++ b/shared/net.go @@ -21,7 +21,6 @@ func DownloadHash(def DefinitionImage, file, checksum string, hashFunc hash.Hash var ( client http.Client hashes []string - hash string errerror ) targetDir := GetTargetDir(def) @@ -69,6 +68,8 @@ func DownloadHash(def DefinitionImage, file, checksum string, hashFunc hash.Hash result := fmt.Sprintf("%x", hashFunc.Sum(nil)) + var hash string + for _, h := range hashes { if result == h { hash = h @@ -94,15 +95,27 @@ func DownloadHash(def DefinitionImage, file, checksum string, hashFunc hash.Hash fmt.Printf("%s\r", progress.Text) } - if hashFunc != nil { - hashFunc.Reset() - } - _, err = lxd.DownloadFileHash(&client, "", progress, nil, imagePath, file, hash, hashFunc, image) - if err != nil { - if checksum == "" && strings.HasPrefix(err.Error(), "Hash mismatch") { - return targetDir, nil + if checksum == "" { + _, err = lxd.DownloadFileHash(&client, "", progress, nil, imagePath, file, "", nil, image) + if err != nil && !strings.HasPrefix(err.Error(), "Hash mismatch") { + return "", err + } + } else { + // Check all file hashes in case multiple have been provided. + for _, h := range hashes { + if hashFunc != nil { + hashFunc.Reset() + } + + _, err = lxd.DownloadFileHash(&client, "", progress, nil, imagePath, file, h, hashFunc, image) + if err == nil { + break + } + } + + if err != nil { + return "", err } - return "", err } fmt.Println("") ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel