MCPcopy Index your code
hub / github.com/cloud-hypervisor/cloud-hypervisor / validate

Method validate

vmm/src/api/mod.rs:442–487  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

440 }
441
442 pub fn validate(&self) -> Result<(), VmSendMigrationConfigError> {
443 match self.destination_url.as_str() {
444 url if url
445 .strip_prefix("tcp:")
446 .is_some_and(|addr| !addr.is_empty()) => {}
447 url if url
448 .strip_prefix("unix:")
449 .is_some_and(|path| !path.is_empty()) =>
450 {
451 if self.connections.get() > 1 {
452 return Err(VmSendMigrationConfigError::ValidationError(
453 "UNIX sockets and connections option cannot be used at the same time."
454 .to_string(),
455 ));
456 }
457 }
458 _ => {
459 return Err(VmSendMigrationConfigError::ValidationError(
460 "destination_url must use tcp:<host>:<port> or unix:<path>.".to_string(),
461 ));
462 }
463 }
464
465 if self.connections.get() > MAX_MIGRATION_CONNECTIONS {
466 return Err(VmSendMigrationConfigError::ValidationError(format!(
467 "connections must not exceed {MAX_MIGRATION_CONNECTIONS}."
468 )));
469 }
470
471 if self.local {
472 if !self.destination_url.starts_with("unix:") {
473 return Err(VmSendMigrationConfigError::ValidationError(
474 "local option is only supported with UNIX sockets.".to_string(),
475 ));
476 }
477
478 if self.connections.get() > 1 {
479 return Err(VmSendMigrationConfigError::ValidationError(
480 "local option and connections option cannot be used at the same time."
481 .to_string(),
482 ));
483 }
484 }
485
486 Ok(())
487 }
488}
489
490pub enum ApiResponsePayload {

Callers 1

parseMethod · 0.45

Calls 3

ValidationErrorEnum · 0.85
is_emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected