diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb
index 1b1bde2..7cb988b 100644
--- a/lib/vagrant-libvirt/action/create_domain.rb
+++ b/lib/vagrant-libvirt/action/create_domain.rb
@@ -52,6 +52,7 @@ module VagrantPlugins
# Storage
@storage_pool_name = config.storage_pool_name
@disks = config.disks
+ @cdrom = config.cdrom
config = env[:machine].provider_config
@domain_type = config.driver
@@ -121,6 +122,7 @@ module VagrantPlugins
@disks.each do |disk|
env[:ui].info(" -- Disk(#{disk[:device]}): #{disk[:absolute_path]}")
end
+ env[:ui].info(" -- CDROM: #{@cdrom}")
env[:ui].info(" -- Command line : #{@cmd_line}")
# Create libvirt domain.
diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb
index a27921b..d7cf921 100644
--- a/lib/vagrant-libvirt/config.rb
+++ b/lib/vagrant-libvirt/config.rb
@@ -74,6 +74,7 @@ module VagrantPlugins
# Storage
attr_accessor :disks
+ attr_accessor :cdrom
def initialize
@uri = UNSET_VALUE
@@ -112,6 +113,7 @@ module VagrantPlugins
# Storage
@disks = []
+ @cdrom = UNSET_VALUE
end
def _get_device(disks)
@@ -129,6 +131,40 @@ module VagrantPlugins
# NOTE: this will run twice for each time it's needed- keep it idempotent
def storage(storage_type, options={})
+ if storage_type == :file
+ _handle_file_storage(options)
+ end
+ end
+
+ def _handle_file_storage(options={})
+ if options[:device] == :cdrom
+ _handle_cdrom_storage(options)
+ else
+ _handle_disk_storage(options)
+ end
+ end
+
+ def _handle_cdrom_storage(options={})
+ #
+ #
+ #
+ #
+ #
+
+ options = {
+ :dev => "hdc",
+ :bus => "ide",
+ :path => nil,
+ }.merge(options)
+
+ @cdrom = {
+ :dev => options[:dev],
+ :bus => options[:bus],
+ :path => options[:path]
+ }
+ end
+
+ def _handle_disk_storage(options={})
options = {
:device => _get_device(@disks),
:type => 'qcow2',
@@ -146,9 +182,7 @@ module VagrantPlugins
:cache => options[:cache] || 'default',
}
- if storage_type == :file
- @disks << disk # append
- end
+ @disks << disk # append
end
# code to generate URI from a config moved out of the connect action
@@ -242,6 +276,7 @@ module VagrantPlugins
# Storage
@disks = [] if @disks == UNSET_VALUE
+ @cdrom = nil if @cdrom == UNSET_VALUE
end
def validate(machine)
diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb
index eebb8e2..33e6762 100644
--- a/lib/vagrant-libvirt/templates/domain.xml.erb
+++ b/lib/vagrant-libvirt/templates/domain.xml.erb
@@ -48,6 +48,15 @@
-%>
<% end -%>
+
+<% if @cdrom %>
+
+
+
+
+
+<% end %>
+