@@ -25,7 +25,10 @@ const CowSerial = "cocoon-cow"
2525// the DB), we write a placeholder record first, then create directories and
2626// prepare disks, and finally update the record to Created state.
2727func (ch * CloudHypervisor ) Create (ctx context.Context , vmCfg * types.VMConfig , storageConfigs []* types.StorageConfig , networkConfigs []* types.NetworkConfig , bootCfg * types.BootConfig ) (* types.VM , error ) {
28- id := hypervisor .GenerateID ()
28+ id , err := hypervisor .GenerateID ()
29+ if err != nil {
30+ return nil , fmt .Errorf ("generate VM ID: %w" , err )
31+ }
2932 now := time .Now ()
3033
3134 blobIDs := extractBlobIDs (storageConfigs , bootCfg )
@@ -60,7 +63,6 @@ func (ch *CloudHypervisor) Create(ctx context.Context, vmCfg *types.VMConfig, st
6063 var (
6164 preparedStorage []* types.StorageConfig
6265 bootCopy * types.BootConfig
63- err error
6466 )
6567 if bootCfg != nil {
6668 b := * bootCfg
@@ -136,6 +138,8 @@ func (ch *CloudHypervisor) prepareOCI(ctx context.Context, vmID string, vmCfg *t
136138
137139 // Append static IP configuration for each network interface.
138140 // Format: ip=<client-IP>:<server>:<gw-IP>:<netmask>:<hostname>:<device>:<autoconf>
141+ // The index i matches the CH --net ordering, which maps 1:1 to guest eth{i}.
142+ // NICs with Network==nil (DHCP) still occupy their slot but get no ip= param.
139143 if len (networkConfigs ) > 0 {
140144 cmdline .WriteString (" net.ifnames=0" )
141145 for i , n := range networkConfigs {
@@ -184,6 +188,7 @@ func (ch *CloudHypervisor) prepareCloudimg(ctx context.Context, vmID string, vmC
184188 Hostname : vmCfg .Name ,
185189 RootPassword : ch .conf .DefaultRootPassword ,
186190 }
191+ // Index i matches CH --net order → guest eth{i}. See prepareOCI comment.
187192 for i , n := range networkConfigs {
188193 if n .Network != nil {
189194 ones , _ := n .Network .Netmask .Size ()
0 commit comments