kvm

JSON

rev 72  |  foxhop  |  1389007498000  |  JSON

rev 71
rev 72
f1KVM guest managementf1KVM guest management
2=======================2=======================
n3 n
4.. contents:: 3.. contents:: 
54
7Install packages 6Install packages 
8===============================7===============================
n9 n
10**Debian or Ubuntu**8**Debian or Ubuntu**
119
23KVM virsh cheat sheet!21KVM virsh cheat sheet!
24============================22============================
n25 n
26This is a list of commands to use in the virsh cli.23This is a list of commands to use in the virsh cli.
2724
44List running guests 41List running guests 
45---------------------------------------------- 42---------------------------------------------- 
n46 n
47**xen** 43**xen** 
48 | xm list 44 | xm list 
54Start a guest 50Start a guest 
55---------------------------------------------- 51---------------------------------------------- 
n56 n
57**xen** 52**xen** 
58 | xm create /etc/xen/<dom name>53 | xm create /etc/xen/<dom name>
64Console to guest59Console to guest
65---------------------------------------------- 60---------------------------------------------- 
n66 n
67**xen** 61**xen** 
68 xm console <dom name>62 xm console <dom name>
73Shutdown a guest 67Shutdown a guest 
74---------------------------------------------- 68---------------------------------------------- 
n75 n
76**xen** 69**xen** 
77 xm shutdown <dom name> 70 xm shutdown <dom name> 
98Autostart guest on reboot 91Autostart guest on reboot 
99---------------------------------------------- 92---------------------------------------------- 
n100 n
101**xen** 93**xen** 
102 ln -s /etc/xen/<dom name> /etc/xen/auto/<dom name>94 ln -s /etc/xen/<dom name> /etc/xen/auto/<dom name>
126Quit virsh cli118Quit virsh cli
127-----------------119-----------------
n128 n
129**kvm** 120**kvm** 
130 virsh quit121 virsh quit
136Virtual Serial Console configuration127Virtual Serial Console configuration
137======================================128======================================
n138 n
139**From the KVM host run:**129**From the KVM host run:**
140130
165Vmbuilder Example155Vmbuilder Example
166======================156======================
n167 n
168This example assumes ubuntu linux.157This example assumes ubuntu linux.
169158
170Install vmbuilder159Install vmbuilder
171---------------------160---------------------
n172 n
173.. code-block:: python161.. code-block:: python
174162
177Display Help vmbuilder165Display Help vmbuilder
178--------------------------------166--------------------------------
n179 n
180.. code-block:: python167.. code-block:: python
181168
227virt-install214virt-install
228================215================
n229 n
230debian netboot example216debian netboot example
231---------------------------217---------------------------
328  <disk type='file' device='disk'>314  <disk type='file' device='disk'>
329    <driver name='qemu' type='raw'/>315    <driver name='qemu' type='raw'/>
t330    <source file='/KVMROOT/cammy-var.img'/>t316    <source file='/KVMROOT/cammy-aux.img'/>
331    <target dev='vdb' bus='virtio'/>317    <target dev='vdb' bus='virtio'/>
332  <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>318  <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
rev 71  |  foxhop  |  1370116575000  |  JSON

rev 70
rev 71
228================228================
229229
nn230debian netboot example
231---------------------------
232 
230This method shows the virt-install script installing from a debian netboot image233This method shows the virt-install script installing from a debian netboot image
> hosted on the internet> hosted on the internet
231234
245 --extra-args="auto=true priority=critical keymap=us locale=en_US hostname=$HOST248 --extra-args="auto=true priority=critical keymap=us locale=en_US hostname=$HOST
>NAME domain=$DOMAIN url=http://192.168.1.22/foxhop-debconf-preseed.txt">NAME domain=$DOMAIN url=http://192.168.1.22/foxhop-debconf-preseed.txt"
246249
nn250ubuntu netboot example
251----------------------------
247252
tt253This method shows the virt-install script installing from an ubuntu netboot imag
 >e hosted on the internet
254 
255.. code-block:: bash
256 
257 HOSTNAME=mbison
258 DOMAIN=foxhop.net
259 
260 sudo virt-install \
261 --name=$HOSTNAME \
262 --vcpu=1 \
263 --ram=396 \
264 --disk=/KVMROOT/$HOSTNAME.qcow2,size=10 \
265 --os-type=linux \
266 --autostart \
267 --location=http://archive.ubuntu.com/ubuntu/dists/raring/main/installer-amd64/ 
 >\
268 --extra-args="auto=true priority=critical keymap=us locale=en_US hostname=$HOST
 >NAME domain=$DOMAIN url=http://192.168.1.22/foxhop-debconf-preseed.txt"
248269
249270
rev 70  |  foxhop  |  1368972733000  |  JSON

rev 69
rev 70
243 --autostart \243 --autostart \
244 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \244 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \
t245 --extra-args="auto=true priority=critical keymap=us locale=en_US url=http://192t245 --extra-args="auto=true priority=critical keymap=us locale=en_US hostname=$HOST
>.168.1.22/foxhop-debconf-preseed.txt hostname=$HOSTNAME domain=$DOMAIN">NAME domain=$DOMAIN url=http://192.168.1.22/foxhop-debconf-preseed.txt"
246246
247247
rev 69  |  foxhop  |  1368914160000  |  JSON

rev 68
rev 69
243 --autostart \243 --autostart \
244 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \244 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \
t245 --extra-args="auto=true priority=critical locale=en_US url=http://192.168.1.22/t245 --extra-args="auto=true priority=critical keymap=us locale=en_US url=http://192
>foxhop-debconf-preseed.txt hostname=$HOSTNAME domain=$DOMAIN">.168.1.22/foxhop-debconf-preseed.txt hostname=$HOSTNAME domain=$DOMAIN"
246246
247247
rev 68  |  foxhop  |  1368912750000  |  JSON

rev 67
rev 68
243 --autostart \243 --autostart \
244 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \244 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \
t245 --extra-args="auto=true priority=critical locale=en_US interface=eth0 url=http:t245 --extra-args="auto=true priority=critical locale=en_US url=http://192.168.1.22/
>//192.168.1.22/foxhop-debconf-preseed.txt hostname=$HOSTNAME domain=$DOMAIN">foxhop-debconf-preseed.txt hostname=$HOSTNAME domain=$DOMAIN"
246246
247247
rev 67  |  foxhop  |  1368912476000  |  JSON

rev 66
rev 67
243 --autostart \243 --autostart \
244 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \244 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \
t245 --extra-args="auto=true priority=critical interface=eth0 url=http://192.168.1.2t245 --extra-args="auto=true priority=critical locale=en_US interface=eth0 url=http:
>2/foxhop-debconf-preseed.txt hostname=$HOSTNAME domain=$DOMAIN">//192.168.1.22/foxhop-debconf-preseed.txt hostname=$HOSTNAME domain=$DOMAIN"
246246
247247
rev 66  |  foxhop  |  1368912159000  |  JSON

rev 65
rev 66
232.. code-block:: bash232.. code-block:: bash
233233
t234 sudo virt-install --name=tehforum --vcpu=1 --ram=128 --disk=/KVMROOT/tehforum.qt234 HOSTNAME=tehforum
>cow2,size=10 --os-type=linux --autostart --location=http://ftp.nl.debian.org/deb 
>ian/dists/wheezy/main/installer-amd64/ --extra-args="auto=true priority=critical 
> hostname=tehforum domain=foxhop.net url=http://akuma.foxhop.net:8000/foxhop-deb 
>conf-preseed.txt"Mounting a qcow2 image on the host 
235 DOMAIN=foxhop.net
236 
237 sudo virt-install \
238 --name=$HOSTNAME \
239 --vcpu=1 \
240 --ram=396 \
241 --disk=/KVMROOT/$HOSTNAME.qcow2,size=10 \
242 --os-type=linux \
243 --autostart \
244 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \
245 --extra-args="auto=true priority=critical interface=eth0 url=http://192.168.1.2
 >2/foxhop-debconf-preseed.txt hostname=$HOSTNAME domain=$DOMAIN"
246 
247 
248 
249 
250Mounting a qcow2 image on the host
235======================================251======================================
236252
rev 65  |  foxhop  |  1368907994000  |  JSON

rev 64
rev 65
232.. code-block:: bash232.. code-block:: bash
233233
t234 DOMNAME=tehforumt234 sudo virt-install --name=tehforum --vcpu=1 --ram=128 --disk=/KVMROOT/tehforum.q
 >cow2,size=10 --os-type=linux --autostart --location=http://ftp.nl.debian.org/deb
 >ian/dists/wheezy/main/installer-amd64/ --extra-args="auto=true priority=critical
 > hostname=tehforum domain=foxhop.net url=http://akuma.foxhop.net:8000/foxhop-deb
 >conf-preseed.txt"Mounting a qcow2 image on the host
