Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 7d53350

Browse files
committed
virt-install: Add --watchdog support
1 parent dfaeb23 commit 7d53350

10 files changed

Lines changed: 257 additions & 20 deletions

File tree

man/en/virt-clone.1

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.07)
1+
.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.07)
22
.\"
33
.\" Standard preamble:
44
.\" ========================================================================
5-
.de Sh \" Subsection heading
6-
.br
7-
.if t .Sp
8-
.ne 5
9-
.PP
10-
\fB\\$1\fR
11-
.PP
12-
..
135
.de Sp \" Vertical space (when we can't use .PP)
146
.if t .sp .5v
157
.if n .sp
@@ -53,7 +45,7 @@
5345
.el .ds Aq '
5446
.\"
5547
.\" If the F register is turned on, we'll generate index entries on stderr for
56-
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
48+
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
5749
.\" entries marked with X<> in POD. Of course, you'll have to process the
5850
.\" output yourself in some meaningful fashion.
5951
.ie \nF \{\
@@ -132,7 +124,7 @@
132124
.\" ========================================================================
133125
.\"
134126
.IX Title "VIRT-CLONE 1"
135-
.TH VIRT-CLONE 1 "2009-12-01" "" "Virtual Machine Install Tools"
127+
.TH VIRT-CLONE 1 "2010-03-03" "" "Virtual Machine Install Tools"
136128
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
137129
.\" way too many mistakes in technical documents.
138130
.if n .ad l
@@ -166,7 +158,7 @@ Show the help message and exit
166158
.IP "\-\-connect=CONNECT" 4
167159
.IX Item "--connect=CONNECT"
168160
Connect to a non-default hypervisor. See \fIvirt\-install\fR\|(1) for details
169-
.Sh "General Options"
161+
.SS "General Options"
170162
.IX Subsection "General Options"
171163
General configuration parameters that apply to all guest clones.
172164
.IP "\-o \s-1ORIGINAL_GUEST\s0, \-\-original=ORIGINAL_GUEST" 2
@@ -205,7 +197,7 @@ currently active.
205197
specify \s-1UUID\s0, you should use a 32\-digit hexadecimal number. \s-1UUID\s0 are intended
206198
to be unique across the entire data center, and indeed world. Bear this in
207199
mind if manually specifying a \s-1UUID\s0
208-
.Sh "Storage Configuration"
200+
.SS "Storage Configuration"
209201
.IX Subsection "Storage Configuration"
210202
.IP "\-f \s-1DISKFILE\s0, \-\-file=DISKFILE" 2
211203
.IX Item "-f DISKFILE, --file=DISKFILE"
@@ -224,16 +216,18 @@ Fully allocate the new storage if the path being cloned is a sparse file.
224216
See \fIvirt\-install\fR\|(1) for more details on sparse vs. nonsparse.
225217
.IP "\-\-preserve\-data" 2
226218
.IX Item "--preserve-data"
227-
Preserve a new file to use as the disk image for the new guest.
228-
.Sh "Networking Configuration"
219+
No storage is cloned: disk images specific by \-\-file are preserved as is,
220+
and referenced in the new clone \s-1XML\s0. This is useful if you want to clone
221+
a \s-1VM\s0 \s-1XML\s0 template, but not the storage contents.
222+
.SS "Networking Configuration"
229223
.IX Subsection "Networking Configuration"
230224
.IP "\-m \s-1MAC\s0, \-\-mac=MAC" 2
231225
.IX Item "-m MAC, --mac=MAC"
232226
Fixed \s-1MAC\s0 address for the guest; If this parameter is omitted, or the value
233227
\&\f(CW\*(C`RANDOM\*(C'\fR is specified a suitable address will be randomly generated. Addresses
234228
are applied sequentially to the networks as they are listed in the original
235229
guest \s-1XML\s0.
236-
.Sh "Miscellaneous Options"
230+
.SS "Miscellaneous Options"
237231
.IX Subsection "Miscellaneous Options"
238232
.IP "\-d, \-\-debug" 2
239233
.IX Item "-d, --debug"

man/en/virt-install.1

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
.\" ========================================================================
125125
.\"
126126
.IX Title "VIRT-INSTALL 1"
127-
.TH VIRT-INSTALL 1 "2010-02-08" "" "Virtual Machine Install Tools"
127+
.TH VIRT-INSTALL 1 "2010-03-22" "" "Virtual Machine Install Tools"
128128
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
129129
.\" way too many mistakes in technical documents.
130130
.if n .ad l
@@ -299,6 +299,18 @@ Generic 2.6.x kernel
299299
.IP "virtio26" 4
300300
.IX Item "virtio26"
301301
Generic 2.6.25 or later kernel with virtio
302+
.IP "mandriva2009" 4
303+
.IX Item "mandriva2009"
304+
Mandriva Linux 2009 and earlier
305+
.IP "mandriva2010" 4
306+
.IX Item "mandriva2010"
307+
Mandriva Linux 2010 and later
308+
.IP "mes5" 4
309+
.IX Item "mes5"
310+
Mandriva Enterprise Server 5.0
311+
.IP "mes5.1" 4
312+
.IX Item "mes5.1"
313+
Mandriva Enterprise Server 5.1 and later
302314
.IP "rhel2.1" 4
303315
.IX Item "rhel2.1"
304316
Red Hat Enterprise Linux 2.1
@@ -454,7 +466,45 @@ A node device name via libvirt, as shown by 'virsh nodedev\-list'
454466
Parameters specific only to fully virtualized guest installs.
455467
.IP "\-\-sound" 2
456468
.IX Item "--sound"
457-
Attach a virtual audio device to the guest.
469+
Attach a virtual audio device to the guest. The device model will be \s-1AC97\s0
470+
if the hypervisor supports it, otherwise will be \s-1ES1370\s0
471+
.IP "\-\-watchdog MODEL[,action=ACTION]" 2
472+
.IX Item "--watchdog MODEL[,action=ACTION]"
473+
Attach a virtual hardware watchdog device to the guest. This requires a
474+
daemon and device driver in the guest. The watchdog fires a signal when
475+
the virtual machine appears to hung. \s-1ACTION\s0 specifies what libvirt will do
476+
when the watchdog fires. Values are
477+
.RS 2
478+
.IP "\fBreset\fR" 4
479+
.IX Item "reset"
480+
Forcefully reset the guest (the default)
481+
.IP "\fBpoweroff\fR" 4
482+
.IX Item "poweroff"
483+
Forcefully power off the guest
484+
.IP "\fBpause\fR" 4
485+
.IX Item "pause"
486+
Pause the guest
487+
.IP "\fBnone\fR" 4
488+
.IX Item "none"
489+
Do nothing
490+
.IP "\fBshutdown\fR" 4
491+
.IX Item "shutdown"
492+
Gracefully shutdown the guest (not recommended, since a hung guest probably
493+
won't respond to a graceful shutdown)
494+
.RE
495+
.RS 2
496+
.Sp
497+
\&\s-1MODEL\s0 is the emulated device model: either i6300esb (the default) or ib700.
498+
Some examples:
499+
.Sp
500+
Use the recommended settings:
501+
.Sp
502+
\&\-\-watchdog default
503+
.Sp
504+
Use the i6300esb with the 'poweroff' action
505+
.Sp
506+
\&\-\-watchdog i6300esb,action=poweroff
507+
.RE
458508
.IP "\-\-parallel=CHAROPTS" 2
459509
.IX Item "--parallel=CHAROPTS"
460510
.PD 0
@@ -527,6 +577,10 @@ Unix socket (see \fIunix\fR\|(7). \s-1MODE\s0 has similar behavior and defaults
527577
.RE
528578
.RS 2
529579
.RE
580+
.IP "\-\-description" 2
581+
.IX Item "--description"
582+
Human readable text description of the virtual machine. This will be stored
583+
in the guests \s-1XML\s0 configuration for access by other applications.
530584
.IP "\-\-noapic" 2
531585
.IX Item "--noapic"
532586
Override the \s-1OS\s0 type / variant to disables the \s-1APIC\s0 setting for fully

man/en/virt-install.pod.in

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,49 @@ Parameters specific only to fully virtualized guest installs.
182182
Attach a virtual audio device to the guest. The device model will be AC97
183183
if the hypervisor supports it, otherwise will be ES1370
184184

185+
=item --watchdog MODEL[,action=ACTION]
186+
187+
Attach a virtual hardware watchdog device to the guest. This requires a
188+
daemon and device driver in the guest. The watchdog fires a signal when
189+
the virtual machine appears to hung. ACTION specifies what libvirt will do
190+
when the watchdog fires. Values are
191+
192+
=over 4
193+
194+
=item B<reset>
195+
196+
Forcefully reset the guest (the default)
197+
198+
=item B<poweroff>
199+
200+
Forcefully power off the guest
201+
202+
=item B<pause>
203+
204+
Pause the guest
205+
206+
=item B<none>
207+
208+
Do nothing
209+
210+
=item B<shutdown>
211+
212+
Gracefully shutdown the guest (not recommended, since a hung guest probably
213+
won't respond to a graceful shutdown)
214+
215+
=back
216+
217+
MODEL is the emulated device model: either i6300esb (the default) or ib700.
218+
Some examples:
219+
220+
Use the recommended settings:
221+
222+
--watchdog default
223+
224+
Use the i6300esb with the 'poweroff' action
225+
226+
--watchdog i6300esb,action=poweroff
227+
185228
=item --parallel=CHAROPTS
186229

187230
=item --serial=CHAROPTS

tests/clitest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,19 @@
360360
"--hvm --nodisks --pxe --description \"foobar & baz\"",
361361
# HVM windows install with disk
362362
"--hvm --cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0",
363+
# Watchdog dev default
364+
"--hvm --nodisks --pxe --watchdog default",
365+
# Watchdog opts
366+
"--hvm --nodisks --pxe --watchdog ib700,action=pause",
363367
],
364368

365369
"invalid": [
366370
# pxe and nonetworks
367371
"--nodisks --pxe --nonetworks",
368372
# Colliding name
369373
"--nodisks --pxe --name test",
374+
# Busted watchdog
375+
"--hvm --nodisks --pxe --watchdog default,action=foobar",
370376
],
371377
}, # category "misc"
372378

tests/xmlconfig-xml/boot-many-devices.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<product id='0x1234'/>
7272
</source>
7373
</hostdev>
74+
<watchdog model='ib700' action='none'/>
7475
</devices>
7576
<seclabel type='static' model='selinux'>
7677
<label>foolabel</label>

tests/xmlconfig.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from virtinst import VirtualCharDevice
2828
from virtinst import VirtualVideoDevice
2929
from virtinst import VirtualController
30+
from virtinst import VirtualWatchdog
3031
import tests
3132

3233
conn = tests.open_testdriver()
@@ -672,6 +673,11 @@ def testManyDevices(self):
672673
g.add_device(vdev2)
673674
g.add_device(vdev3)
674675

676+
wdev2 = VirtualWatchdog(g.conn)
677+
wdev2.model = "ib700"
678+
wdev2.action = "none"
679+
g.add_device(wdev2)
680+
675681
g.clock.offset = "localtime"
676682

677683
seclabel = virtinst.Seclabel(g.conn)

virt-install

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,38 @@ def get_chardevs(char_type, opts, guest):
144144
fail(_("Error in %(chartype)s device parameters: %(err)s") %
145145
{"chartype": char_type, "err": str(e) })
146146

147+
def parse_watchdog(guest, optstring):
148+
# Peel the model type off the front
149+
model, ignore, optstring = partition(optstring, ",")
150+
opts = cli.parse_optstr(optstring)
151+
dev = virtinst.VirtualWatchdog(guest.conn)
152+
153+
def set_param(paramname, dictname, val=None):
154+
if not val:
155+
if opts.has_key(dictname):
156+
val = opts[dictname]
157+
del(opts[dictname])
158+
else:
159+
return
160+
161+
setattr(dev, paramname, val)
162+
163+
set_param("model", "model", model)
164+
set_param("action", "action")
165+
166+
# If extra parameters, then user passed some garbage param
167+
if opts:
168+
raise ValueError(_("Unknown option(s) %s") % opts.keys())
169+
170+
return dev
171+
172+
def get_watchdog(watchdogs, guest):
173+
for optstr in cli.listify(watchdogs):
174+
try:
175+
dev = parse_watchdog(guest, optstr)
176+
guest.add_device(dev)
177+
except Exception, e:
178+
fail(_("Error in watchdog device parameters: %s") % str(e))
147179

148180
def parse_disk_option(guest, path, size):
149181
"""helper to properly parse --disk options"""
@@ -553,6 +585,9 @@ def parse_args():
553585
fulg = OptionGroup(parser, _("Full Virtualization specific options"))
554586
fulg.add_option("", "--sound", action="store_true", dest="sound",
555587
default=False, help=_("Use sound device emulation"))
588+
fulg.add_option("", "--watchdog", type="string", dest="watchdog",
589+
action="callback", callback=cli.check_before_append,
590+
help=_("Add a watchdog device to the domain."))
556591
fulg.add_option("", "--noapic", action="store_true", dest="noapic",
557592
default=False,
558593
help=_("Disables APIC for fully virtualized guest "
@@ -751,6 +786,7 @@ def main():
751786
cli.get_vcpus(options.vcpus, options.check_cpu, guest, conn)
752787
cli.get_cpuset(options.cpuset, guest.memory, guest, conn)
753788
if ishvm:
789+
get_watchdog(options.watchdog, guest)
754790
cli.get_sound(options.sound, guest)
755791
get_chardevs(VirtualDevice.VIRTUAL_DEV_SERIAL, options.serials, guest)
756792
get_chardevs(VirtualDevice.VIRTUAL_DEV_PARALLEL, options.parallels,

virtinst/VirtualDevice.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class VirtualDevice(object):
4141
VIRTUAL_DEV_CONSOLE = "console"
4242
VIRTUAL_DEV_VIDEO = "video"
4343
VIRTUAL_DEV_CONTROLLER = "controller"
44+
VIRTUAL_DEV_WATCHDOG = "watchdog"
4445

4546
# Ordering in this list is important: it will be the order the
4647
# Guest class outputs XML. So changing this may upset the test suite
@@ -49,7 +50,8 @@ class VirtualDevice(object):
4950
VIRTUAL_DEV_INPUT, VIRTUAL_DEV_GRAPHICS,
5051
VIRTUAL_DEV_SERIAL, VIRTUAL_DEV_PARALLEL,
5152
VIRTUAL_DEV_CONSOLE, VIRTUAL_DEV_AUDIO,
52-
VIRTUAL_DEV_VIDEO, VIRTUAL_DEV_HOSTDEV ]
53+
VIRTUAL_DEV_VIDEO, VIRTUAL_DEV_HOSTDEV,
54+
VIRTUAL_DEV_WATCHDOG ]
5355

5456
# General device type (disk, interface, etc.)
5557
_virtual_device_type = None

0 commit comments

Comments
 (0)