@@ -259,4 +259,126 @@ public void testDomainXMLParser() {
259259 assertEquals (WatchDogDef .WatchDogModel .I6300ESB , watchDogs .get (0 ).getModel ());
260260 assertEquals (WatchDogDef .WatchDogAction .RESET , watchDogs .get (0 ).getAction ());
261261 }
262+
263+ @ Test
264+ public void testDomainXMLParserWithoutModelName () {
265+ String xml = "<domain type='kvm'>\n " +
266+ " <name>testkiran</name>\n " +
267+ " <uuid>aafaaabc-8657-4efc-9c52-3422d4e04088</uuid>\n " +
268+ " <memory unit='KiB'>2097152</memory>\n " +
269+ " <currentMemory unit='KiB'>2097152</currentMemory>\n " +
270+ " <vcpu placement='static'>2</vcpu>\n " +
271+ " <os>\n " +
272+ " <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>\n " +
273+ " <boot dev='hd'/>\n " +
274+ " </os>\n " +
275+ " <features>\n " +
276+ " <acpi/>\n " +
277+ " <apic/>\n " +
278+ " </features>\n " +
279+ " <cpu mode='host-model' check='partial'>\n " +
280+ " <model fallback='allow'/>\n " +
281+ " </cpu>\n " +
282+ " <clock offset='utc'>\n " +
283+ " <timer name='rtc' tickpolicy='catchup'/>\n " +
284+ " <timer name='pit' tickpolicy='delay'/>\n " +
285+ " <timer name='hpet' present='no'/>\n " +
286+ " </clock>\n " +
287+ " <on_poweroff>destroy</on_poweroff>\n " +
288+ " <on_reboot>restart</on_reboot>\n " +
289+ " <on_crash>destroy</on_crash>\n " +
290+ " <pm>\n " +
291+ " <suspend-to-mem enabled='no'/>\n " +
292+ " <suspend-to-disk enabled='no'/>\n " +
293+ " </pm>\n " +
294+ " <devices>\n " +
295+ " <emulator>/usr/libexec/qemu-kvm</emulator>\n " +
296+ " <disk type='file' device='disk'>\n " +
297+ " <driver name='qemu' type='qcow2'/>\n " +
298+ " <source file='/var/lib/libvirt/images/ubuntu-22.04.qcow2'/>\n " +
299+ " <target dev='vda' bus='virtio'/>\n " +
300+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>\n " +
301+ " </disk>\n " +
302+ " <disk type='file' device='disk'>\n " +
303+ " <driver name='qemu' type='qcow2'/>\n " +
304+ " <source file='/var/lib/libvirt/images/testkiran.qcow2'/>\n " +
305+ " <target dev='vdb' bus='virtio'/>\n " +
306+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>\n " +
307+ " </disk>\n " +
308+ " <controller type='usb' index='0' model='ich9-ehci1'>\n " +
309+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>\n " +
310+ " </controller>\n " +
311+ " <controller type='usb' index='0' model='ich9-uhci1'>\n " +
312+ " <master startport='0'/>\n " +
313+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>\n " +
314+ " </controller>\n " +
315+ " <controller type='usb' index='0' model='ich9-uhci2'>\n " +
316+ " <master startport='2'/>\n " +
317+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>\n " +
318+ " </controller>\n " +
319+ " <controller type='usb' index='0' model='ich9-uhci3'>\n " +
320+ " <master startport='4'/>\n " +
321+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>\n " +
322+ " </controller>\n " +
323+ " <controller type='pci' index='0' model='pci-root'/>\n " +
324+ " <controller type='virtio-serial' index='0'>\n " +
325+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>\n " +
326+ " </controller>\n " +
327+ " <interface type='network'>\n " +
328+ " <mac address='52:54:00:09:73:b8'/>\n " +
329+ " <source network='default'/>\n " +
330+ " <model type='virtio'/>\n " +
331+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>\n " +
332+ " </interface>\n " +
333+ " <serial type='pty'>\n " +
334+ " <target type='isa-serial' port='0'>\n " +
335+ " <model name='isa-serial'/>\n " +
336+ " </target>\n " +
337+ " </serial>\n " +
338+ " <console type='pty'>\n " +
339+ " <target type='serial' port='0'/>\n " +
340+ " </console>\n " +
341+ " <channel type='spicevmc'>\n " +
342+ " <target type='virtio' name='com.redhat.spice.0'/>\n " +
343+ " <address type='virtio-serial' controller='0' bus='0' port='1'/>\n " +
344+ " </channel>\n " +
345+ " <input type='tablet' bus='usb'>\n " +
346+ " <address type='usb' bus='0' port='1'/>\n " +
347+ " </input>\n " +
348+ " <input type='mouse' bus='ps2'/>\n " +
349+ " <input type='keyboard' bus='ps2'/>\n " +
350+ " <graphics type='vnc' port='-1' autoport='yes'>\n " +
351+ " <listen type='address'/>\n " +
352+ " </graphics>\n " +
353+ " <graphics type='spice' autoport='yes'>\n " +
354+ " <listen type='address'/>\n " +
355+ " <image compression='off'/>\n " +
356+ " </graphics>\n " +
357+ " <sound model='ich6'>\n " +
358+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>\n " +
359+ " </sound>\n " +
360+ " <video>\n " +
361+ " <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>\n " +
362+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>\n " +
363+ " </video>\n " +
364+ " <redirdev bus='usb' type='spicevmc'>\n " +
365+ " <address type='usb' bus='0' port='2'/>\n " +
366+ " </redirdev>\n " +
367+ " <redirdev bus='usb' type='spicevmc'>\n " +
368+ " <address type='usb' bus='0' port='3'/>\n " +
369+ " </redirdev>\n " +
370+ " <memballoon model='virtio'>\n " +
371+ " <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>\n " +
372+ " </memballoon>\n " +
373+ " </devices>\n " +
374+ "</domain>" ;
375+
376+ LibvirtDomainXMLParser libvirtDomainXMLParser = new LibvirtDomainXMLParser ();
377+ try {
378+ libvirtDomainXMLParser .parseDomainXML (xml );
379+ } catch (Exception e ) {
380+ System .out .println ("Got exception " + e .getMessage ());
381+ throw e ;
382+ }
383+ }
262384}
0 commit comments