235 
236 sudo virt-install --name=$DOMNAME --vcpu=1 --ram=128 --os-type=linux --autostar
>t \ 
237 --disk=/KVMROOT/tehforum.qcow2,size=10 \
238 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \
239 --extra-args="auto=true priority=critical interface=auto lang=english console-k
>eymaps-at/keymap=us locale=en_US hostname=$DOMNAME domain=foxhop.net url=http:// 
>www.debian.org/releases/stable/example-preseed.txt" 
240 
241 
242 
243 
244 
245Mounting a qcow2 image on the host
246======================================235======================================
247236
rev 64  |  foxhop  |  1368893989000  |  JSON

rev 63
rev 64
232.. code-block:: bash232.. code-block:: bash
233233
t234 sudo virt-install --name=mbison --ram=256 --disk=/KVMROOT/mbison.qcow2,size=10 t234 DOMNAME=tehforum
>--location=http://ftp.us.debian.org/debian/dists/Debian7.0.0/main/installer-amd6 
>4/ 
235 
236 sudo virt-install --name=$DOMNAME --vcpu=1 --ram=128 --os-type=linux --autostar
 >t \
237 --disk=/KVMROOT/tehforum.qcow2,size=10 \
238 --location=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/ \
239 --extra-args="auto=true priority=critical interface=auto lang=english console-k
 >eymaps-at/keymap=us locale=en_US hostname=$DOMNAME domain=foxhop.net url=http://
 >www.debian.org/releases/stable/example-preseed.txt"
240 
235241
236242
rev 63  |  foxhop  |  1368844413000  |  JSON

rev 62
rev 63
225225
226226
tt227virt-install
228================
229 
230This method shows the virt-install script installing from a debian netboot image
 > hosted on the internet
231 
232.. code-block:: bash
233 
234 sudo virt-install --name=mbison --ram=256 --disk=/KVMROOT/mbison.qcow2,size=10 
 >--location=http://ftp.us.debian.org/debian/dists/Debian7.0.0/main/installer-amd6
 >4/
235 
236 
237 
227238
228Mounting a qcow2 image on the host239Mounting a qcow2 image on the host
rev 62  |  foxhop  |  1363908315000  |  JSON

rev 61
rev 62
289  <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>289  <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
290290
t291SSH to the guest and verify that the disk shows up in *fdisk -l*.  You may now pt291SSH to the guest and verify that the disk shows up in *fdisk -l*.  You may now p
>artition this disk how you like.  For more information on `linux raw filesystem >artition this disk how you like.  For more information view `linux raw filesyste
>management <http://www.foxhop.net/linux-raw-filesystem-management>`_>m management <http://www.foxhop.net/linux-raw-filesystem-management>`_.
292292
rev 61  |  foxhop  |  1363908285000  |  JSON

rev 60
rev 61
289  <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>289  <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
290290
tt291SSH to the guest and verify that the disk shows up in *fdisk -l*.  You may now p
 >artition this disk how you like.  For more information on `linux raw filesystem 
 >management <http://www.foxhop.net/linux-raw-filesystem-management>`_
291292
rev 60  |  foxhop  |  1363908140000  |  JSON

rev 59
rev 60
263263
264 qemu-img info /vms/cammy/cammy-aux.img264 qemu-img info /vms/cammy/cammy-aux.img
tt265 
266Now we need to mount this disk:
267 
268.. code-block:: bash
269 
270 sudo virsh attach-disk cammy /vms/cammy/cammy-aux.img vdb
271 
272That command only mounted the disk.  To make this change permanent we need to al
 >ter the dom's xml:
273 
274.. code-block:: xml
275 
276 # sudo virsh edit cammy
277 
278  <disk type='file' device='disk'>
279    <driver name='qemu' type='qcow2'/>
280    <source file='/KVMROOT/cammy.qcow2'/>
281    <target dev='vda' bus='virtio'/>
282    <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
283  </disk>
284 
285  <disk type='file' device='disk'>
286    <driver name='qemu' type='raw'/>
287    <source file='/KVMROOT/cammy-var.img'/>
288    <target dev='vdb' bus='virtio'/>
289  <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
290 
291 
rev 59  |  foxhop  |  1331486545000  |  JSON

rev 58
rev 59
247This is how you add an additional disk to a guest.  In this example I will be ad247This is how you add an additional disk to a guest.  In this example I will be ad
>ding a 20GB disk image to a guest dom named cammy.>ding a 20GB disk image to a guest dom named cammy.
248248
n249::n249.. code-block:: bash
250250
251 fallocate -l 20g /vms/cammy/cammy-aux.img251 fallocate -l 20g /vms/cammy/cammy-aux.img
252252
n253or:: n253or
254 
255.. code-block:: bash
254256
255 qemu-img create -f qcow2 /vms/cammy/cammy-aux.img 20G257 qemu-img create -f qcow2 /vms/cammy/cammy-aux.img 20G
257If you want to look that the image statistics try this command.259If you want to look that the image statistics try this command.
258260
t259::t261.. code-block:: bash
262 
260263
261 qemu-img info /vms/cammy/cammy-aux.img264 qemu-img info /vms/cammy/cammy-aux.img
rev 58  |  foxhop  |  1331486466000  |  JSON

rev 57
rev 58
251 fallocate -l 20g /vms/cammy/cammy-aux.img251 fallocate -l 20g /vms/cammy/cammy-aux.img
252252
tt253or:: 
254 
255 qemu-img create -f qcow2 /vms/cammy/cammy-aux.img 20G
256 
253If you want to look that the image statistics try this command.257If you want to look that the image statistics try this command.
254258
rev 57  |  foxhop  |  1331480715000  |  JSON

rev 56
rev 57
251 fallocate -l 20g /vms/cammy/cammy-aux.img251 fallocate -l 20g /vms/cammy/cammy-aux.img
252252
n253If you want to look that the image statistics try this commandn253If you want to look that the image statistics try this command.
254254
255::255::
tt256 
256 qemu-img info /vms/cammy/cammy-aux.img257 qemu-img info /vms/cammy/cammy-aux.img
rev 56  |  foxhop  |  1331480693000  |  JSON

rev 55
rev 56
247This is how you add an additional disk to a guest.  In this example I will be ad247This is how you add an additional disk to a guest.  In this example I will be ad
>ding a 20GB disk image to a guest dom named cammy.>ding a 20GB disk image to a guest dom named cammy.
248248
nn249::
249250
nn251 fallocate -l 20g /vms/cammy/cammy-aux.img
250252
tt253If you want to look that the image statistics try this command
254 
255::
256 qemu-img info /vms/cammy/cammy-aux.img
rev 55  |  foxhop  |  1331480369000  |  JSON

rev 54
rev 55
247This is how you add an additional disk to a guest.  In this example I will be ad247This is how you add an additional disk to a guest.  In this example I will be ad
>ding a 20GB disk image to a guest dom named cammy.>ding a 20GB disk image to a guest dom named cammy.
248248
n249fallocate -l 20g /vms/cammy/cammy-aux.imgn
250249
n251Analyze an Disk Imagen
252==========================
253250
t254**This is how**::t
255 
256  qemu-img info cammy.qcow2 
257  image: cammy.qcow2
258  file format: qcow2
259  virtual size: 21G (22548578304 bytes)
260  disk size: 895M
261  cluster_size: 65536
262 
263  qemu-img info cammy-aux.img
264  image: cammy-aux.img
265  file format: raw
266  virtual size: 20G (21474836480 bytes)
267  disk size: 20G
268 
rev 54  |  foxhop  |  1331480240000  |  JSON

rev 53
rev 54
247This is how you add an additional disk to a guest.  In this example I will be ad247This is how you add an additional disk to a guest.  In this example I will be ad
>ding a 20GB disk image to a guest dom named cammy.>ding a 20GB disk image to a guest dom named cammy.
248248
nn249fallocate -l 20g /vms/cammy/cammy-aux.img
249250
nn251Analyze an Disk Image
252==========================
250253
tt254**This is how**::
255 
256  qemu-img info cammy.qcow2 
257  image: cammy.qcow2
258  file format: qcow2
259  virtual size: 21G (22548578304 bytes)
260  disk size: 895M
261  cluster_size: 65536
262 
263  qemu-img info cammy-aux.img
264  image: cammy-aux.img
265  file format: raw
266  virtual size: 20G (21474836480 bytes)
267  disk size: 20G
268 
rev 53  |  foxhop  |  1331478815000  |  JSON

