<commit_before>package libvirt

import "encoding/xml"

type Domain struct {
	XMLName xml.Name `xml:"domain"`
	ID      int      `xml:"id,attr,omitempty"`
	Type    string   `xml:"type,attr"`
	Name    string   `xml:"name,omitempty"`
	UUID    string   `xml:"uuid,omitempty"`
	// TODO: metadata

	OS    OS     `xml:"os"`
	IDMap *IDMap `xml:"idmap,omitempty"`

	Memory UnitInt `xml:"memory"`
	VCPU   int     `xml:"vcpu"`

	OnPoweroff string `xml:"on_poweroff,omitempty"`
	OnReboot   string `xml:"on_reboot,omitempty"`
	OnCrash    string `xml:"on_crash,omitempty"`

	Devices Devices `xml:"devices"`
}

func (d *Domain) XML() []byte {
	data, _ := xml.Marshal(d)
	return data
}

type OS struct {
	Type     OSType   `xml:"type"`
	Init     string   `xml:"init"`
	InitArgs []string `xml:"initarg,omitempty"`
}

type OSType struct {
	Value   string `xml:",chardata"`
	Arch    string `xml:"arch,attr,omitempty"`
	Machine string `xml:"machine,attr,omitempty"`
}

type IDMap struct {
	Uid IDMapping `xml:"uid"`
	Gid IDMapping `xml:"gid"`
}

type IDMapping struct {
	Start  int `xml:"start,attr"`
	Target int `xml:"target,attr"`
	Count  int `xml:"count,attr"`
}

type UnitInt struct {
	Value int    `xml:",chardata"`
	Unit  string `xml:"unit,attr,omitempty"`
}

type Devices struct {
	Emulator    string       `xml:"emulator,omitempty"`
	Filesystems []Filesystem `xml:"filesystem"`
	HostDevs    []HostDev    `xml:"hostdev"`
	Interfaces  []Interface  `xml:"interface"`
	Consoles    []Console    `xml:"console"`
}

type Filesystem struct {
	Type   string    `xml:"type,attr,omitempty"`
	Driver *FSDriver `xml:"driver,omitempty"`
	Source FSRef     `xml:"source"`
	Target FSRef     `xml:"target"`
}

type FSDriver struct {
	Name   string `xml:"name,attr,omitempty"`
	Type   string `xml:"type,attr,omitempty"`
	Format string `xml:"format,attr,omitempty"`
}

type FSRef struct {
	Dir  string `xml:"dir,attr,omitempty"`
	File string `xml:"file,attr,omitempty"`
}

type HostDev struct {
	Mode         string `xml:"mode,attr"`
	Type         string `xml:"type,attr"`
	SrcBlock     string `xml:"source>block,omitempty"`
	SrcChar      string `xml:"source>char,omitempty"`
	SrcInterface string `xml:"source>interface,omitempty"`
}

type Interface struct {
	Type   string        `xml:"type,attr"`
	Source InterfaceSrc  `xml:"source"`
	Target *InterfaceSrc `xml:"target,omitempty"`
}

type InterfaceSrc struct {
	Network string `xml:"network,attr,omitempty"`
	Dev     string `xml:"dev,attr,omitempty"`
	Mode    string `xml:"mode,attr,omitempty"`
}

type Console struct {
	Type string `xml:"type,attr"`
}

type Network struct {
	XMLName xml.Name `xml:"network"`
	Name    string   `xml:"name"`
	Bridge  Bridge   `xml:"bridge"`
	Forward Forward  `xml:"forward"`
	IP      IP       `xml:"ip"`
	MAC     MAC      `xml:"mac"`
}

func (n *Network) XML() []byte {
	data, _ := xml.Marshal(n)
	return data
}

type Bridge struct {
	Name string `xml:"name,attr"`
	STP  string `xml:"stp,attr"`
}

type Forward struct {
	Mode string `xml:"mode,attr"`
}

type IP struct {
	Address string `xml:"address,attr"`
	Netmask string `xml:"netmask,attr"`
}

type MAC struct {
	Address string `xml:"address,attr"`
}
<commit_msg>host: Fix libvirt network XML<commit_after>package libvirt

import "encoding/xml"

