Use CDROM optical drive devices for virtual machines in OpenStack

Source: Internet
Author: User

      • Catch fish in the libvirt.
      • Stove in Nova.
      • Actual effect
      • How to Uninstall

Catch fish in the libvirt.

There are several ways to load a disc file for a virtual machine, as follows:

1. Mount using the IDE mode:

virshattach-disk{instance_name}{iso_path}hda--sourcetypeblock--driverqemu--subdriverraw  --typecdrom

The XML format is as follows:

<disk type=‘block‘ device=‘cdrom‘>  <driver name=‘qemu‘ type=‘raw‘/>  <source dev=‘{iso_path}‘/>  <target dev=‘hda‘/></disk>

2. Mount using SCSI mode:

virshattach-disk{instance_name}{iso_path}sda--sourcetypeblock--driverqemu--subdriverraw  --typecdrom

The XML format is as follows:

<disk  type  = ' block '   device  = ' cdrom ' ;  <driver  name  =< Span class= "Hljs-value" > ' qemu '  type  = ' raw ' />  <source  dev  = '/var/lib/nova/instances/ Virtio-win-0.1-100.iso ' />  <target  Span class= "Hljs-attribute" >dev  = ' SDA ' />  disk ;   

The difference between the two methods is the device driver type, mounted using HDX drive letter, the attached device will default to the IDE device, and using the SDX Drive letter Mount, it will be considered a SCSI device by default.

Because some windows mirrors are missing a SCSI drive that does not recognize an optical drive device that is mounted using the SDX drive letter, the HDX disk is selected to mount the optical drive device.

Then the IDE has the same problem, the IDE device does not support hot plug:

virsh attach-disk {instance_name} {iso_path} hdaerror: Failed to attach diskerrornot‘ide‘ cannot be hotplugged.

It is found that if you write an empty source_path to this optical drive device, it will not be considered a pull action if it is mounted to replace the Source_path value.

{instance_name}Target     Source------------------------------------------------vda        {volume_path}vdb        {volume_path}hdb        {instance_name}{iso_path} hdb --sourcetype block  --driver qemu --subdriver raw  --type cdromDisk{instance_name}Target     Source------------------------------------------------vda        {volume_path}vdb        {volume_path}hdb        {iso_path}
Stove in Nova.

What to do in Nova is to add an optical drive device to the virtual machine and give the CD-ROM device an empty default path. The XML processing of the virtual machine disk device is done in nova.virt.libvirt.driver.py.

The XML class for the disk device is the Libvirtconfigguestdisk class in nova.virt.libvirt.config.py, which can create a new instance based on its properties.

A decision condition is added here to more flexibly control whether the device is turned on, based on the Hw_set_cdrom attribute in the flavor extra_specs.

Add the following code to the Get_guest_storage_config function in nova.virt.libvirt.driver.py (note that the drive letter must be HDA):

                 forVol.inchBlock_device_mapping:connection_info = vol[' Connection_info '] Vol_dev = Block_device.prepend_dev (vol[' Mount_device ']) info = disk_mapping[vol_dev] cfg = Self.volume_driver_method (' Connect_volume ', Connection_info, I NFO) devices.append (CFG)# new Code begin                ifInst_type[' Extra_specs '].get (' Hw_set_cdrom ', False): Log.info ("* * Setting CDROM * *")CD_cfg = Vconfig. Libvirtconfigguestdisk ()CD_cfg.driver_name =' Qemu '                    CD_cfg.source_device =' cdrom '                    CD_cfg.driver_format =' Raw '                    CD_cfg.driver_cache =' None '                    CD_cfg.target_bus =' IDE '                    CD_cfg.target_dev =' HDA '                    CD_cfg.root_name =' Disk '                    CD_cfg.source_type=' Block '                    CD_cfg.source_path ="'Devices.append (CD_CFG)# new Code End
Actual effect

Mount Operation Needless to say, the method of various ...

Look at the effect

Before Mount:

Windows 2003:

Windows 2008:

When mounted:

Windows 2003:



Windows 2008:


Linux:

How to Uninstall

To update the optical drive an empty Source_path is available:

{instance_name}Target     Source------------------------------------------------vda        {volume_path}vdb        {volume_path}hda        {iso_path}{instance_name}"" hda --sourcetype block  --driver qemu --subdriver raw  --type cdromDisk{instance_name}Target     Source------------------------------------------------vda        {volume_path}vdb        {volume_path}hda        -

Another address: http://pages.turtleend.info/2015/06/11/openstack-use-cdrom-device.html

Use CDROM optical drive devices for virtual machines in OpenStack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.