@@ -28,6 +28,7 @@ import { compareVersions } from 'compare-versions';
28
28
29
29
import { getSocketCompatibility } from './compatibility-mode' ;
30
30
import { getDetectionChecks } from './detection-checks' ;
31
+ import { KrunkitHelper } from './krunkit-helper' ;
31
32
import { PodmanBinaryLocationHelper } from './podman-binary-location-helper' ;
32
33
import { PodmanCleanupMacOS } from './podman-cleanup-macos' ;
33
34
import { PodmanCleanupWindows } from './podman-cleanup-windows' ;
@@ -37,7 +38,6 @@ import { PodmanConfiguration } from './podman-configuration';
37
38
import { PodmanInfoHelper } from './podman-info-helper' ;
38
39
import { PodmanInstall } from './podman-install' ;
39
40
import { PodmanRemoteConnections } from './podman-remote-connections' ;
40
- import { QemuHelper } from './qemu-helper' ;
41
41
import { RegistrySetup } from './registry-setup' ;
42
42
import {
43
43
appConfigDir ,
@@ -89,7 +89,7 @@ const configurationCompatibilityMode = 'setting.dockerCompatibility';
89
89
let telemetryLogger : extensionApi . TelemetryLogger | undefined ;
90
90
91
91
const wslHelper = new WslHelper ( ) ;
92
- const qemuHelper = new QemuHelper ( ) ;
92
+ const krunkitHelper = new KrunkitHelper ( ) ;
93
93
const podmanBinaryHelper = new PodmanBinaryLocationHelper ( ) ;
94
94
const podmanInfoHelper = new PodmanInfoHelper ( ) ;
95
95
@@ -746,10 +746,7 @@ export async function registerProviderFor(
746
746
await startMachine ( provider , podmanConfiguration , machineInfo , context , logger , undefined , false ) ;
747
747
} ,
748
748
stop : async ( context , logger ) : Promise < void > => {
749
- await execPodman ( [ 'machine' , 'stop' , machineInfo . name ] , machineInfo . vmType , {
750
- logger : new LoggerDelegator ( context , logger ) ,
751
- } ) ;
752
- provider . updateStatus ( 'stopped' ) ;
749
+ await stopMachine ( provider , machineInfo , context , logger ) ;
753
750
} ,
754
751
delete : async ( logger ) : Promise < void > => {
755
752
await execPodman ( [ 'machine' , 'rm' , '-f' , machineInfo . name ] , machineInfo . vmType , {
@@ -871,6 +868,7 @@ export async function startMachine(
871
868
autoStart ?: boolean ,
872
869
) : Promise < void > {
873
870
const telemetryRecords : Record < string , unknown > = { } ;
871
+ telemetryRecords . provider = machineInfo . vmType ;
874
872
const startTime = performance . now ( ) ;
875
873
876
874
await checkRosettaMacArm ( podmanConfiguration ) ;
@@ -898,6 +896,31 @@ export async function startMachine(
898
896
}
899
897
}
900
898
899
+ export async function stopMachine (
900
+ provider : extensionApi . Provider ,
901
+ machineInfo : MachineInfo ,
902
+ context ?: extensionApi . LifecycleContext ,
903
+ logger ?: extensionApi . Logger ,
904
+ ) : Promise < void > {
905
+ const startTime = performance . now ( ) ;
906
+ const telemetryRecords : Record < string , unknown > = { } ;
907
+ telemetryRecords . provider = machineInfo . vmType ;
908
+ try {
909
+ await execPodman ( [ 'machine' , 'stop' , machineInfo . name ] , machineInfo . vmType , {
910
+ logger : new LoggerDelegator ( context , logger ) ,
911
+ } ) ;
912
+ provider . updateStatus ( 'stopped' ) ;
913
+ } catch ( err : unknown ) {
914
+ telemetryRecords . error = err ;
915
+ throw err ;
916
+ } finally {
917
+ // send telemetry event
918
+ const endTime = performance . now ( ) ;
919
+ telemetryRecords . duration = endTime - startTime ;
920
+ sendTelemetryRecords ( 'podman.machine.stop' , telemetryRecords , false ) ;
921
+ }
922
+ }
923
+
901
924
async function doHandleError (
902
925
provider : extensionApi . Provider ,
903
926
machineInfo : MachineInfo ,
@@ -1764,7 +1787,7 @@ export function isLibkrunSupported(podmanVersion: string): boolean {
1764
1787
return isMac ( ) && compareVersions ( podmanVersion , PODMAN_MINIMUM_VERSION_FOR_LIBKRUN_SUPPORT ) >= 0 ;
1765
1788
}
1766
1789
1767
- function sendTelemetryRecords (
1790
+ export function sendTelemetryRecords (
1768
1791
eventName : string ,
1769
1792
telemetryRecords : Record < string , unknown > ,
1770
1793
includeMachineStats : boolean ,
@@ -1784,16 +1807,16 @@ function sendTelemetryRecords(
1784
1807
telemetryRecords . hostCpuModel = hostCpus [ 0 ] . model ;
1785
1808
1786
1809
// on macOS, try to see if podman is coming from brew or from the installer
1787
- // and display version of qemu
1810
+ // and display version of krunkit
1788
1811
if ( extensionApi . env . isMac ) {
1789
- let qemuPath : string | undefined ;
1812
+ let krunkitPath : string | undefined ;
1790
1813
1791
1814
try {
1792
1815
const podmanBinaryResult = await podmanBinaryHelper . getPodmanLocationMac ( ) ;
1793
1816
1794
1817
telemetryRecords . podmanCliSource = podmanBinaryResult . source ;
1795
1818
if ( podmanBinaryResult . source === 'installer' ) {
1796
- qemuPath = '/opt/podman/qemu /bin' ;
1819
+ krunkitPath = '/opt/podman/bin' ;
1797
1820
}
1798
1821
telemetryRecords . podmanCliFoundPath = podmanBinaryResult . foundPath ;
1799
1822
if ( podmanBinaryResult . error ) {
@@ -1804,16 +1827,18 @@ function sendTelemetryRecords(
1804
1827
console . trace ( 'unable to check from which path podman is coming' , error ) ;
1805
1828
}
1806
1829
1807
- // add qemu version
1808
- try {
1809
- const qemuVersion = await qemuHelper . getQemuVersion ( qemuPath ) ;
1810
- if ( qemuPath ) {
1811
- telemetryRecords . qemuPath = qemuPath ;
1830
+ if ( telemetryRecords . provider === 'libkrun' ) {
1831
+ // add krunkit version
1832
+ try {
1833
+ const krunkitVersion = await krunkitHelper . getKrunkitVersion ( krunkitPath ) ;
1834
+ if ( krunkitPath ) {
1835
+ telemetryRecords . krunkitPath = krunkitPath ;
1836
+ }
1837
+ telemetryRecords . krunkitVersion = krunkitVersion ;
1838
+ } catch ( error ) {
1839
+ console . trace ( 'unable to check krunkit version' , error ) ;
1840
+ telemetryRecords . errorKrunkitVersion = error ;
1812
1841
}
1813
- telemetryRecords . qemuVersion = qemuVersion ;
1814
- } catch ( error ) {
1815
- console . trace ( 'unable to check qemu version' , error ) ;
1816
- telemetryRecords . errorQemuVersion = error ;
1817
1842
}
1818
1843
} else if ( extensionApi . env . isWindows ) {
1819
1844
// try to get wsl version
@@ -1856,6 +1881,7 @@ export async function createMachine(
1856
1881
let provider : string | undefined ;
1857
1882
if ( params [ 'podman.factory.machine.provider' ] ) {
1858
1883
provider = getProviderByLabel ( params [ 'podman.factory.machine.provider' ] ) ;
1884
+ telemetryRecords . provider = provider ;
1859
1885
}
1860
1886
1861
1887
// cpus
0 commit comments