type Domain struct {
	XMLName xml.Name `xml:"domain"`
	ID      int      `xml:"id,attr,omitempty"`
	Type    string   `xml:"type,attr"`
	Name    string   `xml:"name,omitempty"`
	UUID    string   `xml:"uuid,omitempty"`
	// TODO: metadata

	OS    OS     `xml:"os"`
	IDMap *IDMap `xml:"idmap,omitempty"`

	Memory UnitInt `xml:"memory"`
	VCPU   int     `xml:"vcpu"`

	OnPoweroff string `xml:"on_poweroff,omitempty"`
	OnReboot   string `xml:"on_reboot,omitempty"`
	OnCrash    string `xml:"on_crash,omitempty"`

	Devices Devices `xml:"devices"`
}

func (d *Domain) XML() []byte {
	data, _ := xml.Marshal(d)
	return data
}

type OS struct {
	Type     OSType   `xml:"type"`
	Init     string   `xml:"init"`
	InitArgs []string `xml:"initarg,omitempty"`
}

type OSType struct {
	Value   string `xml:",chardata"`
	Arch    string `xml:"arch,attr,omitempty"`
	Machine string `xml:"machine,attr,omitempty"`
}

type IDMap struct {
	Uid IDMapping `xml:"uid"`
	Gid IDMapping `xml:"gid"`
}

type IDMapping struct {
	Start  int `xml:"start,attr"`
	Target int `xml:"target,attr"`
	Count  int `xml:"count,attr"`
}

type UnitInt struct {
	Value int    `xml:",chardata"`
	Unit  string `xml:"unit,attr,omitempty"`
}

type Devices struct {
	Emulator    string       `xml:"emulator,omitempty"`
	Filesystems []Filesystem `xml:"filesystem"`
	HostDevs    []HostDev    `xml:"hostdev"`
	Interfaces  []Interface  `xml:"interface"`
	Consoles    []Console    `xml:"console"`
}

type Filesystem struct {
	Type   string    `xml:"type,attr,omitempty"`
	Driver *FSDriver `xml:"driver,omitempty"`
	Source FSRef     `xml:"source"`
	Target FSRef     `xml:"target"`
}

type FSDriver struct {
	Name   string `xml:"name,attr,omitempty"`
	Type   string `xml:"type,attr,omitempty"`
	Format string `xml:"format,attr,omitempty"`
}

type FSRef struct {
	Dir  string `xml:"dir,attr,omitempty"`
	File string `xml:"file,attr,omitempty"`
}

type HostDev struct {
	Mode         string `xml:"mode,attr"`
	Type         string `xml:"type,attr"`
	SrcBlock     string `xml:"source>block,omitempty"`
	SrcChar      string `xml:"source>char,omitempty"`
	SrcInterface string `xml:"source>interface,omitempty"`
}

type Interface struct {
	Type   string        `xml:"type,attr"`
	Source InterfaceSrc  `xml:"source"`
	Target *InterfaceSrc `xml:"target,omitempty"`
}

type InterfaceSrc struct {
	Network string `xml:"network,attr,omitempty"`
	Dev     string `xml:"dev,attr,omitempty"`
	Mode    string `xml:"mode,attr,omitempty"`
}

type Console struct {
	Type string `xml:"type,attr"`
}

type Network struct {
	XMLName xml.Name `xml:"network"`
	Name    string   `xml:"name"`
	Bridge  Bridge   `xml:"bridge"`
	Forward Forward  `xml:"forward"`
	IP      *IP      `xml:"ip,omitempty"`
	MAC     *MAC     `xml:"mac,omitempty"`
}

func (n *Network) XML() []byte {
	data, _ := xml.Marshal(n)
	return data
}

type Bridge struct {
	Name string `xml:"name,attr"`
	STP  string `xml:"stp,attr"`
}

type Forward struct {
	Mode string `xml:"mode,attr"`
}

type IP struct {
	Address string `xml:"address,attr"`
	Netmask string `xml:"netmask,attr"`
}

type MAC struct {
	Address string `xml:"address,attr"`
}

{'fraction_non_alphanumeric': 0.14825855036084093, 'fraction_numerical': 0.0, 'mean_word_length': 4.29045643153527, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 138}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5485125', 'n_tokens_mistral': 2187, 'n_tokens_neox': 2152, 'n_words': 550}