Skip to content

Commit

Permalink
instance/drivers/driver_qemu: wait until hotplugged vCPUs are visible
Browse files Browse the repository at this point in the history
Fixes: #13295
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
  • Loading branch information
mihalicyn committed Apr 10, 2024
1 parent 4340011 commit 23bcf47
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lxd/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -7477,7 +7477,7 @@ func (d *qemu) SetAffinity(set []string) error {

// Confirm nothing weird is going on.
if len(set) != len(pids) {
return fmt.Errorf("QEMU has less vCPUs (%v) than configured (%v)", pids, set)
return fmt.Errorf("QEMU has different count of vCPUs (%v) than configured (%v)", pids, set)
}

for i, pid := range pids {
Expand Down Expand Up @@ -9020,6 +9020,26 @@ func (d *qemu) setCPUs(count int) error {
}
}

cpusWereSeen := false
for i := 0; i < 50; i++ {
// Get the list of PIDs from the VM.
pids, err := monitor.GetCPUs()
if err != nil {
return fmt.Errorf("Failed to get VM instance's QEMU process list: %w", err)
}

if count == len(pids) {
cpusWereSeen = true
break
}

time.Sleep(200 * time.Millisecond)
}

if !cpusWereSeen {
return fmt.Errorf("Failed to wait until all vCPUs (%d) come online", count)
}

revert.Success()

return nil
Expand Down

0 comments on commit 23bcf47

Please sign in to comment.