lib/vagrant-libvirt/templates/domain.xml.erb in vagrant-libvirt-0.3.0 vs lib/vagrant-libvirt/templates/domain.xml.erb in vagrant-libvirt-0.4.0

- old
+ new

@@ -102,27 +102,40 @@ <<%= feature[:name] %> state='<%= feature[:state] %>' /> <% end %> </hyperv> <% end %> </features> - <clock offset='utc'/> + <clock offset='<%= @clock_offset %>'> + <% @clock_timers.each do |clock_timer| %> + <timer<% clock_timer.each do |attr, value| %> <%= attr %>='<%= value %>'<% end %>/> + <% end %> + </clock> <devices> <% if @emulator_path %> <emulator><%= @emulator_path %></emulator> <% end %> <% if @domain_volume_path %> <disk type='file' device='disk'> - <driver name='qemu' type='qcow2' cache='<%= @domain_volume_cache %>'/> + <driver name='qemu' type='qcow2' <%= + @disk_driver_opts.empty? ? "cache='#{@domain_volume_cache}'" : + @disk_driver_opts.reject { |k,v| v.nil? } + .map { |k,v| "#{k}='#{v}'"} + .join(' ') -%>/> <source file='<%= @domain_volume_path %>'/> <%# we need to ensure a unique target dev -%> <target dev='<%= @disk_device %>' bus='<%= @disk_bus %>'/> </disk> <% end %> <%# additional disks -%> <% @disks.each do |d| -%> <disk type='file' device='disk'> - <driver name='qemu' type='<%= d[:type] %>' cache='<%= d[:cache] %>'/> + <driver name='qemu' type='<%= d[:type] %>' <%= + d.select { |k,_| [:cache, :io, :copy_on_read, :discard, :detect_zeroes].include? k } + .reject { |k,v| v.nil? } + .map { |k,v| "#{k}='#{v}'"} + .join(' ') + -%>/> <source file='<%= d[:absolute_path] %>'/> <target dev='<%= d[:device] %>' bus='<%= d[:bus] %>'/> <% if d[:shareable] %> <shareable/> <% end %> @@ -255,20 +268,31 @@ <smartcard mode='<%= @smartcard_dev[:mode] %>' type='<%= @smartcard_dev[:type] %>'/> <% end %> <% end %> <% end -%> - <% if @tpm_path -%> + <% if @tpm_path || @tpm_version -%> <%# TPM Device -%> <tpm model='<%= @tpm_model %>'> - <backend type='<%= @tpm_type %>'> + <backend type='<%= @tpm_type %>'<% if @tpm_version %> version='<%= @tpm_version %>'<% end %>> + <% if @tpm_path -%> <device path='<%= @tpm_path %>'/> + <% end -%> </backend> </tpm> <% end -%> <% if not @usbctl_dev.empty? %> <%# USB Controller -%> <controller type='usb' model='<%= @usbctl_dev[:model] %>' <%= "ports=\"#{@usbctl_dev[:ports]}\" " if @usbctl_dev[:ports] %>/> + <% end %> + <% unless @memballoon_enabled.nil? %> + <% if @memballoon_enabled %> + <memballoon model='<%= @memballoon_model %>'> + <address type='pci' domain='0x0000' bus='<%= @memballoon_pci_bus %>' slot='<%= @memballoon_pci_slot %>' function='0x0'/> + </memballoon> + <% else %> + <memballoon model='none'/> + <% end %> <% end %> </devices> <% if not @qemu_args.empty? or not @qemu_env.empty? %> <qemu:commandline>