Updating media registry for new VDI

Discussion about using the VirtualBox API, Tutorials, Samples.

Updating media registry for new VDI

Postby rousseauhk » 17. May 2013, 18:59

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
rousseauhk
 
Posts: 45
Joined: 8. Apr 2013, 09:16
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu Server

Re: Updating media registry for new VDI

Postby noteirak » 17. May 2013, 23:54

Pseudo code for this, before doing anything to the VDI
Code: Select all   Expand viewCollapse view
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://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Re: Updating media registry for new VDI

Postby rousseauhk » 18. May 2013, 04:22

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
rousseauhk
 
Posts: 45
Joined: 8. Apr 2013, 09:16
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu Server

Re: Updating media registry for new VDI

Postby noteirak » 19. May 2013, 10:53

Yes you need to perform the Accessibility check, as described by the SDK for IMedium using
Code: Select all   Expand viewCollapse view
IMedium::refreshState();
Hyperbox - Virtual Infrastructure Manager - https://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7


Return to The VirtualBox API

Who is online

Users browsing this forum: No registered users and 1 guest