(&mut self, desired_vcpus: u32)
| 1545 | } |
| 1546 | |
| 1547 | pub fn resize(&mut self, desired_vcpus: u32) -> Result<bool> { |
| 1548 | if desired_vcpus.cmp(&self.present_vcpus()) == cmp::Ordering::Equal { |
| 1549 | return Ok(false); |
| 1550 | } |
| 1551 | |
| 1552 | if !self.dynamic { |
| 1553 | return Ok(false); |
| 1554 | } |
| 1555 | |
| 1556 | if desired_vcpus < 1 { |
| 1557 | return Err(Error::DesiredVCpuCountIsZero); |
| 1558 | } |
| 1559 | |
| 1560 | if self.check_pending_removed_vcpu() { |
| 1561 | return Err(Error::VcpuPendingRemovedVcpu); |
| 1562 | } |
| 1563 | |
| 1564 | match desired_vcpus.cmp(&self.present_vcpus()) { |
| 1565 | cmp::Ordering::Greater => { |
| 1566 | let vcpus = self.create_vcpus(desired_vcpus, None)?; |
| 1567 | for vcpu in vcpus { |
| 1568 | let mut vcpu = vcpu.lock().unwrap(); |
| 1569 | self.configure_vcpu(&mut vcpu, None)?; |
| 1570 | } |
| 1571 | self.activate_vcpus(desired_vcpus, true, None)?; |
| 1572 | Ok(true) |
| 1573 | } |
| 1574 | cmp::Ordering::Less => { |
| 1575 | self.mark_vcpus_for_removal(desired_vcpus); |
| 1576 | Ok(true) |
| 1577 | } |
| 1578 | _ => Ok(false), |
| 1579 | } |
| 1580 | } |
| 1581 | |
| 1582 | /// Signals all vCPU threads and waits for them to ACK the interruption. |
| 1583 | /// |
no test coverage detected