Hi all I am very new to VIX API, I wanted to create a clone of an existing machine. but I am getting error(Segmentation fault) while creating clone. Could any one of you help me regarding this.
Please find the code that I used :
use VMware::Vix::Simple;
use VMware::Vix::API::Constants;
my $err = VIX_OK;
my $hostHandle = VIX_INVALID_HANDLE;
($err, $hostHandle) = HostConnect(VIX_API_VERSION,
VIX_SERVICEPROVIDER_VMWARE_WORKSTATION,
undef, # hostName
0, #port number
"root", # userName
"root123", # password
0, # options
VIX_INVALID_HANDLE); # propertyListHandle
die "HostConnect() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;
($err, $vmHandle) = VMOpen($hostHandle,"//apps//Images//BaseImage//BaseImage.vmx");
die "VMOpen() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;
($err, $cloneHandle) = VMClone($vmHandle,
"Snapshot_1",
VIX_CLONETYPE_LINKED,
"//apps//Images//Clone_1//Clone_1.vmx",
0, # options
VIX_INVALID_HANDLE); # propertyListHandle
die "VMClone() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;
HostDisconnect($hostHandle);
The second argument to VM<Clone() is a handle to a snapshot, not a string value.
It looks like you want to use VMGetNamedSnapshot($mvHandle, "Snapshot_1") first to get the snapshot handle and pass that in.
Hi lemke,
I triedcode after changing as per your directions but, still I get segmentation fault.
Now my code looks like following:
$name="Snapshot_1";
($err, $snapshotHandle) = VMGetNamedSnapshot($vmHandle,$name);
($err, $cloneHandle) = VMClone($vmHandle,
$snapshotHandle,
VIX_CLONETYPE_LINKED,
"//apps//Images//NIS09_6//NISO9_6.vmx",
0, # options
VIX_INVALID_HANDLE); # propertyListHandle
I am also attaching the scree shot of Vm image. and the error.
What happens if you use single forward slashes instead of two?
I tried that -- no problems.
I've been unable to repro the crash, throwing all sorts of parameters at things in case you have a bug I don't see.
I do get various errors, but those were all in expected cases (bad snapshot names, VM power states, etc).
You should also probably turn on perl warnings (at least use perl -w); that would have caught the string vs handle issue in your original code.
One thing I can't quickly try and may be involved is the version of the VM. I'm testing with WS 6.5 created VMs, and from the screenshot, your's is from 5.x . Can you try it with a new VM and see if it passes?
Also, just to be sure, what version of Vix are you using?
I tried using single forward slash but, still I am gettiing the same error. let me try it out in 6.x version vm as lemke said.