Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Secure solution for nexus infrastructure
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flg_masters
TM
Secure solution for nexus infrastructure
Commits
83114af2
Commit
83114af2
authored
2 years ago
by
Florent Gluck
Browse files
Options
Downloads
Patches
Plain Diff
Files exported from a VMs are now exported as a compressed archive (.tar.gz) instead of .tar
parent
d98f5639
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/exec/Guestfish.go
+2
-2
2 additions, 2 deletions
src/exec/Guestfish.go
src/router/routerVMs.go
+2
-2
2 additions, 2 deletions
src/router/routerVMs.go
src/version/version.go
+1
-1
1 addition, 1 deletion
src/version/version.go
src/vms/vms.go
+3
-3
3 additions, 3 deletions
src/vms/vms.go
with
8 additions
and
8 deletions
src/exec/Guestfish.go
+
2
−
2
View file @
83114af2
...
...
@@ -43,9 +43,9 @@ func CopyToVM(vmDiskFile, tarFile, vmDir string) error {
return
nil
}
// Recursively copies a directory in the VM's filesystem (vmDir) into a
tar
archive.
// Recursively copies a directory in the VM's filesystem (vmDir) into a
compressed
archive.
func
CopyFromVM
(
vmDiskFile
,
vmDir
,
tarFile
string
)
error
{
cmd
:=
exec
.
Command
(
guestfishBinary
,
"--ro"
,
"-i"
,
"tar-out"
,
"-a"
,
vmDiskFile
,
vmDir
,
tarFile
)
cmd
:=
exec
.
Command
(
guestfishBinary
,
"--ro"
,
"-i"
,
"tar-out"
,
"-a"
,
vmDiskFile
,
vmDir
,
tarFile
,
"compress:gzip"
)
stdoutStderr
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
output
:=
fmt
.
Sprintf
(
"[%s]"
,
stdoutStderr
)
...
...
This diff is collapsed.
Click to expand it.
src/router/routerVMs.go
+
2
−
2
View file @
83114af2
...
...
@@ -378,7 +378,7 @@ func (r *RouterVMs)DeleteVMAccessForUser(c echo.Context) error {
return
c
.
JSONPretty
(
http
.
StatusOK
,
jsonMsg
(
"OK"
),
" "
)
}
// Exports a VM's directory into a
.tar
archive.
// Exports a VM's directory into a
compressed
archive.
// Requires either capability:
// User cap: VM_READFS_ANY: any VM can have their filesystem read.
// VM access cap: VM_READFS: any of the VMs with this cap for the logged user can have their filesystem read.
...
...
@@ -396,7 +396,7 @@ func (r *RouterVMs)ExportVMDir(c echo.Context) error {
// Creates a unique tar filename.
tmpDir
:=
paths
.
GetInstance
()
.
TmpDir
tarFile
:=
filepath
.
Join
(
tmpDir
,
"exportdir_"
+
vm
.
ID
.
String
()
+
".tar"
)
tarFile
:=
filepath
.
Join
(
tmpDir
,
"exportdir_"
+
vm
.
ID
.
String
()
+
".tar
.gz
"
)
// Extracts VM's p.Dir directory into tarFile on the host.
if
err
:=
r
.
vms
.
ExportVMFiles
(
vm
,
p
.
Dir
,
tarFile
);
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
src/version/version.go
+
1
−
1
View file @
83114af2
...
...
@@ -7,7 +7,7 @@ import (
const
(
major
=
1
minor
=
2
bugfix
=
0
bugfix
=
1
)
type
Version
struct
{
...
...
This diff is collapsed.
Click to expand it.
src/vms/vms.go
+
3
−
3
View file @
83114af2
...
...
@@ -389,14 +389,14 @@ func (vms *VMs)DeleteVMAccess(vmID uuid.UUID, loggedUserEmail, userEmail string)
return
nil
}
// Exports a VM's directory and its subdirectories into a
tar
archive on the host.
// Exports a VM's directory and its subdirectories into a
compressed
archive on the host.
func
(
vms
*
VMs
)
ExportVMFiles
(
vm
*
VM
,
vmDir
,
tarFile
string
)
error
{
vmDisk
:=
vm
.
getDiskPath
()
return
exec
.
CopyFromVM
(
vmDisk
,
vmDir
,
tarFile
)
}
// Import files into a VM's filesystem, in a specified directory.
func
(
vms
*
VMs
)
ImportFilesToVM
(
vm
*
VM
,
hostDir
,
vmDir
string
)
error
{
func
(
vms
*
VMs
)
ImportFilesToVM
(
vm
*
VM
,
tarFile
,
vmDir
string
)
error
{
// Marks the VM to copy from as being busy.
if
err
:=
vms
.
setDiskBusy
(
vm
);
err
!=
nil
{
return
errors
.
New
(
"Failed setting disk busy flag during VM files import: "
+
err
.
Error
())
...
...
@@ -405,7 +405,7 @@ func (vms *VMs)ImportFilesToVM(vm *VM, hostDir, vmDir string) error {
defer
vms
.
clearDiskBusy
(
vm
)
vmDisk
:=
vm
.
getDiskPath
()
return
exec
.
CopyToVM
(
vmDisk
,
hostDir
,
vmDir
)
return
exec
.
CopyToVM
(
vmDisk
,
tarFile
,
vmDir
)
}
// Marks a VM as "busy", meaning its disk file is being accessed for a possibly long time.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment