2010/7/21 Daniel Veillard <veillard@xxxxxxxxxx>: > On Tue, Jul 13, 2010 at 10:11:05PM +0200, Matthias Bolte wrote: >> This works for file-backed SCSI disk device with a datastore >> related source path. >> --- >> >> v2: >> - check that ESX reports the same controller model for all disks attached to >> the SCSI controller, otherwise let autodetection fail >> >> docs/drvesx.html.in | 9 ++ >> docs/schemas/domain.rng | 1 + >> src/conf/domain_conf.c | 1 + >> src/conf/domain_conf.h | 1 + >> src/esx/esx_vi_generator.input | 149 +++++++++++++++++++++++ >> src/esx/esx_vi_generator.py | 3 + >> src/esx/esx_vmx.c | 256 +++++++++++++++++++++++++++++++++++++--- > [...] >> diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input >> index ff65178..b4b33f6 100644 >> --- a/src/esx/esx_vi_generator.input >> +++ b/src/esx/esx_vi_generator.input >> @@ -184,6 +184,40 @@ object Event >> end >> >> >> +object FileInfo >> + String path r >> + Long fileSize o >> + DateTime modification o >> +end >> + >> + >> +object FileQuery >> +end >> + >> + >> +object FileQueryFlags >> + Boolean fileType r >> + Boolean fileSize r >> + Boolean modification r >> +end >> + >> + >> +object FloppyImageFileInfo extends FileInfo >> +end >> + >> + >> +object FloppyImageFileQuery extends FileQuery >> +end >> + >> + >> +object FolderFileInfo extends FileInfo >> +end >> + >> + >> +object FolderFileQuery extends FileQuery >> +end >> + >> + >> object HostCpuIdInfo >> Int level r >> String vendor o >> @@ -194,6 +228,22 @@ object HostCpuIdInfo >> end >> >> >> +object HostDatastoreBrowserSearchResults >> + ManagedObjectReference datastore o >> + String folderPath o >> + FileInfo file ol >> +end >> + >> + >> +object HostDatastoreBrowserSearchSpec >> + FileQuery query ol >> + FileQueryFlags details o >> + Boolean searchCaseInsensitive o >> + String matchPattern ol >> + Boolean sortFoldersFirst o >> +end >> + >> + >> object HostFileSystemVolume >> String type r >> String name r >> @@ -225,6 +275,14 @@ object HostVmfsVolume extends HostFileSystemVolume >> end >> >> >> +object IsoImageFileInfo extends FileInfo >> +end >> + >> + >> +object IsoImageFileQuery extends FileQuery >> +end >> + >> + >> object LocalDatastoreInfo extends DatastoreInfo >> String path o >> end >> @@ -424,6 +482,14 @@ object TaskInfo >> end >> >> >> +object TemplateConfigFileInfo extends VmConfigFileInfo >> +end >> + >> + >> +object TemplateConfigFileQuery extends VmConfigFileQuery >> +end >> + >> + >> object TraversalSpec extends SelectionSpec >> String type r >> String path r >> @@ -502,6 +568,82 @@ object VirtualMachineSnapshotTree >> end >> >> >> +object VmConfigFileInfo extends FileInfo >> + Int configVersion o >> +end >> + >> + >> +object VmConfigFileQuery extends FileQuery >> + VmConfigFileQueryFilter filter o >> + VmConfigFileQueryFlags details o >> +end >> + >> + >> +object VmConfigFileQueryFilter >> + Int matchConfigVersion ol >> +end >> + >> + >> +object VmConfigFileQueryFlags >> + Boolean configVersion r >> +end >> + >> + >> +object VmDiskFileInfo extends FileInfo >> + String diskType o >> + Long capacityKb o >> + Int hardwareVersion o >> + String controllerType o >> + String diskExtents ol >> +end >> + >> + >> +object VmDiskFileQuery extends FileQuery >> + VmDiskFileQueryFilter filter o >> + VmDiskFileQueryFlags details o >> +end >> + >> + >> +object VmDiskFileQueryFilter >> + String diskType ol >> + Int matchHardwareVersion ol >> + String controllerType ol >> +end >> + >> + >> +object VmDiskFileQueryFlags >> + Boolean diskType r >> + Boolean capacityKb r >> + Boolean hardwareVersion r >> + Boolean controllerType o >> + Boolean diskExtents o >> +end >> + >> + >> +object VmLogFileInfo extends FileInfo >> +end >> + >> + >> +object VmLogFileQuery extends FileQuery >> +end >> + >> + >> +object VmNvramFileInfo extends FileInfo >> +end >> + >> + >> +object VmNvramFileQuery extends FileQuery >> +end >> + >> + >> +object VmSnapshotFileInfo extends FileInfo >> +end >> + >> + >> +object VmSnapshotFileQuery extends FileQuery >> +end >> + >> + >> object VmfsDatastoreInfo extends DatastoreInfo >> HostVmfsVolume vmfs o >> end >> @@ -658,6 +800,13 @@ method RevertToSnapshot_Task returns ManagedObjectReference r >> end >> >> >> +method SearchDatastore_Task returns ManagedObjectReference r >> + ManagedObjectReference _this r >> + String datastorePath r >> + HostDatastoreBrowserSearchSpec searchSpec o >> +end >> + >> + >> method SessionIsActive returns Boolean r >> ManagedObjectReference _this:SessionManager r >> String sessionID r > > I'm somehow surprized that all those extension to the generator are > needed for SCSI type detection :-) Don't worry most of that will be needed for the upcoming storage volume handling anyway :) > [...] >> + if (esxVI_VmDiskFileQuery_Alloc(&vmDiskFileQuery) < 0 || >> + esxVI_VmDiskFileQueryFlags_Alloc(&vmDiskFileQuery->details) < 0 || >> + esxVI_FileQuery_AppendToList >> + (&searchSpec->query, >> + esxVI_FileQuery_DynamicCast(vmDiskFileQuery)) < 0) { >> + goto cleanup; >> + } >> + >> + vmDiskFileQuery->details->diskType = esxVI_Boolean_False; >> + vmDiskFileQuery->details->capacityKb = esxVI_Boolean_False; >> + vmDiskFileQuery->details->hardwareVersion = esxVI_Boolean_False; >> + vmDiskFileQuery->details->controllerType = esxVI_Boolean_True; >> + vmDiskFileQuery->details->diskExtents = esxVI_Boolean_False; >> + >> + if (esxVI_String_Alloc(&searchSpec->matchPattern) < 0) { >> + goto cleanup; >> + } >> + >> + searchSpec->matchPattern->value = fileName; >> + >> + /* Search datastore for file */ >> + if (esxVI_SearchDatastore_Task(ctx, hostDatastoreBrowser, datastorePath, >> + searchSpec, &task) < 0 || >> + esxVI_WaitForTaskCompletion(ctx, task, NULL, esxVI_Boolean_False, >> + &taskInfoState) < 0) { >> + goto cleanup; >> + } > > Okay that explains some of it, you need to do a full query and sort > the controller type informations... Yes, I query for the FileInfo and to be on the safe side I need to be able to handle all types that inherit from FileInfo. You'll be surprised by the huge pile of new types I would have to add once I would want to deserialize the error details from SOAP faults or task errors. The vSphere API contains a type for every possible error. > > ACK, patch looks fine to me > > Daniel > Thanks, pushed. Matthias -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list