unix:virtualization:virtlib:quickreference
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
unix:virtualization:virtlib:quickreference [2020/10/17 02:25] – created rodolico | unix:virtualization:virtlib:quickreference [2021/04/21 23:18] – rodolico | ||
---|---|---|---|
Line 7: | Line 7: | ||
===== virsh ===== | ===== virsh ===== | ||
- | The main controller for virt-lib. The basic format of the command is <code bash> | + | The main controller for virt-lib. The basic format of the command is <code bash> |
+ | |||
+ | Some common commands are: | ||
* **list --all** - list all domains virt-lib knows about and show their state (running, off, whatever) | * **list --all** - list all domains virt-lib knows about and show their state (running, off, whatever) | ||
+ | * **vncdisplay //name//** - show vnc display number (not port) assigned | ||
+ | * **dommemstat //name//** - show allocated RAM | ||
+ | * **domstats //name// | grep vcpu.current** - displays number of virtual cpu's assigned | ||
* **start //name//** - starts the domain named **name** (name from list --all) | * **start //name//** - starts the domain named **name** (name from list --all) | ||
+ | * **reboot //name//** | ||
+ | * **shutdown //name//** | ||
+ | * **dumpxml //name//** dumps the config to STDOUT | ||
+ | * **list --autostart** - list all domains which will autostart | ||
+ | * **autostart domain** - set domain to be autostarted in the future | ||
+ | * **autostart --disable domain** - unset autostart flag for domain | ||
+ | * **console domain** - attaches to the serial console of domain assuming the port has been set up. | ||
* Attach/ | * Attach/ | ||
* attach-interface --domain pxe --type bridge --source br1 --model virtio --config --live | * attach-interface --domain pxe --type bridge --source br1 --model virtio --config --live | ||
* detach-interface --domain pxe --type bridge --mac 52: | * detach-interface --domain pxe --type bridge --mac 52: | ||
+ | * Remove virtual image (config file only)< | ||
==== Remove a network from the entire system ==== | ==== Remove a network from the entire system ==== | ||
Line 28: | Line 41: | ||
</ | </ | ||
- | domxml | + | ==== New Install of Windows with virtio ==== |
+ | |||
+ | // | ||
+ | ]] will do the trick with only one extra step. | ||
+ | |||
+ | - Add the --print-xml flag to virt-install, | ||
+ | - Manually edit the resulting xml file, adding a second cdrom drive (copy/ | ||
+ | - Change the drive letter | ||
+ | - Change the target to point to virtio-win.iso | ||
+ | - run virsh create name_of_xml_file to begin the installation | ||
+ | |||
+ | |||
+ | ==== Upgrading a disk to virtio (Unix) ==== | ||
+ | |||
+ | I messed up and did not use virtio as the bus for one of my setups, which resulted in horrible disk I/O. I could have rebuilt the virtual (it was a simple install and I had not gone very far), but I decided to learn how to do it the "right way". The trick here is to detach the disk, then re-attach it with the proper parameters. | ||
+ | |||
+ | **Warning** Linux (and FreeBSD) have the virtio drivers built in, but Microsoft products do not. Read the section on Microsoft products if you are trying to do this with Windows. | ||
+ | |||
+ | In my case, I wanted to reconfigure the boot drive, so I needed the machine down. It was running under the scsi bus, and I wanted virtio. Note that his is using LVM2 as the back end. | ||
+ | |||
+ | <code bash> | ||
+ | # get a list of all the block devices | ||
+ | virsh domblklist router | ||
+ | # detach the first drive (sda) from the domain router | ||
+ | virsh detach-disk router sda --config | ||
+ | # reattach it using the virtio bus. | ||
+ | virsh attach-disk router / | ||
+ | </ | ||
+ | |||
+ | Normally, you attach/ | ||
+ | |||
+ | ==== Upgrading a disk to virtio (Windows) ==== | ||
+ | |||
+ | For Windows, you need to have the correct device drivers installed before you change the disk. This assumes the domain is running | ||
+ | - Get a copy of the Windows VirtIO-win in iso onto your machine, someplace virsh can access, and mount the ISO | ||
+ | - Download ISO<code bash>cd / | ||
+ | - Mount it on a running system< | ||
+ | - Create a temporary disk and attach it. Use virtio for the format of it. | ||
+ | - <code bash> | ||
+ | - Open your console to the windows domain | ||
+ | - Find the new diskdisk (sdb). It will have a yellow triangle, indicating it can not be read because there is no device driver. Right click and say " | ||
+ | - Shut down your Windows guest | ||
+ | - Detach, then attach the primary drive.< | ||
+ | # get a list of all the block devices | ||
+ | virsh domblklist router | ||
+ | # detach the first drive (sda) from the domain router | ||
+ | virsh detach-disk domainname sda --config | ||
+ | # reattach it using the virtio bus. | ||
+ | virsh attach-disk domainname / | ||
+ | </ | ||
+ | - Start the Windows guest back up. Since the drivers are already installed, it should come back up. | ||
+ | |||
+ | I did this with a Windows 10 installation on my workstation. Prior to using virtio, it would take, literally, 5-7 minutes after boot before I could do anything, and it was very sluggish after that. Once I used virtio, it was almost bare hardware speeds. | ||
+ | |||
+ | ===== Shutdown and restart of Windows guests ===== | ||
+ | |||
+ | ==== Problems shutting down with //virsh// ==== | ||
+ | After installing the win-virtio package, you can use qemu-guest-agent to manage shutdown and reboot. This is much more reliable than using ACPI. | ||
+ | |||
+ | Edit the guest | ||
+ | <code bash> | ||
+ | virsh edit DOMAIN | ||
+ | </ | ||
+ | |||
+ | Place the following block under the < | ||
+ | |||
+ | <code xml> | ||
+ | <channel type=" | ||
+ | <source mode=" | ||
+ | <target type=" | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | You will need to restart the virtual before the changes take effect. Once that is done, however, you can use the following commands much more reliably. | ||
+ | <code bash> | ||
+ | virsh shutdown DOMAIN | ||
+ | virsh reboot DOMAIN | ||
+ | </ | ||
+ | |||
+ | ==== Windows servers will not restart ==== | ||
+ | |||
+ | I'm having a problem with Windows virtuals not rebooting. When you issue the restart command, they shut off and don't come back up. As a band aid, I have a script running on the hypervisor with a cron job, every 5 minutes. | ||
+ | |||
+ | |||
+ | ===== Replacing Network Interfaces ===== | ||
+ | |||
+ | Sometimes you need to undefine and redefine a network interface. This is actually fairly simple to do. | ||
+ | |||
+ | <code bash> | ||
+ | # get a list of all network interfaces in domain | ||
+ | virsh domiflist domain | ||
+ | # remove the one you want. Use values (type, mac) from above command | ||
+ | virsh detach-interface domain --type bridge --mac ##:##:##:##:##:## | ||
+ | # redefine it. Use values from above command, or change as needed | ||
+ | virsh attach-interface domain --type bridge --source br_private --mac ##:##:##:##:##:## | ||
+ | </ | ||
+ | |||
+ | In this example, //domain// is the name of the domain to be worked on. I use domiflist to get information about the network interfaces as I need the type and mac. The --config makes it permanent, writing it to the config file. | ||
+ | |||
+ | In my case, I had built a Windows domain without using virtio, and I wanted to change it. This was actually the simplest way I found to do it. | ||
+ | ==== Links ==== | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// |
unix/virtualization/virtlib/quickreference.txt · Last modified: 2023/02/26 17:12 by rodolico