Skip to content

Commit

Permalink
Support multiple watchdogs in the domain schema
Browse files Browse the repository at this point in the history
Libvirt allows several watchdog devices since 9.1.0. The documentation
now states:

Having multiple watchdogs is usually not something very common, but be
aware that this might happen, for example, when an implicit watchdog
device is added as part of another device. For example the iTCO watchdog
being part of the ich9 southbridge, which is used with the q35 machine
type.

Signed-off-by: Vasiliy Ulyanov <[email protected]>
  • Loading branch information
vasiliy-ul committed Jul 19, 2023
1 parent d161611 commit df896a5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
10 changes: 6 additions & 4 deletions pkg/virt-launcher/virtwrap/api/deepcopy_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/virt-launcher/virtwrap/api/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ type Devices struct {
Inputs []Input `xml:"input"`
Serials []Serial `xml:"serial"`
Consoles []Console `xml:"console"`
Watchdog *Watchdog `xml:"watchdog,omitempty"`
Watchdogs []Watchdog `xml:"watchdog,omitempty"`
Rng *Rng `xml:"rng,omitempty"`
Filesystems []FilesystemDevice `xml:"filesystem,omitempty"`
Redirs []RedirectedDevice `xml:"redirdev,omitempty"`
Expand Down
10 changes: 6 additions & 4 deletions pkg/virt-launcher/virtwrap/api/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,12 @@ var _ = ginkgo.Describe("Schema", func() {
exampleDomain.Spec.Devices.Consoles = []Console{
{Type: "pty"},
}
exampleDomain.Spec.Devices.Watchdog = &Watchdog{
Model: "i6300esb",
Action: "poweroff",
Alias: NewUserDefinedAlias("mywatchdog"),
exampleDomain.Spec.Devices.Watchdogs = []Watchdog{
{
Model: "i6300esb",
Action: "poweroff",
Alias: NewUserDefinedAlias("mywatchdog"),
},
}
exampleDomain.Spec.Devices.Rng = &Rng{
Model: v1.VirtIO,
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-launcher/virtwrap/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ func Convert_v1_VirtualMachineInstance_To_api_Domain(vmi *v1.VirtualMachineInsta
if err != nil {
return err
}
domain.Spec.Devices.Watchdog = newWatchdog
domain.Spec.Devices.Watchdogs = append(domain.Spec.Devices.Watchdogs, *newWatchdog)
}

if vmi.Spec.Domain.Devices.Rng != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/virt-launcher/virtwrap/converter/pci-placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func PlacePCIDevicesOnRootComplex(spec *api.DomainSpec) (err error) {
return err
}
}
if spec.Devices.Watchdog != nil {
spec.Devices.Watchdog.Address, err = assigner.PlacePCIDeviceAtNextSlot(spec.Devices.Watchdog.Address)
for i, watchdog := range spec.Devices.Watchdogs {
spec.Devices.Watchdogs[i].Address, err = assigner.PlacePCIDeviceAtNextSlot(watchdog.Address)
if err != nil {
return err
}
Expand Down

0 comments on commit df896a5

Please sign in to comment.