xref: /illumos-kvm-cmd/README.md (revision 390587f3)
1<pre>
2  ___  _____ __  __ _   _
3 / _ \| ____|  \/  | | | |
4| | | |  _| | |\/| | | | |
5| |_| | |___| |  | | |_| |
6 \__\_\_____|_|  |_|\___/
7</pre>
8
9
10For full documentation on all the various options for QEMU please see the html docs.
11
12
13# BUILDING
14
15Preparing:
16
17Edit build.sh and change the --kerneldir option to point to the directory of
18the kvm repository and change the --prefix option to whatever you want.
19
20    $ ./build.sh
21    $ make install
22
23
24# USING
25
26Follow the qemu documentation for all of the various options available. The
27rest of this will be examples and specific pieces about how to use things with
28a VNIC and a ZVOL. The following is a sample configuration for qemu running a Linux VM.
29
30    $ /smartdc/bin/qemu-system-x86_64 \
31        -enable-kvm \
32        -nographic \
33        -drive file=smartdc.iso,media=cdrom,if=ide \
34        -boot order=cd \
35        -smp 4 \
36        -m 1024 \
37        -vnc 0.0.0.0:0 \
38        -net nic,vlan=0,name=net0,model=virtio,macaddr=90:b8:d0:c0:ff:ee\
39        -net vnic,vlan=0,name=net0,ifname=eth0,macaddr=90:b8:d0:c0:ff:ee,\
40             ip=10.88.88.50,netmask=255.255.255.0,gateway_ip=10.88.88.2,\
41             server_ip=10.88.88.200,dns_ip0=8.8.4.4,dns_ip1=8.8.4.4,\
42	     hostname=host1,lease_time=3600 \
43        -no-hpet \
44        -chardev socket,id=serial0,path=/tmp/vm.console,server,nowait \
45        -serial chardev:serial0 \
46        -drive file=/dev/zvol/rdsk/zones/rec-8,if=virtio,index=0
47
48
49# ZVOLs
50
51It is highly desirable to be able to give a virtual machine a zvol to use as a
52disk. This is accomplished via the -drive option. Simply pass the block device
53that corresponds to the zvol.
54
55To create a zvol use a command similar to:
56
57    $ zfs create -V 10g tank/vm-hdd
58
59
60# VNICs
61
62We have added an option to have a virtual machine's network interface card
63directly correspond to a Crossbow vnic on the system. The -net vnic has several
64mandatory arguments:
65
66* __vlan__ must be specified and correspond to a single -net nic line
67* __name__ must be specified and correspond to a single -net nic line
68* __macaddr__ must be specified if the MAC Address of the VNIC does not match
69  the MAC address on the -net nic line.
70* __ifname__ must be specified and correspond to the name of the crossbow vnic.
71
72To set up the crossbow vnic, simply create it. There is no need to plumb it.
73The device will be opened up in promiscuous mode.
74
75To create a vnic you'll want something akin to:
76
77    $ dladm create-vnic -l e1000g0 vnic0
78
79The -net vnic option also supports configuring networking on the virtual
80machine via dhcp. In this mode, qemu acts as a DHCP server for the virtual
81machine. To enable vnic dhcp, specify the following arguments:
82
83* __ip__ (eg: 192.168.0.2) must be specified in order to enable dhcp
84* __netmask__ (eg: 255.255.255.0) must be specified
85* __gateway_ip__ (eg: 192.168.0.1) must be specified
86* __server_ip__ (eg: 192.168.0.3) is optional. This allows specifying the
87  IP address of qemu's DHCP server.
88* __dns_ip__ (eg: 8.8.4.4) is optional, and allows specifying the DNS
89  server the virtual machine will use.  The default value is 8.8.8.8.
90* __dns_ip0__, __dns_ip1__, __dns_ip2__, and __dns_ip3__ are optional,
91  and allow specifying a list of DNS servers, rather than just one.
92  These options override the dns_ip option.
93* __hostname__ (eg: myhostname) is optional. This defaults to no hostname.
94* __lease_time__ (eg: 3600) is optional, and allows specifying the DHCP
95  lease time in seconds.  The default value is 86400 (or 1 day).
96
97The following is a sample -net vnic line for running with DHCP:
98
99    -net vnic,vlan=0,name=net0,ifname=eth0,macaddr=90:b8:d0:c0:ff:ee, \
100        ip=10.88.88.50,netmask=255.255.255.0,gateway_ip=10.88.88.2, \
101        server_ip=10.88.88.200,dns_ip=8.8.4.4,hostname=host1,lease_time=3600
102
103