MCPcopy
hub / github.com/lxc/incus / Stop

Method Stop

internal/server/device/proxy.go:459–489  ·  view source on GitHub ↗

Stop is run when the device is removed from the instance.

()

Source from the content-addressed store, hash-verified

457
458// Stop is run when the device is removed from the instance.
459func (d *proxy) Stop() (*deviceConfig.RunConfig, error) {
460 // Stop any background NAT address monitor before clearing the firewall entries.
461 d.stopNATMonitor()
462
463 // Remove possible firewall entries.
464 err := d.state.Firewall.InstanceClearProxyNAT(d.inst.Project().Name, d.inst.Name(), d.name)
465 if err != nil {
466 logger.Errorf("Failed to remove proxy NAT filters: %v", err)
467 }
468
469 devFileName := fmt.Sprintf("proxy.%s", linux.PathNameEncode(d.name))
470 devPath := filepath.Join(d.inst.DevicesPath(), devFileName)
471
472 if !util.PathExists(devPath) {
473 // There's no proxy process if NAT is enabled
474 return nil, nil
475 }
476
477 err = d.killProxyProc(devPath)
478 if err != nil {
479 return nil, err
480 }
481
482 // Unload apparmor profile.
483 err = apparmor.ForkproxyUnload(d.state.OS, d.inst, d)
484 if err != nil {
485 return nil, err
486 }
487
488 return nil, nil
489}
490
491func (d *proxy) setupNAT() error {
492 listenAddr, err := network.ProxyParseAddr(d.config["listen"])

Callers

nothing calls this directly

Calls 10

stopNATMonitorMethod · 0.95
killProxyProcMethod · 0.95
ErrorfFunction · 0.92
PathNameEncodeFunction · 0.92
PathExistsFunction · 0.92
ForkproxyUnloadFunction · 0.92
InstanceClearProxyNATMethod · 0.65
ProjectMethod · 0.65
NameMethod · 0.65
DevicesPathMethod · 0.65

Tested by

no test coverage detected