VirtualBox

Opened 6 years ago

Last modified 5 years ago

#18296 new defect

mtype multiattach does not work

Reported by: Stephen Rondeau Owned by:
Component: other Version: VirtualBox 6.0.0
Keywords: multiattach Cc:
Guest type: other Host type: other

Description

Linux cn3-vcl4 4.19.13-200.fc28.x86_64 #1 SMP Sat Dec 29 23:10:35 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

The VM was created and registered today. The VDI file is old, but I don't think it is earlier than 4.0. This command works on 5.2.22:

VBoxManage -q storageattach "centos1" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "/classroom/vms/tinfo442/centos73.vdi" --mtype multiattach

but yield the following error on 6.0:

VBoxManage: error: Cannot change type for medium '/classroom/vms/tinfo442/centos73.vdi': the media type 'MultiAttach' can only be used on media registered with a machine that was created with VirtualBox 4.0 or later VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MediumWrap, interface IMedium, callee nsISupports VBoxManage: error: Context: "COMSETTER(Type)(enmMediumType)" at line 708 of file VBoxManageStorageController.cpp VBoxManage: error: Failed to set the medium type

Switching mtype to "immutable" is a workaround.

Change History (5)

comment:1 by jobias, 6 years ago

I am having exact the same problem, even with machines created with Vrtualbox 6.0

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" storageattach MyM_1 --storagectl "SATA Controller" --port 0 --device 0 --type "hdd" --medium "C:\temp\cloned.vmdk" --mtype multiattach --setuuid "" VBoxManage.exe: error: Cannot change type for medium 'C:\temp\cloned.vmdk': the media type 'MultiAttach' can only be used on media registered with a machine that was created with VirtualBox 4.0 or later VBoxManage.exe: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MediumWrap, interface IMedium, callee IUnknown VBoxManage.exe: error: Context: "COMSETTER(Type)(enmMediumType)" at line 708 of file VBoxManageStorageController.cpp VBoxManage.exe: error: Failed to set the medium type

comment:2 by pabordel, 6 years ago

Same for me with 6.0.2 : on a fresh new install, and a new user, I have the same message when I try to create the first machine with a multiattach disk

command line :

vboxmanage createvm -name "Serveur" --register -ostype Ubuntu_64 --groups "test"

vboxmanage modifyvm "Serveur" --memory 2048 --vram 24 --clipboard bidirectional

vboxmanage modifyvm "Serveur" --nic1 bridged --nictype1 virtio --bridgeadapter1 eno1 vboxmanage storagectl "Serveur" --name hdd --add sata

vboxmanage storageattach "Serveur" --storagectl hdd --type hdd --medium /virtualbox/mint19.vdi --mtype multiattach --port 0

The vdi file was created previously with virtualbox 5.2

error message :

VBoxManage: error: Cannot change type for medium '/virtualbox/mint19.vdi': the media type 'MultiAttach' can only be used on media registered with a machine that was created with VirtualBox 4.0 or later VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MediumWrap, interface IMedium, callee nsISupports VBoxManage: error: Context: "COMSETTER(Type)(enmMediumType)" at line 708 of file VBoxManageStorageController.cpp VBoxManage: error: Failed to set the medium type

comment:3 by Brian.Raker, 6 years ago

Likewise. New VDI created today on VB 6.0.4 r128413 and I can't modify it to type "multiattach".

VBoxManage modifyhd --type multiattach F:\OpenStackLab\rocky-labs\osbash\img\base-shared_folder-rocky-ubuntu-18.04-amd64.vdi
VBoxManage.exe: error: Cannot change type for medium 'F:\OpenStackLab\rocky-labs\osbash\img\base-shared_folder-rocky-ubuntu-18.04-amd64.vdi': the media type 'MultiAttach' can only be used on media registered with a machine that was created with VirtualBox 4.0 or later
VBoxManage.exe: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MediumWrap, interface IMedium, callee IUnknown
VBoxManage.exe: error: Context: "COMSETTER(Type)(enmMediumType)" at line 727 of file VBoxManageDisk.cpp

comment:4 by nitrotm, 6 years ago

Seems to be related to this piece of code from https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Main/src-server/MediumImpl.cpp

1854	    if (aType == MediumType_MultiAttach)
1855	    {
1856	        // This type is new with VirtualBox 4.0 and therefore requires settings
1857	        // version 1.11 in the settings backend. Unfortunately it is not enough to do
1858	        // the usual routine in MachineConfigFile::bumpSettingsVersionIfNeeded() for
1859	        // two reasons: The medium type is a property of the media registry tree, which
1860	        // can reside in the global config file (for pre-4.0 media); we would therefore
1861	        // possibly need to bump the global config version. We don't want to do that though
1862	        // because that might make downgrading to pre-4.0 impossible.
1863	        // As a result, we can only use these two new types if the medium is NOT in the
1864	        // global registry:
1865	        const Guid &uuidGlobalRegistry = m->pVirtualBox->i_getGlobalRegistryId();
1866	        if (i_isInRegistry(uuidGlobalRegistry))
1867	            return setError(VBOX_E_INVALID_OBJECT_STATE,
1868	                            tr("Cannot change type for medium '%s': the media type 'MultiAttach' can only be used "
1869	                               "on media registered with a machine that was created with VirtualBox 4.0 or later"),
1870	                            m->strLocationFull.c_str());
1871	    }

I can confirm that multiattach was working fine before 4.0. In the comments above, there is a notice about not having the medium in the media registry. But I don't understand why this has to be enforced. In my use-case, I'd like to register these shared multiattach disks in the registry so my api clients can list them...

comment:5 by Stephen Rondeau, 5 years ago

Here is a workaround:

  1. Attach as normal disk:

VBoxManage -q storageattach "centos1" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "/classroom/vms/tinfo442/centos73.vdi" --mtype normal

  1. Remove the normal disk:

VBoxManage -q storageattach "centos1" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium none

  1. Attach as multiattach:

VBoxManage -q storageattach "centos1" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "/classroom/vms/tinfo442/centos73.vdi" --mtype multiattach

That changes the .vbox file to add a MediaRegistry tag, followed by the correct spec for a HardDisk with MultiAttach, then by the differencing disk that allows the multiattach to work:

<MediaRegistry>

<HardDisks>

<HardDisk uuid="{f672f74a-5926-4507-8854-f75dc1ba67c5}" location="classroom/vms/tinfo442/centos73.vdi" format="VDI" type="MultiAttach">

<HardDisk uuid="{942d9e0a-a227-4cb8-8de3-914b89e78ea3}" location="Snapshots/{942d9e0a-a227-4cb8-8de3-914b89e78ea3}.vdi" format="VDI">

Note: See TracTickets for help on using tickets.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette