diff --git a/go.mod b/go.mod index 6faac09622..d9d18a94b3 100644 --- a/go.mod +++ b/go.mod @@ -65,7 +65,7 @@ require ( k8s.io/api v0.29.3 k8s.io/apimachinery v0.29.3 k8s.io/client-go v0.29.3 - libvirt.org/go/libvirtxml v1.11000.1 + libvirt.org/go/libvirtxml v1.11002.0 ) require ( diff --git a/go.sum b/go.sum index 9265753e96..b1c3a67355 100644 --- a/go.sum +++ b/go.sum @@ -609,8 +609,8 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -libvirt.org/go/libvirtxml v1.11000.1 h1:xbqKCYJRr3QPamY0PKE/exAGgTCosH5s4vB6NPXGcFY= -libvirt.org/go/libvirtxml v1.11000.1/go.mod h1:7Oq2BLDstLr/XtoQD8Fr3mfDNrzlI3utYKySXF2xkng= +libvirt.org/go/libvirtxml v1.11002.0 h1:1dMUj32MAFvV+Qe0sYxrZNcMqa/mdO7sATS91mxth5s= +libvirt.org/go/libvirtxml v1.11002.0/go.mod h1:7Oq2BLDstLr/XtoQD8Fr3mfDNrzlI3utYKySXF2xkng= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/vendor/libvirt.org/go/libvirtxml/domain.go b/vendor/libvirt.org/go/libvirtxml/domain.go index 2cd4851473..2fc08ce426 100644 --- a/vendor/libvirt.org/go/libvirtxml/domain.go +++ b/vendor/libvirt.org/go/libvirtxml/domain.go @@ -78,16 +78,30 @@ type DomainControllerXenBus struct { MaxEventChannels uint `xml:"maxEventChannels,attr,omitempty"` } +type DomainControllerDriverIOThreads struct { + IOThread []DomainControllerDriverIOThread `xml:"iothread"` +} + +type DomainControllerDriverIOThread struct { + ID uint `xml:"id,attr"` + Queues []DomainControllerDriverIOThreadQueue `xml:"queue"` +} + +type DomainControllerDriverIOThreadQueue struct { + ID uint `xml:"id,attr"` +} + type DomainControllerDriver struct { - Queues *uint `xml:"queues,attr"` - CmdPerLUN *uint `xml:"cmd_per_lun,attr"` - MaxSectors *uint `xml:"max_sectors,attr"` - IOEventFD string `xml:"ioeventfd,attr,omitempty"` - IOThread uint `xml:"iothread,attr,omitempty"` - IOMMU string `xml:"iommu,attr,omitempty"` - ATS string `xml:"ats,attr,omitempty"` - Packed string `xml:"packed,attr,omitempty"` - PagePerVQ string `xml:"page_per_vq,attr,omitempty"` + Queues *uint `xml:"queues,attr"` + CmdPerLUN *uint `xml:"cmd_per_lun,attr"` + MaxSectors *uint `xml:"max_sectors,attr"` + IOEventFD string `xml:"ioeventfd,attr,omitempty"` + IOThread uint `xml:"iothread,attr,omitempty"` + IOMMU string `xml:"iommu,attr,omitempty"` + ATS string `xml:"ats,attr,omitempty"` + Packed string `xml:"packed,attr,omitempty"` + PagePerVQ string `xml:"page_per_vq,attr,omitempty"` + IOThreads *DomainControllerDriverIOThreads `xml:"iothreads"` } type DomainController struct { @@ -367,6 +381,14 @@ type DomainDiskIOTune struct { GroupName string `xml:"group_name,omitempty"` } +type ThrottleFilter struct { + Group string `xml:"group,attr"` +} + +type ThrottleFilters struct { + ThrottleFilter []ThrottleFilter `xml:"throttlefilter"` +} + type DomainDiskGeometry struct { Cylinders uint `xml:"cyls,attr"` Headers uint `xml:"heads,attr"` @@ -405,34 +427,35 @@ type DomainBackendDomain struct { } type DomainDisk struct { - XMLName xml.Name `xml:"disk"` - Device string `xml:"device,attr,omitempty"` - RawIO string `xml:"rawio,attr,omitempty"` - SGIO string `xml:"sgio,attr,omitempty"` - Snapshot string `xml:"snapshot,attr,omitempty"` - Model string `xml:"model,attr,omitempty"` - Driver *DomainDiskDriver `xml:"driver"` - Auth *DomainDiskAuth `xml:"auth"` - Source *DomainDiskSource `xml:"source"` - BackingStore *DomainDiskBackingStore `xml:"backingStore"` - BackendDomain *DomainBackendDomain `xml:"backenddomain"` - Geometry *DomainDiskGeometry `xml:"geometry"` - BlockIO *DomainDiskBlockIO `xml:"blockio"` - Mirror *DomainDiskMirror `xml:"mirror"` - Target *DomainDiskTarget `xml:"target"` - IOTune *DomainDiskIOTune `xml:"iotune"` - ReadOnly *DomainDiskReadOnly `xml:"readonly"` - Shareable *DomainDiskShareable `xml:"shareable"` - Transient *DomainDiskTransient `xml:"transient"` - Serial string `xml:"serial,omitempty"` - WWN string `xml:"wwn,omitempty"` - Vendor string `xml:"vendor,omitempty"` - Product string `xml:"product,omitempty"` - Encryption *DomainDiskEncryption `xml:"encryption"` - Boot *DomainDeviceBoot `xml:"boot"` - ACPI *DomainDeviceACPI `xml:"acpi"` - Alias *DomainAlias `xml:"alias"` - Address *DomainAddress `xml:"address"` + XMLName xml.Name `xml:"disk"` + Device string `xml:"device,attr,omitempty"` + RawIO string `xml:"rawio,attr,omitempty"` + SGIO string `xml:"sgio,attr,omitempty"` + Snapshot string `xml:"snapshot,attr,omitempty"` + Model string `xml:"model,attr,omitempty"` + Driver *DomainDiskDriver `xml:"driver"` + Auth *DomainDiskAuth `xml:"auth"` + Source *DomainDiskSource `xml:"source"` + BackingStore *DomainDiskBackingStore `xml:"backingStore"` + BackendDomain *DomainBackendDomain `xml:"backenddomain"` + Geometry *DomainDiskGeometry `xml:"geometry"` + BlockIO *DomainDiskBlockIO `xml:"blockio"` + Mirror *DomainDiskMirror `xml:"mirror"` + Target *DomainDiskTarget `xml:"target"` + IOTune *DomainDiskIOTune `xml:"iotune"` + ThrottleFilters *ThrottleFilters `xml:"throttlefilters"` + ReadOnly *DomainDiskReadOnly `xml:"readonly"` + Shareable *DomainDiskShareable `xml:"shareable"` + Transient *DomainDiskTransient `xml:"transient"` + Serial string `xml:"serial,omitempty"` + WWN string `xml:"wwn,omitempty"` + Vendor string `xml:"vendor,omitempty"` + Product string `xml:"product,omitempty"` + Encryption *DomainDiskEncryption `xml:"encryption"` + Boot *DomainDeviceBoot `xml:"boot"` + ACPI *DomainDeviceACPI `xml:"acpi"` + Alias *DomainAlias `xml:"alias"` + Address *DomainAddress `xml:"address"` } type DomainFilesystemDriver struct { @@ -578,22 +601,27 @@ type DomainInterfaceModel struct { Type string `xml:"type,attr"` } +type DomainInterfaceSourceVHostUser struct { + Chardev *DomainChardevSource `xml:"-"` + Dev string `xml:"-"` +} + type DomainInterfaceSource struct { - User *DomainInterfaceSourceUser `xml:"-"` - Ethernet *DomainInterfaceSourceEthernet `xml:"-"` - VHostUser *DomainChardevSource `xml:"-"` - Server *DomainInterfaceSourceServer `xml:"-"` - Client *DomainInterfaceSourceClient `xml:"-"` - MCast *DomainInterfaceSourceMCast `xml:"-"` - Network *DomainInterfaceSourceNetwork `xml:"-"` - Bridge *DomainInterfaceSourceBridge `xml:"-"` - Internal *DomainInterfaceSourceInternal `xml:"-"` - Direct *DomainInterfaceSourceDirect `xml:"-"` - Hostdev *DomainInterfaceSourceHostdev `xml:"-"` - UDP *DomainInterfaceSourceUDP `xml:"-"` - VDPA *DomainInterfaceSourceVDPA `xml:"-"` - Null *DomainInterfaceSourceNull `xml:"-"` - VDS *DomainInterfaceSourceVDS `xml:"-"` + User *DomainInterfaceSourceUser `xml:"-"` + Ethernet *DomainInterfaceSourceEthernet `xml:"-"` + VHostUser *DomainInterfaceSourceVHostUser `xml:"-"` + Server *DomainInterfaceSourceServer `xml:"-"` + Client *DomainInterfaceSourceClient `xml:"-"` + MCast *DomainInterfaceSourceMCast `xml:"-"` + Network *DomainInterfaceSourceNetwork `xml:"-"` + Bridge *DomainInterfaceSourceBridge `xml:"-"` + Internal *DomainInterfaceSourceInternal `xml:"-"` + Direct *DomainInterfaceSourceDirect `xml:"-"` + Hostdev *DomainInterfaceSourceHostdev `xml:"-"` + UDP *DomainInterfaceSourceUDP `xml:"-"` + VDPA *DomainInterfaceSourceVDPA `xml:"-"` + Null *DomainInterfaceSourceNull `xml:"-"` + VDS *DomainInterfaceSourceVDS `xml:"-"` } type DomainInterfaceSourceUser struct { @@ -1324,6 +1352,8 @@ type DomainGraphicRDP struct { AutoPort string `xml:"autoport,attr,omitempty"` ReplaceUser string `xml:"replaceUser,attr,omitempty"` MultiUser string `xml:"multiUser,attr,omitempty"` + Username string `xml:"username,attr,omitempty"` + Passwd string `xml:"passwd,attr,omitempty"` Listen string `xml:"listen,attr,omitempty"` Listeners []DomainGraphicListener `xml:"listen"` } @@ -1756,8 +1786,15 @@ type DomainHostdevSubsysUSB struct { } type DomainHostdevSubsysUSBSource struct { - GuestReset string `xml:"guestReset,attr,omitempty"` - Address *DomainAddressUSB `xml:"address"` + GuestReset string `xml:"guestReset,attr,omitempty"` + StartUpPolicy string `xml:"startupPolicy,attr,omitempty"` + Address *DomainAddressUSB `xml:"address"` + Product *DomainHostDevProductVendorID `xml:"product"` + Vendor *DomainHostDevProductVendorID `xml:"vendor"` +} + +type DomainHostDevProductVendorID struct { + ID string `xml:"id,attr,omitempty"` } type DomainHostdevSubsysSCSI struct { @@ -2403,6 +2440,7 @@ type DomainOS struct { Kernel string `xml:"kernel,omitempty"` Initrd string `xml:"initrd,omitempty"` Cmdline string `xml:"cmdline,omitempty"` + Shim string `xml:"shim,omitempty"` DTB string `xml:"dtb,omitempty"` ACPI *DomainACPI `xml:"acpi"` BootDevices []DomainBootDevice `xml:"boot"` @@ -2788,6 +2826,10 @@ type DomainFeatureAsyncTeardown struct { Enabled string `xml:"enabled,attr,omitempty"` } +type DomainFeatureAIA struct { + Value string `xml:"value,attr"` +} + type DomainFeatureList struct { PAE *DomainFeature `xml:"pae"` ACPI *DomainFeature `xml:"acpi"` @@ -2818,6 +2860,7 @@ type DomainFeatureList struct { AsyncTeardown *DomainFeatureAsyncTeardown `xml:"async-teardown"` RAS *DomainFeatureState `xml:"ras"` PS2 *DomainFeatureState `xml:"ps2"` + AIA *DomainFeatureAIA `xml:"aia"` } type DomainCPUTuneShares struct { @@ -3136,6 +3179,12 @@ type DomainGenID struct { Value string `xml:",chardata"` } +type DomainThrottleGroups struct { + ThrottleGroups []ThrottleGroup `xml:"throttlegroup"` +} + +type ThrottleGroup DomainDiskIOTune + // NB, try to keep the order of fields in this struct // matching the order of XML elements that libvirt // will generate when dumping XML. @@ -3168,6 +3217,7 @@ type Domain struct { BootloaderArgs string `xml:"bootloader_args,omitempty"` OS *DomainOS `xml:"os"` IDMap *DomainIDMap `xml:"idmap"` + ThrottleGroups *DomainThrottleGroups `xml:"throttlegroups"` Features *DomainFeatureList `xml:"features"` CPU *DomainCPU `xml:"cpu"` Clock *DomainClock `xml:"clock"` @@ -4345,8 +4395,11 @@ func (a *DomainInterfaceSourceHostdev) UnmarshalXML(d *xml.Decoder, start xml.St } } else if typ == "usb" { a.USB = &DomainHostdevSubsysUSBSource{ + "", "", &DomainAddressUSB{}, + &DomainHostDevProductVendorID{}, + &DomainHostDevProductVendorID{}, } err := d.DecodeElement(a.USB, &tok) if err != nil { @@ -4360,6 +4413,43 @@ func (a *DomainInterfaceSourceHostdev) UnmarshalXML(d *xml.Decoder, start xml.St return nil } +func (a *DomainInterfaceSourceVHostUser) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if a.Chardev != nil { + typ := getChardevSourceType(a.Chardev) + if typ != "" { + start.Attr = append(start.Attr, xml.Attr{ + xml.Name{Local: "type"}, typ, + }) + } + return e.EncodeElement(a.Chardev, start) + } else if a.Dev != "" { + start.Attr = append(start.Attr, xml.Attr{ + xml.Name{Local: "dev"}, a.Dev, + }) + e.EncodeToken(start) + e.EncodeToken(start.End()) + e.Flush() + } + return nil +} + +func (a *DomainInterfaceSourceVHostUser) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + dev, ok := getAttr(start.Attr, "dev") + if ok { + a.Dev = dev + d.Skip() + return nil + } else { + typ, ok := getAttr(start.Attr, "type") + if !ok { + typ = "unix" + } + a.Chardev = createChardevSource(typ) + d.DecodeElement(a.Chardev, &start) + } + return nil +} + func (a *DomainInterfaceSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error { if a.User != nil { if a.User.Dev != "" { @@ -4373,12 +4463,6 @@ func (a *DomainInterfaceSource) MarshalXML(e *xml.Encoder, start xml.StartElemen } return nil } else if a.VHostUser != nil { - typ := getChardevSourceType(a.VHostUser) - if typ != "" { - start.Attr = append(start.Attr, xml.Attr{ - xml.Name{Local: "type"}, typ, - }) - } return e.EncodeElement(a.VHostUser, start) } else if a.Server != nil { return e.EncodeElement(a.Server, start) @@ -4414,11 +4498,6 @@ func (a *DomainInterfaceSource) UnmarshalXML(d *xml.Decoder, start xml.StartElem } else if a.Ethernet != nil { return d.DecodeElement(a.Ethernet, &start) } else if a.VHostUser != nil { - typ, ok := getAttr(start.Attr, "type") - if !ok { - typ = "pty" - } - a.VHostUser = createChardevSource(typ) return d.DecodeElement(a.VHostUser, &start) } else if a.Server != nil { return d.DecodeElement(a.Server, &start) @@ -4530,7 +4609,7 @@ func (a *DomainInterface) UnmarshalXML(d *xml.Decoder, start xml.StartElement) e } else if typ == "ethernet" { a.Source.Ethernet = &DomainInterfaceSourceEthernet{} } else if typ == "vhostuser" { - a.Source.VHostUser = &DomainChardevSource{} + a.Source.VHostUser = &DomainInterfaceSourceVHostUser{} } else if typ == "server" { a.Source.Server = &DomainInterfaceSourceServer{} } else if typ == "client" { diff --git a/vendor/libvirt.org/go/libvirtxml/domain_capabilities.go b/vendor/libvirt.org/go/libvirtxml/domain_capabilities.go index 60b83676eb..b88ae1284f 100644 --- a/vendor/libvirt.org/go/libvirtxml/domain_capabilities.go +++ b/vendor/libvirt.org/go/libvirtxml/domain_capabilities.go @@ -191,6 +191,7 @@ type DomainCapsFeatureSEV struct { ReducedPhysBits uint `xml:"reducedPhysBits,omitempty"` MaxGuests uint `xml:"maxGuests,omitempty"` MaxESGuests uint `xml:"maxESGuests,omitempty"` + Cpu0ID string `xml:"cpu0Id,omitempty"` } type DomainCapsFeatureSGX struct { diff --git a/vendor/libvirt.org/go/libvirtxml/node_device.go b/vendor/libvirt.org/go/libvirtxml/node_device.go index fdf3b39d3d..4f392e9733 100644 --- a/vendor/libvirt.org/go/libvirtxml/node_device.go +++ b/vendor/libvirt.org/go/libvirtxml/node_device.go @@ -69,6 +69,7 @@ type NodeDeviceCapability struct { APQueue *NodeDeviceAPQueueCapability APCard *NodeDeviceAPCardCapability APMatrix *NodeDeviceAPMatrixCapability + CCWGroup *NodeDeviceCCWGroupCapability } type NodeDeviceIDName struct { @@ -308,10 +309,19 @@ type NodeDeviceDRMCapability struct { Type string `xml:"type"` } +type NodeDeviceCCWSubCapability struct { + GroupMember *NodeDeviceCCWGroupMemberCapability +} + +type NodeDeviceCCWGroupMemberCapability struct { + GroupDevice string `xml:"group_device"` +} + type NodeDeviceCCWCapability struct { - CSSID *uint `xml:"cssid"` - SSID *uint `xml:"ssid"` - DevNo *uint `xml:"devno"` + CSSID *uint `xml:"cssid"` + SSID *uint `xml:"ssid"` + DevNo *uint `xml:"devno"` + Capabilities []NodeDeviceCCWSubCapability `xml:"capability"` } type NodeDeviceMDevCapability struct { @@ -374,6 +384,33 @@ type NodeDeviceAPMatrixMDevTypesCapability struct { Types []NodeDeviceMDevType `xml:"type"` } +type NodeDeviceCCWGroupCapability struct { + State string `xml:"state",omitempty` + CSSID *uint `xml:"cssid"` + SSID *uint `xml:"ssid"` + DevNo *uint `xml:"devno"` + Members *NodeDeviceCCWGroupMembers `xml:"members"` + Capabilities []NodeDeviceCCWGroupSubCapability `xml:"capability"` +} + +type NodeDeviceCCWGroupMembers struct { + CCWDevice []NodeDeviceCCWGroupMembersDevice `xml:"ccw_device"` +} + +type NodeDeviceCCWGroupMembersDevice struct { + Ref string `xml:"ref,attr,omitempty"` + Name string `xml:",chardata"` +} + +type NodeDeviceCCWGroupSubCapability struct { + QEthGeneric *NodeDeviceCCWGroupSubCapabilityQEthGeneric `xml:"-"` +} + +type NodeDeviceCCWGroupSubCapabilityQEthGeneric struct { + CardType string `xml:"card_type"` + ChpID string `xml:"chpid"` +} + func (a *NodeDevicePCIAddress) MarshalXML(e *xml.Encoder, start xml.StartElement) error { marshalUintAttr(&start, "domain", a.Domain, "0x%04x") marshalUintAttr(&start, "bus", a.Bus, "0x%02x") @@ -462,6 +499,14 @@ func (c *NodeDeviceCCWCapability) MarshalXML(e *xml.Encoder, start xml.StartElem e.EncodeToken(xml.CharData(fmt.Sprintf("0x%04x", *c.DevNo))) e.EncodeToken(devno.End()) } + if c.Capabilities != nil { + for _, subcap := range c.Capabilities { + start := xml.StartElement{ + Name: xml.Name{Local: "capability"}, + } + e.EncodeElement(&subcap, start) + } + } e.EncodeToken(start.End()) return nil } @@ -483,30 +528,38 @@ func (c *NodeDeviceCCWCapability) UnmarshalXML(d *xml.Decoder, start xml.StartEl return err } - if tok.Name.Local != "cssid" && - tok.Name.Local != "ssid" && - tok.Name.Local != "devno" { - continue - } - - chardata, ok := cdata.(xml.CharData) - if !ok { - return fmt.Errorf("Expected text for CCW '%s'", tok.Name.Local) - } + if tok.Name.Local == "cssid" || + tok.Name.Local == "ssid" || + tok.Name.Local == "devno" { + chardata, ok := cdata.(xml.CharData) + if !ok { + return fmt.Errorf("Expected text for CCW '%s'", tok.Name.Local) + } - valstr := strings.TrimPrefix(string(chardata), "0x") - val, err := strconv.ParseUint(valstr, 16, 64) - if err != nil { - return err - } + valstr := strings.TrimPrefix(string(chardata), "0x") + val, err := strconv.ParseUint(valstr, 16, 64) + if err != nil { + return err + } - vali := uint(val) - if tok.Name.Local == "cssid" { - c.CSSID = &vali - } else if tok.Name.Local == "ssid" { - c.SSID = &vali - } else if tok.Name.Local == "devno" { - c.DevNo = &vali + vali := uint(val) + if tok.Name.Local == "cssid" { + c.CSSID = &vali + } else if tok.Name.Local == "ssid" { + c.SSID = &vali + } else if tok.Name.Local == "devno" { + c.DevNo = &vali + } + } else if tok.Name.Local == "capability" { + subcap := &NodeDeviceCCWSubCapability{} + err := d.DecodeElement(subcap, &tok) + if err != nil { + return err + } + c.Capabilities = append(c.Capabilities, *subcap) + continue + } else { + continue } } } @@ -856,6 +909,34 @@ func (c *NodeDeviceStorageSubCapability) UnmarshalXML(d *xml.Decoder, start xml. return nil } +func (c *NodeDeviceCCWSubCapability) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if c.GroupMember != nil { + start.Attr = append(start.Attr, xml.Attr{ + xml.Name{Local: "type"}, "ccwgroup_member", + }) + return e.EncodeElement(c.GroupMember, start) + } + return nil +} + +func (c *NodeDeviceCCWSubCapability) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + typ, ok := getAttr(start.Attr, "type") + if !ok { + return fmt.Errorf("Missing node device capability type") + } + + switch typ { + case "ccwgroup_member": + var groupMemberCaps NodeDeviceCCWGroupMemberCapability + if err := d.DecodeElement(&groupMemberCaps, &start); err != nil { + return err + } + c.GroupMember = &groupMemberCaps + } + d.Skip() + return nil +} + func (c *NodeDeviceStorageSubCapability) MarshalXML(e *xml.Encoder, start xml.StartElement) error { if c.Removable != nil { start.Attr = append(start.Attr, xml.Attr{ @@ -1015,6 +1096,154 @@ func (c *nodeDevicePCIVPDFields) MarshalXML(e *xml.Encoder, start xml.StartEleme return nil } +func (c *NodeDeviceCCWGroupCapability) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + e.EncodeToken(start) + if c.State != "" { + state := xml.StartElement{ + Name: xml.Name{Local: "state"}, + } + e.EncodeToken(state) + e.EncodeToken(xml.CharData(c.State)) + e.EncodeToken(state.End()) + } + if c.CSSID != nil { + cssid := xml.StartElement{ + Name: xml.Name{Local: "cssid"}, + } + e.EncodeToken(cssid) + e.EncodeToken(xml.CharData(fmt.Sprintf("0x%x", *c.CSSID))) + e.EncodeToken(cssid.End()) + } + if c.SSID != nil { + ssid := xml.StartElement{ + Name: xml.Name{Local: "ssid"}, + } + e.EncodeToken(ssid) + e.EncodeToken(xml.CharData(fmt.Sprintf("0x%x", *c.SSID))) + e.EncodeToken(ssid.End()) + } + if c.DevNo != nil { + devno := xml.StartElement{ + Name: xml.Name{Local: "devno"}, + } + e.EncodeToken(devno) + e.EncodeToken(xml.CharData(fmt.Sprintf("0x%04x", *c.DevNo))) + e.EncodeToken(devno.End()) + } + if c.Members != nil { + start := xml.StartElement{ + Name: xml.Name{Local: "members"}, + } + e.EncodeElement(&c.Members, start) + } + if c.Capabilities != nil { + for _, subcap := range c.Capabilities { + start := xml.StartElement{ + Name: xml.Name{Local: "capability"}, + } + e.EncodeElement(&subcap, start) + } + } + e.EncodeToken(start.End()) + return nil +} + +func (c *NodeDeviceCCWGroupCapability) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + for { + tok, err := d.Token() + if err == io.EOF { + break + } + if err != nil { + return err + } + + switch tok := tok.(type) { + case xml.StartElement: + cdata, err := d.Token() + if err != nil { + return err + } + + if tok.Name.Local == "cssid" || + tok.Name.Local == "ssid" || + tok.Name.Local == "devno" { + chardata, ok := cdata.(xml.CharData) + if !ok { + return fmt.Errorf("Expected text for CCW '%s'", tok.Name.Local) + } + + valstr := strings.TrimPrefix(string(chardata), "0x") + val, err := strconv.ParseUint(valstr, 16, 64) + if err != nil { + return err + } + + vali := uint(val) + if tok.Name.Local == "cssid" { + c.CSSID = &vali + } else if tok.Name.Local == "ssid" { + c.SSID = &vali + } else if tok.Name.Local == "devno" { + c.DevNo = &vali + } + } else if tok.Name.Local == "state" { + chardata, ok := cdata.(xml.CharData) + if !ok { + return fmt.Errorf("Expected text for CCW '%s'", tok.Name.Local) + } + + c.State = string(chardata) + } else if tok.Name.Local == "members" { + members := &NodeDeviceCCWGroupMembers{} + err := d.DecodeElement(members, &tok) + if err != nil { + return err + } + c.Members = members + } else if tok.Name.Local == "capability" { + subcap := &NodeDeviceCCWGroupSubCapability{} + err := d.DecodeElement(subcap, &tok) + if err != nil { + return err + } + c.Capabilities = append(c.Capabilities, *subcap) + } else { + continue + } + } + } + return nil +} + +func (c *NodeDeviceCCWGroupSubCapability) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if c.QEthGeneric != nil { + start.Attr = append(start.Attr, xml.Attr{ + xml.Name{Local: "type"}, "qeth_generic", + }) + return e.EncodeElement(c.QEthGeneric, start) + } + return nil +} + +func (c *NodeDeviceCCWGroupSubCapability) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + typ, ok := getAttr(start.Attr, "type") + if !ok { + return fmt.Errorf("Missing node device capability type") + } + + switch typ { + case "qeth_generic": + var qethCaps NodeDeviceCCWGroupSubCapabilityQEthGeneric + if err := d.DecodeElement(&qethCaps, &start); err != nil { + return err + } + c.QEthGeneric = &qethCaps + } + d.Skip() + return nil +} + func (c *NodeDeviceCapability) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { typ, ok := getAttr(start.Attr, "type") if !ok { @@ -1118,6 +1347,12 @@ func (c *NodeDeviceCapability) UnmarshalXML(d *xml.Decoder, start xml.StartEleme return err } c.APCard = &apCaps + case "ccwgroup": + var ccwGroupCaps NodeDeviceCCWGroupCapability + if err := d.DecodeElement(&ccwGroupCaps, &start); err != nil { + return err + } + c.CCWGroup = &ccwGroupCaps } d.Skip() return nil @@ -1204,6 +1439,11 @@ func (c *NodeDeviceCapability) MarshalXML(e *xml.Encoder, start xml.StartElement xml.Name{Local: "type"}, "ap_matrix", }) return e.EncodeElement(c.APMatrix, start) + } else if c.CCWGroup != nil { + start.Attr = append(start.Attr, xml.Attr{ + xml.Name{Local: "type"}, "ccwgroup", + }) + return e.EncodeElement(c.CCWGroup, start) } return nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 4d46ffbecb..cc95b913b8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1342,7 +1342,7 @@ k8s.io/utils/integer k8s.io/utils/internal/third_party/forked/golang/net k8s.io/utils/net k8s.io/utils/strings/slices -# libvirt.org/go/libvirtxml v1.11000.1 +# libvirt.org/go/libvirtxml v1.11002.0 ## explicit; go 1.11 libvirt.org/go/libvirtxml # sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd