mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
libxl: support HVM direct kernel boot
Add support for HVM direct kernel boot in libxl. Also add a test to verify domXML <-> native conversions. Signed-off-by: Chunyan Liu <cyliu@suse.com> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
0fe504f15a
commit
13e2c22099
@ -702,6 +702,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
|
||||
if (VIR_STRDUP(b_info->u.hvm.boot, bootorder) < 0)
|
||||
return -1;
|
||||
|
||||
#ifdef LIBXL_HAVE_BUILDINFO_KERNEL
|
||||
if (VIR_STRDUP(b_info->cmdline, def->os.cmdline) < 0)
|
||||
return -1;
|
||||
if (VIR_STRDUP(b_info->kernel, def->os.kernel) < 0)
|
||||
return -1;
|
||||
if (VIR_STRDUP(b_info->ramdisk, def->os.initrd) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
if (def->emulator) {
|
||||
if (!virFileExists(def->emulator)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
|
@ -62,6 +62,7 @@ static int
|
||||
xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
|
||||
{
|
||||
size_t i;
|
||||
const char *extra, *root;
|
||||
|
||||
if (STREQ(def->os.type, "hvm")) {
|
||||
const char *boot;
|
||||
@ -76,6 +77,28 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LIBXL_HAVE_BUILDINFO_KERNEL
|
||||
if (xenConfigCopyStringOpt(conf, "kernel", &def->os.kernel) < 0)
|
||||
return -1;
|
||||
|
||||
if (xenConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0)
|
||||
return -1;
|
||||
|
||||
if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
|
||||
return -1;
|
||||
|
||||
if (xenConfigGetString(conf, "root", &root, NULL) < 0)
|
||||
return -1;
|
||||
|
||||
if (root) {
|
||||
if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0)
|
||||
return -1;
|
||||
} else {
|
||||
if (VIR_STRDUP(def->os.cmdline, extra) < 0)
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (xenConfigGetString(conf, "boot", &boot, "c") < 0)
|
||||
return -1;
|
||||
|
||||
@ -98,8 +121,6 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
|
||||
def->os.nBootDevs++;
|
||||
}
|
||||
} else {
|
||||
const char *extra, *root;
|
||||
|
||||
if (xenConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0)
|
||||
return -1;
|
||||
if (xenConfigCopyStringOpt(conf, "bootargs", &def->os.bootloaderArgs) < 0)
|
||||
@ -459,6 +480,20 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def)
|
||||
if (xenConfigSetString(conf, "builder", "hvm") < 0)
|
||||
return -1;
|
||||
|
||||
#ifdef LIBXL_HAVE_BUILDINFO_KERNEL
|
||||
if (def->os.kernel &&
|
||||
xenConfigSetString(conf, "kernel", def->os.kernel) < 0)
|
||||
return -1;
|
||||
|
||||
if (def->os.initrd &&
|
||||
xenConfigSetString(conf, "ramdisk", def->os.initrd) < 0)
|
||||
return -1;
|
||||
|
||||
if (def->os.cmdline &&
|
||||
xenConfigSetString(conf, "extra", def->os.cmdline) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < def->os.nBootDevs; i++) {
|
||||
switch (def->os.bootDevs[i]) {
|
||||
case VIR_DOMAIN_BOOT_FLOPPY:
|
||||
|
29
tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg
Normal file
29
tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg
Normal file
@ -0,0 +1,29 @@
|
||||
name = "XenGuest2"
|
||||
uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
|
||||
maxmem = 579
|
||||
memory = 394
|
||||
vcpus = 1
|
||||
pae = 1
|
||||
acpi = 1
|
||||
apic = 1
|
||||
hap = 0
|
||||
viridian = 0
|
||||
localtime = 0
|
||||
on_poweroff = "destroy"
|
||||
on_reboot = "restart"
|
||||
on_crash = "restart"
|
||||
device_model = "/usr/lib/xen/bin/qemu-system-i386"
|
||||
sdl = 0
|
||||
vnc = 1
|
||||
vncunused = 1
|
||||
vnclisten = "127.0.0.1"
|
||||
vncpasswd = "123poi"
|
||||
vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ]
|
||||
parallel = "none"
|
||||
serial = "none"
|
||||
builder = "hvm"
|
||||
kernel = "/tmp/vmlinuz"
|
||||
ramdisk = "/tmp/initrd"
|
||||
extra = "ignore_loglvl"
|
||||
boot = "d"
|
||||
disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
|
49
tests/xlconfigdata/test-fullvirt-direct-kernel-boot.xml
Normal file
49
tests/xlconfigdata/test-fullvirt-direct-kernel-boot.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<domain type='xen'>
|
||||
<name>XenGuest2</name>
|
||||
<uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>592896</memory>
|
||||
<currentMemory unit='KiB'>403456</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='xenfv'>hvm</type>
|
||||
<loader type='rom'>/usr/lib/xen/boot/hvmloader</loader>
|
||||
<kernel>/tmp/vmlinuz</kernel>
|
||||
<initrd>/tmp/initrd</initrd>
|
||||
<cmdline>ignore_loglvl</cmdline>
|
||||
<boot dev='cdrom'/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<pae/>
|
||||
</features>
|
||||
<clock offset='utc' adjustment='reset'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>restart</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/lib/xen/bin/qemu-system-i386</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<driver name='phy' type='raw'/>
|
||||
<source dev='/dev/HostVG/XenGuest2'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
</disk>
|
||||
<disk type='file' device='cdrom'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source file='/root/boot.iso'/>
|
||||
<target dev='hdc' bus='ide'/>
|
||||
<readonly/>
|
||||
</disk>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:16:3e:66:92:9c'/>
|
||||
<source bridge='xenbr1'/>
|
||||
<script path='vif-bridge'/>
|
||||
<model type='e1000'/>
|
||||
</interface>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'>
|
||||
<listen type='address' address='127.0.0.1'/>
|
||||
</graphics>
|
||||
</devices>
|
||||
</domain>
|
@ -219,6 +219,9 @@ mymain(void)
|
||||
#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
|
||||
DO_TEST("fullvirt-multiusb", 3);
|
||||
#endif
|
||||
#ifdef LIBXL_HAVE_BUILDINFO_KERNEL
|
||||
DO_TEST("fullvirt-direct-kernel-boot", 3);
|
||||
#endif
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlopt);
|
||||
|
Loading…
x
Reference in New Issue
Block a user