domain.go 147 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218
  1. /*
  2. * This file is part of the libvirt-go-xml project
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. *
  22. * Copyright (C) 2016 Red Hat, Inc.
  23. *
  24. */
  25. package libvirtxml
  26. import (
  27. "encoding/xml"
  28. "fmt"
  29. "io"
  30. "strconv"
  31. "strings"
  32. )
  33. type DomainControllerPCIHole64 struct {
  34. Size uint64 `xml:",chardata"`
  35. Unit string `xml:"unit,attr,omitempty"`
  36. }
  37. type DomainControllerPCIModel struct {
  38. Name string `xml:"name,attr"`
  39. }
  40. type DomainControllerPCITarget struct {
  41. ChassisNr *uint
  42. Chassis *uint
  43. Port *uint
  44. BusNr *uint
  45. Index *uint
  46. NUMANode *uint
  47. }
  48. type DomainControllerPCI struct {
  49. Model *DomainControllerPCIModel `xml:"model"`
  50. Target *DomainControllerPCITarget `xml:"target"`
  51. Hole64 *DomainControllerPCIHole64 `xml:"pcihole64"`
  52. }
  53. type DomainControllerUSBMaster struct {
  54. StartPort uint `xml:"startport,attr"`
  55. }
  56. type DomainControllerUSB struct {
  57. Port *uint `xml:"ports,attr"`
  58. Master *DomainControllerUSBMaster `xml:"master"`
  59. }
  60. type DomainControllerVirtIOSerial struct {
  61. Ports *uint `xml:"ports,attr"`
  62. Vectors *uint `xml:"vectors,attr"`
  63. }
  64. type DomainControllerXenBus struct {
  65. MaxGrantFrames uint `xml:"maxGrantFrames,attr,omitempty"`
  66. }
  67. type DomainControllerDriver struct {
  68. Queues *uint `xml:"queues,attr"`
  69. CmdPerLUN *uint `xml:"cmd_per_lun,attr"`
  70. MaxSectors *uint `xml:"max_sectors,attr"`
  71. IOEventFD string `xml:"ioeventfd,attr,omitempty"`
  72. IOThread uint `xml:"iothread,attr,omitempty"`
  73. IOMMU string `xml:"iommu,attr,omitempty"`
  74. ATS string `xml:"ats,attr,omitempty"`
  75. }
  76. type DomainController struct {
  77. XMLName xml.Name `xml:"controller"`
  78. Type string `xml:"type,attr"`
  79. Index *uint `xml:"index,attr"`
  80. Model string `xml:"model,attr,omitempty"`
  81. Driver *DomainControllerDriver `xml:"driver"`
  82. PCI *DomainControllerPCI `xml:"-"`
  83. USB *DomainControllerUSB `xml:"-"`
  84. VirtIOSerial *DomainControllerVirtIOSerial `xml:"-"`
  85. XenBus *DomainControllerXenBus `xml:"-"`
  86. Alias *DomainAlias `xml:"alias"`
  87. Address *DomainAddress `xml:"address"`
  88. }
  89. type DomainDiskSecret struct {
  90. Type string `xml:"type,attr,omitempty"`
  91. Usage string `xml:"usage,attr,omitempty"`
  92. UUID string `xml:"uuid,attr,omitempty"`
  93. }
  94. type DomainDiskAuth struct {
  95. Username string `xml:"username,attr,omitempty"`
  96. Secret *DomainDiskSecret `xml:"secret"`
  97. }
  98. type DomainDiskSourceHost struct {
  99. Transport string `xml:"transport,attr,omitempty"`
  100. Name string `xml:"name,attr,omitempty"`
  101. Port string `xml:"port,attr,omitempty"`
  102. Socket string `xml:"socket,attr,omitempty"`
  103. }
  104. type DomainDiskReservationsSource DomainChardevSource
  105. type DomainDiskReservations struct {
  106. Enabled string `xml:"enabled,attr,omitempty"`
  107. Managed string `xml:"managed,attr,omitempty"`
  108. Source *DomainDiskReservationsSource `xml:"source"`
  109. }
  110. type DomainDiskSource struct {
  111. File *DomainDiskSourceFile `xml:"-"`
  112. Block *DomainDiskSourceBlock `xml:"-"`
  113. Dir *DomainDiskSourceDir `xml:"-"`
  114. Network *DomainDiskSourceNetwork `xml:"-"`
  115. Volume *DomainDiskSourceVolume `xml:"-"`
  116. StartupPolicy string `xml:"startupPolicy,attr,omitempty"`
  117. Index uint `xml:"index,attr,omitempty"`
  118. Encryption *DomainDiskEncryption `xml:"encryption"`
  119. Reservations *DomainDiskReservations `xml:"reservations"`
  120. }
  121. type DomainDiskSourceFile struct {
  122. File string `xml:"file,attr,omitempty"`
  123. SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
  124. }
  125. type DomainDiskSourceBlock struct {
  126. Dev string `xml:"dev,attr,omitempty"`
  127. SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
  128. }
  129. type DomainDiskSourceDir struct {
  130. Dir string `xml:"dir,attr,omitempty"`
  131. }
  132. type DomainDiskSourceNetwork struct {
  133. Protocol string `xml:"protocol,attr,omitempty"`
  134. Name string `xml:"name,attr,omitempty"`
  135. TLS string `xml:"tls,attr,omitempty"`
  136. Hosts []DomainDiskSourceHost `xml:"host"`
  137. Initiator *DomainDiskSourceNetworkInitiator `xml:"initiator"`
  138. Snapshot *DomainDiskSourceNetworkSnapshot `xml:"snapshot"`
  139. Config *DomainDiskSourceNetworkConfig `xml:"config"`
  140. Auth *DomainDiskAuth `xml:"auth"`
  141. }
  142. type DomainDiskSourceNetworkInitiator struct {
  143. IQN *DomainDiskSourceNetworkIQN `xml:"iqn"`
  144. }
  145. type DomainDiskSourceNetworkIQN struct {
  146. Name string `xml:"name,attr,omitempty"`
  147. }
  148. type DomainDiskSourceNetworkSnapshot struct {
  149. Name string `xml:"name,attr"`
  150. }
  151. type DomainDiskSourceNetworkConfig struct {
  152. File string `xml:"file,attr"`
  153. }
  154. type DomainDiskSourceVolume struct {
  155. Pool string `xml:"pool,attr,omitempty"`
  156. Volume string `xml:"volume,attr,omitempty"`
  157. Mode string `xml:"mode,attr,omitempty"`
  158. SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
  159. }
  160. type DomainDiskDriver struct {
  161. Name string `xml:"name,attr,omitempty"`
  162. Type string `xml:"type,attr,omitempty"`
  163. Cache string `xml:"cache,attr,omitempty"`
  164. ErrorPolicy string `xml:"error_policy,attr,omitempty"`
  165. RErrorPolicy string `xml:"rerror_policy,attr,omitempty"`
  166. IO string `xml:"io,attr,omitempty"`
  167. IOEventFD string `xml:"ioeventfd,attr,omitempty"`
  168. EventIDX string `xml:"event_idx,attr,omitempty"`
  169. CopyOnRead string `xml:"copy_on_read,attr,omitempty"`
  170. Discard string `xml:"discard,attr,omitempty"`
  171. IOThread *uint `xml:"iothread,attr"`
  172. DetectZeros string `xml:"detect_zeroes,attr,omitempty"`
  173. Queues *uint `xml:"queues,attr"`
  174. IOMMU string `xml:"iommu,attr,omitempty"`
  175. ATS string `xml:"ats,attr,omitempty"`
  176. }
  177. type DomainDiskTarget struct {
  178. Dev string `xml:"dev,attr,omitempty"`
  179. Bus string `xml:"bus,attr,omitempty"`
  180. Tray string `xml:"tray,attr,omitempty"`
  181. Removable string `xml:"removable,attr,omitempty"`
  182. }
  183. type DomainDiskEncryption struct {
  184. Format string `xml:"format,attr,omitempty"`
  185. Secret *DomainDiskSecret `xml:"secret"`
  186. }
  187. type DomainDiskReadOnly struct {
  188. }
  189. type DomainDiskShareable struct {
  190. }
  191. type DomainDiskTransient struct {
  192. }
  193. type DomainDiskIOTune struct {
  194. TotalBytesSec uint64 `xml:"total_bytes_sec,omitempty"`
  195. ReadBytesSec uint64 `xml:"read_bytes_sec,omitempty"`
  196. WriteBytesSec uint64 `xml:"write_bytes_sec,omitempty"`
  197. TotalIopsSec uint64 `xml:"total_iops_sec,omitempty"`
  198. ReadIopsSec uint64 `xml:"read_iops_sec,omitempty"`
  199. WriteIopsSec uint64 `xml:"write_iops_sec,omitempty"`
  200. TotalBytesSecMax uint64 `xml:"total_bytes_sec_max,omitempty"`
  201. ReadBytesSecMax uint64 `xml:"read_bytes_sec_max,omitempty"`
  202. WriteBytesSecMax uint64 `xml:"write_bytes_sec_max,omitempty"`
  203. TotalIopsSecMax uint64 `xml:"total_iops_sec_max,omitempty"`
  204. ReadIopsSecMax uint64 `xml:"read_iops_sec_max,omitempty"`
  205. WriteIopsSecMax uint64 `xml:"write_iops_sec_max,omitempty"`
  206. TotalBytesSecMaxLength uint64 `xml:"total_bytes_sec_max_length,omitempty"`
  207. ReadBytesSecMaxLength uint64 `xml:"read_bytes_sec_max_length,omitempty"`
  208. WriteBytesSecMaxLength uint64 `xml:"write_bytes_sec_max_length,omitempty"`
  209. TotalIopsSecMaxLength uint64 `xml:"total_iops_sec_max_length,omitempty"`
  210. ReadIopsSecMaxLength uint64 `xml:"read_iops_sec_max_length,omitempty"`
  211. WriteIopsSecMaxLength uint64 `xml:"write_iops_sec_max_length,omitempty"`
  212. SizeIopsSec uint64 `xml:"size_iops_sec,omitempty"`
  213. GroupName string `xml:"group_name,omitempty"`
  214. }
  215. type DomainDiskGeometry struct {
  216. Cylinders uint `xml:"cyls,attr"`
  217. Headers uint `xml:"heads,attr"`
  218. Sectors uint `xml:"secs,attr"`
  219. Trans string `xml:"trans,attr,omitempty"`
  220. }
  221. type DomainDiskBlockIO struct {
  222. LogicalBlockSize uint `xml:"logical_block_size,attr,omitempty"`
  223. PhysicalBlockSize uint `xml:"physical_block_size,attr,omitempty"`
  224. }
  225. type DomainDiskFormat struct {
  226. Type string `xml:"type,attr"`
  227. }
  228. type DomainDiskBackingStore struct {
  229. Index uint `xml:"index,attr,omitempty"`
  230. Format *DomainDiskFormat `xml:"format"`
  231. Source *DomainDiskSource `xml:"source"`
  232. BackingStore *DomainDiskBackingStore `xml:"backingStore"`
  233. }
  234. type DomainDiskMirror struct {
  235. Job string `xml:"job,attr,omitempty"`
  236. Ready string `xml:"ready,attr,omitempty"`
  237. Format *DomainDiskFormat `xml:"format"`
  238. Source *DomainDiskSource `xml:"source"`
  239. }
  240. type DomainDisk struct {
  241. XMLName xml.Name `xml:"disk"`
  242. Device string `xml:"device,attr,omitempty"`
  243. RawIO string `xml:"rawio,attr,omitempty"`
  244. SGIO string `xml:"sgio,attr,omitempty"`
  245. Snapshot string `xml:"snapshot,attr,omitempty"`
  246. Model string `xml:"model,attr,omitempty"`
  247. Driver *DomainDiskDriver `xml:"driver"`
  248. Auth *DomainDiskAuth `xml:"auth"`
  249. Source *DomainDiskSource `xml:"source"`
  250. BackingStore *DomainDiskBackingStore `xml:"backingStore"`
  251. Geometry *DomainDiskGeometry `xml:"geometry"`
  252. BlockIO *DomainDiskBlockIO `xml:"blockio"`
  253. Mirror *DomainDiskMirror `xml:"mirror"`
  254. Target *DomainDiskTarget `xml:"target"`
  255. IOTune *DomainDiskIOTune `xml:"iotune"`
  256. ReadOnly *DomainDiskReadOnly `xml:"readonly"`
  257. Shareable *DomainDiskShareable `xml:"shareable"`
  258. Transient *DomainDiskTransient `xml:"transient"`
  259. Serial string `xml:"serial,omitempty"`
  260. WWN string `xml:"wwn,omitempty"`
  261. Vendor string `xml:"vendor,omitempty"`
  262. Product string `xml:"product,omitempty"`
  263. Encryption *DomainDiskEncryption `xml:"encryption"`
  264. Boot *DomainDeviceBoot `xml:"boot"`
  265. Alias *DomainAlias `xml:"alias"`
  266. Address *DomainAddress `xml:"address"`
  267. }
  268. type DomainFilesystemDriver struct {
  269. Type string `xml:"type,attr,omitempty"`
  270. Format string `xml:"format,attr,omitempty"`
  271. Name string `xml:"name,attr,omitempty"`
  272. WRPolicy string `xml:"wrpolicy,attr,omitempty"`
  273. IOMMU string `xml:"iommu,attr,omitempty"`
  274. ATS string `xml:"ats,attr,omitempty"`
  275. }
  276. type DomainFilesystemSource struct {
  277. Mount *DomainFilesystemSourceMount `xml:"-"`
  278. Block *DomainFilesystemSourceBlock `xml:"-"`
  279. File *DomainFilesystemSourceFile `xml:"-"`
  280. Template *DomainFilesystemSourceTemplate `xml:"-"`
  281. RAM *DomainFilesystemSourceRAM `xml:"-"`
  282. Bind *DomainFilesystemSourceBind `xml:"-"`
  283. Volume *DomainFilesystemSourceVolume `xml:"-"`
  284. }
  285. type DomainFilesystemSourceMount struct {
  286. Dir string `xml:"dir,attr"`
  287. }
  288. type DomainFilesystemSourceBlock struct {
  289. Dev string `xml:"dev,attr"`
  290. }
  291. type DomainFilesystemSourceFile struct {
  292. File string `xml:"file,attr"`
  293. }
  294. type DomainFilesystemSourceTemplate struct {
  295. Name string `xml:"name,attr"`
  296. }
  297. type DomainFilesystemSourceRAM struct {
  298. Usage uint `xml:"usage,attr"`
  299. Units string `xml:"units,attr,omitempty"`
  300. }
  301. type DomainFilesystemSourceBind struct {
  302. Dir string `xml:"dir,attr"`
  303. }
  304. type DomainFilesystemSourceVolume struct {
  305. Pool string `xml:"pool,attr"`
  306. Volume string `xml:"volume,attr"`
  307. }
  308. type DomainFilesystemTarget struct {
  309. Dir string `xml:"dir,attr"`
  310. }
  311. type DomainFilesystemReadOnly struct {
  312. }
  313. type DomainFilesystemSpaceHardLimit struct {
  314. Value uint `xml:",chardata"`
  315. Unit string `xml:"unit,attr,omitempty"`
  316. }
  317. type DomainFilesystemSpaceSoftLimit struct {
  318. Value uint `xml:",chardata"`
  319. Unit string `xml:"unit,attr,omitempty"`
  320. }
  321. type DomainFilesystem struct {
  322. XMLName xml.Name `xml:"filesystem"`
  323. AccessMode string `xml:"accessmode,attr,omitempty"`
  324. Model string `xml:"model,attr,omitempty"`
  325. Driver *DomainFilesystemDriver `xml:"driver"`
  326. Source *DomainFilesystemSource `xml:"source"`
  327. Target *DomainFilesystemTarget `xml:"target"`
  328. ReadOnly *DomainFilesystemReadOnly `xml:"readonly"`
  329. SpaceHardLimit *DomainFilesystemSpaceHardLimit `xml:"space_hard_limit"`
  330. SpaceSoftLimit *DomainFilesystemSpaceSoftLimit `xml:"space_soft_limit"`
  331. Alias *DomainAlias `xml:"alias"`
  332. Address *DomainAddress `xml:"address"`
  333. }
  334. type DomainInterfaceMAC struct {
  335. Address string `xml:"address,attr"`
  336. }
  337. type DomainInterfaceModel struct {
  338. Type string `xml:"type,attr"`
  339. }
  340. type DomainInterfaceSource struct {
  341. User *DomainInterfaceSourceUser `xml:"-"`
  342. Ethernet *DomainInterfaceSourceEthernet `xml:"-"`
  343. VHostUser *DomainChardevSource `xml:"-"`
  344. Server *DomainInterfaceSourceServer `xml:"-"`
  345. Client *DomainInterfaceSourceClient `xml:"-"`
  346. MCast *DomainInterfaceSourceMCast `xml:"-"`
  347. Network *DomainInterfaceSourceNetwork `xml:"-"`
  348. Bridge *DomainInterfaceSourceBridge `xml:"-"`
  349. Internal *DomainInterfaceSourceInternal `xml:"-"`
  350. Direct *DomainInterfaceSourceDirect `xml:"-"`
  351. Hostdev *DomainInterfaceSourceHostdev `xml:"-"`
  352. UDP *DomainInterfaceSourceUDP `xml:"-"`
  353. }
  354. type DomainInterfaceSourceUser struct {
  355. }
  356. type DomainInterfaceSourceEthernet struct {
  357. IP []DomainInterfaceIP `xml:"ip"`
  358. Route []DomainInterfaceRoute `xml:"route"`
  359. }
  360. type DomainInterfaceSourceServer struct {
  361. Address string `xml:"address,attr,omitempty"`
  362. Port uint `xml:"port,attr,omitempty"`
  363. Local *DomainInterfaceSourceLocal `xml:"local"`
  364. }
  365. type DomainInterfaceSourceClient struct {
  366. Address string `xml:"address,attr,omitempty"`
  367. Port uint `xml:"port,attr,omitempty"`
  368. Local *DomainInterfaceSourceLocal `xml:"local"`
  369. }
  370. type DomainInterfaceSourceMCast struct {
  371. Address string `xml:"address,attr,omitempty"`
  372. Port uint `xml:"port,attr,omitempty"`
  373. Local *DomainInterfaceSourceLocal `xml:"local"`
  374. }
  375. type DomainInterfaceSourceNetwork struct {
  376. Network string `xml:"network,attr,omitempty"`
  377. PortGroup string `xml:"portgroup,attr,omitempty"`
  378. Bridge string `xml:"bridge,attr,omitempty"`
  379. }
  380. type DomainInterfaceSourceBridge struct {
  381. Bridge string `xml:"bridge,attr"`
  382. }
  383. type DomainInterfaceSourceInternal struct {
  384. Name string `xml:"name,attr,omitempty"`
  385. }
  386. type DomainInterfaceSourceDirect struct {
  387. Dev string `xml:"dev,attr,omitempty"`
  388. Mode string `xml:"mode,attr,omitempty"`
  389. }
  390. type DomainInterfaceSourceHostdev struct {
  391. PCI *DomainHostdevSubsysPCISource `xml:"-"`
  392. USB *DomainHostdevSubsysUSBSource `xml:"-"`
  393. }
  394. type DomainInterfaceSourceUDP struct {
  395. Address string `xml:"address,attr,omitempty"`
  396. Port uint `xml:"port,attr,omitempty"`
  397. Local *DomainInterfaceSourceLocal `xml:"local"`
  398. }
  399. type DomainInterfaceSourceLocal struct {
  400. Address string `xml:"address,attr,omitempty"`
  401. Port uint `xml:"port,attr,omitempty"`
  402. }
  403. type DomainInterfaceTarget struct {
  404. Dev string `xml:"dev,attr"`
  405. }
  406. type DomainInterfaceLink struct {
  407. State string `xml:"state,attr"`
  408. }
  409. type DomainDeviceBoot struct {
  410. Order uint `xml:"order,attr"`
  411. LoadParm string `xml:"loadparm,attr,omitempty"`
  412. }
  413. type DomainInterfaceScript struct {
  414. Path string `xml:"path,attr"`
  415. }
  416. type DomainInterfaceDriver struct {
  417. Name string `xml:"name,attr,omitempty"`
  418. TXMode string `xml:"txmode,attr,omitempty"`
  419. IOEventFD string `xml:"ioeventfd,attr,omitempty"`
  420. EventIDX string `xml:"event_idx,attr,omitempty"`
  421. Queues uint `xml:"queues,attr,omitempty"`
  422. RXQueueSize uint `xml:"rx_queue_size,attr,omitempty"`
  423. TXQueueSize uint `xml:"tx_queue_size,attr,omitempty"`
  424. IOMMU string `xml:"iommu,attr,omitempty"`
  425. ATS string `xml:"ats,attr,omitempty"`
  426. Host *DomainInterfaceDriverHost `xml:"host"`
  427. Guest *DomainInterfaceDriverGuest `xml:"guest"`
  428. }
  429. type DomainInterfaceDriverHost struct {
  430. CSum string `xml:"csum,attr,omitempty"`
  431. GSO string `xml:"gso,attr,omitempty"`
  432. TSO4 string `xml:"tso4,attr,omitempty"`
  433. TSO6 string `xml:"tso6,attr,omitempty"`
  434. ECN string `xml:"ecn,attr,omitempty"`
  435. UFO string `xml:"ufo,attr,omitempty"`
  436. MrgRXBuf string `xml:"mrg_rxbuf,attr,omitempty"`
  437. }
  438. type DomainInterfaceDriverGuest struct {
  439. CSum string `xml:"csum,attr,omitempty"`
  440. TSO4 string `xml:"tso4,attr,omitempty"`
  441. TSO6 string `xml:"tso6,attr,omitempty"`
  442. ECN string `xml:"ecn,attr,omitempty"`
  443. UFO string `xml:"ufo,attr,omitempty"`
  444. }
  445. type DomainInterfaceVirtualPort struct {
  446. Params *DomainInterfaceVirtualPortParams `xml:"parameters"`
  447. }
  448. type DomainInterfaceVirtualPortParams struct {
  449. Any *DomainInterfaceVirtualPortParamsAny `xml:"-"`
  450. VEPA8021QBG *DomainInterfaceVirtualPortParamsVEPA8021QBG `xml:"-"`
  451. VNTag8011QBH *DomainInterfaceVirtualPortParamsVNTag8021QBH `xml:"-"`
  452. OpenVSwitch *DomainInterfaceVirtualPortParamsOpenVSwitch `xml:"-"`
  453. MidoNet *DomainInterfaceVirtualPortParamsMidoNet `xml:"-"`
  454. }
  455. type DomainInterfaceVirtualPortParamsAny struct {
  456. ManagerID *uint `xml:"managerid,attr"`
  457. TypeID *uint `xml:"typeid,attr"`
  458. TypeIDVersion *uint `xml:"typeidversion,attr"`
  459. InstanceID string `xml:"instanceid,attr,omitempty"`
  460. ProfileID string `xml:"profileid,attr,omitempty"`
  461. InterfaceID string `xml:"interfaceid,attr,omitempty"`
  462. }
  463. type DomainInterfaceVirtualPortParamsVEPA8021QBG struct {
  464. ManagerID *uint `xml:"managerid,attr"`
  465. TypeID *uint `xml:"typeid,attr"`
  466. TypeIDVersion *uint `xml:"typeidversion,attr"`
  467. InstanceID string `xml:"instanceid,attr,omitempty"`
  468. }
  469. type DomainInterfaceVirtualPortParamsVNTag8021QBH struct {
  470. ProfileID string `xml:"profileid,attr,omitempty"`
  471. }
  472. type DomainInterfaceVirtualPortParamsOpenVSwitch struct {
  473. InterfaceID string `xml:"interfaceid,attr,omitempty"`
  474. ProfileID string `xml:"profileid,attr,omitempty"`
  475. }
  476. type DomainInterfaceVirtualPortParamsMidoNet struct {
  477. InterfaceID string `xml:"interfaceid,attr,omitempty"`
  478. }
  479. type DomainInterfaceBandwidthParams struct {
  480. Average *int `xml:"average,attr"`
  481. Peak *int `xml:"peak,attr"`
  482. Burst *int `xml:"burst,attr"`
  483. Floor *int `xml:"floor,attr"`
  484. }
  485. type DomainInterfaceBandwidth struct {
  486. Inbound *DomainInterfaceBandwidthParams `xml:"inbound"`
  487. Outbound *DomainInterfaceBandwidthParams `xml:"outbound"`
  488. }
  489. type DomainInterfaceVLan struct {
  490. Trunk string `xml:"trunk,attr,omitempty"`
  491. Tags []DomainInterfaceVLanTag `xml:"tag"`
  492. }
  493. type DomainInterfaceVLanTag struct {
  494. ID uint `xml:"id,attr"`
  495. NativeMode string `xml:"nativeMode,attr,omitempty"`
  496. }
  497. type DomainInterfaceGuest struct {
  498. Dev string `xml:"dev,attr,omitempty"`
  499. Actual string `xml:"actual,attr,omitempty"`
  500. }
  501. type DomainInterfaceFilterRef struct {
  502. Filter string `xml:"filter,attr"`
  503. Parameters []DomainInterfaceFilterParam `xml:"parameter"`
  504. }
  505. type DomainInterfaceFilterParam struct {
  506. Name string `xml:"name,attr"`
  507. Value string `xml:"value,attr"`
  508. }
  509. type DomainInterfaceBackend struct {
  510. Tap string `xml:"tap,attr,omitempty"`
  511. VHost string `xml:"vhost,attr,omitempty"`
  512. }
  513. type DomainInterfaceTune struct {
  514. SndBuf uint `xml:"sndbuf"`
  515. }
  516. type DomainInterfaceMTU struct {
  517. Size uint `xml:"size,attr"`
  518. }
  519. type DomainInterfaceCoalesce struct {
  520. RX *DomainInterfaceCoalesceRX `xml:"rx"`
  521. }
  522. type DomainInterfaceCoalesceRX struct {
  523. Frames *DomainInterfaceCoalesceRXFrames `xml:"frames"`
  524. }
  525. type DomainInterfaceCoalesceRXFrames struct {
  526. Max *uint `xml:"max,attr"`
  527. }
  528. type DomainROM struct {
  529. Bar string `xml:"bar,attr,omitempty"`
  530. File string `xml:"file,attr,omitempty"`
  531. Enabled string `xml:"enabled,attr,omitempty"`
  532. }
  533. type DomainInterfaceIP struct {
  534. Address string `xml:"address,attr"`
  535. Family string `xml:"family,attr,omitempty"`
  536. Prefix uint `xml:"prefix,attr,omitempty"`
  537. Peer string `xml:"peer,attr,omitempty"`
  538. }
  539. type DomainInterfaceRoute struct {
  540. Family string `xml:"family,attr,omitempty"`
  541. Address string `xml:"address,attr"`
  542. Netmask string `xml:"netmask,attr,omitempty"`
  543. Prefix uint `xml:"prefix,attr,omitempty"`
  544. Gateway string `xml:"gateway,attr"`
  545. Metric uint `xml:"metric,attr,omitempty"`
  546. }
  547. type DomainInterface struct {
  548. XMLName xml.Name `xml:"interface"`
  549. Managed string `xml:"managed,attr,omitempty"`
  550. TrustGuestRXFilters string `xml:"trustGuestRxFilters,attr,omitempty"`
  551. MAC *DomainInterfaceMAC `xml:"mac"`
  552. Source *DomainInterfaceSource `xml:"source"`
  553. Boot *DomainDeviceBoot `xml:"boot"`
  554. VLan *DomainInterfaceVLan `xml:"vlan"`
  555. VirtualPort *DomainInterfaceVirtualPort `xml:"virtualport"`
  556. IP []DomainInterfaceIP `xml:"ip"`
  557. Route []DomainInterfaceRoute `xml:"route"`
  558. Script *DomainInterfaceScript `xml:"script"`
  559. Target *DomainInterfaceTarget `xml:"target"`
  560. Guest *DomainInterfaceGuest `xml:"guest"`
  561. Model *DomainInterfaceModel `xml:"model"`
  562. Driver *DomainInterfaceDriver `xml:"driver"`
  563. Backend *DomainInterfaceBackend `xml:"backend"`
  564. FilterRef *DomainInterfaceFilterRef `xml:"filterref"`
  565. Tune *DomainInterfaceTune `xml:"tune"`
  566. Link *DomainInterfaceLink `xml:"link"`
  567. MTU *DomainInterfaceMTU `xml:"mtu"`
  568. Bandwidth *DomainInterfaceBandwidth `xml:"bandwidth"`
  569. Coalesce *DomainInterfaceCoalesce `xml:"coalesce"`
  570. ROM *DomainROM `xml:"rom"`
  571. Alias *DomainAlias `xml:"alias"`
  572. Address *DomainAddress `xml:"address"`
  573. }
  574. type DomainChardevSource struct {
  575. Null *DomainChardevSourceNull `xml:"-"`
  576. VC *DomainChardevSourceVC `xml:"-"`
  577. Pty *DomainChardevSourcePty `xml:"-"`
  578. Dev *DomainChardevSourceDev `xml:"-"`
  579. File *DomainChardevSourceFile `xml:"-"`
  580. Pipe *DomainChardevSourcePipe `xml:"-"`
  581. StdIO *DomainChardevSourceStdIO `xml:"-"`
  582. UDP *DomainChardevSourceUDP `xml:"-"`
  583. TCP *DomainChardevSourceTCP `xml:"-"`
  584. UNIX *DomainChardevSourceUNIX `xml:"-"`
  585. SpiceVMC *DomainChardevSourceSpiceVMC `xml:"-"`
  586. SpicePort *DomainChardevSourceSpicePort `xml:"-"`
  587. NMDM *DomainChardevSourceNMDM `xml:"-"`
  588. }
  589. type DomainChardevSourceNull struct {
  590. }
  591. type DomainChardevSourceVC struct {
  592. }
  593. type DomainChardevSourcePty struct {
  594. Path string `xml:"path,attr"`
  595. SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
  596. }
  597. type DomainChardevSourceDev struct {
  598. Path string `xml:"path,attr"`
  599. SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
  600. }
  601. type DomainChardevSourceFile struct {
  602. Path string `xml:"path,attr"`
  603. Append string `xml:"append,attr,omitempty"`
  604. SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
  605. }
  606. type DomainChardevSourcePipe struct {
  607. Path string `xml:"path,attr"`
  608. SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
  609. }
  610. type DomainChardevSourceStdIO struct {
  611. }
  612. type DomainChardevSourceUDP struct {
  613. BindHost string `xml:"-"`
  614. BindService string `xml:"-"`
  615. ConnectHost string `xml:"-"`
  616. ConnectService string `xml:"-"`
  617. }
  618. type DomainChardevSourceReconnect struct {
  619. Enabled string `xml:"enabled,attr"`
  620. Timeout *uint `xml:"timeout,attr"`
  621. }
  622. type DomainChardevSourceTCP struct {
  623. Mode string `xml:"mode,attr,omitempty"`
  624. Host string `xml:"host,attr,omitempty"`
  625. Service string `xml:"service,attr,omitempty"`
  626. TLS string `xml:"tls,attr,omitempty"`
  627. Reconnect *DomainChardevSourceReconnect `xml:"reconnect"`
  628. }
  629. type DomainChardevSourceUNIX struct {
  630. Mode string `xml:"mode,attr,omitempty"`
  631. Path string `xml:"path,attr,omitempty"`
  632. Reconnect *DomainChardevSourceReconnect `xml:"reconnect"`
  633. SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
  634. }
  635. type DomainChardevSourceSpiceVMC struct {
  636. }
  637. type DomainChardevSourceSpicePort struct {
  638. Channel string `xml:"channel,attr"`
  639. }
  640. type DomainChardevSourceNMDM struct {
  641. Master string `xml:"master,attr"`
  642. Slave string `xml:"slave,attr"`
  643. }
  644. type DomainChardevTarget struct {
  645. Type string `xml:"type,attr,omitempty"`
  646. Name string `xml:"name,attr,omitempty"`
  647. State string `xml:"state,attr,omitempty"` // is guest agent connected?
  648. Port *uint `xml:"port,attr"`
  649. }
  650. type DomainConsoleTarget struct {
  651. Type string `xml:"type,attr,omitempty"`
  652. Port *uint `xml:"port,attr"`
  653. }
  654. type DomainSerialTarget struct {
  655. Type string `xml:"type,attr,omitempty"`
  656. Port *uint `xml:"port,attr"`
  657. Model *DomainSerialTargetModel `xml:"model"`
  658. }
  659. type DomainSerialTargetModel struct {
  660. Name string `xml:"name,attr,omitempty"`
  661. }
  662. type DomainParallelTarget struct {
  663. Type string `xml:"type,attr,omitempty"`
  664. Port *uint `xml:"port,attr"`
  665. }
  666. type DomainChannelTarget struct {
  667. VirtIO *DomainChannelTargetVirtIO `xml:"-"`
  668. Xen *DomainChannelTargetXen `xml:"-"`
  669. GuestFWD *DomainChannelTargetGuestFWD `xml:"-"`
  670. }
  671. type DomainChannelTargetVirtIO struct {
  672. Name string `xml:"name,attr,omitempty"`
  673. State string `xml:"state,attr,omitempty"` // is guest agent connected?
  674. }
  675. type DomainChannelTargetXen struct {
  676. Name string `xml:"name,attr,omitempty"`
  677. State string `xml:"state,attr,omitempty"` // is guest agent connected?
  678. }
  679. type DomainChannelTargetGuestFWD struct {
  680. Address string `xml:"address,attr,omitempty"`
  681. Port string `xml:"port,attr,omitempty"`
  682. }
  683. type DomainAlias struct {
  684. Name string `xml:"name,attr"`
  685. }
  686. type DomainAddressPCI struct {
  687. Domain *uint `xml:"domain,attr"`
  688. Bus *uint `xml:"bus,attr"`
  689. Slot *uint `xml:"slot,attr"`
  690. Function *uint `xml:"function,attr"`
  691. MultiFunction string `xml:"multifunction,attr,omitempty"`
  692. ZPCI *DomainAddressZPCI `xml:"zpci"`
  693. }
  694. type DomainAddressZPCI struct {
  695. UID *uint `xml:"uid,attr,omitempty"`
  696. FID *uint `xml:"fid,attr,omitempty"`
  697. }
  698. type DomainAddressUSB struct {
  699. Bus *uint `xml:"bus,attr"`
  700. Port string `xml:"port,attr,omitempty"`
  701. Device *uint `xml:"device,attr"`
  702. }
  703. type DomainAddressDrive struct {
  704. Controller *uint `xml:"controller,attr"`
  705. Bus *uint `xml:"bus,attr"`
  706. Target *uint `xml:"target,attr"`
  707. Unit *uint `xml:"unit,attr"`
  708. }
  709. type DomainAddressDIMM struct {
  710. Slot *uint `xml:"slot,attr"`
  711. Base *uint64 `xml:"base,attr"`
  712. }
  713. type DomainAddressISA struct {
  714. IOBase *uint `xml:"iobase,attr"`
  715. IRQ *uint `xml:"irq,attr"`
  716. }
  717. type DomainAddressVirtioMMIO struct {
  718. }
  719. type DomainAddressCCW struct {
  720. CSSID *uint `xml:"cssid,attr"`
  721. SSID *uint `xml:"ssid,attr"`
  722. DevNo *uint `xml:"devno,attr"`
  723. }
  724. type DomainAddressVirtioSerial struct {
  725. Controller *uint `xml:"controller,attr"`
  726. Bus *uint `xml:"bus,attr"`
  727. Port *uint `xml:"port,attr"`
  728. }
  729. type DomainAddressSpaprVIO struct {
  730. Reg *uint64 `xml:"reg,attr"`
  731. }
  732. type DomainAddressCCID struct {
  733. Controller *uint `xml:"controller,attr"`
  734. Slot *uint `xml:"slot,attr"`
  735. }
  736. type DomainAddressVirtioS390 struct {
  737. }
  738. type DomainAddress struct {
  739. PCI *DomainAddressPCI
  740. Drive *DomainAddressDrive
  741. VirtioSerial *DomainAddressVirtioSerial
  742. CCID *DomainAddressCCID
  743. USB *DomainAddressUSB
  744. SpaprVIO *DomainAddressSpaprVIO
  745. VirtioS390 *DomainAddressVirtioS390
  746. CCW *DomainAddressCCW
  747. VirtioMMIO *DomainAddressVirtioMMIO
  748. ISA *DomainAddressISA
  749. DIMM *DomainAddressDIMM
  750. }
  751. type DomainChardevLog struct {
  752. File string `xml:"file,attr"`
  753. Append string `xml:"append,attr,omitempty"`
  754. }
  755. type DomainConsole struct {
  756. XMLName xml.Name `xml:"console"`
  757. TTY string `xml:"tty,attr,omitempty"`
  758. Source *DomainChardevSource `xml:"source"`
  759. Protocol *DomainChardevProtocol `xml:"protocol"`
  760. Target *DomainConsoleTarget `xml:"target"`
  761. Log *DomainChardevLog `xml:"log"`
  762. Alias *DomainAlias `xml:"alias"`
  763. Address *DomainAddress `xml:"address"`
  764. }
  765. type DomainSerial struct {
  766. XMLName xml.Name `xml:"serial"`
  767. Source *DomainChardevSource `xml:"source"`
  768. Protocol *DomainChardevProtocol `xml:"protocol"`
  769. Target *DomainSerialTarget `xml:"target"`
  770. Log *DomainChardevLog `xml:"log"`
  771. Alias *DomainAlias `xml:"alias"`
  772. Address *DomainAddress `xml:"address"`
  773. }
  774. type DomainParallel struct {
  775. XMLName xml.Name `xml:"parallel"`
  776. Source *DomainChardevSource `xml:"source"`
  777. Protocol *DomainChardevProtocol `xml:"protocol"`
  778. Target *DomainParallelTarget `xml:"target"`
  779. Log *DomainChardevLog `xml:"log"`
  780. Alias *DomainAlias `xml:"alias"`
  781. Address *DomainAddress `xml:"address"`
  782. }
  783. type DomainChardevProtocol struct {
  784. Type string `xml:"type,attr"`
  785. }
  786. type DomainChannel struct {
  787. XMLName xml.Name `xml:"channel"`
  788. Source *DomainChardevSource `xml:"source"`
  789. Protocol *DomainChardevProtocol `xml:"protocol"`
  790. Target *DomainChannelTarget `xml:"target"`
  791. Log *DomainChardevLog `xml:"log"`
  792. Alias *DomainAlias `xml:"alias"`
  793. Address *DomainAddress `xml:"address"`
  794. }
  795. type DomainRedirDev struct {
  796. XMLName xml.Name `xml:"redirdev"`
  797. Bus string `xml:"bus,attr,omitempty"`
  798. Source *DomainChardevSource `xml:"source"`
  799. Protocol *DomainChardevProtocol `xml:"protocol"`
  800. Boot *DomainDeviceBoot `xml:"boot"`
  801. Alias *DomainAlias `xml:"alias"`
  802. Address *DomainAddress `xml:"address"`
  803. }
  804. type DomainRedirFilter struct {
  805. USB []DomainRedirFilterUSB `xml:"usbdev"`
  806. }
  807. type DomainRedirFilterUSB struct {
  808. Class *uint `xml:"class,attr"`
  809. Vendor *uint `xml:"vendor,attr"`
  810. Product *uint `xml:"product,attr"`
  811. Version string `xml:"version,attr,omitempty"`
  812. Allow string `xml:"allow,attr"`
  813. }
  814. type DomainInput struct {
  815. XMLName xml.Name `xml:"input"`
  816. Type string `xml:"type,attr"`
  817. Bus string `xml:"bus,attr,omitempty"`
  818. Model string `xml:"model,attr,omitempty"`
  819. Driver *DomainInputDriver `xml:"driver"`
  820. Source *DomainInputSource `xml:"source"`
  821. Alias *DomainAlias `xml:"alias"`
  822. Address *DomainAddress `xml:"address"`
  823. }
  824. type DomainInputDriver struct {
  825. IOMMU string `xml:"iommu,attr,omitempty"`
  826. ATS string `xml:"ats,attr,omitempty"`
  827. }
  828. type DomainInputSource struct {
  829. EVDev string `xml:"evdev,attr"`
  830. }
  831. type DomainGraphicListenerAddress struct {
  832. Address string `xml:"address,attr,omitempty"`
  833. }
  834. type DomainGraphicListenerNetwork struct {
  835. Address string `xml:"address,attr,omitempty"`
  836. Network string `xml:"network,attr,omitempty"`
  837. }
  838. type DomainGraphicListenerSocket struct {
  839. Socket string `xml:"socket,attr,omitempty"`
  840. }
  841. type DomainGraphicListener struct {
  842. Address *DomainGraphicListenerAddress `xml:"-"`
  843. Network *DomainGraphicListenerNetwork `xml:"-"`
  844. Socket *DomainGraphicListenerSocket `xml:"-"`
  845. }
  846. type DomainGraphicChannel struct {
  847. Name string `xml:"name,attr,omitempty"`
  848. Mode string `xml:"mode,attr,omitempty"`
  849. }
  850. type DomainGraphicFileTransfer struct {
  851. Enable string `xml:"enable,attr,omitempty"`
  852. }
  853. type DomainGraphicsSDLGL struct {
  854. Enable string `xml:"enable,attr,omitempty"`
  855. }
  856. type DomainGraphicSDL struct {
  857. Display string `xml:"display,attr,omitempty"`
  858. XAuth string `xml:"xauth,attr,omitempty"`
  859. FullScreen string `xml:"fullscreen,attr,omitempty"`
  860. GL *DomainGraphicsSDLGL `xml:"gl"`
  861. }
  862. type DomainGraphicVNC struct {
  863. Socket string `xml:"socket,attr,omitempty"`
  864. Port int `xml:"port,attr,omitempty"`
  865. AutoPort string `xml:"autoport,attr,omitempty"`
  866. WebSocket int `xml:"websocket,attr,omitempty"`
  867. Keymap string `xml:"keymap,attr,omitempty"`
  868. SharePolicy string `xml:"sharePolicy,attr,omitempty"`
  869. Passwd string `xml:"passwd,attr,omitempty"`
  870. PasswdValidTo string `xml:"passwdValidTo,attr,omitempty"`
  871. Connected string `xml:"connected,attr,omitempty"`
  872. Listen string `xml:"listen,attr,omitempty"`
  873. Listeners []DomainGraphicListener `xml:"listen"`
  874. }
  875. type DomainGraphicRDP struct {
  876. Port int `xml:"port,attr,omitempty"`
  877. AutoPort string `xml:"autoport,attr,omitempty"`
  878. ReplaceUser string `xml:"replaceUser,attr,omitempty"`
  879. MultiUser string `xml:"multiUser,attr,omitempty"`
  880. Listen string `xml:"listen,attr,omitempty"`
  881. Listeners []DomainGraphicListener `xml:"listen"`
  882. }
  883. type DomainGraphicDesktop struct {
  884. Display string `xml:"display,attr,omitempty"`
  885. FullScreen string `xml:"fullscreen,attr,omitempty"`
  886. }
  887. type DomainGraphicSpiceChannel struct {
  888. Name string `xml:"name,attr"`
  889. Mode string `xml:"mode,attr"`
  890. }
  891. type DomainGraphicSpiceImage struct {
  892. Compression string `xml:"compression,attr"`
  893. }
  894. type DomainGraphicSpiceJPEG struct {
  895. Compression string `xml:"compression,attr"`
  896. }
  897. type DomainGraphicSpiceZLib struct {
  898. Compression string `xml:"compression,attr"`
  899. }
  900. type DomainGraphicSpicePlayback struct {
  901. Compression string `xml:"compression,attr"`
  902. }
  903. type DomainGraphicSpiceStreaming struct {
  904. Mode string `xml:"mode,attr"`
  905. }
  906. type DomainGraphicSpiceMouse struct {
  907. Mode string `xml:"mode,attr"`
  908. }
  909. type DomainGraphicSpiceClipBoard struct {
  910. CopyPaste string `xml:"copypaste,attr"`
  911. }
  912. type DomainGraphicSpiceFileTransfer struct {
  913. Enable string `xml:"enable,attr"`
  914. }
  915. type DomainGraphicSpiceGL struct {
  916. Enable string `xml:"enable,attr,omitempty"`
  917. RenderNode string `xml:"rendernode,attr,omitempty"`
  918. }
  919. type DomainGraphicSpice struct {
  920. Port int `xml:"port,attr,omitempty"`
  921. TLSPort int `xml:"tlsPort,attr,omitempty"`
  922. AutoPort string `xml:"autoport,attr,omitempty"`
  923. Listen string `xml:"listen,attr,omitempty"`
  924. Keymap string `xml:"keymap,attr,omitempty"`
  925. DefaultMode string `xml:"defaultMode,attr,omitempty"`
  926. Passwd string `xml:"passwd,attr,omitempty"`
  927. PasswdValidTo string `xml:"passwdValidTo,attr,omitempty"`
  928. Connected string `xml:"connected,attr,omitempty"`
  929. Listeners []DomainGraphicListener `xml:"listen"`
  930. Channel []DomainGraphicSpiceChannel `xml:"channel"`
  931. Image *DomainGraphicSpiceImage `xml:"image"`
  932. JPEG *DomainGraphicSpiceJPEG `xml:"jpeg"`
  933. ZLib *DomainGraphicSpiceZLib `xml:"zlib"`
  934. Playback *DomainGraphicSpicePlayback `xml:"playback"`
  935. Streaming *DomainGraphicSpiceStreaming `xml:"streaming"`
  936. Mouse *DomainGraphicSpiceMouse `xml:"mouse"`
  937. ClipBoard *DomainGraphicSpiceClipBoard `xml:"clipboard"`
  938. FileTransfer *DomainGraphicSpiceFileTransfer `xml:"filetransfer"`
  939. GL *DomainGraphicSpiceGL `xml:"gl"`
  940. }
  941. type DomainGraphicEGLHeadlessGL struct {
  942. RenderNode string `xml:"rendernode,attr,omitempty"`
  943. }
  944. type DomainGraphicEGLHeadless struct {
  945. GL *DomainGraphicEGLHeadlessGL `xml:"gl"`
  946. }
  947. type DomainGraphic struct {
  948. XMLName xml.Name `xml:"graphics"`
  949. SDL *DomainGraphicSDL `xml:"-"`
  950. VNC *DomainGraphicVNC `xml:"-"`
  951. RDP *DomainGraphicRDP `xml:"-"`
  952. Desktop *DomainGraphicDesktop `xml:"-"`
  953. Spice *DomainGraphicSpice `xml:"-"`
  954. EGLHeadless *DomainGraphicEGLHeadless `xml:"-"`
  955. }
  956. type DomainVideoAccel struct {
  957. Accel3D string `xml:"accel3d,attr,omitempty"`
  958. Accel2D string `xml:"accel2d,attr,omitempty"`
  959. }
  960. type DomainVideoModel struct {
  961. Type string `xml:"type,attr"`
  962. Heads uint `xml:"heads,attr,omitempty"`
  963. Ram uint `xml:"ram,attr,omitempty"`
  964. VRam uint `xml:"vram,attr,omitempty"`
  965. VRam64 uint `xml:"vram64,attr,omitempty"`
  966. VGAMem uint `xml:"vgamem,attr,omitempty"`
  967. Primary string `xml:"primary,attr,omitempty"`
  968. Accel *DomainVideoAccel `xml:"acceleration"`
  969. }
  970. type DomainVideo struct {
  971. XMLName xml.Name `xml:"video"`
  972. Model DomainVideoModel `xml:"model"`
  973. Driver *DomainVideoDriver `xml:"driver"`
  974. Alias *DomainAlias `xml:"alias"`
  975. Address *DomainAddress `xml:"address"`
  976. }
  977. type DomainVideoDriver struct {
  978. VGAConf string `xml:"vgaconf,attr,omitempty"`
  979. IOMMU string `xml:"iommu,attr,omitempty"`
  980. ATS string `xml:"ats,attr,omitempty"`
  981. }
  982. type DomainMemBalloonStats struct {
  983. Period uint `xml:"period,attr"`
  984. }
  985. type DomainMemBalloon struct {
  986. XMLName xml.Name `xml:"memballoon"`
  987. Model string `xml:"model,attr"`
  988. AutoDeflate string `xml:"autodeflate,attr,omitempty"`
  989. Driver *DomainMemBalloonDriver `xml:"driver"`
  990. Stats *DomainMemBalloonStats `xml:"stats"`
  991. Alias *DomainAlias `xml:"alias"`
  992. Address *DomainAddress `xml:"address"`
  993. }
  994. type DomainVSockCID struct {
  995. Auto string `xml:"auto,attr,omitempty"`
  996. Address string `xml:"address,attr,omitempty"`
  997. }
  998. type DomainVSock struct {
  999. XMLName xml.Name `xml:"vsock"`
  1000. Model string `xml:"model,attr,omitempty"`
  1001. CID *DomainVSockCID `xml:"cid"`
  1002. Alias *DomainAlias `xml:"alias"`
  1003. Address *DomainAddress `xml:"address"`
  1004. }
  1005. type DomainMemBalloonDriver struct {
  1006. IOMMU string `xml:"iommu,attr,omitempty"`
  1007. ATS string `xml:"ats,attr,omitempty"`
  1008. }
  1009. type DomainPanic struct {
  1010. XMLName xml.Name `xml:"panic"`
  1011. Model string `xml:"model,attr,omitempty"`
  1012. Alias *DomainAlias `xml:"alias"`
  1013. Address *DomainAddress `xml:"address"`
  1014. }
  1015. type DomainSoundCodec struct {
  1016. Type string `xml:"type,attr"`
  1017. }
  1018. type DomainSound struct {
  1019. XMLName xml.Name `xml:"sound"`
  1020. Model string `xml:"model,attr"`
  1021. Codec []DomainSoundCodec `xml:"codec"`
  1022. Alias *DomainAlias `xml:"alias"`
  1023. Address *DomainAddress `xml:"address"`
  1024. }
  1025. type DomainRNGRate struct {
  1026. Bytes uint `xml:"bytes,attr"`
  1027. Period uint `xml:"period,attr,omitempty"`
  1028. }
  1029. type DomainRNGBackend struct {
  1030. Random *DomainRNGBackendRandom `xml:"-"`
  1031. EGD *DomainRNGBackendEGD `xml:"-"`
  1032. }
  1033. type DomainRNGBackendEGD struct {
  1034. Source *DomainChardevSource `xml:"source"`
  1035. Protocol *DomainChardevProtocol `xml:"protocol"`
  1036. }
  1037. type DomainRNGBackendRandom struct {
  1038. Device string `xml:",chardata"`
  1039. }
  1040. type DomainRNG struct {
  1041. XMLName xml.Name `xml:"rng"`
  1042. Model string `xml:"model,attr"`
  1043. Driver *DomainRNGDriver `xml:"driver"`
  1044. Rate *DomainRNGRate `xml:"rate"`
  1045. Backend *DomainRNGBackend `xml:"backend"`
  1046. Alias *DomainAlias `xml:"alias"`
  1047. Address *DomainAddress `xml:"address"`
  1048. }
  1049. type DomainRNGDriver struct {
  1050. IOMMU string `xml:"iommu,attr,omitempty"`
  1051. ATS string `xml:"ats,attr,omitempty"`
  1052. }
  1053. type DomainHostdevSubsysUSB struct {
  1054. Source *DomainHostdevSubsysUSBSource `xml:"source"`
  1055. }
  1056. type DomainHostdevSubsysUSBSource struct {
  1057. Address *DomainAddressUSB `xml:"address"`
  1058. }
  1059. type DomainHostdevSubsysSCSI struct {
  1060. SGIO string `xml:"sgio,attr,omitempty"`
  1061. RawIO string `xml:"rawio,attr,omitempty"`
  1062. Source *DomainHostdevSubsysSCSISource `xml:"source"`
  1063. ReadOnly *DomainDiskReadOnly `xml:"readonly"`
  1064. Shareable *DomainDiskShareable `xml:"shareable"`
  1065. }
  1066. type DomainHostdevSubsysSCSISource struct {
  1067. Host *DomainHostdevSubsysSCSISourceHost `xml:"-"`
  1068. ISCSI *DomainHostdevSubsysSCSISourceISCSI `xml:"-"`
  1069. }
  1070. type DomainHostdevSubsysSCSIAdapter struct {
  1071. Name string `xml:"name,attr"`
  1072. }
  1073. type DomainHostdevSubsysSCSISourceHost struct {
  1074. Adapter *DomainHostdevSubsysSCSIAdapter `xml:"adapter"`
  1075. Address *DomainAddressDrive `xml:"address"`
  1076. }
  1077. type DomainHostdevSubsysSCSISourceISCSI struct {
  1078. Name string `xml:"name,attr"`
  1079. Host []DomainDiskSourceHost `xml:"host"`
  1080. Auth *DomainDiskAuth `xml:"auth"`
  1081. }
  1082. type DomainHostdevSubsysSCSIHost struct {
  1083. Model string `xml:"model,attr,omitempty"`
  1084. Source *DomainHostdevSubsysSCSIHostSource `xml:"source"`
  1085. }
  1086. type DomainHostdevSubsysSCSIHostSource struct {
  1087. Protocol string `xml:"protocol,attr,omitempty"`
  1088. WWPN string `xml:"wwpn,attr,omitempty"`
  1089. }
  1090. type DomainHostdevSubsysPCISource struct {
  1091. Address *DomainAddressPCI `xml:"address"`
  1092. }
  1093. type DomainHostdevSubsysPCIDriver struct {
  1094. Name string `xml:"name,attr,omitempty"`
  1095. }
  1096. type DomainHostdevSubsysPCI struct {
  1097. Driver *DomainHostdevSubsysPCIDriver `xml:"driver"`
  1098. Source *DomainHostdevSubsysPCISource `xml:"source"`
  1099. }
  1100. type DomainAddressMDev struct {
  1101. UUID string `xml:"uuid,attr"`
  1102. }
  1103. type DomainHostdevSubsysMDevSource struct {
  1104. Address *DomainAddressMDev `xml:"address"`
  1105. }
  1106. type DomainHostdevSubsysMDev struct {
  1107. Model string `xml:"model,attr,omitempty"`
  1108. Display string `xml:"display,attr,omitempty"`
  1109. Source *DomainHostdevSubsysMDevSource `xml:"source"`
  1110. }
  1111. type DomainHostdevCapsStorage struct {
  1112. Source *DomainHostdevCapsStorageSource `xml:"source"`
  1113. }
  1114. type DomainHostdevCapsStorageSource struct {
  1115. Block string `xml:"block"`
  1116. }
  1117. type DomainHostdevCapsMisc struct {
  1118. Source *DomainHostdevCapsMiscSource `xml:"source"`
  1119. }
  1120. type DomainHostdevCapsMiscSource struct {
  1121. Char string `xml:"char"`
  1122. }
  1123. type DomainIP struct {
  1124. Address string `xml:"address,attr,omitempty"`
  1125. Family string `xml:"family,attr,omitempty"`
  1126. Prefix *uint `xml:"prefix,attr"`
  1127. }
  1128. type DomainRoute struct {
  1129. Family string `xml:"family,attr,omitempty"`
  1130. Address string `xml:"address,attr,omitempty"`
  1131. Gateway string `xml:"gateway,attr,omitempty"`
  1132. }
  1133. type DomainHostdevCapsNet struct {
  1134. Source *DomainHostdevCapsNetSource `xml:"source"`
  1135. IP []DomainIP `xml:"ip"`
  1136. Route []DomainRoute `xml:"route"`
  1137. }
  1138. type DomainHostdevCapsNetSource struct {
  1139. Interface string `xml:"interface"`
  1140. }
  1141. type DomainHostdev struct {
  1142. Managed string `xml:"managed,attr,omitempty"`
  1143. SubsysUSB *DomainHostdevSubsysUSB `xml:"-"`
  1144. SubsysSCSI *DomainHostdevSubsysSCSI `xml:"-"`
  1145. SubsysSCSIHost *DomainHostdevSubsysSCSIHost `xml:"-"`
  1146. SubsysPCI *DomainHostdevSubsysPCI `xml:"-"`
  1147. SubsysMDev *DomainHostdevSubsysMDev `xml:"-"`
  1148. CapsStorage *DomainHostdevCapsStorage `xml:"-"`
  1149. CapsMisc *DomainHostdevCapsMisc `xml:"-"`
  1150. CapsNet *DomainHostdevCapsNet `xml:"-"`
  1151. Boot *DomainDeviceBoot `xml:"boot"`
  1152. ROM *DomainROM `xml:"rom"`
  1153. Alias *DomainAlias `xml:"alias"`
  1154. Address *DomainAddress `xml:"address"`
  1155. }
  1156. type DomainMemorydevSource struct {
  1157. NodeMask string `xml:"nodemask,omitempty"`
  1158. PageSize *DomainMemorydevSourcePagesize `xml:"pagesize"`
  1159. Path string `xml:"path,omitempty"`
  1160. AlignSize *DomainMemorydevSourceAlignsize `xml:"alignsize"`
  1161. PMem *DomainMemorydevSourcePMem `xml:"pmem"`
  1162. }
  1163. type DomainMemorydevSourcePMem struct {
  1164. }
  1165. type DomainMemorydevSourcePagesize struct {
  1166. Value uint64 `xml:",chardata"`
  1167. Unit string `xml:"unit,attr,omitempty"`
  1168. }
  1169. type DomainMemorydevSourceAlignsize struct {
  1170. Value uint64 `xml:",chardata"`
  1171. Unit string `xml:"unit,attr,omitempty"`
  1172. }
  1173. type DomainMemorydevTargetNode struct {
  1174. Value uint `xml:",chardata"`
  1175. }
  1176. type DomainMemorydevTargetReadOnly struct {
  1177. }
  1178. type DomainMemorydevTargetSize struct {
  1179. Value uint `xml:",chardata"`
  1180. Unit string `xml:"unit,attr,omitempty"`
  1181. }
  1182. type DomainMemorydevTargetLabel struct {
  1183. Size *DomainMemorydevTargetSize `xml:"size"`
  1184. }
  1185. type DomainMemorydevTarget struct {
  1186. Size *DomainMemorydevTargetSize `xml:"size"`
  1187. Node *DomainMemorydevTargetNode `xml:"node"`
  1188. Label *DomainMemorydevTargetLabel `xml:"label"`
  1189. ReadOnly *DomainMemorydevTargetReadOnly `xml:"readonly"`
  1190. }
  1191. type DomainMemorydev struct {
  1192. XMLName xml.Name `xml:"memory"`
  1193. Model string `xml:"model,attr"`
  1194. Access string `xml:"access,attr,omitempty"`
  1195. Discard string `xml:"discard,attr,omitempty"`
  1196. Source *DomainMemorydevSource `xml:"source"`
  1197. Target *DomainMemorydevTarget `xml:"target"`
  1198. Alias *DomainAlias `xml:"alias"`
  1199. Address *DomainAddress `xml:"address"`
  1200. }
  1201. type DomainWatchdog struct {
  1202. XMLName xml.Name `xml:"watchdog"`
  1203. Model string `xml:"model,attr"`
  1204. Action string `xml:"action,attr,omitempty"`
  1205. Alias *DomainAlias `xml:"alias"`
  1206. Address *DomainAddress `xml:"address"`
  1207. }
  1208. type DomainHub struct {
  1209. Type string `xml:"type,attr"`
  1210. Alias *DomainAlias `xml:"alias"`
  1211. Address *DomainAddress `xml:"address"`
  1212. }
  1213. type DomainIOMMU struct {
  1214. Model string `xml:"model,attr"`
  1215. Driver *DomainIOMMUDriver `xml:"driver"`
  1216. }
  1217. type DomainIOMMUDriver struct {
  1218. IntRemap string `xml:"intremap,attr,omitempty"`
  1219. CachingMode string `xml:"caching_mode,attr,omitempty"`
  1220. EIM string `xml:"eim,attr,omitempty"`
  1221. IOTLB string `xml:"iotlb,attr,omitempty"`
  1222. }
  1223. type DomainNVRAM struct {
  1224. Alias *DomainAlias `xml:"alias"`
  1225. Address *DomainAddress `xml:"address"`
  1226. }
  1227. type DomainLease struct {
  1228. Lockspace string `xml:"lockspace"`
  1229. Key string `xml:"key"`
  1230. Target *DomainLeaseTarget `xml:"target"`
  1231. }
  1232. type DomainLeaseTarget struct {
  1233. Path string `xml:"path,attr"`
  1234. Offset uint64 `xml:"offset,attr,omitempty"`
  1235. }
  1236. type DomainSmartcard struct {
  1237. XMLName xml.Name `xml:"smartcard"`
  1238. Passthrough *DomainChardevSource `xml:"source"`
  1239. Protocol *DomainChardevProtocol `xml:"protocol"`
  1240. Host *DomainSmartcardHost `xml:"-"`
  1241. HostCerts []DomainSmartcardHostCert `xml:"certificate"`
  1242. Database string `xml:"database,omitempty"`
  1243. Alias *DomainAlias `xml:"alias"`
  1244. Address *DomainAddress `xml:"address"`
  1245. }
  1246. type DomainSmartcardHost struct {
  1247. }
  1248. type DomainSmartcardHostCert struct {
  1249. File string `xml:",chardata"`
  1250. }
  1251. type DomainTPM struct {
  1252. XMLName xml.Name `xml:"tpm"`
  1253. Model string `xml:"model,attr,omitempty"`
  1254. Backend *DomainTPMBackend `xml:"backend"`
  1255. Alias *DomainAlias `xml:"alias"`
  1256. Address *DomainAddress `xml:"address"`
  1257. }
  1258. type DomainTPMBackend struct {
  1259. Passthrough *DomainTPMBackendPassthrough `xml:"-"`
  1260. Emulator *DomainTPMBackendEmulator `xml:"-"`
  1261. }
  1262. type DomainTPMBackendPassthrough struct {
  1263. Device *DomainTPMBackendDevice `xml:"device"`
  1264. }
  1265. type DomainTPMBackendEmulator struct {
  1266. Version string `xml:"version,attr,omitempty"`
  1267. }
  1268. type DomainTPMBackendDevice struct {
  1269. Path string `xml:"path,attr"`
  1270. }
  1271. type DomainShmem struct {
  1272. XMLName xml.Name `xml:"shmem"`
  1273. Name string `xml:"name,attr"`
  1274. Size *DomainShmemSize `xml:"size"`
  1275. Model *DomainShmemModel `xml:"model"`
  1276. Server *DomainShmemServer `xml:"server"`
  1277. MSI *DomainShmemMSI `xml:"msi"`
  1278. Alias *DomainAlias `xml:"alias"`
  1279. Address *DomainAddress `xml:"address"`
  1280. }
  1281. type DomainShmemSize struct {
  1282. Value uint `xml:",chardata"`
  1283. Unit string `xml:"unit,attr,omitempty"`
  1284. }
  1285. type DomainShmemModel struct {
  1286. Type string `xml:"type,attr"`
  1287. }
  1288. type DomainShmemServer struct {
  1289. Path string `xml:"path,attr,omitempty"`
  1290. }
  1291. type DomainShmemMSI struct {
  1292. Enabled string `xml:"enabled,attr,omitempty"`
  1293. Vectors uint `xml:"vectors,attr,omitempty"`
  1294. IOEventFD string `xml:"ioeventfd,attr,omitempty"`
  1295. }
  1296. type DomainDeviceList struct {
  1297. Emulator string `xml:"emulator,omitempty"`
  1298. Disks []DomainDisk `xml:"disk"`
  1299. Controllers []DomainController `xml:"controller"`
  1300. Leases []DomainLease `xml:"lease"`
  1301. Filesystems []DomainFilesystem `xml:"filesystem"`
  1302. Interfaces []DomainInterface `xml:"interface"`
  1303. Smartcards []DomainSmartcard `xml:"smartcard"`
  1304. Serials []DomainSerial `xml:"serial"`
  1305. Parallels []DomainParallel `xml:"parallel"`
  1306. Consoles []DomainConsole `xml:"console"`
  1307. Channels []DomainChannel `xml:"channel"`
  1308. Inputs []DomainInput `xml:"input"`
  1309. TPMs []DomainTPM `xml:"tpm"`
  1310. Graphics []DomainGraphic `xml:"graphics"`
  1311. Sounds []DomainSound `xml:"sound"`
  1312. Videos []DomainVideo `xml:"video"`
  1313. Hostdevs []DomainHostdev `xml:"hostdev"`
  1314. RedirDevs []DomainRedirDev `xml:"redirdev"`
  1315. RedirFilters []DomainRedirFilter `xml:"redirfilter"`
  1316. Hubs []DomainHub `xml:"hub"`
  1317. Watchdog *DomainWatchdog `xml:"watchdog"`
  1318. MemBalloon *DomainMemBalloon `xml:"memballoon"`
  1319. RNGs []DomainRNG `xml:"rng"`
  1320. NVRAM *DomainNVRAM `xml:"nvram"`
  1321. Panics []DomainPanic `xml:"panic"`
  1322. Shmems []DomainShmem `xml:"shmem"`
  1323. Memorydevs []DomainMemorydev `xml:"memory"`
  1324. IOMMU *DomainIOMMU `xml:"iommu"`
  1325. VSock *DomainVSock `xml:"vsock"`
  1326. }
  1327. type DomainMemory struct {
  1328. Value uint `xml:",chardata"`
  1329. Unit string `xml:"unit,attr,omitempty"`
  1330. DumpCore string `xml:"dumpCore,attr,omitempty"`
  1331. }
  1332. type DomainCurrentMemory struct {
  1333. Value uint `xml:",chardata"`
  1334. Unit string `xml:"unit,attr,omitempty"`
  1335. }
  1336. type DomainMaxMemory struct {
  1337. Value uint `xml:",chardata"`
  1338. Unit string `xml:"unit,attr,omitempty"`
  1339. Slots uint `xml:"slots,attr,omitempty"`
  1340. }
  1341. type DomainMemoryHugepage struct {
  1342. Size uint `xml:"size,attr"`
  1343. Unit string `xml:"unit,attr,omitempty"`
  1344. Nodeset string `xml:"nodeset,attr,omitempty"`
  1345. }
  1346. type DomainMemoryHugepages struct {
  1347. Hugepages []DomainMemoryHugepage `xml:"page"`
  1348. }
  1349. type DomainMemoryNosharepages struct {
  1350. }
  1351. type DomainMemoryLocked struct {
  1352. }
  1353. type DomainMemorySource struct {
  1354. Type string `xml:"type,attr,omitempty"`
  1355. }
  1356. type DomainMemoryAccess struct {
  1357. Mode string `xml:"mode,attr,omitempty"`
  1358. }
  1359. type DomainMemoryAllocation struct {
  1360. Mode string `xml:"mode,attr,omitempty"`
  1361. }
  1362. type DomainMemoryDiscard struct {
  1363. }
  1364. type DomainMemoryBacking struct {
  1365. MemoryHugePages *DomainMemoryHugepages `xml:"hugepages"`
  1366. MemoryNosharepages *DomainMemoryNosharepages `xml:"nosharepages"`
  1367. MemoryLocked *DomainMemoryLocked `xml:"locked"`
  1368. MemorySource *DomainMemorySource `xml:"source"`
  1369. MemoryAccess *DomainMemoryAccess `xml:"access"`
  1370. MemoryAllocation *DomainMemoryAllocation `xml:"allocation"`
  1371. MemoryDiscard *DomainMemoryDiscard `xml:"discard"`
  1372. }
  1373. type DomainOSType struct {
  1374. Arch string `xml:"arch,attr,omitempty"`
  1375. Machine string `xml:"machine,attr,omitempty"`
  1376. Type string `xml:",chardata"`
  1377. }
  1378. type DomainSMBios struct {
  1379. Mode string `xml:"mode,attr"`
  1380. }
  1381. type DomainNVRam struct {
  1382. NVRam string `xml:",chardata"`
  1383. Template string `xml:"template,attr,omitempty"`
  1384. }
  1385. type DomainBootDevice struct {
  1386. Dev string `xml:"dev,attr"`
  1387. }
  1388. type DomainBootMenu struct {
  1389. Enable string `xml:"enable,attr,omitempty"`
  1390. Timeout string `xml:"timeout,attr,omitempty"`
  1391. }
  1392. type DomainSysInfoBIOS struct {
  1393. Entry []DomainSysInfoEntry `xml:"entry"`
  1394. }
  1395. type DomainSysInfoSystem struct {
  1396. Entry []DomainSysInfoEntry `xml:"entry"`
  1397. }
  1398. type DomainSysInfoBaseBoard struct {
  1399. Entry []DomainSysInfoEntry `xml:"entry"`
  1400. }
  1401. type DomainSysInfoProcessor struct {
  1402. Entry []DomainSysInfoEntry `xml:"entry"`
  1403. }
  1404. type DomainSysInfoMemory struct {
  1405. Entry []DomainSysInfoEntry `xml:"entry"`
  1406. }
  1407. type DomainSysInfoChassis struct {
  1408. Entry []DomainSysInfoEntry `xml:"entry"`
  1409. }
  1410. type DomainSysInfoOEMStrings struct {
  1411. Entry []string `xml:"entry"`
  1412. }
  1413. type DomainSysInfo struct {
  1414. Type string `xml:"type,attr"`
  1415. BIOS *DomainSysInfoBIOS `xml:"bios"`
  1416. System *DomainSysInfoSystem `xml:"system"`
  1417. BaseBoard []DomainSysInfoBaseBoard `xml:"baseBoard"`
  1418. Chassis *DomainSysInfoChassis `xml:"chassis"`
  1419. Processor []DomainSysInfoProcessor `xml:"processor"`
  1420. Memory []DomainSysInfoMemory `xml:"memory"`
  1421. OEMStrings *DomainSysInfoOEMStrings `xml:"oemStrings"`
  1422. }
  1423. type DomainSysInfoEntry struct {
  1424. Name string `xml:"name,attr"`
  1425. Value string `xml:",chardata"`
  1426. }
  1427. type DomainBIOS struct {
  1428. UseSerial string `xml:"useserial,attr,omitempty"`
  1429. RebootTimeout *int `xml:"rebootTimeout,attr"`
  1430. }
  1431. type DomainLoader struct {
  1432. Path string `xml:",chardata"`
  1433. Readonly string `xml:"readonly,attr,omitempty"`
  1434. Secure string `xml:"secure,attr,omitempty"`
  1435. Type string `xml:"type,attr,omitempty"`
  1436. }
  1437. type DomainACPI struct {
  1438. Tables []DomainACPITable `xml:"table"`
  1439. }
  1440. type DomainACPITable struct {
  1441. Type string `xml:"type,attr"`
  1442. Path string `xml:",chardata"`
  1443. }
  1444. type DomainOSInitEnv struct {
  1445. Name string `xml:"name,attr"`
  1446. Value string `xml:",chardata"`
  1447. }
  1448. type DomainOS struct {
  1449. Type *DomainOSType `xml:"type"`
  1450. Firmware string `xml:"firmware,attr,omitempty"`
  1451. Init string `xml:"init,omitempty"`
  1452. InitArgs []string `xml:"initarg"`
  1453. InitEnv []DomainOSInitEnv `xml:"initenv"`
  1454. InitDir string `xml:"initdir,omitempty"`
  1455. InitUser string `xml:"inituser,omitempty"`
  1456. InitGroup string `xml:"initgroup,omitempty"`
  1457. Loader *DomainLoader `xml:"loader"`
  1458. NVRam *DomainNVRam `xml:"nvram"`
  1459. Kernel string `xml:"kernel,omitempty"`
  1460. Initrd string `xml:"initrd,omitempty"`
  1461. Cmdline string `xml:"cmdline,omitempty"`
  1462. DTB string `xml:"dtb,omitempty"`
  1463. ACPI *DomainACPI `xml:"acpi"`
  1464. BootDevices []DomainBootDevice `xml:"boot"`
  1465. BootMenu *DomainBootMenu `xml:"bootmenu"`
  1466. BIOS *DomainBIOS `xml:"bios"`
  1467. SMBios *DomainSMBios `xml:"smbios"`
  1468. }
  1469. type DomainResource struct {
  1470. Partition string `xml:"partition,omitempty"`
  1471. }
  1472. type DomainVCPU struct {
  1473. Placement string `xml:"placement,attr,omitempty"`
  1474. CPUSet string `xml:"cpuset,attr,omitempty"`
  1475. Current string `xml:"current,attr,omitempty"`
  1476. Value int `xml:",chardata"`
  1477. }
  1478. type DomainVCPUsVCPU struct {
  1479. Id *uint `xml:"id,attr"`
  1480. Enabled string `xml:"enabled,attr,omitempty"`
  1481. Hotpluggable string `xml:"hotpluggable,attr,omitempty"`
  1482. Order *uint `xml:"order,attr"`
  1483. }
  1484. type DomainVCPUs struct {
  1485. VCPU []DomainVCPUsVCPU `xml:"vcpu"`
  1486. }
  1487. type DomainCPUModel struct {
  1488. Fallback string `xml:"fallback,attr,omitempty"`
  1489. Value string `xml:",chardata"`
  1490. VendorID string `xml:"vendor_id,attr,omitempty"`
  1491. }
  1492. type DomainCPUTopology struct {
  1493. Sockets int `xml:"sockets,attr,omitempty"`
  1494. Cores int `xml:"cores,attr,omitempty"`
  1495. Threads int `xml:"threads,attr,omitempty"`
  1496. }
  1497. type DomainCPUFeature struct {
  1498. Policy string `xml:"policy,attr,omitempty"`
  1499. Name string `xml:"name,attr,omitempty"`
  1500. }
  1501. type DomainCPUCache struct {
  1502. Level uint `xml:"level,attr,omitempty"`
  1503. Mode string `xml:"mode,attr"`
  1504. }
  1505. type DomainCPU struct {
  1506. XMLName xml.Name `xml:"cpu"`
  1507. Match string `xml:"match,attr,omitempty"`
  1508. Mode string `xml:"mode,attr,omitempty"`
  1509. Check string `xml:"check,attr,omitempty"`
  1510. Model *DomainCPUModel `xml:"model"`
  1511. Vendor string `xml:"vendor,omitempty"`
  1512. Topology *DomainCPUTopology `xml:"topology"`
  1513. Cache *DomainCPUCache `xml:"cache"`
  1514. Features []DomainCPUFeature `xml:"feature"`
  1515. Numa *DomainNuma `xml:"numa"`
  1516. }
  1517. type DomainNuma struct {
  1518. Cell []DomainCell `xml:"cell"`
  1519. }
  1520. type DomainCell struct {
  1521. ID *uint `xml:"id,attr"`
  1522. CPUs string `xml:"cpus,attr"`
  1523. Memory string `xml:"memory,attr"`
  1524. Unit string `xml:"unit,attr,omitempty"`
  1525. MemAccess string `xml:"memAccess,attr,omitempty"`
  1526. Discard string `xml:"discard,attr,omitempty"`
  1527. Distances *DomainCellDistances `xml:"distances"`
  1528. }
  1529. type DomainCellDistances struct {
  1530. Siblings []DomainCellSibling `xml:"sibling"`
  1531. }
  1532. type DomainCellSibling struct {
  1533. ID uint `xml:"id,attr"`
  1534. Value uint `xml:"value,attr"`
  1535. }
  1536. type DomainClock struct {
  1537. Offset string `xml:"offset,attr,omitempty"`
  1538. Basis string `xml:"basis,attr,omitempty"`
  1539. Adjustment string `xml:"adjustment,attr,omitempty"`
  1540. TimeZone string `xml:"timezone,attr,omitempty"`
  1541. Timer []DomainTimer `xml:"timer"`
  1542. }
  1543. type DomainTimer struct {
  1544. Name string `xml:"name,attr"`
  1545. Track string `xml:"track,attr,omitempty"`
  1546. TickPolicy string `xml:"tickpolicy,attr,omitempty"`
  1547. CatchUp *DomainTimerCatchUp `xml:"catchup"`
  1548. Frequency uint32 `xml:"frequency,attr,omitempty"`
  1549. Mode string `xml:"mode,attr,omitempty"`
  1550. Present string `xml:"present,attr,omitempty"`
  1551. }
  1552. type DomainTimerCatchUp struct {
  1553. Threshold uint `xml:"threshold,attr,omitempty"`
  1554. Slew uint `xml:"slew,attr,omitempty"`
  1555. Limit uint `xml:"limit,attr,omitempty"`
  1556. }
  1557. type DomainFeature struct {
  1558. }
  1559. type DomainFeatureState struct {
  1560. State string `xml:"state,attr,omitempty"`
  1561. }
  1562. type DomainFeatureAPIC struct {
  1563. EOI string `xml:"eoi,attr,omitempty"`
  1564. }
  1565. type DomainFeatureHyperVVendorId struct {
  1566. DomainFeatureState
  1567. Value string `xml:"value,attr,omitempty"`
  1568. }
  1569. type DomainFeatureHyperVSpinlocks struct {
  1570. DomainFeatureState
  1571. Retries uint `xml:"retries,attr,omitempty"`
  1572. }
  1573. type DomainFeatureHyperV struct {
  1574. DomainFeature
  1575. Relaxed *DomainFeatureState `xml:"relaxed"`
  1576. VAPIC *DomainFeatureState `xml:"vapic"`
  1577. Spinlocks *DomainFeatureHyperVSpinlocks `xml:"spinlocks"`
  1578. VPIndex *DomainFeatureState `xml:"vpindex"`
  1579. Runtime *DomainFeatureState `xml:"runtime"`
  1580. Synic *DomainFeatureState `xml:"synic"`
  1581. STimer *DomainFeatureState `xml:"stimer"`
  1582. Reset *DomainFeatureState `xml:"reset"`
  1583. VendorId *DomainFeatureHyperVVendorId `xml:"vendor_id"`
  1584. Frequencies *DomainFeatureState `xml:"frequencies"`
  1585. ReEnlightenment *DomainFeatureState `xml:"reenlightenment"`
  1586. TLBFlush *DomainFeatureState `xml:"tlbflush"`
  1587. IPI *DomainFeatureState `xml:"ipi"`
  1588. EVMCS *DomainFeatureState `xml:"evmcs"`
  1589. }
  1590. type DomainFeatureKVM struct {
  1591. Hidden *DomainFeatureState `xml:"hidden"`
  1592. }
  1593. type DomainFeatureGIC struct {
  1594. Version string `xml:"version,attr,omitempty"`
  1595. }
  1596. type DomainFeatureIOAPIC struct {
  1597. Driver string `xml:"driver,attr,omitempty"`
  1598. }
  1599. type DomainFeatureHPT struct {
  1600. Resizing string `xml:"resizing,attr,omitempty"`
  1601. MaxPageSize *DomainFeatureHPTPageSize `xml:"maxpagesize"`
  1602. }
  1603. type DomainFeatureHPTPageSize struct {
  1604. Unit string `xml:"unit,attr,omitempty"`
  1605. Value string `xml:",chardata"`
  1606. }
  1607. type DomainFeatureSMM struct {
  1608. State string `xml:"state,attr,omitempty"`
  1609. TSeg *DomainFeatureSMMTSeg `xml:"tseg"`
  1610. }
  1611. type DomainFeatureSMMTSeg struct {
  1612. Unit string `xml:"unit,attr,omitempty"`
  1613. Value uint `xml:",chardata"`
  1614. }
  1615. type DomainFeatureCapability struct {
  1616. State string `xml:"state,attr,omitempty"`
  1617. }
  1618. type DomainLaunchSecurity struct {
  1619. SEV *DomainLaunchSecuritySEV `xml:"-"`
  1620. }
  1621. type DomainLaunchSecuritySEV struct {
  1622. CBitPos *uint `xml:"cbitpos"`
  1623. ReducedPhysBits *uint `xml:"reducedPhysBits"`
  1624. Policy *uint `xml:"policy"`
  1625. DHCert string `xml:"dhCert"`
  1626. Session string `xml:"sesion"`
  1627. }
  1628. type DomainFeatureCapabilities struct {
  1629. Policy string `xml:"policy,attr,omitempty"`
  1630. AuditControl *DomainFeatureCapability `xml:"audit_control"`
  1631. AuditWrite *DomainFeatureCapability `xml:"audit_write"`
  1632. BlockSuspend *DomainFeatureCapability `xml:"block_suspend"`
  1633. Chown *DomainFeatureCapability `xml:"chown"`
  1634. DACOverride *DomainFeatureCapability `xml:"dac_override"`
  1635. DACReadSearch *DomainFeatureCapability `xml:"dac_read_Search"`
  1636. FOwner *DomainFeatureCapability `xml:"fowner"`
  1637. FSetID *DomainFeatureCapability `xml:"fsetid"`
  1638. IPCLock *DomainFeatureCapability `xml:"ipc_lock"`
  1639. IPCOwner *DomainFeatureCapability `xml:"ipc_owner"`
  1640. Kill *DomainFeatureCapability `xml:"kill"`
  1641. Lease *DomainFeatureCapability `xml:"lease"`
  1642. LinuxImmutable *DomainFeatureCapability `xml:"linux_immutable"`
  1643. MACAdmin *DomainFeatureCapability `xml:"mac_admin"`
  1644. MACOverride *DomainFeatureCapability `xml:"mac_override"`
  1645. MkNod *DomainFeatureCapability `xml:"mknod"`
  1646. NetAdmin *DomainFeatureCapability `xml:"net_admin"`
  1647. NetBindService *DomainFeatureCapability `xml:"net_bind_service"`
  1648. NetBroadcast *DomainFeatureCapability `xml:"net_broadcast"`
  1649. NetRaw *DomainFeatureCapability `xml:"net_raw"`
  1650. SetGID *DomainFeatureCapability `xml:"setgid"`
  1651. SetFCap *DomainFeatureCapability `xml:"setfcap"`
  1652. SetPCap *DomainFeatureCapability `xml:"setpcap"`
  1653. SetUID *DomainFeatureCapability `xml:"setuid"`
  1654. SysAdmin *DomainFeatureCapability `xml:"sys_admin"`
  1655. SysBoot *DomainFeatureCapability `xml:"sys_boot"`
  1656. SysChRoot *DomainFeatureCapability `xml:"sys_chroot"`
  1657. SysModule *DomainFeatureCapability `xml:"sys_module"`
  1658. SysNice *DomainFeatureCapability `xml:"sys_nice"`
  1659. SysPAcct *DomainFeatureCapability `xml:"sys_pacct"`
  1660. SysPTrace *DomainFeatureCapability `xml:"sys_ptrace"`
  1661. SysRawIO *DomainFeatureCapability `xml:"sys_rawio"`
  1662. SysResource *DomainFeatureCapability `xml:"sys_resource"`
  1663. SysTime *DomainFeatureCapability `xml:"sys_time"`
  1664. SysTTYCnofig *DomainFeatureCapability `xml:"sys_tty_config"`
  1665. SysLog *DomainFeatureCapability `xml:"syslog"`
  1666. WakeAlarm *DomainFeatureCapability `xml:"wake_alarm"`
  1667. }
  1668. type DomainFeatureMSRS struct {
  1669. Unknown string `xml:"unknown,attr"`
  1670. }
  1671. type DomainFeatureList struct {
  1672. PAE *DomainFeature `xml:"pae"`
  1673. ACPI *DomainFeature `xml:"acpi"`
  1674. APIC *DomainFeatureAPIC `xml:"apic"`
  1675. HAP *DomainFeatureState `xml:"hap"`
  1676. Viridian *DomainFeature `xml:"viridian"`
  1677. PrivNet *DomainFeature `xml:"privnet"`
  1678. HyperV *DomainFeatureHyperV `xml:"hyperv"`
  1679. KVM *DomainFeatureKVM `xml:"kvm"`
  1680. PVSpinlock *DomainFeatureState `xml:"pvspinlock"`
  1681. PMU *DomainFeatureState `xml:"pmu"`
  1682. VMPort *DomainFeatureState `xml:"vmport"`
  1683. GIC *DomainFeatureGIC `xml:"gic"`
  1684. SMM *DomainFeatureSMM `xml:"smm"`
  1685. IOAPIC *DomainFeatureIOAPIC `xml:"ioapic"`
  1686. HPT *DomainFeatureHPT `xml:"hpt"`
  1687. HTM *DomainFeatureState `xml:"htm"`
  1688. NestedHV *DomainFeatureState `xml:"nested-hv"`
  1689. Capabilities *DomainFeatureCapabilities `xml:"capabilities"`
  1690. VMCoreInfo *DomainFeatureState `xml:"vmcoreinfo"`
  1691. MSRS *DomainFeatureMSRS `xml:"msrs"`
  1692. }
  1693. type DomainCPUTuneShares struct {
  1694. Value uint `xml:",chardata"`
  1695. }
  1696. type DomainCPUTunePeriod struct {
  1697. Value uint64 `xml:",chardata"`
  1698. }
  1699. type DomainCPUTuneQuota struct {
  1700. Value int64 `xml:",chardata"`
  1701. }
  1702. type DomainCPUTuneVCPUPin struct {
  1703. VCPU uint `xml:"vcpu,attr"`
  1704. CPUSet string `xml:"cpuset,attr"`
  1705. }
  1706. type DomainCPUTuneEmulatorPin struct {
  1707. CPUSet string `xml:"cpuset,attr"`
  1708. }
  1709. type DomainCPUTuneIOThreadPin struct {
  1710. IOThread uint `xml:"iothread,attr"`
  1711. CPUSet string `xml:"cpuset,attr"`
  1712. }
  1713. type DomainCPUTuneVCPUSched struct {
  1714. VCPUs string `xml:"vcpus,attr"`
  1715. Scheduler string `xml:"scheduler,attr,omitempty"`
  1716. Priority *int `xml:"priority,attr"`
  1717. }
  1718. type DomainCPUTuneIOThreadSched struct {
  1719. IOThreads string `xml:"iothreads,attr"`
  1720. Scheduler string `xml:"scheduler,attr,omitempty"`
  1721. Priority *int `xml:"priority,attr"`
  1722. }
  1723. type DomainCPUCacheTune struct {
  1724. VCPUs string `xml:"vcpus,attr,omitempty"`
  1725. Cache []DomainCPUCacheTuneCache `xml:"cache"`
  1726. Monitor []DomainCPUCacheTuneMonitor `xml:"monitor"`
  1727. }
  1728. type DomainCPUCacheTuneCache struct {
  1729. ID uint `xml:"id,attr"`
  1730. Level uint `xml:"level,attr"`
  1731. Type string `xml:"type,attr"`
  1732. Size uint `xml:"size,attr"`
  1733. Unit string `xml:"unit,attr"`
  1734. }
  1735. type DomainCPUCacheTuneMonitor struct {
  1736. Level uint `xml:"level,attr,omitempty"`
  1737. VCPUs string `xml:"vcpus,attr,omitempty"`
  1738. }
  1739. type DomainCPUMemoryTune struct {
  1740. VCPUs string `xml:"vcpus,attr"`
  1741. Nodes []DomainCPUMemoryTuneNode `xml:"node"`
  1742. }
  1743. type DomainCPUMemoryTuneNode struct {
  1744. ID uint `xml:"id,attr"`
  1745. Bandwidth uint `xml:"bandwidth,attr"`
  1746. }
  1747. type DomainCPUTune struct {
  1748. Shares *DomainCPUTuneShares `xml:"shares"`
  1749. Period *DomainCPUTunePeriod `xml:"period"`
  1750. Quota *DomainCPUTuneQuota `xml:"quota"`
  1751. GlobalPeriod *DomainCPUTunePeriod `xml:"global_period"`
  1752. GlobalQuota *DomainCPUTuneQuota `xml:"global_quota"`
  1753. EmulatorPeriod *DomainCPUTunePeriod `xml:"emulator_period"`
  1754. EmulatorQuota *DomainCPUTuneQuota `xml:"emulator_quota"`
  1755. IOThreadPeriod *DomainCPUTunePeriod `xml:"iothread_period"`
  1756. IOThreadQuota *DomainCPUTuneQuota `xml:"iothread_quota"`
  1757. VCPUPin []DomainCPUTuneVCPUPin `xml:"vcpupin"`
  1758. EmulatorPin *DomainCPUTuneEmulatorPin `xml:"emulatorpin"`
  1759. IOThreadPin []DomainCPUTuneIOThreadPin `xml:"iothreadpin"`
  1760. VCPUSched []DomainCPUTuneVCPUSched `xml:"vcpusched"`
  1761. IOThreadSched []DomainCPUTuneIOThreadSched `xml:"iothreadsched"`
  1762. CacheTune []DomainCPUCacheTune `xml:"cachetune"`
  1763. MemoryTune []DomainCPUMemoryTune `xml:"memorytune"`
  1764. }
  1765. type DomainQEMUCommandlineArg struct {
  1766. Value string `xml:"value,attr"`
  1767. }
  1768. type DomainQEMUCommandlineEnv struct {
  1769. Name string `xml:"name,attr"`
  1770. Value string `xml:"value,attr,omitempty"`
  1771. }
  1772. type DomainQEMUCommandline struct {
  1773. XMLName xml.Name `xml:"http://libvirt.org/schemas/domain/qemu/1.0 commandline"`
  1774. Args []DomainQEMUCommandlineArg `xml:"arg"`
  1775. Envs []DomainQEMUCommandlineEnv `xml:"env"`
  1776. }
  1777. type DomainLXCNamespace struct {
  1778. XMLName xml.Name `xml:"http://libvirt.org/schemas/domain/lxc/1.0 namespace"`
  1779. ShareNet *DomainLXCNamespaceMap `xml:"sharenet"`
  1780. ShareIPC *DomainLXCNamespaceMap `xml:"shareipc"`
  1781. ShareUTS *DomainLXCNamespaceMap `xml:"shareuts"`
  1782. }
  1783. type DomainLXCNamespaceMap struct {
  1784. Type string `xml:"type,attr"`
  1785. Value string `xml:"value,attr"`
  1786. }
  1787. type DomainBHyveCommandlineArg struct {
  1788. Value string `xml:"value,attr"`
  1789. }
  1790. type DomainBHyveCommandlineEnv struct {
  1791. Name string `xml:"name,attr"`
  1792. Value string `xml:"value,attr,omitempty"`
  1793. }
  1794. type DomainBHyveCommandline struct {
  1795. XMLName xml.Name `xml:"http://libvirt.org/schemas/domain/bhyve/1.0 commandline"`
  1796. Args []DomainBHyveCommandlineArg `xml:"arg"`
  1797. Envs []DomainBHyveCommandlineEnv `xml:"env"`
  1798. }
  1799. type DomainBlockIOTune struct {
  1800. Weight uint `xml:"weight,omitempty"`
  1801. Device []DomainBlockIOTuneDevice `xml:"device"`
  1802. }
  1803. type DomainBlockIOTuneDevice struct {
  1804. Path string `xml:"path"`
  1805. Weight uint `xml:"weight,omitempty"`
  1806. ReadIopsSec uint `xml:"read_iops_sec,omitempty"`
  1807. WriteIopsSec uint `xml:"write_iops_sec,omitempty"`
  1808. ReadBytesSec uint `xml:"read_bytes_sec,omitempty"`
  1809. WriteBytesSec uint `xml:"write_bytes_sec,omitempty"`
  1810. }
  1811. type DomainPM struct {
  1812. SuspendToMem *DomainPMPolicy `xml:"suspend-to-mem"`
  1813. SuspendToDisk *DomainPMPolicy `xml:"suspend-to-disk"`
  1814. }
  1815. type DomainPMPolicy struct {
  1816. Enabled string `xml:"enabled,attr"`
  1817. }
  1818. type DomainSecLabel struct {
  1819. Type string `xml:"type,attr,omitempty"`
  1820. Model string `xml:"model,attr,omitempty"`
  1821. Relabel string `xml:"relabel,attr,omitempty"`
  1822. Label string `xml:"label,omitempty"`
  1823. ImageLabel string `xml:"imagelabel,omitempty"`
  1824. BaseLabel string `xml:"baselabel,omitempty"`
  1825. }
  1826. type DomainDeviceSecLabel struct {
  1827. Model string `xml:"model,attr,omitempty"`
  1828. LabelSkip string `xml:"labelskip,attr,omitempty"`
  1829. Relabel string `xml:"relabel,attr,omitempty"`
  1830. Label string `xml:"label,omitempty"`
  1831. }
  1832. type DomainNUMATune struct {
  1833. Memory *DomainNUMATuneMemory `xml:"memory"`
  1834. MemNodes []DomainNUMATuneMemNode `xml:"memnode"`
  1835. }
  1836. type DomainNUMATuneMemory struct {
  1837. Mode string `xml:"mode,attr,omitempty"`
  1838. Nodeset string `xml:"nodeset,attr,omitempty"`
  1839. Placement string `xml:"placement,attr,omitempty"`
  1840. }
  1841. type DomainNUMATuneMemNode struct {
  1842. CellID uint `xml:"cellid,attr"`
  1843. Mode string `xml:"mode,attr"`
  1844. Nodeset string `xml:"nodeset,attr"`
  1845. }
  1846. type DomainIOThreadIDs struct {
  1847. IOThreads []DomainIOThread `xml:"iothread"`
  1848. }
  1849. type DomainIOThread struct {
  1850. ID uint `xml:"id,attr"`
  1851. }
  1852. type DomainKeyWrap struct {
  1853. Ciphers []DomainKeyWrapCipher `xml:"cipher"`
  1854. }
  1855. type DomainKeyWrapCipher struct {
  1856. Name string `xml:"name,attr"`
  1857. State string `xml:"state,attr"`
  1858. }
  1859. type DomainIDMap struct {
  1860. UIDs []DomainIDMapRange `xml:"uid"`
  1861. GIDs []DomainIDMapRange `xml:"gid"`
  1862. }
  1863. type DomainIDMapRange struct {
  1864. Start uint `xml:"start,attr"`
  1865. Target uint `xml:"target,attr"`
  1866. Count uint `xml:"count,attr"`
  1867. }
  1868. type DomainMemoryTuneLimit struct {
  1869. Value uint64 `xml:",chardata"`
  1870. Unit string `xml:"unit,attr,omitempty"`
  1871. }
  1872. type DomainMemoryTune struct {
  1873. HardLimit *DomainMemoryTuneLimit `xml:"hard_limit"`
  1874. SoftLimit *DomainMemoryTuneLimit `xml:"soft_limit"`
  1875. MinGuarantee *DomainMemoryTuneLimit `xml:"min_guarantee"`
  1876. SwapHardLimit *DomainMemoryTuneLimit `xml:"swap_hard_limit"`
  1877. }
  1878. type DomainMetadata struct {
  1879. XML string `xml:",innerxml"`
  1880. }
  1881. type DomainVMWareDataCenterPath struct {
  1882. XMLName xml.Name `xml:"http://libvirt.org/schemas/domain/vmware/1.0 datacenterpath"`
  1883. Value string `xml:",chardata"`
  1884. }
  1885. type DomainPerf struct {
  1886. Events []DomainPerfEvent `xml:"event"`
  1887. }
  1888. type DomainPerfEvent struct {
  1889. Name string `xml:"name,attr"`
  1890. Enabled string `xml:"enabled,attr"`
  1891. }
  1892. type DomainGenID struct {
  1893. Value string `xml:",chardata"`
  1894. }
  1895. // NB, try to keep the order of fields in this struct
  1896. // matching the order of XML elements that libvirt
  1897. // will generate when dumping XML.
  1898. type Domain struct {
  1899. XMLName xml.Name `xml:"domain"`
  1900. Type string `xml:"type,attr,omitempty"`
  1901. ID *int `xml:"id,attr"`
  1902. Name string `xml:"name,omitempty"`
  1903. UUID string `xml:"uuid,omitempty"`
  1904. GenID *DomainGenID `xml:"genid"`
  1905. Title string `xml:"title,omitempty"`
  1906. Description string `xml:"description,omitempty"`
  1907. Metadata *DomainMetadata `xml:"metadata"`
  1908. MaximumMemory *DomainMaxMemory `xml:"maxMemory"`
  1909. Memory *DomainMemory `xml:"memory"`
  1910. CurrentMemory *DomainCurrentMemory `xml:"currentMemory"`
  1911. BlockIOTune *DomainBlockIOTune `xml:"blkiotune"`
  1912. MemoryTune *DomainMemoryTune `xml:"memtune"`
  1913. MemoryBacking *DomainMemoryBacking `xml:"memoryBacking"`
  1914. VCPU *DomainVCPU `xml:"vcpu"`
  1915. VCPUs *DomainVCPUs `xml:"vcpus"`
  1916. IOThreads uint `xml:"iothreads,omitempty"`
  1917. IOThreadIDs *DomainIOThreadIDs `xml:"iothreadids"`
  1918. CPUTune *DomainCPUTune `xml:"cputune"`
  1919. NUMATune *DomainNUMATune `xml:"numatune"`
  1920. Resource *DomainResource `xml:"resource"`
  1921. SysInfo *DomainSysInfo `xml:"sysinfo"`
  1922. Bootloader string `xml:"bootloader,omitempty"`
  1923. BootloaderArgs string `xml:"bootloader_args,omitempty"`
  1924. OS *DomainOS `xml:"os"`
  1925. IDMap *DomainIDMap `xml:"idmap"`
  1926. Features *DomainFeatureList `xml:"features"`
  1927. CPU *DomainCPU `xml:"cpu"`
  1928. Clock *DomainClock `xml:"clock"`
  1929. OnPoweroff string `xml:"on_poweroff,omitempty"`
  1930. OnReboot string `xml:"on_reboot,omitempty"`
  1931. OnCrash string `xml:"on_crash,omitempty"`
  1932. PM *DomainPM `xml:"pm"`
  1933. Perf *DomainPerf `xml:"perf"`
  1934. Devices *DomainDeviceList `xml:"devices"`
  1935. SecLabel []DomainSecLabel `xml:"seclabel"`
  1936. KeyWrap *DomainKeyWrap `xml:"keywrap"`
  1937. LaunchSecurity *DomainLaunchSecurity `xml:"launchSecurity"`
  1938. /* Hypervisor namespaces must all be last */
  1939. QEMUCommandline *DomainQEMUCommandline
  1940. LXCNamespace *DomainLXCNamespace
  1941. BHyveCommandline *DomainBHyveCommandline
  1942. VMWareDataCenterPath *DomainVMWareDataCenterPath
  1943. }
  1944. func (d *Domain) Unmarshal(doc string) error {
  1945. return xml.Unmarshal([]byte(doc), d)
  1946. }
  1947. func (d *Domain) Marshal() (string, error) {
  1948. doc, err := xml.MarshalIndent(d, "", " ")
  1949. if err != nil {
  1950. return "", err
  1951. }
  1952. return string(doc), nil
  1953. }
  1954. type domainController DomainController
  1955. type domainControllerPCI struct {
  1956. DomainControllerPCI
  1957. domainController
  1958. }
  1959. type domainControllerUSB struct {
  1960. DomainControllerUSB
  1961. domainController
  1962. }
  1963. type domainControllerVirtIOSerial struct {
  1964. DomainControllerVirtIOSerial
  1965. domainController
  1966. }
  1967. type domainControllerXenBus struct {
  1968. DomainControllerXenBus
  1969. domainController
  1970. }
  1971. func (a *DomainControllerPCITarget) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  1972. marshalUintAttr(&start, "chassisNr", a.ChassisNr, "%d")
  1973. marshalUintAttr(&start, "chassis", a.Chassis, "%d")
  1974. marshalUintAttr(&start, "port", a.Port, "%d")
  1975. marshalUintAttr(&start, "busNr", a.BusNr, "%d")
  1976. marshalUintAttr(&start, "index", a.Index, "%d")
  1977. e.EncodeToken(start)
  1978. if a.NUMANode != nil {
  1979. node := xml.StartElement{
  1980. Name: xml.Name{Local: "node"},
  1981. }
  1982. e.EncodeToken(node)
  1983. e.EncodeToken(xml.CharData(fmt.Sprintf("%d", *a.NUMANode)))
  1984. e.EncodeToken(node.End())
  1985. }
  1986. e.EncodeToken(start.End())
  1987. return nil
  1988. }
  1989. func (a *DomainControllerPCITarget) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  1990. for _, attr := range start.Attr {
  1991. if attr.Name.Local == "chassisNr" {
  1992. if err := unmarshalUintAttr(attr.Value, &a.ChassisNr, 10); err != nil {
  1993. return err
  1994. }
  1995. } else if attr.Name.Local == "chassis" {
  1996. if err := unmarshalUintAttr(attr.Value, &a.Chassis, 10); err != nil {
  1997. return err
  1998. }
  1999. } else if attr.Name.Local == "port" {
  2000. if err := unmarshalUintAttr(attr.Value, &a.Port, 0); err != nil {
  2001. return err
  2002. }
  2003. } else if attr.Name.Local == "busNr" {
  2004. if err := unmarshalUintAttr(attr.Value, &a.BusNr, 10); err != nil {
  2005. return err
  2006. }
  2007. } else if attr.Name.Local == "index" {
  2008. if err := unmarshalUintAttr(attr.Value, &a.Index, 10); err != nil {
  2009. return err
  2010. }
  2011. }
  2012. }
  2013. for {
  2014. tok, err := d.Token()
  2015. if err == io.EOF {
  2016. break
  2017. }
  2018. if err != nil {
  2019. return err
  2020. }
  2021. switch tok := tok.(type) {
  2022. case xml.StartElement:
  2023. if tok.Name.Local == "node" {
  2024. data, err := d.Token()
  2025. if err != nil {
  2026. return err
  2027. }
  2028. switch data := data.(type) {
  2029. case xml.CharData:
  2030. val, err := strconv.ParseUint(string(data), 10, 64)
  2031. if err != nil {
  2032. return err
  2033. }
  2034. vali := uint(val)
  2035. a.NUMANode = &vali
  2036. }
  2037. }
  2038. }
  2039. }
  2040. return nil
  2041. }
  2042. func (a *DomainController) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2043. start.Name.Local = "controller"
  2044. if a.Type == "pci" {
  2045. pci := domainControllerPCI{}
  2046. pci.domainController = domainController(*a)
  2047. if a.PCI != nil {
  2048. pci.DomainControllerPCI = *a.PCI
  2049. }
  2050. return e.EncodeElement(pci, start)
  2051. } else if a.Type == "usb" {
  2052. usb := domainControllerUSB{}
  2053. usb.domainController = domainController(*a)
  2054. if a.USB != nil {
  2055. usb.DomainControllerUSB = *a.USB
  2056. }
  2057. return e.EncodeElement(usb, start)
  2058. } else if a.Type == "virtio-serial" {
  2059. vioserial := domainControllerVirtIOSerial{}
  2060. vioserial.domainController = domainController(*a)
  2061. if a.VirtIOSerial != nil {
  2062. vioserial.DomainControllerVirtIOSerial = *a.VirtIOSerial
  2063. }
  2064. return e.EncodeElement(vioserial, start)
  2065. } else if a.Type == "xenbus" {
  2066. xenbus := domainControllerXenBus{}
  2067. xenbus.domainController = domainController(*a)
  2068. if a.XenBus != nil {
  2069. xenbus.DomainControllerXenBus = *a.XenBus
  2070. }
  2071. return e.EncodeElement(xenbus, start)
  2072. } else {
  2073. gen := domainController(*a)
  2074. return e.EncodeElement(gen, start)
  2075. }
  2076. }
  2077. func getAttr(attrs []xml.Attr, name string) (string, bool) {
  2078. for _, attr := range attrs {
  2079. if attr.Name.Local == name {
  2080. return attr.Value, true
  2081. }
  2082. }
  2083. return "", false
  2084. }
  2085. func (a *DomainController) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2086. typ, ok := getAttr(start.Attr, "type")
  2087. if !ok {
  2088. return fmt.Errorf("Missing 'type' attribute on domain controller")
  2089. }
  2090. if typ == "pci" {
  2091. var pci domainControllerPCI
  2092. err := d.DecodeElement(&pci, &start)
  2093. if err != nil {
  2094. return err
  2095. }
  2096. *a = DomainController(pci.domainController)
  2097. a.PCI = &pci.DomainControllerPCI
  2098. return nil
  2099. } else if typ == "usb" {
  2100. var usb domainControllerUSB
  2101. err := d.DecodeElement(&usb, &start)
  2102. if err != nil {
  2103. return err
  2104. }
  2105. *a = DomainController(usb.domainController)
  2106. a.USB = &usb.DomainControllerUSB
  2107. return nil
  2108. } else if typ == "virtio-serial" {
  2109. var vioserial domainControllerVirtIOSerial
  2110. err := d.DecodeElement(&vioserial, &start)
  2111. if err != nil {
  2112. return err
  2113. }
  2114. *a = DomainController(vioserial.domainController)
  2115. a.VirtIOSerial = &vioserial.DomainControllerVirtIOSerial
  2116. return nil
  2117. } else if typ == "xenbus" {
  2118. var xenbus domainControllerXenBus
  2119. err := d.DecodeElement(&xenbus, &start)
  2120. if err != nil {
  2121. return err
  2122. }
  2123. *a = DomainController(xenbus.domainController)
  2124. a.XenBus = &xenbus.DomainControllerXenBus
  2125. return nil
  2126. } else {
  2127. var gen domainController
  2128. err := d.DecodeElement(&gen, &start)
  2129. if err != nil {
  2130. return err
  2131. }
  2132. *a = DomainController(gen)
  2133. return nil
  2134. }
  2135. }
  2136. func (d *DomainGraphic) Unmarshal(doc string) error {
  2137. return xml.Unmarshal([]byte(doc), d)
  2138. }
  2139. func (d *DomainGraphic) Marshal() (string, error) {
  2140. doc, err := xml.MarshalIndent(d, "", " ")
  2141. if err != nil {
  2142. return "", err
  2143. }
  2144. return string(doc), nil
  2145. }
  2146. func (d *DomainController) Unmarshal(doc string) error {
  2147. return xml.Unmarshal([]byte(doc), d)
  2148. }
  2149. func (d *DomainController) Marshal() (string, error) {
  2150. doc, err := xml.MarshalIndent(d, "", " ")
  2151. if err != nil {
  2152. return "", err
  2153. }
  2154. return string(doc), nil
  2155. }
  2156. func (a *DomainDiskReservationsSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2157. start.Name.Local = "source"
  2158. src := DomainChardevSource(*a)
  2159. typ := getChardevSourceType(&src)
  2160. if typ != "" {
  2161. start.Attr = append(start.Attr, xml.Attr{
  2162. xml.Name{Local: "type"}, typ,
  2163. })
  2164. }
  2165. return e.EncodeElement(&src, start)
  2166. }
  2167. func (a *DomainDiskReservationsSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2168. typ, ok := getAttr(start.Attr, "type")
  2169. if !ok {
  2170. typ = "unix"
  2171. }
  2172. src := createChardevSource(typ)
  2173. err := d.DecodeElement(&src, &start)
  2174. if err != nil {
  2175. return err
  2176. }
  2177. *a = DomainDiskReservationsSource(*src)
  2178. return nil
  2179. }
  2180. type domainDiskSource DomainDiskSource
  2181. type domainDiskSourceFile struct {
  2182. DomainDiskSourceFile
  2183. domainDiskSource
  2184. }
  2185. type domainDiskSourceBlock struct {
  2186. DomainDiskSourceBlock
  2187. domainDiskSource
  2188. }
  2189. type domainDiskSourceDir struct {
  2190. DomainDiskSourceDir
  2191. domainDiskSource
  2192. }
  2193. type domainDiskSourceNetwork struct {
  2194. DomainDiskSourceNetwork
  2195. domainDiskSource
  2196. }
  2197. type domainDiskSourceVolume struct {
  2198. DomainDiskSourceVolume
  2199. domainDiskSource
  2200. }
  2201. func (a *DomainDiskSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2202. if a.File != nil {
  2203. if a.StartupPolicy == "" && a.Encryption == nil && a.File.File == "" {
  2204. return nil
  2205. }
  2206. file := domainDiskSourceFile{
  2207. *a.File, domainDiskSource(*a),
  2208. }
  2209. return e.EncodeElement(&file, start)
  2210. } else if a.Block != nil {
  2211. if a.StartupPolicy == "" && a.Encryption == nil && a.Block.Dev == "" {
  2212. return nil
  2213. }
  2214. block := domainDiskSourceBlock{
  2215. *a.Block, domainDiskSource(*a),
  2216. }
  2217. return e.EncodeElement(&block, start)
  2218. } else if a.Dir != nil {
  2219. dir := domainDiskSourceDir{
  2220. *a.Dir, domainDiskSource(*a),
  2221. }
  2222. return e.EncodeElement(&dir, start)
  2223. } else if a.Network != nil {
  2224. network := domainDiskSourceNetwork{
  2225. *a.Network, domainDiskSource(*a),
  2226. }
  2227. return e.EncodeElement(&network, start)
  2228. } else if a.Volume != nil {
  2229. if a.StartupPolicy == "" && a.Encryption == nil && a.Volume.Pool == "" && a.Volume.Volume == "" {
  2230. return nil
  2231. }
  2232. volume := domainDiskSourceVolume{
  2233. *a.Volume, domainDiskSource(*a),
  2234. }
  2235. return e.EncodeElement(&volume, start)
  2236. }
  2237. return nil
  2238. }
  2239. func (a *DomainDiskSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2240. if a.File != nil {
  2241. file := domainDiskSourceFile{
  2242. *a.File, domainDiskSource(*a),
  2243. }
  2244. err := d.DecodeElement(&file, &start)
  2245. if err != nil {
  2246. return err
  2247. }
  2248. *a = DomainDiskSource(file.domainDiskSource)
  2249. a.File = &file.DomainDiskSourceFile
  2250. } else if a.Block != nil {
  2251. block := domainDiskSourceBlock{
  2252. *a.Block, domainDiskSource(*a),
  2253. }
  2254. err := d.DecodeElement(&block, &start)
  2255. if err != nil {
  2256. return err
  2257. }
  2258. *a = DomainDiskSource(block.domainDiskSource)
  2259. a.Block = &block.DomainDiskSourceBlock
  2260. } else if a.Dir != nil {
  2261. dir := domainDiskSourceDir{
  2262. *a.Dir, domainDiskSource(*a),
  2263. }
  2264. err := d.DecodeElement(&dir, &start)
  2265. if err != nil {
  2266. return err
  2267. }
  2268. *a = DomainDiskSource(dir.domainDiskSource)
  2269. a.Dir = &dir.DomainDiskSourceDir
  2270. } else if a.Network != nil {
  2271. network := domainDiskSourceNetwork{
  2272. *a.Network, domainDiskSource(*a),
  2273. }
  2274. err := d.DecodeElement(&network, &start)
  2275. if err != nil {
  2276. return err
  2277. }
  2278. *a = DomainDiskSource(network.domainDiskSource)
  2279. a.Network = &network.DomainDiskSourceNetwork
  2280. } else if a.Volume != nil {
  2281. volume := domainDiskSourceVolume{
  2282. *a.Volume, domainDiskSource(*a),
  2283. }
  2284. err := d.DecodeElement(&volume, &start)
  2285. if err != nil {
  2286. return err
  2287. }
  2288. *a = DomainDiskSource(volume.domainDiskSource)
  2289. a.Volume = &volume.DomainDiskSourceVolume
  2290. }
  2291. return nil
  2292. }
  2293. type domainDiskBackingStore DomainDiskBackingStore
  2294. func (a *DomainDiskBackingStore) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2295. start.Name.Local = "backingStore"
  2296. if a.Source != nil {
  2297. if a.Source.File != nil {
  2298. start.Attr = append(start.Attr, xml.Attr{
  2299. xml.Name{Local: "type"}, "file",
  2300. })
  2301. } else if a.Source.Block != nil {
  2302. start.Attr = append(start.Attr, xml.Attr{
  2303. xml.Name{Local: "type"}, "block",
  2304. })
  2305. } else if a.Source.Dir != nil {
  2306. start.Attr = append(start.Attr, xml.Attr{
  2307. xml.Name{Local: "type"}, "dir",
  2308. })
  2309. } else if a.Source.Network != nil {
  2310. start.Attr = append(start.Attr, xml.Attr{
  2311. xml.Name{Local: "type"}, "network",
  2312. })
  2313. } else if a.Source.Volume != nil {
  2314. start.Attr = append(start.Attr, xml.Attr{
  2315. xml.Name{Local: "type"}, "volume",
  2316. })
  2317. }
  2318. }
  2319. disk := domainDiskBackingStore(*a)
  2320. return e.EncodeElement(disk, start)
  2321. }
  2322. func (a *DomainDiskBackingStore) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2323. typ, ok := getAttr(start.Attr, "type")
  2324. if !ok {
  2325. typ = "file"
  2326. }
  2327. a.Source = &DomainDiskSource{}
  2328. if typ == "file" {
  2329. a.Source.File = &DomainDiskSourceFile{}
  2330. } else if typ == "block" {
  2331. a.Source.Block = &DomainDiskSourceBlock{}
  2332. } else if typ == "network" {
  2333. a.Source.Network = &DomainDiskSourceNetwork{}
  2334. } else if typ == "dir" {
  2335. a.Source.Dir = &DomainDiskSourceDir{}
  2336. } else if typ == "volume" {
  2337. a.Source.Volume = &DomainDiskSourceVolume{}
  2338. }
  2339. disk := domainDiskBackingStore(*a)
  2340. err := d.DecodeElement(&disk, &start)
  2341. if err != nil {
  2342. return err
  2343. }
  2344. *a = DomainDiskBackingStore(disk)
  2345. if !ok && a.Source.File.File == "" {
  2346. a.Source.File = nil
  2347. }
  2348. return nil
  2349. }
  2350. type domainDiskMirror DomainDiskMirror
  2351. func (a *DomainDiskMirror) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2352. start.Name.Local = "mirror"
  2353. if a.Source != nil {
  2354. if a.Source.File != nil {
  2355. start.Attr = append(start.Attr, xml.Attr{
  2356. xml.Name{Local: "type"}, "file",
  2357. })
  2358. if a.Source.File.File != "" {
  2359. start.Attr = append(start.Attr, xml.Attr{
  2360. xml.Name{Local: "file"}, a.Source.File.File,
  2361. })
  2362. }
  2363. if a.Format != nil && a.Format.Type != "" {
  2364. start.Attr = append(start.Attr, xml.Attr{
  2365. xml.Name{Local: "format"}, a.Format.Type,
  2366. })
  2367. }
  2368. } else if a.Source.Block != nil {
  2369. start.Attr = append(start.Attr, xml.Attr{
  2370. xml.Name{Local: "type"}, "block",
  2371. })
  2372. } else if a.Source.Dir != nil {
  2373. start.Attr = append(start.Attr, xml.Attr{
  2374. xml.Name{Local: "type"}, "dir",
  2375. })
  2376. } else if a.Source.Network != nil {
  2377. start.Attr = append(start.Attr, xml.Attr{
  2378. xml.Name{Local: "type"}, "network",
  2379. })
  2380. } else if a.Source.Volume != nil {
  2381. start.Attr = append(start.Attr, xml.Attr{
  2382. xml.Name{Local: "type"}, "volume",
  2383. })
  2384. }
  2385. }
  2386. disk := domainDiskMirror(*a)
  2387. return e.EncodeElement(disk, start)
  2388. }
  2389. func (a *DomainDiskMirror) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2390. typ, ok := getAttr(start.Attr, "type")
  2391. if !ok {
  2392. typ = "file"
  2393. }
  2394. a.Source = &DomainDiskSource{}
  2395. if typ == "file" {
  2396. a.Source.File = &DomainDiskSourceFile{}
  2397. } else if typ == "block" {
  2398. a.Source.Block = &DomainDiskSourceBlock{}
  2399. } else if typ == "network" {
  2400. a.Source.Network = &DomainDiskSourceNetwork{}
  2401. } else if typ == "dir" {
  2402. a.Source.Dir = &DomainDiskSourceDir{}
  2403. } else if typ == "volume" {
  2404. a.Source.Volume = &DomainDiskSourceVolume{}
  2405. }
  2406. disk := domainDiskMirror(*a)
  2407. err := d.DecodeElement(&disk, &start)
  2408. if err != nil {
  2409. return err
  2410. }
  2411. *a = DomainDiskMirror(disk)
  2412. if !ok {
  2413. if a.Source.File.File == "" {
  2414. file, ok := getAttr(start.Attr, "file")
  2415. if ok {
  2416. a.Source.File.File = file
  2417. } else {
  2418. a.Source.File = nil
  2419. }
  2420. }
  2421. if a.Format == nil {
  2422. format, ok := getAttr(start.Attr, "format")
  2423. if ok {
  2424. a.Format = &DomainDiskFormat{
  2425. Type: format,
  2426. }
  2427. }
  2428. }
  2429. }
  2430. return nil
  2431. }
  2432. type domainDisk DomainDisk
  2433. func (a *DomainDisk) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2434. start.Name.Local = "disk"
  2435. if a.Source != nil {
  2436. if a.Source.File != nil {
  2437. start.Attr = append(start.Attr, xml.Attr{
  2438. xml.Name{Local: "type"}, "file",
  2439. })
  2440. } else if a.Source.Block != nil {
  2441. start.Attr = append(start.Attr, xml.Attr{
  2442. xml.Name{Local: "type"}, "block",
  2443. })
  2444. } else if a.Source.Dir != nil {
  2445. start.Attr = append(start.Attr, xml.Attr{
  2446. xml.Name{Local: "type"}, "dir",
  2447. })
  2448. } else if a.Source.Network != nil {
  2449. start.Attr = append(start.Attr, xml.Attr{
  2450. xml.Name{Local: "type"}, "network",
  2451. })
  2452. } else if a.Source.Volume != nil {
  2453. start.Attr = append(start.Attr, xml.Attr{
  2454. xml.Name{Local: "type"}, "volume",
  2455. })
  2456. }
  2457. }
  2458. disk := domainDisk(*a)
  2459. return e.EncodeElement(disk, start)
  2460. }
  2461. func (a *DomainDisk) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2462. typ, ok := getAttr(start.Attr, "type")
  2463. if !ok {
  2464. typ = "file"
  2465. }
  2466. a.Source = &DomainDiskSource{}
  2467. if typ == "file" {
  2468. a.Source.File = &DomainDiskSourceFile{}
  2469. } else if typ == "block" {
  2470. a.Source.Block = &DomainDiskSourceBlock{}
  2471. } else if typ == "network" {
  2472. a.Source.Network = &DomainDiskSourceNetwork{}
  2473. } else if typ == "dir" {
  2474. a.Source.Dir = &DomainDiskSourceDir{}
  2475. } else if typ == "volume" {
  2476. a.Source.Volume = &DomainDiskSourceVolume{}
  2477. }
  2478. disk := domainDisk(*a)
  2479. err := d.DecodeElement(&disk, &start)
  2480. if err != nil {
  2481. return err
  2482. }
  2483. *a = DomainDisk(disk)
  2484. return nil
  2485. }
  2486. func (d *DomainDisk) Unmarshal(doc string) error {
  2487. return xml.Unmarshal([]byte(doc), d)
  2488. }
  2489. func (d *DomainDisk) Marshal() (string, error) {
  2490. doc, err := xml.MarshalIndent(d, "", " ")
  2491. if err != nil {
  2492. return "", err
  2493. }
  2494. return string(doc), nil
  2495. }
  2496. func (a *DomainFilesystemSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2497. if a.Mount != nil {
  2498. return e.EncodeElement(a.Mount, start)
  2499. } else if a.Block != nil {
  2500. return e.EncodeElement(a.Block, start)
  2501. } else if a.File != nil {
  2502. return e.EncodeElement(a.File, start)
  2503. } else if a.Template != nil {
  2504. return e.EncodeElement(a.Template, start)
  2505. } else if a.RAM != nil {
  2506. return e.EncodeElement(a.RAM, start)
  2507. } else if a.Bind != nil {
  2508. return e.EncodeElement(a.Bind, start)
  2509. } else if a.Volume != nil {
  2510. return e.EncodeElement(a.Volume, start)
  2511. }
  2512. return nil
  2513. }
  2514. func (a *DomainFilesystemSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2515. if a.Mount != nil {
  2516. return d.DecodeElement(a.Mount, &start)
  2517. } else if a.Block != nil {
  2518. return d.DecodeElement(a.Block, &start)
  2519. } else if a.File != nil {
  2520. return d.DecodeElement(a.File, &start)
  2521. } else if a.Template != nil {
  2522. return d.DecodeElement(a.Template, &start)
  2523. } else if a.RAM != nil {
  2524. return d.DecodeElement(a.RAM, &start)
  2525. } else if a.Bind != nil {
  2526. return d.DecodeElement(a.Bind, &start)
  2527. } else if a.Volume != nil {
  2528. return d.DecodeElement(a.Volume, &start)
  2529. }
  2530. return nil
  2531. }
  2532. type domainFilesystem DomainFilesystem
  2533. func (a *DomainFilesystem) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2534. start.Name.Local = "filesystem"
  2535. if a.Source != nil {
  2536. if a.Source.Mount != nil {
  2537. start.Attr = append(start.Attr, xml.Attr{
  2538. xml.Name{Local: "type"}, "mount",
  2539. })
  2540. } else if a.Source.Block != nil {
  2541. start.Attr = append(start.Attr, xml.Attr{
  2542. xml.Name{Local: "type"}, "block",
  2543. })
  2544. } else if a.Source.File != nil {
  2545. start.Attr = append(start.Attr, xml.Attr{
  2546. xml.Name{Local: "type"}, "file",
  2547. })
  2548. } else if a.Source.Template != nil {
  2549. start.Attr = append(start.Attr, xml.Attr{
  2550. xml.Name{Local: "type"}, "template",
  2551. })
  2552. } else if a.Source.RAM != nil {
  2553. start.Attr = append(start.Attr, xml.Attr{
  2554. xml.Name{Local: "type"}, "ram",
  2555. })
  2556. } else if a.Source.Bind != nil {
  2557. start.Attr = append(start.Attr, xml.Attr{
  2558. xml.Name{Local: "type"}, "bind",
  2559. })
  2560. } else if a.Source.Volume != nil {
  2561. start.Attr = append(start.Attr, xml.Attr{
  2562. xml.Name{Local: "type"}, "volume",
  2563. })
  2564. }
  2565. }
  2566. fs := domainFilesystem(*a)
  2567. return e.EncodeElement(fs, start)
  2568. }
  2569. func (a *DomainFilesystem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2570. typ, ok := getAttr(start.Attr, "type")
  2571. if !ok {
  2572. typ = "mount"
  2573. }
  2574. a.Source = &DomainFilesystemSource{}
  2575. if typ == "mount" {
  2576. a.Source.Mount = &DomainFilesystemSourceMount{}
  2577. } else if typ == "block" {
  2578. a.Source.Block = &DomainFilesystemSourceBlock{}
  2579. } else if typ == "file" {
  2580. a.Source.File = &DomainFilesystemSourceFile{}
  2581. } else if typ == "template" {
  2582. a.Source.Template = &DomainFilesystemSourceTemplate{}
  2583. } else if typ == "ram" {
  2584. a.Source.RAM = &DomainFilesystemSourceRAM{}
  2585. } else if typ == "bind" {
  2586. a.Source.Bind = &DomainFilesystemSourceBind{}
  2587. } else if typ == "volume" {
  2588. a.Source.Volume = &DomainFilesystemSourceVolume{}
  2589. }
  2590. fs := domainFilesystem(*a)
  2591. err := d.DecodeElement(&fs, &start)
  2592. if err != nil {
  2593. return err
  2594. }
  2595. *a = DomainFilesystem(fs)
  2596. return nil
  2597. }
  2598. func (d *DomainFilesystem) Unmarshal(doc string) error {
  2599. return xml.Unmarshal([]byte(doc), d)
  2600. }
  2601. func (d *DomainFilesystem) Marshal() (string, error) {
  2602. doc, err := xml.MarshalIndent(d, "", " ")
  2603. if err != nil {
  2604. return "", err
  2605. }
  2606. return string(doc), nil
  2607. }
  2608. func (a *DomainInterfaceVirtualPortParams) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2609. start.Name.Local = "parameters"
  2610. if a.Any != nil {
  2611. return e.EncodeElement(a.Any, start)
  2612. } else if a.VEPA8021QBG != nil {
  2613. return e.EncodeElement(a.VEPA8021QBG, start)
  2614. } else if a.VNTag8011QBH != nil {
  2615. return e.EncodeElement(a.VNTag8011QBH, start)
  2616. } else if a.OpenVSwitch != nil {
  2617. return e.EncodeElement(a.OpenVSwitch, start)
  2618. } else if a.MidoNet != nil {
  2619. return e.EncodeElement(a.MidoNet, start)
  2620. }
  2621. return nil
  2622. }
  2623. func (a *DomainInterfaceVirtualPortParams) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2624. if a.Any != nil {
  2625. return d.DecodeElement(a.Any, &start)
  2626. } else if a.VEPA8021QBG != nil {
  2627. return d.DecodeElement(a.VEPA8021QBG, &start)
  2628. } else if a.VNTag8011QBH != nil {
  2629. return d.DecodeElement(a.VNTag8011QBH, &start)
  2630. } else if a.OpenVSwitch != nil {
  2631. return d.DecodeElement(a.OpenVSwitch, &start)
  2632. } else if a.MidoNet != nil {
  2633. return d.DecodeElement(a.MidoNet, &start)
  2634. }
  2635. return nil
  2636. }
  2637. type domainInterfaceVirtualPort DomainInterfaceVirtualPort
  2638. func (a *DomainInterfaceVirtualPort) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2639. start.Name.Local = "virtualport"
  2640. if a.Params != nil {
  2641. if a.Params.Any != nil {
  2642. /* no type attr wanted */
  2643. } else if a.Params.VEPA8021QBG != nil {
  2644. start.Attr = append(start.Attr, xml.Attr{
  2645. xml.Name{Local: "type"}, "802.1Qbg",
  2646. })
  2647. } else if a.Params.VNTag8011QBH != nil {
  2648. start.Attr = append(start.Attr, xml.Attr{
  2649. xml.Name{Local: "type"}, "802.1Qbh",
  2650. })
  2651. } else if a.Params.OpenVSwitch != nil {
  2652. start.Attr = append(start.Attr, xml.Attr{
  2653. xml.Name{Local: "type"}, "openvswitch",
  2654. })
  2655. } else if a.Params.MidoNet != nil {
  2656. start.Attr = append(start.Attr, xml.Attr{
  2657. xml.Name{Local: "type"}, "midonet",
  2658. })
  2659. }
  2660. }
  2661. vp := domainInterfaceVirtualPort(*a)
  2662. return e.EncodeElement(&vp, start)
  2663. }
  2664. func (a *DomainInterfaceVirtualPort) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2665. typ, ok := getAttr(start.Attr, "type")
  2666. a.Params = &DomainInterfaceVirtualPortParams{}
  2667. if !ok {
  2668. var any DomainInterfaceVirtualPortParamsAny
  2669. a.Params.Any = &any
  2670. } else if typ == "802.1Qbg" {
  2671. var vepa DomainInterfaceVirtualPortParamsVEPA8021QBG
  2672. a.Params.VEPA8021QBG = &vepa
  2673. } else if typ == "802.1Qbh" {
  2674. var vntag DomainInterfaceVirtualPortParamsVNTag8021QBH
  2675. a.Params.VNTag8011QBH = &vntag
  2676. } else if typ == "openvswitch" {
  2677. var ovs DomainInterfaceVirtualPortParamsOpenVSwitch
  2678. a.Params.OpenVSwitch = &ovs
  2679. } else if typ == "midonet" {
  2680. var mido DomainInterfaceVirtualPortParamsMidoNet
  2681. a.Params.MidoNet = &mido
  2682. }
  2683. vp := domainInterfaceVirtualPort(*a)
  2684. err := d.DecodeElement(&vp, &start)
  2685. if err != nil {
  2686. return err
  2687. }
  2688. *a = DomainInterfaceVirtualPort(vp)
  2689. return nil
  2690. }
  2691. func (a *DomainInterfaceSourceHostdev) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2692. e.EncodeToken(start)
  2693. if a.PCI != nil {
  2694. addr := xml.StartElement{
  2695. Name: xml.Name{Local: "address"},
  2696. }
  2697. addr.Attr = append(addr.Attr, xml.Attr{
  2698. xml.Name{Local: "type"}, "pci",
  2699. })
  2700. e.EncodeElement(a.PCI.Address, addr)
  2701. } else if a.USB != nil {
  2702. addr := xml.StartElement{
  2703. Name: xml.Name{Local: "address"},
  2704. }
  2705. addr.Attr = append(addr.Attr, xml.Attr{
  2706. xml.Name{Local: "type"}, "usb",
  2707. })
  2708. e.EncodeElement(a.USB.Address, addr)
  2709. }
  2710. e.EncodeToken(start.End())
  2711. return nil
  2712. }
  2713. func (a *DomainInterfaceSourceHostdev) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2714. for {
  2715. tok, err := d.Token()
  2716. if err != nil {
  2717. if err == io.EOF {
  2718. break
  2719. }
  2720. return err
  2721. }
  2722. switch tok := tok.(type) {
  2723. case xml.StartElement:
  2724. if tok.Name.Local == "address" {
  2725. typ, ok := getAttr(tok.Attr, "type")
  2726. if !ok {
  2727. return fmt.Errorf("Missing hostdev address type attribute")
  2728. }
  2729. if typ == "pci" {
  2730. a.PCI = &DomainHostdevSubsysPCISource{
  2731. &DomainAddressPCI{},
  2732. }
  2733. err := d.DecodeElement(a.PCI.Address, &tok)
  2734. if err != nil {
  2735. return err
  2736. }
  2737. } else if typ == "usb" {
  2738. a.USB = &DomainHostdevSubsysUSBSource{
  2739. &DomainAddressUSB{},
  2740. }
  2741. err := d.DecodeElement(a.USB, &tok)
  2742. if err != nil {
  2743. return err
  2744. }
  2745. }
  2746. }
  2747. }
  2748. }
  2749. d.Skip()
  2750. return nil
  2751. }
  2752. func (a *DomainInterfaceSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2753. if a.User != nil {
  2754. /* We don't want an empty <source></source> for User mode */
  2755. //return e.EncodeElement(a.User, start)
  2756. return nil
  2757. } else if a.Ethernet != nil {
  2758. if len(a.Ethernet.IP) > 0 && len(a.Ethernet.Route) > 0 {
  2759. return e.EncodeElement(a.Ethernet, start)
  2760. }
  2761. return nil
  2762. } else if a.VHostUser != nil {
  2763. typ := getChardevSourceType(a.VHostUser)
  2764. if typ != "" {
  2765. start.Attr = append(start.Attr, xml.Attr{
  2766. xml.Name{Local: "type"}, typ,
  2767. })
  2768. }
  2769. return e.EncodeElement(a.VHostUser, start)
  2770. } else if a.Server != nil {
  2771. return e.EncodeElement(a.Server, start)
  2772. } else if a.Client != nil {
  2773. return e.EncodeElement(a.Client, start)
  2774. } else if a.MCast != nil {
  2775. return e.EncodeElement(a.MCast, start)
  2776. } else if a.Network != nil {
  2777. return e.EncodeElement(a.Network, start)
  2778. } else if a.Bridge != nil {
  2779. return e.EncodeElement(a.Bridge, start)
  2780. } else if a.Internal != nil {
  2781. return e.EncodeElement(a.Internal, start)
  2782. } else if a.Direct != nil {
  2783. return e.EncodeElement(a.Direct, start)
  2784. } else if a.Hostdev != nil {
  2785. return e.EncodeElement(a.Hostdev, start)
  2786. } else if a.UDP != nil {
  2787. return e.EncodeElement(a.UDP, start)
  2788. }
  2789. return nil
  2790. }
  2791. func (a *DomainInterfaceSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2792. if a.User != nil {
  2793. return d.DecodeElement(a.User, &start)
  2794. } else if a.Ethernet != nil {
  2795. return d.DecodeElement(a.Ethernet, &start)
  2796. } else if a.VHostUser != nil {
  2797. typ, ok := getAttr(start.Attr, "type")
  2798. if !ok {
  2799. typ = "pty"
  2800. }
  2801. a.VHostUser = createChardevSource(typ)
  2802. return d.DecodeElement(a.VHostUser, &start)
  2803. } else if a.Server != nil {
  2804. return d.DecodeElement(a.Server, &start)
  2805. } else if a.Client != nil {
  2806. return d.DecodeElement(a.Client, &start)
  2807. } else if a.MCast != nil {
  2808. return d.DecodeElement(a.MCast, &start)
  2809. } else if a.Network != nil {
  2810. return d.DecodeElement(a.Network, &start)
  2811. } else if a.Bridge != nil {
  2812. return d.DecodeElement(a.Bridge, &start)
  2813. } else if a.Internal != nil {
  2814. return d.DecodeElement(a.Internal, &start)
  2815. } else if a.Direct != nil {
  2816. return d.DecodeElement(a.Direct, &start)
  2817. } else if a.Hostdev != nil {
  2818. return d.DecodeElement(a.Hostdev, &start)
  2819. } else if a.UDP != nil {
  2820. return d.DecodeElement(a.UDP, &start)
  2821. }
  2822. return nil
  2823. }
  2824. type domainInterface DomainInterface
  2825. func (a *DomainInterface) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2826. start.Name.Local = "interface"
  2827. if a.Source != nil {
  2828. if a.Source.User != nil {
  2829. start.Attr = append(start.Attr, xml.Attr{
  2830. xml.Name{Local: "type"}, "user",
  2831. })
  2832. } else if a.Source.Ethernet != nil {
  2833. start.Attr = append(start.Attr, xml.Attr{
  2834. xml.Name{Local: "type"}, "ethernet",
  2835. })
  2836. } else if a.Source.VHostUser != nil {
  2837. start.Attr = append(start.Attr, xml.Attr{
  2838. xml.Name{Local: "type"}, "vhostuser",
  2839. })
  2840. } else if a.Source.Server != nil {
  2841. start.Attr = append(start.Attr, xml.Attr{
  2842. xml.Name{Local: "type"}, "server",
  2843. })
  2844. } else if a.Source.Client != nil {
  2845. start.Attr = append(start.Attr, xml.Attr{
  2846. xml.Name{Local: "type"}, "client",
  2847. })
  2848. } else if a.Source.MCast != nil {
  2849. start.Attr = append(start.Attr, xml.Attr{
  2850. xml.Name{Local: "type"}, "mcast",
  2851. })
  2852. } else if a.Source.Network != nil {
  2853. start.Attr = append(start.Attr, xml.Attr{
  2854. xml.Name{Local: "type"}, "network",
  2855. })
  2856. } else if a.Source.Bridge != nil {
  2857. start.Attr = append(start.Attr, xml.Attr{
  2858. xml.Name{Local: "type"}, "bridge",
  2859. })
  2860. } else if a.Source.Internal != nil {
  2861. start.Attr = append(start.Attr, xml.Attr{
  2862. xml.Name{Local: "type"}, "internal",
  2863. })
  2864. } else if a.Source.Direct != nil {
  2865. start.Attr = append(start.Attr, xml.Attr{
  2866. xml.Name{Local: "type"}, "direct",
  2867. })
  2868. } else if a.Source.Hostdev != nil {
  2869. start.Attr = append(start.Attr, xml.Attr{
  2870. xml.Name{Local: "type"}, "hostdev",
  2871. })
  2872. } else if a.Source.UDP != nil {
  2873. start.Attr = append(start.Attr, xml.Attr{
  2874. xml.Name{Local: "type"}, "udp",
  2875. })
  2876. }
  2877. }
  2878. fs := domainInterface(*a)
  2879. return e.EncodeElement(fs, start)
  2880. }
  2881. func (a *DomainInterface) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2882. typ, ok := getAttr(start.Attr, "type")
  2883. if !ok {
  2884. return fmt.Errorf("Missing interface type attribute")
  2885. }
  2886. a.Source = &DomainInterfaceSource{}
  2887. if typ == "user" {
  2888. a.Source.User = &DomainInterfaceSourceUser{}
  2889. } else if typ == "ethernet" {
  2890. a.Source.Ethernet = &DomainInterfaceSourceEthernet{}
  2891. } else if typ == "vhostuser" {
  2892. a.Source.VHostUser = &DomainChardevSource{}
  2893. } else if typ == "server" {
  2894. a.Source.Server = &DomainInterfaceSourceServer{}
  2895. } else if typ == "client" {
  2896. a.Source.Client = &DomainInterfaceSourceClient{}
  2897. } else if typ == "mcast" {
  2898. a.Source.MCast = &DomainInterfaceSourceMCast{}
  2899. } else if typ == "network" {
  2900. a.Source.Network = &DomainInterfaceSourceNetwork{}
  2901. } else if typ == "bridge" {
  2902. a.Source.Bridge = &DomainInterfaceSourceBridge{}
  2903. } else if typ == "internal" {
  2904. a.Source.Internal = &DomainInterfaceSourceInternal{}
  2905. } else if typ == "direct" {
  2906. a.Source.Direct = &DomainInterfaceSourceDirect{}
  2907. } else if typ == "hostdev" {
  2908. a.Source.Hostdev = &DomainInterfaceSourceHostdev{}
  2909. } else if typ == "udp" {
  2910. a.Source.UDP = &DomainInterfaceSourceUDP{}
  2911. }
  2912. fs := domainInterface(*a)
  2913. err := d.DecodeElement(&fs, &start)
  2914. if err != nil {
  2915. return err
  2916. }
  2917. *a = DomainInterface(fs)
  2918. return nil
  2919. }
  2920. func (d *DomainInterface) Unmarshal(doc string) error {
  2921. return xml.Unmarshal([]byte(doc), d)
  2922. }
  2923. func (d *DomainInterface) Marshal() (string, error) {
  2924. doc, err := xml.MarshalIndent(d, "", " ")
  2925. if err != nil {
  2926. return "", err
  2927. }
  2928. return string(doc), nil
  2929. }
  2930. type domainSmartcard DomainSmartcard
  2931. func (a *DomainSmartcard) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2932. start.Name.Local = "smartcard"
  2933. if a.Passthrough != nil {
  2934. start.Attr = append(start.Attr, xml.Attr{
  2935. xml.Name{Local: "mode"}, "passthrough",
  2936. })
  2937. typ := getChardevSourceType(a.Passthrough)
  2938. if typ != "" {
  2939. start.Attr = append(start.Attr, xml.Attr{
  2940. xml.Name{Local: "type"}, typ,
  2941. })
  2942. }
  2943. } else if a.Host != nil {
  2944. start.Attr = append(start.Attr, xml.Attr{
  2945. xml.Name{Local: "mode"}, "host",
  2946. })
  2947. } else if len(a.HostCerts) != 0 {
  2948. start.Attr = append(start.Attr, xml.Attr{
  2949. xml.Name{Local: "mode"}, "host-certificates",
  2950. })
  2951. }
  2952. smartcard := domainSmartcard(*a)
  2953. return e.EncodeElement(smartcard, start)
  2954. }
  2955. func (a *DomainSmartcard) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2956. mode, ok := getAttr(start.Attr, "mode")
  2957. if !ok {
  2958. return fmt.Errorf("Missing mode on smartcard device")
  2959. }
  2960. if mode == "host" {
  2961. a.Host = &DomainSmartcardHost{}
  2962. } else if mode == "passthrough" {
  2963. typ, ok := getAttr(start.Attr, "type")
  2964. if !ok {
  2965. typ = "pty"
  2966. }
  2967. a.Passthrough = createChardevSource(typ)
  2968. }
  2969. smartcard := domainSmartcard(*a)
  2970. err := d.DecodeElement(&smartcard, &start)
  2971. if err != nil {
  2972. return err
  2973. }
  2974. *a = DomainSmartcard(smartcard)
  2975. return nil
  2976. }
  2977. func (d *DomainSmartcard) Unmarshal(doc string) error {
  2978. return xml.Unmarshal([]byte(doc), d)
  2979. }
  2980. func (d *DomainSmartcard) Marshal() (string, error) {
  2981. doc, err := xml.MarshalIndent(d, "", " ")
  2982. if err != nil {
  2983. return "", err
  2984. }
  2985. return string(doc), nil
  2986. }
  2987. func (a *DomainTPMBackend) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2988. start.Name.Local = "backend"
  2989. if a.Passthrough != nil {
  2990. start.Attr = append(start.Attr, xml.Attr{
  2991. xml.Name{Local: "type"}, "passthrough",
  2992. })
  2993. err := e.EncodeElement(a.Passthrough, start)
  2994. if err != nil {
  2995. return err
  2996. }
  2997. } else if a.Emulator != nil {
  2998. start.Attr = append(start.Attr, xml.Attr{
  2999. xml.Name{Local: "type"}, "emulator",
  3000. })
  3001. err := e.EncodeElement(a.Emulator, start)
  3002. if err != nil {
  3003. return err
  3004. }
  3005. }
  3006. return nil
  3007. }
  3008. func (a *DomainTPMBackend) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3009. typ, ok := getAttr(start.Attr, "type")
  3010. if !ok {
  3011. return fmt.Errorf("Missing TPM backend type")
  3012. }
  3013. if typ == "passthrough" {
  3014. a.Passthrough = &DomainTPMBackendPassthrough{}
  3015. err := d.DecodeElement(a.Passthrough, &start)
  3016. if err != nil {
  3017. return err
  3018. }
  3019. } else if typ == "emulator" {
  3020. a.Emulator = &DomainTPMBackendEmulator{}
  3021. err := d.DecodeElement(a.Emulator, &start)
  3022. if err != nil {
  3023. return err
  3024. }
  3025. } else {
  3026. d.Skip()
  3027. }
  3028. return nil
  3029. }
  3030. func (d *DomainTPM) Unmarshal(doc string) error {
  3031. return xml.Unmarshal([]byte(doc), d)
  3032. }
  3033. func (d *DomainTPM) Marshal() (string, error) {
  3034. doc, err := xml.MarshalIndent(d, "", " ")
  3035. if err != nil {
  3036. return "", err
  3037. }
  3038. return string(doc), nil
  3039. }
  3040. func (d *DomainShmem) Unmarshal(doc string) error {
  3041. return xml.Unmarshal([]byte(doc), d)
  3042. }
  3043. func (d *DomainShmem) Marshal() (string, error) {
  3044. doc, err := xml.MarshalIndent(d, "", " ")
  3045. if err != nil {
  3046. return "", err
  3047. }
  3048. return string(doc), nil
  3049. }
  3050. func getChardevSourceType(s *DomainChardevSource) string {
  3051. if s.Null != nil {
  3052. return "null"
  3053. } else if s.VC != nil {
  3054. return "vc"
  3055. } else if s.Pty != nil {
  3056. return "pty"
  3057. } else if s.Dev != nil {
  3058. return "dev"
  3059. } else if s.File != nil {
  3060. return "file"
  3061. } else if s.Pipe != nil {
  3062. return "pipe"
  3063. } else if s.StdIO != nil {
  3064. return "stdio"
  3065. } else if s.UDP != nil {
  3066. return "udp"
  3067. } else if s.TCP != nil {
  3068. return "tcp"
  3069. } else if s.UNIX != nil {
  3070. return "unix"
  3071. } else if s.SpiceVMC != nil {
  3072. return "spicevmc"
  3073. } else if s.SpicePort != nil {
  3074. return "spiceport"
  3075. } else if s.NMDM != nil {
  3076. return "nmdm"
  3077. }
  3078. return ""
  3079. }
  3080. func createChardevSource(typ string) *DomainChardevSource {
  3081. switch typ {
  3082. case "null":
  3083. return &DomainChardevSource{
  3084. Null: &DomainChardevSourceNull{},
  3085. }
  3086. case "vc":
  3087. return &DomainChardevSource{
  3088. VC: &DomainChardevSourceVC{},
  3089. }
  3090. case "pty":
  3091. return &DomainChardevSource{
  3092. Pty: &DomainChardevSourcePty{},
  3093. }
  3094. case "dev":
  3095. return &DomainChardevSource{
  3096. Dev: &DomainChardevSourceDev{},
  3097. }
  3098. case "file":
  3099. return &DomainChardevSource{
  3100. File: &DomainChardevSourceFile{},
  3101. }
  3102. case "pipe":
  3103. return &DomainChardevSource{
  3104. Pipe: &DomainChardevSourcePipe{},
  3105. }
  3106. case "stdio":
  3107. return &DomainChardevSource{
  3108. StdIO: &DomainChardevSourceStdIO{},
  3109. }
  3110. case "udp":
  3111. return &DomainChardevSource{
  3112. UDP: &DomainChardevSourceUDP{},
  3113. }
  3114. case "tcp":
  3115. return &DomainChardevSource{
  3116. TCP: &DomainChardevSourceTCP{},
  3117. }
  3118. case "unix":
  3119. return &DomainChardevSource{
  3120. UNIX: &DomainChardevSourceUNIX{},
  3121. }
  3122. case "spicevmc":
  3123. return &DomainChardevSource{
  3124. SpiceVMC: &DomainChardevSourceSpiceVMC{},
  3125. }
  3126. case "spiceport":
  3127. return &DomainChardevSource{
  3128. SpicePort: &DomainChardevSourceSpicePort{},
  3129. }
  3130. case "nmdm":
  3131. return &DomainChardevSource{
  3132. NMDM: &DomainChardevSourceNMDM{},
  3133. }
  3134. }
  3135. return nil
  3136. }
  3137. type domainChardevSourceUDPFlat struct {
  3138. Mode string `xml:"mode,attr"`
  3139. Host string `xml:"host,attr,omitempty"`
  3140. Service string `xml:"service,attr,omitempty"`
  3141. }
  3142. func (a *DomainChardevSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3143. if a.Null != nil {
  3144. return nil
  3145. } else if a.VC != nil {
  3146. return nil
  3147. } else if a.Pty != nil {
  3148. if a.Pty.Path != "" {
  3149. return e.EncodeElement(a.Pty, start)
  3150. }
  3151. return nil
  3152. } else if a.Dev != nil {
  3153. return e.EncodeElement(a.Dev, start)
  3154. } else if a.File != nil {
  3155. return e.EncodeElement(a.File, start)
  3156. } else if a.Pipe != nil {
  3157. return e.EncodeElement(a.Pipe, start)
  3158. } else if a.StdIO != nil {
  3159. return nil
  3160. } else if a.UDP != nil {
  3161. srcs := []domainChardevSourceUDPFlat{
  3162. domainChardevSourceUDPFlat{
  3163. Mode: "bind",
  3164. Host: a.UDP.BindHost,
  3165. Service: a.UDP.BindService,
  3166. },
  3167. domainChardevSourceUDPFlat{
  3168. Mode: "connect",
  3169. Host: a.UDP.ConnectHost,
  3170. Service: a.UDP.ConnectService,
  3171. },
  3172. }
  3173. if srcs[0].Host != "" || srcs[0].Service != "" {
  3174. err := e.EncodeElement(&srcs[0], start)
  3175. if err != nil {
  3176. return err
  3177. }
  3178. }
  3179. if srcs[1].Host != "" || srcs[1].Service != "" {
  3180. err := e.EncodeElement(&srcs[1], start)
  3181. if err != nil {
  3182. return err
  3183. }
  3184. }
  3185. } else if a.TCP != nil {
  3186. return e.EncodeElement(a.TCP, start)
  3187. } else if a.UNIX != nil {
  3188. if a.UNIX.Path == "" && a.UNIX.Mode == "" {
  3189. return nil
  3190. }
  3191. return e.EncodeElement(a.UNIX, start)
  3192. } else if a.SpiceVMC != nil {
  3193. return nil
  3194. } else if a.SpicePort != nil {
  3195. return e.EncodeElement(a.SpicePort, start)
  3196. } else if a.NMDM != nil {
  3197. return e.EncodeElement(a.NMDM, start)
  3198. }
  3199. return nil
  3200. }
  3201. func (a *DomainChardevSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3202. if a.Null != nil {
  3203. d.Skip()
  3204. return nil
  3205. } else if a.VC != nil {
  3206. d.Skip()
  3207. return nil
  3208. } else if a.Pty != nil {
  3209. return d.DecodeElement(a.Pty, &start)
  3210. } else if a.Dev != nil {
  3211. return d.DecodeElement(a.Dev, &start)
  3212. } else if a.File != nil {
  3213. return d.DecodeElement(a.File, &start)
  3214. } else if a.Pipe != nil {
  3215. return d.DecodeElement(a.Pipe, &start)
  3216. } else if a.StdIO != nil {
  3217. d.Skip()
  3218. return nil
  3219. } else if a.UDP != nil {
  3220. src := domainChardevSourceUDPFlat{}
  3221. err := d.DecodeElement(&src, &start)
  3222. if src.Mode == "connect" {
  3223. a.UDP.ConnectHost = src.Host
  3224. a.UDP.ConnectService = src.Service
  3225. } else {
  3226. a.UDP.BindHost = src.Host
  3227. a.UDP.BindService = src.Service
  3228. }
  3229. return err
  3230. } else if a.TCP != nil {
  3231. return d.DecodeElement(a.TCP, &start)
  3232. } else if a.UNIX != nil {
  3233. return d.DecodeElement(a.UNIX, &start)
  3234. } else if a.SpiceVMC != nil {
  3235. d.Skip()
  3236. return nil
  3237. } else if a.SpicePort != nil {
  3238. return d.DecodeElement(a.SpicePort, &start)
  3239. } else if a.NMDM != nil {
  3240. return d.DecodeElement(a.NMDM, &start)
  3241. }
  3242. return nil
  3243. }
  3244. type domainConsole DomainConsole
  3245. func (a *DomainConsole) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3246. start.Name.Local = "console"
  3247. if a.Source != nil {
  3248. typ := getChardevSourceType(a.Source)
  3249. if typ != "" {
  3250. start.Attr = append(start.Attr, xml.Attr{
  3251. xml.Name{Local: "type"}, typ,
  3252. })
  3253. }
  3254. }
  3255. fs := domainConsole(*a)
  3256. return e.EncodeElement(fs, start)
  3257. }
  3258. func (a *DomainConsole) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3259. typ, ok := getAttr(start.Attr, "type")
  3260. if !ok {
  3261. typ = "pty"
  3262. }
  3263. a.Source = createChardevSource(typ)
  3264. con := domainConsole(*a)
  3265. err := d.DecodeElement(&con, &start)
  3266. if err != nil {
  3267. return err
  3268. }
  3269. *a = DomainConsole(con)
  3270. return nil
  3271. }
  3272. func (d *DomainConsole) Unmarshal(doc string) error {
  3273. return xml.Unmarshal([]byte(doc), d)
  3274. }
  3275. func (d *DomainConsole) Marshal() (string, error) {
  3276. doc, err := xml.MarshalIndent(d, "", " ")
  3277. if err != nil {
  3278. return "", err
  3279. }
  3280. return string(doc), nil
  3281. }
  3282. type domainSerial DomainSerial
  3283. func (a *DomainSerial) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3284. start.Name.Local = "serial"
  3285. if a.Source != nil {
  3286. typ := getChardevSourceType(a.Source)
  3287. if typ != "" {
  3288. start.Attr = append(start.Attr, xml.Attr{
  3289. xml.Name{Local: "type"}, typ,
  3290. })
  3291. }
  3292. }
  3293. s := domainSerial(*a)
  3294. return e.EncodeElement(s, start)
  3295. }
  3296. func (a *DomainSerial) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3297. typ, ok := getAttr(start.Attr, "type")
  3298. if !ok {
  3299. typ = "pty"
  3300. }
  3301. a.Source = createChardevSource(typ)
  3302. con := domainSerial(*a)
  3303. err := d.DecodeElement(&con, &start)
  3304. if err != nil {
  3305. return err
  3306. }
  3307. *a = DomainSerial(con)
  3308. return nil
  3309. }
  3310. func (d *DomainSerial) Unmarshal(doc string) error {
  3311. return xml.Unmarshal([]byte(doc), d)
  3312. }
  3313. func (d *DomainSerial) Marshal() (string, error) {
  3314. doc, err := xml.MarshalIndent(d, "", " ")
  3315. if err != nil {
  3316. return "", err
  3317. }
  3318. return string(doc), nil
  3319. }
  3320. type domainParallel DomainParallel
  3321. func (a *DomainParallel) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3322. start.Name.Local = "parallel"
  3323. if a.Source != nil {
  3324. typ := getChardevSourceType(a.Source)
  3325. if typ != "" {
  3326. start.Attr = append(start.Attr, xml.Attr{
  3327. xml.Name{Local: "type"}, typ,
  3328. })
  3329. }
  3330. }
  3331. s := domainParallel(*a)
  3332. return e.EncodeElement(s, start)
  3333. }
  3334. func (a *DomainParallel) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3335. typ, ok := getAttr(start.Attr, "type")
  3336. if !ok {
  3337. typ = "pty"
  3338. }
  3339. a.Source = createChardevSource(typ)
  3340. con := domainParallel(*a)
  3341. err := d.DecodeElement(&con, &start)
  3342. if err != nil {
  3343. return err
  3344. }
  3345. *a = DomainParallel(con)
  3346. return nil
  3347. }
  3348. func (d *DomainParallel) Unmarshal(doc string) error {
  3349. return xml.Unmarshal([]byte(doc), d)
  3350. }
  3351. func (d *DomainParallel) Marshal() (string, error) {
  3352. doc, err := xml.MarshalIndent(d, "", " ")
  3353. if err != nil {
  3354. return "", err
  3355. }
  3356. return string(doc), nil
  3357. }
  3358. func (d *DomainInput) Unmarshal(doc string) error {
  3359. return xml.Unmarshal([]byte(doc), d)
  3360. }
  3361. func (d *DomainInput) Marshal() (string, error) {
  3362. doc, err := xml.MarshalIndent(d, "", " ")
  3363. if err != nil {
  3364. return "", err
  3365. }
  3366. return string(doc), nil
  3367. }
  3368. func (d *DomainVideo) Unmarshal(doc string) error {
  3369. return xml.Unmarshal([]byte(doc), d)
  3370. }
  3371. func (d *DomainVideo) Marshal() (string, error) {
  3372. doc, err := xml.MarshalIndent(d, "", " ")
  3373. if err != nil {
  3374. return "", err
  3375. }
  3376. return string(doc), nil
  3377. }
  3378. type domainChannelTarget DomainChannelTarget
  3379. func (a *DomainChannelTarget) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3380. if a.VirtIO != nil {
  3381. start.Attr = append(start.Attr, xml.Attr{
  3382. xml.Name{Local: "type"}, "virtio",
  3383. })
  3384. return e.EncodeElement(a.VirtIO, start)
  3385. } else if a.Xen != nil {
  3386. start.Attr = append(start.Attr, xml.Attr{
  3387. xml.Name{Local: "type"}, "xen",
  3388. })
  3389. return e.EncodeElement(a.Xen, start)
  3390. } else if a.GuestFWD != nil {
  3391. start.Attr = append(start.Attr, xml.Attr{
  3392. xml.Name{Local: "type"}, "guestfwd",
  3393. })
  3394. return e.EncodeElement(a.GuestFWD, start)
  3395. }
  3396. return nil
  3397. }
  3398. func (a *DomainChannelTarget) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3399. typ, ok := getAttr(start.Attr, "type")
  3400. if !ok {
  3401. return fmt.Errorf("Missing channel target type")
  3402. }
  3403. if typ == "virtio" {
  3404. a.VirtIO = &DomainChannelTargetVirtIO{}
  3405. return d.DecodeElement(a.VirtIO, &start)
  3406. } else if typ == "xen" {
  3407. a.Xen = &DomainChannelTargetXen{}
  3408. return d.DecodeElement(a.Xen, &start)
  3409. } else if typ == "guestfwd" {
  3410. a.GuestFWD = &DomainChannelTargetGuestFWD{}
  3411. return d.DecodeElement(a.GuestFWD, &start)
  3412. }
  3413. d.Skip()
  3414. return nil
  3415. }
  3416. type domainChannel DomainChannel
  3417. func (a *DomainChannel) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3418. start.Name.Local = "channel"
  3419. if a.Source != nil {
  3420. typ := getChardevSourceType(a.Source)
  3421. if typ != "" {
  3422. start.Attr = append(start.Attr, xml.Attr{
  3423. xml.Name{Local: "type"}, typ,
  3424. })
  3425. }
  3426. }
  3427. fs := domainChannel(*a)
  3428. return e.EncodeElement(fs, start)
  3429. }
  3430. func (a *DomainChannel) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3431. typ, ok := getAttr(start.Attr, "type")
  3432. if !ok {
  3433. typ = "pty"
  3434. }
  3435. a.Source = createChardevSource(typ)
  3436. con := domainChannel(*a)
  3437. err := d.DecodeElement(&con, &start)
  3438. if err != nil {
  3439. return err
  3440. }
  3441. *a = DomainChannel(con)
  3442. return nil
  3443. }
  3444. func (d *DomainChannel) Unmarshal(doc string) error {
  3445. return xml.Unmarshal([]byte(doc), d)
  3446. }
  3447. func (d *DomainChannel) Marshal() (string, error) {
  3448. doc, err := xml.MarshalIndent(d, "", " ")
  3449. if err != nil {
  3450. return "", err
  3451. }
  3452. return string(doc), nil
  3453. }
  3454. func (a *DomainRedirFilterUSB) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3455. marshalUintAttr(&start, "class", a.Class, "0x%02x")
  3456. marshalUintAttr(&start, "vendor", a.Vendor, "0x%04x")
  3457. marshalUintAttr(&start, "product", a.Product, "0x%04x")
  3458. if a.Version != "" {
  3459. start.Attr = append(start.Attr, xml.Attr{
  3460. xml.Name{Local: "version"}, a.Version,
  3461. })
  3462. }
  3463. start.Attr = append(start.Attr, xml.Attr{
  3464. xml.Name{Local: "allow"}, a.Allow,
  3465. })
  3466. e.EncodeToken(start)
  3467. e.EncodeToken(start.End())
  3468. return nil
  3469. }
  3470. func (a *DomainRedirFilterUSB) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3471. for _, attr := range start.Attr {
  3472. if attr.Name.Local == "class" && attr.Value != "-1" {
  3473. if err := unmarshalUintAttr(attr.Value, &a.Class, 0); err != nil {
  3474. return err
  3475. }
  3476. } else if attr.Name.Local == "product" && attr.Value != "-1" {
  3477. if err := unmarshalUintAttr(attr.Value, &a.Product, 0); err != nil {
  3478. return err
  3479. }
  3480. } else if attr.Name.Local == "vendor" && attr.Value != "-1" {
  3481. if err := unmarshalUintAttr(attr.Value, &a.Vendor, 0); err != nil {
  3482. return err
  3483. }
  3484. } else if attr.Name.Local == "version" && attr.Value != "-1" {
  3485. a.Version = attr.Value
  3486. } else if attr.Name.Local == "allow" {
  3487. a.Allow = attr.Value
  3488. }
  3489. }
  3490. d.Skip()
  3491. return nil
  3492. }
  3493. type domainRedirDev DomainRedirDev
  3494. func (a *DomainRedirDev) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3495. start.Name.Local = "redirdev"
  3496. if a.Source != nil {
  3497. typ := getChardevSourceType(a.Source)
  3498. if typ != "" {
  3499. start.Attr = append(start.Attr, xml.Attr{
  3500. xml.Name{Local: "type"}, typ,
  3501. })
  3502. }
  3503. }
  3504. fs := domainRedirDev(*a)
  3505. return e.EncodeElement(fs, start)
  3506. }
  3507. func (a *DomainRedirDev) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3508. typ, ok := getAttr(start.Attr, "type")
  3509. if !ok {
  3510. typ = "pty"
  3511. }
  3512. a.Source = createChardevSource(typ)
  3513. con := domainRedirDev(*a)
  3514. err := d.DecodeElement(&con, &start)
  3515. if err != nil {
  3516. return err
  3517. }
  3518. *a = DomainRedirDev(con)
  3519. return nil
  3520. }
  3521. func (d *DomainRedirDev) Unmarshal(doc string) error {
  3522. return xml.Unmarshal([]byte(doc), d)
  3523. }
  3524. func (d *DomainRedirDev) Marshal() (string, error) {
  3525. doc, err := xml.MarshalIndent(d, "", " ")
  3526. if err != nil {
  3527. return "", err
  3528. }
  3529. return string(doc), nil
  3530. }
  3531. func (d *DomainMemBalloon) Unmarshal(doc string) error {
  3532. return xml.Unmarshal([]byte(doc), d)
  3533. }
  3534. func (d *DomainMemBalloon) Marshal() (string, error) {
  3535. doc, err := xml.MarshalIndent(d, "", " ")
  3536. if err != nil {
  3537. return "", err
  3538. }
  3539. return string(doc), nil
  3540. }
  3541. func (d *DomainVSock) Unmarshal(doc string) error {
  3542. return xml.Unmarshal([]byte(doc), d)
  3543. }
  3544. func (d *DomainVSock) Marshal() (string, error) {
  3545. doc, err := xml.MarshalIndent(d, "", " ")
  3546. if err != nil {
  3547. return "", err
  3548. }
  3549. return string(doc), nil
  3550. }
  3551. func (d *DomainSound) Unmarshal(doc string) error {
  3552. return xml.Unmarshal([]byte(doc), d)
  3553. }
  3554. func (d *DomainSound) Marshal() (string, error) {
  3555. doc, err := xml.MarshalIndent(d, "", " ")
  3556. if err != nil {
  3557. return "", err
  3558. }
  3559. return string(doc), nil
  3560. }
  3561. type domainRNGBackendEGD DomainRNGBackendEGD
  3562. func (a *DomainRNGBackendEGD) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3563. start.Name.Local = "backend"
  3564. if a.Source != nil {
  3565. typ := getChardevSourceType(a.Source)
  3566. if typ != "" {
  3567. start.Attr = append(start.Attr, xml.Attr{
  3568. xml.Name{Local: "type"}, typ,
  3569. })
  3570. }
  3571. }
  3572. egd := domainRNGBackendEGD(*a)
  3573. return e.EncodeElement(egd, start)
  3574. }
  3575. func (a *DomainRNGBackendEGD) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3576. typ, ok := getAttr(start.Attr, "type")
  3577. if !ok {
  3578. typ = "pty"
  3579. }
  3580. a.Source = createChardevSource(typ)
  3581. con := domainRNGBackendEGD(*a)
  3582. err := d.DecodeElement(&con, &start)
  3583. if err != nil {
  3584. return err
  3585. }
  3586. *a = DomainRNGBackendEGD(con)
  3587. return nil
  3588. }
  3589. func (a *DomainRNGBackend) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3590. if a.Random != nil {
  3591. start.Attr = append(start.Attr, xml.Attr{
  3592. xml.Name{Local: "model"}, "random",
  3593. })
  3594. return e.EncodeElement(a.Random, start)
  3595. } else if a.EGD != nil {
  3596. start.Attr = append(start.Attr, xml.Attr{
  3597. xml.Name{Local: "model"}, "egd",
  3598. })
  3599. return e.EncodeElement(a.EGD, start)
  3600. }
  3601. return nil
  3602. }
  3603. func (a *DomainRNGBackend) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3604. model, ok := getAttr(start.Attr, "model")
  3605. if !ok {
  3606. return nil
  3607. }
  3608. if model == "random" {
  3609. a.Random = &DomainRNGBackendRandom{}
  3610. err := d.DecodeElement(a.Random, &start)
  3611. if err != nil {
  3612. return err
  3613. }
  3614. } else if model == "egd" {
  3615. a.EGD = &DomainRNGBackendEGD{}
  3616. err := d.DecodeElement(a.EGD, &start)
  3617. if err != nil {
  3618. return err
  3619. }
  3620. }
  3621. d.Skip()
  3622. return nil
  3623. }
  3624. func (d *DomainRNG) Unmarshal(doc string) error {
  3625. return xml.Unmarshal([]byte(doc), d)
  3626. }
  3627. func (d *DomainRNG) Marshal() (string, error) {
  3628. doc, err := xml.MarshalIndent(d, "", " ")
  3629. if err != nil {
  3630. return "", err
  3631. }
  3632. return string(doc), nil
  3633. }
  3634. func (a *DomainHostdevSubsysSCSISource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3635. if a.Host != nil {
  3636. return e.EncodeElement(a.Host, start)
  3637. } else if a.ISCSI != nil {
  3638. start.Attr = append(start.Attr, xml.Attr{
  3639. xml.Name{Local: "protocol"}, "iscsi",
  3640. })
  3641. return e.EncodeElement(a.ISCSI, start)
  3642. }
  3643. return nil
  3644. }
  3645. func (a *DomainHostdevSubsysSCSISource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3646. proto, ok := getAttr(start.Attr, "protocol")
  3647. if !ok {
  3648. a.Host = &DomainHostdevSubsysSCSISourceHost{}
  3649. err := d.DecodeElement(a.Host, &start)
  3650. if err != nil {
  3651. return err
  3652. }
  3653. }
  3654. if proto == "iscsi" {
  3655. a.ISCSI = &DomainHostdevSubsysSCSISourceISCSI{}
  3656. err := d.DecodeElement(a.ISCSI, &start)
  3657. if err != nil {
  3658. return err
  3659. }
  3660. }
  3661. d.Skip()
  3662. return nil
  3663. }
  3664. type domainHostdev DomainHostdev
  3665. type domainHostdevSubsysSCSI struct {
  3666. DomainHostdevSubsysSCSI
  3667. domainHostdev
  3668. }
  3669. type domainHostdevSubsysSCSIHost struct {
  3670. DomainHostdevSubsysSCSIHost
  3671. domainHostdev
  3672. }
  3673. type domainHostdevSubsysUSB struct {
  3674. DomainHostdevSubsysUSB
  3675. domainHostdev
  3676. }
  3677. type domainHostdevSubsysPCI struct {
  3678. DomainHostdevSubsysPCI
  3679. domainHostdev
  3680. }
  3681. type domainHostdevSubsysMDev struct {
  3682. DomainHostdevSubsysMDev
  3683. domainHostdev
  3684. }
  3685. type domainHostdevCapsStorage struct {
  3686. DomainHostdevCapsStorage
  3687. domainHostdev
  3688. }
  3689. type domainHostdevCapsMisc struct {
  3690. DomainHostdevCapsMisc
  3691. domainHostdev
  3692. }
  3693. type domainHostdevCapsNet struct {
  3694. DomainHostdevCapsNet
  3695. domainHostdev
  3696. }
  3697. func (a *DomainHostdev) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3698. start.Name.Local = "hostdev"
  3699. if a.SubsysSCSI != nil {
  3700. start.Attr = append(start.Attr, xml.Attr{
  3701. xml.Name{Local: "mode"}, "subsystem",
  3702. })
  3703. start.Attr = append(start.Attr, xml.Attr{
  3704. xml.Name{Local: "type"}, "scsi",
  3705. })
  3706. scsi := domainHostdevSubsysSCSI{}
  3707. scsi.domainHostdev = domainHostdev(*a)
  3708. scsi.DomainHostdevSubsysSCSI = *a.SubsysSCSI
  3709. return e.EncodeElement(scsi, start)
  3710. } else if a.SubsysSCSIHost != nil {
  3711. start.Attr = append(start.Attr, xml.Attr{
  3712. xml.Name{Local: "mode"}, "subsystem",
  3713. })
  3714. start.Attr = append(start.Attr, xml.Attr{
  3715. xml.Name{Local: "type"}, "scsi_host",
  3716. })
  3717. scsi_host := domainHostdevSubsysSCSIHost{}
  3718. scsi_host.domainHostdev = domainHostdev(*a)
  3719. scsi_host.DomainHostdevSubsysSCSIHost = *a.SubsysSCSIHost
  3720. return e.EncodeElement(scsi_host, start)
  3721. } else if a.SubsysUSB != nil {
  3722. start.Attr = append(start.Attr, xml.Attr{
  3723. xml.Name{Local: "mode"}, "subsystem",
  3724. })
  3725. start.Attr = append(start.Attr, xml.Attr{
  3726. xml.Name{Local: "type"}, "usb",
  3727. })
  3728. usb := domainHostdevSubsysUSB{}
  3729. usb.domainHostdev = domainHostdev(*a)
  3730. usb.DomainHostdevSubsysUSB = *a.SubsysUSB
  3731. return e.EncodeElement(usb, start)
  3732. } else if a.SubsysPCI != nil {
  3733. start.Attr = append(start.Attr, xml.Attr{
  3734. xml.Name{Local: "mode"}, "subsystem",
  3735. })
  3736. start.Attr = append(start.Attr, xml.Attr{
  3737. xml.Name{Local: "type"}, "pci",
  3738. })
  3739. pci := domainHostdevSubsysPCI{}
  3740. pci.domainHostdev = domainHostdev(*a)
  3741. pci.DomainHostdevSubsysPCI = *a.SubsysPCI
  3742. return e.EncodeElement(pci, start)
  3743. } else if a.SubsysMDev != nil {
  3744. start.Attr = append(start.Attr, xml.Attr{
  3745. xml.Name{Local: "mode"}, "subsystem",
  3746. })
  3747. start.Attr = append(start.Attr, xml.Attr{
  3748. xml.Name{Local: "type"}, "mdev",
  3749. })
  3750. mdev := domainHostdevSubsysMDev{}
  3751. mdev.domainHostdev = domainHostdev(*a)
  3752. mdev.DomainHostdevSubsysMDev = *a.SubsysMDev
  3753. return e.EncodeElement(mdev, start)
  3754. } else if a.CapsStorage != nil {
  3755. start.Attr = append(start.Attr, xml.Attr{
  3756. xml.Name{Local: "mode"}, "capabilities",
  3757. })
  3758. start.Attr = append(start.Attr, xml.Attr{
  3759. xml.Name{Local: "type"}, "storage",
  3760. })
  3761. storage := domainHostdevCapsStorage{}
  3762. storage.domainHostdev = domainHostdev(*a)
  3763. storage.DomainHostdevCapsStorage = *a.CapsStorage
  3764. return e.EncodeElement(storage, start)
  3765. } else if a.CapsMisc != nil {
  3766. start.Attr = append(start.Attr, xml.Attr{
  3767. xml.Name{Local: "mode"}, "capabilities",
  3768. })
  3769. start.Attr = append(start.Attr, xml.Attr{
  3770. xml.Name{Local: "type"}, "misc",
  3771. })
  3772. misc := domainHostdevCapsMisc{}
  3773. misc.domainHostdev = domainHostdev(*a)
  3774. misc.DomainHostdevCapsMisc = *a.CapsMisc
  3775. return e.EncodeElement(misc, start)
  3776. } else if a.CapsNet != nil {
  3777. start.Attr = append(start.Attr, xml.Attr{
  3778. xml.Name{Local: "mode"}, "capabilities",
  3779. })
  3780. start.Attr = append(start.Attr, xml.Attr{
  3781. xml.Name{Local: "type"}, "net",
  3782. })
  3783. net := domainHostdevCapsNet{}
  3784. net.domainHostdev = domainHostdev(*a)
  3785. net.DomainHostdevCapsNet = *a.CapsNet
  3786. return e.EncodeElement(net, start)
  3787. } else {
  3788. gen := domainHostdev(*a)
  3789. return e.EncodeElement(gen, start)
  3790. }
  3791. }
  3792. func (a *DomainHostdev) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3793. mode, ok := getAttr(start.Attr, "mode")
  3794. if !ok {
  3795. return fmt.Errorf("Missing 'mode' attribute on domain hostdev")
  3796. }
  3797. typ, ok := getAttr(start.Attr, "type")
  3798. if !ok {
  3799. return fmt.Errorf("Missing 'type' attribute on domain controller")
  3800. }
  3801. if mode == "subsystem" {
  3802. if typ == "scsi" {
  3803. var scsi domainHostdevSubsysSCSI
  3804. err := d.DecodeElement(&scsi, &start)
  3805. if err != nil {
  3806. return err
  3807. }
  3808. *a = DomainHostdev(scsi.domainHostdev)
  3809. a.SubsysSCSI = &scsi.DomainHostdevSubsysSCSI
  3810. return nil
  3811. } else if typ == "scsi_host" {
  3812. var scsi_host domainHostdevSubsysSCSIHost
  3813. err := d.DecodeElement(&scsi_host, &start)
  3814. if err != nil {
  3815. return err
  3816. }
  3817. *a = DomainHostdev(scsi_host.domainHostdev)
  3818. a.SubsysSCSIHost = &scsi_host.DomainHostdevSubsysSCSIHost
  3819. return nil
  3820. } else if typ == "usb" {
  3821. var usb domainHostdevSubsysUSB
  3822. err := d.DecodeElement(&usb, &start)
  3823. if err != nil {
  3824. return err
  3825. }
  3826. *a = DomainHostdev(usb.domainHostdev)
  3827. a.SubsysUSB = &usb.DomainHostdevSubsysUSB
  3828. return nil
  3829. } else if typ == "pci" {
  3830. var pci domainHostdevSubsysPCI
  3831. err := d.DecodeElement(&pci, &start)
  3832. if err != nil {
  3833. return err
  3834. }
  3835. *a = DomainHostdev(pci.domainHostdev)
  3836. a.SubsysPCI = &pci.DomainHostdevSubsysPCI
  3837. return nil
  3838. } else if typ == "mdev" {
  3839. var mdev domainHostdevSubsysMDev
  3840. err := d.DecodeElement(&mdev, &start)
  3841. if err != nil {
  3842. return err
  3843. }
  3844. *a = DomainHostdev(mdev.domainHostdev)
  3845. a.SubsysMDev = &mdev.DomainHostdevSubsysMDev
  3846. return nil
  3847. }
  3848. } else if mode == "capabilities" {
  3849. if typ == "storage" {
  3850. var storage domainHostdevCapsStorage
  3851. err := d.DecodeElement(&storage, &start)
  3852. if err != nil {
  3853. return err
  3854. }
  3855. *a = DomainHostdev(storage.domainHostdev)
  3856. a.CapsStorage = &storage.DomainHostdevCapsStorage
  3857. return nil
  3858. } else if typ == "misc" {
  3859. var misc domainHostdevCapsMisc
  3860. err := d.DecodeElement(&misc, &start)
  3861. if err != nil {
  3862. return err
  3863. }
  3864. *a = DomainHostdev(misc.domainHostdev)
  3865. a.CapsMisc = &misc.DomainHostdevCapsMisc
  3866. return nil
  3867. } else if typ == "net" {
  3868. var net domainHostdevCapsNet
  3869. err := d.DecodeElement(&net, &start)
  3870. if err != nil {
  3871. return err
  3872. }
  3873. *a = DomainHostdev(net.domainHostdev)
  3874. a.CapsNet = &net.DomainHostdevCapsNet
  3875. return nil
  3876. }
  3877. }
  3878. var gen domainHostdev
  3879. err := d.DecodeElement(&gen, &start)
  3880. if err != nil {
  3881. return err
  3882. }
  3883. *a = DomainHostdev(gen)
  3884. return nil
  3885. }
  3886. func (d *DomainHostdev) Unmarshal(doc string) error {
  3887. return xml.Unmarshal([]byte(doc), d)
  3888. }
  3889. func (d *DomainHostdev) Marshal() (string, error) {
  3890. doc, err := xml.MarshalIndent(d, "", " ")
  3891. if err != nil {
  3892. return "", err
  3893. }
  3894. return string(doc), nil
  3895. }
  3896. func (a *DomainGraphicListener) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3897. start.Name.Local = "listen"
  3898. if a.Address != nil {
  3899. start.Attr = append(start.Attr, xml.Attr{
  3900. xml.Name{Local: "type"}, "address",
  3901. })
  3902. return e.EncodeElement(a.Address, start)
  3903. } else if a.Network != nil {
  3904. start.Attr = append(start.Attr, xml.Attr{
  3905. xml.Name{Local: "type"}, "network",
  3906. })
  3907. return e.EncodeElement(a.Network, start)
  3908. } else if a.Socket != nil {
  3909. start.Attr = append(start.Attr, xml.Attr{
  3910. xml.Name{Local: "type"}, "socket",
  3911. })
  3912. return e.EncodeElement(a.Socket, start)
  3913. } else {
  3914. start.Attr = append(start.Attr, xml.Attr{
  3915. xml.Name{Local: "type"}, "none",
  3916. })
  3917. e.EncodeToken(start)
  3918. e.EncodeToken(start.End())
  3919. }
  3920. return nil
  3921. }
  3922. func (a *DomainGraphicListener) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3923. typ, ok := getAttr(start.Attr, "type")
  3924. if !ok {
  3925. return fmt.Errorf("Missing 'type' attribute on domain graphics listen")
  3926. }
  3927. if typ == "address" {
  3928. var addr DomainGraphicListenerAddress
  3929. err := d.DecodeElement(&addr, &start)
  3930. if err != nil {
  3931. return err
  3932. }
  3933. a.Address = &addr
  3934. return nil
  3935. } else if typ == "network" {
  3936. var net DomainGraphicListenerNetwork
  3937. err := d.DecodeElement(&net, &start)
  3938. if err != nil {
  3939. return err
  3940. }
  3941. a.Network = &net
  3942. return nil
  3943. } else if typ == "socket" {
  3944. var sock DomainGraphicListenerSocket
  3945. err := d.DecodeElement(&sock, &start)
  3946. if err != nil {
  3947. return err
  3948. }
  3949. a.Socket = &sock
  3950. return nil
  3951. } else if typ == "none" {
  3952. d.Skip()
  3953. }
  3954. return nil
  3955. }
  3956. func (a *DomainGraphic) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3957. start.Name.Local = "graphics"
  3958. if a.SDL != nil {
  3959. start.Attr = append(start.Attr, xml.Attr{
  3960. xml.Name{Local: "type"}, "sdl",
  3961. })
  3962. return e.EncodeElement(a.SDL, start)
  3963. } else if a.VNC != nil {
  3964. start.Attr = append(start.Attr, xml.Attr{
  3965. xml.Name{Local: "type"}, "vnc",
  3966. })
  3967. return e.EncodeElement(a.VNC, start)
  3968. } else if a.RDP != nil {
  3969. start.Attr = append(start.Attr, xml.Attr{
  3970. xml.Name{Local: "type"}, "rdp",
  3971. })
  3972. return e.EncodeElement(a.RDP, start)
  3973. } else if a.Desktop != nil {
  3974. start.Attr = append(start.Attr, xml.Attr{
  3975. xml.Name{Local: "type"}, "desktop",
  3976. })
  3977. return e.EncodeElement(a.Desktop, start)
  3978. } else if a.Spice != nil {
  3979. start.Attr = append(start.Attr, xml.Attr{
  3980. xml.Name{Local: "type"}, "spice",
  3981. })
  3982. return e.EncodeElement(a.Spice, start)
  3983. } else if a.EGLHeadless != nil {
  3984. start.Attr = append(start.Attr, xml.Attr{
  3985. xml.Name{Local: "type"}, "egl-headless",
  3986. })
  3987. return e.EncodeElement(a.EGLHeadless, start)
  3988. }
  3989. return nil
  3990. }
  3991. func (a *DomainGraphic) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3992. typ, ok := getAttr(start.Attr, "type")
  3993. if !ok {
  3994. return fmt.Errorf("Missing 'type' attribute on domain graphics")
  3995. }
  3996. if typ == "sdl" {
  3997. var sdl DomainGraphicSDL
  3998. err := d.DecodeElement(&sdl, &start)
  3999. if err != nil {
  4000. return err
  4001. }
  4002. a.SDL = &sdl
  4003. return nil
  4004. } else if typ == "vnc" {
  4005. var vnc DomainGraphicVNC
  4006. err := d.DecodeElement(&vnc, &start)
  4007. if err != nil {
  4008. return err
  4009. }
  4010. a.VNC = &vnc
  4011. return nil
  4012. } else if typ == "rdp" {
  4013. var rdp DomainGraphicRDP
  4014. err := d.DecodeElement(&rdp, &start)
  4015. if err != nil {
  4016. return err
  4017. }
  4018. a.RDP = &rdp
  4019. return nil
  4020. } else if typ == "desktop" {
  4021. var desktop DomainGraphicDesktop
  4022. err := d.DecodeElement(&desktop, &start)
  4023. if err != nil {
  4024. return err
  4025. }
  4026. a.Desktop = &desktop
  4027. return nil
  4028. } else if typ == "spice" {
  4029. var spice DomainGraphicSpice
  4030. err := d.DecodeElement(&spice, &start)
  4031. if err != nil {
  4032. return err
  4033. }
  4034. a.Spice = &spice
  4035. return nil
  4036. } else if typ == "egl-headless" {
  4037. var egl DomainGraphicEGLHeadless
  4038. err := d.DecodeElement(&egl, &start)
  4039. if err != nil {
  4040. return err
  4041. }
  4042. a.EGLHeadless = &egl
  4043. return nil
  4044. }
  4045. return nil
  4046. }
  4047. func (d *DomainMemorydev) Unmarshal(doc string) error {
  4048. return xml.Unmarshal([]byte(doc), d)
  4049. }
  4050. func (d *DomainMemorydev) Marshal() (string, error) {
  4051. doc, err := xml.MarshalIndent(d, "", " ")
  4052. if err != nil {
  4053. return "", err
  4054. }
  4055. return string(doc), nil
  4056. }
  4057. func (d *DomainWatchdog) Unmarshal(doc string) error {
  4058. return xml.Unmarshal([]byte(doc), d)
  4059. }
  4060. func (d *DomainWatchdog) Marshal() (string, error) {
  4061. doc, err := xml.MarshalIndent(d, "", " ")
  4062. if err != nil {
  4063. return "", err
  4064. }
  4065. return string(doc), nil
  4066. }
  4067. func marshalUintAttr(start *xml.StartElement, name string, val *uint, format string) {
  4068. if val != nil {
  4069. start.Attr = append(start.Attr, xml.Attr{
  4070. xml.Name{Local: name}, fmt.Sprintf(format, *val),
  4071. })
  4072. }
  4073. }
  4074. func marshalUint64Attr(start *xml.StartElement, name string, val *uint64, format string) {
  4075. if val != nil {
  4076. start.Attr = append(start.Attr, xml.Attr{
  4077. xml.Name{Local: name}, fmt.Sprintf(format, *val),
  4078. })
  4079. }
  4080. }
  4081. func (a *DomainAddressPCI) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4082. marshalUintAttr(&start, "domain", a.Domain, "0x%04x")
  4083. marshalUintAttr(&start, "bus", a.Bus, "0x%02x")
  4084. marshalUintAttr(&start, "slot", a.Slot, "0x%02x")
  4085. marshalUintAttr(&start, "function", a.Function, "0x%x")
  4086. if a.MultiFunction != "" {
  4087. start.Attr = append(start.Attr, xml.Attr{
  4088. xml.Name{Local: "multifunction"}, a.MultiFunction,
  4089. })
  4090. }
  4091. e.EncodeToken(start)
  4092. if a.ZPCI != nil {
  4093. zpci := xml.StartElement{}
  4094. zpci.Name.Local = "zpci"
  4095. err := e.EncodeElement(a.ZPCI, zpci)
  4096. if err != nil {
  4097. return err
  4098. }
  4099. }
  4100. e.EncodeToken(start.End())
  4101. return nil
  4102. }
  4103. func (a *DomainAddressZPCI) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4104. marshalUintAttr(&start, "uid", a.UID, "0x%04x")
  4105. marshalUintAttr(&start, "fid", a.FID, "0x%04x")
  4106. e.EncodeToken(start)
  4107. e.EncodeToken(start.End())
  4108. return nil
  4109. }
  4110. func (a *DomainAddressUSB) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4111. marshalUintAttr(&start, "bus", a.Bus, "%d")
  4112. if a.Port != "" {
  4113. start.Attr = append(start.Attr, xml.Attr{
  4114. xml.Name{Local: "port"}, a.Port,
  4115. })
  4116. }
  4117. marshalUintAttr(&start, "device", a.Device, "%d")
  4118. e.EncodeToken(start)
  4119. e.EncodeToken(start.End())
  4120. return nil
  4121. }
  4122. func (a *DomainAddressDrive) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4123. marshalUintAttr(&start, "controller", a.Controller, "%d")
  4124. marshalUintAttr(&start, "bus", a.Bus, "%d")
  4125. marshalUintAttr(&start, "target", a.Target, "%d")
  4126. marshalUintAttr(&start, "unit", a.Unit, "%d")
  4127. e.EncodeToken(start)
  4128. e.EncodeToken(start.End())
  4129. return nil
  4130. }
  4131. func (a *DomainAddressDIMM) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4132. marshalUintAttr(&start, "slot", a.Slot, "%d")
  4133. marshalUint64Attr(&start, "base", a.Base, "0x%x")
  4134. e.EncodeToken(start)
  4135. e.EncodeToken(start.End())
  4136. return nil
  4137. }
  4138. func (a *DomainAddressISA) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4139. marshalUintAttr(&start, "iobase", a.IOBase, "0x%x")
  4140. marshalUintAttr(&start, "irq", a.IRQ, "0x%x")
  4141. e.EncodeToken(start)
  4142. e.EncodeToken(start.End())
  4143. return nil
  4144. }
  4145. func (a *DomainAddressVirtioMMIO) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4146. e.EncodeToken(start)
  4147. e.EncodeToken(start.End())
  4148. return nil
  4149. }
  4150. func (a *DomainAddressCCW) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4151. marshalUintAttr(&start, "cssid", a.CSSID, "0x%x")
  4152. marshalUintAttr(&start, "ssid", a.SSID, "0x%x")
  4153. marshalUintAttr(&start, "devno", a.DevNo, "0x%04x")
  4154. e.EncodeToken(start)
  4155. e.EncodeToken(start.End())
  4156. return nil
  4157. }
  4158. func (a *DomainAddressVirtioSerial) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4159. marshalUintAttr(&start, "controller", a.Controller, "%d")
  4160. marshalUintAttr(&start, "bus", a.Bus, "%d")
  4161. marshalUintAttr(&start, "port", a.Port, "%d")
  4162. e.EncodeToken(start)
  4163. e.EncodeToken(start.End())
  4164. return nil
  4165. }
  4166. func (a *DomainAddressSpaprVIO) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4167. marshalUint64Attr(&start, "reg", a.Reg, "0x%x")
  4168. e.EncodeToken(start)
  4169. e.EncodeToken(start.End())
  4170. return nil
  4171. }
  4172. func (a *DomainAddressCCID) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4173. marshalUintAttr(&start, "controller", a.Controller, "%d")
  4174. marshalUintAttr(&start, "slot", a.Slot, "%d")
  4175. e.EncodeToken(start)
  4176. e.EncodeToken(start.End())
  4177. return nil
  4178. }
  4179. func (a *DomainAddressVirtioS390) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4180. e.EncodeToken(start)
  4181. e.EncodeToken(start.End())
  4182. return nil
  4183. }
  4184. func (a *DomainAddress) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4185. if a.USB != nil {
  4186. start.Attr = append(start.Attr, xml.Attr{
  4187. xml.Name{Local: "type"}, "usb",
  4188. })
  4189. return e.EncodeElement(a.USB, start)
  4190. } else if a.PCI != nil {
  4191. start.Attr = append(start.Attr, xml.Attr{
  4192. xml.Name{Local: "type"}, "pci",
  4193. })
  4194. return e.EncodeElement(a.PCI, start)
  4195. } else if a.Drive != nil {
  4196. start.Attr = append(start.Attr, xml.Attr{
  4197. xml.Name{Local: "type"}, "drive",
  4198. })
  4199. return e.EncodeElement(a.Drive, start)
  4200. } else if a.DIMM != nil {
  4201. start.Attr = append(start.Attr, xml.Attr{
  4202. xml.Name{Local: "type"}, "dimm",
  4203. })
  4204. return e.EncodeElement(a.DIMM, start)
  4205. } else if a.ISA != nil {
  4206. start.Attr = append(start.Attr, xml.Attr{
  4207. xml.Name{Local: "type"}, "isa",
  4208. })
  4209. return e.EncodeElement(a.ISA, start)
  4210. } else if a.VirtioMMIO != nil {
  4211. start.Attr = append(start.Attr, xml.Attr{
  4212. xml.Name{Local: "type"}, "virtio-mmio",
  4213. })
  4214. return e.EncodeElement(a.VirtioMMIO, start)
  4215. } else if a.CCW != nil {
  4216. start.Attr = append(start.Attr, xml.Attr{
  4217. xml.Name{Local: "type"}, "ccw",
  4218. })
  4219. return e.EncodeElement(a.CCW, start)
  4220. } else if a.VirtioSerial != nil {
  4221. start.Attr = append(start.Attr, xml.Attr{
  4222. xml.Name{Local: "type"}, "virtio-serial",
  4223. })
  4224. return e.EncodeElement(a.VirtioSerial, start)
  4225. } else if a.SpaprVIO != nil {
  4226. start.Attr = append(start.Attr, xml.Attr{
  4227. xml.Name{Local: "type"}, "spapr-vio",
  4228. })
  4229. return e.EncodeElement(a.SpaprVIO, start)
  4230. } else if a.CCID != nil {
  4231. start.Attr = append(start.Attr, xml.Attr{
  4232. xml.Name{Local: "type"}, "ccid",
  4233. })
  4234. return e.EncodeElement(a.CCID, start)
  4235. } else if a.VirtioS390 != nil {
  4236. start.Attr = append(start.Attr, xml.Attr{
  4237. xml.Name{Local: "type"}, "virtio-s390",
  4238. })
  4239. return e.EncodeElement(a.VirtioS390, start)
  4240. } else {
  4241. return nil
  4242. }
  4243. }
  4244. func unmarshalUint64Attr(valstr string, valptr **uint64, base int) error {
  4245. if base == 16 {
  4246. valstr = strings.TrimPrefix(valstr, "0x")
  4247. }
  4248. val, err := strconv.ParseUint(valstr, base, 64)
  4249. if err != nil {
  4250. return err
  4251. }
  4252. *valptr = &val
  4253. return nil
  4254. }
  4255. func unmarshalUintAttr(valstr string, valptr **uint, base int) error {
  4256. if base == 16 {
  4257. valstr = strings.TrimPrefix(valstr, "0x")
  4258. }
  4259. val, err := strconv.ParseUint(valstr, base, 64)
  4260. if err != nil {
  4261. return err
  4262. }
  4263. vali := uint(val)
  4264. *valptr = &vali
  4265. return nil
  4266. }
  4267. func (a *DomainAddressUSB) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4268. for _, attr := range start.Attr {
  4269. if attr.Name.Local == "bus" {
  4270. if err := unmarshalUintAttr(attr.Value, &a.Bus, 10); err != nil {
  4271. return err
  4272. }
  4273. } else if attr.Name.Local == "port" {
  4274. a.Port = attr.Value
  4275. } else if attr.Name.Local == "device" {
  4276. if err := unmarshalUintAttr(attr.Value, &a.Device, 10); err != nil {
  4277. return err
  4278. }
  4279. }
  4280. }
  4281. d.Skip()
  4282. return nil
  4283. }
  4284. func (a *DomainAddressPCI) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4285. for _, attr := range start.Attr {
  4286. if attr.Name.Local == "domain" {
  4287. if err := unmarshalUintAttr(attr.Value, &a.Domain, 0); err != nil {
  4288. return err
  4289. }
  4290. } else if attr.Name.Local == "bus" {
  4291. if err := unmarshalUintAttr(attr.Value, &a.Bus, 0); err != nil {
  4292. return err
  4293. }
  4294. } else if attr.Name.Local == "slot" {
  4295. if err := unmarshalUintAttr(attr.Value, &a.Slot, 0); err != nil {
  4296. return err
  4297. }
  4298. } else if attr.Name.Local == "function" {
  4299. if err := unmarshalUintAttr(attr.Value, &a.Function, 0); err != nil {
  4300. return err
  4301. }
  4302. } else if attr.Name.Local == "multifunction" {
  4303. a.MultiFunction = attr.Value
  4304. }
  4305. }
  4306. for {
  4307. tok, err := d.Token()
  4308. if err == io.EOF {
  4309. break
  4310. }
  4311. if err != nil {
  4312. return err
  4313. }
  4314. switch tok := tok.(type) {
  4315. case xml.StartElement:
  4316. if tok.Name.Local == "zpci" {
  4317. a.ZPCI = &DomainAddressZPCI{}
  4318. err = d.DecodeElement(a.ZPCI, &tok)
  4319. if err != nil {
  4320. return err
  4321. }
  4322. }
  4323. }
  4324. }
  4325. return nil
  4326. }
  4327. func (a *DomainAddressZPCI) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4328. for _, attr := range start.Attr {
  4329. if attr.Name.Local == "fid" {
  4330. if err := unmarshalUintAttr(attr.Value, &a.FID, 0); err != nil {
  4331. return err
  4332. }
  4333. } else if attr.Name.Local == "uid" {
  4334. if err := unmarshalUintAttr(attr.Value, &a.UID, 0); err != nil {
  4335. return err
  4336. }
  4337. }
  4338. }
  4339. d.Skip()
  4340. return nil
  4341. }
  4342. func (a *DomainAddressDrive) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4343. for _, attr := range start.Attr {
  4344. if attr.Name.Local == "controller" {
  4345. if err := unmarshalUintAttr(attr.Value, &a.Controller, 10); err != nil {
  4346. return err
  4347. }
  4348. } else if attr.Name.Local == "bus" {
  4349. if err := unmarshalUintAttr(attr.Value, &a.Bus, 10); err != nil {
  4350. return err
  4351. }
  4352. } else if attr.Name.Local == "target" {
  4353. if err := unmarshalUintAttr(attr.Value, &a.Target, 10); err != nil {
  4354. return err
  4355. }
  4356. } else if attr.Name.Local == "unit" {
  4357. if err := unmarshalUintAttr(attr.Value, &a.Unit, 10); err != nil {
  4358. return err
  4359. }
  4360. }
  4361. }
  4362. d.Skip()
  4363. return nil
  4364. }
  4365. func (a *DomainAddressDIMM) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4366. for _, attr := range start.Attr {
  4367. if attr.Name.Local == "slot" {
  4368. if err := unmarshalUintAttr(attr.Value, &a.Slot, 10); err != nil {
  4369. return err
  4370. }
  4371. } else if attr.Name.Local == "base" {
  4372. if err := unmarshalUint64Attr(attr.Value, &a.Base, 16); err != nil {
  4373. return err
  4374. }
  4375. }
  4376. }
  4377. d.Skip()
  4378. return nil
  4379. }
  4380. func (a *DomainAddressISA) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4381. for _, attr := range start.Attr {
  4382. if attr.Name.Local == "iobase" {
  4383. if err := unmarshalUintAttr(attr.Value, &a.IOBase, 16); err != nil {
  4384. return err
  4385. }
  4386. } else if attr.Name.Local == "irq" {
  4387. if err := unmarshalUintAttr(attr.Value, &a.IRQ, 16); err != nil {
  4388. return err
  4389. }
  4390. }
  4391. }
  4392. d.Skip()
  4393. return nil
  4394. }
  4395. func (a *DomainAddressVirtioMMIO) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4396. d.Skip()
  4397. return nil
  4398. }
  4399. func (a *DomainAddressCCW) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4400. for _, attr := range start.Attr {
  4401. if attr.Name.Local == "cssid" {
  4402. if err := unmarshalUintAttr(attr.Value, &a.CSSID, 0); err != nil {
  4403. return err
  4404. }
  4405. } else if attr.Name.Local == "ssid" {
  4406. if err := unmarshalUintAttr(attr.Value, &a.SSID, 0); err != nil {
  4407. return err
  4408. }
  4409. } else if attr.Name.Local == "devno" {
  4410. if err := unmarshalUintAttr(attr.Value, &a.DevNo, 0); err != nil {
  4411. return err
  4412. }
  4413. }
  4414. }
  4415. d.Skip()
  4416. return nil
  4417. }
  4418. func (a *DomainAddressVirtioSerial) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4419. for _, attr := range start.Attr {
  4420. if attr.Name.Local == "controller" {
  4421. if err := unmarshalUintAttr(attr.Value, &a.Controller, 10); err != nil {
  4422. return err
  4423. }
  4424. } else if attr.Name.Local == "bus" {
  4425. if err := unmarshalUintAttr(attr.Value, &a.Bus, 10); err != nil {
  4426. return err
  4427. }
  4428. } else if attr.Name.Local == "port" {
  4429. if err := unmarshalUintAttr(attr.Value, &a.Port, 10); err != nil {
  4430. return err
  4431. }
  4432. }
  4433. }
  4434. d.Skip()
  4435. return nil
  4436. }
  4437. func (a *DomainAddressSpaprVIO) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4438. for _, attr := range start.Attr {
  4439. if attr.Name.Local == "reg" {
  4440. if err := unmarshalUint64Attr(attr.Value, &a.Reg, 16); err != nil {
  4441. return err
  4442. }
  4443. }
  4444. }
  4445. d.Skip()
  4446. return nil
  4447. }
  4448. func (a *DomainAddressCCID) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4449. for _, attr := range start.Attr {
  4450. if attr.Name.Local == "controller" {
  4451. if err := unmarshalUintAttr(attr.Value, &a.Controller, 10); err != nil {
  4452. return err
  4453. }
  4454. } else if attr.Name.Local == "slot" {
  4455. if err := unmarshalUintAttr(attr.Value, &a.Slot, 10); err != nil {
  4456. return err
  4457. }
  4458. }
  4459. }
  4460. d.Skip()
  4461. return nil
  4462. }
  4463. func (a *DomainAddressVirtioS390) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4464. d.Skip()
  4465. return nil
  4466. }
  4467. func (a *DomainAddress) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4468. var typ string
  4469. for _, attr := range start.Attr {
  4470. if attr.Name.Local == "type" {
  4471. typ = attr.Value
  4472. break
  4473. }
  4474. }
  4475. if typ == "" {
  4476. d.Skip()
  4477. return nil
  4478. }
  4479. if typ == "usb" {
  4480. a.USB = &DomainAddressUSB{}
  4481. return d.DecodeElement(a.USB, &start)
  4482. } else if typ == "pci" {
  4483. a.PCI = &DomainAddressPCI{}
  4484. return d.DecodeElement(a.PCI, &start)
  4485. } else if typ == "drive" {
  4486. a.Drive = &DomainAddressDrive{}
  4487. return d.DecodeElement(a.Drive, &start)
  4488. } else if typ == "dimm" {
  4489. a.DIMM = &DomainAddressDIMM{}
  4490. return d.DecodeElement(a.DIMM, &start)
  4491. } else if typ == "isa" {
  4492. a.ISA = &DomainAddressISA{}
  4493. return d.DecodeElement(a.ISA, &start)
  4494. } else if typ == "virtio-mmio" {
  4495. a.VirtioMMIO = &DomainAddressVirtioMMIO{}
  4496. return d.DecodeElement(a.VirtioMMIO, &start)
  4497. } else if typ == "ccw" {
  4498. a.CCW = &DomainAddressCCW{}
  4499. return d.DecodeElement(a.CCW, &start)
  4500. } else if typ == "virtio-serial" {
  4501. a.VirtioSerial = &DomainAddressVirtioSerial{}
  4502. return d.DecodeElement(a.VirtioSerial, &start)
  4503. } else if typ == "spapr-vio" {
  4504. a.SpaprVIO = &DomainAddressSpaprVIO{}
  4505. return d.DecodeElement(a.SpaprVIO, &start)
  4506. } else if typ == "ccid" {
  4507. a.CCID = &DomainAddressCCID{}
  4508. return d.DecodeElement(a.CCID, &start)
  4509. } else if typ == "spapr-vio" {
  4510. a.VirtioS390 = &DomainAddressVirtioS390{}
  4511. return d.DecodeElement(a.VirtioS390, &start)
  4512. }
  4513. return nil
  4514. }
  4515. func (d *DomainCPU) Unmarshal(doc string) error {
  4516. return xml.Unmarshal([]byte(doc), d)
  4517. }
  4518. func (d *DomainCPU) Marshal() (string, error) {
  4519. doc, err := xml.MarshalIndent(d, "", " ")
  4520. if err != nil {
  4521. return "", err
  4522. }
  4523. return string(doc), nil
  4524. }
  4525. func (a *DomainLaunchSecuritySEV) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4526. e.EncodeToken(start)
  4527. cbitpos := xml.StartElement{
  4528. Name: xml.Name{Local: "cbitpos"},
  4529. }
  4530. e.EncodeToken(cbitpos)
  4531. e.EncodeToken(xml.CharData(fmt.Sprintf("%d", *a.CBitPos)))
  4532. e.EncodeToken(cbitpos.End())
  4533. reducedPhysBits := xml.StartElement{
  4534. Name: xml.Name{Local: "reducedPhysBits"},
  4535. }
  4536. e.EncodeToken(reducedPhysBits)
  4537. e.EncodeToken(xml.CharData(fmt.Sprintf("%d", *a.ReducedPhysBits)))
  4538. e.EncodeToken(reducedPhysBits.End())
  4539. if a.Policy != nil {
  4540. policy := xml.StartElement{
  4541. Name: xml.Name{Local: "policy"},
  4542. }
  4543. e.EncodeToken(policy)
  4544. e.EncodeToken(xml.CharData(fmt.Sprintf("0x%04x", *a.Policy)))
  4545. e.EncodeToken(policy.End())
  4546. }
  4547. dhcert := xml.StartElement{
  4548. Name: xml.Name{Local: "dhCert"},
  4549. }
  4550. e.EncodeToken(dhcert)
  4551. e.EncodeToken(xml.CharData(fmt.Sprintf("%s", a.DHCert)))
  4552. e.EncodeToken(dhcert.End())
  4553. session := xml.StartElement{
  4554. Name: xml.Name{Local: "session"},
  4555. }
  4556. e.EncodeToken(session)
  4557. e.EncodeToken(xml.CharData(fmt.Sprintf("%s", a.Session)))
  4558. e.EncodeToken(session.End())
  4559. e.EncodeToken(start.End())
  4560. return nil
  4561. }
  4562. func (a *DomainLaunchSecuritySEV) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4563. for {
  4564. tok, err := d.Token()
  4565. if err == io.EOF {
  4566. break
  4567. }
  4568. if err != nil {
  4569. return err
  4570. }
  4571. switch tok := tok.(type) {
  4572. case xml.StartElement:
  4573. if tok.Name.Local == "policy" {
  4574. data, err := d.Token()
  4575. if err != nil {
  4576. return err
  4577. }
  4578. switch data := data.(type) {
  4579. case xml.CharData:
  4580. if err := unmarshalUintAttr(string(data), &a.Policy, 16); err != nil {
  4581. return err
  4582. }
  4583. }
  4584. } else if tok.Name.Local == "cbitpos" {
  4585. data, err := d.Token()
  4586. if err != nil {
  4587. return err
  4588. }
  4589. switch data := data.(type) {
  4590. case xml.CharData:
  4591. if err := unmarshalUintAttr(string(data), &a.CBitPos, 10); err != nil {
  4592. return err
  4593. }
  4594. }
  4595. } else if tok.Name.Local == "reducedPhysBits" {
  4596. data, err := d.Token()
  4597. if err != nil {
  4598. return err
  4599. }
  4600. switch data := data.(type) {
  4601. case xml.CharData:
  4602. if err := unmarshalUintAttr(string(data), &a.ReducedPhysBits, 10); err != nil {
  4603. return err
  4604. }
  4605. }
  4606. } else if tok.Name.Local == "dhCert" {
  4607. data, err := d.Token()
  4608. if err != nil {
  4609. return err
  4610. }
  4611. switch data := data.(type) {
  4612. case xml.CharData:
  4613. a.DHCert = string(data)
  4614. }
  4615. } else if tok.Name.Local == "session" {
  4616. data, err := d.Token()
  4617. if err != nil {
  4618. return err
  4619. }
  4620. switch data := data.(type) {
  4621. case xml.CharData:
  4622. a.Session = string(data)
  4623. }
  4624. }
  4625. }
  4626. }
  4627. return nil
  4628. }
  4629. func (a *DomainLaunchSecurity) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4630. if a.SEV != nil {
  4631. start.Attr = append(start.Attr, xml.Attr{
  4632. xml.Name{Local: "type"}, "sev",
  4633. })
  4634. return e.EncodeElement(a.SEV, start)
  4635. } else {
  4636. return nil
  4637. }
  4638. }
  4639. func (a *DomainLaunchSecurity) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4640. var typ string
  4641. for _, attr := range start.Attr {
  4642. if attr.Name.Local == "type" {
  4643. typ = attr.Value
  4644. }
  4645. }
  4646. if typ == "" {
  4647. d.Skip()
  4648. return nil
  4649. }
  4650. if typ == "sev" {
  4651. a.SEV = &DomainLaunchSecuritySEV{}
  4652. return d.DecodeElement(a.SEV, &start)
  4653. }
  4654. return nil
  4655. }