Sys::De...lization(3)

πŸ“¦
version 0.107 Β· 2 versions
, in fedora 43

✨ NAME ✨

okay so bestie, welcome to Sys::Detect::Virtualization β€” it's the little Perl module that sniffs around and tells you if your UNIX box is secretly running as a virtual machine πŸ’… no cap, it literally just detects whether you're a guest under virtualization.


🌸 VERSION 🌸

Version 0.107 β€” she's giving vintage but she works πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

the vibe check, in code form:

use Sys::Detect::Virtualization;

my $detector = eval { Sys::Detect::Virtualization->new() };
if( $@ ) {
    print "Detector may not be supported for your platform.  Error was: $@\n";
}

my @found = $detector->detect();
if( @found ) {
    print "Possible virtualized system.  May be running under:\n";
    print "\t$_\n" for @found;
}

πŸŽ€ DESCRIPTION πŸŽ€

This module is out here trying to figure out whether your system is running as a guest under virtualization, and it does it with a bunch of heuristics πŸ” (fancy word for "educated guessing, bestie"). It's not one perfect test β€” it's a whole squad of little checks vibing together.


πŸ’œ METHODS πŸ’œ

πŸ‘‘ Class Methods

  • new ( $args ) β€” builds you a fresh detector object. Slays on success and hands you the object back. Fails? It dies. πŸ’€
heads up: this constructor will fail if the system isn't running a supported OS. Currently, only Linux is supported. sorry to the BSD girlies 😭

$args is an optional hash reference with extra stuff for the constructor. Right now the supported keys are:

  • verbose β€” set to 1 if you want verbose debugging output, 0 if you don't. Defaults to 0.
  • ignore_host β€” set to 1 if we should report no virtualization whenever a virtualization host (not a guest) is detected. Defaults to 1.

🌈 Instance Methods

  • detect ( ) β€” runs the detection heuristics and returns a list of possible virtualization systems, or an empty list if it found nothing. Hits come back ordered from most likely to least likely. ✨
fr fr, not detecting anything does NOT mean the system isn't virtualized β€” it just means we couldn't detect it. absence of evidence, bestie, not evidence of absence πŸ™ˆ
  • guess ( ) β€” runs the heuristics and returns a single answer based on the "best guess" available. Currently that's defined as the virt platform with the most heuristic hits. main character energy only, one winner πŸ‘‘

🧚 Internal Methods

You probably shouldn't ever need to call these β€” they're backstage, iykyk πŸ™ˆ

  • get_detectors ( ) β€” returns a list of all detector subroutines for the given instance.
  • _find_bin ( $command ) β€” returns the full path to the given command by searching $ENV{PATH}. If it's not in the path variable, the directories /usr/sbin, /usr/bin, /sbin, and /bin get appended.
  • _fh_apply_patterns ( $fh, $patterns ) β€” checks the data from $fh against the patterns in $patterns, line by line.

$patterns is a listref read pairwise. The first item of each pair is the pattern, and the second item of each pair is a list of names of virt solutions detected by the pattern.

  • _check_command_output ( $command, $patterns ) β€” checks the output of $command against the patterns in $patterns, line by line.

$patterns is a listref read pairwise. The first item of each pair is the pattern, and the second item of each pair is the name of the virt solution detected by the pattern.

  • _check_file_contents ( $fileglob, $patterns ) β€” checks the content of each filename in $fileglob against the patterns in $patterns, line by line.

$fileglob is a glob that returns zero or more filenames.

$patterns is a listref read pairwise. The first item of each pair is the pattern, and the second item of each pair is the name of the virt solution detected by the pattern.

  • _check_path_exists ( $paths ) β€” checks whether each path in $paths exists.

$paths is a listref read pairwise. The first item of each pair is the path name, and the second item of each pair is the name of the virt solution detected by the existence of that $path.


πŸ’– AUTHOR πŸ’–

Dave O'Neill, <dmo@dmo.ca> β€” legend behavior, honestly 🫢


πŸ’€ BUGS πŸ’€

Known issues, bestie, let's be transparent:

  • No support for non-Linux platforms. Feel free to contribute an appropriate Sys::Detect::Virtualization::foo class for your platform. (be the change you want to see ✨)
  • No weighting of tests so that high-confidence checks can be done first. Patches welcome. πŸ‘€

Please report any bugs or feature requests to bug-sys-detect-virtualization at rt.cpan.org, or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sys-Detect-Virtualization>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. so you literally never get ghosted πŸ’…


🌟 SUPPORT 🌟

You can find documentation for this module with the perldoc command.

perldoc Sys::Detect::Virtualization

You can also look for information at:

  • RT: CPAN's request tracker

<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sys-Detect-Virtualization>

  • AnnoCPAN: Annotated CPAN documentation

<http://annocpan.org/dist/Sys-Detect-Virtualization>

  • CPAN Ratings

<http://cpanratings.perl.org/d/Sys-Detect-Virtualization>

  • Search CPAN

<http://search.cpan.org/dist/Sys-Detect-Virtualization/>

  • The author's blog

<http://www.dmo.ca/blog/>


Copyright (C) 2009 Roaring Penguin Software Inc.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See <http://dev.perl.org/licenses/> for more information.


okay that's the whole page, bestie, you ate it all up πŸ“ this was perl v5.42.0, dated 2025-07-25, and she's filed under Sys::De...lization(3) β€” iconic, no notes, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from