[lxc-devel] [lxd/master] Properly handle xattrs
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Aug 1 19:54:02 UTC 2018
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/20180801/04957c32/attachment.bin>
-------------- next part --------------
From 9230ec91b438535f15cd8b1259579070f74bdad3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 15:50:36 -0400
Subject: [PATCH 1/2] tar: Support xattrs
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>
---
lxc/image.go | 2 +-
lxd/storage_btrfs.go | 6 +++---
lxd/storage_ceph.go | 6 +++---
lxd/storage_dir.go | 6 +++---
lxd/storage_lvm.go | 6 +++---
lxd/storage_zfs.go | 6 +++---
shared/archive_linux.go | 2 +-
7 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/lxc/image.go b/lxc/image.go
index f54460612f..4e9afa5f6a 100644
--- a/lxc/image.go
+++ b/lxc/image.go
@@ -595,7 +595,7 @@ func (c *cmdImageImport) packImageDir(path string) (string, error) {
defer outFile.Close()
outFileName := outFile.Name()
- shared.RunCommand("tar", "-C", path, "--numeric-owner", "-cJf", outFileName, "rootfs", "templates", "metadata.yaml")
+ shared.RunCommand("tar", "-C", path, "--numeric-owner", "--xattrs", "-cJf", outFileName, "rootfs", "templates", "metadata.yaml")
return outFileName, nil
}
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index 17f6038bbb..8fdacc0717 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -1757,7 +1757,7 @@ func (s *storageBtrfs) ContainerBackupDump(backup backup) ([]byte, error) {
backupMntPoint := getBackupMountPoint(s.pool.Name, backup.Name())
logger.Debugf("Taring up \"%s\" on storage pool \"%s\"", backupMntPoint, s.pool.Name)
- args := []string{"-cJf", "-", "-C", backupMntPoint, "--transform", "s,^./,backup/,"}
+ args := []string{"-cJf", "--xattrs", "-", "-C", backupMntPoint, "--transform", "s,^./,backup/,"}
if backup.ContainerOnly() {
// Exclude snapshots directory
args = append(args, "--exclude", fmt.Sprintf("%s/snapshots", backup.Name()))
@@ -1880,7 +1880,7 @@ func (s *storageBtrfs) doContainerBackupLoadVanilla(info backupInfo, data io.Rea
cur := fmt.Sprintf("backup/snapshots/%s", snap)
data.Seek(0, 0)
err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-",
- "--recursive-unlink", "--strip-components=3", "-C", containerMntPoint, cur)
+ "--recursive-unlink", "--xattrs", "--strip-components=3", "-C", containerMntPoint, cur)
if err != nil {
logger.Errorf("Failed to untar \"%s\" into \"%s\": %s", cur, containerMntPoint, err)
return err
@@ -1896,7 +1896,7 @@ func (s *storageBtrfs) doContainerBackupLoadVanilla(info backupInfo, data io.Rea
// Extract container
data.Seek(0, 0)
err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-",
- "--strip-components=2", "-C", containerMntPoint, "backup/container")
+ "--strip-components=2", "--xattrs", "-C", containerMntPoint, "backup/container")
if err != nil {
logger.Errorf("Failed to untar \"backup/container\" into \"%s\": %s", containerMntPoint, err)
return err
diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index 27d7ea6979..537c066f4e 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -1957,7 +1957,7 @@ func (s *storageCeph) ContainerBackupDump(backup backup) ([]byte, error) {
backupMntPoint := getBackupMountPoint(s.pool.Name, backup.Name())
logger.Debugf("Taring up \"%s\" on storage pool \"%s\"", backupMntPoint, s.pool.Name)
- args := []string{"-cJf", "-", "-C", backupMntPoint, "--transform", "s,^./,backup/,"}
+ args := []string{"-cJf", "--xattrs", "-", "-C", backupMntPoint, "--transform", "s,^./,backup/,"}
if backup.ContainerOnly() {
// Exclude snapshots directory
args = append(args, "--exclude", fmt.Sprintf("%s/snapshots", backup.Name()))
@@ -2001,7 +2001,7 @@ func (s *storageCeph) ContainerBackupLoad(info backupInfo, data io.ReadSeeker) e
data.Seek(0, 0)
err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-",
- "--recursive-unlink", "--strip-components=3", "-C", containerMntPoint, cur)
+ "--recursive-unlink", "--strip-components=3", "--xattrs", "-C", containerMntPoint, cur)
if err != nil {
logger.Errorf("Failed to untar \"%s\" into \"%s\": %s", cur, containerMntPoint, err)
return err
@@ -2030,7 +2030,7 @@ func (s *storageCeph) ContainerBackupLoad(info backupInfo, data io.ReadSeeker) e
// Extract container
data.Seek(0, 0)
err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-",
- "--strip-components=2", "-C", containerMntPoint, "backup/container")
+ "--strip-components=2", "--xattrs", "-C", containerMntPoint, "backup/container")
if err != nil {
logger.Errorf("Failed to untar \"backup/container\" into \"%s\": %s", containerMntPoint, err)
return err
diff --git a/lxd/storage_dir.go b/lxd/storage_dir.go
index 4462c39e9d..6c94947d66 100644
--- a/lxd/storage_dir.go
+++ b/lxd/storage_dir.go
@@ -1240,7 +1240,7 @@ func (s *storageDir) ContainerBackupDump(backup backup) ([]byte, error) {
backupMntPoint := getBackupMountPoint(s.pool.Name, backup.Name())
- args := []string{"-cJf", "-", "-C", backupMntPoint, "--transform", "s,^./,backup/,"}
+ args := []string{"-cJf", "--xattrs", "-", "-C", backupMntPoint, "--transform", "s,^./,backup/,"}
if backup.ContainerOnly() {
// Exclude snapshots directory
args = append(args, "--exclude", fmt.Sprintf("%s/snapshots", backup.Name()))
@@ -1278,7 +1278,7 @@ func (s *storageDir) ContainerBackupLoad(info backupInfo, data io.ReadSeeker) er
// Extract container
data.Seek(0, 0)
err = shared.RunCommandWithFds(data, nil, "tar", "-xJf",
- "-", "--strip-components=2", "-C", containerMntPoint, "backup/container")
+ "-", "--strip-components=2", "--xattrs", "-C", containerMntPoint, "backup/container")
if err != nil {
return err
}
@@ -1298,7 +1298,7 @@ func (s *storageDir) ContainerBackupLoad(info backupInfo, data io.ReadSeeker) er
// Extract snapshots
data.Seek(0, 0)
err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-",
- "--strip-components=2", "-C", snapshotMntPoint, "backup/snapshots")
+ "--strip-components=2", "--xattrs", "-C", snapshotMntPoint, "backup/snapshots")
if err != nil {
return err
}
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 6d6f51180c..6e8a28c9f0 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -1829,7 +1829,7 @@ func (s *storageLvm) ContainerBackupRename(backup backup, newName string) error
func (s *storageLvm) ContainerBackupDump(backup backup) ([]byte, error) {
var buffer bytes.Buffer
- args := []string{"-cJf", "-", "-C", getBackupMountPoint(s.pool.Name, backup.Name()),
+ args := []string{"-cJf", "--xattrs", "-", "-C", getBackupMountPoint(s.pool.Name, backup.Name()),
"--transform", "s,^./,backup/,"}
if backup.ContainerOnly() {
// Exclude snapshots directory
@@ -1854,7 +1854,7 @@ func (s *storageLvm) ContainerBackupLoad(info backupInfo, data io.ReadSeeker) er
// Extract container
data.Seek(0, 0)
- err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-", "--strip-components=2",
+ err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-", "--strip-components=2", "--xattrs",
"-C", containerPath, "backup/container")
if err != nil {
return err
@@ -1870,7 +1870,7 @@ func (s *storageLvm) ContainerBackupLoad(info backupInfo, data io.ReadSeeker) er
// Extract snapshots
data.Seek(0, 0)
err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-",
- "--strip-components=3", "-C", containerPath, fmt.Sprintf("backup/snapshots/%s", snap))
+ "--strip-components=3", "--xattrs", "-C", containerPath, fmt.Sprintf("backup/snapshots/%s", snap))
if err != nil {
return err
}
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 0d0edbd464..8bd5dedbb3 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -2086,7 +2086,7 @@ func (s *storageZfs) ContainerBackupDump(backup backup) ([]byte, error) {
backupMntPoint := getBackupMountPoint(s.pool.Name, backup.Name())
logger.Debugf("Taring up \"%s\" on storage pool \"%s\"", backupMntPoint, s.pool.Name)
- args := []string{"-cJf", "-", "-C", backupMntPoint, "--transform", "s,^./,backup/,"}
+ args := []string{"-cJf", "--xattrs", "-", "-C", backupMntPoint, "--transform", "s,^./,backup/,"}
if backup.ContainerOnly() {
// Exclude snapshots directory
args = append(args, "--exclude", fmt.Sprintf("%s/snapshots", backup.Name()))
@@ -2227,7 +2227,7 @@ func (s *storageZfs) doContainerBackupLoadVanilla(info backupInfo, data io.ReadS
data.Seek(0, 0)
err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-",
- "--recursive-unlink", "--strip-components=3", "-C", containerMntPoint, cur)
+ "--recursive-unlink", "--strip-components=3", "--xattrs", "-C", containerMntPoint, cur)
if err != nil {
logger.Errorf("Failed to untar \"%s\" into \"%s\": %s", cur, containerMntPoint, err)
return err
@@ -2243,7 +2243,7 @@ func (s *storageZfs) doContainerBackupLoadVanilla(info backupInfo, data io.ReadS
// Extract container
data.Seek(0, 0)
err = shared.RunCommandWithFds(data, nil, "tar", "-xJf", "-",
- "--strip-components=2", "-C", containerMntPoint, "backup/container")
+ "--strip-components=2", "--xattrs", "-C", containerMntPoint, "backup/container")
if err != nil {
logger.Errorf("Failed to untar \"backup/container\" into \"%s\": %s", containerMntPoint, err)
return err
diff --git a/shared/archive_linux.go b/shared/archive_linux.go
index 6656d18e67..37f27ab760 100644
--- a/shared/archive_linux.go
+++ b/shared/archive_linux.go
@@ -67,7 +67,7 @@ func Unpack(file string, path string, blockBackend bool, runningInUserns bool) e
args = append(args, "--exclude=rootfs/dev/*")
args = append(args, "--exclude=rootfs/./dev/*")
}
- args = append(args, "-C", path, "--numeric-owner")
+ args = append(args, "-C", path, "--numeric-owner", "--xattrs")
args = append(args, extractArgs...)
args = append(args, file)
} else if strings.HasPrefix(extension, ".squashfs") {
From 17b39b63f5e974b85b67475e80cae6cf9fa7afe6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 1 Aug 2018 15:52:50 -0400
Subject: [PATCH 2/2] rsync: Support xattrs
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>
---
lxc-to-lxd/transfer.go | 1 +
lxd-p2c/transfer.go | 1 +
lxd/rsync.go | 3 +++
3 files changed, 5 insertions(+)
diff --git a/lxc-to-lxd/transfer.go b/lxc-to-lxd/transfer.go
index c190d4d059..c0390321e9 100644
--- a/lxc-to-lxd/transfer.go
+++ b/lxc-to-lxd/transfer.go
@@ -73,6 +73,7 @@ func rsyncSendSetup(path string, rsyncArgs string) (*exec.Cmd, net.Conn, io.Read
"--numeric-ids",
"--partial",
"--sparse",
+ "--xattrs",
}
// Ignore deletions (requires 3.1 or higher)
diff --git a/lxd-p2c/transfer.go b/lxd-p2c/transfer.go
index 40e0d662ea..d145eccf6e 100644
--- a/lxd-p2c/transfer.go
+++ b/lxd-p2c/transfer.go
@@ -73,6 +73,7 @@ func rsyncSendSetup(path string, rsyncArgs string) (*exec.Cmd, net.Conn, io.Read
"--numeric-ids",
"--partial",
"--sparse",
+ "--xattrs",
}
// Ignore deletions (requires 3.1 or higher)
diff --git a/lxd/rsync.go b/lxd/rsync.go
index 2f7d43f46e..5f300312e5 100644
--- a/lxd/rsync.go
+++ b/lxd/rsync.go
@@ -40,6 +40,7 @@ func rsyncLocalCopy(source string, dest string, bwlimit string) (string, error)
"--delete",
"--checksum",
"--numeric-ids",
+ "--xattrs",
"--bwlimit", bwlimit,
rsyncVerbosity,
shared.AddSlash(source),
@@ -109,6 +110,7 @@ func rsyncSendSetup(name string, path string, bwlimit string, execPath string) (
"--numeric-ids",
"--partial",
"--sparse",
+ "--xattrs",
path,
"localhost:/tmp/foo",
"-e",
@@ -184,6 +186,7 @@ func RsyncRecv(path string, conn *websocket.Conn, writeWrapper func(io.WriteClos
"--devices",
"--partial",
"--sparse",
+ "--xattrs",
".",
path)
More information about the lxc-devel
mailing list