Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
77af5f83
Commit
77af5f83
authored
May 27, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2120 from vtolstov/discard
add discard option to qemu builder
parents
44008c32
3984f5e6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
builder/qemu/builder.go
builder/qemu/builder.go
+15
-0
builder/qemu/step_run.go
builder/qemu/step_run.go
+1
-1
website/source/docs/builders/qemu.html.markdown
website/source/docs/builders/qemu.html.markdown
+3
-0
No files found.
builder/qemu/builder.go
View file @
77af5f83
...
...
@@ -66,6 +66,11 @@ var diskCache = map[string]bool{
"directsync"
:
true
,
}
var
diskDiscard
=
map
[
string
]
bool
{
"unmap"
:
true
,
"ignore"
:
true
,
}
type
Builder
struct
{
config
Config
runner
multistep
.
Runner
...
...
@@ -79,6 +84,7 @@ type Config struct {
DiskInterface
string
`mapstructure:"disk_interface"`
DiskSize
uint
`mapstructure:"disk_size"`
DiskCache
string
`mapstructure:"disk_cache"`
DiskDiscard
string
`mapstructure:"disk_discard"`
FloppyFiles
[]
string
`mapstructure:"floppy_files"`
Format
string
`mapstructure:"format"`
Headless
bool
`mapstructure:"headless"`
...
...
@@ -144,6 +150,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
b
.
config
.
DiskCache
=
"writeback"
}
if
b
.
config
.
DiskDiscard
==
""
{
b
.
config
.
DiskDiscard
=
"ignore"
}
if
b
.
config
.
Accelerator
==
""
{
b
.
config
.
Accelerator
=
"kvm"
}
...
...
@@ -237,6 +247,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs
,
errors
.
New
(
"unrecognized disk cache type"
))
}
if
_
,
ok
:=
diskDiscard
[
b
.
config
.
DiskDiscard
];
!
ok
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"unrecognized disk cache type"
))
}
if
b
.
config
.
HTTPPortMin
>
b
.
config
.
HTTPPortMax
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"http_port_min must be less than http_port_max"
))
...
...
builder/qemu/step_run.go
View file @
77af5f83
...
...
@@ -82,7 +82,7 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error
defaultArgs
[
"-machine"
]
=
fmt
.
Sprintf
(
"type=%s"
,
config
.
MachineType
)
defaultArgs
[
"-netdev"
]
=
fmt
.
Sprintf
(
"user,id=user.0,hostfwd=tcp::%v-:22"
,
sshHostPort
)
defaultArgs
[
"-device"
]
=
fmt
.
Sprintf
(
"%s,netdev=user.0"
,
config
.
NetDevice
)
defaultArgs
[
"-drive"
]
=
fmt
.
Sprintf
(
"file=%s,if=%s,cache=%s
"
,
imgPath
,
config
.
DiskInterface
,
config
.
DiskCache
)
defaultArgs
[
"-drive"
]
=
fmt
.
Sprintf
(
"file=%s,if=%s,cache=%s
,discard=%s"
,
imgPath
,
config
.
DiskInterface
,
config
.
DiskCache
,
config
.
DiskDiscard
)
if
!
config
.
DiskImage
{
defaultArgs
[
"-cdrom"
]
=
isoPath
}
...
...
website/source/docs/builders/qemu.html.markdown
View file @
77af5f83
...
...
@@ -115,6 +115,9 @@ each category, the available options are alphabetized and described.
values include any of "writethrough", "writeback", "none", "unsafe" or
"directsync".
*
`disk_discard`
(string) - The discard mode to use for disk. Allowed values
include any of "unmap" or "ignore".
*
`disk_image`
(boolean) - Packer defaults to building from an ISO file,
this parameter controls whether the ISO URL supplied is actually a bootable
QEMU image. When this value is set to true, the machine will clone the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment