Merge pull request #18236 from baude/vsock0

Enabled network over vsock
This commit is contained in:
OpenShift Merge Robot
2023-04-17 17:25:24 -04:00
committed by GitHub
10 changed files with 257 additions and 106 deletions

View File

@@ -395,9 +395,6 @@ func (vmm *VirtualMachineManager) NewVirtualMachine(name string, config *Hardwar
return err
}
//if err := vmm.CreateVhdxFile(config.DiskPath, config.DiskSize*1024*1024*1024); err != nil {
// return err
//}
if err := NewDriveSettingsBuilder(systemSettings).
AddScsiController().
AddSyntheticDiskDrive(0).
@@ -416,13 +413,15 @@ func (vmm *VirtualMachineManager) NewVirtualMachine(name string, config *Hardwar
return err
}
// Add default network connection
if err := NewNetworkSettingsBuilder(systemSettings).
AddSyntheticEthernetPort(nil).
AddEthernetPortAllocation(""). // "" = connect to default switch
Finish(). // allocation
Finish(). // port
Complete(); err != nil {
return err
if config.Network {
if err := NewNetworkSettingsBuilder(systemSettings).
AddSyntheticEthernetPort(nil).
AddEthernetPortAllocation(""). // "" = connect to default switch
Finish(). // allocation
Finish(). // port
Complete(); err != nil {
return err
}
}
return nil
}

View File

@@ -98,6 +98,9 @@ type HardwareConfig struct {
DiskSize uint64
// Memory in megabytes assigned to the vm
Memory int32
// Network is bool to add a Network Connection to the
// default network switch in Microsoft HyperV
Network bool
}
type Statuses struct {