Skip to content

Conversation

@ljluestc
Copy link

@ljluestc ljluestc commented Jan 2, 2026

…platform compatibility

Description

This PR implements hot-updating of bandwidth limits for VPC guests and includes significant improvements for cross-platform development (macOS/Linux).

Key Changes

  1. VPC Bandwidth Hot-Update:

    • Hot-Update Logic: Modified pkg/hostman/guestman/qemu-kvm.go to explicitly detect changes in network interface bandwidth (Bw).
    • Immediate Application: When a change is detected, the system now automatically:
      • Regenerates the network interface setup script using generateNicScripts.
      • Executes the script via SetNicUp to apply the new traffic control (TC) rules and OVS configuration immediately.
    • Optimization: Preserved the optimized path for simple VLAN-only updates to avoid unnecessary script execution.
  2. Cross-Platform Compatibility (Zero-Failure Protocol):

    • Platform Stubs: Introduced _others.go files and standard //go:build linux build tags across multiple packages (cgrouputils, iproute2, lbagent, snapshot_service) to resolve compilation errors on non-Linux systems.
    • Dependency Refactoring: Updated pkg/cloudproxy/agent/worker/worker.go to replace the Linux-specific netlink library with the standard net library, ensuring the agent compiles and runs on macOS.
    • Test Stability: Fixed various unit tests to ensure a "Zero-Failure" state for go test ./pkg/... on macOS environments.

Related Issue

Testing

  • Unit Tests:
    • go test ./pkg/hostman/guestman/... - PASSED
    • go test ./pkg/hostman/... - PASSED
  • Manual Verification:
    • Verified that changing the bandwidth limit for a running VM triggers the SetNicUp flow.
    • Confirmed that the ovs-vsctl and tc commands are effectively updated without interrupting the VM instance.
    • Validated that the project compiles and tests pass on macOS (Darwin).

Checklist

  • Code compiles correctly.
  • Unit tests passed.
  • Logic verified for hot-update scenario.
  • Cross-platform build tags applied correctly.

What this PR does / why we need it:

Does this PR need to be backport to the previous release branch?:

…platform compatibility

## Description
This PR implements hot-updating of bandwidth limits for VPC guests and includes significant improvements for cross-platform development (macOS/Linux).

### Key Changes

1. **VPC Bandwidth Hot-Update:**
   - **Hot-Update Logic**: Modified `pkg/hostman/guestman/qemu-kvm.go` to explicitly detect changes in network interface bandwidth (`Bw`).
   - **Immediate Application**: When a change is detected, the system now automatically:
     - Regenerates the network interface setup script using `generateNicScripts`.
     - Executes the script via `SetNicUp` to apply the new traffic control (TC) rules and OVS configuration immediately.
   - **Optimization**: Preserved the optimized path for simple VLAN-only updates to avoid unnecessary script execution.

2. **Cross-Platform Compatibility (Zero-Failure Protocol):**
   - **Platform Stubs**: Introduced `_others.go` files and standard `//go:build linux` build tags across multiple packages (`cgrouputils`, `iproute2`, `lbagent`, `snapshot_service`) to resolve compilation errors on non-Linux systems.
   - **Dependency Refactoring**: Updated `pkg/cloudproxy/agent/worker/worker.go` to replace the Linux-specific `netlink` library with the standard `net` library, ensuring the agent compiles and runs on macOS.
   - **Test Stability**: Fixed various unit tests to ensure a "Zero-Failure" state for `go test ./pkg/...` on macOS environments.

## Related Issue
- Fixes yunionio#12553: VPC Guest Bandwidth requires VM restart to take effect.

## Testing
- **Unit Tests**:
  - `go test ./pkg/hostman/guestman/...` - **PASSED**
  - `go test ./pkg/hostman/...` - **PASSED**
- **Manual Verification**:
  - Verified that changing the bandwidth limit for a running VM triggers the `SetNicUp` flow.
  - Confirmed that the `ovs-vsctl` and `tc` commands are effectively updated without interrupting the VM instance.
  - Validated that the project compiles and tests pass on macOS (Darwin).

## Checklist
- [x] Code compiles correctly.
- [x] Unit tests passed.
- [x] Logic verified for hot-update scenario.
- [x] Cross-platform build tags applied correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vm in VPC needs to restart to make bandwidth change take effect

2 participants