virsh create somefile.xml
creates my machine just fine but when I shut the machine down the whole thing disappears. Machines I made with the virt-manager GUI are persistent (stick around after shutdown) and the xml file is derived from those virt-manager created machines.
On my host I am using libvirt and a KVM guest. When the host is shutting down, libvirt suspends the guest. When the host is starting up, libvirt resumes the guest. The problem is, if the guest is suspended and resumed after 24 hours for example, then the guest time is 24 hours in the past.
I thought that maybe the problem is with the clocksource, but it is set to "kvm-clock" already.
$ cat /sys/devices/system/clocksource/clocksource0/available_clocksource
kvm-clock tsc hpet acpi_pm
$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
kvm-clock
I created a KVM guest from the command line with virt-install
where I used the command line options --disk pool=vg0,size=20
and --name virt1.example.com
.
How can I delete this KVM guest from the command line? I don't need it anymore.
Just for the record the whole command line was
virt-install --debug --hvm --vnc --name virt1.example.com --os-type=linux --os-variant=rhel6 --pxe --network network=default,model=e1000,mac=02:54:00:13:be:e4 --disk pool=vg0,size=20 --ram 1024 --vcpus=1
and here is some extra information
[root@server ~]# virsh vol-list vg0
Name Path
-----------------------------------------
lv0 /dev/vg0/lv0
lv_swap /dev/vg0/lv_swap
virt1.example.com.img /dev/vg0/virt1.example.com.img
[root@server ~]# virsh list
Id Name State
----------------------------------
3 virt1.example.com running
Update
Running these three commands seems to remove the installed KVM
virsh destroy virt1.example.com
virsh undefine virt1.example.com
virsh vol-delete --pool vg0 virt1.example.com.img
For more details see the terminal session:
[root@server ~]# virsh list --all
Id Name State
----------------------------------
3 virt1.example.com running
[root@server ~]# virsh undefine virt1.example.com
error: Failed to undefine domain virt1.example.com
error: Requested operation is not valid: cannot delete active domain
[root@server ~]# virsh destroy virt1.example.com
Domain virt1.example.com destroyed
[root@server ~]# virsh list --all
Id Name State
----------------------------------
- virt1.example.com shut off
[root@server ~]# virsh undefine virt1.example.com
Domain virt1.example.com has been undefined
[root@server ~]# virsh list --all
Id Name State
----------------------------------
[root@server ~]# virsh vol-list --pool vg0
Name Path
-----------------------------------------
lv0 /dev/vg0/lv0
lv_swap /dev/vg0/lv_swap
virt1.example.com.img /dev/vg0/virt1.example.com.img
[root@server ~]# virsh vol-delete --pool vg0 virt1.example.com.img
Vol virt1.example.com.img deleted
[root@server ~]# virsh vol-list --pool vg0
Name Path
-----------------------------------------
lv0 /dev/vg0/lv0
lv_swap /dev/vg0/lv_swap
[root@server ~]# cat /etc/issue
CentOS Linux release 6.0 (Final)
Kernel \r on an \m
[root@server ~]# virsh --version
0.8.1
How can I rename a VM on KVM+libvirt?
I would like it to change the name in the 'inventory' as well as change the name of the storage etc.
How can I forward ports on a server running libvirt/KVM to specified ports on VM's, when using NAT?
For example, the host has a public IP of 1.2.3.4. I want to forward port 80 to 10.0.0.1 and port 22 to 10.0.0.2.
I assume I need to add iptables rules, but I'm not sure where is appropriate and what exactly should be specified.
Output of iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere 10.0.0.0/24 state RELATED,ESTABLISHED
ACCEPT all -- 10.0.0.0/24 anywhere
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Output of ifconfig
eth0 Link encap:Ethernet HWaddr 00:1b:fc:46:73:b9
inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::21b:fcff:fe46:73b9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:201 errors:0 dropped:0 overruns:0 frame:0
TX packets:85 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31161 (31.1 KB) TX bytes:12090 (12.0 KB)
Interrupt:17
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
virbr1 Link encap:Ethernet HWaddr ca:70:d1:77:b2:48
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::c870:d1ff:fe77:b248/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:468 (468.0 B)
I'm using Ubuntu 10.04.