Daniel P. Berrange wrote:
Jeremy mentioned that it looked like libvirt wasn't able to create an
HVM domain configured to boot off cdrom, so I took a closer look at the
code and indeed the code dealing with <boot> section was both incomplete,
and just plain broken. Incomplete in so much as it never included details
of the ISO file backing the CDROM, and broken in so much as it was doing
string comparisons against the wrong variables. Digging further found
lots more work relating to creation of HVM domains so I've had a go at
writing a patch to resolve matters.
* Parsing of UUID from SEXPR assumed that the UUID fetched would always
have four '-' in the usual places. Well, when you run 'dumpxml' from
virsh the <uuid> element has the UUID encoded without any '-' chars.
If you feed this back into 'virsh create' and then once again run
'dumpxml' parsing will fail & libvirt throws errors. So this patch
allows for parsing of UUID's without '-'.
* The XML document size was limited to 1k - we just 'malloc(1000)'. While
this was enough for common cases, if someone creates lots of disk or
network devices this would overflow and libvirt return an error. So I
increased it to 4k which ought to be enough for forseeable future - in
any case my previous patch to fetch XML via the proxy is limited to 4k
in size too.
Now onto the fine details...
When converting SEXPR into XML current code is doing the following:
(boot a) -> <boot dev='/dev/fd0'/>
(boot c) -> <boot dev='hda'/>
(boot d) -> <boot dev='/dev/cdrom'/>
This is rather inconsistent - the 'hda' is intended to map to an entry
in <devices> block. The '/dev/fd0' and '/dev/cdrom' entries did not
map to anything.
Meanwhile, when converting from XML to SXEXPR it is doing the following
<boot dev='hda'/> -> (boot a)
<boot dev='hdd'/> -> (boot d)
<boot dev='*'/> -> (boot c)
Obviously this sucks because these processes should be matching each
other.
Secondly, the (image (hvm....)) SEXPR has three entries for defining
the ISO / disk image file backing the CDROM / Floppy devices. These
were just being ignored, rather than turned into <disk> entries within
the <devices> block. Similarly there was no way to express a <disk>
entry for CDROM/Floppy in the XML when creating a domain.
The upshot of all this is that although the last release of libvirt
included HVM support it was basically unusable for domain creation
unless you were using HD to boot. The XML returned was also incorrect.
Now the good news. Since it was sooo broken, we can fix without worrying
about XML compatability since there is no way any application could be
relying on it in its current state.
Sorry to have dumped the HVM code in such crude shape. I wanted to
finish the work when returning from vacation in July but became
distracted with other tasks :-(, and then went on another vacation last
week :-). The patch I sent in June only worked for the most basic
configurations. Perhaps I wasn't clear enough about the state of the
patch when posted.
BTW, I like the resulting patch from this thread. My apologies again
for not following through on the HVM support.
Regards,
Jim