-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: yaroslavborbat <yaroslav.752@gmail.com>
- Loading branch information
1 parent
cdcf91d
commit 1797d13
Showing
1 changed file
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
diff --git a/cmd/virt-launcher/virt-launcher.go b/cmd/virt-launcher/virt-launcher.go | ||
index e8d7c553f9..205f4bcba7 100644 | ||
--- a/cmd/virt-launcher/virt-launcher.go | ||
+++ b/cmd/virt-launcher/virt-launcher.go | ||
@@ -364,6 +364,7 @@ func main() { | ||
log.Log.Warningf("failed to set log verbosity. The value of logVerbosity label should be an integer, got %s instead.", verbosityStr) | ||
} | ||
} | ||
+ log.Log.Info("DEBUG: start...") | ||
|
||
if *simulateCrash { | ||
panic(fmt.Errorf("Simulated virt-launcher crash")) | ||
diff --git a/pkg/virt-launcher/virtwrap/converter/converter.go b/pkg/virt-launcher/virtwrap/converter/converter.go | ||
index e81e1f8cb0..7f0c203fd1 100644 | ||
--- a/pkg/virt-launcher/virtwrap/converter/converter.go | ||
+++ b/pkg/virt-launcher/virtwrap/converter/converter.go | ||
@@ -590,7 +590,7 @@ func Add_Agent_To_api_Channel() (channel api.Channel) { | ||
} | ||
|
||
func Convert_v1_Volume_To_api_Disk(source *v1.Volume, disk *api.Disk, c *ConverterContext, diskIndex int) error { | ||
- | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_Volume_To_api_Disk. convert source volume %s to disk", source.Name) | ||
if source.ContainerDisk != nil { | ||
return Convert_v1_ContainerDiskSource_To_api_Disk(source.Name, source.ContainerDisk, disk, c, diskIndex) | ||
} | ||
@@ -659,6 +659,7 @@ func Convert_v1_Hotplug_Volume_To_api_Disk(source *v1.Volume, disk *api.Disk, c | ||
} | ||
|
||
func Convert_v1_Config_To_api_Disk(volumeName string, disk *api.Disk, configType config.Type) error { | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_Config_To_api_Disk. convert source volume %s to disk", volumeName) | ||
disk.Type = "file" | ||
disk.Driver.Type = "raw" | ||
disk.Driver.ErrorPolicy = "stop" | ||
@@ -701,6 +702,7 @@ func GetHotplugBlockDeviceVolumePath(volumeName string) string { | ||
} | ||
|
||
func Convert_v1_PersistentVolumeClaim_To_api_Disk(name string, disk *api.Disk, c *ConverterContext) error { | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_PersistentVolumeClaim_To_api_Disk. convert source volume %s to disk", name) | ||
if c.IsBlockPVC[name] { | ||
return Convert_v1_BlockVolumeSource_To_api_Disk(name, disk, c.VolumesDiscardIgnore) | ||
} | ||
@@ -716,6 +718,7 @@ func Convert_v1_Hotplug_PersistentVolumeClaim_To_api_Disk(name string, disk *api | ||
} | ||
|
||
func Convert_v1_DataVolume_To_api_Disk(name string, disk *api.Disk, c *ConverterContext) error { | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_DataVolume_To_api_Disk. convert source volume %s to disk", name) | ||
if c.IsBlockDV[name] { | ||
return Convert_v1_BlockVolumeSource_To_api_Disk(name, disk, c.VolumesDiscardIgnore) | ||
} | ||
@@ -732,13 +735,15 @@ func Convert_v1_Hotplug_DataVolume_To_api_Disk(name string, disk *api.Disk, c *C | ||
|
||
// Convert_v1_FilesystemVolumeSource_To_api_Disk takes a FS source and builds the domain Disk representation | ||
func Convert_v1_FilesystemVolumeSource_To_api_Disk(volumeName string, disk *api.Disk, volumesDiscardIgnore []string) error { | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_FilesystemVolumeSource_To_api_Disk. convert source volume %s to disk", volumeName) | ||
file := GetFilesystemVolumePath(volumeName) | ||
info, err := GetImageInfo(file) | ||
if err != nil { | ||
- return fmt.Errorf("failed to get image info: %w", err) | ||
+ log.DefaultLogger().Errorf("DEBUG: failed to get image info: %v", err) | ||
} | ||
+ log.DefaultLogger().Errorf("DEBUG: format: %v", info.Format) | ||
disk.Type = "file" | ||
- disk.Driver.Type = info.Format | ||
+ disk.Driver.Type = "qcow2" | ||
disk.Driver.ErrorPolicy = "stop" | ||
disk.Source.File = file | ||
if !contains(volumesDiscardIgnore, volumeName) { | ||
@@ -752,10 +757,11 @@ func Convert_v1_Hotplug_FilesystemVolumeSource_To_api_Disk(volumeName string, di | ||
file := GetHotplugFilesystemVolumePath(volumeName) | ||
info, err := GetImageInfo(file) | ||
if err != nil { | ||
- return fmt.Errorf("failed to get image info: %w", err) | ||
+ log.DefaultLogger().Errorf("DEBUG: failed to get image info: %v", err) | ||
} | ||
+ log.DefaultLogger().Errorf("DEBUG: format: %v", info.Format) | ||
disk.Type = "file" | ||
- disk.Driver.Type = info.Format | ||
+ disk.Driver.Type = "qcow2" | ||
disk.Driver.ErrorPolicy = "stop" | ||
if !contains(volumesDiscardIgnore, volumeName) { | ||
disk.Driver.Discard = "unmap" | ||
@@ -789,14 +795,28 @@ func Convert_v1_Hotplug_BlockVolumeSource_To_api_Disk(volumeName string, disk *a | ||
} | ||
|
||
func Convert_v1_HostDisk_To_api_Disk(volumeName string, path string, disk *api.Disk) error { | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_HostDisk_To_api_Disk. convert source volume %s to disk", volumeName) | ||
+ | ||
+ file := hostdisk.GetMountedHostDiskPath(volumeName, path) | ||
+ info, err := GetImageInfo(file) | ||
+ if err != nil { | ||
+ log.DefaultLogger().Errorf("DEBUG: failed to get image info: %v", err) | ||
+ } | ||
+ format := "raw" | ||
+ if info != nil && info.Format != "" { | ||
+ format = info.Format | ||
+ } | ||
+ log.DefaultLogger().Errorf("DEBUG: format: %v", format) | ||
+ | ||
disk.Type = "file" | ||
- disk.Driver.Type = "raw" | ||
+ disk.Driver.Type = format | ||
disk.Driver.ErrorPolicy = "stop" | ||
- disk.Source.File = hostdisk.GetMountedHostDiskPath(volumeName, path) | ||
+ disk.Source.File = file | ||
return nil | ||
} | ||
|
||
func Convert_v1_SysprepSource_To_api_Disk(volumeName string, disk *api.Disk) error { | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_SysprepSource_To_api_Disk. convert source volume %s to disk", volumeName) | ||
if disk.Type == "lun" { | ||
return fmt.Errorf(deviceTypeNotCompatibleFmt, disk.Alias.GetName()) | ||
} | ||
@@ -808,6 +828,7 @@ func Convert_v1_SysprepSource_To_api_Disk(volumeName string, disk *api.Disk) err | ||
} | ||
|
||
func Convert_v1_CloudInitSource_To_api_Disk(source v1.VolumeSource, disk *api.Disk, c *ConverterContext) error { | ||
+ log.DefaultLogger().Info("DEBUG. Convert_v1_CloudInitSource_To_api_Disk. convert source volume to disk") | ||
if disk.Type == "lun" { | ||
return fmt.Errorf(deviceTypeNotCompatibleFmt, disk.Alias.GetName()) | ||
} | ||
@@ -829,6 +850,7 @@ func Convert_v1_CloudInitSource_To_api_Disk(source v1.VolumeSource, disk *api.Di | ||
} | ||
|
||
func Convert_v1_DownwardMetricSource_To_api_Disk(disk *api.Disk, c *ConverterContext) error { | ||
+ log.DefaultLogger().Info("DEBUG. Convert_v1_DownwardMetricSource_To_api_Disk. convert source volume to disk") | ||
disk.Type = "file" | ||
disk.ReadOnly = toApiReadOnly(true) | ||
disk.Driver = &api.DiskDriver{ | ||
@@ -844,6 +866,7 @@ func Convert_v1_DownwardMetricSource_To_api_Disk(disk *api.Disk, c *ConverterCon | ||
} | ||
|
||
func Convert_v1_EmptyDiskSource_To_api_Disk(volumeName string, _ *v1.EmptyDiskSource, disk *api.Disk) error { | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_EmptyDiskSource_To_api_Disk. convert source volume %s to disk", volumeName) | ||
if disk.Type == "lun" { | ||
return fmt.Errorf(deviceTypeNotCompatibleFmt, disk.Alias.GetName()) | ||
} | ||
@@ -858,6 +881,7 @@ func Convert_v1_EmptyDiskSource_To_api_Disk(volumeName string, _ *v1.EmptyDiskSo | ||
} | ||
|
||
func Convert_v1_ContainerDiskSource_To_api_Disk(volumeName string, _ *v1.ContainerDiskSource, disk *api.Disk, c *ConverterContext, diskIndex int) error { | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_ContainerDiskSource_To_api_Disk. convert source volume %s to disk", volumeName) | ||
if disk.Type == "lun" { | ||
return fmt.Errorf(deviceTypeNotCompatibleFmt, disk.Alias.GetName()) | ||
} | ||
@@ -884,6 +908,7 @@ func Convert_v1_ContainerDiskSource_To_api_Disk(volumeName string, _ *v1.Contain | ||
} | ||
|
||
func Convert_v1_EphemeralVolumeSource_To_api_Disk(volumeName string, disk *api.Disk, c *ConverterContext) error { | ||
+ log.DefaultLogger().Infof("DEBUG. Convert_v1_EphemeralVolumeSource_To_api_Disk. convert source volume %s to disk", volumeName) | ||
disk.Type = "file" | ||
disk.Driver.Type = "qcow2" | ||
disk.Driver.ErrorPolicy = "stop" | ||
@@ -1532,6 +1557,7 @@ func Convert_v1_VirtualMachineInstance_To_api_Domain(vmi *v1.VirtualMachineInsta | ||
|
||
prefixMap := newDeviceNamer(vmi.Status.VolumeStatus, vmi.Spec.Domain.Devices.Disks) | ||
for _, disk := range vmi.Spec.Domain.Devices.Disks { | ||
+ log.DefaultLogger().Infof("DEBUG. convert disk: %v", disk) | ||
newDisk := api.Disk{} | ||
|
||
err := Convert_v1_Disk_To_api_Disk(c, &disk, &newDisk, prefixMap, numBlkQueues, volumeStatusMap) | ||
diff --git a/pkg/virt-launcher/virtwrap/manager.go b/pkg/virt-launcher/virtwrap/manager.go | ||
index 6076182327..9a7da18d65 100644 | ||
--- a/pkg/virt-launcher/virtwrap/manager.go | ||
+++ b/pkg/virt-launcher/virtwrap/manager.go | ||
@@ -971,6 +971,17 @@ func (l *LibvirtDomainManager) SyncVMI(vmi *v1.VirtualMachineInstance, allowEmul | ||
logger.Error("Conversion failed.") | ||
return nil, err | ||
} | ||
+ for _, d := range domain.Spec.Devices.Disks { | ||
+ if d.Type == "file" { | ||
+ info, err := converter.GetImageInfo(d.Source.File) | ||
+ if err != nil { | ||
+ logger.Errorf("DEBUG. Failed to get image info: %v", err) | ||
+ continue | ||
+ } | ||
+ logger.Infof("DEBUG. IMAGE file %s format %s", d.Source.File, info.Format) | ||
+ } | ||
+ } | ||
+ logger.V(1).Infof("DEBUG. Object: %v", domain) | ||
|
||
// Set defaults which are not coming from the cluster | ||
api.NewDefaulter(c.Architecture).SetObjectDefaults_Domain(domain) |