rev 52
rev 53
241241
242242
tt243 
244Add another disk image to a guest
245====================================
246 
247This is how you add an additional disk to a guest.  In this example I will be ad
 >ding a 20GB disk image to a guest dom named cammy.
248 
249 
250 
rev 52  |  foxhop  |  1328651219000  |  JSON

rev 51
rev 52
181181
182 vmbuilder kvm ubuntu --help182 vmbuilder kvm ubuntu --help
nn183 
184Custom vmbuilder string 
185-------------------------------                 
186                        
187mbison example  
188 
189.. code-block:: bash                    
190                
191 VMNAME=mbison                  
192 mkdir /vms/$VMNAME                     
193                        
194 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt
 >ual \                   
195 --hostname=$VMNAME --domain='foxhop.net' --rootsize='10240' --mem='1024' \     
 >                
196 --ip=192.168.1.51 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \         
 >        
197 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose                
 >        
198                                
199cammy example                   
200                        
201.. code-block:: bash                    
202                        
203 VMNAME=cammy                   
204 mkdir /vms/$VMNAME                     
205                        
206 sudo vmbuilder kvm ubuntu       \                      
207     --libvirt=qemu:///system    \                      
208     --suite=lucid               \                      
209     --arch=amd64 -o             \                      
210     --flavour=virtual           \                      
211     --hostname=$VMNAME          \                      
212     --dest=/vms/$VMNAME         \                      
213     --rootsize=20480            \                      
214     --mem=1024                  \                      
215     --bridge=br0                \                      
216     --ip=192.168.1.52           \                      
217     --gw=192.168.1.254          \                      
218     --dns=192.168.1.22          \                      
219     --user=john                 \                      
220     --pass=doe                  \                      
221     --addpkg=openssh-server     \                      
222     --addpkg=acpid              \                      
223     --timezone=EDT              \                      
224     --verbose
183225
184226
197  sudo mount /dev/nbd0p1 /mnt/image239  sudo mount /dev/nbd0p1 /mnt/image
198240
tt241 
242 
rev 51  |  foxhop  |  1315165643000  |  JSON

rev 50
rev 51
182 vmbuilder kvm ubuntu --help182 vmbuilder kvm ubuntu --help
183183
tt184 
185 
186Mounting a qcow2 image on the host
187======================================
188 
189Sometimes it is helpful to be able to mount a drive image under the host system.
 > For example, if the guest doesn't have network support, the only way to transfe
 >r files into and out of the guest will be by the storage devices it can address 
 >or to restore files from a backup image.
190 
191To mount qcow2 images there is (at least in F-11 qemu) very useful qemu-nbd util
 >. It shares image through kernel network block device protocol and this allows t
 >o mount it:
192 
193.. code-block:: bash
194   
195  sudo modprobe nbd max_part=63
196  sudo qemu-nbd -c /dev/nbd0 image.img
197  sudo mount /dev/nbd0p1 /mnt/image
198 
rev 50  |  foxhop  |  1315164896000  |  JSON

rev 49
rev 50
163163
164164
t165 t
166 Vmbuilder Example165Vmbuilder Example
167======================166======================
168167
rev 49  |  foxhop  |  1315164859000  |  JSON

rev 48
rev 49
162162
163163
nn164 
165 
164 Vmbuilder Example166 Vmbuilder Example
165======================167======================
181 vmbuilder kvm ubuntu --help183 vmbuilder kvm ubuntu --help
182184
t183Custom vmbuilder stringt
184-------------------------------
185 
186mbison example 
187 
188.. code-block:: bash
189 
190 VMNAME=mbison
191 mkdir /vms/$VMNAME
192 
193 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt
>ual \ 
194 --hostname=$VMNAME --domain='foxhop.net' --rootsize='10240' --mem='1024' \
195 --ip=192.168.1.51 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
196 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose
197 
198cammy example
199 
200.. code-block:: bash
201 
202 
203 VMNAME=cammy
204 mkdir /vms/$VMNAME
205 
206 sudo vmbuilder kvm ubuntu       \
207     --libvirt=qemu:///system    \
208     --suite=lucid               \
209     --arch=amd64 -o             \
210     --flavour=virtual           \
211     --hostname=$VMNAME          \
212     --dest=/vms/$VMNAME         \
213     --rootsize=20480            \
214     --mem=1024                  \
215     --bridge=br0                \
216     --ip=192.168.1.52           \
217     --gw=192.168.1.254          \
218     --dns=192.168.1.22          \
219     --user=john                 \
220     --pass=doe                  \
221     --addpkg=openssh-server     \
222     --addpkg=acpid              \
223     --timezone=EDT              \ 
224     --verbose
225 
226 
227 
rev 48  |  foxhop  |  1309472490000  |  JSON

rev 47
rev 48
134134
135135
n136configure kvm serial consolen136Virtual Serial Console configuration
137==================================137======================================
138138
139**From the KVM host run:**139**From the KVM host run:**
159 sudo vi /etc/init/ttyS0.conf159 sudo vi /etc/init/ttyS0.conf
160 sudo diff /etc/init/tty06.conf /etc/init/ttyS0.conf160 sudo diff /etc/init/tty06.conf /etc/init/ttyS0.conf
nn161 
162 
163 
161 Vmbuilder Example164 Vmbuilder Example
162======================165======================
223226
224227
t225Mount a qcow2 or raw image filet
226=================================
227 
228The following procedures allow a host to mount a guest image file.  This is usef
>ul when trouble shooting issues with the guest.  The following procedures requir 
>e root access (you can sudo). 
229 
230**qcow2**
231 
232.. code-block:: python
233 
234 modprobe nbd max_part=63
235 qemu-nbd -c /dev/nbd0 image.img
236 mount /dev/nbd0p1 /mnt/image
237 
238**raw**
239 
240.. code-block:: python
241 
242 losetup /dev/loop0 image.img
243 kpartx -a /dev/loop0
244 mount /dev/mapper/loop0p1 /mnt/image
245 
246If there is an LVM present on the image file, you can initialize it by running
247 
248.. code-block:: python
249 
250 vgscan
251 vgchange -ay
252 mount /dev/VolGroupName/LogVolName /mnt/image
253 
254Run the following when finished
255 
256.. code-block:: python
257 
258 umount /mnt/image
259 vgchange -an VolGroupName
260 killall qemu-nbd
261 kpartx -d /dev/loop0
262 losetup -d /dev/loop0
263 
264reference: http://en.wikibooks.org/wiki/QEMU/Images
265 
266 
rev 47  |  foxhop  |  1309467982000  |  JSON

rev 46
rev 47
135135
136configure kvm serial console136configure kvm serial console
n137---------------------------------n137==================================
138138
139**From the KVM host run:**139**From the KVM host run:**
265265
266266
t267Backing up kvm guests with virtbackt
268=======================================
269 
270http://russell.ballestrini.net/virtback-a-python-libvirt-backup-utility-for-kvm/
271 
272download virt-back and place it into usr/local/bin 
273 
274run: *virt-back -h* for a list of options
rev 46  |  foxhop  |  1309467316000  |  JSON

rev 45
rev 46
134134
135135
n136Noten136configure kvm serial console
137------137---------------------------------
138Typically the guests harddrive is not attached, you must add it in the configura
>tion. 
139138
n140Typically the guests memory is set to 100mbs, you might want to change that in tn139**From the KVM host run:**
>he configuration. 
141140
n142Once booted and ssh'd into the VM, cat /etc/network/interfaces to verify that thn141.. code-block:: xml
>e DNS settings are correct. 
143142
n144Debian/ubuntu guest don't have acpid installed by default. (Could change the vmbn143 virsh edit <dom>
>uilder string) 
145144
nn145Then add the following inside the <device></device> directives:
146146
nn147.. code-block:: xml
148 
149 <serial type="pty">
150     <source path="/dev/pts/3" />
151     <target port="1" />
152 </serial>
153 
154**From the Guest run:**
155 
156.. code-block:: xml
157 
158 sudo cp -p /etc/init/tty06.conf /etc/init/ttyS0.conf
159 sudo vi /etc/init/ttyS0.conf
160 sudo diff /etc/init/tty06.conf /etc/init/ttyS0.conf
147Vmbuilder Example161 Vmbuilder Example
148======================162======================
149163
256http://russell.ballestrini.net/virtback-a-python-libvirt-backup-utility-for-kvm/270http://russell.ballestrini.net/virtback-a-python-libvirt-backup-utility-for-kvm/
257271
n258download virtback and place it into usr/local/bin n272download virt-back and place it into usr/local/bin 
259273
t260run: *virtback -h* for a list of optionst274run: *virt-back -h* for a list of options
rev 45  |  foxhop  |  1309396865000  |  JSON

