Updating media registry for new VDI

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
rousseauhk
Posts: 45
Joined: 8. Apr 2013, 09:16
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu Server
Contact:

Updating media registry for new VDI

Post by rousseauhk »

I have a VDI which sits in the same place (c:/programdata/myapp/base.vdi) and which I use as the master VDI for cloning.

When I overwrite the base.vdi with a new version, and then try to Clone from it, I get a UUID mismatch error, since the new version of base.vdi was created from a different source to the previous version.

(UUID {96e75df9-ab4a-428d-a5e4-bd0e38362c9e} of the medium 'C:\ProgramData\myapp\base.vdi' does not match the value {acc967ad-a183-4882-9f34-7e7ce035617a} stored in the media registry ('C:\Windows\system32\config\systemprofile/.VirtualBox\VirtualBox.xml'))

How can I use the API to update the media registry with the new UUID/new VDI?

thanks
Steve
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Updating media registry for new VDI

Post by noteirak »

Pseudo code for this, before doing anything to the VDI

Code: Select all

IMedium = IVirtualbox::openMedium(path,type,accessMode);
IMedium::close();
// copy the file to the location
IVirtualbox::openMedium(path,type,accessMode);
That should update the media registry. But your way is definitly not the good way.I would rewrite the UUID to the expected value instead, then replace the file.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
rousseauhk
Posts: 45
Joined: 8. Apr 2013, 09:16
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu Server
Contact:

Re: Updating media registry for new VDI

Post by rousseauhk »

I tried setting the UUID with IMedium.SetIds(), but got a different error about the "Accessibility check was not yet performed". Closing & reopening the medium seems to help - I'll do more testing to verify.

thx
Steve
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Updating media registry for new VDI

Post by noteirak »

Yes you need to perform the Accessibility check, as described by the SDK for IMedium using

Code: Select all

IMedium::refreshState();
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply