Skip to content

Commit 1a07b3c

Browse files
committed
Rename VM Api GRPC call RemoveNic to DetachNic
Signed-off-by: Guvenc Gulce <[email protected]>
1 parent 755d421 commit 1a07b3c

File tree

10 files changed

+51
-51
lines changed

10 files changed

+51
-51
lines changed

cli/src/vm_commands.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use feos_proto::vm_service::{
99
net_config, stream_vm_console_request as console_input, vm_service_client::VmServiceClient,
1010
AttachConsoleMessage, AttachDiskRequest, AttachNicRequest, ConsoleData, CpuConfig,
1111
CreateVmRequest, DeleteVmRequest, DiskConfig, GetVmRequest, ListVmsRequest, MemoryConfig,
12-
NetConfig, PauseVmRequest, PingVmRequest, RemoveDiskRequest, RemoveNicRequest, ResumeVmRequest,
12+
NetConfig, PauseVmRequest, PingVmRequest, RemoveDiskRequest, DetachNicRequest, ResumeVmRequest,
1313
ShutdownVmRequest, StartVmRequest, StreamVmConsoleRequest, StreamVmEventsRequest, TapConfig,
1414
VfioPciConfig, VmConfig, VmState, VmStateChangedEvent,
1515
};
@@ -185,11 +185,11 @@ pub enum VmCommand {
185185
#[arg(long, help = "Custom device identifier for the new interface")]
186186
device_id: Option<String>,
187187
},
188-
/// Remove a network interface from a VM
189-
RemoveNic {
188+
/// Detach a network interface from a VM
189+
DetachNic {
190190
#[arg(long, required = true, help = "VM identifier")]
191191
vm_id: String,
192-
#[arg(long, required = true, help = "Device identifier of the NIC to remove")]
192+
#[arg(long, required = true, help = "Device identifier of the NIC to detach")]
193193
device_id: String,
194194
},
195195
}
@@ -282,8 +282,8 @@ pub async fn handle_vm_command(args: VmArgs) -> Result<()> {
282282
)
283283
.await?
284284
}
285-
VmCommand::RemoveNic { vm_id, device_id } => {
286-
remove_nic(&mut client, vm_id, device_id).await?
285+
VmCommand::DetachNic { vm_id, device_id } => {
286+
detach_nic(&mut client, vm_id, device_id).await?
287287
}
288288
}
289289

@@ -833,16 +833,16 @@ async fn attach_nic(
833833
Ok(())
834834
}
835835