rev 44
rev 45
200     --gw=192.168.1.254          \200     --gw=192.168.1.254          \
201     --dns=192.168.1.22          \201     --dns=192.168.1.22          \
tt202     --user=john                 \
203     --pass=doe                  \
202     --addpkg=openssh-server     \204     --addpkg=openssh-server     \
203     --addpkg=acpid              \205     --addpkg=acpid              \
rev 44  |  foxhop  |  1309395662000  |  JSON

rev 43
rev 44
194     --hostname=$VMNAME          \194     --hostname=$VMNAME          \
195     --dest=/vms/$VMNAME         \195     --dest=/vms/$VMNAME         \
t196     --raw=/vms/$VMNAME.dcow2    \t
197     --rootsize=20480            \196     --rootsize=20480            \
198     --mem=1024                  \197     --mem=1024                  \
rev 43  |  foxhop  |  1309394944000  |  JSON

rev 42
rev 43
190     --libvirt=qemu:///system    \190     --libvirt=qemu:///system    \
191     --suite=lucid               \191     --suite=lucid               \
n192     --flavour=virtual           \ n
193     --arch=amd64 -o             \192     --arch=amd64 -o             \
nn193     --flavour=virtual           \
194     --hostname=$VMNAME          \194     --hostname=$VMNAME          \
195     --dest=/vms/$VMNAME         \195     --dest=/vms/$VMNAME         \
208208
209209
t210 t
211 
212Mount a qcow2 or raw image file210Mount a qcow2 or raw image file
213=================================211=================================
rev 42  |  foxhop  |  1309394858000  |  JSON

rev 41
rev 42
191     --suite=lucid               \191     --suite=lucid               \
192     --flavour=virtual           \ 192     --flavour=virtual           \ 
n193     --arch=amd64                \n193     --arch=amd64 -o             \
194     --hostname=$VMNAME          \194     --hostname=$VMNAME          \
195     --dest=/vms/$VMNAME         \195     --dest=/vms/$VMNAME         \
210210
211211
t212 t
213Mount a qcow2 or raw image file212Mount a qcow2 or raw image file
214=================================213=================================
rev 41  |  foxhop  |  1309394575000  |  JSON

rev 40
rev 41
183.. code-block:: bash183.. code-block:: bash
184184
nn185 
185 VMNAME=cammy186 VMNAME=cammy
186 mkdir /vms/$VMNAME187 mkdir /vms/$VMNAME
187188
t188 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virtt189 sudo vmbuilder kvm ubuntu       \
>ual \ 
189 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 \190     --libvirt=qemu:///system    \
190 --hostname=$VMNAME --domain='foxhop.net' --bridge=br0 \191     --suite=lucid               \
191 --raw=/vms/$VMNAME.dcow2 --rootsize='20480' --mem='1024' \192     --flavour=virtual           \ 
192 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose193     --arch=amd64                \
193 194     --hostname=$VMNAME          \
195     --dest=/vms/$VMNAME         \
196     --raw=/vms/$VMNAME.dcow2    \
197     --rootsize=20480            \
198     --mem=1024                  \
199     --bridge=br0                \
200     --ip=192.168.1.52           \
201     --gw=192.168.1.254          \
202     --dns=192.168.1.22          \
203     --addpkg=openssh-server     \
204     --addpkg=acpid              \
205     --timezone=EDT              \ 
206     --verbose
194207
195208
rev 40  |  foxhop  |  1309383355000  |  JSON

rev 39
rev 40
189 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 \189 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 \
190 --hostname=$VMNAME --domain='foxhop.net' --bridge=br0 \190 --hostname=$VMNAME --domain='foxhop.net' --bridge=br0 \
t191 --raw=/vms/$VMNAME --rootsize='20480' --mem='1024' \t191 --raw=/vms/$VMNAME.dcow2 --rootsize='20480' --mem='1024' \
192 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose192 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose
193193
rev 39  |  foxhop  |  1309382931000  |  JSON

rev 38
rev 39
187187
188 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt188 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt
>ual \>ual \
t189 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 t189 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 \
190 --hostname=$VMNAME --domain='foxhop.net' --bridge=br0 \190 --hostname=$VMNAME --domain='foxhop.net' --bridge=br0 \
191 --raw=/vms/$VMNAME --rootsize='20480' --mem='1024' \191 --raw=/vms/$VMNAME --rootsize='20480' --mem='1024' \
rev 38  |  foxhop  |  1309382757000  |  JSON

rev 37
rev 38
187187
188 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt188 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt
>ual \>ual \
t189 --hostname=$VMNAME --domain='foxhop.net' --rootsize='20480' --mem='1024' \t
190 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \189 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 
190 --hostname=$VMNAME --domain='foxhop.net' --bridge=br0 \
191 --raw=/vms/$VMNAME --rootsize='20480' --mem='1024' \
191 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose192 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose
192193
rev 37  |  foxhop  |  1309381505000  |  JSON

rev 36
rev 37
176 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt176 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt
>ual \>ual \
177 --hostname=$VMNAME --domain='foxhop.net' --rootsize='10240' --mem='1024' \177 --hostname=$VMNAME --domain='foxhop.net' --rootsize='10240' --mem='1024' \
t178 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \t178 --ip=192.168.1.51 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
179 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose179 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose
180180
rev 36  |  foxhop  |  1309381303000  |  JSON

rev 35
rev 36
167-------------------------------167-------------------------------
168168
nn169mbison example 
170 
169.. code-block:: bash171.. code-block:: bash
170172
176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \178 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
177 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose179 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose
tt180 
181cammy example
182 
183.. code-block:: bash
184 
185 VMNAME=cammy
186 mkdir /vms/$VMNAME
187 
188 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt
 >ual \
189 --hostname=$VMNAME --domain='foxhop.net' --rootsize='20480' --mem='1024' \
190 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
191 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose
192 
193 
194 
178195
179196
rev 35  |  foxhop  |  1301097113000  |  JSON

rev 34
rev 35
220220
221reference: http://en.wikibooks.org/wiki/QEMU/Images221reference: http://en.wikibooks.org/wiki/QEMU/Images
tt222 
223 
224Backing up kvm guests with virtback
225=======================================
226 
227http://russell.ballestrini.net/virtback-a-python-libvirt-backup-utility-for-kvm/
228 
229download virtback and place it into usr/local/bin 
230 
231run: *virtback -h* for a list of options
rev 34  |  foxhop  |  1300409809000  |  JSON

rev 33
rev 34
172 mkdir /vms/$VMNAME172 mkdir /vms/$VMNAME
173173
t174 sudo vmbuilder kvm ubuntu --suite=lucid --flavour=virtual \t174 sudo vmbuilder kvm ubuntu --libvirt=qemu:///system --suite=lucid --flavour=virt
 >ual \
175 --hostname=$VMNAME --domain='foxhop.net' --rootsize='10240' --mem='1024' \175 --hostname=$VMNAME --domain='foxhop.net' --rootsize='10240' --mem='1024' \
176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
rev 33  |  foxhop  |  1300409257000  |  JSON

rev 32
rev 33
172 mkdir /vms/$VMNAME172 mkdir /vms/$VMNAME
173173
t174 sudo vmbuilder kvm ubuntu --suite=lucid --flavour=virtual --hostname=$VMNAME --t174 sudo vmbuilder kvm ubuntu --suite=lucid --flavour=virtual \
>domain='foxhop.net' \ 
175 --raw='/vms/$VMNAME/$VMNAME.img' --rootsize='10240' --mem='1024' \175 --hostname=$VMNAME --domain='foxhop.net' --rootsize='10240' --mem='1024' \
176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
177 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose177 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose
rev 32  |  foxhop  |  1300407356000  |  JSON

rev 31
rev 32
172 mkdir /vms/$VMNAME172 mkdir /vms/$VMNAME
173173
n174 sudo vmbuilder kvm ubuntu --suite=lucid --flavour=virtual --hostname=$VMNAME --n174 sudo vmbuilder kvm ubuntu --suite=lucid --flavour=virtual --hostname=$VMNAME --
>domain=foxhop.net \>domain='foxhop.net' \
175 --rootsize=10240 --raw=/vms/$VMNAME/$VMNAME.img --mem=1024 \175 --raw='/vms/$VMNAME/$VMNAME.img' --rootsize='10240' --mem='1024' \
176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
t177 --addpkg=openssh-server --addpkg=acpid --timezone=EDT t177 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --verbose
178178
179179
rev 31  |  foxhop  |  1300404782000  |  JSON

rev 30
rev 31
172 mkdir /vms/$VMNAME172 mkdir /vms/$VMNAME
173173
t174 sudo vmbuilder kvm ubuntu --suite=lucid --flavour=virtual \t174 sudo vmbuilder kvm ubuntu --suite=lucid --flavour=virtual --hostname=$VMNAME --
 >domain=foxhop.net \
