VMware {code} Community
ajuniper
Contributor
Contributor

Finding guest info from within a guest

I'm trying to work out how I can find out information about a VM (name, resource pool, data store, network connections etc.) from within a (Linux) guest.

Within the guest I can find the NIC MAC addresses and the UUID (from dmidecode) either of which ought to be unique within the ESX system. But how do I go from these to find the VM within the ESX system and retrieve the above information?

Then, once the above information has been used (within the guest) to modify a new VMX file, what is the best way of importing/registering that new VM into the same resource pool and on the same data store as the original machine?

Apologies if I'm asking these questions in the wrong forum, I'm new here, there seems to be quite a few different ways to go about it and I'm not yet sure which is likely to be the best to use!

0 Kudos
1 Reply
qinghai0011
Contributor
Contributor

hi, I have the same problem when work with vmware workstation.

you know,we can use VDDK to create a VMDK file.just like the following steps:

1 .open physical disk driver wiht API CreateFile();

2 .send SCSI command to the bus(maybe,the DeviceIoControl funcation will be usefull);

3 .compute the beginning sector and the ending sector

4 .create a vmdk file by using the funcations which provided by vmware company.Just like VixDiskLib_Open(),VixDiskLib_Write().

5 .read the physical disk driver from ZERO sector to the ending sector(here,i just only want to clone "C" patrion for test,so,i compute this partion's beginning sector and ending sector.on my PC,beginning is the 63ird sector ,and ending sector ....for example the 66666666th sector,An LARGE_INTEGER data type)

6 . give a total sectors i will read :the end of "C" partion sector Subtract the beginning sector of this physical disk(that is to say:0),then add this result with 1.

i mean,66666666-0+1=66666667,this, 66666667 sectors ,will be read.

7 .using the funcation VixDiskLib_Create() to create a vmdk file

8 .open the vmdk file by using VixDiskLib_Open(),then ,we will get an handle about this vmdk file,just like the HANDLE returned from CreateFile funcation .

9 .write the datas we read from the physical disk driver ,and write them to the vmdk file by using VixDiskLib_Write() funcation

BUT ,THERE ARE SOME PROBLEN WITH THIS FUNCATION

the VixDiskLib_Write() FUNCATION Prototype is:

VixError

VixDiskLib_Write(VixDiskLibHandle diskHandle,

VixDiskLibSectorType startSector,

VixDiskLibSectorType numSectors,

const uint8 *writeBuffer);

the last Parameter it's data type is const uint8* ,which is equal to unsigned char.When the first of the data in the buffer is 0(0x00),whatever the other data is,this buffer will not be writen to the vmdk file at all.SO,the data lost.Maybe,we can create a VMX file and start vmdk through it,but we couldn't start the OS,the ERROR msg is"miss opration system" OR "can not Detective the guest OS ".even,there is nothing happen when VMWare worktation open the vmdk,the screen is black ,all the time.

BUT, I really read all the sectors exactly .SO,could you help me????my e-mail is

THANKS!

Message was edited by: qinghai0011

0 Kudos