{"id":207,"date":"2024-07-11T16:59:29","date_gmt":"2024-07-11T20:59:29","guid":{"rendered":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/?p=207"},"modified":"2024-10-11T09:03:50","modified_gmt":"2024-10-11T13:03:50","slug":"using-kvm-libvirt-qemu","status":"publish","type":"post","link":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/?p=207","title":{"rendered":"Using KVM\/libvirt\/qemu"},"content":{"rendered":"\n<p>Setup KVM in Linux<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Install virsh:\n\n$ sudo apt-get install libvirt-bin<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>This can be local, or even remote. In most cases, if you want to manage VMs running on the local hypervisor:<br>$ virsh connect qemu:\/\/\/system<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>List any existing VMs:<br>$ virsh list<\/code><\/pre>\n\n\n\n<p>You can export the XML of an existing virtual machine:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ virsh dumpxml myoldvm &gt; ~\/myoldvm.xml<\/code><\/pre>\n\n\n\n<p>And then edit myoldvm.xml, which should be rather straightforward. For more information about libvirt XML format, see:<br>http:\/\/libvirt.org\/format.html<\/p>\n\n\n\n<p>Once you have an XML file describing the new virtual machine you want to create, import it into virsh, and run it immediately:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ virsh create ~\/myoldvm.xml<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>See if it worked:<br>$ virsh list<\/code><\/pre>\n\n\n\n<p>Working with a Running Virtual Machine:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ virsh start mynewvm<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ virsh reboot mynewvm<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ virsh shutdown mynewvm<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ virsh suspend mynewvm<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ virsh resume mynewvm<\/code><\/pre>\n\n\n\n<p>To delete a virtual machine, first terminate it (if running), and then undefine it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ virsh destroy mynewvm<br>$ virsh undefine mynewvm<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Setup KVM in Linux You can export the XML of an existing virtual machine: And then edit myoldvm.xml, which should be rather straightforward. For more information about libvirt XML format, see:http:\/\/libvirt.org\/format.html Once you have an XML file describing the new virtual machine you want to create, import it into virsh, and run it immediately: Working [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-207","post","type-post","status-publish","format-standard","hentry","category-kvm"],"_links":{"self":[{"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=207"}],"version-history":[{"count":1,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/207\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}