175 --hostname=$VMNAME --domain=foxhop.net --rootsize=10240 --raw=/vms/$VMNAME --me175 --rootsize=10240 --raw=/vms/$VMNAME/$VMNAME.img --mem=1024 \
>m=1024 \ 
176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
177 --addpkg=openssh-server --addpkg=acpid --timezone=EDT 177 --addpkg=openssh-server --addpkg=acpid --timezone=EDT 
rev 30  |  foxhop  |  1300404479000  |  JSON

rev 29
rev 30
175 --hostname=$VMNAME --domain=foxhop.net --rootsize=10240 --raw=/vms/$VMNAME --me175 --hostname=$VMNAME --domain=foxhop.net --rootsize=10240 --raw=/vms/$VMNAME --me
>m=1024 \>m=1024 \
176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
t177 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --manifest=/vms/$VMNAME/mt177 --addpkg=openssh-server --addpkg=acpid --timezone=EDT 
>anifest.txt 
178 
178179
179180
rev 29  |  foxhop  |  1300402733000  |  JSON

rev 28
rev 29
172 mkdir /vms/$VMNAME172 mkdir /vms/$VMNAME
173173
t174 sudo vmbuilder kvm ubuntu -o --libvirt=qemu:///system --suite=lucid --flavour=vt174 sudo vmbuilder kvm ubuntu --suite=lucid --flavour=virtual \
>irtual \ 
175 --hostname=$VMNAME --domain=foxhop.net --rootsize=10240 --raw=/vms/$VMNAME --me175 --hostname=$VMNAME --domain=foxhop.net --rootsize=10240 --raw=/vms/$VMNAME --me
>m=1024 \>m=1024 \
176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \176 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
rev 28  |  foxhop  |  1300402249000  |  JSON

rev 27
rev 28
50**kvm** 50**kvm** 
51 | virsh list 51 | virsh list 
n52 | virsh dominfo <guest name> n52 | virsh dominfo <dom name> 
5353
54Start a guest 54Start a guest 
5656
57**xen** 57**xen** 
n58 | xm create /etc/xen/<guest name> n58 | xm create /etc/xen/<dom name>
5959
60**kvm** 60**kvm** 
n61 | virsh create /etc/libvirt/qemu/<guest name>.xmln61 | virsh create /etc/libvirt/qemu/<dom name>.xml
62 | virsh start <domain> 62 | virsh start <dom name>
6363
64Console to guest64Console to guest
6666
67**xen** 67**xen** 
n68 xm console <guest name> n68 xm console <dom name>
6969
70**kvm** 70**kvm** 
n71 virsh console <guest name> n71 virsh console <dom name>
7272
73Shutdown a guest 73Shutdown a guest 
7575
76**xen** 76**xen** 
n77 xm shutdown <guest name> n77 xm shutdown <dom name> 
7878
79**kvm** 79**kvm** 
n80 virsh shutdown <guest name> n80 virsh shutdown <dom name> 
8181
82This command doesn't always work...  82This command doesn't always work...  
84Be sure the guests XML file has the following entry:84Be sure the guests XML file has the following entry:
8585
n86 <feature> <acpi/> </feature>n86 | <feature> 
87 |  <acpi/>
88 | </feature>
8789
88Also make sure the apci is installed on the guest operating system.90Also make sure the apci is installed on the guest operating system.
98100
99**xen** 101**xen** 
n100 ln -s /etc/xen/<guest name> /etc/xen/auto/<guest name> n102 ln -s /etc/xen/<dom name> /etc/xen/auto/<dom name>
101103
102**kvm** 104**kvm** 
n103 virsh autostart <guest name> n105 virsh autostart <dom name>
104106
105Edit a guests configuration file107Edit a guests configuration file
109111
110**kvm**  112**kvm**  
n111 virsh edit <domain>n113 virsh edit <dom name>
112114
113115
117----------------------------119----------------------------
118**xen**120**xen**
n119 xm destroy <guest>n121 xm destroy <dom name>
120122
121**kvm**123**kvm**
n122 virsh destroy <domain>n124 virsh destroy <dom name>
123125
124Quit virsh cli126Quit virsh cli
126128
127**kvm** 129**kvm** 
t128 virsh quitt130 virsh quit
129131
130132
rev 27  |  foxhop  |  1300401993000  |  JSON

rev 26
rev 27
141141
142Debian/ubuntu guest don't have acpid installed by default. (Could change the vmb142Debian/ubuntu guest don't have acpid installed by default. (Could change the vmb
>uilder string)>uilder string)
nn143 
144 
145Vmbuilder Example
146======================
147 
148This example assumes ubuntu linux.
149 
150Install vmbuilder
151---------------------
152 
153.. code-block:: python
154 
155 sudo apt-get install python-vm-builder
156 
157Display Help vmbuilder
158--------------------------------
159 
160.. code-block:: python
161 
162 vmbuilder kvm ubuntu --help
163 
164Custom vmbuilder string
165-------------------------------
166 
167.. code-block:: bash
168 
169 VMNAME=mbison
170 mkdir /vms/$VMNAME
171 
172 sudo vmbuilder kvm ubuntu -o --libvirt=qemu:///system --suite=lucid --flavour=v
 >irtual \
173 --hostname=$VMNAME --domain=foxhop.net --rootsize=10240 --raw=/vms/$VMNAME --me
 >m=1024 \
174 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
175 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --manifest=/vms/$VMNAME/m
 >anifest.txt
176 
177 
143178
144Mount a qcow2 or raw image file179Mount a qcow2 or raw image file
182217
183reference: http://en.wikibooks.org/wiki/QEMU/Images218reference: http://en.wikibooks.org/wiki/QEMU/Images
t184 t
185 
186Vmbuilder Example
187======================
188 
189This example assumes ubuntu linux.
190 
191Install vmbuilder
192---------------------
193 
194.. code-block:: python
195 
196 sudo apt-get install python-vm-builder
197 
198Display Help vmbuilder
199--------------------------------
200 
201.. code-block:: python
202 
203 vmbuilder kvm ubuntu --help
204 
205Custom vmbuilder string
206-------------------------------
207 
208.. code-block:: bash
209 
210 VMNAME=mbison
211 mkdir /vms/$VMNAME
212 
213 sudo vmbuilder kvm ubuntu -o --libvirt=qemu:///system --suite=lucid --flavour=v
>irtual \ 
214 --hostname=$VMNAME --domain=foxhop.net --rootsize=10240 --raw=/vms/$VMNAME --me
>m=1024 \ 
215 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
216 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --manifest=/vms/$VMNAME/m
>anifest.txt 
217 
rev 26  |  foxhop  |  1300401882000  |  JSON

rev 25
rev 26
189This example assumes ubuntu linux.189This example assumes ubuntu linux.
190190
n191**install vmbuilder**n191Install vmbuilder
192---------------------
192193
193.. code-block:: python194.. code-block:: python
195 sudo apt-get install python-vm-builder196 sudo apt-get install python-vm-builder
196197
n197**display help vmbuilder**n198Display Help vmbuilder
199--------------------------------
198200
199.. code-block:: python201.. code-block:: python
201 vmbuilder kvm ubuntu --help203 vmbuilder kvm ubuntu --help
202204
t203**my custom vmbuilder string**t205Custom vmbuilder string
206-------------------------------
204207
205.. code-block:: bash208.. code-block:: bash
rev 25  |  foxhop  |  1300401721000  |  JSON

rev 24
rev 25
206206
207 VMNAME=mbison207 VMNAME=mbison
tt208 mkdir /vms/$VMNAME
208209
209 sudo vmbuilder kvm ubuntu -o --libvirt=qemu:///system --suite=lucid --flavour=v210 sudo vmbuilder kvm ubuntu -o --libvirt=qemu:///system --suite=lucid --flavour=v
>irtual \>irtual \
rev 24  |  foxhop  |  1300400935000  |  JSON

rev 23
rev 24
203**my custom vmbuilder string**203**my custom vmbuilder string**
204204
n205.. code-block:: pythonn205.. code-block:: bash
206206
207 VMNAME=mbison207 VMNAME=mbison
208208
n209 vmbuilder kvm ubuntu --hostname $VMNAME --domain=foxhop.net --suite maverick --n209 sudo vmbuilder kvm ubuntu -o --libvirt=qemu:///system --suite=lucid --flavour=v
>flavour virtual --rootsize=10240 --swapsize=1024 --raw=/vms/$VMNAME --ip 192.168>irtual \
>.1.52 --bridge br0 --addpkg openssh-server --addpkg acpid 
210 --hostname=$VMNAME --domain=foxhop.net --rootsize=10240 --raw=/vms/$VMNAME --me
 >m=1024 \
