[PATCH 5/5] libxl: support HVM direct kernel boot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add support for HVM direct kernel boot in libxl.  Also add a
test to verify domXML <-> native conversions.

Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 src/libxl/libxl_conf.c                             |  9 ++++
 src/xenconfig/xen_xl.c                             | 39 ++++++++++++++++-
 .../test-fullvirt-direct-kernel-boot.cfg           | 29 +++++++++++++
 .../test-fullvirt-direct-kernel-boot.xml           | 49 ++++++++++++++++++++++
 tests/xlconfigtest.c                               |  3 ++
 5 files changed, 127 insertions(+), 2 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 9b3c949..230daec 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -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,
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 12050f3..b572587 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -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:
diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg
new file mode 100644
index 0000000..1fac3a5
--- /dev/null
+++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg
@@ -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" ]
diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.xml b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.xml
new file mode 100644
index 0000000..414f645
--- /dev/null
+++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.xml
@@ -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>
diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
index 6d4aa6d..e8b4aa9 100644
--- a/tests/xlconfigtest.c
+++ b/tests/xlconfigtest.c
@@ -216,6 +216,9 @@ mymain(void)
     DO_TEST("new-disk", 3);
     DO_TEST("spice", 3);
     DO_TEST("fullvirt-multiusb", 3);
+#ifdef LIBXL_HAVE_BUILDINFO_KERNEL
+    DO_TEST("fullvirt-direct-kernel-boot", 3);
+#endif
 
     virObjectUnref(caps);
     virObjectUnref(xmlopt);
-- 
1.8.4.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]