836-
async fn remove_nic(
836+
async fn detach_nic(
837837
client: &mut VmServiceClient<Channel>,
838838
vm_id: String,
839839
device_id: String,
840840
) -> Result<()> {
841-
let request = RemoveNicRequest {
841+
let request = DetachNicRequest {
842842
vm_id: vm_id.clone(),
843843
device_id: device_id.clone(),
844844
};
845-
client.remove_nic(request).await?;
846-
println!("NIC remove request sent for device {device_id} on VM {vm_id}");
845+
client.detach_nic(request).await?;
846+
println!("NIC detach request sent for device {device_id} on VM {vm_id}");
847847
Ok(())
848848
}

feos/services/vm-service/src/api.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use feos_proto::vm_service::{
66
vm_service_server::VmService, AttachDiskRequest, AttachDiskResponse, AttachNicRequest,
77
AttachNicResponse, CreateVmRequest, CreateVmResponse, DeleteVmRequest, DeleteVmResponse,
88
GetVmRequest, ListVmsRequest, ListVmsResponse, PauseVmRequest, PauseVmResponse, PingVmRequest,
9-
PingVmResponse, RemoveDiskRequest, RemoveDiskResponse, RemoveNicRequest, RemoveNicResponse,
9+
PingVmResponse, RemoveDiskRequest, RemoveDiskResponse, DetachNicRequest, DetachNicResponse,
1010
ResumeVmRequest, ResumeVmResponse, ShutdownVmRequest, ShutdownVmResponse, StartVmRequest,
1111
StartVmResponse, StreamVmConsoleRequest, StreamVmConsoleResponse, StreamVmEventsRequest,
1212
VmEvent, VmInfo,
@@ -217,13 +217,13 @@ impl VmService for VmApiHandler {
217217
.await
218218
}
219219

220-
async fn remove_nic(
220+
async fn detach_nic(
221221
&self,
222-
request: Request<RemoveNicRequest>,
223-
) -> Result<Response<RemoveNicResponse>, Status> {
224-
info!("VmApi: Received RemoveNic request.");
222+
request: Request<DetachNicRequest>,
223+
) -> Result<Response<DetachNicResponse>, Status> {
224+
info!("VmApi: Received DetachNic request.");
225225
dispatch_and_wait(&self.dispatcher_tx, |resp_tx| {
226-
Command::RemoveNic(request.into_inner(), resp_tx)
226+
Command::DetachNic(request.into_inner(), resp_tx)
227227
})
228228
.await
229229
}

feos/services/vm-service/src/dispatcher.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
dispatcher_handlers::{
66
handle_attach_disk_command, handle_attach_nic_command, handle_create_vm_command,
77
handle_delete_vm_command, handle_get_vm_command, handle_list_vms_command,
8-
handle_pause_vm_command, handle_remove_disk_command, handle_remove_nic_command,
8+
handle_pause_vm_command, handle_remove_disk_command, handle_detach_nic_command,
99
handle_resume_vm_command, handle_shutdown_vm_command, handle_start_vm_command,
1010
handle_stream_vm_console_command, handle_stream_vm_events_command,
1111
perform_startup_sanity_check,
@@ -113,8 +113,8 @@ impl VmServiceDispatcher {
113113
Command::AttachNic(req, responder) => {
114114
handle_attach_nic_command(&self.repository, req, responder, hypervisor).await;
115115
}
116-
Command::RemoveNic(req, responder) => {
117-
handle_remove_nic_command(&self.repository, req, responder, hypervisor).await;
116+
Command::DetachNic(req, responder) => {
117+
handle_detach_nic_command(&self.repository, req, responder, hypervisor).await;
118118
}
119119
}
120120
},

feos/services/vm-service/src/dispatcher_handlers.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use feos_proto::{
1414
AttachDiskRequest, AttachDiskResponse, AttachNicRequest, AttachNicResponse,
1515
CreateVmRequest, CreateVmResponse, DeleteVmRequest, DeleteVmResponse, GetVmRequest,
1616
ListVmsRequest, ListVmsResponse, PauseVmRequest, PauseVmResponse, RemoveDiskRequest,
17-
RemoveDiskResponse, RemoveNicRequest, RemoveNicResponse, ResumeVmRequest, ResumeVmResponse,
17+
RemoveDiskResponse, DetachNicRequest, DetachNicResponse, ResumeVmRequest, ResumeVmResponse,
1818
ShutdownVmRequest, ShutdownVmResponse, StartVmRequest, StartVmResponse,
1919
StreamVmConsoleRequest, StreamVmConsoleResponse, StreamVmEventsRequest, VmEvent, VmInfo,
2020
VmState, VmStateChangedEvent,
@@ -749,10 +749,10 @@ pub(crate) async fn handle_attach_nic_command(
749749
tokio::spawn(worker::handle_attach_nic(req, responder, hypervisor));
750750
}
751751

752-
pub(crate) async fn handle_remove_nic_command(
752+
pub(crate) async fn handle_detach_nic_command(
753753
repository: &VmRepository,
754-
req: RemoveNicRequest,
755-
responder: oneshot::Sender<Result<RemoveNicResponse, VmServiceError>>,
754+
req: DetachNicRequest,
755+
responder: oneshot::Sender<Result<DetachNicResponse, VmServiceError>>,
756756
hypervisor: Arc<dyn Hypervisor>,
757757
) {
758758
let (_vm_id, mut record) = match parse_vm_id_and_get_record(&req.vm_id, repository).await {
@@ -766,7 +766,7 @@ pub(crate) async fn handle_remove_nic_command(
766766
let current_state = record.status.state;
767767
if matches!(current_state, VmState::Creating | VmState::Crashed) {
768768
let _ = responder.send(Err(VmServiceError::InvalidState(format!(
769-
"Cannot remove NIC from VM in {current_state:?} state."
769+
"Cannot detach NIC from VM in {current_state:?} state."
770770
))));
771771
return;
772772
}
@@ -790,7 +790,7 @@ pub(crate) async fn handle_remove_nic_command(
790790
return;
791791
}
792792

793-
tokio::spawn(worker::handle_remove_nic(req, responder, hypervisor));
793+
tokio::spawn(worker::handle_detach_nic(req, responder, hypervisor));
794794
}
795795

796796
pub(crate) async fn check_and_cleanup_vms(

feos/services/vm-service/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use feos_proto::vm_service::{
66
AttachDiskRequest, AttachDiskResponse, AttachNicRequest, AttachNicResponse, CreateVmRequest,
77
CreateVmResponse, DeleteVmRequest, DeleteVmResponse, GetVmRequest, ListVmsRequest,
88
ListVmsResponse, PauseVmRequest, PauseVmResponse, PingVmRequest, PingVmResponse,
9-
RemoveDiskRequest, RemoveDiskResponse, RemoveNicRequest, RemoveNicResponse, ResumeVmRequest,
9+
RemoveDiskRequest, RemoveDiskResponse, DetachNicRequest, DetachNicResponse, ResumeVmRequest,
1010
ResumeVmResponse, ShutdownVmRequest, ShutdownVmResponse, StartVmRequest, StartVmResponse,
1111
StreamVmConsoleRequest, StreamVmConsoleResponse, StreamVmEventsRequest, VmEvent, VmInfo,
1212
};
@@ -88,9 +88,9 @@ pub enum Command {
8888
AttachNicRequest,
8989
oneshot::Sender<Result<AttachNicResponse, VmServiceError>>,
9090
),
91-
RemoveNic(
92-
RemoveNicRequest,
93-
oneshot::Sender<Result<RemoveNicResponse, VmServiceError>>,
91+
DetachNic(
92+
DetachNicRequest,
93+
oneshot::Sender<Result<DetachNicResponse, VmServiceError>>,
9494
),
9595
}
9696

@@ -113,7 +113,7 @@ impl std::fmt::Debug for Command {
113113
Command::AttachDisk(req, _) => f.debug_tuple("AttachDisk").field(req).finish(),
114114
Command::RemoveDisk(req, _) => f.debug_tuple("RemoveDisk").field(req).finish(),
115115
Command::AttachNic(req, _) => f.debug_tuple("AttachNic").field(req).finish(),
116-
Command::RemoveNic(req, _) => f.debug_tuple("RemoveNic").field(req).finish(),
116+
Command::DetachNic(req, _) => f.debug_tuple("DetachNic").field(req).finish(),
117117
}
118118
}
119119
}

feos/services/vm-service/src/vmm/ch_adapter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use feos_proto::vm_service::{
1414
net_config, AttachDiskRequest, AttachDiskResponse, AttachNicRequest, AttachNicResponse,
1515
CreateVmRequest, DeleteVmRequest, DeleteVmResponse, GetVmRequest, PauseVmRequest,
1616
PauseVmResponse, PingVmRequest, PingVmResponse, RemoveDiskRequest, RemoveDiskResponse,
17-
RemoveNicRequest, RemoveNicResponse, ResumeVmRequest, ResumeVmResponse, ShutdownVmRequest,
17+
DetachNicRequest, DetachNicResponse, ResumeVmRequest, ResumeVmResponse, ShutdownVmRequest,
1818
ShutdownVmResponse, StartVmRequest, StartVmResponse, VmConfig, VmInfo, VmState,
1919
};
2020
use hyper_util::client::legacy::Client;
@@ -536,7 +536,7 @@ impl Hypervisor for CloudHypervisorAdapter {
536536
})
537537
}
538538

539-
async fn remove_nic(&self, req: RemoveNicRequest) -> Result<RemoveNicResponse, VmmError> {
539+
async fn detach_nic(&self, req: DetachNicRequest) -> Result<DetachNicResponse, VmmError> {
540540
let api_client = self.get_ch_api_client(&req.vm_id)?;
541541
let device_to_remove = models::VmRemoveDevice {
542542
id: Some(req.device_id),
@@ -545,6 +545,6 @@ impl Hypervisor for CloudHypervisorAdapter {
545545
.vm_remove_device_put(device_to_remove)
546546
.await
547547
.map_err(|e| VmmError::ApiOperationFailed(format!("vm.remove-device failed: {e}")))?;
548-
Ok(RemoveNicResponse {})
548+
Ok(DetachNicResponse {})
549549
}
550550
}

feos/services/vm-service/src/vmm/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::VmEventWrapper;
55
use feos_proto::vm_service::{
66
AttachDiskRequest, AttachDiskResponse, AttachNicRequest, AttachNicResponse, CreateVmRequest,
77
DeleteVmRequest, DeleteVmResponse, GetVmRequest, PauseVmRequest, PauseVmResponse,
8-
PingVmRequest, PingVmResponse, RemoveDiskRequest, RemoveDiskResponse, RemoveNicRequest,
9-
RemoveNicResponse, ResumeVmRequest, ResumeVmResponse, ShutdownVmRequest, ShutdownVmResponse,
8+
PingVmRequest, PingVmResponse, RemoveDiskRequest, RemoveDiskResponse, DetachNicRequest,
9+
DetachNicResponse, ResumeVmRequest, ResumeVmResponse, ShutdownVmRequest, ShutdownVmResponse,
1010
StartVmRequest, StartVmResponse, VmEvent, VmInfo, VmStateChangedEvent,
1111
};
1212
use prost::Message;
@@ -92,7 +92,7 @@ pub trait Hypervisor: Send + Sync {
9292
async fn attach_disk(&self, req: AttachDiskRequest) -> Result<AttachDiskResponse, VmmError>;
9393
async fn remove_disk(&self, req: RemoveDiskRequest) -> Result<RemoveDiskResponse, VmmError>;
9494
async fn attach_nic(&self, req: AttachNicRequest) -> Result<AttachNicResponse, VmmError>;
95-
async fn remove_nic(&self, req: RemoveNicRequest) -> Result<RemoveNicResponse, VmmError>;
95+
async fn detach_nic(&self, req: DetachNicRequest) -> Result<DetachNicResponse, VmmError>;
9696
}
9797

9898
pub async fn broadcast_state_change_event(

feos/services/vm-service/src/worker.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use feos_proto::{
1111
stream_vm_console_request as console_input, AttachDiskRequest, AttachDiskResponse,
1212
AttachNicRequest, AttachNicResponse, ConsoleData, CreateVmRequest, CreateVmResponse,
1313
DeleteVmRequest, DeleteVmResponse, GetVmRequest, PauseVmRequest, PauseVmResponse,
14-
PingVmRequest, PingVmResponse, RemoveDiskRequest, RemoveDiskResponse, RemoveNicRequest,
15-
RemoveNicResponse, ResumeVmRequest, ResumeVmResponse, ShutdownVmRequest,
14+
PingVmRequest, PingVmResponse, RemoveDiskRequest, RemoveDiskResponse, DetachNicRequest,
15+
DetachNicResponse, ResumeVmRequest, ResumeVmResponse, ShutdownVmRequest,
1616
ShutdownVmResponse, StartVmRequest, StartVmResponse, StreamVmConsoleRequest,
1717
StreamVmConsoleResponse, StreamVmEventsRequest, VmEvent, VmInfo, VmState,
1818
VmStateChangedEvent,
@@ -443,14 +443,14 @@ pub async fn handle_attach_nic(
443443
}
444444
}
445445

446-
pub async fn handle_remove_nic(
447-
req: RemoveNicRequest,
448-
responder: oneshot::Sender<Result<RemoveNicResponse, VmServiceError>>,
446+
pub async fn handle_detach_nic(
447+
req: DetachNicRequest,
448+
responder: oneshot::Sender<Result<DetachNicResponse, VmServiceError>>,
449449
hypervisor: Arc<dyn Hypervisor>,
450450
) {
451-
let result = hypervisor.remove_nic(req).await;
451+
let result = hypervisor.detach_nic(req).await;
452452
if responder.send(result.map_err(Into::into)).is_err() {
453-
error!("VmWorker: Failed to send response for RemoveNic.");
453+
error!("VmWorker: Failed to send response for DetachNic.");
454454
}
455455
}
456456

feos/tests/integration/vm_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use anyhow::{Context, Result};
77
use feos_proto::vm_service::{
88
net_config, stream_vm_console_request as console_input, AttachConsoleMessage, AttachNicRequest,
99
CpuConfig, CreateVmRequest, DeleteVmRequest, GetVmRequest, MemoryConfig, NetConfig,
10-
PauseVmRequest, PingVmRequest, RemoveNicRequest, ResumeVmRequest, ShutdownVmRequest,
10+
PauseVmRequest, PingVmRequest, DetachNicRequest, ResumeVmRequest, ShutdownVmRequest,
1111
StartVmRequest, StreamVmConsoleRequest, StreamVmEventsRequest, TapConfig, VmConfig, VmState,
1212
};
1313
use log::info;
@@ -258,13 +258,13 @@ async fn test_create_and_start_vm() -> Result<()> {
258258
assert!(nic_found, "Attached NIC 'test' was not found in VM config");
259259
info!("Successfully verified NIC attachment.");
260260

261-
info!("Removing NIC 'test' from vm_id: {}", &vm_id);
262-
let remove_nic_req = RemoveNicRequest {
261+
info!("Detaching NIC 'test' from vm_id: {}", &vm_id);
262+
let detach_nic_req = DetachNicRequest {
263263
vm_id: vm_id.clone(),
264264
device_id: "test".to_string(),
265265
};
266-
vm_client.remove_nic(remove_nic_req).await?;
267-
info!("RemoveNic call successful");
266+
vm_client.detach_nic(detach_nic_req).await?;
267+
info!("DetachNic call successful");
268268

269269
tokio::time::sleep(Duration::from_millis(100)).await;
270270

proto/v1/vm.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ service VMService {
4444
// Hot-plugs a new network interface to a running VM.
4545
rpc AttachNic(AttachNicRequest) returns (AttachNicResponse);
4646
// Hot-unplugs a network interface from a running VM.
47-
rpc RemoveNic(RemoveNicRequest) returns (RemoveNicResponse);
47+
rpc DetachNic(DetachNicRequest) returns (DetachNicResponse);
4848
}
4949

5050
// Request stream from client to server for StreamVmConsole
@@ -244,12 +244,12 @@ message AttachNicResponse {
244244
string device_id = 1;
245245
}
246246

247-
message RemoveNicRequest {
247+
message DetachNicRequest {
248248
string vm_id = 1;
249249
string device_id = 2;
250250
}
251251

252-
message RemoveNicResponse {}
252+
message DetachNicResponse {}
253253

254254
message StartVmResponse {}
255255

0 commit comments

Comments
 (0)