211 --ip=192.168.1.52 --gw=192.168.1.254 --dns=192.168.1.22 --bridge=br0 \
212 --addpkg=openssh-server --addpkg=acpid --timezone=EDT --manifest=/vms/$VMNAME/m
 >anifest.txt
210213
t211-o --libvirt qemu:///systemt
rev 23  |  foxhop  |  1300399907000  |  JSON

rev 22
rev 23
201 vmbuilder kvm ubuntu --help201 vmbuilder kvm ubuntu --help
202202
tt203**my custom vmbuilder string**
204 
205.. code-block:: python
206 
207 VMNAME=mbison
208 
209 vmbuilder kvm ubuntu --hostname $VMNAME --domain=foxhop.net --suite maverick --
 >flavour virtual --rootsize=10240 --swapsize=1024 --raw=/vms/$VMNAME --ip 192.168
 >.1.52 --bridge br0 --addpkg openssh-server --addpkg acpid
210 
211-o --libvirt qemu:///system
rev 22  |  foxhop  |  1300398321000  |  JSON

rev 21
rev 22
195 sudo apt-get install python-vm-builder195 sudo apt-get install python-vm-builder
196196
t197 t
198This example assumes ubuntu linux.
199 
200**display help vmbuilder**197**display help vmbuilder**
201198
rev 21  |  foxhop  |  1300398223000  |  JSON

rev 20
rev 21
184184
185185
t186vmbuilder examplet186Vmbuilder Example
187======================187======================
188188
rev 20  |  foxhop  |  1300398207000  |  JSON

rev 19
rev 20
189This example assumes ubuntu linux.189This example assumes ubuntu linux.
190190
nn191**install vmbuilder**
192 
191..code-block:: python193.. code-block:: python
192194
n193sudo apt-get install python-vm-buildern195 sudo apt-get install python-vm-builder
194196
tt197 
198This example assumes ubuntu linux.
199 
200**display help vmbuilder**
201 
202.. code-block:: python
203 
204 vmbuilder kvm ubuntu --help
205 
rev 19  |  foxhop  |  1300397856000  |  JSON

rev 18
rev 19
182182
183reference: http://en.wikibooks.org/wiki/QEMU/Images183reference: http://en.wikibooks.org/wiki/QEMU/Images
tt184 
185 
186vmbuilder example
187======================
188 
189This example assumes ubuntu linux.
190 
191..code-block:: python
192 
193sudo apt-get install python-vm-builder
194 
rev 18  |  foxhop  |  1300231526000  |  JSON

rev 17
rev 18
180 kpartx -d /dev/loop0180 kpartx -d /dev/loop0
181 losetup -d /dev/loop0181 losetup -d /dev/loop0
tt182 
183reference: http://en.wikibooks.org/wiki/QEMU/Images
rev 17  |  foxhop  |  1300229219000  |  JSON

rev 16
rev 17
170 vgchange -ay170 vgchange -ay
171 mount /dev/VolGroupName/LogVolName /mnt/image171 mount /dev/VolGroupName/LogVolName /mnt/image
tt172 
173Run the following when finished
174 
175.. code-block:: python
176 
177 umount /mnt/image
178 vgchange -an VolGroupName
179 killall qemu-nbd
180 kpartx -d /dev/loop0
181 losetup -d /dev/loop0
rev 16  |  foxhop  |  1300228530000  |  JSON

rev 15
rev 16
162 kpartx -a /dev/loop0162 kpartx -a /dev/loop0
163 mount /dev/mapper/loop0p1 /mnt/image163 mount /dev/mapper/loop0p1 /mnt/image
tt164 
165If there is an LVM present on the image file, you can initialize it by running
166 
167.. code-block:: python
168 
169 vgscan
170 vgchange -ay
171 mount /dev/VolGroupName/LogVolName /mnt/image
rev 15  |  foxhop  |  1300228426000  |  JSON

rev 14
rev 15
158158
159.. code-block:: python159.. code-block:: python
t160 t160 
161 losetup /dev/loop0 image.img
161 kpartx -a /dev/loop0162 kpartx -a /dev/loop0
162 mount /dev/mapper/loop0p1 /mnt/image163 mount /dev/mapper/loop0p1 /mnt/image
rev 14  |  foxhop  |  1300228380000  |  JSON

rev 13
rev 14
141141
142Debian/ubuntu guest don't have acpid installed by default. (Could change the vmb142Debian/ubuntu guest don't have acpid installed by default. (Could change the vmb
>uilder string)>uilder string)
tt143 
144Mount a qcow2 or raw image file
145=================================
146 
147The following procedures allow a host to mount a guest image file.  This is usef
 >ul when trouble shooting issues with the guest.  The following procedures requir
 >e root access (you can sudo).
148 
149**qcow2**
150 
151.. code-block:: python
152 
153 modprobe nbd max_part=63
154 qemu-nbd -c /dev/nbd0 image.img
155 mount /dev/nbd0p1 /mnt/image
156 
157**raw**
158 
159.. code-block:: python
160 
161 kpartx -a /dev/loop0
162 mount /dev/mapper/loop0p1 /mnt/image
rev 13  |  foxhop  |  1289340004000  |  JSON

rev 12
rev 13
t1vcKRpO  <a href="http://nvnmeexpvbyy.com/">nvnmeexpvbyy</a>, [url=http://djdoyszt1KVM guest management
>axthm.com/]djdoyszaxthm[/url], [link=http://ymzrlwfvjeug.com/]ymzrlwfvjeug[/link 
>], http://dpfwihmqnjws.com/ 
2=======================
3 
4.. contents:: 
5 
6 
7Install packages 
8===============================
9 
10**Debian or Ubuntu**
11 
12* sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
13 
14 
15**Redhat or Fedora** 
16 
17* yum install kvm 
18* yum install virt-manager libvirt libvirt-python python-virtinst 
19* chkconfig libvirtd on 
20* service libvirtd start 
21 
22 
23KVM virsh cheat sheet!
24============================
25 
26This is a list of commands to use in the virsh cli.
27 
28To start the virsh cli run the following cmd:
29 
30.. code-block:: bash
31  
32  $ virsh
33 
34or:
35 
36.. code-block:: bash
37 
38  virsh --connect qemu:///system
39 
40KVM has its own commands, but we like to use virsh.   
41 
42Here is a list comparing Xen and KVM (virsh) commands. 
43 
44List running guests 
45---------------------------------------------- 
46 
47**xen** 
48 | xm list 
49 
50**kvm** 
51 | virsh list 
52 | virsh dominfo <guest name> 
53 
54Start a guest 
55---------------------------------------------- 
56 
57**xen** 
58 | xm create /etc/xen/<guest name> 
59 
60**kvm** 
61 | virsh create /etc/libvirt/qemu/<guest name>.xml
62 | virsh start <domain> 
63 
64Console to guest
65---------------------------------------------- 
66 
67**xen** 
68 xm console <guest name> 
69 
70**kvm** 
71 virsh console <guest name> 
72 
73Shutdown a guest 
74---------------------------------------------- 
75 
76**xen** 
77 xm shutdown <guest name> 
78 
79**kvm** 
80 virsh shutdown <guest name> 
81 
82This command doesn't always work...  
83 
84Be sure the guests XML file has the following entry:
85 
86 <feature> <acpi/> </feature>
87 
88Also make sure the apci is installed on the guest operating system.
89 
90**debian / ubuntu**
91 sudo apt-get install acpid
92 
93**fedora / redhat**
94 yum install acpid
95 
96Autostart guest on reboot 
97---------------------------------------------- 
98 
99**xen** 
100 ln -s /etc/xen/<guest name> /etc/xen/auto/<guest name> 
101 
102**kvm** 
103 virsh autostart <guest name> 
104 
105Edit a guests configuration file
106-----------------------------------
107**xen**
108  NA
109 
110**kvm**  
111 virsh edit <domain>
112 
113 
114 
115 
116Pull the power on a guest
117----------------------------
118**xen**
119 xm destroy <guest>
120 
121**kvm**
122 virsh destroy <domain>
123 
124Quit virsh cli
125-----------------
126 
127**kvm** 
128 virsh # quit
129 
130 
131 
132 
133 
134Note
135------
136Typically the guests harddrive is not attached, you must add it in the configura
 >tion.
137 
138Typically the guests memory is set to 100mbs, you might want to change that in t
 >he configuration.
139 
140Once booted and ssh'd into the VM, cat /etc/network/interfaces to verify that th
 >e DNS settings are correct.
141 
142Debian/ubuntu guest don't have acpid installed by default. (Could change the vmb
 >uilder string)
