{"id":7732,"date":"2021-01-21T23:40:52","date_gmt":"2021-01-21T20:40:52","guid":{"rendered":"https:\/\/kifarunix.com\/?p=7732"},"modified":"2024-03-19T20:44:05","modified_gmt":"2024-03-19T17:44:05","slug":"list-running-and-stopped-vms-on-kvm","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/list-running-and-stopped-vms-on-kvm\/","title":{"rendered":"List Running and Stopped VMS on KVM"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1012\" height=\"342\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/01\/list-running-stopped_kvm-vms.png\" alt=\"List Running and Stopped VMS on KVM\" class=\"wp-image-7734\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/01\/list-running-stopped_kvm-vms.png?v=1611225486 1012w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/01\/list-running-stopped_kvm-vms-768x260.png?v=1611225486 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/01\/list-running-stopped_kvm-vms-150x51.png?v=1611225486 150w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/01\/list-running-stopped_kvm-vms-300x101.png?v=1611225486 300w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/01\/list-running-stopped_kvm-vms-696x235.png?v=1611225486 696w\" sizes=\"(max-width: 1012px) 100vw, 1012px\" \/><\/figure><\/div>\n\n\n<p>Follow through this guide to learn how to list running and stopped vms on KVM. <a aria-label=\"KVM (opens in a new tab)\" href=\"https:\/\/www.linux-kvm.org\/page\/Main_Page\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">KVM<\/a>, an acronym for Kernel-based Virtual Machine, <em>is an open source virtualization technology built into Linux. Specifically,&nbsp;KVM&nbsp;lets you turn Linux into a&nbsp;hypervisor&nbsp;that allows a host machine to run multiple, isolated virtual environments called guests or virtual machines (VMs)<\/em>.<\/p>\n\n\n\n<p>So you could be using KVM to run your virtual machines and wondering how you can list running and stopped VMS? Well, as much as it is possible to get this information from the KVM UI, the terminal centric nerds can also be able to obtain the same information from the command line.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Listing Running and Stopped VMS on KVM<\/h2>\n\n\n\n<p>KVM ships with a command line tool called <code><strong>virsh<\/strong><\/code>, which is the main interface for managing virsh guest domains. The program can be used to create, pause, and shutdown domains. It can also be used to list current domains.<\/p>\n\n\n\n<p>You can use the <code><strong>virsh<\/strong><\/code> command with the domain monitoring option, <strong><code>list<\/code><\/strong>.<\/p>\n\n\n\n<p>The basic command syntax is;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>virsh list<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>virsh list [OPTION]<\/code><\/pre>\n\n\n\n<p>Where [OPTION] can be one of the very many options as shown in the help page. See below output from <code><strong>virsh list --help<\/strong><\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  NAME\n    list - list domains\n\n  SYNOPSIS\n    list &#91;--inactive] &#91;--all] &#91;--transient] &#91;--persistent] &#91;--with-snapshot] &#91;--without-snapshot] &#91;--with-checkpoint] &#91;--without-checkpoint] &#91;--state-running] &#91;--state-paused] &#91;--state-shutoff] &#91;--state-other] &#91;--autostart] &#91;--no-autostart] &#91;--with-managed-save] &#91;--without-managed-save] &#91;--uuid] &#91;--name] &#91;--table] &#91;--managed-save] &#91;--title]\n\n  DESCRIPTION\n    Returns list of domains.\n\n  OPTIONS\n    --inactive       list inactive domains\n    --all            list inactive &amp; active domains\n    --transient      list transient domains\n    --persistent     list persistent domains\n    --with-snapshot  list domains with existing snapshot\n    --without-snapshot  list domains without a snapshot\n    --with-checkpoint  list domains with existing checkpoint\n    --without-checkpoint  list domains without a checkpoint\n    --state-running  list domains in running state\n    --state-paused   list domains in paused state\n    --state-shutoff  list domains in shutoff state\n    --state-other    list domains in other states\n    --autostart      list domains with autostart enabled\n    --no-autostart   list domains with autostart disabled\n    --with-managed-save  list domains with managed save state\n    --without-managed-save  list domains without managed save\n    --uuid           list uuid's only\n    --name           list domain names only\n    --table          list table (default)\n    --managed-save   mark inactive domains with managed save state\n    --title          show domain title<\/code><\/pre>\n\n\n\n<p>In this tutorial, we are only interested in listing KVM guest vms that are either in running, stopped\/shutoff, or paused state.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">List Running VMS on KVM<\/h3>\n\n\n\n<p>By default, when you run <code><strong>virsh list<\/strong><\/code> command with no other option, it lists currently running or paused vms;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>virsh list<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code> Id   Name                State\n-----------------------------------\n 5    ubuntu20.04-clone   paused\n 6    ubuntu20.04         running<\/code><\/pre>\n\n\n\n<p>If you want to explicitly list running vms, then run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>virsh list --state-running<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code> Id   Name          State\n-----------------------------\n 6    ubuntu20.04   running<\/code><\/pre>\n\n\n\n<p>You can also get the vms in various states, including the running state by using the <code><strong>--all<\/strong><\/code> option.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>virsh list --all<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code> Id   Name                State\n------------------------------------\n 5    ubuntu20.04-clone   paused\n<strong> 6    ubuntu20.04         running\n<\/strong> -    kolla-ansible       shut off<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">List Stopped VMS on KVM<\/h3>\n\n\n\n<p>To list stopped KVM virtual machines, you can pass the <code><strong>--state-shutoff<\/strong><\/code> option to <code><strong>virsh list<\/strong><\/code> command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>virsh list --state-shutoff<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code> Id   Name            State\n--------------------------------\n -    kolla-ansible   shut off<\/code><\/pre>\n\n\n\n<p>Similarly, you can use the &#8211;all option to check vms in all states, including stopped vms;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>virsh list --all<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code> Id   Name                State\n------------------------------------\n 5    ubuntu20.04-clone   paused\n<strong> 6    ubuntu20.04         running\n<\/strong> -    kolla-ansible       shut off<\/code><\/pre>\n\n\n\n<p>You can list other states of the KVM virtual machines by passing specific state option to <code><strong>virsh list<\/strong><\/code> command.<\/p>\n\n\n\n<p>That is how easy it is to list running or stopped vms on KVM.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Other tutorials<\/h3>\n\n\n\n<p><a aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-clone-kvm-virtual-machines\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">How to Clone KVM Virtual Machines<\/a><\/p>\n\n\n\n<p><a aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-fix-qemu-kvm-not-connected-error-on-ubuntu-20-04\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">How to fix QEMU\/KVM Not Connected Error on Ubuntu 20.04<\/a><\/p>\n\n\n\n<p><a aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/use-virtualbox-vms-on-kvm\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">Use VirtualBox VMs on KVM<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-to-rename-kvm-virtual-machine-with-virsh-command\/\" target=\"_blank\" aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener\" class=\"rank-math-link\">How to Rename KVM Virtual Machine with virsh command<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow through this guide to learn how to list running and stopped vms on KVM. KVM, an acronym for Kernel-based Virtual Machine, is an open<\/p>\n","protected":false},"author":1,"featured_media":7734,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[112,121,36],"tags":[113,3049,3051,3050,3052,3055,3056,3053,3054],"class_list":["post-7732","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kvm","category-howtos","category-virtualization","tag-kvm","tag-list-running-vms-on-kvm","tag-list-running-vms-with-virsh-command","tag-list-stopped-vms-on-kvm","tag-list-stopped-vms-with-virsh-command","tag-running-vms","tag-stopped-kvm-vms","tag-virsh-list","tag-virsh-list-all","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/7732"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=7732"}],"version-history":[{"count":3,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/7732\/revisions"}],"predecessor-version":[{"id":21959,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/7732\/revisions\/21959"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/7734"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=7732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=7732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=7732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}