I have a scenario in which I'm supplied with three VDI files: "ubunutubase", 
"extrafiles1" and "extrafiles2" - extrafiles1 is a differencing disk based on 
ubunutubase and extrafiles2 is a differencing disk based on extrafiles1. These 
disks have not previously been known to my VirtualBox instance and I'd like to 
import the hierarchy into my VirtualBox instance programmatically.

Experimenting with IVirtualBox.openHardDisk() I can pass it a parent UUID but 
it seems to try and create a new drive with that UUID which is not the behavior 
I want in this case - here, the drive already exists and I have just imported 
it into 

>>> vbox = 
>>> xpcom.components.classes["@virtualbox.org/VirtualBox;1"].createInstance()
>>> session = 
>>> xpcom.components.classes["@virtualbox.org/Session;1"].createInstance()
>>> ifaces = xpcom.components.interfaces
>>> local_path = 
>>> '/vm_images/.VirtualBox/HardDisks/{4edbe526-6d78-4ce9-885b-63dcce74de5c}.vdi'
>>> hd = vbox.openHardDisk(local_path, ifaces.AccessMode.ReadWrite, False, "", 
>>> False, "")
>>> local_path = 
>>> '/vm_images/.VirtualBox/HardDisks/{3e0569c2-d4fa-4a40-a7c9-f5fb148796c4}.vdi'
>>> hd = vbox.openHardDisk(local_path, ifaces.AccessMode.ReadWrite, False, "", 
>>> True, "4edbe526-6d78-4ce9-885b-63dcce74de5c")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<XPCOMObject method 'openHardDisk'>", line 7, in openHardDisk
xpcom.Exception: 0x80070057 (Cannot register the hard disk 
'/vm_images/.VirtualBox/HardDisks/{3e0569c2-d4fa-4a40-a7c9-f5fb148796c4}.vdi' 
with UUID {4edbe526-6d78-4ce9-885b-63dcce74de5c} because a hard disk 
'/vm_images/.VirtualBox/HardDisks/{4edbe526-6d78-4ce9-885b-63dcce74de5c}.vdi' 
with UUID {4edbe526-6d78-4ce9-885b-63dcce74de5c} already exists in the media 
registry ('/home/sarah/.VirtualBox/VirtualBox.xml'))

This isn't quite the behaviour I would expect. I can't quite work out how 
creating a new parent for an existing differencing disk could possibly work and 
it's certainly not what I was hoping for here.

If I don't pass in the parent UUID then the create succeeds but the drive is 
not created as a child of the parent.

>>> hd = vbox.openHardDisk(local_path, ifaces.AccessMode.ReadWrite, False, "", 
>>> False, "")

I can't currently see any other way of doing this save for moving the disks 
around in the VirtualBox.xml file after everything's been registered. Am I 
doing something wrong or is this genuinely the way the setParentId and parentId 
parameters are intended to work?

(Tested with versions 3.0.0 and 3.0.2)

Thanks,

-- Sarah

_______________________________________________
vbox-dev mailing list
vbox-dev@virtualbox.org
http://vbox.innotek.de/mailman/listinfo/vbox-dev

Reply via email to