rev 12  |  unknown  |  1289305040000  |  JSON

rev 11
rev 12
t No Differences Found t No Differences Found 
rev 11  |  unknown  |  1289305038000  |  JSON

rev 10
rev 11
t1yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdtt1vcKRpO  <a href="http://nvnmeexpvbyy.com/">nvnmeexpvbyy</a>, [url=http://djdoysz
>guser.com/]wwenzdtguser[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link>axthm.com/]djdoyszaxthm[/url], [link=http://ymzrlwfvjeug.com/]ymzrlwfvjeug[/link
>], http://spsndbhfelnh.com/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwv>], http://dpfwihmqnjws.com/
>ef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/url], [link=http://tugwvfmho 
>byj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com/yyZUqx  <a href="http://zo 
>hrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/u 
>rl], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com 
>/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzd 
>tguser.com/]wwenzdtguser[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/lin 
>k], http://spsndbhfelnh.com/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjseww 
>vef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/url], [link=http://tugwvfmh 
>obyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com/yyZUqx  <a href="http://z 
>ohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/ 
>url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.co 
>m/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenz 
>dtguser.com/]wwenzdtguser[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/li 
>nk], http://spsndbhfelnh.com/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsew 
>wvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/url], [link=http://tugwvfm 
>hobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com/yyZUqx  <a href="http:// 
>zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[ 
>/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.c 
>om/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwen 
>zdtguser.com/]wwenzdtguser[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/l 
>ink], http://spsndbhfelnh.com/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjse 
>wwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/url], [link=http://tugwvf 
>mhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com/yyZUqx  <a href="http:/ 
>/zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser 
>[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh. 
>com/ 
rev 10  |  unknown  |  1289277472000  |  JSON

rev 9
rev 10
t No Differences Found t No Differences Found 
rev 9  |  unknown  |  1289277466000  |  JSON

rev 8
rev 9
t1KVM guest managementt1yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdt
 >guser.com/]wwenzdtguser[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link
 >], http://spsndbhfelnh.com/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwv
 >ef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/url], [link=http://tugwvfmho
 >byj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com/yyZUqx  <a href="http://zo
 >hrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/u
 >rl], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com
 >/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzd
 >tguser.com/]wwenzdtguser[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/lin
 >k], http://spsndbhfelnh.com/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjseww
 >vef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/url], [link=http://tugwvfmh
 >obyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com/yyZUqx  <a href="http://z
 >ohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/
 >url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.co
 >m/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenz
 >dtguser.com/]wwenzdtguser[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/li
 >nk], http://spsndbhfelnh.com/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsew
 >wvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/url], [link=http://tugwvfm
 >hobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com/yyZUqx  <a href="http://
 >zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[
 >/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.c
 >om/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwen
 >zdtguser.com/]wwenzdtguser[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/l
 >ink], http://spsndbhfelnh.com/yyZUqx  <a href="http://zohrjsewwvef.com/">zohrjse
 >wwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser[/url], [link=http://tugwvf
 >mhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.com/yyZUqx  <a href="http:/
 >/zohrjsewwvef.com/">zohrjsewwvef</a>, [url=http://wwenzdtguser.com/]wwenzdtguser
 >[/url], [link=http://tugwvfmhobyj.com/]tugwvfmhobyj[/link], http://spsndbhfelnh.
 >com/
2=======================
3 
4.. contents:: 
5 
6 
7Install packages 
8===============================
9 
10**Debian or Ubuntu**
11 
12* sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
13 
14 
15**Redhat or Fedora** 
16 
17* yum install kvm 
18* yum install virt-manager libvirt libvirt-python python-virtinst 
19* chkconfig libvirtd on 
20* service libvirtd start 
21 
22 
23KVM virsh cheat sheet!
24============================
25 
26This is a list of commands to use in the virsh cli.
27 
28To start the virsh cli run the following cmd:
29 
30.. code-block:: bash
31  
32  $ virsh
33 
34or:
35 
36.. code-block:: bash
37 
38  virsh --connect qemu:///system
39 
40KVM has its own commands, but we like to use virsh.   
41 
42Here is a list comparing Xen and KVM (virsh) commands. 
43 
44List running guests 
45---------------------------------------------- 
46 
47**xen** 
48 | xm list 
49 
50**kvm** 
51 | virsh list 
52 | virsh dominfo <guest name> 
53 
54Start a guest 
55---------------------------------------------- 
56 
57**xen** 
58 | xm create /etc/xen/<guest name> 
59 
60**kvm** 
61 | virsh create /etc/libvirt/qemu/<guest name>.xml
62 | virsh start <domain> 
63 
64Console to guest
65---------------------------------------------- 
66 
67**xen** 
68 xm console <guest name> 
69 
70**kvm** 
71 virsh console <guest name> 
72 
73Shutdown a guest 
74---------------------------------------------- 
75 
76**xen** 
77 xm shutdown <guest name> 
78 
79**kvm** 
80 virsh shutdown <guest name> 
81 
82This command doesn't always work...  
83 
84Be sure the guests XML file has the following entry:
85 
86 <feature> <acpi/> </feature>
87 
88Also make sure the apci is installed on the guest operating system.
89 
90**debian / ubuntu**
91 sudo apt-get install acpid
92 
93**fedora / redhat**
94 yum install acpid
95 
96Autostart guest on reboot 
97---------------------------------------------- 
98 
99**xen** 
100 ln -s /etc/xen/<guest name> /etc/xen/auto/<guest name> 
101 
102**kvm** 
103 virsh autostart <guest name> 
104 
105Edit a guests configuration file
106-----------------------------------
107**xen**
108  NA
109 
110**kvm**  
111 virsh edit <domain>
112 
113 
114 
115 
116Pull the power on a guest
117----------------------------
118**xen**
119 xm destroy <guest>
120 
121**kvm**
122 virsh destroy <domain>
123 
124Quit virsh cli
125-----------------
126 
127**kvm** 
128 virsh # quit
129 
130 
131 
132 
133 
134Note
135------
136Typically the guests harddrive is not attached, you must add it in the configura
>tion. 
137 
138Typically the guests memory is set to 100mbs, you might want to change that in t
>he configuration. 
139 
140Once booted and ssh'd into the VM, cat /etc/network/interfaces to verify that th
>e DNS settings are correct. 
141 
142Debian/ubuntu guest don't have acpid installed by default. (Could change the vmb
>uilder string) 
rev 8  |  foxhop  |  1288117043000  |  JSON

rev 7
rev 8
55
66
n7This document talks about a guest named *mbison*. Change this name to better suin7Install packages 
>t your purpose.  
8===============================
9 
10**Debian or Ubuntu**
11 
12* sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
13 
14 
15**Redhat or Fedora** 
16 
17* yum install kvm 
18* yum install virt-manager libvirt libvirt-python python-virtinst 
19* chkconfig libvirtd on 
20* service libvirtd start 
821
922
116129
117130
n118Install packages n
119---------------------------------------------- 
120131
t121**Debian or Ubuntu**t
122 
123* sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
124 
125 
126**Redhat or Fedora** 
127 
128* yum install kvm 
129* yum install virt-manager libvirt libvirt-python python-virtinst 
130* chkconfig libvirtd on 
131* service libvirtd start
132132
133133
rev 7  |  foxhop  |  1288116990000  |  JSON

rev 6
rev 7
119---------------------------------------------- 119---------------------------------------------- 
120120
tt121**Debian or Ubuntu**
122 
123* sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
124 
125 
121**Redhat or Fedora** 126**Redhat or Fedora** 
122127
rev 6  |  foxhop  |  1288116784000  |  JSON

rev 5
rev 6
15To start the virsh cli run the following cmd:15To start the virsh cli run the following cmd:
1616
n17 .. code-block:: bashn17.. code-block:: bash
18  18  
19  $ virsh19  $ virsh
21or:21or:
2222
n23 .. code-block:: bashn23.. code-block:: bash
2424
25  virsh --connect qemu:///system25  virsh --connect qemu:///system
32---------------------------------------------- 32---------------------------------------------- 
3333
n34xen n34**xen** 
35  xm list 35 | xm list 
3636
n37kvm n37**kvm** 
38  virsh list 38 | virsh list 
39  virsh dominfo <guest name> ( more info on guest ) 39 | virsh dominfo <guest name> 
4040
41Start a guest 41Start a guest 
42---------------------------------------------- 42---------------------------------------------- 
4343
n44xen n44**xen** 
45  xm create /etc/xen/<guest name> 45 | xm create /etc/xen/<guest name> 
4646
n47kvm n47**kvm** 
48  virsh create /etc/libvirt/qemu/<guest name>.xml48 | virsh create /etc/libvirt/qemu/<guest name>.xml
49or
50  virsh start <domain> 49 | virsh start <domain> 
5150
52Console to guest51Console to guest
53---------------------------------------------- 52---------------------------------------------- 
5453
n55xen n54**xen** 
56  xm console <guest name> 55 xm console <guest name> 
5756
n58kvm n57**kvm** 
59  virsh console <guest name> 58 virsh console <guest name> 
6059
61Shutdown a guest 60Shutdown a guest 
62---------------------------------------------- 61---------------------------------------------- 
6362
n64xen n63**xen** 
65  xm shutdown <guest name> 64 xm shutdown <guest name> 
6665
n67kvm n66**kvm** 
68  virsh shutdown <guest name> 67 virsh shutdown <guest name> 
6968
n70This doesn't always work.  n69This command doesn't always work...  
7170
72Be sure the guests XML file has the following entry:71Be sure the guests XML file has the following entry:
7372
n74 .. code-block:: xmln73 <feature> <acpi/> </feature>
75 
76  <feature>
77 
78     <acpi/>
79 
80  </feature>
8174
82Also make sure the apci is installed on the guest operating system.75Also make sure the apci is installed on the guest operating system.
8376
n84On debian / ubuntu run:n77**debian / ubuntu**
85 78 sudo apt-get install acpid
86 .. code-block:: bash
8779
n88  $ sudo apt-get install acpidn80**fedora / redhat**
89 81 yum install acpid
9082
91Autostart guest on reboot 83Autostart guest on reboot 
92---------------------------------------------- 84---------------------------------------------- 
9385
n94xen n86**xen** 
95  ln -s /etc/xen/<guest name> /etc/xen/auto/<guest name> 87 ln -s /etc/xen/<guest name> /etc/xen/auto/<guest name> 
9688
n97kvm n89**kvm** 
98  virsh autostart <guest name> 90 virsh autostart <guest name> 
9991
100Edit a guests configuration file92Edit a guests configuration file
101-----------------------------------93-----------------------------------
n102xenn94**xen**
103  NA95  NA
10496
n105kvm  n97**kvm**  
106 virsh edit <domain>98 virsh edit <domain>
10799
111Pull the power on a guest103Pull the power on a guest
112----------------------------104----------------------------
nn105**xen**
106 xm destroy <guest>
113107
n114Pull the power on a guest::  n108**kvm**
115 
116 virsh destroy <domain>109 virsh destroy <domain>
117110
119-----------------112-----------------
120113
t121Quit virsh cli::  t114**kvm** 
122 
123 virsh # quit115 virsh # quit
124116
rev 5  |  foxhop  |  1288115984000  |  JSON

rev 4
rev 5
103  NA103  NA
104104
n105kvm::  n105kvm  
106 virsh edit <domain>106 virsh edit <domain>
107107
114Pull the power on a guest::  114Pull the power on a guest::  
115115
t116 virsh # destroy mbisont116 virsh destroy <domain>
117117
118Quit virsh cli118Quit virsh cli
rev 4  |  foxhop  |  1288115910000  |  JSON

rev 3
rev 4
66
7This document talks about a guest named *mbison*. Change this name to better sui7This document talks about a guest named *mbison*. Change this name to better sui
>t your purpose. >t your purpose. 
n8 n
9 
10 
118
129
28  virsh --connect qemu:///system25  virsh --connect qemu:///system
2926
n30List all guestsn27KVM has its own commands, but we like to use virsh.   
31----------------
32 
33List all guests:: 
34 
35 virsh # list --all
3628
nn29Here is a list comparing Xen and KVM (virsh) commands. 
3730
nn31List running guests 
32---------------------------------------------- 
3833
n39Start a guestn34xen 
40------------------35  xm list 
4136
n42Start a guest::  n37kvm 
38  virsh list 
39  virsh dominfo <guest name> ( more info on guest ) 
4340
n44 virsh # start mbisonn41Start a guest 
42---------------------------------------------- 
4543
n46Flag a guest for autostart on host rebootn44xen 
47--------------------------------------------45  xm create /etc/xen/<guest name> 
4846
n49Flag a guest for autostart on host reboot::  n47kvm 
48  virsh create /etc/libvirt/qemu/<guest name>.xml
49or
50  virsh start <domain> 
5051
n51 virsh # autostart mbisonn52Console to guest
53---------------------------------------------- 
5254
n53Edit a guests configuration filen55xen 
54-----------------------------------56  xm console <guest name> 
5557
n56Edit a guests configuration file::  n58kvm 
59  virsh console <guest name> 
5760
n58 virsh # edit mbisonn61Shutdown a guest 
62---------------------------------------------- 
5963
n60Shutdown a guestn64xen 
61---------------------65  xm shutdown <guest name> 
62Shutdown a guest gracefully::66 
63 67kvm 
64 virsh # shutdown mbison68  virsh shutdown <guest name> 
6569
66This doesn't always work.  70This doesn't always work.  
8589
8690
nn91Autostart guest on reboot 
92---------------------------------------------- 
93 
94xen 
95  ln -s /etc/xen/<guest name> /etc/xen/auto/<guest name> 
96 
97kvm 
98  virsh autostart <guest name> 
99 
100Edit a guests configuration file
101-----------------------------------
102xen
103  NA
104 
105kvm::  
106 virsh edit <domain>
107 
108 
109 
110 
87Pull the power on a guest111Pull the power on a guest
88----------------------------112----------------------------
98122
99 virsh # quit123 virsh # quit
t100 t
101124
102125
rev 3  |  foxhop  |  1288115532000  |  JSON

rev 2
rev 3
104---------------------------------------------- 104---------------------------------------------- 
105105
t106Redhat or Fedora t106**Redhat or Fedora** 
107 
107  yum install kvm 108* yum install kvm 
108  yum install virt-manager libvirt libvirt-python python-virtinst 109* yum install virt-manager libvirt libvirt-python python-virtinst 
109  chkconfig libvirtd on 110* chkconfig libvirtd on 
110  service libvirtd start111* service libvirtd start
112 
111113
112Note114Note
rev 2  |  foxhop  |  1288115400000  |  JSON

rev 1
rev 2
100100
101101
tt102 
103Install packages 
104---------------------------------------------- 
105 
106Redhat or Fedora 
107  yum install kvm 
108  yum install virt-manager libvirt libvirt-python python-virtinst 
109  chkconfig libvirtd on 
110  service libvirtd start
111 
102Note112Note
103------113------
rev 1  |  foxhop  |  1276973303000  |  JSON

empty
rev 1
tt1KVM guest management
2=======================
3 
4.. contents:: 
5 
6 
7This document talks about a guest named *mbison*. Change this name to better sui
 >t your purpose. 
8 
9 
10 
11 
12 
13KVM virsh cheat sheet!
14============================
15 
16This is a list of commands to use in the virsh cli.
17 
18To start the virsh cli run the following cmd:
19 
20 .. code-block:: bash
21  
22  $ virsh
23 
24or:
25 
26 .. code-block:: bash
27 
28  virsh --connect qemu:///system
29 
30List all guests
31----------------
32 
33List all guests:: 
34 
35 virsh # list --all
36 
37 
38 
39Start a guest
40------------------
41 
42Start a guest::  
43 
44 virsh # start mbison
45 
46Flag a guest for autostart on host reboot
47--------------------------------------------
48 
49Flag a guest for autostart on host reboot::  
50 
51 virsh # autostart mbison
52 
53Edit a guests configuration file
54-----------------------------------
55 
56Edit a guests configuration file::  
57 
58 virsh # edit mbison
59 
60Shutdown a guest
61---------------------
62Shutdown a guest gracefully::
63 
64 virsh # shutdown mbison
65 
66This doesn't always work.  
67 
68Be sure the guests XML file has the following entry:
69 
70 .. code-block:: xml
71 
72  <feature>
73 
74     <acpi/>
75 
76  </feature>
77 
78Also make sure the apci is installed on the guest operating system.
79 
80On debian / ubuntu run:
81 
82 .. code-block:: bash
83 
84  $ sudo apt-get install acpid
85 
86 
87Pull the power on a guest
88----------------------------
89 
90Pull the power on a guest::  
91 
92 virsh # destroy mbison
93 
94Quit virsh cli
95-----------------
96 
97Quit virsh cli::  
98 
99 virsh # quit
100 
101 
102Note
103------
104Typically the guests harddrive is not attached, you must add it in the configura
 >tion.
105 
106Typically the guests memory is set to 100mbs, you might want to change that in t
 >he configuration.
107 
108Once booted and ssh'd into the VM, cat /etc/network/interfaces to verify that th
 >e DNS settings are correct.
109 
110Debian/ubuntu guest don't have acpid installed by default. (Could change the vmb
 >uilder string)