Bug 1275358 - RFE: vbox: support cdrom media change for virtualbox >= 4 ('Unsupported device type 1' error)
RFE: vbox: support cdrom media change for virtualbox >= 4 ('Unsupported devic...
Status: NEW
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Libvirt Maintainers
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-26 12:05 EDT by mathieu.tarral
Modified: 2016-04-27 12:33 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Fedora 22 VirtualBox 4.3.32 libvirt-daemon-driver-vbox-1.2.13.1-3
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description mathieu.tarral 2015-10-26 12:05:54 EDT
Description of problem:

libvirt is not able to update a cdrom device on VirtualBox driver.
I wanted to change the source of the cdrom for a specific VM in VirtualBox using virsh.

Here is the new XML for the device :

<disk type='file' device='cdrom' >
    <source file='/tmp/myiso' />
    <target dev='hdc' bus='ide' />
</disk>

I used virsh to update the device :

$ virsh -c 'vbox:///session' update-device myvm device.xml



Version-Release number of selected component (if applicable):


How reproducible:

always.

Steps to Reproduce:
1. create an empty VM in VirtualBox
2. try to update the cdrom device
3. get the error 'Unsupported device type'

Actual results:

error :Failed to update device from device.xml
error :argument unsupported: Unsupported device type 1

Expected results:

success

Additional info:
Comment 1 Cole Robinson 2016-04-10 18:37:28 EDT
What version of libvirt is this?
What distro are you on?
What virtualbox version is this?
Please also provide the full VM XML as well
Comment 2 mathieu.tarral 2016-04-22 09:52:07 EDT
Hi,

sorry for this late reply, but when i tried to reproduce
the bug, i could not use libvirt and virtualbox together :

when i run

$ virsh -c vbox:///session

i get this error :

error: failed to connect to the hypervisor
error: internal error: unable to initialize VirtualBox driver API

so i ran libvirtd in verbose mode and i noticed these error messages :

error : dummyConnectOpen:90 : internal error: unable to initialize VirtualBox driver API

and

virNetSocketReadWire:1609 : End of file while reading data: Input/output error

I really would like to help you with the original bug that i reported, but
i have to know why my libvirt is not working anymore.
I already looked at some resources on internet, but nothing works here.

Could you help me with this ?
Thanks !


What version of libvirt is this?
libvirtd (libvirt) 1.2.18.2
What distro are you on?
Fedora 23
What virtualbox version is this?
VirtualBox 5.0.16
Comment 3 Cole Robinson 2016-04-22 09:54:20 EDT
Is libvirt-daemon-driver-vbox.x86_64 ?

If you're still having issues, maybe try grabbing latest libvirt packages from fedora virt preview repo, maybe it's a libvirt issue that was fixed:

https://fedoraproject.org/wiki/Virtualization_Preview_Repository
Comment 4 mathieu.tarral 2016-04-22 11:51:34 EDT
yes, i installed both libvirt-daemon-driver-vbox.x86_64 and libvirt-daemon-vbox.x86_64.

I also tried to install VirtualBox from the Oracle repository.

And I updated my libvirt components to the one provided by the preview repository that you gave me.

But it doesn't work...

Could help me to debug this issue first ?

Thanks !
Comment 5 Cole Robinson 2016-04-22 18:01:51 EDT
I poked at it, seems the issue is that libvirt doesn't have any virtualbox 5 API support :/

I sent a patch upstream to at least give a warning in this case:

http://www.redhat.com/archives/libvir-list/2016-April/msg01593.html

But unfortunately the larger issue of lack of vbox 5 API support will need someone else to fix, sorry
Comment 6 mathieu.tarral 2016-04-26 18:57:02 EDT
ok so i reinstalled VirtualBox 4 (and removed VirtualBox 5), to be able to
reproduce the bug.

Basically, my script is trying to find a specific VM, look for the cdrom
and update its source file :

#!/usr/bin/env python3

"""
Usage: vm_get_filesystem.py <vm_name>

Options:
    -h --help               Display this message

"""

from docopt import docopt
import os
import sys
import re
import subprocess
import libvirt
import tempfile
import xml.etree.ElementTree as ET


__SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
MYISO = os.path.join(__SCRIPT_DIR, 'live.iso')

if __name__ == '__main__':
    args = docopt(__doc__)
    # connect to VBox
    con = libvirt.open('vbox:///session')
    if con == None:
        print('Failed to connect to the Hypervisor !')
        sys.exit(1)
    # search vm
    vm = con.lookupByName(args['<vm_name>'])
    # get xml and list devices
    xml = vm.XMLDesc()
    print(xml)
    root = ET.fromstring(xml)
    # get all devices xml
    devices = root.find('devices')
    # do we have a disk ?
    for d in devices.iter('disk'):
        if d.get('device') == 'cdrom':
            # cdrom
            cdrom = d
            # change source
            # -> type = file
            cdrom.set('type', 'file')
            # -> source = 'myiso'
            try:
                # set
                cdrom.find('source').set('file', MYISO)
            except:
                # insert
                ET.SubElement(cdrom, 'source', {'file': MYISO})
            new_device_xml = ET.tostring(cdrom).decode('utf-8')
            print(new_device_xml)
            vm.updateDeviceFlags(new_device_xml)

And i don't understand why, at the last line, it raised an error when it calls
vm.updateDeviceFlags(), whith a string that should look like :

<disk device="cdrom" type="file">
      <source file="/tmp/live.iso" />
      <target bus="ide" dev="hdc" />
    </disk>


Did i made a mistake when i called vm.updateDeviceFlags ?
Or is it something else ?

Thank !
Comment 7 Cole Robinson 2016-04-27 12:33:33 EDT
According to the code, we apparently only support disk media change for vbox API < 3.1 :( The error message again sucks here

Unfortunately the virtualbox driver is barely maintained so I don't think this will be fixed any time soon, unless you want to try providing a patch yourself

Note You need to log in before you can comment on or make changes to this bug.