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
c161f9ad
Commit
c161f9ad
authored
Oct 27, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1558 from vtolstov/qemu_cache
builder/qemu: add ability to set cache mode for disk
parents
d8754194
8efc8ec9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
builder/qemu/builder.go
builder/qemu/builder.go
+18
-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
+4
-0
No files found.
builder/qemu/builder.go
View file @
c161f9ad
...
...
@@ -56,6 +56,14 @@ var diskInterface = map[string]bool{
"virtio"
:
true
,
}
var
diskCache
=
map
[
string
]
bool
{
"writethrough"
:
true
,
"writeback"
:
true
,
"none"
:
true
,
"unsafe"
:
true
,
"directsync"
:
true
,
}
type
Builder
struct
{
config
config
runner
multistep
.
Runner
...
...
@@ -68,6 +76,7 @@ type config struct {
BootCommand
[]
string
`mapstructure:"boot_command"`
DiskInterface
string
`mapstructure:"disk_interface"`
DiskSize
uint
`mapstructure:"disk_size"`
DiskCache
string
`mapstructure:"disk_cache`
FloppyFiles
[]
string
`mapstructure:"floppy_files"`
Format
string
`mapstructure:"format"`
Headless
bool
`mapstructure:"headless"`
...
...
@@ -126,6 +135,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
b
.
config
.
DiskSize
=
40000
}
if
b
.
config
.
DiskCache
==
""
{
b
.
config
.
DiskCache
=
"writeback"
}
if
b
.
config
.
Accelerator
==
""
{
b
.
config
.
Accelerator
=
"kvm"
}
...
...
@@ -280,6 +293,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs
,
errors
.
New
(
"unrecognized disk interface type"
))
}
if
_
,
ok
:=
diskCache
[
b
.
config
.
DiskCache
];
!
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 @
c161f9ad
...
...
@@ -81,7 +81,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
"
,
imgPath
,
config
.
DiskInterfac
e
)
defaultArgs
[
"-drive"
]
=
fmt
.
Sprintf
(
"file=%s,if=%s
,cache=%s"
,
imgPath
,
config
.
DiskInterface
,
config
.
DiskCach
e
)
defaultArgs
[
"-cdrom"
]
=
isoPath
defaultArgs
[
"-boot"
]
=
bootDrive
defaultArgs
[
"-m"
]
=
"512M"
...
...
website/source/docs/builders/qemu.html.markdown
View file @
c161f9ad
...
...
@@ -119,6 +119,10 @@ each category, the available options are alphabetized and described.
commands or kickstart type scripts must have proper adjustments for
resulting device names. The Qemu builder uses "virtio" by default.
*
`disk_cache`
(string) - The cache mode to use for disk. Allowed values
values include any of "writethrough", "writeback", "none", "unsafe" or
"directsync".
*
`floppy_files`
(array of strings) - A list of files to place onto a floppy
disk that is attached when the VM is booted. This is most useful
for unattended Windows installs, which look for an
`Autounattend.xml`
file
...
...
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